Linux XFS filesystem development
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Andrey Albershteyn <aalbersh@kernel.org>
Cc: "Darrick J . Wong" <djwong@kernel.org>, linux-xfs@vger.kernel.org
Subject: [PATCH 30/32] xfs_db: support RT data checksum
Date: Thu, 24 Sep 2026 12:04:20 +0200	[thread overview]
Message-ID: <20260924100512.2733748-31-hch@lst.de> (raw)
In-Reply-To: <20260924100512.2733748-1-hch@lst.de>

Support printing the new super block fields, and content of the per-RTG
rtcsum files.

Note that the superblock fields are printed for all metadir file systems
because they reuse space that previously was padding.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 db/block.c        | 10 +++++++++-
 db/field.c        |  2 ++
 db/field.h        |  1 +
 db/inode.c        |  2 ++
 db/rtgroup.c      | 42 ++++++++++++++++++++++++++++++++++++++++++
 db/rtgroup.h      |  5 +++++
 db/sb.c           | 10 ++++++++--
 db/type.c         |  5 +++++
 db/type.h         |  1 +
 man/man8/xfs_db.8 | 13 ++++++++++++-
 10 files changed, 87 insertions(+), 4 deletions(-)

diff --git a/db/block.c b/db/block.c
index 2f1978c41f30..c6dd50dfa764 100644
--- a/db/block.c
+++ b/db/block.c
@@ -263,7 +263,15 @@ dblock_f(
 		dbprintf(_("no type for file data\n"));
 		return 0;
 	}
-	nex = nb = type == TYP_DIR2 ? mp->m_dir_geo->fsbcount : 1;
+
+	if (type == TYP_DIR2)
+		nb = mp->m_dir_geo->fsbcount;
+	else if (type == TYP_RTCSUM)
+		nb = XFS_B_TO_FSB(mp, 1u << mp->m_sb.sb_rtcsum_blklog);
+	else
+		nb = 1;
+
+	nex = nb;
 	bmp = malloc(nb * sizeof(*bmp));
 	bmap(bno, nb, XFS_DATA_FORK, &nex, bmp);
 	if (nex == 0) {
diff --git a/db/field.c b/db/field.c
index 62c983fc3d49..275f175493df 100644
--- a/db/field.c
+++ b/db/field.c
@@ -441,6 +441,8 @@ const ftattr_t	ftattrtab[] = {
 	  0, NULL, NULL },
 	{ FLDT_RGSUMMARY, "rgsummary", NULL, (char *)rgsummary_flds,
 	  btblock_size, FTARG_SIZE, NULL, rgsummary_flds },
+	{ FLDT_RTCSUM, "rtcsum", NULL, (char *)rtcsum_flds,
+	  rtcsumblock_size, FTARG_SIZE, NULL, rtcsum_flds },
 
 	{ FLDT_ZZZ, NULL }
 };
diff --git a/db/field.h b/db/field.h
index 27df5a0fcd1b..77f84d55cb62 100644
--- a/db/field.h
+++ b/db/field.h
@@ -211,6 +211,7 @@ typedef enum fldt	{
 	FLDT_RGBITMAP,
 	FLDT_SUMINFO,
 	FLDT_RGSUMMARY,
+	FLDT_RTCSUM,
 
 	FLDT_ZZZ			/* mark last entry */
 } fldt_t;
diff --git a/db/inode.c b/db/inode.c
index 46f83f18f083..a77595427c56 100644
--- a/db/inode.c
+++ b/db/inode.c
@@ -727,6 +727,8 @@ inode_next_type(void)
 				return TYP_RTRMAPBT;
 			case XFS_METAFILE_RTREFCOUNT:
 				return TYP_RTREFCBT;
+			case XFS_METAFILE_RTCSUM:
+				return TYP_RTCSUM;
 			default:
 				return TYP_DATA;
 			}
diff --git a/db/rtgroup.c b/db/rtgroup.c
index c6b96c9dc79d..666adb2feb33 100644
--- a/db/rtgroup.c
+++ b/db/rtgroup.c
@@ -16,6 +16,8 @@
 #include "output.h"
 #include "init.h"
 #include "rtgroup.h"
