btrfs: fix bytes_may_use leak in move_existing_remap()
PATCH 1/1 btrfs: fix bytes_may_use leak in move_existing_remap()
If the call to btrfs_reserve_extent() in move_existing_remap() returns a smaller extent than we asked for, currently we're not undoing the bytes_may_use change that we made. Fix this by calling btrfs_space_info_update_bytes_may_use() again for the difference.
Signed-off-by Mark Harmstone <[email protected]>
Fixes bbea42dfb91f ("btrfs: move existing remaps before relocating block group")
--- fs/btrfs/relocation.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/btrfs/relocation.c +6 -0
@@ -4174,6 +4174,12 @@ static int move_existing_remap(struct btrfs_fs_info *fs_info,return ret; } +if (ins.offset < length) { +spin_lock (&sinfo->lock); +btrfs_space_info_update_bytes_may_use (sinfo, ins.offset - length); +spin_unlock (&sinfo->lock); + } + dest_addr = ins.objectid; dest_length = ins.offset;
Signature · 1 line
2.52.0
Quoted 6 lines · Mark Harmstone
If the call to
btrfs_reserve_extent()inmove_existing_remap()returns a smaller extent than we asked for, currently we're not undoing thebytes_may_usechange that we made. Fix this by callingbtrfs_space_info_update_bytes_may_use()again for the difference.Signed-off-by Mark Harmstone <[email protected]>
Reviewed-by Boris Burkov <[email protected]>
Quoted 25 lines
Fixes bbea42dfb91f ("btrfs: move existing remaps before relocating block group")--- fs/btrfs/relocation.c | 6 ++++++ 1 file changed, 6 insertions(+)fs/btrfs/relocation.c +6
-0@@ -4174,6 +4174,12 @@ static int move_existing_remap(struct btrfs_fs_info *fs_info,return ret; } +if (ins.offset < length) { +spin_lock (&sinfo->lock); +btrfs_space_info_update_bytes_may_use (sinfo, ins.offset - length); +spin_unlock (&sinfo->lock); + } + dest_addr = ins.objectid; dest_length = ins.offset;Signature · 1 line
2.52.0