Linux NFS development
 help / color / mirror / Atom feed
* [PATCH 0/4] pNFS: reclaim uncommitted layout writes after a server restart
@ 2026-12-01 14:18 Christoph Engelbert via B4 Relay
  2026-12-01 14:18 ` [PATCH 1/4] NFSv4.1: encode loca_reclaim in LAYOUTCOMMIT Christoph Engelbert via B4 Relay
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Christoph Engelbert via B4 Relay @ 2026-12-01 14:18 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker
  Cc: linux-nfs, Benjamin Coddington, Christoph Hellwig, Chuck Lever,
	Christoph Engelbert

A block or SCSI layout client writes file data straight to the storage
device, into extents the metadata server allocated as unwritten. The
server learns that the extents now hold data only from LAYOUTCOMMIT.
If the server restarts between the writes and the commit, the client
never tells it: the data is on the device, but every other client
reads those blocks as zeros. The writer reads its own page cache and
sees nothing wrong. Its close() returned 0 until Benjamin Coddington's
commit below. Now it fails with EIO, but the data is still lost.

RFC 8881, section 12.7.4 gives the recovery: a LAYOUTCOMMIT with
loca_reclaim set, sent during the server's grace period. nfsd accepts
one. The Linux client never sends it:

 - encode_layoutcommit() hardcodes loca_reclaim to false.
 - nfs4_layoutcommit_done() ignores NFS4ERR_GRACE, so a commit refused
   during grace is never sent again.
 - pnfs_layout_handle_reboot() returns and invalidates the layouts,
   and the layout driver's record of the uncommitted extents goes with
   them.

We hit this on a block-layout export served from XFS. Writes made under
a layout in the minutes before a metadata server restart read back as
zeros on a second client (about 25 MiB per file, 12,909 blocks). fio on
the writer reported success.

Patch 1 encodes the flag and sends a reclaiming commit on a privileged
slot. Patch 2 retries a commit refused with NFS4ERR_GRACE. Patch 3 adds
a prepare_layoutcommit_reclaim layout driver operation and sends the
reclaim from pnfs_layout_handle_reboot(), before each layout is
returned or invalidated. A refused reclaim is recorded as a writeback
error, so fsync() and close() report it. Patch 4 implements the
operation for the block and SCSI layouts. It includes extents whose
ordinary commit was still in flight at the restart.

The series is based on Trond's testing branch, because it builds on
Benjamin Coddington's "pnfs/blocklayout: report data lost to a failed
LAYOUTCOMMIT" there. With that commit, a commit refused with
NFS4ERR_GRACE fails fsync() with EIO instead of returning 0; patch 2
turns it into a retry. Patch 4 keeps a failed reclaim from recording
that error, since recovery sends the reclaim again.

Tested on arm64 under QEMU, on the testing branch and on v7.3-rc7, with
two VMs: nfsd exporting XFS with pnfs on an nvmet NVMe/TCP namespace
(SCSI layouts), and a client that writes 64 MiB with O_DIRECT, keeps
the file open without fsync(), and closes it after nfsd restarts:

 - Client connected through the restart: without the series the file
   is lost (size 0, all zeros). With it, the LAYOUTCOMMIT with
   loca_reclaim set is accepted before RECLAIM_COMPLETE, and the file
   is intact in every run, on both bases.
 - Client cut off until grace is over: the data cannot be saved. On
   the testing branch, fsync() or close() fails with EIO, with or
   without the series. On v7.3-rc7 both return 0, with or without the
   series. That report comes from Benjamin's commit, not from this
   series, so a backport of the series should carry it too.

The reproducer builds both kernels and a Debian root file system in
Docker and runs the VMs with QEMU (KVM, HVF, or TCG):

  https://gist.github.com/noctarius/bd6055d0c0bb2c9e7d630076ddc59806

Not tested: the block layout (blkmapd), an ordinary LAYOUTCOMMIT in
flight at the restart, and a server that refuses a reclaim sent during
grace (patch 3's EIO path; a client that misses grace never sends one).

The series was written with the help of an LLM-based coding assistant.
It was used to trace the client's recovery and LAYOUTCOMMIT paths
against RFC 8881, to draft the changes and changelogs, and to run
checkpatch. I reviewed the changes and the analysis behind them.

Signed-off-by: Christoph Engelbert <me@noctarius.com>
---
Christoph Engelbert (4):
      NFSv4.1: encode loca_reclaim in LAYOUTCOMMIT
      NFSv4.1: retry a LAYOUTCOMMIT refused with NFS4ERR_GRACE
      pNFS: reclaim uncommitted layout writes after a server restart
      pnfs/blocklayout: reclaim uncommitted extents after a server restart

 fs/nfs/blocklayout/blocklayout.c |   8 +++
 fs/nfs/blocklayout/blocklayout.h |   8 +++
 fs/nfs/blocklayout/extent_tree.c | 118 +++++++++++++++++++++++++++--------
 fs/nfs/nfs4proc.c                |  11 +++-
 fs/nfs/nfs4xdr.c                 |   2 +-
 fs/nfs/pnfs.c                    | 130 ++++++++++++++++++++++++++++++++++++++-
 fs/nfs/pnfs.h                    |   8 +++
 include/linux/nfs_xdr.h          |   1 +
 8 files changed, 254 insertions(+), 32 deletions(-)
---
base-commit: 3e19991734326332c736e24c9b47b2cffb8f9e42
change-id: 20261201-pnfs-layoutcommit-reclaim-nfs-testing-be4ad2026feb

Best regards,
--  
Christoph Engelbert <me@noctarius.com>



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-12-04  9:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 14:18 [PATCH 0/4] pNFS: reclaim uncommitted layout writes after a server restart Christoph Engelbert via B4 Relay
2026-12-01 14:18 ` [PATCH 1/4] NFSv4.1: encode loca_reclaim in LAYOUTCOMMIT Christoph Engelbert via B4 Relay
2026-12-04  9:42   ` Christoph Hellwig
2026-12-01 14:18 ` [PATCH 2/4] NFSv4.1: retry a LAYOUTCOMMIT refused with NFS4ERR_GRACE Christoph Engelbert via B4 Relay
2026-12-04  9:42   ` Christoph Hellwig
2026-12-01 14:18 ` [PATCH 3/4] pNFS: reclaim uncommitted layout writes after a server restart Christoph Engelbert via B4 Relay
2026-12-04  9:43   ` Christoph Hellwig
2026-12-01 14:18 ` [PATCH 4/4] pnfs/blocklayout: reclaim uncommitted extents " Christoph Engelbert via B4 Relay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox