aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2020-10-26 13:58:49 -0400
committerJosef Bacik <josef@toxicpanda.com>2020-10-28 16:07:50 -0400
commitef0d03f6b6a5993e13a61e5537d5a9d31e4fe059 (patch)
tree8e87134811b8dbacc8f9b4efda3aaeebcfd9c75c
parent51c81cf092eb9820a3927c891329916d89ac38d1 (diff)
downloadbtrfs-next-relocation.tar.gz
btrfs: fix min reserved size calculation in merge_reloc_rootrelocation
The minimum reserve size was adjusted to take into account the height of the tree we are merging, however we can have a root with a level == 0. What we want is root_level + 1 to get the number of nodes we may have to cow. This fixes the enospc_debug warning pops with btrfs/101. Fixes: 44d354abf33e ("btrfs: relocation: review the call sites which can be interrupted by signal") Signed-off-by: Josef Bacik <josef@toxicpanda.com>
-rw-r--r--fs/btrfs/relocation.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 3602806d71bd4..9ba92d86da0bf 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1648,6 +1648,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
struct btrfs_root_item *root_item;
struct btrfs_path *path;
struct extent_buffer *leaf;
+ int reserve_level;
int level;
int max_level;
int replaced = 0;
@@ -1696,7 +1697,8 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
* Thus the needed metadata size is at most root_level * nodesize,
* and * 2 since we have two trees to COW.
*/
- min_reserved = fs_info->nodesize * btrfs_root_level(root_item) * 2;
+ reserve_level = max_t(int, 1, btrfs_root_level(root_item));
+ min_reserved = fs_info->nodesize * reserve_level * 2;
memset(&next_key, 0, sizeof(next_key));
while (1) {