Btrfs: Fix ordering of key field checks in btrfs_previous_item
authorYan Zheng <zheng.yan@oracle.com>
Fri, 24 Jul 2009 15:06:53 +0000 (11:06 -0400)
committerChris Mason <chris.mason@oracle.com>
Fri, 24 Jul 2009 15:22:47 +0000 (11:22 -0400)
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>
fs/btrfs/ctree.c

index 91572091c0a48e4afdb38e65662a2a68f77f910c..978449af4ccde556423d8ddbaba7f867599bd578 100644 (file)
@@ -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;