All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>, Zorro Lang <zlang@kernel.org>,
	fstests@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 05/13] xfs: add a _require_xfs_data_csum helper
Date: Mon, 5 Oct 2026 16:55:35 +0200	[thread overview]
Message-ID: <20261005145535.GA2082@lst.de> (raw)
In-Reply-To: <20261005144856.GA2705364@frogsfrogsfrogs>

On Mon, Oct 05, 2026 at 07:48:56AM -0700, Darrick J. Wong wrote:
> Oh wow, a new ioctl.  Having not tried to do anything with it, it looks
> promising.  Would it be useful for a filesystem with software checksums
> to advertise something like this:
> 
> struct logical_block_metadata_cap foo = {
> 	.lbmd_flags = LBMD_FS_CSUM_CRC32C, /* doesn't yet exist */
> 	.lbmd_interval = i_blocksize(...),
> 	.lbmd_size = 4,
> };

Yes, see the patch below for that below, It might or might not apply to
the current series, but it should give you the idea.

> Even though userspace cannot (yet) access the per-fsblock crc32c data?

Well, I want that to be possible eventually.  I even have working code,
but it has too many layering violations to publish it at the moment.

> Also, if the fs supports per-fsblock checksums and the storage supports
> per-LBA PI, which gets advertised?

Wherever the file systems wants to store it because it intercepts both
the ioctl and the io_uring with metadata ops. So probably is it's own
location.  I should probably add a test for xfs crcs on top of PI to
make sure nothing breaks this..

---
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 96ca3e480cb9..6aa3e7f78eb5 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -46,6 +46,7 @@
 #include "xfs_verify_media.h"
 #include "xfs_zone_priv.h"
 #include "xfs_zone_alloc.h"
+#include "xfs_rtcsum.h"
 
 #include <linux/mount.h>
 #include <linux/fileattr.h>
@@ -1200,6 +1201,36 @@ xfs_ioctl_fs_counts(
 	return 0;
 }
 
+static int
+xfs_ioc_getlbmd_cap(
+	struct xfs_inode		*ip,
+	unsigned int			cmd,
+	struct logical_block_metadata_cap __user *argp)
+{
+	struct xfs_mount		*mp = ip->i_mount;
+	size_t				usize = _IOC_SIZE(cmd);
+	struct logical_block_metadata_cap lbm = {};
+
+	if (xfs_is_rtcsum_inode(ip)) {
+		lbm.lbmd_flags |= LBMD_PI_CAP_INTEGRITY;
+		lbm.lbmd_interval = mp->m_sb.sb_blocksize;
+		lbm.lbmd_pi_size = 1U << mp->m_rtcsum_shift;
+		lbm.lbmd_size = lbm.lbmd_pi_size;
+		switch (mp->m_sb.sb_rtcsum) {
+		case XFS_CSUM_TYPE_CRC32C:
+			lbm.lbmd_guard_tag_type = LBMD_PI_CSUM_CRC32C;
+			break;
+		case XFS_CSUM_TYPE_CRC64:
+			lbm.lbmd_guard_tag_type = LBMD_PI_CSUM_CRC64_NVME;
+			break;
+		default:
+			WARN_ON_ONCE(1);
+		}
+	}
+
+	return copy_struct_to_user(argp, usize, &lbm, sizeof(lbm), NULL);
+}
+
 /*
  * These long-unused ioctls were removed from the official ioctl API in 5.17,
  * but retain these definitions so that we can log warnings about them.
@@ -1467,6 +1498,9 @@ xfs_file_ioctl(
 		return xfs_ioc_verify_media(filp, arg);
 
 	default:
+		if (extensible_ioctl_valid(cmd, FS_IOC_GETLBMD_CAP,
+				LBMD_SIZE_VER0))
+			return xfs_ioc_getlbmd_cap(ip, cmd, arg);
 		return -ENOTTY;
 	}
 }

  reply	other threads:[~2026-10-05 14:55 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 10:07 xfstests support for RT data checksums Christoph Hellwig
2026-09-24 10:07 ` [PATCH 01/13] add a "datacsum" group Christoph Hellwig
2026-09-29  1:31   ` Darrick J. Wong
2026-10-05 13:17     ` Christoph Hellwig
2026-09-24 10:07 ` [PATCH 02/13] common: add a SCRATCH_MKFS_OPTIONS variable Christoph Hellwig
2026-09-29  1:32   ` Darrick J. Wong
2026-10-05 13:18     ` Christoph Hellwig
2026-09-24 10:07 ` [PATCH 03/13] xfs: add a XFS_VERIFY_FILE_DATA variable Christoph Hellwig
2026-09-29  1:34   ` Darrick J. Wong
2026-09-24 10:07 ` [PATCH 04/13] xfs/206: filter out csum information from mkfs output Christoph Hellwig
2026-09-29  1:34   ` Darrick J. Wong
2026-09-24 10:07 ` [PATCH 05/13] xfs: add a _require_xfs_data_csum helper Christoph Hellwig
2026-09-29  1:38   ` Darrick J. Wong
2026-10-05 13:20     ` Christoph Hellwig
2026-10-05 14:48       ` Darrick J. Wong
2026-10-05 14:55         ` Christoph Hellwig [this message]
2026-09-24 10:07 ` [PATCH 06/13] xfs/2301: test lazy bounce buffering mode Christoph Hellwig
2026-09-29  1:42   ` Darrick J. Wong
2026-10-05 13:21     ` Christoph Hellwig
2026-09-24 10:07 ` [PATCH 07/13] xfs/2302: add a basic data checksum test Christoph Hellwig
2026-09-29  1:48   ` Darrick J. Wong
2026-10-05 13:22     ` Christoph Hellwig
2026-09-24 10:07 ` [PATCH 08/13] xfs/2303: test that data checksums detect data misplacement Christoph Hellwig
2026-09-29  1:54   ` Darrick J. Wong
2026-10-05 13:23     ` Christoph Hellwig
2026-09-24 10:07 ` [PATCH 09/13] xfs/2304: version of generic/388 that run xfs_scrub -x for each iteration Christoph Hellwig
2026-09-29  1:56   ` Darrick J. Wong
2026-10-05 13:25     ` Christoph Hellwig
2026-10-05 14:51       ` Darrick J. Wong
2026-10-05 14:56         ` Christoph Hellwig
2026-10-05 15:20           ` Darrick J. Wong
2026-10-07 13:42             ` Christoph Hellwig
2026-10-07 15:19               ` Darrick J. Wong
2026-09-24 10:07 ` [PATCH 10/13] xfs/2305: version of generic/475 " Christoph Hellwig
2026-09-29  1:57   ` Darrick J. Wong
2026-10-05 13:25     ` Christoph Hellwig
2026-09-24 10:07 ` [PATCH 11/13] xfs/2306: test mkfs input validation for RT data csum options Christoph Hellwig
2026-09-29  1:59   ` Darrick J. Wong
2026-10-05 13:26     ` Christoph Hellwig
2026-09-24 10:07 ` [PATCH 12/13] xfs/2307: test checksum handling using corrupted checksums Christoph Hellwig
2026-09-29  2:05   ` Darrick J. Wong
2026-10-05 13:27     ` Christoph Hellwig
2026-09-24 10:07 ` [PATCH 13/13] xfs/2308: test rebuilding of csum files in xfs_repair Christoph Hellwig
2026-09-29  2:03   ` Darrick J. Wong
2026-10-05 13:27     ` 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=20261005145535.GA2082@lst.de \
    --to=hch@lst.de \
    --cc=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=zlang@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.