RE:(2) [PATCH] xfs: refuse a pNFS LAYOUTCOMMIT of a range without blocks

From: Daejun Park

Date: Tue Oct 13 2026 - 21:40:35 EST


On Tue, Oct 13, 2026 at 02:03:59PM +0200, Christoph Hellwig wrote:
> blockgc really should not free them due to the prealloc inode flag.
> Do you still see that with your prefix flag setting fix? If so we
> have a deeper problem.

I don't see it with "xfs: mark the inode preallocated for pNFS write
layouts past EOF" applied: in the same test, blockgc keeps the blocks
and the LAYOUTCOMMIT succeeds with the client's data in place. The
sentence was about trees without that patch, so I'll drop it in v2 and
keep the reclaim case and the range that was never laid out.

> It would be great to get these included in pynfs.
>
> Also a little doc on your setup to run pynfs in client mode against
> nfsd with block/scsilayout would probably useful.

Sure, I'll send them to pynfs with a short README section on the setup,
on top of the block layout test I posted earlier:
https://lore.kernel.org/r/20261006002622epcms2p38e492aef17fdf79e48b05c9aada2918d@epcms2p3

> As soon as we drop the lock, the result might be stale. So I suspect
> we want a CONVERT_ONLY flag to xfs_bmapi_write that makes it refuse
> to allocate blocks instead in one atomic operation.

The IOLOCK held across both keeps truncate, fallocate and blockgc out
today, but the flag doesn't depend on that, so v2 does it that way:
xfs_bmapi_write() takes a new XFS_BMAPI_CONVERT_ONLY flag that fails for
a hole or a delalloc extent instead of allocating, and
xfs_fs_commit_blocks() passes it through xfs_iomap_write_unwritten().

One difference from v1: a LAYOUTCOMMIT with a laid-out range followed by
a hole now converts the laid-out range before it fails.
xfs_fs_commit_blocks() already left earlier extents converted when a
later one failed, and the Linux client resends all of its extents after
a failed LAYOUTCOMMIT, so I don't think that matters.