* [PATCH] btrfs: fix bytes_may_use leak in move_existing_remap()
@ 2026-03-23 14:36 Mark Harmstone
2026-04-07 21:27 ` Boris Burkov
0 siblings, 1 reply; 2+ messages in thread
From: Mark Harmstone @ 2026-03-23 14:36 UTC (permalink / raw)
To: linux-btrfs; +Cc: Mark Harmstone
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 <mark@harmstone.com>
Fixes: bbea42dfb91f ("btrfs: move existing remaps before relocating block group")
---
fs/btrfs/relocation.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 1c42c5180bddd5..3d1756b6116246 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -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;
--
2.52.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] btrfs: fix bytes_may_use leak in move_existing_remap()
2026-03-23 14:36 [PATCH] btrfs: fix bytes_may_use leak in move_existing_remap() Mark Harmstone
@ 2026-04-07 21:27 ` Boris Burkov
0 siblings, 0 replies; 2+ messages in thread
From: Boris Burkov @ 2026-04-07 21:27 UTC (permalink / raw)
To: Mark Harmstone; +Cc: linux-btrfs
On Mon, Mar 23, 2026 at 02:36:14PM +0000, Mark Harmstone wrote:
> 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 <mark@harmstone.com>
Reviewed-by: Boris Burkov <boris@bur.io>
> Fixes: bbea42dfb91f ("btrfs: move existing remaps before relocating block group")
> ---
> fs/btrfs/relocation.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 1c42c5180bddd5..3d1756b6116246 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -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;
>
> --
> 2.52.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-07 21:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23 14:36 [PATCH] btrfs: fix bytes_may_use leak in move_existing_remap() Mark Harmstone
2026-04-07 21:27 ` Boris Burkov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.