+#include "libfrog/crc64.h"
+#include "xfs_rtcsumfile.h"
 
 #define uuid_equal(s,d)		(platform_uuid_compare((s),(d)) == 0)
 
@@ -152,3 +154,43 @@ const field_t	rgsummary_hfld[] = {
 	{ "", FLDT_RGSUMMARY, OI(0), C1, 0, TYP_NONE },
 	{ NULL }
 };
+
+/*
+ * Get the size of a rtcsum block.
+ */
+int
+rtcsumblock_size(
+	void	*obj,
+	int	startoff,
+	int	idx)
+{
+	return bitize(1u << mp->m_sb.sb_rtcsum_blklog);
+}
+
+static int
+rtcsum_count(
+	void			*obj,
+	int			startoff)
+{
+	return xfs_rtcsum_payload_size(mp) >> mp->m_rtcsum_shift;
+}
+
+#define	OFF(f)	bitize(offsetof(struct xfs_rtbuf_blkinfo, rt_ ## f))
+const field_t rtcsum_flds[] = {
+	{ "magicnum", FLDT_UINT32X, OI(OFF(magic)), C1, 0, TYP_NONE },
+	{ "crc", FLDT_CRC, OI(OFF(crc)), C1, 0, TYP_NONE },
+	{ "owner", FLDT_INO, OI(OFF(owner)), C1, 0, TYP_NONE },
+	{ "bno", FLDT_DFSBNO, OI(OFF(blkno)), C1, 0, TYP_BMAPBTD },
+	{ "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE },
+	{ "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE },
+	/* the checksums are after the blkinfo structure */
+	{ "csums", FLDT_SUMINFO, OI(bitize(sizeof(struct xfs_rtbuf_blkinfo))),
+	  rtcsum_count, FLD_ARRAY | FLD_COUNT, TYP_DATA },
+	{ NULL }
+};
+#undef OFF
+
+const field_t rtcsum_hfld[] = {
+	{ "", FLDT_RTCSUM, OI(0), C1, 0, TYP_NONE },
+	{ NULL }
+};
diff --git a/db/rtgroup.h b/db/rtgroup.h
index 5b120f2c9a29..b674154fcbad 100644
--- a/db/rtgroup.h
+++ b/db/rtgroup.h
@@ -15,6 +15,11 @@ extern const struct field	rgbitmap_hfld[];
 extern const struct field	rgsummary_flds[];
 extern const struct field	rgsummary_hfld[];
 
+extern const struct field	rtcsum_flds[];
+extern const struct field	rtcsum_hfld[];
+
+int rtcsumblock_size(void *obj, int startoff, int idx);
+
 extern void	rtsb_init(void);
 extern int	rtsb_size(void *obj, int startoff, int idx);
 
diff --git a/db/sb.c b/db/sb.c
index 666207145a86..c565e6535f63 100644
--- a/db/sb.c
+++ b/db/sb.c
@@ -144,8 +144,14 @@ const field_t	sb_flds[] = {
 		FLD_COUNT, TYP_NONE },
 	{ "pad", FLDT_UINT8X, OI(OFF(pad)), metadirfld_count,
 		FLD_COUNT, TYP_NONE },
-	{ "rtstart", FLDT_DRFSBNO, OI(OFF(rtstart)), zonedfld_count, FLD_COUNT, TYP_NONE },
-	{ "rtreserved", FLDT_UINT64D, OI(OFF(rtreserved)), zonedfld_count, FLD_COUNT, TYP_NONE },
+	{ "rtcsum_type", FLDT_UINT8D, OI(OFF(rtcsum_type)), metadirfld_count,
+		FLD_COUNT, TYP_NONE },
+	{ "rtcsum_blklog", FLDT_UINT8D, OI(OFF(rtcsum_blklog)), metadirfld_count,
+		FLD_COUNT, TYP_NONE },
+	{ "rtstart", FLDT_DRFSBNO, OI(OFF(rtstart)), zonedfld_count,
+		FLD_COUNT, TYP_NONE },
+	{ "rtreserved", FLDT_UINT64D, OI(OFF(rtreserved)), zonedfld_count,
+		FLD_COUNT, TYP_NONE },
 	{ NULL }
 };
 
diff --git a/db/type.c b/db/type.c
index 324f416a49cc..2db5b5f6a54d 100644
--- a/db/type.c
+++ b/db/type.c
@@ -71,6 +71,7 @@ static const typ_t	__typtab[] = {
 		TYP_F_NO_CRC_OFF },
 	{ TYP_RGBITMAP, NULL },
 	{ TYP_RGSUMMARY, NULL },
+	{ TYP_RTCSUM, NULL },
 	{ TYP_NONE, NULL }
 };
 
@@ -125,6 +126,8 @@ static const typ_t	__typtab_crc[] = {
 		&xfs_rtbitmap_buf_ops, XFS_RTBUF_CRC_OFF },
 	{ TYP_RGSUMMARY, "rgsummary", handle_struct, rgsummary_hfld,
 		&xfs_rtsummary_buf_ops, XFS_RTBUF_CRC_OFF },
+	{ TYP_RTCSUM, "rtcsum", handle_struct, rtcsum_hfld,
+		&xfs_rtcsum_buf_ops, XFS_RTBUF_CRC_OFF },
 	{ TYP_NONE, NULL }
 };
 
@@ -179,6 +182,8 @@ static const typ_t	__typtab_spcrc[] = {
 		&xfs_rtbitmap_buf_ops, XFS_RTBUF_CRC_OFF },
 	{ TYP_RGSUMMARY, "rgsummary", handle_struct, rgsummary_hfld,
 		&xfs_rtsummary_buf_ops, XFS_RTBUF_CRC_OFF },
+	{ TYP_RTCSUM, "rtcsum", handle_struct, rtcsum_hfld,
+		&xfs_rtcsum_buf_ops, XFS_RTBUF_CRC_OFF },
 	{ TYP_NONE, NULL }
 };
 
diff --git a/db/type.h b/db/type.h
index a2488a663dbd..d95c83c78d17 100644
--- a/db/type.h
+++ b/db/type.h
@@ -39,6 +39,7 @@ typedef enum typnm
 	TYP_FINOBT,
 	TYP_RGBITMAP,
 	TYP_RGSUMMARY,
+	TYP_RTCSUM,
 	TYP_NONE
 } typnm_t;
 
diff --git a/man/man8/xfs_db.8 b/man/man8/xfs_db.8
index c2d4065944be..ab89d709b89e 100644
--- a/man/man8/xfs_db.8
+++ b/man/man8/xfs_db.8
@@ -1356,7 +1356,8 @@ The possible data types are:
 .BR agf ", " agfl ", " agi ", " attr ", " bmapbta ", " bmapbtd ,
 .BR bnobt ", " cntbt ", " data ", " dir ", " dir2 ", " dqblk ,
 .BR inobt ", " inode ", " log ", " refcntbt ", " rmapbt ", " rtbitmap ,
-.BR rtsummary ", " sb ", " symlink ", " rtrmapbt ", " rtrefcbt ", and " text .
+.BR rtsummary ", " sb ", " symlink ", " rtrmapbt ", " rtrefcbt ,
+.BR rtcsum ", and " text .
 See the TYPES section below for more information on these data types.
 .TP
 .BI "timelimit [" OPTIONS ]
@@ -2644,6 +2645,16 @@ The first dimension is the size range,
 the second dimension is the starting bitmap block number
 (adjacent entries are for the same size, adjacent bitmap blocks).
 .TP
+.B rtcsum
+For RT data-checksum enabled file systems, there is one data checksum file
+for each realtime group.  The data checksum file contains the standard
+RT block self-describing metadata header, and an array of the checksums
+for the realtime group.  The size of each entry depends on the checksum
+used: 4 bytes for
+.BR crc32c
+and 8 bytes for
+.BR crc64 .
+.TP
 .B sb
 There is one sb (superblock) structure per allocation group.
 It is the first disk block in the allocation group.
-- 
2.53.0


  parent reply	other threads:[~2026-09-24 10:07 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
2026-09-26  6:19     ` Christoph Hellwig
2026-09-24 10:04 ` Christoph Hellwig [this message]
2026-09-25 23:43   ` [PATCH 30/32] xfs_db: support RT data checksum 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=20260924100512.2733748-31-hch@lst.de \
    --to=hch@lst.de \
    --cc=aalbersh@kernel.org \
    --cc=djwong@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