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 00/12] pNFS: layout recalls and writes that have to be resent
Date: Fri, 4 Dec 2026 12:41:51 -0500 [thread overview]
Message-ID: <cover.1796405840.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 8 adds a second count on the layout segment, pls_hold, which keeps
the segment allocated without keeping it on the layout. Patches 9 and
10 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 12 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.
A held segment keeps its mirrors on the flexfiles layout header's list
after the segment has been returned, so patch 7 has the lookup for a
deleted deviceid walk the segments that are on the layout.
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 8 to 10 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.
Patch 2 returns the error from an O_DIRECT read whose requests were
all dropped, and ends the read's count at the first request 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 9
a task can wait for a layout with the folio locked, so patch 11 has
nfs_wb_folio() wait and resend a folio that the layout driver refuses
with -EAGAIN. That replaces 1/5. The rest of that series is posted on
top of v4 of this one, and I'll rebase it on this version.
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 11 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 changes since v4 are for cases these
tests don't reach, and were made from the review alone.
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 v4, from the sashiko review:
https://lore.kernel.org/linux-nfs/cover.1796306148.git.bcodding@hammerspace.com/
- New patch 7: the flexfiles lookup for a deleted deviceid walks the
layout's segments.
- Patch 9 (was 8): a LAYOUTERROR takes its segment reference only if
the segment still has one. A descriptor's segment may have left the
layout by then, and v4 took the reference from zero.
- Patch 9: a write that is rescheduled from the submitter drops its
open context reference through nfsiod, as writeback must.
- Patch 9: the reference for I/O is taken without the inode's i_lock.
- Patch 10 (was 9): pnfs_generic_commit_pagelist() keeps the layout
header while it goes through the commit lists. In v4 a commit
bucket's hold could be the last reference on the header that the
lists are part of.
- Patch 11 (was 10): nfs_launder_folio() doesn't resend from an
exiting task or a kernel thread, where no signal ends the wait, and
a fatal signal is checked after every wait.
- Patch 4: a failure to create the DS RPC client returns the layout
unless the write goes to the MDS. v4 retried at once on the same
layout.
- Patch 2: the read's count ends at the first request dropped. A pNFS
read that is resent can drop requests from the middle.
- Patch 3: an O_DIRECT write that fails with a hard error ends its
count at the request that was refused, whose copy another mirror may
have sent.
- Patches 3 and 4: the stable tag is v6.6+, where patch 1 applies.
- Changelogs of patches 10 and 11 corrected (LOCALIO commit,
nfs_update_folio()).
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 8 to 10: the pageio descriptor and the commit buckets
don't keep a layout in use.
- Patch 12 (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 11. 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: a fatal error preparing the DS no longer returns the layout
under FF_FLAGS_NO_IO_THRU_MDS.
- Patch 1: unchanged.
Benjamin Coddington (12):
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/flexfiles: look for a deviceid in the layout's segments
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 | 74 +++++---
fs/nfs/file.c | 6 +-
fs/nfs/filelayout/filelayout.c | 2 +-
fs/nfs/flexfilelayout/flexfilelayout.c | 117 ++++++++-----
fs/nfs/inode.c | 1 +
fs/nfs/internal.h | 3 +-
fs/nfs/nfs42proc.c | 6 +-
fs/nfs/pagelist.c | 46 ++++-
fs/nfs/pnfs.c | 233 +++++++++++++++++++++----
fs/nfs/pnfs.h | 12 ++
fs/nfs/pnfs_nfs.c | 74 +++++---
fs/nfs/read.c | 3 +-
fs/nfs/write.c | 49 ++++--
include/linux/nfs_fs.h | 1 +
include/linux/nfs_xdr.h | 3 +-
16 files changed, 499 insertions(+), 139 deletions(-)
base-commit: 3e19991734326332c736e24c9b47b2cffb8f9e42
--
2.53.0
next 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 Benjamin Coddington [this message]
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 ` [PATCH v5 06/12] NFS: wait before resending an O_DIRECT write that was refused again Benjamin Coddington
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=cover.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