Linux NFS development
 help / color / mirror / Atom feed
From: Benjamin Coddington <ben.coddington@hammerspace.com>
To: Trond Myklebust <trondmy@kernel.org>,
	Anna Schumaker <anna@kernel.org>,
	Mike Snitzer <snitzer@kernel.org>
Cc: Olga Kornievskaia <okorniev@redhat.com>, linux-nfs@vger.kernel.org
Subject: [PATCH v5 06/12] NFS: wait before resending an O_DIRECT write that was refused again
Date: Fri,  4 Dec 2026 12:41:57 -0500	[thread overview]
Message-ID: <dee70f1fd634eccdd5525c6cc4e2bc01e84bdcec.1796405840.git.bcodding@hammerspace.com> (raw)
In-Reply-To: <cover.1796405840.git.bcodding@hammerspace.com>

From: Benjamin Coddington <bcodding@hammerspace.com>

nfs_direct_write_reschedule() resends the requests of an O_DIRECT write
from nfsiod.  When the resend itself gets -EAGAIN, for example because
the layout driver has no layout segment to write with yet, the requests
go back on the commit list and the work is queued again at once.  The
worker then resends in a loop until a layout is available.

Queue the work a second later when a resend ends with -EAGAIN.  The first
resend of a write is still immediate.

Signed-off-by: Benjamin Coddington <bcodding@hammerspace.com>
---
 fs/nfs/direct.c   | 8 +++++++-
 fs/nfs/internal.h | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 2dd78fc12e2e..66b87965e77b 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -635,6 +635,11 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
 		}
 	}
 
+	spin_lock(&dreq->lock);
+	if (desc.pg_error == -EAGAIN &&
+	    dreq->flags == NFS_ODIRECT_RESCHED_WRITES)
+		dreq->work_delay = HZ;
+	spin_unlock(&dreq->lock);
 	if (put_dreq(dreq))
 		nfs_direct_write_complete(dreq);
 }
@@ -753,6 +758,7 @@ static void nfs_direct_write_schedule_work(struct work_struct *work)
 	int flags = dreq->flags;
 
 	dreq->flags = 0;
+	dreq->work_delay = 0;
 	switch (flags) {
 		case NFS_ODIRECT_DO_COMMIT:
 			nfs_direct_commit_schedule(dreq);
@@ -771,7 +777,7 @@ static void nfs_direct_write_complete(struct nfs_direct_req *dreq)
 {
 	trace_nfs_direct_write_complete(dreq);
 	/* Calls nfs_direct_write_schedule_work */
-	queue_delayed_work(nfsiod_workqueue, &dreq->work, 0);
+	queue_delayed_work(nfsiod_workqueue, &dreq->work, dreq->work_delay);
 }
 
 static void nfs_direct_write_completion(struct nfs_pgio_header *hdr)
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index f34da925f3d5..5a5c1b960546 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -1037,6 +1037,7 @@ struct nfs_direct_req {
 	struct nfs_mds_commit_info mds_cinfo;	/* Storage for cinfo */
 	struct pnfs_ds_commit_info ds_cinfo;	/* Storage for cinfo */
 	struct delayed_work	work;
+	unsigned long		work_delay;	/* jiffies */
 	int			flags;
 	/* for write */
 #define NFS_ODIRECT_DO_COMMIT		(1)	/* an unstable reply was received */
-- 
2.53.0


  parent reply	other threads:[~2026-12-04 17:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 17:41 [PATCH v5 00/12] pNFS: layout recalls and writes that have to be resent Benjamin Coddington
2026-12-04 17:41 ` [PATCH v5 01/12] NFS: resend O_DIRECT write requests that error cleanup gets with -EAGAIN Benjamin Coddington
2026-12-04 17:41 ` [PATCH v5 02/12] NFS: report the error when an O_DIRECT read's requests are never sent Benjamin Coddington
2026-12-04 17:41 ` [PATCH v5 03/12] NFS: send every mirror when one of them can take no more Benjamin Coddington
2026-12-04 17:41 ` [PATCH v5 04/12] pNFS/flexfiles: don't switch a busy mirrored write descriptor to the MDS Benjamin Coddington
2026-12-04 17:41 ` [PATCH v5 05/12] NFS: make the O_DIRECT write work a delayed_work Benjamin Coddington
2026-12-04 17:41 ` Benjamin Coddington [this message]
2026-12-04 17:41 ` [PATCH v5 07/12] pNFS/flexfiles: look for a deviceid in the layout's segments Benjamin Coddington
2026-12-04 17:41 ` [PATCH v5 08/12] pNFS: add a layout segment hold that doesn't keep the layout in use Benjamin Coddington
2026-12-04 17:42 ` [PATCH v5 09/12] pNFS: don't keep a layout in use from an idle pageio descriptor Benjamin Coddington
2026-12-04 17:42 ` [PATCH v5 10/12] pNFS: don't keep a layout in use from a commit bucket Benjamin Coddington
2026-12-04 17:42 ` [PATCH v5 11/12] NFS: wait and resend a folio refused with -EAGAIN in nfs_wb_folio() Benjamin Coddington
2026-12-04 17:42 ` [PATCH v5 12/12] pNFS: answer a file recall with NFS4ERR_DELAY while I/O drains Benjamin Coddington

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=dee70f1fd634eccdd5525c6cc4e2bc01e84bdcec.1796405840.git.bcodding@hammerspace.com \
    --to=ben.coddington@hammerspace.com \
    --cc=anna@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=okorniev@redhat.com \
    --cc=snitzer@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