Linux NFS development
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Steve Dickson <steved@redhat.com>, Chuck Lever <cel@kernel.org>,
	 NeilBrown <neil@brown.name>,
	Olga Kornievskaia <okorniev@redhat.com>,
	 Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
	 Trond Myklebust <trondmy@kernel.org>,
	Anna Schumaker <anna@kernel.org>,
	 Mike Snitzer <snitzer@kernel.org>
Cc: linux-nfs@vger.kernel.org, Jeff Layton <jlayton@kernel.org>
Subject: [PATCH nfs-utils v2 3/4] exportfs: Display and document read_io= and write_io=
Date: Thu, 29 Oct 2026 08:10:10 -0400	[thread overview]
Message-ID: <20261029-master-v2-3-32bfc6ac16da@kernel.org> (raw)
In-Reply-To: <20261029-master-v2-0-32bfc6ac16da@kernel.org>

Show explicitly-set I/O modes in "exportfs -v" output and document the
new options in exports(5). Warn when exporting if the running kernel,
or no-netlink, means they will be ignored.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 support/include/nfslib.h   |  1 +
 utils/exportfs/exportfs.c  | 34 ++++++++++++++++++++++++++++++++++
 utils/exportfs/exports.man | 22 ++++++++++++++++++++++
 3 files changed, 57 insertions(+)

diff --git a/support/include/nfslib.h b/support/include/nfslib.h
index 7d7aadaed159..51094886a19e 100644
--- a/support/include/nfslib.h
+++ b/support/include/nfslib.h
@@ -79,6 +79,7 @@ struct xprtsec_entry {
  * Per-export I/O modes for read_io=/write_io=. Values must match the
  * kernel's NFSD_IO_* enum (fs/nfsd/nfsd.h). NFSD_IO_UNSET means no
  * option was given; the export follows the server's global setting.
+ * It matches the kernel's NFSD_IO_DEFAULT value.
  */
 #define NFSD_IO_BUFFERED	0
 #define NFSD_IO_DONTCACHE	1
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index ecf66fd07fd1..eb08ce4662f8 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -614,6 +614,32 @@ try_proc:
 	return 1;
 }
 
+/*
+ * mountd passes read_io= and write_io= to the kernel only over netlink, and
+ * only to a kernel that takes them.  @test_result is from can_test().
+ */
+static void
+validate_iomode(nfs_export *exp, const char *path, int test_result)
+{
+	static int supported = -1;
+
+	if (exp->m_export.e_read_io == NFSD_IO_UNSET &&
+	    exp->m_export.e_write_io == NFSD_IO_UNSET)
+		return;
+
+	if (supported < 0)
+		supported = test_result == 2 ?
+			    nfsd_export_iomode_supported() : 0;
+	/* nfsd is not loaded, so there is no telling yet */
+	if (supported < 0)
+		return;
+
+	if (!supported)
+		xlog(L_WARNING, "%s: ignoring read_io= and write_io=: %s", path,
+		     no_netlink ? "no-netlink is set" :
+				  "not supported by the running kernel");
+}
+
 static void
 validate_export(nfs_export *exp)
 {
@@ -642,6 +668,8 @@ validate_export(nfs_export *exp)
 	if (!test_result)
 		return;
 
+	validate_iomode(exp, path, test_result);
+
 	/*
 	 * When netlink is available, skip the export_test() probe.
 	 * mountd/exportd will validate exports at cache-fill time.
@@ -838,6 +866,12 @@ dump(int verbose, int export_format)
 				c = dumpopt(c, "no_acl");
 			if (ep->e_flags & NFSEXP_PNFS)
 				c = dumpopt(c, "pnfs");
+			if (ep->e_read_io != NFSD_IO_UNSET)
+				c = dumpopt(c, "read_io=%s",
+					    iomode_name(ep->e_read_io));
+			if (ep->e_write_io != NFSD_IO_UNSET)
+				c = dumpopt(c, "write_io=%s",
+					    iomode_name(ep->e_write_io));
 			if (ep->e_flags & NFSEXP_FSID)
 				c = dumpopt(c, "fsid=%d", ep->e_fsid);
 			if (ep->e_uuid)
diff --git a/utils/exportfs/exports.man b/utils/exportfs/exports.man
index 7f0278fb8d33..ac8bce905573 100644
--- a/utils/exportfs/exports.man
+++ b/utils/exportfs/exports.man
@@ -477,6 +477,28 @@ devices. The default can be explicitly requested with the
 .I no_pnfs
 option.
 
+.TP
+.IR read_io= buffered|dontcache|direct
+This option selects the I/O mode the server uses for NFS READ requests
+to this export:
+.I buffered
+uses the page cache,
+.I dontcache
+uses the page cache but drops the data behind on completion, and
+.I direct
+uses direct I/O.
+If the option is not specified, the export follows the server's global
+setting, which defaults to
+.IR buffered .
+If the kernel does not support per-export I/O modes, the option is
+ignored and a warning is logged.
+
+.TP
+.IR write_io= buffered|dontcache|direct
+This option selects the I/O mode the server uses for NFS WRITE requests
+to this export, with the same values and default as
+.IR read_io= .
+
 .TP
 .IR security_label
 With this option set, clients using NFSv4.2 or higher will be able to

-- 
2.56.0


  parent reply	other threads:[~2026-10-29 12:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 12:10 [PATCH nfs-utils v2 0/4] exports: add support for new read_io= and write_io= export options Jeff Layton
2026-10-29 12:10 ` [PATCH nfs-utils v2 1/4] exportfs/mountd/exportd: track the svc_export policy highest attribute Jeff Layton
2026-10-29 12:10 ` [PATCH nfs-utils v2 2/4] exports: Add read_io= and write_io= export options Jeff Layton
2026-10-29 12:10 ` Jeff Layton [this message]
2026-10-29 12:10 ` [PATCH nfs-utils v2 4/4] nfsd-iomode-advisor: recommend read_io= and write_io= for an export Jeff Layton

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=20261029-master-v2-3-32bfc6ac16da@kernel.org \
    --to=jlayton@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=anna@kernel.org \
    --cc=cel@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=snitzer@kernel.org \
    --cc=steved@redhat.com \
    --cc=tom@talpey.com \
    --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