Re: [PATCH 7/8] xfs: map the whole range of a pNFS layout in one ->map_blocks call

From: Chuck Lever

Date: Thu Oct 08 2026 - 12:38:39 EST


Daejun Park <daejun7.park@xxxxxxxxxxx> wrote:
> If an allocation fails after others in the same call, the error is
> returned without the inode update and the log force. nfsd then fails the
> LAYOUTGET, so none of the blocks allocated is handed out; they stay
> unwritten, and blocks past EOF can be freed again unless the inode
> already has XFS_DIFLAG_PREALLOC or the file is empty.

The same freeing can happen to blocks a client holds a write layout
for, AFAICS. But that is not new. Commit 527851124d10 handed out the
same blocks.

This is however the patch where a fix could go.


> + while (nr < *nr_iomaps && offset_fsb < end_fsb) {
> + struct xfs_bmbt_irec imap;
> + u64 seq;
> +
> + error = xfs_fs_map_extent(ip, offset_fsb, offset + length,
> + write, &imap, &seq, &allocated);
> + if (error)
> + goto out_unlock;
> + error = xfs_bmbt_to_iomap(ip, &iomaps[nr++], &imap, 0, 0, seq);
> + if (error)
> + goto out_unlock;
> + offset_fsb = imap.br_startoff + imap.br_blockcount;
> + }


--
Chuck Lever (Come to NFS bake-a-thon! https://nfsv4bat.org)