Linux filesystem development
 help / color / mirror / Atom feed
From: "Pankaj Raghav (Samsung)" <pankaj.raghav@linux.dev>
To: Christoph Hellwig <hch@lst.de>
Cc: Carlos Maiolino <cem@kernel.org>,
	linux-xfs@vger.kernel.org,  linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 20/25] xfs: verify data checksums during media verification
Date: Wed, 11 Nov 2026 12:57:39 +0100	[thread overview]
Message-ID: <avRUQnZqmuiQVC1h@quentin> (raw)
In-Reply-To: <20261104085929.317544-21-hch@lst.de>

On Wed, Nov 04, 2026 at 09:57:24AM +0100, Christoph Hellwig wrote:
> Wire up reading and verifying data checksums during media verification.
> This is very similar to the file read path in that it kicks of an async
> read for the checksum buffer before reading the data, and then validating
> once both are read in.
> 
> To support this, split the per-read logic in xfs_verify_media into a
> separate helpers for the data checksums vs no checksum cases.
> 
> +
> +/*
> + * Data checksums are per-FSB, so we can only validate FSB-aligned regions.
> + *
> + * When the alignment leads to an empty range, give up.
> + */

A comment here would be helpful about the return values.
0 for success,
1 for media errors
errno for other errors.

> +static int
> +xfs_submit_verify_bio_csum(
> +	struct xfs_mount	*mp,
> +	struct xfs_verify_media	*me,
> +	struct xfs_buftarg	*btp,
> +	struct folio		*folio,
> +	xfs_daddr_t		*daddr)
> +{
> +	xfs_fsblock_t		bno = xfs_daddr_to_rtb(mp, *daddr);
> +	xfs_fsblock_t		end = xfs_daddr_to_rtb(mp, me->me_end_daddr);
> +	struct xfs_buf		*csum_bp = NULL;
> +	struct bvec_iter	saved_iter;
> +	unsigned int		bbcount;
> +	xfs_filblks_t		len;
> +	struct bio		bio;
> +	struct bio_vec		bv;
> +	int			error;
> +
> +	len = min3(end - bno, xfs_rtcsum_max_len(mp, bno),
> +			XFS_B_TO_FSBT(mp, folio_size(folio)));

For large block size systems, if we allocate a single page in the folio
due to fragmentation, len will always be zero (4096 >> (blocklog > 12)).

> +	if (!len) {
> +		*daddr = me->me_end_daddr;
> +		return 0;
> +	}

And we skip those ranges without verifying anything with a success.

I think we should raise the iosize to a single FSB in
xfs_verify_alloc_folio and should return ENOMEM if we cannot allocate
one?

> +
> +	error = xfs_rtcsum_read_async(mp, bno, &csum_bp);
> +	if (error)
> +		return error;
> +
> +	*daddr = xfs_rtb_to_daddr(mp, bno);
> +	bbcount = XFS_FSB_TO_BB(mp, len);
> +
> +	bio_init(&bio, btp->bt_bdev, &bv, 1, REQ_OP_READ);
> +	bio.bi_iter.bi_sector = *daddr;
> +	bio_add_folio_nofail(&bio, folio, bbcount << SECTOR_SHIFT, 0);
> +
> +	saved_iter = bio.bi_iter;
> +	error = submit_bio_wait(&bio);
> +	if (error) {
> +		xfs_verify_media_error(mp, me, btp, *daddr, bbcount, error);
> +		error = 1;
> +		goto out_buf_rele;
> +	}
> +
> +	error = xfs_buf_read_async_wait(csum_bp);
> +	if (error)
> +		goto out_buf_rele;
> +
> +	error = xfs_csum_verify(mp, &bio, &saved_iter,
> +			csum_bp->b_addr + xfs_rtb_to_rtcsumoff(mp, bno), bno,
> +			false);
> +	if (error) {
> +		xfs_verify_media_error(mp, me, btp, *daddr, bbcount, error);
> +		error = 1;
> +		goto out_buf_rele;
> +	}
> +
> +	*daddr = xfs_rtb_to_daddr(mp, bno + len);
> +out_buf_rele:
> +	xfs_buf_rele(csum_bp);
> +	bio_uninit(&bio);
> +	return error;
> +}
> +

