Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/2] New test for ioctl(FS_IOC_GETLBMD_CAP) feature
@ 2026-03-25 14:19 Andrea Cervesato
  2026-03-25 14:19 ` [LTP] [PATCH 1/2] Add logical_block_metadata_cap struct fallback Andrea Cervesato
  2026-03-25 14:19 ` [LTP] [PATCH 2/2] Add new test ioctl_getlbmd01 Andrea Cervesato
  0 siblings, 2 replies; 7+ messages in thread
From: Andrea Cervesato @ 2026-03-25 14:19 UTC (permalink / raw)
  To: Linux Test Project

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
Andrea Cervesato (2):
      Add logical_block_metadata_cap struct fallback
      Add new test ioctl_getlbmd01

 configure.ac                                      |  2 +
 include/lapi/fs.h                                 | 21 ++++++
 runtest/syscalls                                  |  2 +
 testcases/kernel/syscalls/ioctl/.gitignore        |  1 +
 testcases/kernel/syscalls/ioctl/ioctl_getlbmd01.c | 84 +++++++++++++++++++++++
 5 files changed, 110 insertions(+)
---
base-commit: b874b6a264cf4f343c17d543ebe4ff91fbb89042
change-id: 20260325-ioctl_getlbmd01-62b5ab65d63f

Best regards,
-- 
Andrea Cervesato <andrea.cervesato@suse.com>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH 1/2] Add logical_block_metadata_cap struct fallback
  2026-03-25 14:19 [LTP] [PATCH 0/2] New test for ioctl(FS_IOC_GETLBMD_CAP) feature Andrea Cervesato
@ 2026-03-25 14:19 ` Andrea Cervesato
  2026-04-27  8:25   ` Petr Vorel
                     ` (2 more replies)
  2026-03-25 14:19 ` [LTP] [PATCH 2/2] Add new test ioctl_getlbmd01 Andrea Cervesato
  1 sibling, 3 replies; 7+ messages in thread
From: Andrea Cervesato @ 2026-03-25 14:19 UTC (permalink / raw)
  To: Linux Test Project

From: Andrea Cervesato <andrea.cervesato@suse.com>

Add UAPI fallback definitions for struct logical_block_metadata_cap,
FS_IOC_GETLBMD_CAP ioctl and related LBMD_* constants in lapi/fs.h
for systems whose kernel headers predate v6.17.

Also add the corresponding AC_CHECK_TYPES entry in configure.ac.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 configure.ac      |  2 ++
 include/lapi/fs.h | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/configure.ac b/configure.ac
