diff mbox

[04/10] Btrfs: fix wrong generation check of super block on a seed device

Message ID 1406173035-29478-4-git-send-email-miaox@cn.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Miao Xie July 24, 2014, 3:37 a.m. UTC
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>
---
 fs/btrfs/scrub.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

David Sterba July 24, 2014, 1:25 p.m. UTC | #1
On Thu, Jul 24, 2014 at 11:37:09AM +0800, Miao Xie wrote:
> 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>

Good catch.

Reviewed-by: David Sterba <dsterba@suse.cz>
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 9a81874e..98b9f8e 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -2835,7 +2835,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);