]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Btrfs: fix wrong generation check of super block on a seed device
authorMiao Xie <miaox@cn.fujitsu.com>
Thu, 24 Jul 2014 03:37:09 +0000 (11:37 +0800)
committerChris Mason <clm@fb.com>
Wed, 17 Sep 2014 20:37:44 +0000 (13:37 -0700)
The super block generation of the seed devices is not the same as the
filesystem which sprouted from them because we don't update the super
block on the seed devices when we change that new filesystem. So we
should not use the generation of that new filesystem to check the super
block generation on the seed devices, Fix it.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/scrub.c

index d1aa95a4f843a76d7e85993754ca905e70df502d..72c8981e7c0a8c09b6fc2b2e3d6cd908a50db226 100644 (file)
@@ -2832,7 +2832,11 @@ static noinline_for_stack int scrub_supers(struct scrub_ctx *sctx,
        if (test_bit(BTRFS_FS_STATE_ERROR, &root->fs_info->fs_state))
                return -EIO;
 
-       gen = root->fs_info->last_trans_committed;
+       /* Seed devices of a new filesystem has their own generation. */
+       if (scrub_dev->fs_devices != root->fs_info->fs_devices)
+               gen = scrub_dev->generation;
+       else
+               gen = root->fs_info->last_trans_committed;
 
        for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
                bytenr = btrfs_sb_offset(i);