Linux XFS filesystem development
 help / color / mirror / Atom feed
* support for RT data checksums v2
@ 2026-11-04  8:57 Christoph Hellwig
  2026-11-04  8:57 ` [PATCH 01/25] block: export fs_bio_integrity_verify Christoph Hellwig
                   ` (24 more replies)
  0 siblings, 25 replies; 34+ messages in thread
From: Christoph Hellwig @ 2026-11-04  8:57 UTC (permalink / raw)
  To: Carlos Maiolino; +Cc: linux-xfs, linux-fsdevel

Hi all,

data checksums provide an additional safeguard against silent data loss.

In classic XFS they were hard to support because they need to be
atomically updated with the written data.  The zoned allocator solves
that problem because it always writes out of place, and the checksums
can be committed at the same as the metadata linking the newly written
file data into place.  In theory, a conventional allocator could be used
in combination with the always_cow option, but there are few upsides of
this compared to using the zoned allocator.

Data checksums are stored in per-realtime group files in the metadir,
similar to other modern RT metadata.  Unlike the checksum design in btrfs
or some other file system, the checksums are associated with the
physical blocks, and not with logical data in files.  This reduces the
mapping overhead, and significantly reduces the write amplification,
and also avoids duplicate checksums for reflinked files (although those
are not yet supported with the zoned allocator anyway).

The initial version provides two checksums algorithms: crc32c and crc64.
Both of those are cyclic redundancy check algorithms which provide known
good detection of bit flips that is better than general purpose hash
functions.  Both are not cryptographic hashes and thus do not provide any
kind of protection against intentional tampering with the data.
The crc32c parameters exactly match those use for xfs metadata checksums,
and also those used by the default btrfs checksum, and the NVMe PI
formats using crc32c.  The crc64 parameters exactly match those using
the NVMe PI formats using crc64.  crc32c provides reasonable assurance
for today's hardware, but might prove limiting for extremely large data
sets, crc64 fills that void, but probably warrants using > 4k file system
block sizes to amortize the overhead.

In this series the checksums are only used to check data integrity
and report issues with it.  That on it's own is a bit of a lame story,
but it is important as a building block for two additional features
under development:

 - exposing the checksum to userspace through io_uring with
   IORING_RW_ATTR_FLAG_PI.  A prototype of this exists, but it needs
   a bit more rework of common code than I'd like for the initial
   review.  As a side effect this support will also support salvaging
   data with bad checksums for analysis in userspace.
 - retrying reads through a different replica from RAID devices that
   provide it.  This has been proposed before and requires some
   hairy block layer infrastructure.  I have a prototype for MD-based
   mirrors that can be extended to other use cases.  The same mechanism
   can also be used to retry reads for the already checksum protected
   XFS metadata.

The performance drop when using data checksums is between not measurable
to about 2% for most workloads on HDD and SSD.  On fast enough SSDs
single threaded large reads can see up to 10% slow down as the
checksum validation runs on a strict per-cpu workqueue through the block
layer in-task bio completion.  If needed, different completion methods
that distribute the I/O completions could be added.

This series is repost with all the code review comments from last round
hopefully addressed to resync with -rc1, but without full benchmarking of
the new one-shot log item based approach, and without a design document.
If you need that to digest the code, this version is not for you.

    git://git.infradead.org/users/hch/xfs.git xfs-crc

Gitweb:

    https://git.infradead.org/?p=users/hch/xfs.git;a=shortlog;h=refs/heads/xfs-crc

Note that the series will need a rebase on top of the fsverity work,
but the code points have been chosen to hopefully not conflict.

The userspace repositories are here:

    git://git.infradead.org/users/hch/xfsprorgs.git xfs-crc
    git://git.infradead.org/users/hch/xfstests-dev.git xfs-crc


Changes since v1:
 - improve various comments and commit logs in terms of spelling and
   structure
 - minor indentation fixes
 - add a big comment explaining the io_parent/io_csum_alloc/io_csum_alloc
   union and the relation to the io_csum field in struct iomap_ioend.
 - add a log reservation assert in xfs_rtfile_initialize_block
 - use xfs_rgblock_t instead of xfs_rtblock_t in two places that clearly
   deal with rgblock numbers
 - clear oz_csum_bufs on zone open failure for extra belts and suspenders
 - add a comment on the bi_idx assert in xfs_rtcsum_prepare_read
 - add an assert and improve the comment for the no-bp case in
   xfs_rtcsum_verify_ioend
 - add a comment (provided by Darrick) explaining the checksum log vs
   extent remap ordering
 - remove the unused csum_buf field from struct xfs_gc_bio
 - add a comment explaining the xfs_submit_verify_bio_csum return value
 - make the end calculation in xfs_submit_verify_bio_csum more
   rounding-safe with a code snipplet from Darrick, and give up if
   the range is empty afterwards
 - use plural "data checksums" in the experimental warning
 - s/xfs_rgb_to_/rgbno_to_/
 - improve superblock field validation
 - add health reporting (XFS_RTGROUP_GEOM_SICK_CSUM)
 - reduce the log reservation that added a bit too much slack in some
   cases
 - use xfs_buf_set_uptodate
 - fix error handling in xfs_rtcsum_open_zone
 - don't enable xfs_iomap_read_ops for all device that require stable
   pages
 - remove an extra xfs_rtcsum.h include in xfs_zone_alloc.c
 - fix a lost error in xfs_zone_gc_finish_chunk
 - set bi_end_io earlier to fix completions when xfs_rtcsum_prepare_read
   fails
 - add a xfs_min_diosize helper to share code between the aops and
   statx reporting
 - add a XFS_FEAT_* value for rtcsum
 - switch to an INCOMPAT flag as old kernels don't like the padding reuse
   in xfs_dsb
 - fix a buffer double buffer put in the read async error path
 - fix arithmerics on the media verify ioctl
 - refactor get_cache_zone to avoid a sleep under RCU condition
 - hold the IOLOCK over zone reset to synchronize with media verification,
   and check the write pointer and not just for an empty zone
 