-- 
Pankaj

  reply	other threads:[~2026-11-11 11:57 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04  8:57 support for RT data checksums v2 Christoph Hellwig
2026-11-04  8:57 ` [PATCH 01/25] block: export fs_bio_integrity_verify Christoph Hellwig
2026-11-04  8:57 ` [PATCH 02/25] iomap: add support for data checksumming Christoph Hellwig
2026-11-11 11:21   ` Pankaj Raghav (Samsung)
2026-11-11 17:38     ` Christoph Hellwig
2026-11-04  8:57 ` [PATCH 03/25] xfs: always call xfs_update_stable_writes in xfs_ioctl_setattr_xflags Christoph Hellwig
2026-11-11 11:11   ` Pankaj Raghav (Samsung)
2026-11-11 17:37     ` Christoph Hellwig
2026-11-04  8:57 ` [PATCH 04/25] xfs: use a separate lockdep class for all rmap inode locks Christoph Hellwig
2026-11-04  8:57 ` [PATCH 05/25] xfs: add a xfs_buf_read_async buffer cache API Christoph Hellwig
2026-11-04  8:57 ` [PATCH 06/25] xfs: add xfs_daddr_to_rgno and xfs_daddr_to_rgbno helpers Christoph Hellwig
2026-11-04  8:57 ` [PATCH 07/25] xfs: prepare xfs_rtfile_initialize_blocks for larger than FSB blocks Christoph Hellwig
2026-11-04  8:57 ` [PATCH 08/25] xfs: relase zi_open_zones_lock over xfs_open_zone_put on unmount Christoph Hellwig
2026-11-04  8:57 ` [PATCH 09/25] xfs: put the open zone outside RCU protection in xfs_get_cached_zone Christoph Hellwig
2026-11-04  8:57 ` [PATCH 10/25] xfs: define the RT data checksum on-disk format Christoph Hellwig
2026-11-04  8:57 ` [PATCH 11/25] xfs: add support for per-RTG csum files Christoph Hellwig
2026-11-04  8:57 ` [PATCH 12/25] xfs: calculate the log reservation for logging data checksum buffers Christoph Hellwig
2026-11-04  8:57 ` [PATCH 13/25] xfs: core RT data checksum support Christoph Hellwig
2026-11-04  8:57 ` [PATCH 14/25] xfs: data checksums require stable writes Christoph Hellwig
2026-11-04  8:57 ` [PATCH 15/25] xfs: require file system block size alignment when using data checksums Christoph Hellwig
2026-11-04  8:57 ` [PATCH 16/25] xfs: add support for reading with " Christoph Hellwig
2026-11-11 11:31   ` Pankaj Raghav (Samsung)
2026-11-11 17:38     ` Christoph Hellwig
2026-11-04  8:57 ` [PATCH 17/25] xfs: add support for writing " Christoph Hellwig
2026-11-04  8:57 ` [PATCH 18/25] xfs: add data checksum support to zoned garbage collection Christoph Hellwig
2026-11-04  8:57 ` [PATCH 19/25] xfs: simplify range tracking in xfs_verify_media Christoph Hellwig
2026-11-04  8:57 ` [PATCH 20/25] xfs: verify data checksums during media verification Christoph Hellwig
2026-11-11 11:57   ` Pankaj Raghav (Samsung) [this message]
2026-11-11 17:39     ` Christoph Hellwig
2026-11-04  8:57 ` [PATCH 21/25] xfs: don't try to verify checksums on empty zones Christoph Hellwig
2026-11-04  8:57 ` [PATCH 22/25] xfs: report RT data checksum information via XFS_FSOP_GEOM Christoph Hellwig
2026-11-04  8:57 ` [PATCH 23/25] xfs: add an experimental feature warning for RT data checksums Christoph Hellwig
2026-11-04  8:57 ` [PATCH 24/25] xfs: enable " Christoph Hellwig
2026-11-04  8:57 ` [PATCH 25/25] xfs: add a RT checksum log item 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=avRUQnZqmuiQVC1h@quentin \
    --to=pankaj.raghav@linux.dev \
    --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