linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] NFSD: Fix SCSI reservation conflict causing pNFS client to revert I/O to MDS
@ 2025-09-30 16:28 Dai Ngo
  2025-09-30 19:15 ` Benjamin Coddington
  0 siblings, 1 reply; 12+ messages in thread
From: Dai Ngo @ 2025-09-30 16:28 UTC (permalink / raw)
  To: chuck.lever, jlayton, neilb, okorniev, tom; +Cc: hch, linux-nfs

When servicing the GETDEVICEINFO call from an NFS client, the NFS server
creates a SCSI persistent reservation on the target device using the
reservation type PR_EXCLUSIVE_ACCESS_REG_ONLY. This setting restricts
device access so that only hosts registered with a reservation key can
perform read or write operations. Any unregistered initiator is completely
blocked, including standard SCSI commands such as READCAPACITY.

As a result, if an NFS client reboots or a new client attempts to
access the device, its SCSI driver issues a READCAPACITY command before
registering a key. This command fails with a Reservation Conflict error
since the initiator is not yet registered. Consequently, the client
detects the SCSI device size as zero.

When it subsequently receives a LAYOUTGET reply, it finds the device
openable but with a size of zero, so it falls back to performing I/O
through the MDS instead of directly accessing the block device.

To resolve this, the patch changes the persistent reservation type from
PR_EXCLUSIVE_ACCESS_REG_ONLY to PR_WRITE_EXCLUSIVE_REG_ONLY. With this
reservation type, registered initiators retain full read and write access,
but unregistered initiators are now permitted to issue read commands
(including READCAPACITY) while still being blocked from write operations.

Allowing unregistered reads prevents reservation conflicts on READCAPACITY,
ensuring the device size can be properly discovered by clients. This
enables direct I/O to the SCSI block device after client reboot or new
client addition, rather than unnecessarily reverting to the MDS.

Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
---
 fs/nfsd/blocklayout.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c
index fde5539cf6a6..ab7903d584a6 100644
--- a/fs/nfsd/blocklayout.c
+++ b/fs/nfsd/blocklayout.c
@@ -291,7 +291,7 @@ nfsd4_block_get_device_info_scsi(struct super_block *sb,
 	}
 
 	ret = ops->pr_reserve(sb->s_bdev, NFSD_MDS_PR_KEY,
-			PR_EXCLUSIVE_ACCESS_REG_ONLY, 0);
+			PR_WRITE_EXCLUSIVE_REG_ONLY, 0);
 	if (ret) {
 		pr_err("pNFS: failed to reserve device %s.\n",
 			sb->s_id);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-10-09 20:20 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-30 16:28 [PATCH 1/1] NFSD: Fix SCSI reservation conflict causing pNFS client to revert I/O to MDS Dai Ngo
2025-09-30 19:15 ` Benjamin Coddington
2025-09-30 21:41   ` Dai Ngo
2025-10-01 10:54     ` Benjamin Coddington
2025-10-01 17:36       ` Dai Ngo
2025-10-03  6:45         ` Christoph Hellwig
2025-10-07 16:49           ` Dai Ngo
2025-10-07 15:59         ` Dai Ngo
2025-10-07 20:37           ` Benjamin Coddington
2025-10-09 17:43             ` Dai Ngo
2025-10-09 19:46               ` Benjamin Coddington
2025-10-09 20:20                 ` Dai Ngo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).