Linux XFS filesystem development
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Brian Foster <bfoster@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>, 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:59:50 +0200	[thread overview]
Message-ID: <20260717085950.GA32056@lst.de> (raw)
In-Reply-To: <aljY0uI6jY8y2b3Z@bfoster>

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.


  reply	other threads:[~2026-07-17  8:59 UTC|newest]

Thread overview: 15+ 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 [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-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=20260717085950.GA32056@lst.de \
    --to=hch@lst.de \
    --cc=bfoster@redhat.com \
    --cc=cem@kernel.org \
    --cc=djwong@kernel.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