Skip to content

Commit

Permalink
Btrfs: Fix ordering of key field checks in btrfs_previous_item
Browse files Browse the repository at this point in the history
Check objectid of item before checking the item type, otherwise we may return
zero for a key that is actually too low.

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Yan Zheng authored and Chris Mason committed Jul 24, 2009
1 parent 1fcbac5 commit 0a4eefb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/btrfs/ctree.c
Original file line number Diff line number Diff line change
Expand Up @@ -4296,10 +4296,10 @@ int btrfs_previous_item(struct btrfs_root *root,
path->slots[0]--;

btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
if (found_key.type == type)
return 0;
if (found_key.objectid < min_objectid)
break;
if (found_key.type == type)
return 0;
if (found_key.objectid == min_objectid &&
found_key.type < type)
break;
Expand Down

0 comments on commit 0a4eefb

Please sign in to comment.