Linux XFS filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Andrey Albershteyn <aalbersh@kernel.org>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 29/32] mkfs: support RT data checksums
Date: Fri, 25 Sep 2026 16:39:08 -0700	[thread overview]
Message-ID: <20260925233908.GO2705364@frogsfrogsfrogs> (raw)
In-Reply-To: <20260924100512.2733748-30-hch@lst.de>

On Thu, Sep 24, 2026 at 12:04:19PM +0200, Christoph Hellwig wrote:
> Parse the -r csum and -r csumbisze options, set the superblock fields

                           csumbsize

> based on that and create the per-RTG csum files when requested.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  man/man8/mkfs.xfs.8.in |  17 ++++++
>  mkfs/proto.c           |   9 +++
>  mkfs/xfs_mkfs.c        | 126 ++++++++++++++++++++++++++++++++++++++++-
>  3 files changed, 149 insertions(+), 3 deletions(-)
> 
> diff --git a/man/man8/mkfs.xfs.8.in b/man/man8/mkfs.xfs.8.in
> index 927cd075bf8a..b2da1e76f10f 100644
> --- a/man/man8/mkfs.xfs.8.in
> +++ b/man/man8/mkfs.xfs.8.in
> @@ -1315,6 +1315,23 @@ Controls the amount of space in the realtime section that is reserved for
>  internal use by garbage collection and reorganization algorithms.
>  Defaults to 0 if not set.
>  This option is only valid if the zoned realtime allocator is used.
> +.TP
> +.BI csum= value
> +Controls which data checksum is used.
> +Valid options are
> +.I none
> +,
> +.I crc32c
> +and
> +.I crc64.
> +Defaults to
> +.I none
> +if not set.
> +This option is only valid if the zoned realtime allocator is used.
> +.TP
> +.BI csumbsize= value
> +Controls the blocksize of the data checksum files.  Valid values are
> +32k and 64k.  Defaults to 32k or the filesystem block size if larger.
>  .RE
>  .PP
>  .PD 0
> diff --git a/mkfs/proto.c b/mkfs/proto.c
> index 7ef8cc9d88a1..c232d1171d44 100644
> --- a/mkfs/proto.c
> +++ b/mkfs/proto.c
> @@ -11,6 +11,8 @@
>  #include <sys/xattr.h>
>  #include <linux/xattr.h>
>  #include "libfrog/convert.h"
> +#include "libfrog/crc64.h"
> +#include "libxfs/xfs_rtcsumfile.h"
>  #include "proto.h"
>  
>  /*
> @@ -1221,6 +1223,13 @@ rtinit_groups(
>  				fail(_("rtrmap rtsb init failed"), error);
>  		}
>  
> +		if (xfs_has_rtcsum(mp)) {
> +			error = xfs_rtcsum_alloc_blocks(rtg);
> +			if (error)
> +				fail(_("Initialization of rtcsum inode failed"),
> +					error);
> +		}
> +
>  		if (!xfs_has_zoned(mp))
>  			rtfreesp_init(rtg);
>  	}
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 334367b81555..9abeca61ee2a 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -6,15 +6,17 @@
>  #include "libfrog/util.h"
>  #include "libxfs.h"
>  #include <ctype.h>
> -#include "libxfs/xfs_zones.h"
>  #include "xfs_multidisk.h"
>  #include "libxcmd.h"
>  #include "libfrog/fsgeom.h"
>  #include "libfrog/convert.h"
>  #include "libfrog/crc32cselftest.h"
> +#include "libfrog/crc64.h"
>  #include "libfrog/dahashselftest.h"
>  #include "libfrog/fsproperties.h"
>  #include "libfrog/zones.h"
> +#include "libxfs/xfs_zones.h"
> +#include "libxfs/xfs_rtcsumfile.h"
>  #include "proto.h"
>  #include <ini.h>
>  
> @@ -145,6 +147,8 @@ enum {
>  	R_ZONED,
>  	R_START,
>  	R_RESERVED,
> +	R_CSUM,
> +	R_CSUMBSIZE,

BTW now that Andrey has merged the config file generator code, you'll
have to add the relevant R_CSUM/R_CSUMBSIZE bits to libfrog/fsgeom.c.

>  	R_MAX_OPTS,
>  };
>  
> @@ -777,6 +781,8 @@ static struct opt_params ropts = {
>  		[R_ZONED] = "zoned",
>  		[R_START] = "start",
>  		[R_RESERVED] = "reserved",
> +		[R_CSUM] = "csum",
> +		[R_CSUMBSIZE] = "csumbsize",
>  		[R_MAX_OPTS] = NULL,
>  	},
>  	.subopt_params = {
> @@ -864,6 +870,19 @@ static struct opt_params ropts = {
>  		  .maxval = LLONG_MAX,
>  		  .defaultval = SUBOPT_NEEDS_VAL,
>  		},
> +		{ .index = R_CSUM,
> +		  .conflicts = { { NULL, LAST_CONFLICT } },
> +		  .minval = 0,
> +		  .maxval = LLONG_MAX,
> +		  .defaultval = SUBOPT_NEEDS_VAL,
> +		},
> +		{ .index = R_CSUMBSIZE,
> +		  .conflicts = { { NULL, LAST_CONFLICT } },
> +		  .convert = true,
> +		  .minval = 1u << XFS_RTCSUM_BSIZE_LOG_MIN,
> +		  .maxval = 1u << XFS_RTCSUM_BSIZE_LOG_MAX,
> +		  .defaultval = SUBOPT_NEEDS_VAL,
> +		},
>  	},
>  };
>  
> @@ -1074,6 +1093,8 @@ struct sb_feat_args {
>  	bool	exchrange;		/* XFS_SB_FEAT_INCOMPAT_EXCHRANGE */
>  	bool	zoned;
>  	bool	zone_gaps;
> +	uint8_t	rtcsum_type;
> +	uint8_t	rtcsum_blklog;
>  
>  	uint16_t qflags;
>  };
> @@ -1102,6 +1123,7 @@ struct cli_params {
>  	char	*rtstart;
>  	uint64_t rtreserved;
>  	char	*max_atomic_write;
> +	char	*rtcsumbsize;
>  
>  	/* parameters where 0 is a valid CLI value */
>  	int	dsunit;
> @@ -1191,6 +1213,7 @@ struct mkfs_params {
>  	struct sb_feat_args	sb_feat;
>  	uint64_t	rtstart;
>  	uint64_t	rtreserved;
> +	uint32_t	rtcsumbsize;
>  
>  	uint64_t	max_atomic_write;
>  };
> @@ -1229,7 +1252,8 @@ usage( void )
>  			    pquota|pqnoenforce]\n\
>  /* data subvol */	[-d agcount=n,agsize=n,file,name=xxx,size=num,\n\
>  			    (sunit=value,swidth=value|su=num,sw=num|noalign),\n\
> -			    sectsize=num,concurrency=num]\n\
> +			    sectsize=num,concurrency=num,\n\
> +			    csum=type]\n\