index 9d6ec7f13ad421aa35840ebc65745c962b11e1db..685771096f5329177237f2c2a6e5dda00853c469 100644
--- a/configure.ac
+++ b/configure.ac
@@ -274,6 +274,8 @@ AC_CHECK_TYPES([struct file_attr],,,[#include <linux/fs.h>])
 
 AC_CHECK_TYPES([struct fsxattr],,,[#include <linux/fs.h>])
 
+AC_CHECK_TYPES([struct logical_block_metadata_cap],,,[#include <linux/fs.h>])
+
 AC_CHECK_TYPES([struct sockaddr_vm],,,[
 #include <sys/socket.h>
 #include <linux/vm_sockets.h>
diff --git a/include/lapi/fs.h b/include/lapi/fs.h
index 6b5056bd25c5504637f01f10be8b091f79d5632d..471ad0a25b805b9d4254b13611445a1cc294e0f1 100644
--- a/include/lapi/fs.h
+++ b/include/lapi/fs.h
@@ -136,4 +136,25 @@ static inline int file_setattr(int dfd, const char *filename,
 }
 #endif
 
+#ifndef HAVE_STRUCT_LOGICAL_BLOCK_METADATA_CAP
+struct logical_block_metadata_cap {
+	uint32_t	lbmd_flags;
+	uint16_t	lbmd_interval;
+	uint8_t		lbmd_size;
+	uint8_t		lbmd_opaque_size;
+	uint8_t		lbmd_opaque_offset;
+	uint8_t		lbmd_pi_size;
+	uint8_t		lbmd_pi_offset;
+	uint8_t		lbmd_guard_tag_type;
+	uint8_t		lbmd_app_tag_size;
+	uint8_t		lbmd_ref_tag_size;
+	uint8_t		lbmd_storage_tag_size;
+	uint8_t		pad;
+};
+#endif
+
+#ifndef FS_IOC_GETLBMD_CAP
+# define FS_IOC_GETLBMD_CAP	_IOWR(0x15, 2, struct logical_block_metadata_cap)
+#endif
+
 #endif /* LAPI_FS_H__ */

-- 
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* [LTP] [PATCH 2/2] Add new test ioctl_getlbmd01
  2026-03-25 14:19 [LTP] [PATCH 0/2] New test for ioctl(FS_IOC_GETLBMD_CAP) feature Andrea Cervesato
  2026-03-25 14:19 ` [LTP] [PATCH 1/2] Add logical_block_metadata_cap struct fallback Andrea Cervesato
@ 2026-03-25 14:19 ` Andrea Cervesato
  2026-04-27  8:22   ` Petr Vorel
  1 sibling, 1 reply; 7+ messages in thread
From: Andrea Cervesato @ 2026-03-25 14:19 UTC (permalink / raw)
  To: Linux Test Project

From: Andrea Cervesato <andrea.cervesato@suse.com>

Verify :manpage:`ioctl(2)` with FS_IOC_GETLBMD_CAP on block devices.

- fill struct logical_block_metadata_cap with non-zero pattern, call
  FS_IOC_GETLBMD_CAP on a block device without integrity support
  and verify the kernel zeroed out all fields
- call FS_IOC_GETLBMD_CAP on a regular file and verify it fails
  with ENOTTY

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 runtest/syscalls                                  |  2 +
 testcases/kernel/syscalls/ioctl/.gitignore        |  1 +
 testcases/kernel/syscalls/ioctl/ioctl_getlbmd01.c | 84 +++++++++++++++++++++++
 3 files changed, 87 insertions(+)

diff --git a/runtest/syscalls b/runtest/syscalls
index 6ba0227a87f30e68e473c9019a6e6acc224738d9..e94a9cb58a1563dc15f26a16db480c8cac468375 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -624,6 +624,8 @@ ioctl_ficlonerange01 ioctl_ficlonerange01
 ioctl_ficlonerange02 ioctl_ficlonerange02
 ioctl_fiemap01 ioctl_fiemap01
 
+ioctl_getlbmd01 ioctl_getlbmd01
+
 ioctl_pidfd01 ioctl_pidfd01
 ioctl_pidfd02 ioctl_pidfd02
 ioctl_pidfd03 ioctl_pidfd03
diff --git a/testcases/kernel/syscalls/ioctl/.gitignore b/testcases/kernel/syscalls/ioctl/.gitignore
index dac4583fa7c05a4cdd937e86bd8f935dd15aebc8..63765dea61a795aac01e5b6b14996e441b56d3e3 100644
--- a/testcases/kernel/syscalls/ioctl/.gitignore
+++ b/testcases/kernel/syscalls/ioctl/.gitignore
@@ -30,6 +30,7 @@
 /ioctl_ficlonerange01
 /ioctl_ficlonerange02
 /ioctl_fiemap01
+/ioctl_getlbmd01
 /ioctl_pidfd01
 /ioctl_pidfd02
 /ioctl_pidfd03
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_getlbmd01.c b/testcases/kernel/syscalls/ioctl/ioctl_getlbmd01.c
new file mode 100644
index 0000000000000000000000000000000000000000..56622977fa949e47ffaaf7403e1f266768366878
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_getlbmd01.c
@@ -0,0 +1,84 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2026 Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * Verify :manpage:`ioctl(2)` with FS_IOC_GETLBMD_CAP on block devices.
+ *
+ * - fill struct logical_block_metadata_cap with non-zero pattern, call
+ *   FS_IOC_GETLBMD_CAP on a block device without integrity support
+ *   and verify the kernel zeroed out all fields
+ * - call FS_IOC_GETLBMD_CAP on a regular file and verify it fails
+ *   with ENOTTY
+ */
+
+#include <sys/ioctl.h>
+#include "tst_test.h"
+#include "lapi/fs.h"
+
+static int dev_fd = -1;
+static int file_fd = -1;
+
+static struct logical_block_metadata_cap *meta_cap;
+
+static void run(void)
+{
+	memset(meta_cap, 0xff, sizeof(*meta_cap));
+
+	TST_EXP_PASS(ioctl(dev_fd, FS_IOC_GETLBMD_CAP, meta_cap),
+		"FS_IOC_GETLBMD_CAP on block device");
+
+	if (!TST_PASS)
+		return;
+
+	TST_EXP_EQ_LU(meta_cap->lbmd_flags, 0);
+	TST_EXP_EQ_LU(meta_cap->lbmd_interval, 0);
+	TST_EXP_EQ_LU(meta_cap->lbmd_size, 0);
+	TST_EXP_EQ_LU(meta_cap->lbmd_opaque_size, 0);
+	TST_EXP_EQ_LU(meta_cap->lbmd_opaque_offset, 0);
+	TST_EXP_EQ_LU(meta_cap->lbmd_pi_size, 0);
+	TST_EXP_EQ_LU(meta_cap->lbmd_pi_offset, 0);
+	TST_EXP_EQ_LU(meta_cap->lbmd_guard_tag_type, 0);
+	TST_EXP_EQ_LU(meta_cap->lbmd_app_tag_size, 0);
+	TST_EXP_EQ_LU(meta_cap->lbmd_ref_tag_size, 0);
+	TST_EXP_EQ_LU(meta_cap->lbmd_storage_tag_size, 0);
+
+	TST_EXP_FAIL(ioctl(file_fd, FS_IOC_GETLBMD_CAP, meta_cap), ENOTTY,
+		"FS_IOC_GETLBMD_CAP on regular file");
+}
+
+static void setup(void)
+{
+	dev_fd = SAFE_OPEN(tst_device->dev, O_RDONLY);
+
+	SAFE_TOUCH("testfile", 0644, NULL);
+	file_fd = SAFE_OPEN("testfile", O_RDONLY);
+}
+
+static void cleanup(void)
+{
+	if (file_fd != -1)
+		SAFE_CLOSE(file_fd);
+
+	if (dev_fd != -1)
+		SAFE_CLOSE(dev_fd);
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_device = 1,
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.min_kver = "6.17",
+	.needs_kconfigs = (const char *[]) {
+		"CONFIG_BLK_DEV_INTEGRITY=y",
+		NULL,
+	},
+	.bufs = (struct tst_buffers[]) {
+		{&meta_cap, .size = sizeof(*meta_cap)},
+		{},
+	},
+};

-- 
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 2/2] Add new test ioctl_getlbmd01
  2026-03-25 14:19 ` [LTP] [PATCH 2/2] Add new test ioctl_getlbmd01 Andrea Cervesato
@ 2026-04-27  8:22   ` Petr Vorel
  0 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2026-04-27  8:22 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: Linux Test Project

Hi Andrea,

LGTM, thanks!
Reviewed-by: Petr Vorel <pvorel@suse.cz>

> +static struct tst_test test = {
> +	.test_all = run,
> +	.setup = setup,
> +	.cleanup = cleanup,
> +	.needs_device = 1,
> +	.needs_root = 1,
> +	.needs_tmpdir = 1,
nit: This is not needed due needs_device (see needs_tmpdir()).
(can be fixed before merge.

Kind regards,
Petr Vorel

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 1/2] Add logical_block_metadata_cap struct fallback
  2026-03-25 14:19 ` [LTP] [PATCH 1/2] Add logical_block_metadata_cap struct fallback Andrea Cervesato
@ 2026-04-27  8:25   ` Petr Vorel
  2026-05-06 12:58   ` [LTP] " linuxtestproject.agent
  2026-05-06 13:10   ` [LTP] [PATCH 1/2] " Andrea Cervesato via ltp
  2 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2026-04-27  8:25 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: Linux Test Project

Hi Andrea,

obviously correct, thanks!

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] Add logical_block_metadata_cap struct fallback
  2026-03-25 14:19 ` [LTP] [PATCH 1/2] Add logical_block_metadata_cap struct fallback Andrea Cervesato
  2026-04-27  8:25   ` Petr Vorel
@ 2026-05-06 12:58   ` linuxtestproject.agent
  2026-05-06 13:10   ` [LTP] [PATCH 1/2] " Andrea Cervesato via ltp
  2 siblings, 0 replies; 7+ messages in thread
From: linuxtestproject.agent @ 2026-05-06 12:58 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hi Andrea,

--- [PATCH 1/2] ---

On Wed, 25 Mar 2026 15:19:10 +0100, Andrea Cervesato wrote:
> Add logical_block_metadata_cap struct fallback
>
> Add UAPI fallback definitions for struct logical_block_metadata_cap,
> FS_IOC_GETLBMD_CAP ioctl and related LBMD_* constants in lapi/fs.h

The commit message claims LBMD_* constants are added, but none appear in
the diff. The kernel's uapi/linux/fs.h defines LBMD_PI_CAP_INTEGRITY,
LBMD_PI_CAP_REFTAG, LBMD_PI_CSUM_{NONE,IP,CRC16_T10DIF,CRC64_NVME}, and
LBMD_SIZE_VER0 — either add them to lapi/fs.h or drop the claim from the
commit message.

---
Note:

Our agent completed the review of the patch. The full review can be
found at: <not available>

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH 1/2] Add logical_block_metadata_cap struct fallback
  2026-03-25 14:19 ` [LTP] [PATCH 1/2] Add logical_block_metadata_cap struct fallback Andrea Cervesato
  2026-04-27  8:25   ` Petr Vorel
  2026-05-06 12:58   ` [LTP] " linuxtestproject.agent
@ 2026-05-06 13:10   ` Andrea Cervesato via ltp
  2 siblings, 0 replies; 7+ messages in thread
From: Andrea Cervesato via ltp @ 2026-05-06 13:10 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: Linux Test Project

Merged, Thanks!

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2026-05-06 13:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-25 14:19 [LTP] [PATCH 0/2] New test for ioctl(FS_IOC_GETLBMD_CAP) feature Andrea Cervesato
2026-03-25 14:19 ` [LTP] [PATCH 1/2] Add logical_block_metadata_cap struct fallback Andrea Cervesato
2026-04-27  8:25   ` Petr Vorel
2026-05-06 12:58   ` [LTP] " linuxtestproject.agent
2026-05-06 13:10   ` [LTP] [PATCH 1/2] " Andrea Cervesato via ltp
2026-03-25 14:19 ` [LTP] [PATCH 2/2] Add new test ioctl_getlbmd01 Andrea Cervesato
2026-04-27  8:22   ` Petr Vorel

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