From: Boris Burkov <boris@bur.io>
To: Sun YangKai <sunk67188@gmail.com>
Cc: linux-btrfs@vger.kernel.org, Chris Mason <clm@meta.com>
Subject: Re: [PATCH] btrfs: hold space_info->lock when clearing periodic reclaim ready
Date: Mon, 9 Feb 2026 09:10:55 -0800 [thread overview]
Message-ID: <20260209171032.GA216489@zen.localdomain> (raw)
In-Reply-To: <20260209130248.29418-1-sunk67188@gmail.com>
On Mon, Feb 09, 2026 at 08:53:39PM +0800, Sun YangKai wrote:
> btrfs_set_periodic_reclaim_ready() requires space_info->lock to be held,
> as enforced by lockdep_assert_held(). However, btrfs_reclaim_sweep() was
> calling it after do_reclaim_sweep() returns, at which point
> space_info->lock is no longer held.
>
> Fix this by explicitly acquiring space_info->lock before clearing the
> periodic reclaim ready flag in btrfs_reclaim_sweep().
>
> Fixes: 19eff93dc738 ("btrfs: fix periodic reclaim condition")
> Reported-by: Chris Mason <clm@meta.com>
> Closes: https://lore.kernel.org/linux-btrfs/20260208182556.891815-1-clm@meta.com/
> Signed-off-by: Sun YangKai <sunk67188@gmail.com>
Reviewed-by: Boris Burkov <boris@bur.io>
> ---
> fs/btrfs/space-info.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
> index 1dd65fae6349..931f0dc02b95 100644
> --- a/fs/btrfs/space-info.c
> +++ b/fs/btrfs/space-info.c
> @@ -2205,8 +2205,11 @@ void btrfs_reclaim_sweep(const struct btrfs_fs_info *fs_info)
> if (!btrfs_should_periodic_reclaim(space_info))
> continue;
> for (raid = 0; raid < BTRFS_NR_RAID_TYPES; raid++) {
> - if (do_reclaim_sweep(space_info, raid))
> + if (do_reclaim_sweep(space_info, raid)) {
> + spin_lock(&space_info->lock);
> btrfs_set_periodic_reclaim_ready(space_info, false);
> + spin_unlock(&space_info->lock);
> + }
> }
> }
> }
> --
> 2.52.0
>
next prev parent reply other threads:[~2026-02-09 17:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-09 12:53 [PATCH] btrfs: hold space_info->lock when clearing periodic reclaim ready Sun YangKai
2026-02-09 17:10 ` Boris Burkov [this message]
2026-02-24 17:06 ` David Sterba
2026-02-26 8:03 ` Sun YangKai
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=20260209171032.GA216489@zen.localdomain \
--to=boris@bur.io \
--cc=clm@meta.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=sunk67188@gmail.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