btrfs-progs: check: fix false alert on dropped leaf in lowmem mode

For btrfs-progs test case 021-partially-dropped-snapshot-case, if the
first leaf is already dropped, btrfs check low-memory mode will report
false alert:

checking fs roots
checksum verify failed on 29917184 found E4E3BDB6 wanted 00000000
checksum verify failed on 29917184 found E4E3BDB6 wanted 00000000
checksum verify failed on 29917184 found E4E3BDB6 wanted 00000000
checksum verify failed on 29917184 found E4E3BDB6 wanted 00000000

This is caused by we are calling check_fs_first_inode() function,
unlike the rest part of check_fs_root_v2(), it doesn't have enough check
on dropping progress, and caused the false alert.

Fix it by checking dropping progress before searching slot.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
master
Qu Wenruo 2017-01-18 13:21:07 +08:00 committed by David Sterba
parent 0e95fff4ff
commit b73d67f20a
1 changed files with 8 additions and 1 deletions

View File

@ -4947,11 +4947,18 @@ static int check_fs_first_inode(struct btrfs_root *root, unsigned int ext_ref)
int err = 0;
int ret;
btrfs_init_path(&path);
key.objectid = BTRFS_FIRST_FREE_OBJECTID;
key.type = BTRFS_INODE_ITEM_KEY;
key.offset = 0;
/* For root being dropped, we don't need to check first inode */
if (btrfs_root_refs(&root->root_item) == 0 &&
btrfs_disk_key_objectid(&root->root_item.drop_progress) >=
key.objectid)
return 0;
btrfs_init_path(&path);
ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0);
if (ret < 0)
goto out;