public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Dai Ngo <dai.ngo@oracle.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	trondmy@kernel.org, anna@kernel.org, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 1/1] pNFS: Serialize SCSI PR registration to avoid reservation conflicts
Date: Wed, 4 Mar 2026 05:11:54 -0800	[thread overview]
Message-ID: <aagvmtZ0t-GKwrZ4@infradead.org> (raw)
In-Reply-To: <53291a21-4a4a-4f43-8f8d-73f9415d6128@oracle.com>

On Tue, Mar 03, 2026 at 10:21:07AM -0800, Dai Ngo wrote:
> > >   			struct pnfs_block_dev_map *map);
> > > +	struct mutex			pbd_mutex;
> > Can you keep this up with the non-function pointer fields?
> 
> Can you please clarify this, you meant move this mutex up above
> the (*map)() declaration?

Yes.

> > > -	if (test_and_set_bit(PNFS_BDEV_REGISTERED, &dev->flags))
> > > +	mutex_lock(&dev->pbd_mutex);
> > > +	if (test_and_set_bit(PNFS_BDEV_REGISTERED, &dev->flags)) {
> > > +		mutex_unlock(&dev->pbd_mutex);
> > >   		return true;
> > > +	}
> > This seems to only lock the registration side, and not the
> > unregistration side, which is a bit odd.
> 
> The reason I did not use the mutex on unregistration is because
> unregistration happens when the export is unmounted and I don't
> see any race condition can happen at that time. Besides, even if
> there is race condition on the unregistration the consequence is
> a duplicate SCSI PR unregistration which is harmless.
> 
> However, if you think we should also protect the unregistration
> then I can add it in. At the very least, it makes the code look
> symmetric.

And it clearly defines what the mutex protects, so please yes.

> 
> >    If you fully protect
> > register/unregister we also don't need atomic bitops for
> > PNFS_BDEV_REGISTERED and have a more consistent locking scheme.
> 
> Even we fully protect register/unregister don't we still need the
> PNFS_BDEV_REGISTERED bit so the others thread can check and skip
> the register/unregister op?

Yes, but it doesn't need to use the atomic bit ops.


      reply	other threads:[~2026-03-04 13:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-02  0:51 [PATCH 1/1] pNFS: Serialize SCSI PR registration to avoid reservation conflicts Dai Ngo
2026-03-03 15:33 ` Christoph Hellwig
2026-03-03 16:11   ` Chuck Lever
2026-03-03 18:21   ` Dai Ngo
2026-03-04 13:11     ` Christoph Hellwig [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=aagvmtZ0t-GKwrZ4@infradead.org \
    --to=hch@infradead.org \
    --cc=anna@kernel.org \
    --cc=dai.ngo@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trondmy@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