]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
btrfs: Bypass unrelated items before accessing its contents in scrub
authorZhao Lei <zhaolei@cn.fujitsu.com>
Wed, 22 Jul 2015 05:14:48 +0000 (13:14 +0800)
committerChris Mason <clm@fb.com>
Sun, 9 Aug 2015 14:07:12 +0000 (07:07 -0700)
When we access extent_root in scrub_stripe() and
scrub_raid56_parity(), we need bypass unrelated tree item firstly
before using its contents to do other condition.

It is not a bug fix, only making code sequence in logic.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/scrub.c

index b03dd10e1d25873551e39dcd523043f433498b3e..fadf5fcd930676fd27d708b081d6c87d7773436b 100644 (file)
@@ -2856,6 +2856,10 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx,
                        }
                        btrfs_item_key_to_cpu(l, &key, slot);
 
+                       if (key.type != BTRFS_EXTENT_ITEM_KEY &&
+                           key.type != BTRFS_METADATA_ITEM_KEY)
+                               goto next;
+
                        if (key.type == BTRFS_METADATA_ITEM_KEY)
                                bytes = root->nodesize;
                        else
@@ -2864,10 +2868,6 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx,
                        if (key.objectid + bytes <= logic_start)
                                goto next;
 
-                       if (key.type != BTRFS_EXTENT_ITEM_KEY &&
-                           key.type != BTRFS_METADATA_ITEM_KEY)
-                               goto next;
-
                        if (key.objectid >= logic_end) {
                                stop_loop = 1;
                                break;
@@ -3193,6 +3193,10 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
                        }
                        btrfs_item_key_to_cpu(l, &key, slot);
 
+                       if (key.type != BTRFS_EXTENT_ITEM_KEY &&
+                           key.type != BTRFS_METADATA_ITEM_KEY)
+                               goto next;
+
                        if (key.type == BTRFS_METADATA_ITEM_KEY)
                                bytes = root->nodesize;
                        else
@@ -3201,10 +3205,6 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
                        if (key.objectid + bytes <= logical)
                                goto next;
 
-                       if (key.type != BTRFS_EXTENT_ITEM_KEY &&
-                           key.type != BTRFS_METADATA_ITEM_KEY)
-                               goto next;
-
                        if (key.objectid >= logical + map->stripe_len) {
                                /* out of this device extent */
                                if (key.objectid >= logic_end)