Linux filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Carlos Maiolino <cem@kernel.org>, Jens Axboe <axboe@kernel.dk>,
	Christian Brauner <brauner@kernel.org>,
	linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 13/21] xfs: require file system block size alignment when using data checksums
Date: Fri, 25 Sep 2026 16:24:56 -0700	[thread overview]
Message-ID: <20260925232456.GH2705364@frogsfrogsfrogs> (raw)
In-Reply-To: <20260924100032.2733101-14-hch@lst.de>

On Thu, Sep 24, 2026 at 11:59:45AM +0200, Christoph Hellwig wrote:
> The checksums cover a whole block, so we can't read or update parts of a
> block.  Report the requirement and enforce it for direct I/O reads.
> Direct I/O writes already require file system block size alignment when
> using the zoned allocator, and buffered I/O never does sub-block I/O.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_file.c  | 14 +++++++++++++-
>  fs/xfs/xfs_ioend.c | 13 +++++++++++--
>  fs/xfs/xfs_iops.c  | 10 +++++++++-
>  3 files changed, 33 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index 6f25879b6510..5b25f33527c0 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -29,6 +29,7 @@
>  #include "xfs_zone_alloc.h"
>  #include "xfs_error.h"
>  #include "xfs_errortag.h"
> +#include "xfs_rtcsum.h"
>  
>  #include <linux/dax.h>
>  #include <linux/falloc.h>
> @@ -270,9 +271,20 @@ xfs_file_dio_read(
>  	if (ret)
>  		return ret;
>  	if (mapping_stable_writes(iocb->ki_filp->f_mapping)) {
> +		unsigned int		dio_flags = 0;
> +
> +		/*
> +		 * Each checksums covers a whole file system block, and thus
> +		 * sub-fsblock reads are not supported for file systems using
> +		 * data checksums.
> +		 */
> +		if (xfs_is_rtcsum_inode(ip))
> +			dio_flags |= IOMAP_DIO_FSBLOCK_ALIGNED;
>  		ret = iomap_dio_rw(iocb, to, &xfs_read_iomap_ops,
> -				&xfs_dio_read_bounce_ops, 0, NULL, 0);
> +				&xfs_dio_read_bounce_ops, dio_flags, NULL, 0);
>  	} else {
> +		ASSERT(!xfs_is_rtcsum_inode(ip));
> +
>  		ret = iomap_dio_read_simple(iocb, to, xfs_read_iomap_begin);
>  		if (ret == -ENOTBLK)
>  			ret = iomap_dio_rw(iocb, to, &xfs_read_iomap_ops, NULL,
> diff --git a/fs/xfs/xfs_ioend.c b/fs/xfs/xfs_ioend.c
> index f0e01ac34de8..54bd0995ac29 100644
> --- a/fs/xfs/xfs_ioend.c
> +++ b/fs/xfs/xfs_ioend.c
> @@ -44,6 +44,15 @@ xfs_bounce_submit_ioend(
>  	submit_bio(&ioend->io_bio);
>  }
>  
> +static unsigned int
> +xfs_read_bounce_minsize(
> +	struct iomap_ioend	*ioend)
> +{
> +	if (xfs_is_rtcsum_inode(XFS_I(ioend->io_inode)))
> +		return i_blocksize(ioend->io_inode);
> +	return bdev_logical_block_size(ioend->io_bio.bi_bdev);
> +}
> +
>  static void
>  xfs_end_bio_bounced(
>  	struct bio		*bio)
> @@ -86,7 +95,7 @@ xfs_read_bounce_and_resubmit(
>  		.bi_offset	= ioend->io_bvec_offset,
>  	};
>  	bio->bi_end_io = xfs_end_bio_bounced;
> -	iomap_bounce_read(ioend, bdev_logical_block_size(bio->bi_bdev),
> +	iomap_bounce_read(ioend, xfs_read_bounce_minsize(ioend),
>  			xfs_bounce_submit_ioend);
>  	memalloc_nofs_restore(nofs_flag);
>  }
> @@ -134,7 +143,7 @@ xfs_ioend_submit_read(
>  	ioend = iomap_init_ioend(inode, bio, file_offset, ioend_flags);
>  	if ((ioend_flags & IOMAP_IOEND_DIRECT) &&
>  	    READ_ONCE(mp->m_read_bounce) == XFS_READ_BOUNCE_ALWAYS) {
> -		iomap_bounce_read(ioend, bdev_logical_block_size(bio->bi_bdev),
> +		iomap_bounce_read(ioend, xfs_read_bounce_minsize(ioend),
>  				xfs_bounce_submit_ioend);
>  		return;
>  	}
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index d1306e723899..a5f01e2e3a67 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -581,6 +581,15 @@ xfs_report_dioalign(
>  	stat->result_mask |= STATX_DIOALIGN | STATX_DIO_READ_ALIGN;
>  	stat->dio_mem_align = bdev_dma_alignment(bdev) + 1;
>  
> +	/*
> +	 * Each checksums covers a whole file system block, and thus sub-fsblock
> +	 * reads are not supported for file systems using data checksums.
> +	 */
> +	if (xfs_is_rtcsum_inode(ip))
> +		stat->dio_read_offset_align = xfs_inode_alloc_unitsize(ip);

The allocation unit could be larger than the fsblock size, why is it
necessary to have such large directio reads on a checksummed file?
Though come to think of it zoned mode doesn't allow rtextsize > 1fsb
so this question might be hair-splitting.

I think you could reuse xfs_read_bounce_minsize() here.

--D

> +	else
> +		stat->dio_read_offset_align = bdev_logical_block_size(bdev);
> +
>  	/*
>  	 * For COW inodes, we can only perform out of place writes of entire
>  	 * allocation units (blocks or RT extents).
> @@ -591,7 +600,6 @@ xfs_report_dioalign(
>  	 * alignment in dio_offset_align, and the smaller read alignment in
>  	 * dio_read_offset_align.
>  	 */
> -	stat->dio_read_offset_align = bdev_logical_block_size(bdev);
>  	if (xfs_is_cow_inode(ip))
>  		stat->dio_offset_align = xfs_inode_alloc_unitsize(ip);
>  	else
> -- 
> 2.53.0
> 
> 

  reply	other threads:[~2026-09-25 23:24 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24  9:59 support for RT data checksums Christoph Hellwig
2026-09-24  9:59 ` [PATCH 01/21] block: export fs_bio_integrity_verify Christoph Hellwig
2026-09-24 20:29   ` Darrick J. Wong
2026-09-24  9:59 ` [PATCH 02/21] iomap: add support for data checksumming Christoph Hellwig
2026-09-24 21:39   ` Darrick J. Wong
2026-09-25  5:53     ` Christoph Hellwig
2026-09-24  9:59 ` [PATCH 03/21] xfs: add a xfs_buf_read_async buffer cache API Christoph Hellwig
2026-09-24 21:43   ` Darrick J. Wong
2026-09-25  5:54     ` Christoph Hellwig
2026-09-24  9:59 ` [PATCH 04/21] xfs: add xfs_daddr_to_rgno and xfs_daddr_to_rgbno helpers Christoph Hellwig
2026-09-24 21:44   ` Darrick J. Wong
2026-09-24  9:59 ` [PATCH 05/21] xfs: introduce XFS_BLI_PREALLOC Christoph Hellwig
2026-09-24 21:49   ` Darrick J. Wong
2026-09-25  5:57     ` Christoph Hellwig
2026-10-08 11:46   ` Anuj gupta
2026-09-24  9:59 ` [PATCH 06/21] xfs: prepare xfs_rtfile_initialize_blocks for larger than FSB blocks Christoph Hellwig
2026-09-24 22:03   ` Darrick J. Wong
2026-09-25  5:58     ` Christoph Hellwig
2026-09-24  9:59 ` [PATCH 07/21] xfs: relase zi_open_zones_lock over xfs_open_zone_put on unmount Christoph Hellwig
2026-09-24  9:59 ` [PATCH 08/21] xfs: define the RT data checksum on-disk format Christoph Hellwig
2026-09-24 22:13   ` Darrick J. Wong
2026-09-25  0:04     ` Eric Biggers
2026-09-25  6:01     ` Christoph Hellwig
2026-09-24  9:59 ` [PATCH 09/21] xfs: add support for per-RTG csum files Christoph Hellwig
2026-09-24 22:24   ` Darrick J. Wong
2026-09-25  6:10     ` Christoph Hellwig
2026-09-24  9:59 ` [PATCH 10/21] xfs: calculate the log reservation for logging data checksum buffers Christoph Hellwig
2026-09-24 22:30   ` Darrick J. Wong
2026-09-25  6:12     ` Christoph Hellwig
2026-09-24  9:59 ` [PATCH 11/21] xfs: core RT data checksum support Christoph Hellwig
2026-09-25 23:20   ` Darrick J. Wong
2026-09-26  6:13     ` Christoph Hellwig
2026-09-24  9:59 ` [PATCH 12/21] xfs: data checksums require stable writes Christoph Hellwig
2026-09-25 23:21   ` Darrick J. Wong
2026-09-24  9:59 ` [PATCH 13/21] xfs: require file system block size alignment when using data checksums Christoph Hellwig
2026-09-25 23:24   ` Darrick J. Wong [this message]
2026-09-26  6:15     ` Christoph Hellwig
2026-09-24  9:59 ` [PATCH 14/21] xfs: add support for reading with " Christoph Hellwig
2026-09-29  0:42   ` Darrick J. Wong
2026-10-05 12:59     ` Christoph Hellwig
2026-09-24  9:59 ` [PATCH 15/21] xfs: add support for writing " Christoph Hellwig
2026-09-29  1:01   ` Darrick J. Wong
2026-10-05 13:00     ` Christoph Hellwig
2026-09-24  9:59 ` [PATCH 16/21] xfs: add data checksum support to zoned garbage collection Christoph Hellwig
2026-09-29  1:06   ` Darrick J. Wong
2026-10-05 13:11     ` Christoph Hellwig
2026-09-24  9:59 ` [PATCH 17/21] xfs: verify data checksums during media verification Christoph Hellwig
2026-09-29  1:19   ` Darrick J. Wong
2026-10-05 13:13     ` Christoph Hellwig
2026-09-24  9:59 ` [PATCH 18/21] xfs: don't try to verify checksums on empty zones Christoph Hellwig
2026-09-29  1:25   ` Darrick J. Wong
2026-10-05 13:14     ` Christoph Hellwig
2026-10-08 11:43   ` Anuj gupta
2026-09-24  9:59 ` [PATCH 19/21] xfs: report RT data checksum information via XFS_FSOP_GEOM Christoph Hellwig
2026-09-29  1:26   ` Darrick J. Wong
2026-09-24  9:59 ` [PATCH 20/21] xfs: add an experimental feature warning for RT data checksums Christoph Hellwig
2026-09-29  1:27   ` Darrick J. Wong
2026-09-24  9:59 ` [PATCH 21/21] xfs: enable " Christoph Hellwig
2026-09-29  1:27   ` Darrick J. Wong
2026-10-05 13:16     ` Christoph Hellwig
2026-09-24 22:52 ` support for " Dave Chinner
2026-09-25  6:27   ` Christoph Hellwig
2026-09-27 22:59     ` Dave Chinner
2026-09-28  5:24       ` Christoph Hellwig
2026-09-29 14:11         ` Dave Chinner
2026-09-30  7:11           ` Dave Chinner
2026-10-05 13:53             ` Christoph Hellwig
2026-10-06  5:31               ` Dave Chinner
2026-10-07 13:46                 ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260925232456.GH2705364@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=cem@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox