Re: [PATCH 4/5] xfs: factor out a xfs_iomap_set_anon_write helper

Hans Holmberg <[email protected]>
Newsgroups org.kernel.vger.linux-xfs
Message-ID <[email protected]>
On 11/08/2026 18:50, Christoph Hellwig wrote:
> De-duplicate the iomap setup for zoned writes.
> 
> Signed-off-by: Christoph Hellwig <[email protected]>
> Reviewed-by: "Darrick J. Wong" <[email protected]>
> ---
>  fs/xfs/xfs_aops.c  |  8 ++------
>  fs/xfs/xfs_iomap.c |  6 +-----
>  fs/xfs/xfs_iomap.h | 14 ++++++++++++++
>  3 files changed, 17 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
> index 9506cd8d15e6..d46b089f006a 100644
> --- a/fs/xfs/xfs_aops.c
> +++ b/fs/xfs/xfs_aops.c
> @@ -633,12 +633,8 @@ xfs_zoned_map_blocks(
>  			XFS_BMAPI_REMAP);
>  	xfs_iunlock(ip, XFS_ILOCK_EXCL);
>  
> -	wpc->iomap.type = IOMAP_MAPPED;
> -	wpc->iomap.bdev = mp->m_rtdev_targp->bt_bdev;
> -	wpc->iomap.offset = offset;
> -	wpc->iomap.length = XFS_FSB_TO_B(mp, count_fsb);
> -	wpc->iomap.flags = IOMAP_F_ANON_WRITE | IOMAP_F_DIRTY;
> -
> +	xfs_iomap_set_anon_write(ip, &wpc->iomap, offset,
> +			XFS_FSB_TO_B(mp, count_fsb));
>  	trace_xfs_zoned_map_blocks(ip, offset, wpc->iomap.length);
>  	return 0;
>  }
> diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
> index 9fa9aa33745f..e87c26c3e03b 100644
> --- a/fs/xfs/xfs_iomap.c
> +++ b/fs/xfs/xfs_iomap.c
> @@ -1080,11 +1080,7 @@ xfs_zoned_direct_write_iomap_begin(
>  			return error;
>  	}
>  
> -	iomap->type = IOMAP_MAPPED;
> -	iomap->bdev = ip->i_mount->m_rtdev_targp->bt_bdev;
> -	iomap->offset = offset;
> -	iomap->length = length;
> -	iomap->flags = IOMAP_F_ANON_WRITE | IOMAP_F_DIRTY;
> +	xfs_iomap_set_anon_write(ip, iomap, offset, length);
>  	return 0;
>  }
>  
> diff --git a/fs/xfs/xfs_iomap.h b/fs/xfs/xfs_iomap.h
> index ebcce7d49446..f697d7e73ab6 100644
> --- a/fs/xfs/xfs_iomap.h
> +++ b/fs/xfs/xfs_iomap.h
> @@ -29,6 +29,20 @@ int xfs_zero_range(struct xfs_inode *ip, loff_t pos, loff_t len,
>  int xfs_truncate_page(struct xfs_inode *ip, loff_t pos,
>  		struct xfs_zone_alloc_ctx *ac, bool *did_zero);
>  
> +static inline void
> +xfs_iomap_set_anon_write(
> +	struct xfs_inode		*ip,
> +	struct iomap			*iomap,
> +	loff_t				offset,
> +	loff_t				length)
> +{
> +	iomap->type = IOMAP_MAPPED;
> +	iomap->bdev = ip->i_mount->m_rtdev_targp->bt_bdev;
> +	iomap->offset = offset;
> +	iomap->length = length;
> +	iomap->flags = IOMAP_F_ANON_WRITE | IOMAP_F_DIRTY;
> +}
> +
>  static inline xfs_filblks_t
>  xfs_aligned_fsb_count(
>  	xfs_fileoff_t		offset_fsb,

Looks good,

Reviewed-by: Hans Holmberg <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.