Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

Fixes: bbea42dfb91f ("btrfs: move existing remaps before relocating block group")
Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Mark Harmstone <mark@harmstone.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Mark Harmstone and committed by
David Sterba
68a13501 fc3d5328

+6
+6
fs/btrfs/relocation.c
··· 4174 4174 return ret; 4175 4175 } 4176 4176 4177 + if (ins.offset < length) { 4178 + spin_lock(&sinfo->lock); 4179 + btrfs_space_info_update_bytes_may_use(sinfo, ins.offset - length); 4180 + spin_unlock(&sinfo->lock); 4181 + } 4182 + 4177 4183 dest_addr = ins.objectid; 4178 4184 dest_length = ins.offset; 4179 4185