Some block rsv fixes
cover Some block rsv fixes
Hello,
Nikolay has noticed that -o enospc_debug was getting some warnings in btrfs_use_block_rsv() on some tests. I dug into them and one class is easy to fix as it's a straight regression. The other one is going to require some more debugging, so in the meantime here's the two patches I have so far that can be merged. The first is just to make my life easier when debugging these problems, and the second is the actual regression fix. It should probably be tagged for stable as well since the regression was backported to stable. Thanks,
Josef
Josef Bacik (2):
btrfs: print the block rsv type when we fail our reservation
btrfs: fix min reserved size calculation in merge_reloc_root
fs/btrfs/block-rsv.c | 3 ++- fs/btrfs/relocation.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/2 btrfs: print the block rsv type when we fail our reservation
To help with debugging, print the type of the block rsv when we fail to use our target block rsv in btrfs_use_block_rsv.
--- fs/btrfs/block-rsv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/block-rsv.c +2 -1
@@ -519,7 +519,8 @@ struct btrfs_block_rsv *btrfs_use_block_rsv(struct btrfs_trans_handle *trans, /*DEFAULT_RATELIMIT_BURST*/ 1);if (__ratelimit (&_rs))WARN (1 ,KERN_DEBUG -"BTRFS: block rsv returned %d\n" , ret); +"BTRFS: block rsv %d returned %d\n" , + block_rsv->type, ret); } try_reserve: ret = btrfs_reserve_metadata_bytes(root, block_rsv, blocksize,
Signature · 1 line
2.26.2
PATCH 2/2 btrfs: fix min reserved size calculation in merge_reloc_root
In reply to Josef BacikThe 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.
44d354abf33e ("btrfs: relocation: review the call sites which can be interrupted by signal")
--- fs/btrfs/relocation.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/relocation.c +2 -1
@@ -1696,7 +1696,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 ; + min_reserved = fs_info->nodesize * + (btrfs_root_level (root_item) +1 ) *2 ;memset (&next_key,0 ,sizeof (next_key));while (1 ) {
Signature · 1 line
2.26.2