From: Mike Snitzer <snitzer@kernel.org>
To: Chuck Lever <chuck.lever@oracle.com>, Jeff Layton <jlayton@kernel.org>
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH v3 1/3] NFSD: avoid DONTCACHE for misaligned ends of misaligned DIO WRITE
Date: Wed, 5 Nov 2025 01:19:06 -0500 [thread overview]
Message-ID: <aQrsWnHK1ny3Md9g@kernel.org> (raw)
In-Reply-To: <20251104164229.43259-2-snitzer@kernel.org>
NFSD_IO_DIRECT can easily improve streaming misaligned WRITE
performance if it uses buffered IO (without DONTCACHE) for the
misaligned end segment(s) and O_DIRECT for the aligned middle
segment's IO.
On one capable testbed, this commit improved streaming 47008 byte
write performance from 0.3433 GB/s to 1.26 GB/s.
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
---
fs/nfsd/vfs.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
v3: drop unrelated change to avoid DONTCACHE if READ is less than 32K
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 701dd261c252..075d7162eb2e 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1347,6 +1347,14 @@ nfsd_write_dio_iters_init(struct bio_vec *bvec, unsigned int nvecs,
++args->nsegs;
}
+ /*
+ * Don't use IOCB_DONTCACHE if misaligned DIO (args->nsegs > 1),
+ * because IO for misaligned segments can benefit from the page
+ * cache (e.g. when handling streaming misaligned IO).
+ */
+ if (args->nsegs > 1 && (args->flags_buffered & IOCB_DONTCACHE))
+ args->flags_buffered &= ~IOCB_DONTCACHE;
+
return;
no_dio:
@@ -1400,7 +1408,7 @@ nfsd_direct_write(struct svc_rqst *rqstp, struct svc_fh *fhp,
/*
* IOCB_DONTCACHE preserves the intent of NFSD_IO_DIRECT when
- * writing unaligned segments or handling fallback I/O.
+ * falling back to buffered IO if entire WRITE is unaligned.
*/
args.flags_buffered = kiocb->ki_flags;
if (args.nf->nf_file->f_op->fop_flags & FOP_DONTCACHE)
--
2.44.0
next prev parent reply other threads:[~2025-11-05 6:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-04 16:42 [PATCH 0/3] NFSD: additional NFSD Direct changes Mike Snitzer
2025-11-04 16:42 ` [PATCH 1/3] nfsd: avoid using DONTCACHE for misaligned DIO's buffered IO fallback Mike Snitzer
2025-11-04 17:23 ` Chuck Lever
2025-11-04 17:35 ` Mike Snitzer
2025-11-04 19:33 ` Chuck Lever
2025-11-04 18:11 ` [PATCH v2 " Mike Snitzer
2025-11-05 6:19 ` Mike Snitzer [this message]
2025-11-05 14:58 ` [PATCH v3 1/3] NFSD: avoid DONTCACHE for misaligned ends of misaligned DIO WRITE Chuck Lever
2025-11-05 17:33 ` Mike Snitzer
2025-11-04 16:42 ` [PATCH 2/3] NFSD: add new NFSD_IO_DIRECT variants that may override stable_how Mike Snitzer
2025-11-04 16:42 ` [PATCH 3/3] NFSD: update Documentation/filesystems/nfs/nfsd-io-modes.rst Mike Snitzer
2025-11-04 17:25 ` Chuck Lever
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=aQrsWnHK1ny3Md9g@kernel.org \
--to=snitzer@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.