There's no csum= parameter for -d, or at least I didn't see a D_CSUM
entry above.

>  /* force overwrite */	[-f]\n\
>  /* inode size */	[-i perblock=n|size=num,maxpct=n,attr=0|1|2,\n\
>  			    projid32bit=0|1,sparse=0|1,nrext64=0|1,\n\
> @@ -1245,7 +1269,8 @@ usage( void )
>  /* populate from directory */	[-p dirname,atime=0|1]\n\
>  /* quiet */		[-q]\n\
>  /* realtime subvol */	[-r extsize=num,size=num,rtdev=xxx,rgcount=n,rgsize=n,\n\
> -			    concurrency=num,zoned=0|1,start=n,reserved=n]\n\
> +			    concurrency=num,zoned=0|1,start=n,reserved=n,\n\
> +			    csum=type],csumbsize=n\n\
>  /* sectorsize */	[-s size=num]\n\
>  /* version */		[-V]\n\
>  			devicename\n\
> @@ -1858,6 +1883,24 @@ set_data_concurrency(
>  		cli->data_concurrency = optnum;
>  }
>  
> +static bool
> +set_data_csum(
> +	const char		*value,
> +	uint8_t			*csum_val)
> +{
> +	if (!value)
> +		return false;
> +	if (!strcmp(value, "none"))
> +		*csum_val = XFS_CSUM_TYPE_NONE;
> +	else if (!strcmp(value, "crc32c"))
> +		*csum_val = XFS_CSUM_TYPE_CRC32C;
> +	else if (!strcmp(value, "crc64"))
> +		*csum_val = XFS_CSUM_TYPE_CRC64;
> +	else
> +		return false;
> +	return true;
> +}
> +
>  static int
>  data_opts_parser(
>  	struct opt_params	*opts,
> @@ -2269,6 +2312,13 @@ rtdev_opts_parser(
>  	case R_RESERVED:
>  		cli->rtreserved = getnum(value, opts, subopt);
>  		break;
> +	case R_CSUM:
> +		if (!set_data_csum(value, &cli->sb_feat.rtcsum_type))
> +			return -EINVAL;
> +		break;
> +	case R_CSUMBSIZE:
> +		cli->rtcsumbsize = getstr(value, opts, subopt);
> +		break;
>  	default:
>  		return -EINVAL;
>  	}
> @@ -3048,6 +3098,11 @@ _("internal RT section only supported in zoned mode\n"));
>  _("reserved RT blocks only supported in zoned mode\n"));
>  			usage();
>  		}
> +		if (cli->sb_feat.rtcsum_type || cli->sb_feat.rtcsum_blklog) {
> +			fprintf(stderr,
> +_("data checksums not supported without zoned mode\n"));
> +			usage();
> +		}
>  	}
>  
>  	if (cli->xi->rt.name || cfg->rtstart) {
> @@ -4921,6 +4976,11 @@ sb_set_features(
>  	}
>  	if (fp->zone_gaps)
>  		sbp->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_ZONE_GAPS;
> +	if (fp->rtcsum_type) {
> +		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_RTCSUM;
> +		sbp->sb_rtcsum_type = fp->rtcsum_type;
> +		sbp->sb_rtcsum_blklog = fp->rtcsum_blklog;
> +	}
>  }
>  
>  /*
> @@ -5243,6 +5303,63 @@ validate_max_atomic_write_ags(
>  	}
>  }
>  
> +static void
> +validate_rtcsumbsize(
> +	struct mkfs_params	*cfg,
> +	struct cli_params	*cli,
> +	struct xfs_mount	*mp)
> +{
> +	unsigned int		l;
> +
> +	if (!cli->sb_feat.rtcsum_type) {
> +		if (cli->rtcsumbsize) {
> +			fprintf(stderr,
> + _("RT data csum block size options requires RT data csum type.\n"));
> +			exit(1);
> +		}
> +		return;
> +	}
> +
> +	if (!cfg->sb_feat.zoned) {
> +		fprintf(stderr,
> + _("RT data checksums require a zoned RT subvolume\n"));
> +		exit(1);
> +	}
> +
> +	if (cli->rtcsumbsize) {
> +		cfg->rtcsumbsize =
> +			 getnum(cli->rtcsumbsize, &ropts, R_CSUMBSIZE);
> +	} else {
> +		cfg->rtcsumbsize =
> +			 max(1u << XFS_RTCSUM_BSIZE_LOG_MIN, cfg->blocksize);
> +	}
> +
> +	if (!is_power_of_2(cfg->rtcsumbsize)) {
> +		fprintf(stderr,
> + _("RT data csum block size of %u bytes is not a power of 2\n"),
> +			cfg->rtcsumbsize);
> +		exit(1);
> +	}
> +
> +	if (cfg->rtcsumbsize < cfg->blocksize) {
> +		fprintf(stderr,
> + _("RT data csum block size of %u bytes is smaller than fsblock size %u.\n"),
> +			cfg->rtcsumbsize, cfg->blocksize);
> +		exit(1);
> +	}
> +
> +	if (cfg->rtcsumbsize % cfg->blocksize) {
> +		fprintf(stderr,
> + _("RT data csum block size of %u bytes not aligned with fsblock size %u.\n"),
> +			cfg->rtcsumbsize, cfg->blocksize);
> +		exit(1);
> +	}
> +
> +	cfg->sb_feat.rtcsum_blklog = 0;
> +	for (l = cfg->rtcsumbsize; l > 1; l >>= 1)
> +		cfg->sb_feat.rtcsum_blklog++;

log2_roundup?

--D

> +}
> +
>  static void
>  calculate_log_size(
>  	struct mkfs_params	*cfg,
> @@ -5523,6 +5640,8 @@ finish_superblock_setup(
>  	sbp->sb_unit = cfg->dsunit;
>  	sbp->sb_width = cfg->dswidth;
>  	mp->m_features |= libxfs_sb_version_to_features(sbp);
> +	mp->m_rtcsum_shift = xfs_data_csum_shift(mp->m_sb.sb_rtcsum_type);
> +	mp->m_rtcsum_bsize = 1u << mp->m_sb.sb_rtcsum_blklog;
>  	libxfs_sb_mount_rextsize(mp, sbp);
>  }
>  
> @@ -6290,6 +6409,7 @@ main(
>  	validate_datadev(&cfg, &cli);
>  	validate_logdev(&cfg, &cli);
>  	validate_rtdev(&cfg, &cli, &zt);
> +	validate_rtcsumbsize(&cfg, &cli, mp);
>  	calc_stripe_factors(&cfg, &cli, &ft);
>  
>  	/*
> -- 
> 2.53.0
> 
> 

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

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 10:03 xfsprogs support for RT data checksums Christoph Hellwig
2026-09-24 10:03 ` [PATCH 01/32] man: fix alignment of the rtstart field in ioctl_xfs_fsgeometry.2 Christoph Hellwig
2026-09-24 20:30   ` Darrick J. Wong
2026-09-26  6:15     ` Christoph Hellwig
2026-09-29 10:14       ` Andrey Albershteyn
2026-09-24 10:03 ` [PATCH 02/32] add cpu_to_le64 and le64_to_cpu_helpers Christoph Hellwig
2026-09-24 20:30   ` Darrick J. Wong
2026-09-24 10:03 ` [PATCH 03/32] libfrog: add a crc64_nvme implementation Christoph Hellwig
2026-09-24 10:03 ` [PATCH 04/32] libxfs: add DIV_ROUND_UP_ULL Christoph Hellwig
2026-09-24 20:44   ` Darrick J. Wong
2026-09-25  6:13     ` Christoph Hellwig
2026-09-24 10:03 ` [PATCH 05/32] libxfs: remove a spurious xfs_rtbitmap.h include in xfs_sb.c Christoph Hellwig
2026-09-25 23:27   ` Darrick J. Wong
2026-09-24 10:03 ` [PATCH 06/32] libxfs: add SZ_* constants Christoph Hellwig
2026-09-25 23:27   ` Darrick J. Wong
2026-09-24 10:03 ` [PATCH 07/32] xfs: remove spurious XBF_DONE clearing on readahead validation failure Christoph Hellwig
2026-09-24 10:03 ` [PATCH 08/32] xfs: hide b_flags manipulation from code outside of xfs_buf.c Christoph Hellwig
2026-09-24 10:03 ` [PATCH 09/32] FIXUP Christoph Hellwig
2026-09-25 23:29   ` Darrick J. Wong
2026-09-26  6:17     ` Christoph Hellwig
2026-09-24 10:04 ` [PATCH 10/32] xfs: add error injection for lazy bounce buffering Christoph Hellwig
2026-09-24 10:04 ` [PATCH 11/32] xfs: add xfs_daddr_to_rgno and xfs_daddr_to_rgbno helpers Christoph Hellwig
2026-09-24 10:04 ` [PATCH 12/32] FIXUP Christoph Hellwig
2026-09-24 10:04 ` [PATCH 13/32] xfs: introduce XFS_BLI_PREALLOC Christoph Hellwig
2026-09-24 10:04 ` [PATCH 14/32] xfs: centralize setting of buf_ops/buf_type/magic for rtblocks Christoph Hellwig
2026-09-24 10:04 ` [PATCH 15/32] xfs: factor out a xfs_rtfile_initialize_buf helper Christoph Hellwig
2026-09-24 10:04 ` [PATCH 16/32] xfs: add a xfs_rtblock_payload helper Christoph Hellwig
2026-09-24 10:04 ` [PATCH 17/32] xfs: prepare xfs_rtfile_initialize_blocks for larger than FSB blocks Christoph Hellwig
2026-09-24 10:04 ` [PATCH 18/32] FIXUP Christoph Hellwig
2026-09-24 10:04 ` [PATCH 19/32] xfs: define the RT data checksum on-disk format Christoph Hellwig
2026-09-24 10:04 ` [PATCH 20/32] FIXUP Christoph Hellwig
2026-09-24 10:04 ` [PATCH 21/32] xfs: add support for per-RTG csum files Christoph Hellwig
2026-09-24 10:04 ` [PATCH 22/32] FIXUP Christoph Hellwig
2026-09-24 10:04 ` [PATCH 23/32] xfs: calculate the log reservation for logging data checksum buffers Christoph Hellwig
2026-09-24 10:04 ` [PATCH 24/32] xfs: report RT data checksum information via XFS_FSOP_GEOM Christoph Hellwig
2026-09-24 10:04 ` [PATCH 25/32] xfs: enable RT data checksums Christoph Hellwig
2026-09-24 10:04 ` [PATCH 26/32] man: document the rtcsum geom fields Christoph Hellwig
2026-09-25 23:31   ` Darrick J. Wong
2026-09-26  6:17     ` Christoph Hellwig
2026-09-24 10:04 ` [PATCH 27/32] libfrog: print csum geometry information Christoph Hellwig
2026-09-25 23:32   ` Darrick J. Wong
2026-09-24 10:04 ` [PATCH 28/32] xfs_io: report checksum information from fs geometry in statfs Christoph Hellwig
2026-09-25 23:33   ` Darrick J. Wong
2026-09-26  6:18     ` Christoph Hellwig
2026-09-24 10:04 ` [PATCH 29/32] mkfs: support RT data checksums Christoph Hellwig
2026-09-25 23:39   ` Darrick J. Wong [this message]
2026-09-26  6:19     ` Christoph Hellwig
2026-09-24 10:04 ` [PATCH 30/32] xfs_db: support RT data checksum Christoph Hellwig
2026-09-25 23:43   ` Darrick J. Wong
2026-09-26  6:21     ` Christoph Hellwig
2026-09-26 18:20       ` Darrick J. Wong
2026-09-24 10:04 ` [PATCH 31/32] repair: support RT data checksums Christoph Hellwig
2026-09-25 23:54   ` Darrick J. Wong
2026-09-26  6:23     ` Christoph Hellwig
2026-09-27  0:01       ` Darrick J. Wong
2026-09-24 10:04 ` [PATCH 32/32] xfs_scrub: don't merge over unused space when data checksums are enabled Christoph Hellwig
2026-09-25 23:51   ` Darrick J. Wong

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=20260925233908.GO2705364@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=aalbersh@kernel.org \
    --cc=hch@lst.de \
    --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