From: Dave Chinner <david@fromorbit.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/4] xfs: buffer pins need to hold a buffer reference
Date: Thu, 18 May 2023 08:24:20 +1000 [thread overview]
Message-ID: <ZGVUFJ8uXSUreTPf@dread.disaster.area> (raw)
In-Reply-To: <ZGTPj0ov+95jjpuH@infradead.org>
On Wed, May 17, 2023 at 05:58:55AM -0700, Christoph Hellwig wrote:
> On Wed, May 17, 2023 at 10:04:46AM +1000, Dave Chinner wrote:
> > To fix this, we need to ensure that buffer existence extends beyond
> > the BLI reference count checks and until the unpin processing is
> > complete. This implies that a buffer pin operation must also take a
> > buffer reference to ensure that the buffer cannot be freed until the
> > buffer unpin processing is complete.
>
> Yeah. I wonder why we haven't done this from the very beginning..
Likely because the whole BLI lifecycle is completely screwed up and
nobody has had the time to understand it fully and fix it properly.
> > + /*
> > + * Nothing to do but drop the buffer pin reference if the BLI is
> > + * still active
> > + */
>
> Nit: this block comment is indentented by an extra space.
>
> > + if (!freed) {
> > + xfs_buf_rele(bp);
> > return;
> > + }
> >
> > if (stale) {
>
> Nit: this is the only use of the stale variable now, so we might
> as well just drop it.
Actually, after we've dropped the bli reference, it isn't safe to
reference the bli unless we know the buffer is stale. In this case,
we know the bli still exists because the buffer has been locked
since it was marked stale. However, for the other cases the BLI
could be freed from under us as it's reference count is zero and so
the next call to xfs_buf_item_relse() will free it no matter where
it comes from.
The reference counting around BLIs a total mess - this patch just
gets rid of one landmine but there's still plenty more in this code
that need to be untangled.
> > ASSERT(bip->bli_flags & XFS_BLI_STALE);
>
> .. which then also clearly shows this ASSERT is pointless now.
*nod*
> Otherwise looks good:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
Thanks.
-Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2023-05-17 22:24 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-17 0:04 xfs: bug fixes for 6.4-rcX Dave Chinner
2023-05-17 0:04 ` [PATCH 1/4] xfs: buffer pins need to hold a buffer reference Dave Chinner
2023-05-17 1:26 ` Darrick J. Wong
2023-05-17 12:58 ` Christoph Hellwig
2023-05-17 22:24 ` Dave Chinner [this message]
2023-05-17 0:04 ` [PATCH 2/4] xfs: restore allocation trylock iteration Dave Chinner
2023-05-17 1:11 ` Darrick J. Wong
2023-05-17 12:59 ` Christoph Hellwig
2023-05-17 0:04 ` [PATCH 3/4] xfs: defered work could create precommits Dave Chinner
2023-05-17 1:20 ` Darrick J. Wong
2023-05-17 1:44 ` Dave Chinner
2023-06-01 15:01 ` Christoph Hellwig
2023-05-17 0:04 ` [PATCH 4/4] xfs: fix AGF vs inode cluster buffer deadlock Dave Chinner
2023-05-17 1:26 ` Darrick J. Wong
2023-05-17 1:47 ` Dave Chinner
2023-06-01 1:51 ` Dave Chinner
2023-06-01 14:38 ` Darrick J. Wong
2023-06-01 15:12 ` Christoph Hellwig
2023-06-25 2:58 ` Matthew Wilcox
2023-06-25 22:34 ` Dave Chinner
2023-05-17 7:07 ` xfs: bug fixes for 6.4-rcX Amir Goldstein
2023-05-17 11:34 ` Dave Chinner
2023-05-17 12:48 ` Amir Goldstein
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=ZGVUFJ8uXSUreTPf@dread.disaster.area \
--to=david@fromorbit.com \
--cc=hch@infradead.org \
--cc=linux-xfs@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