From: Leo Martins <loemra.dev@gmail.com>
To: David Sterba <dsterba@suse.cz>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH] btrfs: take delayed_node mutex when releasing item
Date: Wed, 12 Nov 2025 09:03:55 -0800 [thread overview]
Message-ID: <20251112170401.506658-1-loemra.dev@gmail.com> (raw)
In-Reply-To: <20251112070925.GD13846@twin.jikos.cz>
On Wed, 12 Nov 2025 08:09:25 +0100 David Sterba <dsterba@suse.cz> wrote:
> On Tue, Nov 11, 2025 at 04:22:57PM -0800, Leo Martins wrote:
> > The error path in btrfs_delete_delayed_dir_index does not take
> > the delayed_node mutex when releasing delayed item.
> > btrfs_release_delayed_item -> __btrfs_remove_delayed_item which
> > has lockdep_assert_held(&delayed_node->mutex)
> >
> > Fix this by taking the mutex when releasing.
> >
> > Fixes: 933c22a7512c ("btrfs: delayed-inode: Kill the BUG_ON() in btrfs_delete_delayed_dir_index()")
> > Signed-off-by: Leo Martins <loemra.dev@gmail.com>
> > ---
> > fs/btrfs/delayed-inode.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
> > index e77a597580c5..30dd067e2db3 100644
> > --- a/fs/btrfs/delayed-inode.c
> > +++ b/fs/btrfs/delayed-inode.c
> > @@ -1662,7 +1662,9 @@ int btrfs_delete_delayed_dir_index(struct btrfs_trans_handle *trans,
> > btrfs_err(trans->fs_info,
> > "metadata reservation failed for delayed dir item deletion, index: %llu, root: %llu, inode: %llu, error: %d",
> > index, btrfs_root_id(node->root), node->inode_id, ret);
> > + mutex_lock(&node->mutex);
> > btrfs_release_delayed_item(item);
> > + mutex_unlock(&node->mutex);
>
> I don't think it's needed, the item has been just allocated but not yet
> added to the rbtree (__btrfs_add_delayed_item() a few lines below).
>
> In btrfs_release_delayed_item() there's a check if the item is in the
> rbtree, if not then nothing is done. Otherwise the lockdep assertion is
> checked, and the locking would be needed.
Whoops, you're right, good catch.
prev parent reply other threads:[~2025-11-12 17:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-12 0:22 [PATCH] btrfs: take delayed_node mutex when releasing item Leo Martins
2025-11-12 7:09 ` David Sterba
2025-11-12 17:03 ` Leo Martins [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=20251112170401.506658-1-loemra.dev@gmail.com \
--to=loemra.dev@gmail.com \
--cc=dsterba@suse.cz \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
/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