diff options
author | Filipe David Borba Manana <fdmanana@gmail.com> | 2013-10-15 03:12:27 +0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2013-11-12 07:02:26 +0400 |
commit | e8b0d724d596f2ac1264ad830a04ef8e415be956 (patch) | |
tree | ffe440a82656dc8d50b4234d497e8db7a31d47e0 /fs/btrfs/ctree.c | |
parent | e93ae26fe1123e9077e79cc7af8a0d42adf4812f (diff) | |
download | linux-e8b0d724d596f2ac1264ad830a04ef8e415be956.tar.xz |
Btrfs: fix btrfs_prev_leaf() previous key computation
If we decrement the key type, we must reset its offset to the largest
possible offset (u64)-1. If we decrement the key's objectid, then we
must reset the key's type and offset to their largest possible values,
(u8)-1 and (u64)-1 respectively. Not doing so can make us miss an
items in the tree.
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r-- | fs/btrfs/ctree.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 8f3d6f893585..a749121203df 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -4827,14 +4827,18 @@ static int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path) btrfs_item_key_to_cpu(path->nodes[0], &key, 0); - if (key.offset > 0) + if (key.offset > 0) { key.offset--; - else if (key.type > 0) + } else if (key.type > 0) { key.type--; - else if (key.objectid > 0) + key.offset = (u64)-1; + } else if (key.objectid > 0) { key.objectid--; - else + key.type = (u8)-1; + key.offset = (u64)-1; + } else { return 1; + } btrfs_release_path(path); ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); |