Re: [PATCH] pNFS: Fix EBUSY check in pnfs_layout_need_return
From: Trond Myklebust
Date: Tue Aug 18 2026 - 14:28:53 EST
On Mon, 2026-08-17 at 15:40 +0000, tmenninger@xxxxxxxxxxxxxxx wrote:
> From: Tim Menninger <tmenninger@xxxxxxxxxxxxxxxx>
>
> Commit 41d0a8ead9720 ("NFSv4/pnfs: Add support for the
> PNFS_LAYOUT_FILE_BULK_RETURN flag") changed pnfs_layout_need_return()
> to
> check whether pnfs_mark_layout_stateid_return() returns -EBUSY.
>
> However, the new check compares the return value against EBUSY rather
> than -EBUSY. Since pnfs_mark_layout_stateid_return() returns negative
> errno values, the -EBUSY case is never detected.
>
> But pnfs_layout_need_return() calls pnfs_mark_layout_stateid_return()
> calls pnfs_mark_matching_lsegs_return(), which returns 0 if a
> layoutreturn needs to be scheduled.
>
> Fix the comparison in pnfs_layout_need_return() to check for 0, i.e.
> a
> layoutreturn needs to be scheduled.
>
> Fixes: 41d0a8ead9720 ("NFSv4/pnfs: Add support for the
> PNFS_LAYOUT_FILE_BULK_RETURN flag")
> Signed-off-by: Tim Menninger <tmenninger@xxxxxxxxxxxxxxxx>
> ---
> fs/nfs/pnfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
> index 9f32dd7c4c63..fb141cef4d54 100644
> --- a/fs/nfs/pnfs.c
> +++ b/fs/nfs/pnfs.c
> @@ -1389,7 +1389,7 @@ pnfs_layout_need_return(struct pnfs_layout_hdr
> *lo)
> return false;
> return pnfs_mark_layout_stateid_return(lo, &lo-
> >plh_return_segs,
> lo-
> >plh_return_iomode,
> - lo->plh_return_seq)
> != EBUSY;
> + lo->plh_return_seq)
> == 0;
> }
>
> static void pnfs_layoutreturn_before_put_layout_hdr(struct
> pnfs_layout_hdr *lo)
This breaks the ability of the client to respond to layout recalls even
when it does not think it holds a layout. That's a situation that can
occur when using soft or softerr mounts.
--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trondmy@xxxxxxxxxx, trond.myklebust@xxxxxxxxxxxxxxx