Skip to contentSkip to conversation

New test for ioctl(FS_IOC_GETLBMD_CAP) feature

PATCH Applied Andrea Cervesato 4 participants 7 messages Mar 25 – May 6

lore
Share & tools
lore
#0 lore raw

cover New test for ioctl(FS_IOC_GETLBMD_CAP) feature

---
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,

Signature · 5 lines
Andrea Cervesato <[email protected]>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH 1/2 Add logical_block_metadata_cap struct fallback

From: Andrea Cervesato <[email protected]>

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.

---
 configure.ac      |  2 ++
 include/lapi/fs.h | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)
configure.ac +2 -0
index 9d6ec7f13ad421aa35840ebc65745c962b11e1db..685771096f5329177237f2c2a6e5dda00853c469 100644
@@ -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>
include/lapi/fs.h +21 -0
index 6b5056bd25c5504637f01f10be8b091f79d5632d..471ad0a25b805b9d4254b13611445a1cc294e0f1 100644
@@ -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__ */
Signature · 5 lines
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Re: [LTP] [PATCH 1/2] Add logical_block_metadata_cap struct fallback

Hi Andrea,

obviously correct, thanks!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

Re: [LTP] Add logical_block_metadata_cap struct fallback

In reply to Andrea Cervesato

Hi Andrea,

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

Quoted 4 lines · Andrea Cervesato

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

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

PATCH 2/2 Add new test ioctl_getlbmd01

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

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

---
 runtest/syscalls                                  |  2 +
 testcases/kernel/syscalls/ioctl/.gitignore        |  1 +
 testcases/kernel/syscalls/ioctl/ioctl_getlbmd01.c | 84 +++++++++++++++++++++++
 3 files changed, 87 insertions(+)
runtest/syscalls +2 -0
index 6ba0227a87f30e68e473c9019a6e6acc224738d9..e94a9cb58a1563dc15f26a16db480c8cac468375 100644
@@ -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
testcases/kernel/syscalls/ioctl/.gitignore +1 -0
index dac4583fa7c05a4cdd937e86bd8f935dd15aebc8..63765dea61a795aac01e5b6b14996e441b56d3e3 100644
@@ -30,6 +30,7 @@
 /ioctl_ficlonerange01
 /ioctl_ficlonerange02
 /ioctl_fiemap01
+/ioctl_getlbmd01
 /ioctl_pidfd01
 /ioctl_pidfd02
 /ioctl_pidfd03
testcases/kernel/syscalls/ioctl/ioctl_getlbmd01.c new file +84 -0

84 lines not on this page · raw message

Signature · 5 lines
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 2/2
#6 lore raw

Re: [LTP] [PATCH 2/2] Add new test ioctl_getlbmd01

Hi Andrea,

LGTM, thanks!

testcases/kernel/syscalls/ioctl/ioctl_getlbmd01.c line 74

Quoted 7 lines
testcases/kernel/syscalls/ioctl/ioctl_getlbmd01.c new file +7 -0
+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

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp