From 3f467adb34adcb28b01281cafb9d5d91f6045b9c Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Tue, 5 Jan 2021 16:40:18 -0500 Subject: [PATCH] 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 Signed-off-by: Josef Bacik Signed-off-by: David Sterba --- check/mode-common.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/check/mode-common.c b/check/mode-common.c index a6489191..ef77b060 100644 --- a/check/mode-common.c +++ b/check/mode-common.c @@ -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) { - btrfs_pin_extent(gfs_info, bytenr, - gfs_info->nodesize); + if (pin) + btrfs_pin_extent(gfs_info, bytenr, + gfs_info->nodesize); + else + set_extent_dirty(tree, bytenr, + gfs_info->nodesize); continue; }