From: Boris Burkov <boris@bur.io>
To: Mark Harmstone <mark@harmstone.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: fix bytes_may_use leak in do_remap_reloc_trans()
Date: Tue, 7 Apr 2026 14:26:58 -0700 [thread overview]
Message-ID: <20260407212658.GA1564178@zen.localdomain> (raw)
In-Reply-To: <20260323143704.119969-1-mark@harmstone.com>
On Mon, Mar 23, 2026 at 02:36:51PM +0000, Mark Harmstone wrote:
> 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.
>
> Signed-off-by: Mark Harmstone <mark@harmstone.com>
Reviewed-by: Boris Burkov <boris@bur.io>
> Fixes: fd6594b1446c ("btrfs: replace identity remaps with actual remaps when doing relocations")
> ---
> fs/btrfs/relocation.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 1c42c5180bddd5..c0bd6db6011965 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -5000,6 +5000,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;
> --
> 2.52.0
>
prev parent reply other threads:[~2026-04-07 21:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-23 14:36 [PATCH] btrfs: fix bytes_may_use leak in do_remap_reloc_trans() Mark Harmstone
2026-04-07 21:26 ` Boris Burkov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260407212658.GA1564178@zen.localdomain \
--to=boris@bur.io \
--cc=linux-btrfs@vger.kernel.org \
--cc=mark@harmstone.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox