Commit 9b882453 authored by Mark Harmstone's avatar Mark Harmstone Committed by David Sterba
Browse files

btrfs: fix bytes_may_use leak in do_remap_reloc_trans()



If the call to btrfs_reserve_extent() in do_remap_reloc_trans() 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: fd6594b1 ("btrfs: replace identity remaps with actual remaps when doing relocations")
Reviewed-by: default avatarBoris Burkov <boris@bur.io>
Signed-off-by: default avatarMark Harmstone <mark@harmstone.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 68a13501
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -5006,6 +5006,12 @@ static int do_remap_reloc_trans(struct btrfs_fs_info *fs_info,
		return ret;
	}

	if (ins.offset < remap_length) {
		spin_lock(&sinfo->lock);
		btrfs_space_info_update_bytes_may_use(sinfo, ins.offset - remap_length);
		spin_unlock(&sinfo->lock);
	}

	made_reservation = true;

	new_addr = ins.objectid;