Re: [PATCH 15/22] iomap,xfs: move T10 PI handling for direct I/O into ->submit_io

"Darrick J. Wong" <[email protected]>
Newsgroups org.kernel.vger.linux-xfs,org.kernel.vger.linux-block,org.kernel.vger.linux-fsdevel
Message-ID <20260723205503.GE2901224@frogsfrogsfrogs>
On Thu, Jul 23, 2026 at 04:49:40PM +0200, Christoph Hellwig wrote:
> Currently the buffered I/O code defers PI handling into the submit
> handlers, while direct I/O does it in common code.  Move it all
> into the file system callbacks or their generic implementations
> to be consistent, and to allow file systems to shared helpers
> for submission of buffered and direct bios.
> 
> Signed-off-by: Christoph Hellwig <[email protected]>

I think I like this cleanup, the bio integrity setup code was scattered
around a lot of places.

Reviewed-by: "Darrick J. Wong" <[email protected]>

--D

> ---
>  fs/iomap/direct-io.c | 22 ++++++++++++----------
>  fs/xfs/xfs_file.c    | 13 ++++++++++---
>  2 files changed, 22 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
> index e2cd5f92babe..8d476f40a3bb 100644
> --- a/fs/iomap/direct-io.c
> +++ b/fs/iomap/direct-io.c
> @@ -75,10 +75,19 @@ static void iomap_dio_submit_bio(const struct iomap_iter *iter,
>  
>  	if (dio->dops && dio->dops->submit_io) {
>  		dio->dops->submit_io(iter, bio, pos);
> -	} else {
> -		WARN_ON_ONCE(iter->iomap.flags & IOMAP_F_ANON_WRITE);
> -		blk_crypto_submit_bio(bio);
> +		return;
> +	}
> +
> +	WARN_ON_ONCE(iter->iomap.flags & IOMAP_F_ANON_WRITE);
> +
> +	if (iter->iomap.flags & IOMAP_F_INTEGRITY) {
> +		if (dio->flags & IOMAP_DIO_WRITE)
> +			fs_bio_integrity_generate(bio);
> +		else
> +			fs_bio_integrity_alloc(bio);
>  	}
> +
> +	blk_crypto_submit_bio(bio);
>  }
>  
>  static inline enum fserror_type iomap_dio_err_type(const struct iomap_dio *dio)
> @@ -372,13 +381,6 @@ static ssize_t iomap_dio_bio_iter_one(struct iomap_iter *iter,
>  		goto out_bio_release_pages;
>  	}
>  
> -	if (iter->iomap.flags & IOMAP_F_INTEGRITY) {
> -		if (dio->flags & IOMAP_DIO_WRITE)
> -			fs_bio_integrity_generate(bio);
> -		else
> -			fs_bio_integrity_alloc(bio);
> -	}
> -
>  	if (dio->flags & IOMAP_DIO_WRITE)
>  		task_io_account_write(ret);
>  	else if ((dio->flags & IOMAP_DIO_USER_BACKED) &&
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index e94a26f32e65..80dd278e023f 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -37,6 +37,7 @@
>  #include <linux/fadvise.h>
>  #include <linux/mount.h>
>  #include <linux/filelock.h>
> +#include <linux/bio-integrity.h>
>  
>  static const struct vm_operations_struct xfs_file_vm_ops;
>  
> @@ -235,8 +236,12 @@ xfs_dio_read_bounce_submit_io(
>  	struct bio		*bio,
>  	loff_t			file_offset)
>  {
> -	iomap_init_ioend(iter->inode, bio, file_offset,
> -		iomap_ioend_flags(&iter->iomap) | IOMAP_IOEND_DIRECT);
> +	struct iomap_ioend	*ioend;
> +
> +	ioend = iomap_init_ioend(iter->inode, bio, file_offset,
> +			iomap_ioend_flags(&iter->iomap) | IOMAP_IOEND_DIRECT);
> +	if (ioend->io_flags & IOMAP_IOEND_INTEGRITY)
> +		fs_bio_integrity_alloc(bio);
>  	bio->bi_end_io = xfs_end_bio;
>  	submit_bio(bio);
>  }
> @@ -725,7 +730,9 @@ xfs_dio_zoned_submit_io(
>  
>  	bio->bi_end_io = xfs_end_bio;
>  	ioend = iomap_init_ioend(iter->inode, bio, file_offset,
> -		iomap_ioend_flags(&iter->iomap) | IOMAP_IOEND_DIRECT);
> +			iomap_ioend_flags(&iter->iomap) | IOMAP_IOEND_DIRECT);
> +	if (ioend->io_flags & IOMAP_IOEND_INTEGRITY)
> +		fs_bio_integrity_generate(bio);
>  	xfs_zone_alloc_and_submit(ioend, &ac->open_zone);
>  }
>  
> -- 
> 2.53.0
> 
>
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.