Skip to contentSkip to conversation

selftests: add ublk selftests

PATCH Applied Ming Lei 2 participants 8 messages Feb 28, 2025 – Mar 1, 2025

Subsystems (4)
lore
Share & tools
lore

Ming Lei

author
#0 lore raw

v3 cover selftests: add ublk selftests

Hello Jens,

This patchset adds ublk kernel selftests, which is very handy for developer for verifying kernel change, especially ublk heavily depends on io_uring subsystem. Also it provides template for target implementation.

Please consider it for v6.15.

The 1st patch adds one ublk utility and one entry test. The 2nd patch adds test over file backed ublk. The 3rd patch adds test for ublk zero copy.

How to run:
- make install
- make headers_install INSTALL_HDR_PATH=/usr # in case UAPI is changed
- reboot
- make -C tools/testing/selftests TARGETS=ublk run_test

Thanks,

V3:
- re-organize code, and move target code into standalone source file
- fix one error handling bug
- add licence tag
- add dma limit for zero copy file backed target
- kill checkpatch ERROR

V2:
- fix one sqe allocation bug, so ublk zero copy with io_link can pass
- dump log in case of error
- add one more test for mkfs/mount on zero copy

Ming Lei (3):
selftests: ublk: add kernel selftests for ublk
selftests: ublk: add file backed ublk
selftests: ublk: add ublk zero copy test

 MAINTAINERS                                  |    1 +
 tools/testing/selftests/Makefile             |    1 +
 tools/testing/selftests/ublk/.gitignore      |    3 +
 tools/testing/selftests/ublk/Makefile        |   16 +
 tools/testing/selftests/ublk/config          |    1 +
 tools/testing/selftests/ublk/file_backed.c   |  220 ++++
 tools/testing/selftests/ublk/kublk.c         | 1110 ++++++++++++++++++
 tools/testing/selftests/ublk/kublk.h         |  326 +++++
 tools/testing/selftests/ublk/null.c          |   38 +
 tools/testing/selftests/ublk/test_common.sh  |  113 ++
 tools/testing/selftests/ublk/test_loop_01.sh |   31 +
 tools/testing/selftests/ublk/test_loop_02.sh |   22 +
 tools/testing/selftests/ublk/test_loop_03.sh |   33 +
 tools/testing/selftests/ublk/test_loop_04.sh |   22 +
 tools/testing/selftests/ublk/test_null_01.sh |   19 +
 15 files changed, 1956 insertions(+)
 create mode 100644 tools/testing/selftests/ublk/.gitignore
 create mode 100644 tools/testing/selftests/ublk/Makefile
 create mode 100644 tools/testing/selftests/ublk/config
 create mode 100644 tools/testing/selftests/ublk/file_backed.c
 create mode 100644 tools/testing/selftests/ublk/kublk.c
 create mode 100644 tools/testing/selftests/ublk/kublk.h
 create mode 100644 tools/testing/selftests/ublk/null.c
 create mode 100755 tools/testing/selftests/ublk/test_common.sh
 create mode 100755 tools/testing/selftests/ublk/test_loop_01.sh
 create mode 100755 tools/testing/selftests/ublk/test_loop_02.sh
 create mode 100755 tools/testing/selftests/ublk/test_loop_03.sh
 create mode 100755 tools/testing/selftests/ublk/test_loop_04.sh
 create mode 100755 tools/testing/selftests/ublk/test_null_01.sh
Signature · 1 line
2.47.0
author
#1 lore raw

PATCH v3 1/3 selftests: ublk: add kernel selftests for ublk

Both ublk driver and userspace heavily depends on io_uring subsystem, and tools/testing/selftests/ should be the best place for holding this cross-subsystem tests.

Add basic read/write IO test over this ublk null disk, and make sure ublk working.

More tests will be added.

