aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/scrub.c
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2014-07-23 23:37:08 -0400
committerChris Mason <clm@fb.com>2014-09-17 16:37:43 -0400
commit17a9be2f28595945ec9bfac0dd15b86891c1f1de (patch)
tree6d7e96a2a34af75da646b0dd4cd32e5882f60b9d /fs/btrfs/scrub.c
parent2fad4e83e12591eb3bd213875b9edc2d18e93383 (diff)
Btrfs: fix wrong fsid check of scrub
All the metadata in the seed devices has the same fsid as the fsid of the seed filesystem which is on the seed device, so we should check them by the current filesystem. 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>
Diffstat (limited to 'fs/btrfs/scrub.c')
-rw-r--r--fs/btrfs/scrub.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 4ae1c5feccbe..d1aa95a4f843 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -1359,6 +1359,16 @@ static void scrub_recheck_block(struct btrfs_fs_info *fs_info,
1359 return; 1359 return;
1360} 1360}
1361 1361
1362static inline int scrub_check_fsid(u8 fsid[],
1363 struct scrub_page *spage)
1364{
1365 struct btrfs_fs_devices *fs_devices = spage->dev->fs_devices;
1366 int ret;
1367
1368 ret = memcmp(fsid, fs_devices->fsid, BTRFS_UUID_SIZE);
1369 return !ret;
1370}
1371
1362static void scrub_recheck_block_checksum(struct btrfs_fs_info *fs_info, 1372static void scrub_recheck_block_checksum(struct btrfs_fs_info *fs_info,
1363 struct scrub_block *sblock, 1373 struct scrub_block *sblock,
1364 int is_metadata, int have_csum, 1374 int is_metadata, int have_csum,
@@ -1378,7 +1388,7 @@ static void scrub_recheck_block_checksum(struct btrfs_fs_info *fs_info,
1378 h = (struct btrfs_header *)mapped_buffer; 1388 h = (struct btrfs_header *)mapped_buffer;
1379 1389
1380 if (sblock->pagev[0]->logical != btrfs_stack_header_bytenr(h) || 1390 if (sblock->pagev[0]->logical != btrfs_stack_header_bytenr(h) ||
1381 memcmp(h->fsid, fs_info->fsid, BTRFS_UUID_SIZE) || 1391 !scrub_check_fsid(h->fsid, sblock->pagev[0]) ||
1382 memcmp(h->chunk_tree_uuid, fs_info->chunk_tree_uuid, 1392 memcmp(h->chunk_tree_uuid, fs_info->chunk_tree_uuid,
1383 BTRFS_UUID_SIZE)) { 1393 BTRFS_UUID_SIZE)) {
1384 sblock->header_error = 1; 1394 sblock->header_error = 1;
@@ -1749,7 +1759,7 @@ static int scrub_checksum_tree_block(struct scrub_block *sblock)
1749 if (sblock->pagev[0]->generation != btrfs_stack_header_generation(h)) 1759 if (sblock->pagev[0]->generation != btrfs_stack_header_generation(h))
1750 ++fail; 1760 ++fail;
1751 1761
1752 if (memcmp(h->fsid, fs_info->fsid, BTRFS_UUID_SIZE)) 1762 if (!scrub_check_fsid(h->fsid, sblock->pagev[0]))
1753 ++fail; 1763 ++fail;
1754 1764
1755 if (memcmp(h->chunk_tree_uuid, fs_info->chunk_tree_uuid, 1765 if (memcmp(h->chunk_tree_uuid, fs_info->chunk_tree_uuid,
@@ -1788,8 +1798,6 @@ static int scrub_checksum_super(struct scrub_block *sblock)
1788{ 1798{
1789 struct btrfs_super_block *s; 1799 struct btrfs_super_block *s;
1790 struct scrub_ctx *sctx = sblock->sctx; 1800 struct scrub_ctx *sctx = sblock->sctx;
1791 struct btrfs_root *root = sctx->dev_root;
1792 struct btrfs_fs_info *fs_info = root->fs_info;
1793 u8 calculated_csum[BTRFS_CSUM_SIZE]; 1801 u8 calculated_csum[BTRFS_CSUM_SIZE];
1794 u8 on_disk_csum[BTRFS_CSUM_SIZE]; 1802 u8 on_disk_csum[BTRFS_CSUM_SIZE];
1795 struct page *page; 1803 struct page *page;
@@ -1814,7 +1822,7 @@ static int scrub_checksum_super(struct scrub_block *sblock)
1814 if (sblock->pagev[0]->generation != btrfs_super_generation(s)) 1822 if (sblock->pagev[0]->generation != btrfs_super_generation(s))
1815 ++fail_gen; 1823 ++fail_gen;
1816 1824
1817 if (memcmp(s->fsid, fs_info->fsid, BTRFS_UUID_SIZE)) 1825 if (!scrub_check_fsid(s->fsid, sblock->pagev[0]))
1818 ++fail_cor; 1826 ++fail_cor;
1819 1827
1820 len = BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE; 1828 len = BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE;