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 v4 00/11] pNFS: layout recalls and writes that have to be resent
Date: Thu,  3 Dec 2026 08:56:55 -0500	[thread overview]
Message-ID: <cover.1796306148.git.bcodding@hammerspace.com> (raw)

From: Benjamin Coddington <bcodding@hammerspace.com>

v3 answered a CB_LAYOUTRECALL with NFS4ERR_DELAY while I/O on the layout
drains.  Trond pointed out on 5/6 that a layout segment reference does
not mean I/O is in flight: a pageio descriptor keeps its segment while
it waits for a folio lock or faults in an O_DIRECT buffer, and a commit
bucket keeps one until the COMMIT is sent.  Those holders keep a recall
from completing, and what they wait for can be waiting for the layout
the recall holds back.  Two cases deadlock, with or without v3:

 - An O_DIRECT write whose buffer is an mmap of the same file.  The
   writer faults the buffer in with its descriptor and its commit
   buckets holding segments, and the fault's read waits for a layout.

 - Writeback that has queued one folio and waits for the lock on the
   next, while the task holding that lock is in nfs_wb_folio() or
   nfs_read_folio() waiting for a layout.

This version stops those holders from keeping the layout in use.
Patch 7 adds a second count on the layout segment, pls_hold, which keeps
the segment allocated without keeping it on the layout.  Patches 8 and 9
move the pageio descriptor and the commit buckets to it.  They take a
reference only when they put I/O or a COMMIT on the wire, and if the
segment has been invalidated by then the requests are sent again with a
new one.  Patch 11 is v3's file recall patch without the flag that
blocked LAYOUTGET: it answers NFS4ERR_DELAY only while a segment in the
recalled range is in use.

That resend path is the one the mirrored write fallback series fixes,
and the recall tests don't pass without it, so its remaining three
patches are here as patches 1, 3 and 4, and that series ends:
https://lore.kernel.org/linux-nfs/cover.1795148523.git.bcodding@hammerspace.com/
With patches 7 to 9 and without patch 1, an O_DIRECT write under recalls
returns success with mirrors left holding old data.  Without patch 4,
KASAN reports a use-after-free of the mirror array.  Patches 3 and 4
have changes from the sashiko review of that posting, listed below.

Patch 2 returns the error from an O_DIRECT read whose requests were
all dropped.  Patches 5 and 6 pace the O_DIRECT write resend, which
otherwise runs without a pause until a layout is available.  Patch 5 is
2/5 of the FF_FLAGS_NO_IO_THRU_MDS series unchanged:
https://lore.kernel.org/linux-nfs/cover.1795122899.git.bcodding@hammerspace.com/

Splitting the references also solves the nfs_wb_folio() problem I
asked about on 1/5 of the FF_FLAGS_NO_IO_THRU_MDS series.  With patch 8
a task can wait for a layout with the folio locked, so patch 10 has
nfs_wb_folio() wait and resend a folio that the layout driver refuses
with -EAGAIN.  That replaces 1/5, and I'll repost the rest of that
series on top of this one.

v3's 6/6 (write through the MDS while a recalled layout drains) is
dropped.

Tested on a KASAN kernel against a reffs MDS that hands out six-way
mirrored flexfiles layouts with FF_FLAGS_NO_IO_THRU_MDS, with knfsd as
the NFSv3 data server so that writes are UNSTABLE and need a COMMIT:

 - Buffered and O_DIRECT readers and writers on three files while FSID,
   ALL and FILE recalls, with clora_changed set and clear, run in a
   loop.  The files and each of the six mirrors match the data written.
   On the base, a buffered write(2) in this test fails with EAGAIN in
   some runs.  With patch 10 it doesn't.

 - The O_DIRECT write from an mmap of the same file, with an FSID recall
   sent while the writer is between chunks.  On the base the writer
   stays in ff_layout_pg_retry_wait() until it is killed.  With the
   series the write completes and the recall gets
   NFS4ERR_NOMATCHING_LAYOUT.

 - Writeback stopped after queueing its first folio, with a test-only
   delay, while a FILE recall is outstanding and a second task reads or
   writes the next dirty folio.  On the base both tasks hang.  With the
   series both finish and the data is correct.

 - Buffered data written UNSTABLE and not yet committed when an FSID or
   FILE recall arrives.  The data is written again with the new layout
   and reads back correctly.

Not tested: layouts with a single mirror, the files layout driver, and
the block layout drivers.

The series is based on Trond's testing branch at 3e1999173432, which has
1/6 to 4/6 of v3 and 2/4 of the mirrored write fallback series.

