Article View: linux.kernel.netdev
Article #7982[PATCH 2/6] NFSD: Apply per-export I/O modes to READ and WRITE
From: Jeff Layton
Date: Tue, 27 Oct 2026 16:45
Date: Tue, 27 Oct 2026 16:45
149 lines
14362 bytes
14362 bytes
Resolve each export's effective I/O mode (explicit setting, else the
global io_cache_read/write knob) in nfsd_iter_read and nfsd_vfs_write,
and skip splice for reads on exports whose effective read mode is not
buffered. Update the debugfs knob comments to match.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/nfsd/debugfs.c | 6 ++++--
fs/nfsd/nfs4xdr.c | 6 ++++--
fs/nfsd/vfs.c | 39 ++++++++++++++++++++++++++++++++++++---
fs/nfsd/vfs.h | 2 ++
4 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/fs/nfsd/debugfs.c b/fs/nfsd/debugfs.c
index 4af1e6b8b212..a10159db3b60 100644
--- a/fs/nfsd/debugfs.c
+++ b/fs/nfsd/debugfs.c
@@ -47,7 +47,8 @@ DEFINE_DEBUGFS_ATTRIBUTE(nfsd_dsr_fops, nfsd_dsr_get, nfsd_dsr_set, "%llu\n");
* %2: NFS READ will use direct IO
*
* This setting takes immediate effect for all NFS versions,
- * all exports, and in all NFSD net namespaces.
+ * all exports without an explicit riomode= setting, and in all
+ * NFSD net namespaces.
*/
static int nfsd_io_cache_read_get(void *data, u64 *val)
@@ -92,7 +93,8 @@ DEFINE_DEBUGFS_ATTRIBUTE(nfsd_io_cache_read_fops, nfsd_io_cache_read_get,
* %1: NFS WRITE will use dontcache (buffered IO w/ dropbehind)
*
* This setting takes immediate effect for all NFS versions,
- * all exports, and in all NFSD net namespaces.
+ * all exports without an explicit wiomode= setting, and in all
+ * NFSD net namespaces.
*/
static int nfsd_io_cache_write_get(void *data, u64 *val)
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 4d983444604a..9215feeeb0ba 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -5366,7 +5366,8 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
maxcount = min_t(unsigned long, read->rd_length,
(xdr->buf->buflen - xdr->buf->len));
- if (file->f_op->splice_read && splice_ok)
+ if (file->f_op->splice_read && splice_ok &&
+ nfsd_read_iomode(read->rd_fhp->fh_export) == NFSD_IO_BUFFERED)
nfserr = nfsd4_encode_splice_read(resp, read, file, maxcount);
else
nfserr = nfsd4_encode_readv(resp, read, maxcount);
@@ -6264,7 +6265,8 @@ nfsd4_encode_read_plus_data(struct nfsd4_compoundres *resp,
maxcount = min_t(unsigned long, read->rd_length,
(xdr->buf->buflen - xdr->buf->len));
- if (file->f_op->splice_read && splice_ok)
+ if (file->f_op->splice_read && splice_ok &&
+ nfsd_read_iomode(read->rd_fhp->fh_export) == NFSD_IO_BUFFERED)
nfserr = nfsd4_encode_splice_read(resp, read, file, maxcount);
else
nfserr = nfsd4_encode_readv(resp, read, maxcount);
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 7f9ec6c4af6d..15613b6df290 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1266,6 +1266,38 @@ static bool nfsd_direct_read_ok(struct svc_rqst *rqstp, struct svc_fh *fhp,
return true;
}
+/**
+ * nfsd_read_iomode - effective NFS READ I/O mode for an export
+ * @exp: export being accessed
+ *
+ * An export without an explicit riomode= setting follows the global
+ * nfsd_io_cache_read knob.
+ *
+ * Returns one of NFSD_IO_BUFFERED, NFSD_IO_DONTCACHE, or NFSD_IO_DIRECT.
+ */
+int nfsd_read_iomode(struct svc_export *exp)
+{
+ if (exp->ex_riomode == NFSD_IO_DEFAULT)
+ return nfsd_io_cache_read;
+ return exp->ex_riomode;
+}
+
+/**
+ * nfsd_write_iomode - effective NFS WRITE I/O mode for an export
+ * @exp: export being accessed
+ *
+ * An export without an explicit wiomode= setting follows the global
+ * nfsd_io_cache_write knob.
+ *
+ * Returns one of NFSD_IO_BUFFERED, NFSD_IO_DONTCACHE, or NFSD_IO_DIRECT.
+ */
+int nfsd_write_iomode(struct svc_export *exp)
+{
+ if (exp->ex_wiomode == NFSD_IO_DEFAULT)
+ return nfsd_io_cache_write;
+ return exp->ex_wiomode;
+}
+
/**
* nfsd_iter_read - Perform a VFS read using an iterator
* @rqstp: RPC transaction context
@@ -1300,7 +1332,7 @@ __be32 nfsd_iter_read(struct svc_rqst *rqstp, struct svc_fh *fhp,
init_sync_kiocb(&kiocb, file);
- switch (nfsd_io_cache_read) {
+ switch (nfsd_read_iomode(fhp->fh_export)) {
case NFSD_IO_BUFFERED:
break;
case NFSD_IO_DIRECT:
@@ -1746,7 +1778,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp,
if (verf)
nfsd_copy_write_verifier(verf, nn);
- switch (nfsd_io_cache_write) {
+ switch (nfsd_write_iomode(exp)) {
case NFSD_IO_DIRECT:
host_err = nfsd_direct_write(rqstp, fhp, nf, nvecs,
cnt, &kiocb);
@@ -1853,7 +1885,8 @@ __be32 nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp,
return err;
file = nf->nf_file;
- if (file->f_op->splice_read && nfsd_read_splice_ok(rqstp))
+ if (file->f_op->splice_read && nfsd_read_splice_ok(rqstp) &&
+ nfsd_read_iomode(fhp->fh_export) == NFSD_IO_BUFFERED)
err = nfsd_splice_read(rqstp, fhp, file, offset, count, eof);
else
err = nfsd_iter_read(rqstp, fhp, nf, offset, count, eof);
diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h
index 1f05c83a3ea6..e95611b79397 100644
--- a/fs/nfsd/vfs.h
+++ b/fs/nfsd/vfs.h
@@ -184,6 +184,8 @@ __be32 nfsd_iter_read(struct svc_rqst *rqstp, struct svc_fh *fhp,
struct nfsd_file *nf, loff_t offset,
unsigned long *count, u32 *eof);
bool nfsd_read_splice_ok(struct svc_rqst *rqstp);
+int nfsd_read_iomode(struct svc_export *exp);
+int nfsd_write_iomode(struct svc_export *exp);
__be32 nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp,
loff_t offset, unsigned long *count,
u32 *eof);
--
2.56.0
Technical Details
Message-ID:
<20261027-export-iomode-v1-2-262ed932a036@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352546-linux-kernel-netdev=dewy.ruReferences:
<20261027-export-iomode-v1-0-262ed932a036@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352546-linux-kernel-netdev=dewy.ru From: jlayton@kernel.org (Jeff Layton) Newsgroups: linux.kernel.netdev Subject: [PATCH 2/6] NFSD: Apply per-export I/O modes to READ and WRITE Date: Tue, 27 Oct 2026 12:45:25 -0400 Organization: Usenet Network Message-ID: <20261027-export-iomode-v1-2-262ed932a036@kernel.org> References: <20261027-export-iomode-v1-0-262ed932a036@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="1584087"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:5NG27FMYl47m7Nf1ndZ/XPKxcL8= sha256:IkY3VDX8QFDt5Mr++9kRHSkJKBfKhg6mCUWNkHN8R9Y= sha1:eTRVU5mLB0VnLVPJsdFrODdsXIA= sha256:QMDcGsTyX2BLBhyJHkzIBpRBPNAn6ONEHFSHuiVYFdc= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 2CDF6125C06; Tue, 27 Oct 2026 19:47:08 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 76k5BbEtD9gc; Tue, 27 Oct 2026 19:47:05 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-352546-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 661C3125C0E; Tue, 27 Oct 2026 19:46:56 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 533E06043C4; Tue, 27 Oct 2026 16:45:43 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793119540; b=D7ujfP1sjs+sW81ct59v1uZnNA4Rt7ROxxzTw8w20MxLxFhiM0XzE7oeOybD2Z6cluZc reZLhcQlj6ty8xgK6ez7jUDMl9ZcLm63jQq5hVxKE/PrXVZtXda7+fTbLT563DKrEE5KB rB281uzKkLSvFEMPPZ1ND3JT6bNy7MZ/ENkUcYiXJxVlAOhQVb1PsDC4HRtCeUqW5/wRf e3JrmUKa7nwAAYKzlBsAHHIbGEBVoFvluHOln4uYn0wrXg4KH/AJwGdXT6tYG1sUIrbpo Ada/aly7ubF5SUfInMnX04uQlCwpucHZvFwWFLILO8tSwUOHYmBPGdcmyTJsNVE1onA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793119540; h=X-Original-To:Received:Received:DKIM-Signature:From:Date:Subject: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=EDF7Sfz8pAZF8wfG0fhK2KgtiFpQj/vLigaRZX1+1eQ=; b=eL5kExH9SKf4FPE0Ex0oOKJbmxjtTPH7YZO5D17HFHkGQMcR1es1V9ljQj31lNuxbl6V eeMIdyscb83hCIDsjOgsnQN8KIcXxNak8gl4PM4YkCw/FRs2CROg+SLpl5+QmKDBIHb5w x4RfBuDHTzgdyCWoVIhQb9KSvyUyZoHorMqFe2iX+pusWgDjYw4Sd+P1yE0BR19gmo7jG 1Z8m5IOtFe4vUwEck3yb70Dc+keryTBpaYmXGsPageuW0eMQ/RZlNao8Mi/oAhz1jI4bJ n1yXi0C/Hh12eabJtYV4wkVD5c1LZDLOkYLlQmYJhN7hf1friFIaHeKGokHgu1QHgGQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cGB5jJ+E; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD7BC606A336; Tue, 27 Oct 2026 16:45:39 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cGB5jJ+E X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793119539; b=BJQ0T2cu5tpboaDzBGjkniUHlN+2dj5c++YuleesJyHV8ux4lZL41WTeBkN1k6yvpbR9 3C67HMWf8NdvwlcgMrAkThph7i7J/zVI8sRoEsIhqHwoXI6dvhZ5KJfa5pQ2cPCLjZ5TS jQvybIgtB4as558ZCqu1Brmg5AQc/GumOPxY1mrM7gp1ywHL7UwKuaODom0LmgB+vd5P3 srJEH+1DT8URGIxTi/c/0zqVJuz/cPMwWtW2xnyS3Y8gLeithbXD5Lc5LJub4A4UTQgPL aCtNQN9xMu3ihDxj1DkqTVdlRUzzRb4F/sQ+XOmPpL1cUi9nFI7S7oEO+LcmpzXlejA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793119539; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=EDF7Sfz8pAZF8wfG0fhK2KgtiFpQj/vLigaRZX1+1eQ=; b=jwUlniOVUv9J0ySQIi4ouhAmGbECyAU9he6dv3mpC6e+XSzJL//MIpx+NNwN0qycyZD+ +UFjnnGGwfUr4tpQ/cVbgKFUyEPYakd44/mXfxDhJeG33BeySarSoAdFw0Sij4Vhziojz z6VYgez6JYxV1J0gP0MRTy9E+C4apbZ8WPZ5ggijzBKwGYc7R6g5MyAmEfwCIUbZxZGRb FANyAI39YzT+GmEcZwSJ7pWFHKkgDfEWMkjjuxoXJIAwgQOHMblv+S6iVfGCjxlCE6zdK qemv8HDusR74P9zsqxcjqQxyUzfe2shBNwToMlCCg9QgjcQu4WK0iwuOCkIDgMBHGZg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=cGB5jJ+E; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB647606A32E; Tue, 27 Oct 2026 16:45:38 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E38F1F01828; Tue, 27 Oct 2026 16:45:36 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793119538; bh=EDF7Sfz8pAZF8wfG0fhK2KgtiFpQj/vLigaRZX1+1eQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=cGB5jJ+ETG7b+/Hhhnj0s/MRou3L2n42fRM3AkqSnnmMcn+0+7w7cggw4N7cmTvRI VJMPz8+hYlwuXU47qIrqz6MSim5r3Ut/HSnKTxezpIPXG8P+ZkqyMTDjD3PkA2PLjf kGDUAC+0bBq/mmJ5dAO3kSdwazNdMN3QQpz6NNKwgLMWefQzGzzPt9gb6UVE3Fns8k oB91mFTFmiJtwhhSPkzeNQDAGMMdB5IFf2gsQn9/Sp6xHok0gGbFaQXOQPbN5p4Gyw Xj+bSpepqAxKpkvVKRwx+ChzEfVqmwRXTftnlxmQCWcu6Ih+eMWtctjBFMbhMVG1+N creQgZI1Gk2/g== X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261027-export-iomode-v1-0-262ed932a036@kernel.org> X-Cc: Steve Dickson <steved@redhat.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton <jlayton@kernel.org> X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=5517; i=jlayton@kernel.org; h=from:subject:message-id; bh=W06iSDfE36gkgtT9sFvbZeiD5kvhlk+d8CDqjJ4QEWg=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBq4NUrfKN/ULYCLcA8G+jOeX8EsDY3kz29+Mkhn 0ran40TqwWJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCauDVKwAKCRAADmhBGVaC FUrXD/4kDfw+B5zwec9+tHKMjFPlv5faRsPuf40kYYWOa7OD3STGlRW9/QTIDfBKA/oGqAt0tI/ LpefPLbpoKp3gIbP/seuk7cx1q1jMgu+1JbyugTNu1r+44VJgGO2f2JGo4SUY6hBpqJ4T/zM4CR pip8iU6/6Rd4BWkdd8aGSPR/7T0Vu6Uhd6aFVrzcYQb4TOo4ZUgyXbo25Vb52gVG3XyJZNDHBeJ 9/Kr8Z4D4ZqDrV5wn/t0+adayFGoZ5ue1VcrdJIujaokexzk8sdYoqxc0DUuQi7rq+WSSXSqxQC A0IsJLgx6qfnIjMSpvrq1x6nwFB/BprPQ1v1C5oFo+Nk+s3oJ8hNmsiH+0EA3pvZwUNerWnaZm8 nPb3r47vjMpy9OTNUanOZowQr7gOqX9BEB9iqm3Kj4zMNXYCihHtZc6rbzJSswosUuiuX16eL7s dmMFC1Nlzp6LRFWCRVG9194HjDarAGIgHCqqRcLx6DfWBhsjlTPWBa1R+/V1YAZb6XIdIQVHHPb vv2/6gJbUvEom7EM/E8qCCfMS0J2F4gAt8CLGicW83XnHW7wUv4LVoGH9+sIfRvOtBvj/2TXOJC Bh2kzbyayq2pv35GDQLmJQdT2K5HV0tSTg1qkt5VcrcHtCGfoe9m3UcsVr4xExK+TwkfBVA85GY 65Sn8RA3im0X34A== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215