From: Brian Foster <bfoster@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Carlos Maiolino <cem@kernel.org>,
"Darrick J. Wong" <djwong@kernel.org>,
linux-xfs@vger.kernel.org
Subject: Re: [PATCH 02/12] xfs: consolidate buffer locking in xfs_buf_get_map
Date: Fri, 17 Jul 2026 10:13:10 -0400 [thread overview]
Message-ID: <alo4doLYG7BzuCfO@bfoster> (raw)
In-Reply-To: <20260717085950.GA32056@lst.de>
On Fri, Jul 17, 2026 at 10:59:50AM +0200, Christoph Hellwig wrote:
> On Thu, Jul 16, 2026 at 09:12:50AM -0400, Brian Foster wrote:
> > > - /*
> > > - * A new buffer is held and locked by the owner. This ensures that the
> > > - * buffer is owned by the caller and racing RCU lookups right after
> > > - * inserting into the hash table are safe (and will have to wait for
> > > - * the unlock to do anything non-trivial).
> > > - */
> > > lockref_init(&bp->b_lockref);
> > > - sema_init(&bp->b_sema, 0); /* held, no waiters */
> > > + sema_init(&bp->b_sema, 1); /* unlocked */
> >
> > Maybe I'm missing something, but I thought the point of the locked init
> > was to ensure that the allocator owns the buffer and can't end up
> > blocking on the lock with a racing lookup. I.e., the buffer is locked
> > before it becomes available for external lookup. Do we plan to do that
> > another way, or are we just dropping that assumption?
>
> The comment has been stale for a while. b_sema is not involved in
> lookup synchronization in any way. Only the lockref is needed to actually
> get a stable buffer reference. Once we have a stable buffer reference,
> b_sema is used to protect again multiple readers trying to actually
> read the data (for xfs_buf_read*), but we don't care if that is done
> by the thread that allocated the buffer or not.
>
Hm, Ok. I read the comment as wanting to guarantee that the allocator
gets first crack at the buffer lock, but looking at it again it says it
ensures "racing RCU lookups right after inserting into the hash table
are safe," and indeed that seems to be a little different.
I see that you're intentionally separating out the lookup from the buf
data locking, but it does still look like we're making a potential
functional tradeoff here by changing the insertion side locking. Note
that I don't object or know that it matters in any way, I'd just suggest
to add a note about this in the commit log in case somebody has to refer
back to this in the future.
Otherwise I read through the rest of the series and modulo a nit on
patch 10, it all looks reasonable to me. For the series:
Reviewed-by: Brian Foster <bfoster@redhat.com>
next prev parent reply other threads:[~2026-07-17 14:13 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 14:50 misc buffer cache improvements Christoph Hellwig
2026-07-15 14:50 ` [PATCH 01/12] xfs: don't get a pag reference in xfs_buf_get_map Christoph Hellwig
2026-07-15 14:50 ` [PATCH 02/12] xfs: consolidate buffer locking " Christoph Hellwig
2026-07-16 13:12 ` Brian Foster
2026-07-17 8:59 ` Christoph Hellwig
2026-07-17 14:13 ` Brian Foster [this message]
2026-07-15 14:50 ` [PATCH 03/12] xfs: split out a lower-level xfs_buf_get_map helper from xfs_find_get_buf Christoph Hellwig
2026-07-15 14:50 ` [PATCH 04/12] xfs: remove spurious XBF_DONE clearing on readahead validation failure Christoph Hellwig
2026-07-15 14:50 ` [PATCH 05/12] xfs: remove _XBF_LOGRECOVERY Christoph Hellwig
2026-07-15 14:50 ` [PATCH 06/12] xfs: hide b_flags manipulation from code outside of xfs_buf.c Christoph Hellwig
2026-07-15 14:51 ` [PATCH 07/12] xfs: use WRITE_ONCE to update b_flags Christoph Hellwig
2026-07-15 14:51 ` [PATCH 08/12] xfs: don't reverify buffers in xfs_buf_readahead_map Christoph Hellwig
2026-07-15 14:51 ` [PATCH 09/12] xfs: use goto based error unwinding in xfs_buf_read_map Christoph Hellwig
2026-07-15 14:51 ` [PATCH 10/12] xfs: merge xfs_buf_reverify into xfs_buf_read_map Christoph Hellwig
2026-07-17 14:13 ` Brian Foster
2026-07-15 14:51 ` [PATCH 11/12] xfs: move buffer locking out of xfs_find_get_buf Christoph Hellwig
2026-07-15 14:51 ` [PATCH 12/12] xfs: add lockless xfs_buf_readahead_map fast path Christoph Hellwig
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=alo4doLYG7BzuCfO@bfoster \
--to=bfoster@redhat.com \
--cc=cem@kernel.org \
--cc=djwong@kernel.org \
--cc=hch@lst.de \
--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 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.