Changes since v3:
https://lore.kernel.org/linux-nfs/cover.1793627813.git.bcodding@hammerspace.com/
 - 1/6 to 4/6 are in Trond's testing branch and are not reposted.
 - New patches 7 to 9: the pageio descriptor and the commit buckets
   don't keep a layout in use.
 - Patch 11 (was 5/6): doesn't set NFS_LAYOUT_BULK_RECALL, so LAYOUTGET
   is not blocked after the recall completes and a partial recall only
   waits for segments in its range.  I/O is cancelled on every recall
   with clora_changed set.
 - 6/6 dropped.
 - New patches 2, 6 and 10.  Patch 5 is from the FF_FLAGS_NO_IO_THRU_MDS
   series.

Changes to patches 1, 3 and 4 since v2 of the mirrored write fallback
series:
 - Patch 3: when the current mirror asks for a retry, the other mirrors
   are not sent until it has been coalesced again.  The changelog no
   longer says the mirrors stay in step when their wsize differs.
 - Patch 4: failing to create the DS RPC client is treated like a fatal
   error preparing the DS, and a fatal error no longer returns the
   layout under FF_FLAGS_NO_IO_THRU_MDS.
 - Patch 1: unchanged.

Benjamin Coddington (11):
  NFS: resend O_DIRECT write requests that error cleanup gets with
    -EAGAIN
  NFS: report the error when an O_DIRECT read's requests are never sent
  NFS: send every mirror when one of them can take no more
  pNFS/flexfiles: don't switch a busy mirrored write descriptor to the
    MDS
  NFS: make the O_DIRECT write work a delayed_work
  NFS: wait before resending an O_DIRECT write that was refused again
  pNFS: add a layout segment hold that doesn't keep the layout in use
  pNFS: don't keep a layout in use from an idle pageio descriptor
  pNFS: don't keep a layout in use from a commit bucket
  NFS: wait and resend a folio refused with -EAGAIN in nfs_wb_folio()
  pNFS: answer a file recall with NFS4ERR_DELAY while I/O drains

 fs/nfs/callback_proc.c                 |   8 +
 fs/nfs/direct.c                        |  68 +++++---
 fs/nfs/filelayout/filelayout.c         |   2 +-
 fs/nfs/flexfilelayout/flexfilelayout.c |  81 +++++----
 fs/nfs/internal.h                      |   3 +-
 fs/nfs/pagelist.c                      |  45 ++++-
 fs/nfs/pnfs.c                          | 226 +++++++++++++++++++++----
 fs/nfs/pnfs.h                          |  12 ++
 fs/nfs/pnfs_nfs.c                      |  61 ++++---
 fs/nfs/read.c                          |   3 +-
 fs/nfs/write.c                         |  42 +++--
 include/linux/nfs_xdr.h                |   3 +-
 12 files changed, 425 insertions(+), 129 deletions(-)


base-commit: 3e19991734326332c736e24c9b47b2cffb8f9e42
-- 
2.53.0


             reply	other threads:[~2026-12-03 13:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 13:56 Benjamin Coddington [this message]
2026-12-03 13:56 ` [PATCH v4 01/11] NFS: resend O_DIRECT write requests that error cleanup gets with -EAGAIN Benjamin Coddington
2026-12-03 13:56 ` [PATCH v4 02/11] NFS: report the error when an O_DIRECT read's requests are never sent Benjamin Coddington
2026-12-03 13:56 ` [PATCH v4 03/11] NFS: send every mirror when one of them can take no more Benjamin Coddington
2026-12-03 13:56 ` [PATCH v4 04/11] pNFS/flexfiles: don't switch a busy mirrored write descriptor to the MDS Benjamin Coddington
2026-12-03 13:57 ` [PATCH v4 05/11] NFS: make the O_DIRECT write work a delayed_work Benjamin Coddington
2026-12-03 13:57 ` [PATCH v4 06/11] NFS: wait before resending an O_DIRECT write that was refused again Benjamin Coddington
2026-12-03 13:57 ` [PATCH v4 07/11] pNFS: add a layout segment hold that doesn't keep the layout in use Benjamin Coddington
2026-12-03 13:57 ` [PATCH v4 08/11] pNFS: don't keep a layout in use from an idle pageio descriptor Benjamin Coddington
2026-12-03 13:57 ` [PATCH v4 09/11] pNFS: don't keep a layout in use from a commit bucket Benjamin Coddington
2026-12-03 13:57 ` [PATCH v4 10/11] NFS: wait and resend a folio refused with -EAGAIN in nfs_wb_folio() Benjamin Coddington
2026-12-03 13:57 ` [PATCH v4 11/11] 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=cover.1796306148.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