Re: [PATCH] pNFS: Check lseg validity before marking a layout for return

From: Trond Myklebust

Date: Tue Aug 18 2026 - 13:59:10 EST


On Thu, 2026-08-13 at 13:58 +0000, tmenninger@xxxxxxxxxxxxxxx wrote:
> From: Tim Menninger <tmenninger@xxxxxxxxxxxxxxx>
>
> pnfs_error_mark_layout_for_return() receives the lseg associated with
> the failed I/O but previously used only its I/O mode, operating on
> the
> inode's current layout header regardless of whether the lseg itself
> was
> still valid.
>
> A layout stateid can be invalidated while RPCs still hold references
> to
> its lsegs. pnfs_mark_layout_stateid_invalid() clears NFS_LSEG_VALID
> on
> those lsegs through pnfs_clear_lseg_state(). A subsequent LAYOUTGET
> can
> install a replacement stateid in the same pnfs_layout_hdr. If an RPC
> using one of the old lsegs later reports an error, the current code
> can
> therefore mark the replacement layout for return.
>
> Once NFS_LSEG_VALID has been cleared, the lseg is no longer eligible
> for
> selection for new I/O and must not initiate another error-driven
> return
> of the inode's current layout. Fold pnfs_mark_layout_for_return()

I strongly disagree with the above premise that NFS_LSEG_VALID should
be used to gate layout returns. If the client tries to do I/O and
fails, then it is required to report the error, the type of I/O, and
the byte range to which it applies.
We attempt to redrive that layoutreturn as the outstanding I/O requests
fail. The EBUSY is there to ensure that we don't fire off the
layoutreturn until all the errors have been collected.


So NACK to this patch.
--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trondmy@xxxxxxxxxx, trond.myklebust@xxxxxxxxxxxxxxx