---
 MAINTAINERS                                  |    1 +
 tools/testing/selftests/Makefile             |    1 +
 tools/testing/selftests/ublk/.gitignore      |    3 +
 tools/testing/selftests/ublk/Makefile        |   12 +
 tools/testing/selftests/ublk/config          |    1 +
 tools/testing/selftests/ublk/kublk.c         | 1081 ++++++++++++++++++
 tools/testing/selftests/ublk/kublk.h         |  252 ++++
 tools/testing/selftests/ublk/null.c          |   38 +
 tools/testing/selftests/ublk/test_common.sh  |   58 +
 tools/testing/selftests/ublk/test_null_01.sh |   19 +
 10 files changed, 1466 insertions(+)
 create mode 100644 tools/testing/selftests/ublk/.gitignore
 create mode 100644 tools/testing/selftests/ublk/Makefile
 create mode 100644 tools/testing/selftests/ublk/config
 create mode 100644 tools/testing/selftests/ublk/kublk.c
 create mode 100644 tools/testing/selftests/ublk/kublk.h
 create mode 100644 tools/testing/selftests/ublk/null.c
 create mode 100755 tools/testing/selftests/ublk/test_common.sh
 create mode 100755 tools/testing/selftests/ublk/test_null_01.sh
MAINTAINERS +1 -0
index dbc5e8b038fd..b869ccf024d5 100644
@@ -24365,6 +24365,7 @@ S:	Maintained
 F:	Documentation/block/ublk.rst
 F:	drivers/block/ublk_drv.c
 F:	include/uapi/linux/ublk_cmd.h
+F:	tools/testing/selftests/ublk/
 
 UBSAN
 M:	Kees Cook <[email protected]>
tools/testing/selftests/Makefile +1 -0
index 8daac70c2f9d..52ba0eb5eaa7 100644
@@ -113,6 +113,7 @@ endif
 TARGETS += tmpfs
 TARGETS += tpm2
 TARGETS += tty
+TARGETS += ublk
 TARGETS += uevent
 TARGETS += user_events
 TARGETS += vDSO
tools/testing/selftests/ublk/.gitignore new file +3 -0
new file mode 100644
index 000000000000..8b2871ea7751
@@ -0,0 +1,3 @@
+kublk
+/tools
+*-verify.state
tools/testing/selftests/ublk/Makefile new file +12 -0
new file mode 100644
index 000000000000..b6ac30621091
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0
+
+CFLAGS += -O3 -Wl,-no-as-needed -Wall -I $(top_srcdir)
+LDLIBS += -lpthread -lm -luring
+
+TEST_PROGS := test_null_01.sh
+
+TEST_GEN_PROGS_EXTENDED = kublk
+
+include ../lib.mk
+
+$(TEST_GEN_PROGS_EXTENDED): kublk.c null.c
tools/testing/selftests/ublk/config new file +1 -0
new file mode 100644
index 000000000000..592b0ba4d661
@@ -0,0 +1 @@
+CONFIG_BLK_DEV_UBLK=m
tools/testing/selftests/ublk/kublk.c new file +1081 -0

1,081 lines not on this page · raw message

tools/testing/selftests/ublk/kublk.h new file +252 -0

252 lines not on this page · raw message

tools/testing/selftests/ublk/null.c new file +38 -0
new file mode 100644
index 000000000000..b6ef16a8f514
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#include "kublk.h"
+
+static int ublk_null_tgt_init(struct ublk_dev *dev)
+{
+	const struct ublksrv_ctrl_dev_info *info = &dev->dev_info;
+	unsigned long dev_size = 250UL << 30;
+
+	dev->tgt.dev_size = dev_size;
+	dev->tgt.params = (struct ublk_params) {
+		.types = UBLK_PARAM_TYPE_BASIC,
+		.basic = {
+			.logical_bs_shift	= 9,
+			.physical_bs_shift	= 12,
+			.io_opt_shift		= 12,
+			.io_min_shift		= 9,
+			.max_sectors		= info->max_io_buf_bytes >> 9,
+			.dev_sectors		= dev_size >> 9,
+		},
+	};
+
+	return 0;
+}
+
+static int ublk_null_queue_io(struct ublk_queue *q, int tag)
+{
+	const struct ublksrv_io_desc *iod = ublk_get_iod(q, tag);
+
+	ublk_complete_io(q, tag, iod->nr_sectors << 9);
+	return 0;
+}
+
+const struct ublk_tgt_ops null_tgt_ops = {
+	.name = "null",
+	.init_tgt = ublk_null_tgt_init,
+	.queue_io = ublk_null_queue_io,
+};
tools/testing/selftests/ublk/test_common.sh new file +58 -0

58 lines not on this page · raw message

tools/testing/selftests/ublk/test_null_01.sh new file +19 -0
new file mode 100755
index 000000000000..04fc3ac7c716
@@ -0,0 +1,19 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+. test_common.sh
+
+TID="null_01"
+ERR_CODE=0
+
+_prep_test "null" "basic IO test"
+
+dev_id=`_add_ublk_dev -t null`
+
+# run fio over the two disks
+fio --name=job1 --filename=/dev/ublkb${dev_id} --ioengine=libaio --rw=readwrite --iodepth=32 --size=256M > /dev/null 2>&1
+ERR_CODE=$?
+
+_cleanup_test ${dev_id} "null"
+
+_show_result $TID $ERR_CODE
Signature · 1 line
2.47.0
author
#2 lore raw

PATCH v3 2/3 selftests: ublk: add file backed ublk

In reply to Ming Lei

Add file backed ublk target code, meantime add one fio test for covering write verify, another test for mkfs/mount/umount.

---
 tools/testing/selftests/ublk/Makefile        |   4 +-
 tools/testing/selftests/ublk/file_backed.c   | 158 +++++++++++++++++++
 tools/testing/selftests/ublk/kublk.c         |  12 +-
 tools/testing/selftests/ublk/kublk.h         |   8 +-
 tools/testing/selftests/ublk/test_common.sh  |  47 ++++++
 tools/testing/selftests/ublk/test_loop_01.sh |  31 ++++
 tools/testing/selftests/ublk/test_loop_02.sh |  22 +++
 7 files changed, 277 insertions(+), 5 deletions(-)
 create mode 100644 tools/testing/selftests/ublk/file_backed.c
 create mode 100755 tools/testing/selftests/ublk/test_loop_01.sh
 create mode 100755 tools/testing/selftests/ublk/test_loop_02.sh
tools/testing/selftests/ublk/Makefile +3 -1
index b6ac30621091..7815aaaefc25 100644
@@ -4,9 +4,11 @@ CFLAGS += -O3 -Wl,-no-as-needed -Wall -I $(top_srcdir)
 LDLIBS += -lpthread -lm -luring
 
 TEST_PROGS := test_null_01.sh
+TEST_PROGS += test_loop_01.sh
+TEST_PROGS += test_loop_02.sh
 
 TEST_GEN_PROGS_EXTENDED = kublk
 
 include ../lib.mk
 
-$(TEST_GEN_PROGS_EXTENDED): kublk.c null.c
+$(TEST_GEN_PROGS_EXTENDED): kublk.c null.c file_backed.c
tools/testing/selftests/ublk/file_backed.c new file +158 -0

158 lines not on this page · raw message

tools/testing/selftests/ublk/kublk.c +10 -2
index b2dfd35bc157..f7b9ede17bb3 100644
@@ -8,6 +8,7 @@
 unsigned int ublk_dbg_mask = UBLK_LOG;
 static const struct ublk_tgt_ops *tgt_ops_list[] = {
 	&null_tgt_ops,
+	&loop_tgt_ops,
 };
 
 static const struct ublk_tgt_ops *ublk_find_tgt(const char *name)
@@ -774,7 +775,7 @@ static int __cmd_dev_add(const struct dev_ctx *ctx)
 	struct ublksrv_ctrl_dev_info *info;
 	struct ublk_dev *dev;
 	int dev_id = ctx->dev_id;
