Skip to contentSkip to conversation

liburing/io_passthrough: use metadata if format requires it

PATCH Applied Keith Busch 3 participants 5 messages Apr 16, 2025 – Apr 18, 2025 io_uring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 liburing/io_passthrough: use metadata if format requires it

From: Keith Busch <[email protected]>

---
 test/io_uring_passthrough.c | 16 ++++++++++++++++
 test/nvme.h                 |  2 ++
 2 files changed, 18 insertions(+)
test/io_uring_passthrough.c +16 -0
index bea4f39..66c97da 100644
@@ -17,6 +17,7 @@
 #define BS		8192
 #define BUFFERS		(FILE_SIZE / BS)
 
+static void *meta_mem;
 static struct iovec *vecs;
 static int no_pt;
 
@@ -193,6 +194,12 @@ static int __test_io(const char *file, struct io_uring *ring, int tc, int read,
 			cmd->addr = (__u64)(uintptr_t)&vecs[i];
 			cmd->data_len = 1;
 		}
+
+		if (meta_size) {
+			cmd->metadata = (__u64)(uintptr_t)(meta_mem +
+						meta_size * i * (nlb + 1));
+			cmd->metadata_len = meta_size * (nlb + 1);
+		}
 		cmd->nsid = nsid;
 
 		offset += BS;
@@ -404,6 +411,12 @@ static int test_io_uring_submit_enters(const char *file)
 		cmd->addr = (__u64)(uintptr_t)&vecs[i];
 		cmd->data_len = 1;
 		cmd->nsid = nsid;
+
+		if (meta_size) {
+			cmd->metadata = (__u64)(uintptr_t)(meta_mem +
+						meta_size * i * (nlb + 1));
+			cmd->metadata_len = meta_size * (nlb + 1);
+		}
 	}
 
 	/* submit manually to avoid adding IORING_ENTER_GETEVENTS */
@@ -451,6 +464,9 @@ int main(int argc, char *argv[])
 		return T_EXIT_SKIP;
 
 	vecs = t_create_buffers(BUFFERS, BS);
+	if (meta_size)
+		t_posix_memalign(&meta_mem, 0x1000,
+				 meta_size * BUFFERS * (BS >> lba_shift));
 
 	for (i = 0; i < 32; i++) {
 		int read = (i & 1) != 0;
test/nvme.h +2 -0
index 1254b92..9c3cfa1 100644
@@ -59,6 +59,7 @@ enum nvme_io_opcode {
 
 static int nsid;
 static __u32 lba_shift;
+static __u32 meta_size;
 
 struct nvme_lbaf {
 	__le16			ms;
@@ -157,6 +158,7 @@ static int nvme_get_info(const char *file)
 
 	lba_size = 1 << ns.lbaf[(ns.flbas & 0x0f)].ds;
 	lba_shift = ilog2(lba_size);
+	meta_size = ns.lbaf[(ns.flbas & 0x0f)].ms;
 
 	close(fd);
 	return 0;
Signature · 1 line
2.47.1
#1 lore raw

The patch looks fine.
Just that it seems to have a conflict with the topmost patch [*] at this point.

[*] man: Fix syscall wrappers in example code

maintainer
#2 lore raw
Quoted 5 lines · Kanchan Joshi

The patch looks fine.
Just that it seems to have a conflict with the topmost patch [*] at this point.

[*] man: Fix syscall wrappers in example code

Confused, there should be zero overlap between this patch and the posted one?

Signature · 1 line
Jens Axboe
#3 lore raw
Quoted 2 lines · Jens Axboe

Confused, there should be zero overlap between this patch and the posted one?

Since you are able to apply fine, I must have hallucinated. Sorry for the fuss.

maintainer Applied
#4 lore raw
In reply to Keith Busch
Quoted 1 line · Keith Busch

Applied, thanks!

[1/1] liburing/io_passthrough: use metadata if format requires it

      commit: 60cf4969bd3eca3aba1fc24b6e0af7f92d155351

Best regards,

Signature · 1 line
Jens Axboe