btrfs-progs: check: properly exclude leaves for lowmem mode

The lowmem mode excludes all referenced blocks from the allocator in
order to avoid accidentally overwriting blocks while fixing the file
system.  However for leaves it wouldn't exclude anything, it would just
pin them down, which gets cleaned up on transaction commit.  We're safe
for the first modification, but subsequent modifications could blow up
in our face.  Fix this by properly excluding leaves as well as all of
the nodes.

Reviewed-by: Su Yue <l@damenly.su>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Josef Bacik 2021-01-05 16:40:18 -05:00 committed by David Sterba
parent be6710f89d
commit 3f467adb34

View File

@ -667,8 +667,12 @@ static int traverse_tree_blocks(struct extent_buffer *eb, int tree_root, int pin
/* If we aren't the tree root don't read the block */
if (level == 1 && !tree_root) {
if (pin)
btrfs_pin_extent(gfs_info, bytenr,
gfs_info->nodesize);
else
set_extent_dirty(tree, bytenr,
gfs_info->nodesize);
continue;
}