-	int ret;
+	int ret, i;
 
 	ops = ublk_find_tgt(tgt_type);
 	if (!ops) {
@@ -813,6 +814,13 @@ static int __cmd_dev_add(const struct dev_ctx *ctx)
 	dev->tgt.sq_depth = depth;
 	dev->tgt.cq_depth = depth;
 
+	for (i = 0; i < MAX_BACK_FILES; i++) {
+		if (ctx->files[i]) {
+			strcpy(dev->tgt.backing_file[i], ctx->files[i]);
+			dev->tgt.nr_backing_files++;
+		}
+	}
+
 	ret = ublk_ctrl_add_dev(dev);
 	if (ret < 0) {
 		ublk_err("%s: can't add dev id %d, type %s ret %d\n",
@@ -994,7 +1002,7 @@ static int cmd_dev_get_features(void)
 
 static int cmd_dev_help(char *exe)
 {
-	printf("%s add -t [null] [-q nr_queues] [-d depth] [-n dev_id]\n", exe);
+	printf("%s add -t [null|loop] [-q nr_queues] [-d depth] [-n dev_id] [backfile1] [backfile2] ...\n", exe);
 	printf("\t default: nr_queues=2(max 4), depth=128(max 128), dev_id=-1(auto allocation)\n");
 	printf("%s del [-n dev_id] -a \n", exe);
 	printf("\t -a delete all devices -n delete specified device\n");
tools/testing/selftests/ublk/kublk.h +6 -2
index cb2540caa358..d71c6c3767a9 100644
@@ -105,7 +105,10 @@ struct ublk_tgt {
 	unsigned int  cq_depth;
 	const struct ublk_tgt_ops *ops;
 	struct ublk_params params;
-	char backing_file[1024 - 8 - sizeof(struct ublk_params)];
+
+	int nr_backing_files;
+	unsigned long backing_file_size[MAX_BACK_FILES];
+	char backing_file[MAX_BACK_FILES][PATH_MAX];
 };
 
 struct ublk_queue {
@@ -131,7 +134,7 @@ struct ublk_dev {
 	struct ublksrv_ctrl_dev_info  dev_info;
 	struct ublk_queue q[UBLK_MAX_QUEUES];
 
-	int fds[2];	/* fds[0] points to /dev/ublkcN */
+	int fds[MAX_BACK_FILES + 1];	/* fds[0] points to /dev/ublkcN */
 	int nr_fds;
 	int ctrl_fd;
 	struct io_uring ring;
@@ -248,5 +251,6 @@ static inline int ublk_complete_io(struct ublk_queue *q, unsigned tag, int res)
 }
 
 extern const struct ublk_tgt_ops null_tgt_ops;
+extern const struct ublk_tgt_ops loop_tgt_ops;
 
 #endif
tools/testing/selftests/ublk/test_common.sh +47 -0

53 lines not on this page · raw message

tools/testing/selftests/ublk/test_loop_01.sh new file +31 -0
new file mode 100755
index 000000000000..829e8df05942
@@ -0,0 +1,31 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+. test_common.sh
+
+TID="loop_01"
+ERR_CODE=0
+
+_prep_test "loop" "write and verify test"
+
+backfile_0=`_create_backfile 256M`
+
+dev_id=`_add_ublk_dev -t loop $backfile_0`
+
+# run fio over the ublk disk
+fio --name=write_and_verify \
+    --filename=/dev/ublkb${dev_id} \
+    --ioengine=libaio --iodepth=16 \
+    --rw=write \
+    --size=256M \
+    --direct=1 \
+    --verify=crc32c \
+    --do_verify=1 \
+    --bs=4k > /dev/null 2>&1
+ERR_CODE=$?
+
+_cleanup_test ${dev_id} "loop"
+
+_remove_backfile $backfile_0
+
+_show_result $TID $ERR_CODE
tools/testing/selftests/ublk/test_loop_02.sh new file +22 -0
new file mode 100755
index 000000000000..c71ae63059b8
@@ -0,0 +1,22 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+. test_common.sh
+
+TID="loop_02"
+ERR_CODE=0
+
+_prep_test "loop" "mkfs & mount & umount"
+
+backfile_0=`_create_backfile 256M`
+
+dev_id=`_add_ublk_dev -t loop $backfile_0`
+
+_mkfs_mount_test /dev/ublkb${dev_id}
+ERR_CODE=$?
+
+_cleanup_test ${dev_id} "loop"
+
+_remove_backfile $backfile_0
+
+_show_result $TID $ERR_CODE
Signature · 1 line
2.47.0
author
#3 lore raw

PATCH v3 3/3 selftests: ublk: add ublk zero copy test

In reply to Ming Lei

Enable zero copy on file backed target, meantime add one fio test for covering write verify, another test for mkfs/mount/umount.

---
 tools/testing/selftests/ublk/Makefile        |   2 +
 tools/testing/selftests/ublk/file_backed.c   | 104 +++++++++++++++----
 tools/testing/selftests/ublk/kublk.c         |  25 ++++-
 tools/testing/selftests/ublk/kublk.h         |  70 +++++++++++++
 tools/testing/selftests/ublk/test_common.sh  |   8 ++
 tools/testing/selftests/ublk/test_loop_03.sh |  33 ++++++
 tools/testing/selftests/ublk/test_loop_04.sh |  22 ++++
 7 files changed, 241 insertions(+), 23 deletions(-)
 create mode 100755 tools/testing/selftests/ublk/test_loop_03.sh
 create mode 100755 tools/testing/selftests/ublk/test_loop_04.sh
tools/testing/selftests/ublk/Makefile +2 -0
index 7815aaaefc25..555a3ba5b481 100644
@@ -6,6 +6,8 @@ LDLIBS += -lpthread -lm -luring
 TEST_PROGS := test_null_01.sh
 TEST_PROGS += test_loop_01.sh
 TEST_PROGS += test_loop_02.sh
+TEST_PROGS += test_loop_03.sh
+TEST_PROGS += test_loop_04.sh
 
 TEST_GEN_PROGS_EXTENDED = kublk
 
tools/testing/selftests/ublk/file_backed.c +83 -21

153 lines not on this page · raw message

tools/testing/selftests/ublk/kublk.c +23 -2
index f7b9ede17bb3..b65bdaf7e281 100644
@@ -282,6 +282,8 @@ static void ublk_queue_deinit(struct ublk_queue *q)
 	int i;
 	int nr_ios = q->q_depth;
 
+	io_uring_unregister_buffers(&q->ring);
+
 	io_uring_unregister_ring_fd(&q->ring);
 
 	if (q->ring.ring_fd > 0) {
@@ -312,6 +314,11 @@ static int ublk_queue_init(struct ublk_queue *q)
 	q->cmd_inflight = 0;
 	q->tid = gettid();
 
+	if (dev->dev_info.flags & UBLK_F_SUPPORT_ZERO_COPY) {
+		q->state |= UBLKSRV_NO_BUF;
+		q->state |= UBLKSRV_ZC;
+	}
+
 	cmd_buf_size = ublk_queue_cmd_buf_sz(q);
 	off = UBLKSRV_CMD_BUF_OFFSET + q->q_id * ublk_queue_max_cmd_buf_sz();
 	q->io_cmd_buf = (char *)mmap(0, cmd_buf_size, PROT_READ,
@@ -346,6 +353,15 @@ static int ublk_queue_init(struct ublk_queue *q)
 		goto fail;
 	}
 
+	if (dev->dev_info.flags & UBLK_F_SUPPORT_ZERO_COPY) {
+		ret = io_uring_register_buffers_sparse(&q->ring, q->q_depth);
+		if (ret) {
+			ublk_err("ublk dev %d queue %d register spare buffers failed %d",
+					dev->dev_info.dev_id, q->q_id, ret);
+			goto fail;
+		}
+	}
+
 	io_uring_register_ring_fd(&q->ring);
 
 	ret = io_uring_register_files(&q->ring, dev->fds, dev->nr_fds);
@@ -502,9 +518,10 @@ static void ublk_handle_cqe(struct io_uring *r,
 		ublk_err("%s: res %d userdata %llx queue state %x\n", __func__,
 				cqe->res, cqe->user_data, q->state);
 
-	ublk_dbg(UBLK_DBG_IO_CMD, "%s: res %d (qid %d tag %u cmd_op %u target %d) stopping %d\n",
+	ublk_dbg(UBLK_DBG_IO_CMD, "%s: res %d (qid %d tag %u cmd_op %u target %d/%d) stopping %d\n",
 			__func__, cqe->res, q->q_id, tag, cmd_op,
 			is_target_io(cqe->user_data),
+			user_data_to_tgt_data(cqe->user_data),
 			(q->state & UBLKSRV_QUEUE_STOPPING));
 
 	/* Don't retrieve io in case of target io */
@@ -1022,6 +1039,7 @@ int main(int argc, char *argv[])
 		{ "depth",		1,	NULL, 'd' },
 		{ "debug_mask",		1,	NULL,  0  },
 		{ "quiet",		0,	NULL,  0  },
+		{ "zero_copy",          1,      NULL, 'z' },
 		{ 0, 0, 0, 0 }
 	};
 	int option_idx, opt;
@@ -1038,7 +1056,7 @@ int main(int argc, char *argv[])
 		return ret;
 
 	optind = 2;
-	while ((opt = getopt_long(argc, argv, "t:n:d:q:a",
+	while ((opt = getopt_long(argc, argv, "t:n:d:q:a:z",
 				  longopts, &option_idx)) != -1) {
 		switch (opt) {
 		case 'a':
@@ -1057,6 +1075,9 @@ int main(int argc, char *argv[])
 		case 'd':
 			ctx.queue_depth = strtol(optarg, NULL, 10);
 			break;
+		case 'z':
+			ctx.flags |= UBLK_F_SUPPORT_ZERO_COPY | UBLK_F_USER_COPY;
+			break;
 		case 0:
 			if (!strcmp(longopts[option_idx].name, "debug_mask"))
 				ublk_dbg_mask = strtol(optarg, NULL, 16);
tools/testing/selftests/ublk/kublk.h +70 -0

105 lines not on this page · raw message

tools/testing/selftests/ublk/test_common.sh +8 -0
index ad40c1511f41..304f22ffda58 100755
@@ -102,4 +102,12 @@ _add_ublk_dev() {
 	echo ${dev_id}
 }
 
+_have_feature()
+{
+	if  $UBLK_PROG "features" | grep $1 > /dev/null 2>&1; then
+		return 0
+	fi
+	return 1
+}
+
 export UBLK_PROG=$(pwd)/kublk
tools/testing/selftests/ublk/test_loop_03.sh new file +33 -0
new file mode 100755
index 000000000000..e781ac6db6b4
@@ -0,0 +1,33 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+. test_common.sh
+
+TID="loop_03"
+ERR_CODE=0
+
+_have_feature "ZERO_COPY" || exit 4
+
+_prep_test "loop" "write and verify over zero copy"
+
+backfile_0=`_create_backfile 256M`
+
+dev_id=`_add_ublk_dev -t loop $backfile_0 -z`
+
+# run fio over the ublk disk
+fio --name=write_and_verify \
+    --filename=/dev/ublkb${dev_id} \
+    --ioengine=libaio --iodepth=64 \
+    --rw=write \
+    --size=256M \
+    --direct=1 \
+    --verify=crc32c \
+    --do_verify=1 \
+    --bs=4k > /dev/null 2>&1
+ERR_CODE=$?
+
+_cleanup_test ${dev_id} "loop"
+
+_remove_backfile $backfile_0
+
+_show_result $TID $ERR_CODE
tools/testing/selftests/ublk/test_loop_04.sh new file +22 -0
new file mode 100755
index 000000000000..6ab67247c809
@@ -0,0 +1,22 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+. test_common.sh
+
+TID="loop_04"
+ERR_CODE=0
+
+_prep_test "loop" "mkfs & mount & umount with zero copy"
+
+backfile_0=`_create_backfile 256M`
+
+dev_id=`_add_ublk_dev -t loop -z $backfile_0`
+
+_mkfs_mount_test /dev/ublkb${dev_id}
+ERR_CODE=$?
+
+_cleanup_test ${dev_id} "loop"
+
+_remove_backfile $backfile_0
+
+_show_result $TID $ERR_CODE
Signature · 1 line
2.47.0
maintainer
#4 lore raw
In reply to Ming Lei
Quoted 7 lines · Ming Lei

Hello Jens,

This patchset adds ublk kernel selftests, which is very handy for developer for verifying kernel change, especially ublk heavily depends on io_uring subsystem. Also it provides template for target implementation.

Please consider it for v6.15.

Can we add the zc bits to the liburing test case as well?

Signature · 1 line
Jens Axboe
author
#5 lore raw
Quoted 10 lines · Jens Axboe
Quoted 7 lines · Ming Lei

Hello Jens,

This patchset adds ublk kernel selftests, which is very handy for developer for verifying kernel change, especially ublk heavily depends on io_uring subsystem. Also it provides template for target implementation.

Please consider it for v6.15.

Can we add the zc bits to the liburing test case as well?

OK, will unify the two tests and cover liburing too.

BTW, would you like to consider to move liburing tests or part of them into kernel selftests?

This way looks more friendly for kernel developer:

- single repo, and single patchset can include both io_uring kernel patches and selftests change

- easy to run test against same kernel repo

Also liburing development may be decoupled from io_uring kernel a bit.

Thanks,
Ming

maintainer
#6 lore raw
Quoted 17 lines · Ming Lei
Quoted 10 lines · Jens Axboe
Quoted 7 lines · Ming Lei

Hello Jens,

This patchset adds ublk kernel selftests, which is very handy for developer for verifying kernel change, especially ublk heavily depends on io_uring subsystem. Also it provides template for target implementation.

Please consider it for v6.15.

Can we add the zc bits to the liburing test case as well?

OK, will unify the two tests and cover liburing too.

BTW, would you like to consider to move liburing tests or part of them into kernel selftests?

Quoted 6 lines

This way looks more friendly for kernel developer:

- single repo, and single patchset can include both io_uring kernel patches and selftests change

- easy to run test against same kernel repo

I have considered it, but at least the way I run the liburing tests, it uses a bunch of different types of devices to get full coverage. It's not really a fire-off-and-forget kind of setup. Yes you can run it like that and not have it use any other fs or device, but you won't get full coverage. The liburing regression tests are also meant to be run on ANY kernel, not just the current kernel. Eg I do that for stable kernels.

As far as I can tell, the only win here would be that it'd be easier for someone to run when making a kernel change. And that is a nice win indeed. But there are so many downsides for me and the tests in general, that I don't see that win as being nearly big enough to warrant switching it over.

For new feature tests, I think adding that as kernel selftests may make more sense - test that it works, test failure/error cases, etc.

Quoted 2 lines

Also liburing development may be decoupled from io_uring kernel a bit.

It's already entirely decoupled from the kernel. At least as much as it can be. Yes the uapi header is shared and synced across them, but there's really no other dependency there and no version dependencies between liburing and the kernel.

Signature · 1 line
Jens Axboe
maintainer Applied
#7 lore raw
In reply to Ming Lei
Quoted 11 lines · Ming Lei

This patchset adds ublk kernel selftests, which is very handy for developer for verifying kernel change, especially ublk heavily depends on io_uring subsystem. Also it provides template for target implementation.

Please consider it for v6.15.

The 1st patch adds one ublk utility and one entry test. The 2nd patch adds test over file backed ublk. The 3rd patch adds test for ublk zero copy.

[...]

Applied, thanks!

[1/3] selftests: ublk: add kernel selftests for ublk

      commit: 6aecda00b7d1e187c31e702d607d2b51bbcddbcc
[2/3] selftests: ublk: add file backed ublk
      commit: 5d95bfb5357111028b7a37464d1a18702722efe9
[3/3] selftests: ublk: add ublk zero copy test
      commit: bedc9cbc5f9709b97646fe3423dbf530b74b09d5

Best regards,

Signature · 1 line
Jens Axboe