Diffstat:
 block/bio-integrity-fs.c        |    1 
 fs/iomap/bio.c                  |    2 
 fs/iomap/direct-io.c            |    2 
 fs/iomap/internal.h             |   27 ++-
 fs/iomap/ioend.c                |   78 +++++++++
 fs/xfs/Kconfig                  |    1 
 fs/xfs/Makefile                 |    3 
 fs/xfs/libxfs/xfs_cksum.h       |    7 
 fs/xfs/libxfs/xfs_format.h      |   46 +++++
 fs/xfs/libxfs/xfs_fs.h          |    7 
 fs/xfs/libxfs/xfs_health.h      |    4 
 fs/xfs/libxfs/xfs_log_format.h  |   13 +
 fs/xfs/libxfs/xfs_log_recover.h |    1 
 fs/xfs/libxfs/xfs_ondisk.h      |    5 
 fs/xfs/libxfs/xfs_rtbitmap.c    |   57 ++++---
 fs/xfs/libxfs/xfs_rtbitmap.h    |    3 
 fs/xfs/libxfs/xfs_rtcsumfile.c  |   95 ++++++++++++
 fs/xfs/libxfs/xfs_rtcsumfile.h  |  150 +++++++++++++++++++
 fs/xfs/libxfs/xfs_rtgroup.c     |   16 ++
 fs/xfs/libxfs/xfs_rtgroup.h     |   26 +++
 fs/xfs/libxfs/xfs_sb.c          |   91 +++++++++++
 fs/xfs/libxfs/xfs_sb.h          |    1 
 fs/xfs/libxfs/xfs_shared.h      |    1 
 fs/xfs/libxfs/xfs_trans_resv.c  |   26 +++
 fs/xfs/libxfs/xfs_trans_resv.h  |    4 
 fs/xfs/scrub/agheader.c         |    5 
 fs/xfs/xfs_aops.c               |    3 
 fs/xfs/xfs_buf.c                |   96 ++++++++++++
 fs/xfs/xfs_buf.h                |    4 
 fs/xfs/xfs_buf_item_recover.c   |   10 +
 fs/xfs/xfs_file.c               |   21 ++
 fs/xfs/xfs_health.c             |    1 
 fs/xfs/xfs_inode.h              |   22 ++
 fs/xfs/xfs_ioctl.c              |    2 
 fs/xfs/xfs_ioend.c              |  175 ++++++++++++++++++++--
 fs/xfs/xfs_ioend.h              |    2 
 fs/xfs/xfs_iomap.c              |   72 ++++++++-
 fs/xfs/xfs_iomap.h              |    4 
 fs/xfs/xfs_iops.c               |    8 -
 fs/xfs/xfs_log.h                |    3 
 fs/xfs/xfs_log_recover.c        |    3 
 fs/xfs/xfs_message.c            |    4 
 fs/xfs/xfs_message.h            |    1 
 fs/xfs/xfs_mount.h              |    6 
 fs/xfs/xfs_platform.h           |    1 
 fs/xfs/xfs_reflink.c            |    2 
 fs/xfs/xfs_rtalloc.c            |   11 +
 fs/xfs/xfs_rtcsum.c             |  315 ++++++++++++++++++++++++++++++++++++++++
 fs/xfs/xfs_rtcsum.h             |   30 +++
 fs/xfs/xfs_rtcsum_item.c        |  218 +++++++++++++++++++++++++++
 fs/xfs/xfs_super.c              |   21 ++
 fs/xfs/xfs_sysfs.c              |    2 
 fs/xfs/xfs_trace.h              |    3 
 fs/xfs/xfs_verify_media.c       |  194 +++++++++++++++++++-----
 fs/xfs/xfs_zone_alloc.c         |   43 ++++-
 fs/xfs/xfs_zone_gc.c            |   73 +++++++--
 fs/xfs/xfs_zone_priv.h          |    8 +
 include/linux/iomap.h           |   42 +++++
 58 files changed, 1932 insertions(+), 140 deletions(-)

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2026-11-11 17:39 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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)
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox