Re: [PATCH] xfs: punch delalloc blocks past EOF before mapping a pNFS layout

From: Christoph Hellwig

Date: Mon Nov 30 2026 - 08:02:18 EST


On Thu, Nov 26, 2026 at 10:45:47AM +0900, Daejun Park via B4 Relay wrote:
> @@ -192,6 +193,18 @@ xfs_fs_map_blocks(
> if (WARN_ON_ONCE(error))
> goto out_unlock;
>
> + /*
> + * Writeback stops allocating a delalloc extent once the page it writes
> + * is covered, so speculative preallocation past EOF can stay delalloc.
> + * Delalloc past EOF never holds data. Punch all of it, as
> + * xfs_free_eofblocks() does for preallocated files, so that a layout
> + * never maps it and a LAYOUTCOMMIT never moves EOF over it.
> + */
> + if (ip->i_delayed_blks)
> + xfs_bmap_punch_delalloc_range(ip, XFS_DATA_FORK,
> + round_up(XFS_ISIZE(ip), mp->m_sb.sb_blocksize),
> + LLONG_MAX, NULL);
> +

This is basically a xfs_free_eofblocks. I think we also should do a
xfs_inode_clear_eofblocks_tag here, and we also need to do a
inode_dio_wait to settle i_size after taking the iolock.