RE:(2) [PATCH] xfs: mark the inode preallocated for pNFS write layouts past EOF
From: Daejun Park
Date: Mon Oct 12 2026 - 21:32:26 EST
On Mon, Oct 12, 2026 at 02:41:18PM +0200, Christoph Hellwig wrote:
> > + if (write && !(ip->i_diflags & XFS_DIFLAG_PREALLOC) &&
> > + imap.br_startoff + imap.br_blockcount >
> > + XFS_B_TO_FSB(mp, XFS_ISIZE(ip))) {
> > + error = xfs_fs_map_update_inode(ip);
> > + if (!error)
> > + error = xfs_log_force_inode(ip);
> > + if (error)
> > + goto out_unlock;
> > + }
>
> Let's avoid the code duplication here. Add a boolean flag that
> we need the update, set it both for the new allocation in the if
> le, and based on the condition here, and then do the update
> in a separate conditional below.
>
> And mayne the xfs_log_force_inode should move into
> xfs_fs_map_update_inode while we're at it.
Will do both in v2. xfs_fs_map_blocks() sets a flag for the allocation
and for a write mapping that ends past EOF over blocks that are already
there, and calls xfs_fs_map_update_inode() once after the if/else.
xfs_fs_map_update_inode() forces the log after committing the
transaction, so the separate xfs_log_force_inode() calls go away.
The behaviour does not change: the update still happens under the
IOLOCK, before the blocks are handed out. On nfsd-testing with the same
reproducer, the inode is marked at LAYOUTGET, blockgc keeps the blocks,
and the LAYOUTCOMMIT after 360 seconds succeeds with the data in place,
as with v1.
I will wait a few days for other comments on v1 and then send v2.