selftests: ublk: add user copy test cases
Subsystems (3)
cover selftests: ublk: add user copy test cases
Fix some existing issues in the ublk selftest suite and add coverage for user copy, which is currently untested.
Caleb Sander Mateos (8):
selftests: ublk: correct last_rw map type in seq_io.bt
selftests: ublk: remove unused ios map in seq_io.bt
selftests: ublk: fix fio arguments in run_io_and_recover()
selftests: ublk: use auto_zc for PER_IO_DAEMON tests in stress_04
selftests: ublk: don't share backing files between ublk servers
selftests: ublk: forbid multiple data copy modes
selftests: ublk: add support for user copy to kublk
selftests: ublk: add user copy test cases
tools/testing/selftests/ublk/Makefile | 8 ++ tools/testing/selftests/ublk/file_backed.c | 7 +- tools/testing/selftests/ublk/kublk.c | 74 +++++++++++++++---- tools/testing/selftests/ublk/kublk.h | 11 +++ tools/testing/selftests/ublk/stripe.c | 2 +- tools/testing/selftests/ublk/test_common.sh | 5 +- .../testing/selftests/ublk/test_generic_04.sh | 2 +- .../testing/selftests/ublk/test_generic_05.sh | 2 +- .../testing/selftests/ublk/test_generic_09.sh | 2 +- .../testing/selftests/ublk/test_generic_11.sh | 2 +- .../testing/selftests/ublk/test_generic_14.sh | 40 ++++++++++ tools/testing/selftests/ublk/test_loop_06.sh | 25 +++++++ tools/testing/selftests/ublk/test_loop_07.sh | 21 ++++++ tools/testing/selftests/ublk/test_null_03.sh | 24 ++++++ .../testing/selftests/ublk/test_stress_03.sh | 4 +- .../testing/selftests/ublk/test_stress_04.sh | 14 ++-- .../testing/selftests/ublk/test_stress_05.sh | 17 +++-- .../testing/selftests/ublk/test_stress_06.sh | 39 ++++++++++ .../testing/selftests/ublk/test_stress_07.sh | 39 ++++++++++ .../testing/selftests/ublk/test_stripe_05.sh | 26 +++++++ .../testing/selftests/ublk/test_stripe_06.sh | 21 ++++++ tools/testing/selftests/ublk/trace/seq_io.bt | 3 +- 22 files changed, 350 insertions(+), 38 deletions(-) create mode 100755 tools/testing/selftests/ublk/test_generic_14.sh create mode 100755 tools/testing/selftests/ublk/test_loop_06.sh create mode 100755 tools/testing/selftests/ublk/test_loop_07.sh create mode 100755 tools/testing/selftests/ublk/test_null_03.sh create mode 100755 tools/testing/selftests/ublk/test_stress_06.sh create mode 100755 tools/testing/selftests/ublk/test_stress_07.sh create mode 100755 tools/testing/selftests/ublk/test_stripe_05.sh create mode 100755 tools/testing/selftests/ublk/test_stripe_06.sh
Signature · 1 line
2.45.2
PATCH 1/8 selftests: ublk: correct last_rw map type in seq_io.bt
The last_rw map is initialized with a value of 0 but later assigned the
value args.sector + args.nr_sector, which has type sector_t = u64.
bpftrace complains about the type mismatch between int64 and uint64:
trace/seq_io.bt:18:3-59: ERROR: Type mismatch for @last_rw: trying to assign value of type 'uint64' when map already contains a value of type 'int64'
@last_rw[$dev, str($2)] = (args.sector + args.nr_sector);
Cast the initial value to uint64 so bpftrace will load the program.
--- tools/testing/selftests/ublk/trace/seq_io.bt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ublk/trace/seq_io.bt +1 -1
@@ -2,11 +2,11 @@ $1: dev_t $2: RWBS $3: strlen($2) */ BEGIN { - @last_rw[$1, str($2)] = 0; + @last_rw[$1, str($2)] = (uint64)0; } tracepoint:block:block_rq_complete { $dev = $1; if ((int64)args.dev == $1 && !strncmp(args.rwbs, str($2), $3)) {
Signature · 1 line
2.45.2
Re: [PATCH 1/8] selftests: ublk: correct last_rw map type in seq_io.bt
Quoted 18 lines · Caleb Sander Mateos
The
last_rwmap is initialized with a value of 0 but later assigned the
value args.sector + args.nr_sector, which has typesector_t= u64.
bpftrace complains about the type mismatch between int64 and uint64:
trace/seq_io.bt:18:3-59: ERROR: Type mismatch for @last_rw: trying to assign value of type 'uint64' when map already contains a value of type 'int64'@last_rw[$dev, str($2)] = (args.sector + args.nr_sector);Cast the initial value to uint64 so bpftrace will load the program.
Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/trace/seq_io.bt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/ublk/trace/seq_io.bt +0
-0
tools/testing/selftests/ublk/trace/seq_io.bt line 7
Quoted 7 lines
tools/testing/selftests/ublk/trace/seq_io.bt +1
-1@@ -2,11 +2,11 @@ $1: dev_t $2: RWBS $3: strlen($2) */ BEGIN { - @last_rw[$1, str($2)] = 0; + @last_rw[$1, str($2)] = (uint64)0;
Thanks,
Ming
PATCH 2/8 selftests: ublk: remove unused ios map in seq_io.bt
In reply to Caleb Sander MateosThe ios map populated by seq_io.bt is never read, so remove it.
--- tools/testing/selftests/ublk/trace/seq_io.bt | 1 - 1 file changed, 1 deletion(-)
tools/testing/selftests/ublk/trace/seq_io.bt +0 -1
@@ -15,11 +15,10 @@ tracepoint:block:block_rq_complete printf("io_out_of_order: exp %llu actual %llu\n", args.sector, $last); } @last_rw[$dev, str($2)] = (args.sector + args.nr_sector); } - @ios = count(); } END { clear(@last_rw); }
Signature · 1 line
2.45.2
Re: [PATCH 2/8] selftests: ublk: remove unused ios map in seq_io.bt
Quoted 12 lines · Caleb Sander Mateos
The ios map populated by seq_io.bt is never read, so remove it.
Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/trace/seq_io.bt | 1 - 1 file changed, 1 deletion(-)tools/testing/selftests/ublk/trace/seq_io.bt +0
-0
tools/testing/selftests/ublk/trace/seq_io.bt tracepoint:block:block_rq_complete · line 20
Quoted 6 lines
tools/testing/selftests/ublk/trace/seq_io.bt +0
-1@@ -15,11 +15,10 @@ tracepoint:block:block_rq_complete printf("io_out_of_order: exp %llu actual %llu\n", args.sector, $last); } @last_rw[$dev, str($2)] = (args.sector + args.nr_sector); } - @ios = count();
BTW, it was for debug purpose, but now it isn't needed.
Thanks,
Ming
~
PATCH 3/8 selftests: ublk: fix fio arguments in run_io_and_recover()
In reply to Caleb Sander Mateosrun_io_and_recover() invokes fio with --size="${size}", but the variable size doesn't exist. Thus, the argument expands to --size=, which causes fio to exit immediately with an error without issuing any I/O. Pass the value for size as the first argument to the function.
--- tools/testing/selftests/ublk/test_common.sh | 5 +++-- tools/testing/selftests/ublk/test_generic_04.sh | 2 +- tools/testing/selftests/ublk/test_generic_05.sh | 2 +- tools/testing/selftests/ublk/test_generic_11.sh | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-)
tools/testing/selftests/ublk/test_common.sh +3 -2
@@ -331,15 +331,16 @@ run_io_and_kill_daemon() fi } run_io_and_recover() { - local action=$1 + local size=$1 + local action=$2 local state local dev_id - shift 1 + shift 2 dev_id=$(_add_ublk_dev "$@") _check_add_dev "$TID" $? fio --name=job1 --filename=/dev/ublkb"${dev_id}" --ioengine=libaio \ --rw=randread --iodepth=256 --size="${size}" --numjobs=4 \
tools/testing/selftests/ublk/test_generic_04.sh +1 -1
@@ -6,11 +6,11 @@ TID="generic_04" ERR_CODE=0 ublk_run_recover_test() { - run_io_and_recover "kill_daemon" "$@" + run_io_and_recover 256M "kill_daemon" "$@" ERR_CODE=$? if [ ${ERR_CODE} -ne 0 ]; then echo "$TID failure: $*" _show_result $TID $ERR_CODE fi
tools/testing/selftests/ublk/test_generic_05.sh +1 -1
@@ -6,11 +6,11 @@ TID="generic_05" ERR_CODE=0 ublk_run_recover_test() { - run_io_and_recover "kill_daemon" "$@" + run_io_and_recover 256M "kill_daemon" "$@" ERR_CODE=$? if [ ${ERR_CODE} -ne 0 ]; then echo "$TID failure: $*" _show_result $TID $ERR_CODE fi
tools/testing/selftests/ublk/test_generic_11.sh +1 -1
@@ -6,11 +6,11 @@ TID="generic_11" ERR_CODE=0 ublk_run_quiesce_recover() { - run_io_and_recover "quiesce_dev" "$@" + run_io_and_recover 256M "quiesce_dev" "$@" ERR_CODE=$? if [ ${ERR_CODE} -ne 0 ]; then echo "$TID failure: $*" _show_result $TID $ERR_CODE fi
Signature · 1 line
2.45.2
Re: [PATCH 3/8] selftests: ublk: fix fio arguments in run_io_and_recover()
Quoted 6 lines · Caleb Sander Mateos
run_io_and_recover()invokes fio with --size="${size}", but the variable size doesn't exist. Thus, the argument expands to --size=, which causes fio to exit immediately with an error without issuing any I/O. Pass the value for size as the first argument to the function.Signed-off-by Caleb Sander Mateos <[email protected]>
Thanks,
Ming
PATCH 4/8 selftests: ublk: use auto_zc for PER_IO_DAEMON tests in stress_04
In reply to Caleb Sander Mateosstress_04 is described as "run IO and kill ublk server(zero copy)" but the --per_io_tasks tests cases don't use zero copy. Plus, one of the test cases is duplicated. Add --auto_zc to these test cases and --auto_zc_fallback to one of the duplicated ones. This matches the test cases in stress_03.
--- tools/testing/selftests/ublk/test_stress_04.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/ublk/test_stress_04.sh +4 -4
@@ -38,14 +38,14 @@ if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & fi if _have_feature "PER_IO_DAEMON"; then - ublk_io_and_kill_daemon 8G -t null -q 4 --nthreads 8 --per_io_tasks & - ublk_io_and_kill_daemon 256M -t loop -q 4 --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & - ublk_io_and_kill_daemon 256M -t stripe -q 4 --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_kill_daemon 8G -t null -q 4 --nthreads 8 --per_io_tasks & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & + ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & + ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & fi wait _cleanup_test "stress" _show_result $TID $ERR_CODE
Signature · 1 line
2.45.2
Re: [PATCH 4/8] selftests: ublk: use auto_zc for PER_IO_DAEMON tests in stress_04
Quoted 19 lines · Caleb Sander Mateos
stress_04is described as "run IO and kill ublk server(zero copy)" but the --per_io_tasks tests cases don't use zero copy. Plus, one of the test cases is duplicated. Add --auto_zc to these test cases and --auto_zc_fallback to one of the duplicated ones. This matches the test cases instress_03.Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/test_stress_04.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)tools/testing/selftests/ublk/test_stress_04.sh +0
-0@@ -38,14 +38,14 @@ if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & fi
tools/testing/selftests/ublk/test_stress_04.sh if _have_feature "AUTO_BUF_REG"; then · line 46
Quoted 10 lines
tools/testing/selftests/ublk/test_stress_04.sh +4
-4if _have_feature "PER_IO_DAEMON"; then - ublk_io_and_kill_daemon 8G -t null -q 4 --nthreads 8 --per_io_tasks & - ublk_io_and_kill_daemon 256M -t loop -q 4 --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & - ublk_io_and_kill_daemon 256M -t stripe -q 4 --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_kill_daemon 8G -t null -q 4 --nthreads 8 --per_io_tasks & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & + ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & + ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks &
I'd rather to fix the test description, the original motivation is to cover more data copy parameters(--z, --auto_zc, plain copy) in same stress test.
Thanks,
Ming
Re: [PATCH 4/8] selftests: ublk: use auto_zc for PER_IO_DAEMON tests in stress_04
Quoted 22 lines · Ming Lei
Quoted 20 lines · Caleb Sander Mateos
stress_04is described as "run IO and kill ublk server(zero copy)" but the --per_io_tasks tests cases don't use zero copy. Plus, one of the test cases is duplicated. Add --auto_zc to these test cases and --auto_zc_fallback to one of the duplicated ones. This matches the test cases instress_03.Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/test_stress_04.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)tools/testing/selftests/ublk/test_stress_04.sh +0
-0@@ -38,14 +38,14 @@ if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & fi
Quoted 12 lines
tools/testing/selftests/ublk/test_stress_04.sh if _have_feature "AUTO_BUF_REG"; then · line 46
Quoted 9 lines
tools/testing/selftests/ublk/test_stress_04.sh +4
-4if _have_feature "PER_IO_DAEMON"; then - ublk_io_and_kill_daemon 8G -t null -q 4 --nthreads 8 --per_io_tasks & - ublk_io_and_kill_daemon 256M -t loop -q 4 --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & - ublk_io_and_kill_daemon 256M -t stripe -q 4 --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_kill_daemon 8G -t null -q 4 --nthreads 8 --per_io_tasks & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & + ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & + ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks &I'd rather to fix the test description, the original motivation is to cover more data copy
parameters(--z, --auto_zc, plain copy)in same stress test.
What about the duplicated "-t null -q 4 --nthreads 8 --per_io_tasks" test case? I can't imagine that's intentional...
Thanks,
Caleb
Re: [PATCH 4/8] selftests: ublk: use auto_zc for PER_IO_DAEMON tests in stress_04
Quoted 36 lines · Caleb Sander Mateos
Quoted 22 lines · Ming Lei
Quoted 20 lines · Caleb Sander Mateos
stress_04is described as "run IO and kill ublk server(zero copy)" but the --per_io_tasks tests cases don't use zero copy. Plus, one of the test cases is duplicated. Add --auto_zc to these test cases and --auto_zc_fallback to one of the duplicated ones. This matches the test cases instress_03.Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/test_stress_04.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)tools/testing/selftests/ublk/test_stress_04.sh +0
-0@@ -38,14 +38,14 @@ if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & fiQuoted 12 lines
tools/testing/selftests/ublk/test_stress_04.sh if _have_feature "AUTO_BUF_REG"; then · line 46
Quoted 9 lines
tools/testing/selftests/ublk/test_stress_04.sh +4
-4if _have_feature "PER_IO_DAEMON"; then - ublk_io_and_kill_daemon 8G -t null -q 4 --nthreads 8 --per_io_tasks & - ublk_io_and_kill_daemon 256M -t loop -q 4 --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & - ublk_io_and_kill_daemon 256M -t stripe -q 4 --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_kill_daemon 8G -t null -q 4 --nthreads 8 --per_io_tasks & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & + ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & + ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks &I'd rather to fix the test description, the original motivation is to cover more data copy
parameters(--z, --auto_zc, plain copy)in same stress test.
Quoted 2 lines
What about the duplicated "-t null -q 4 --nthreads 8 --per_io_tasks" test case? I can't imagine that's intentional...
OK, the last one may need to pass '-z' so that --per_io_tasks & -z combination can be covered.
Thanks,
Ming
Re: [PATCH 4/8] selftests: ublk: use auto_zc for PER_IO_DAEMON tests in stress_04
In reply to Ming LeiQuoted 22 lines · Ming Lei
Quoted 20 lines · Caleb Sander Mateos
stress_04is described as "run IO and kill ublk server(zero copy)" but the --per_io_tasks tests cases don't use zero copy. Plus, one of the test cases is duplicated. Add --auto_zc to these test cases and --auto_zc_fallback to one of the duplicated ones. This matches the test cases instress_03.Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/test_stress_04.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)tools/testing/selftests/ublk/test_stress_04.sh +0
-0@@ -38,14 +38,14 @@ if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & fi
Quoted 12 lines
tools/testing/selftests/ublk/test_stress_04.sh if _have_feature "AUTO_BUF_REG"; then · line 46
Quoted 9 lines
tools/testing/selftests/ublk/test_stress_04.sh +4
-4if _have_feature "PER_IO_DAEMON"; then - ublk_io_and_kill_daemon 8G -t null -q 4 --nthreads 8 --per_io_tasks & - ublk_io_and_kill_daemon 256M -t loop -q 4 --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & - ublk_io_and_kill_daemon 256M -t stripe -q 4 --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_kill_daemon 8G -t null -q 4 --nthreads 8 --per_io_tasks & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & + ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & + ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks &I'd rather to fix the test description, the original motivation is to cover more data copy
parameters(--z, --auto_zc, plain copy)in same stress test.
test_stress_02.sh ("run IO and kill ublk server") already covers plain copy. But sure, I can change the test_stress_04.sh description to "... (more features)" or something.
Thanks,
Caleb
Re: [PATCH 4/8] selftests: ublk: use auto_zc for PER_IO_DAEMON tests in stress_04
Quoted 36 lines · Caleb Sander Mateos
Quoted 22 lines · Ming Lei
Quoted 20 lines · Caleb Sander Mateos
stress_04is described as "run IO and kill ublk server(zero copy)" but the --per_io_tasks tests cases don't use zero copy. Plus, one of the test cases is duplicated. Add --auto_zc to these test cases and --auto_zc_fallback to one of the duplicated ones. This matches the test cases instress_03.Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/test_stress_04.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)tools/testing/selftests/ublk/test_stress_04.sh +0
-0@@ -38,14 +38,14 @@ if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & fiQuoted 12 lines
tools/testing/selftests/ublk/test_stress_04.sh if _have_feature "AUTO_BUF_REG"; then · line 46
Quoted 9 lines
tools/testing/selftests/ublk/test_stress_04.sh +4
-4if _have_feature "PER_IO_DAEMON"; then - ublk_io_and_kill_daemon 8G -t null -q 4 --nthreads 8 --per_io_tasks & - ublk_io_and_kill_daemon 256M -t loop -q 4 --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & - ublk_io_and_kill_daemon 256M -t stripe -q 4 --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_kill_daemon 8G -t null -q 4 --nthreads 8 --per_io_tasks & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & + ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & + ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks &I'd rather to fix the test description, the original motivation is to cover more data copy
parameters(--z, --auto_zc, plain copy)in same stress test.
Quoted 3 lines
test_stress_02.sh("run IO and kill ublk server") already covers plain copy. But sure, I can change thetest_stress_04.shdescription to "... (more features)" or something.
oops, stress_02 is same kind of test with stress_04.sh, I missed this point.
Your patch looks correct to make stress_04 for covering zero copy only.
Sorry for the noise.
Thanks,
Ming
PATCH 5/8 selftests: ublk: don't share backing files between ublk servers
In reply to Caleb Sander Mateosstress_04 is missing a wait between blocks of tests, meaning multiple ublk servers will be running in parallel using the same backing files. Add a wait after each section to ensure each backing file is in use by a single ublk server at a time.
--- tools/testing/selftests/ublk/test_stress_04.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/testing/selftests/ublk/test_stress_04.sh +3 -1
@@ -29,23 +29,25 @@ _create_backfile 1 128M _create_backfile 2 128M ublk_io_and_kill_daemon 8G -t null -q 4 -z --no_ublk_fixed_fd & ublk_io_and_kill_daemon 256M -t loop -q 4 -z --no_ublk_fixed_fd "${UBLK_BACKFILES[0]}" & ublk_io_and_kill_daemon 256M -t stripe -q 4 -z "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & +wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc & ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & + wait fi -wait _cleanup_test "stress" _show_result $TID $ERR_CODE
Signature · 1 line
2.45.2
Re: [PATCH 5/8] selftests: ublk: don't share backing files between ublk servers
Quoted 6 lines · Caleb Sander Mateos
stress_04is missing a wait between blocks of tests, meaning multiple ublk servers will be running in parallel using the same backing files. Add a wait after each section to ensure each backing file is in use by a single ublk server at a time.Signed-off-by Caleb Sander Mateos <[email protected]>
Thanks,
Ming
PATCH 6/8 selftests: ublk: forbid multiple data copy modes
In reply to Caleb Sander MateosThe kublk mock ublk server allows multiple data copy mode arguments to be passed on the command line (--zero_copy, --get_data, and --auto_zc). The ublk device will be created with all the requested feature flags, however kublk will only use one of the modes to interact with request data (arbitrarily preferring auto_zc over zero_copy over get_data). To clarify the intent of the test, don't allow multiple data copy modes to be specified. Don't set UBLK_F_USER_COPY for zero_copy, as it's an independent feature. Don't require zero_copy for auto_zc_fallback, as only auto_zc is needed. Fix the test cases passing multiple data copy mode arguments.
--- tools/testing/selftests/ublk/kublk.c | 21 ++++++++++++------- .../testing/selftests/ublk/test_generic_09.sh | 2 +- .../testing/selftests/ublk/test_stress_03.sh | 4 ++-- .../testing/selftests/ublk/test_stress_04.sh | 2 +- .../testing/selftests/ublk/test_stress_05.sh | 10 ++++----- 5 files changed, 22 insertions(+), 17 deletions(-)
tools/testing/selftests/ublk/kublk.c +13 -8
@@ -1611,11 +1611,11 @@ int main(int argc, char *argv[])break ;case 'd' : ctx.queue_depth =strtol (optarg,NULL ,10 );break ;case 'z' : - ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY |UBLK_F_USER_COPY ; + ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY ;break ;case 'r' : value =strtol (optarg,NULL ,10 );if (value) ctx.flags |=UBLK_F_USER_RECOVERY ;
@@ -1674,17 +1674,22 @@ int main(int argc, char *argv[]) optind +=1 ;break ; } } -/* auto_zc_fallback depends on F_AUTO_BUF_REG & F_SUPPORT_ZERO_COPY */ -if (ctx.auto_zc_fallback && - !((ctx.flags &UBLK_F_AUTO_BUF_REG ) && - (ctx.flags &UBLK_F_SUPPORT_ZERO_COPY ))) { -ublk_err ("%s: auto_zc_fallback is set but neither " -"F_AUTO_BUF_REG nor F_SUPPORT_ZERO_COPY is enabled\n" , - __func__); +/* auto_zc_fallback depends on F_AUTO_BUF_REG */ +if (ctx.auto_zc_fallback && !(ctx.flags &UBLK_F_AUTO_BUF_REG )) { +ublk_err ("%s: auto_zc_fallback is set but F_AUTO_BUF_REG is disabled\n" , + __func__); +return -EINVAL ; + } + +if (!!(ctx.flags &UBLK_F_SUPPORT_ZERO_COPY ) + + !!(ctx.flags &UBLK_F_NEED_GET_DATA ) + + !!(ctx.flags &UBLK_F_USER_COPY ) + + !!(ctx.flags &UBLK_F_AUTO_BUF_REG ) >1 ) { +fprintf (stderr,"too many data copy modes specified\n" );return -EINVAL ; } i = optind;while (i < argc && ctx.nr_files <MAX_BACK_FILES ) {
tools/testing/selftests/ublk/test_generic_09.sh +1 -1
@@ -14,11 +14,11 @@ if ! _have_program fio; then exit "$UBLK_SKIP_CODE" fi _prep_test "null" "basic IO test" -dev_id=$(_add_ublk_dev -t null -z --auto_zc --auto_zc_fallback) +dev_id=$(_add_ublk_dev -t null --auto_zc --auto_zc_fallback) _check_add_dev $TID $? # 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=$?
tools/testing/selftests/ublk/test_stress_03.sh +2 -2
@@ -36,19 +36,19 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc & ublk_io_and_remove 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & ublk_io_and_remove 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & wait fi _cleanup_test "stress" _show_result $TID $ERR_CODE
tools/testing/selftests/ublk/test_stress_04.sh +1 -1
@@ -35,11 +35,11 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc & ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks &
tools/testing/selftests/ublk/test_stress_05.sh +5 -5
@@ -56,21 +56,21 @@ for reissue in $(seq 0 1); do wait done if _have_feature "ZERO_COPY"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g -z -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 -z -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & wait done fi if _have_feature "AUTO_BUF_REG"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g --auto_zc -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & - ublk_io_and_remove 8G -t null -q 4 -g -z --auto_zc --auto_zc_fallback -r 1 -i "$reissue" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback -r 1 -i "$reissue" & wait done fi if _have_feature "PER_IO_DAEMON"; then
Signature · 1 line
2.45.2
Re: [PATCH 6/8] selftests: ublk: forbid multiple data copy modes
Quoted 54 lines · Caleb Sander Mateos
The kublk mock ublk server allows multiple data copy mode arguments to be passed on the command line (--zero_copy, --get_data, and --auto_zc). The ublk device will be created with all the requested feature flags, however kublk will only use one of the modes to interact with request data (arbitrarily preferring
auto_zcoverzero_copyoverget_data). To clarify the intent of the test, don't allow multiple data copy modes to be specified. Don't setUBLK_F_USER_COPYforzero_copy, as it's an independent feature. Don't requirezero_copyforauto_zc_fallback, as onlyauto_zcis needed. Fix the test cases passing multiple data copy mode arguments.Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/kublk.c | 21 ++++++++++++------- .../testing/selftests/ublk/test_generic_09.sh | 2 +- .../testing/selftests/ublk/test_stress_03.sh | 4 ++-- .../testing/selftests/ublk/test_stress_04.sh | 2 +- .../testing/selftests/ublk/test_stress_05.sh | 10 ++++----- 5 files changed, 22 insertions(+), 17 deletions(-)tools/testing/selftests/ublk/kublk.c +5
-8@@ -1611,11 +1611,11 @@ int main(int argc, char *argv[])break ;case 'd' : ctx.queue_depth =strtol (optarg,NULL ,10 );break ;case 'z' : - ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY |UBLK_F_USER_COPY ; + ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY ;break ;case 'r' : value =strtol (optarg,NULL ,10 );if (value) ctx.flags |=UBLK_F_USER_RECOVERY ;@@ -1674,17 +1674,22 @@ int main(int argc, char *argv[]) optind +=1 ;break ; } } -/* auto_zc_fallback depends on F_AUTO_BUF_REG & F_SUPPORT_ZERO_COPY */ -if (ctx.auto_zc_fallback && - !((ctx.flags &UBLK_F_AUTO_BUF_REG ) && - (ctx.flags &UBLK_F_SUPPORT_ZERO_COPY ))) { -ublk_err ("%s: auto_zc_fallback is set but neither " -"F_AUTO_BUF_REG nor F_SUPPORT_ZERO_COPY is enabled\n" , - __func__); +/* auto_zc_fallback depends on F_AUTO_BUF_REG */ +if (ctx.auto_zc_fallback && !(ctx.flags &UBLK_F_AUTO_BUF_REG )) { +ublk_err ("%s: auto_zc_fallback is set but F_AUTO_BUF_REG is disabled\n" , + __func__);
tools/testing/selftests/ublk/kublk.c int main(int argc, char *argv[]) · line 1692
Quoted 10 lines
tools/testing/selftests/ublk/kublk.c +8
-0+return -EINVAL ; + } + +if (!!(ctx.flags &UBLK_F_SUPPORT_ZERO_COPY ) + + !!(ctx.flags &UBLK_F_NEED_GET_DATA ) + + !!(ctx.flags &UBLK_F_USER_COPY ) + + !!(ctx.flags &UBLK_F_AUTO_BUF_REG ) >1 ) { +fprintf (stderr,"too many data copy modes specified\n" );return -EINVAL ; }
Actually most of them are allowed to co-exist, such as -z/--auto_zc/-u.
Quoted 79 lines
tools/testing/selftests/ublk/kublk.c +0
-0i = optind;while (i < argc && ctx.nr_files <MAX_BACK_FILES ) {tools/testing/selftests/ublk/test_generic_09.sh +1
-1@@ -14,11 +14,11 @@ if ! _have_program fio; then exit "$UBLK_SKIP_CODE" fi _prep_test "null" "basic IO test" -dev_id=$(_add_ublk_dev -t null -z --auto_zc --auto_zc_fallback) +dev_id=$(_add_ublk_dev -t null --auto_zc --auto_zc_fallback) _check_add_dev $TID $? # 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=$?tools/testing/selftests/ublk/test_stress_03.sh +2
-2@@ -36,19 +36,19 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc & ublk_io_and_remove 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & ublk_io_and_remove 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & wait fi _cleanup_test "stress" _show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_stress_04.sh +1
-1@@ -35,11 +35,11 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc & ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks &tools/testing/selftests/ublk/test_stress_05.sh +2
-2@@ -56,21 +56,21 @@ for reissue in $(seq 0 1); do wait done if _have_feature "ZERO_COPY"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g -z -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 -z -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & wait done
tools/testing/selftests/ublk/test_stress_05.sh for reissue in $(seq 0 1); do · line 71
Quoted 10 lines
tools/testing/selftests/ublk/test_stress_05.sh +3
-3fi if _have_feature "AUTO_BUF_REG"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g --auto_zc -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & - ublk_io_and_remove 8G -t null -q 4 -g -z --auto_zc --auto_zc_fallback -r 1 -i "$reissue" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback -r 1 -i "$reissue" &
--auto_zc_fallback requires both -z and --auto_zc.
Thanks,
Ming
Re: [PATCH 6/8] selftests: ublk: forbid multiple data copy modes
Quoted 60 lines · Ming Lei
Quoted 58 lines · Caleb Sander Mateos
The kublk mock ublk server allows multiple data copy mode arguments to be passed on the command line (--zero_copy, --get_data, and --auto_zc). The ublk device will be created with all the requested feature flags, however kublk will only use one of the modes to interact with request data (arbitrarily preferring
auto_zcoverzero_copyoverget_data). To clarify the intent of the test, don't allow multiple data copy modes to be specified. Don't setUBLK_F_USER_COPYforzero_copy, as it's an independent feature. Don't requirezero_copyforauto_zc_fallback, as onlyauto_zcis needed. Fix the test cases passing multiple data copy mode arguments.Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/kublk.c | 21 ++++++++++++------- .../testing/selftests/ublk/test_generic_09.sh | 2 +- .../testing/selftests/ublk/test_stress_03.sh | 4 ++-- .../testing/selftests/ublk/test_stress_04.sh | 2 +- .../testing/selftests/ublk/test_stress_05.sh | 10 ++++----- 5 files changed, 22 insertions(+), 17 deletions(-)tools/testing/selftests/ublk/kublk.c +9
-8@@ -1611,11 +1611,11 @@ int main(int argc, char *argv[])break ;case 'd' : ctx.queue_depth =strtol (optarg,NULL ,10 );break ;case 'z' : - ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY |UBLK_F_USER_COPY ; + ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY ;break ;case 'r' : value =strtol (optarg,NULL ,10 );if (value) ctx.flags |=UBLK_F_USER_RECOVERY ;@@ -1674,17 +1674,22 @@ int main(int argc, char *argv[]) optind +=1 ;break ; } } -/* auto_zc_fallback depends on F_AUTO_BUF_REG & F_SUPPORT_ZERO_COPY */ -if (ctx.auto_zc_fallback && - !((ctx.flags &UBLK_F_AUTO_BUF_REG ) && - (ctx.flags &UBLK_F_SUPPORT_ZERO_COPY ))) { -ublk_err ("%s: auto_zc_fallback is set but neither " -"F_AUTO_BUF_REG nor F_SUPPORT_ZERO_COPY is enabled\n" , - __func__); +/* auto_zc_fallback depends on F_AUTO_BUF_REG */ +if (ctx.auto_zc_fallback && !(ctx.flags &UBLK_F_AUTO_BUF_REG )) { +ublk_err ("%s: auto_zc_fallback is set but F_AUTO_BUF_REG is disabled\n" , + __func__); +return -EINVAL ; + } + + if (!!(ctx.flags & UBLK_F_SUPPORT_ZERO_COPY) +
Quoted 8 lines
tools/testing/selftests/ublk/kublk.c int main(int argc, char *argv[]) · line 1692
Quoted 6 lines
tools/testing/selftests/ublk/kublk.c +4
-0+ !!(ctx.flags & UBLK_F_NEED_GET_DATA) + + !!(ctx.flags & UBLK_F_USER_COPY) + + !!(ctx.flags & UBLK_F_AUTO_BUF_REG) > 1) { +fprintf (stderr,"too many data copy modes specified\n" );return -EINVAL ; }Actually most of them are allowed to co-exist, such as -z/--auto_zc/-u.
Yes, I know the ublk driver allows multiple copy mode flags to be set (though it will clear UBLK_F_NEED_GET_DATA if any of the others are set). However, kublk will only actually use one of the modes. For example, --get_data --zero_copy will use zero copy for the data transfer, not get data. And --zero_copy --auto_zc will only use auto buffer registration. So I think it's confusing to allow multiple of these parameters to be passed to kublk. Or do you think there is value in testing ublk device creation with multiple data copy mode flags set, but only one of the modes actually used?
Quoted 82 lines
Quoted 82 lines
tools/testing/selftests/ublk/kublk.c +0
-0i = optind;while (i < argc && ctx.nr_files <MAX_BACK_FILES ) {tools/testing/selftests/ublk/test_generic_09.sh +1
-1@@ -14,11 +14,11 @@ if ! _have_program fio; then exit "$UBLK_SKIP_CODE" fi _prep_test "null" "basic IO test" -dev_id=$(_add_ublk_dev -t null -z --auto_zc --auto_zc_fallback) +dev_id=$(_add_ublk_dev -t null --auto_zc --auto_zc_fallback) _check_add_dev $TID $? # 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=$?tools/testing/selftests/ublk/test_stress_03.sh +2
-2@@ -36,19 +36,19 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc & ublk_io_and_remove 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & ublk_io_and_remove 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & wait fi _cleanup_test "stress" _show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_stress_04.sh +1
-1@@ -35,11 +35,11 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc & ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks &tools/testing/selftests/ublk/test_stress_05.sh +2
-2@@ -56,21 +56,21 @@ for reissue in $(seq 0 1); do wait done if _have_feature "ZERO_COPY"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g -z -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 -z -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & wait done fi
Quoted 10 lines
tools/testing/selftests/ublk/test_stress_05.sh for reissue in $(seq 0 1); do · line 71
Quoted 8 lines
tools/testing/selftests/ublk/test_stress_05.sh +3
-3if _have_feature "AUTO_BUF_REG"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g --auto_zc -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & - ublk_io_and_remove 8G -t null -q 4 -g -z --auto_zc --auto_zc_fallback -r 1 -i "$reissue" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback -r 1 -i "$reissue" &--auto_zc_fallback requires both -z and --auto_zc.
Ah, right, I forgot that the fallback path relies on normal zero copy buffer registration. I guess we are missing coverage of that, then, since the tests still passed with --zero_copy disabled.
Thanks,
Caleb
Re: [PATCH 6/8] selftests: ublk: forbid multiple data copy modes
Quoted 173 lines · Caleb Sander Mateos
Quoted 60 lines · Ming Lei
Quoted 58 lines · Caleb Sander Mateos
The kublk mock ublk server allows multiple data copy mode arguments to be passed on the command line (--zero_copy, --get_data, and --auto_zc). The ublk device will be created with all the requested feature flags, however kublk will only use one of the modes to interact with request data (arbitrarily preferring
auto_zcoverzero_copyoverget_data). To clarify the intent of the test, don't allow multiple data copy modes to be specified. Don't setUBLK_F_USER_COPYforzero_copy, as it's an independent feature. Don't requirezero_copyforauto_zc_fallback, as onlyauto_zcis needed. Fix the test cases passing multiple data copy mode arguments.Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/kublk.c | 21 ++++++++++++------- .../testing/selftests/ublk/test_generic_09.sh | 2 +- .../testing/selftests/ublk/test_stress_03.sh | 4 ++-- .../testing/selftests/ublk/test_stress_04.sh | 2 +- .../testing/selftests/ublk/test_stress_05.sh | 10 ++++----- 5 files changed, 22 insertions(+), 17 deletions(-)tools/testing/selftests/ublk/kublk.c +9
-8@@ -1611,11 +1611,11 @@ int main(int argc, char *argv[])break ;case 'd' : ctx.queue_depth =strtol (optarg,NULL ,10 );break ;case 'z' : - ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY |UBLK_F_USER_COPY ; + ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY ;break ;case 'r' : value =strtol (optarg,NULL ,10 );if (value) ctx.flags |=UBLK_F_USER_RECOVERY ;@@ -1674,17 +1674,22 @@ int main(int argc, char *argv[]) optind +=1 ;break ; } } -/* auto_zc_fallback depends on F_AUTO_BUF_REG & F_SUPPORT_ZERO_COPY */ -if (ctx.auto_zc_fallback && - !((ctx.flags &UBLK_F_AUTO_BUF_REG ) && - (ctx.flags &UBLK_F_SUPPORT_ZERO_COPY ))) { -ublk_err ("%s: auto_zc_fallback is set but neither " -"F_AUTO_BUF_REG nor F_SUPPORT_ZERO_COPY is enabled\n" , - __func__); +/* auto_zc_fallback depends on F_AUTO_BUF_REG */ +if (ctx.auto_zc_fallback && !(ctx.flags &UBLK_F_AUTO_BUF_REG )) { +ublk_err ("%s: auto_zc_fallback is set but F_AUTO_BUF_REG is disabled\n" , + __func__); +return -EINVAL ; + } + + if (!!(ctx.flags & UBLK_F_SUPPORT_ZERO_COPY) +Quoted 8 lines
tools/testing/selftests/ublk/kublk.c int main(int argc, char *argv[]) · line 1692
Quoted 6 lines
tools/testing/selftests/ublk/kublk.c +4
-0+ !!(ctx.flags & UBLK_F_NEED_GET_DATA) + + !!(ctx.flags & UBLK_F_USER_COPY) + + !!(ctx.flags & UBLK_F_AUTO_BUF_REG) > 1) { +fprintf (stderr,"too many data copy modes specified\n" );return -EINVAL ; }Actually most of them are allowed to co-exist, such as -z/--auto_zc/-u.
Yes, I know the ublk driver allows multiple copy mode flags to be set (though it will clear
UBLK_F_NEED_GET_DATAif any of the others are set). However, kublk will only actually use one of the modes. For example, --get_data --zero_copy will use zero copy for the data transfer, not get data. And --zero_copy --auto_zc will only use auto buffer registration. So I think it's confusing to allow multiple of these parameters to be passed to kublk. Or do you think there is value in testing ublk device creation with multiple data copy mode flags set, but only one of the modes actually used?Quoted 82 lines
Quoted 82 lines
tools/testing/selftests/ublk/kublk.c +0
-0i = optind;while (i < argc && ctx.nr_files <MAX_BACK_FILES ) {tools/testing/selftests/ublk/test_generic_09.sh +1
-1@@ -14,11 +14,11 @@ if ! _have_program fio; then exit "$UBLK_SKIP_CODE" fi _prep_test "null" "basic IO test" -dev_id=$(_add_ublk_dev -t null -z --auto_zc --auto_zc_fallback) +dev_id=$(_add_ublk_dev -t null --auto_zc --auto_zc_fallback) _check_add_dev $TID $? # 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=$?tools/testing/selftests/ublk/test_stress_03.sh +2
-2@@ -36,19 +36,19 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc & ublk_io_and_remove 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & ublk_io_and_remove 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & wait fi _cleanup_test "stress" _show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_stress_04.sh +1
-1@@ -35,11 +35,11 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc & ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks &tools/testing/selftests/ublk/test_stress_05.sh +2
-2@@ -56,21 +56,21 @@ for reissue in $(seq 0 1); do wait done if _have_feature "ZERO_COPY"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g -z -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 -z -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & wait done fiQuoted 10 lines
tools/testing/selftests/ublk/test_stress_05.sh for reissue in $(seq 0 1); do · line 71
Quoted 8 lines
tools/testing/selftests/ublk/test_stress_05.sh +3
-3if _have_feature "AUTO_BUF_REG"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g --auto_zc -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & - ublk_io_and_remove 8G -t null -q 4 -g -z --auto_zc --auto_zc_fallback -r 1 -i "$reissue" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback -r 1 -i "$reissue" &--auto_zc_fallback requires both -z and --auto_zc.
Quoted 3 lines
Ah, right, I forgot that the fallback path relies on normal zero copy buffer registration. I guess we are missing coverage of that, then, since the tests still passed with --zero_copy disabled.
Looks one regression from commit 0a9beafa7c63 ("ublk: refactor auto buffer register in ublk_dispatch_req()")
Thanks,
Ming
Re: [PATCH 6/8] selftests: ublk: forbid multiple data copy modes
Quoted 175 lines · Ming Lei
Quoted 173 lines · Caleb Sander Mateos
Quoted 60 lines · Ming Lei
Quoted 58 lines · Caleb Sander Mateos
The kublk mock ublk server allows multiple data copy mode arguments to be passed on the command line (--zero_copy, --get_data, and --auto_zc). The ublk device will be created with all the requested feature flags, however kublk will only use one of the modes to interact with request data (arbitrarily preferring
auto_zcoverzero_copyoverget_data). To clarify the intent of the test, don't allow multiple data copy modes to be specified. Don't setUBLK_F_USER_COPYforzero_copy, as it's an independent feature. Don't requirezero_copyforauto_zc_fallback, as onlyauto_zcis needed. Fix the test cases passing multiple data copy mode arguments.Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/kublk.c | 21 ++++++++++++------- .../testing/selftests/ublk/test_generic_09.sh | 2 +- .../testing/selftests/ublk/test_stress_03.sh | 4 ++-- .../testing/selftests/ublk/test_stress_04.sh | 2 +- .../testing/selftests/ublk/test_stress_05.sh | 10 ++++----- 5 files changed, 22 insertions(+), 17 deletions(-)tools/testing/selftests/ublk/kublk.c +9
-8@@ -1611,11 +1611,11 @@ int main(int argc, char *argv[])break ;case 'd' : ctx.queue_depth =strtol (optarg,NULL ,10 );break ;case 'z' : - ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY |UBLK_F_USER_COPY ; + ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY ;break ;case 'r' : value =strtol (optarg,NULL ,10 );if (value) ctx.flags |=UBLK_F_USER_RECOVERY ;@@ -1674,17 +1674,22 @@ int main(int argc, char *argv[]) optind +=1 ;break ; } } -/* auto_zc_fallback depends on F_AUTO_BUF_REG & F_SUPPORT_ZERO_COPY */ -if (ctx.auto_zc_fallback && - !((ctx.flags &UBLK_F_AUTO_BUF_REG ) && - (ctx.flags &UBLK_F_SUPPORT_ZERO_COPY ))) { -ublk_err ("%s: auto_zc_fallback is set but neither " -"F_AUTO_BUF_REG nor F_SUPPORT_ZERO_COPY is enabled\n" , - __func__); +/* auto_zc_fallback depends on F_AUTO_BUF_REG */ +if (ctx.auto_zc_fallback && !(ctx.flags &UBLK_F_AUTO_BUF_REG )) { +ublk_err ("%s: auto_zc_fallback is set but F_AUTO_BUF_REG is disabled\n" , + __func__); +return -EINVAL ; + } + + if (!!(ctx.flags & UBLK_F_SUPPORT_ZERO_COPY) +Quoted 8 lines
tools/testing/selftests/ublk/kublk.c int main(int argc, char *argv[]) · line 1692
Quoted 6 lines
tools/testing/selftests/ublk/kublk.c +4
-0+ !!(ctx.flags & UBLK_F_NEED_GET_DATA) + + !!(ctx.flags & UBLK_F_USER_COPY) + + !!(ctx.flags & UBLK_F_AUTO_BUF_REG) > 1) { +fprintf (stderr,"too many data copy modes specified\n" );return -EINVAL ; }Actually most of them are allowed to co-exist, such as -z/--auto_zc/-u.
Yes, I know the ublk driver allows multiple copy mode flags to be set (though it will clear
UBLK_F_NEED_GET_DATAif any of the others are set). However, kublk will only actually use one of the modes. For example, --get_data --zero_copy will use zero copy for the data transfer, not get data. And --zero_copy --auto_zc will only use auto buffer registration. So I think it's confusing to allow multiple of these parameters to be passed to kublk. Or do you think there is value in testing ublk device creation with multiple data copy mode flags set, but only one of the modes actually used?Quoted 92 lines
Quoted 80 lines
tools/testing/selftests/ublk/kublk.c +0
-0i = optind;while (i < argc && ctx.nr_files <MAX_BACK_FILES ) {tools/testing/selftests/ublk/test_generic_09.sh +1
-1@@ -14,11 +14,11 @@ if ! _have_program fio; then exit "$UBLK_SKIP_CODE" fi _prep_test "null" "basic IO test" -dev_id=$(_add_ublk_dev -t null -z --auto_zc --auto_zc_fallback) +dev_id=$(_add_ublk_dev -t null --auto_zc --auto_zc_fallback) _check_add_dev $TID $? # 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=$?tools/testing/selftests/ublk/test_stress_03.sh +2
-2@@ -36,19 +36,19 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc & ublk_io_and_remove 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & ublk_io_and_remove 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & wait fi _cleanup_test "stress" _show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_stress_04.sh +1
-1@@ -35,11 +35,11 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc & ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks &tools/testing/selftests/ublk/test_stress_05.sh +2
-2@@ -56,21 +56,21 @@ for reissue in $(seq 0 1); do wait done if _have_feature "ZERO_COPY"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g -z -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 -z -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & wait donetools/testing/selftests/ublk/test_stress_05.sh for reissue in $(seq 0 1); do · line 71
Quoted 10 lines
tools/testing/selftests/ublk/test_stress_05.sh +3
-3fi if _have_feature "AUTO_BUF_REG"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g --auto_zc -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & - ublk_io_and_remove 8G -t null -q 4 -g -z --auto_zc --auto_zc_fallback -r 1 -i "$reissue" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback -r 1 -i "$reissue" &--auto_zc_fallback requires both -z and --auto_zc.
Quoted 5 lines
Quoted 3 lines
Ah, right, I forgot that the fallback path relies on normal zero copy buffer registration. I guess we are missing coverage of that, then, since the tests still passed with --zero_copy disabled.
Looks one regression from commit
0a9beafa7c63("ublk: refactor auto buffer register inublk_dispatch_req()")
Is there a particular issue you see in that commit? I think the issue is that if UBLK_IO_F_NEED_REG_BUF is set in the ublksrv_io_desc but zc isn't enabled, the null ublk server will just complete the I/O immediately. And --auto_zc_fallback isn't supported by any of the other ublk servers.
if (auto_zc && !ublk_io_auto_zc_fallback(iod))
queued = null_queue_auto_zc_io(t, q, tag);
else if (zc)
queued = null_queue_zc_io(t, q, tag);
else {
ublk_complete_io(t, q, tag, iod->nr_sectors << 9);
return 0;
}So it looks to me to just be an issue with my kublk change.
Thanks,
Caleb
Re: [PATCH 6/8] selftests: ublk: forbid multiple data copy modes
Quoted 176 lines · Caleb Sander Mateos
Quoted 175 lines · Ming Lei
Quoted 173 lines · Caleb Sander Mateos
Quoted 60 lines · Ming Lei
Quoted 58 lines · Caleb Sander Mateos
The kublk mock ublk server allows multiple data copy mode arguments to be passed on the command line (--zero_copy, --get_data, and --auto_zc). The ublk device will be created with all the requested feature flags, however kublk will only use one of the modes to interact with request data (arbitrarily preferring
auto_zcoverzero_copyoverget_data). To clarify the intent of the test, don't allow multiple data copy modes to be specified. Don't setUBLK_F_USER_COPYforzero_copy, as it's an independent feature. Don't requirezero_copyforauto_zc_fallback, as onlyauto_zcis needed. Fix the test cases passing multiple data copy mode arguments.Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/kublk.c | 21 ++++++++++++------- .../testing/selftests/ublk/test_generic_09.sh | 2 +- .../testing/selftests/ublk/test_stress_03.sh | 4 ++-- .../testing/selftests/ublk/test_stress_04.sh | 2 +- .../testing/selftests/ublk/test_stress_05.sh | 10 ++++----- 5 files changed, 22 insertions(+), 17 deletions(-)tools/testing/selftests/ublk/kublk.c +9
-8@@ -1611,11 +1611,11 @@ int main(int argc, char *argv[])break ;case 'd' : ctx.queue_depth =strtol (optarg,NULL ,10 );break ;case 'z' : - ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY |UBLK_F_USER_COPY ; + ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY ;break ;case 'r' : value =strtol (optarg,NULL ,10 );if (value) ctx.flags |=UBLK_F_USER_RECOVERY ;@@ -1674,17 +1674,22 @@ int main(int argc, char *argv[]) optind +=1 ;break ; } } -/* auto_zc_fallback depends on F_AUTO_BUF_REG & F_SUPPORT_ZERO_COPY */ -if (ctx.auto_zc_fallback && - !((ctx.flags &UBLK_F_AUTO_BUF_REG ) && - (ctx.flags &UBLK_F_SUPPORT_ZERO_COPY ))) { -ublk_err ("%s: auto_zc_fallback is set but neither " -"F_AUTO_BUF_REG nor F_SUPPORT_ZERO_COPY is enabled\n" , - __func__); +/* auto_zc_fallback depends on F_AUTO_BUF_REG */ +if (ctx.auto_zc_fallback && !(ctx.flags &UBLK_F_AUTO_BUF_REG )) { +ublk_err ("%s: auto_zc_fallback is set but F_AUTO_BUF_REG is disabled\n" , + __func__); +return -EINVAL ; + } + + if (!!(ctx.flags & UBLK_F_SUPPORT_ZERO_COPY) +Quoted 8 lines
tools/testing/selftests/ublk/kublk.c int main(int argc, char *argv[]) · line 1692
Quoted 6 lines
tools/testing/selftests/ublk/kublk.c +4
-0+ !!(ctx.flags & UBLK_F_NEED_GET_DATA) + + !!(ctx.flags & UBLK_F_USER_COPY) + + !!(ctx.flags & UBLK_F_AUTO_BUF_REG) > 1) { +fprintf (stderr,"too many data copy modes specified\n" );return -EINVAL ; }Actually most of them are allowed to co-exist, such as -z/--auto_zc/-u.
Yes, I know the ublk driver allows multiple copy mode flags to be set (though it will clear
UBLK_F_NEED_GET_DATAif any of the others are set). However, kublk will only actually use one of the modes. For example, --get_data --zero_copy will use zero copy for the data transfer, not get data. And --zero_copy --auto_zc will only use auto buffer registration. So I think it's confusing to allow multiple of these parameters to be passed to kublk. Or do you think there is value in testing ublk device creation with multiple data copy mode flags set, but only one of the modes actually used?Quoted 92 lines
Quoted 80 lines
tools/testing/selftests/ublk/kublk.c +0
-0i = optind;while (i < argc && ctx.nr_files <MAX_BACK_FILES ) {tools/testing/selftests/ublk/test_generic_09.sh +1
-1@@ -14,11 +14,11 @@ if ! _have_program fio; then exit "$UBLK_SKIP_CODE" fi _prep_test "null" "basic IO test" -dev_id=$(_add_ublk_dev -t null -z --auto_zc --auto_zc_fallback) +dev_id=$(_add_ublk_dev -t null --auto_zc --auto_zc_fallback) _check_add_dev $TID $? # 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=$?tools/testing/selftests/ublk/test_stress_03.sh +2
-2@@ -36,19 +36,19 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc & ublk_io_and_remove 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & ublk_io_and_remove 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & wait fi _cleanup_test "stress" _show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_stress_04.sh +1
-1@@ -35,11 +35,11 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc & ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks &tools/testing/selftests/ublk/test_stress_05.sh +2
-2@@ -56,21 +56,21 @@ for reissue in $(seq 0 1); do wait done if _have_feature "ZERO_COPY"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g -z -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 -z -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & wait donetools/testing/selftests/ublk/test_stress_05.sh for reissue in $(seq 0 1); do · line 71
Quoted 10 lines
tools/testing/selftests/ublk/test_stress_05.sh +3
-3fi if _have_feature "AUTO_BUF_REG"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g --auto_zc -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & - ublk_io_and_remove 8G -t null -q 4 -g -z --auto_zc --auto_zc_fallback -r 1 -i "$reissue" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback -r 1 -i "$reissue" &--auto_zc_fallback requires both -z and --auto_zc.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Ah, right, I forgot that the fallback path relies on normal zero copy buffer registration. I guess we are missing coverage of that, then, since the tests still passed with --zero_copy disabled.
Looks one regression from commit
0a9beafa7c63("ublk: refactor auto buffer register inublk_dispatch_req()")Is there a particular issue you see in that commit? I think the issue
Looks I overlooked.
Quoted 14 lines
is that if
UBLK_IO_F_NEED_REG_BUFis set in theublksrv_io_descbut zc isn't enabled, the null ublk server will just complete the I/O immediately. And --auto_zc_fallback isn't supported by any of the other ublk servers.if (
auto_zc&& !ublk_io_auto_zc_fallback(iod))queued = null_queue_auto_zc_io(t, q, tag); else if (zc) queued = null_queue_zc_io(t, q, tag); else { ublk_complete_io(t, q, tag, iod->nr_sectors << 9); return 0; }
Quoted 1 line
So it looks to me to just be an issue with my kublk change.
But ublk_queue_auto_zc_fallback() is broken, so the auto_zc_fallback code path isn't examined actually.
Thanks,
Ming
Re: [PATCH 6/8] selftests: ublk: forbid multiple data copy modes
Quoted 202 lines · Ming Lei
Quoted 176 lines · Caleb Sander Mateos
Quoted 175 lines · Ming Lei
Quoted 173 lines · Caleb Sander Mateos
Quoted 60 lines · Ming Lei
Quoted 58 lines · Caleb Sander Mateos
The kublk mock ublk server allows multiple data copy mode arguments to be passed on the command line (--zero_copy, --get_data, and --auto_zc). The ublk device will be created with all the requested feature flags, however kublk will only use one of the modes to interact with request data (arbitrarily preferring
auto_zcoverzero_copyoverget_data). To clarify the intent of the test, don't allow multiple data copy modes to be specified. Don't setUBLK_F_USER_COPYforzero_copy, as it's an independent feature. Don't requirezero_copyforauto_zc_fallback, as onlyauto_zcis needed. Fix the test cases passing multiple data copy mode arguments.Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/kublk.c | 21 ++++++++++++------- .../testing/selftests/ublk/test_generic_09.sh | 2 +- .../testing/selftests/ublk/test_stress_03.sh | 4 ++-- .../testing/selftests/ublk/test_stress_04.sh | 2 +- .../testing/selftests/ublk/test_stress_05.sh | 10 ++++----- 5 files changed, 22 insertions(+), 17 deletions(-)tools/testing/selftests/ublk/kublk.c +9
-8@@ -1611,11 +1611,11 @@ int main(int argc, char *argv[])break ;case 'd' : ctx.queue_depth =strtol (optarg,NULL ,10 );break ;case 'z' : - ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY |UBLK_F_USER_COPY ; + ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY ;break ;case 'r' : value =strtol (optarg,NULL ,10 );if (value) ctx.flags |=UBLK_F_USER_RECOVERY ;@@ -1674,17 +1674,22 @@ int main(int argc, char *argv[]) optind +=1 ;break ; } } -/* auto_zc_fallback depends on F_AUTO_BUF_REG & F_SUPPORT_ZERO_COPY */ -if (ctx.auto_zc_fallback && - !((ctx.flags &UBLK_F_AUTO_BUF_REG ) && - (ctx.flags &UBLK_F_SUPPORT_ZERO_COPY ))) { -ublk_err ("%s: auto_zc_fallback is set but neither " -"F_AUTO_BUF_REG nor F_SUPPORT_ZERO_COPY is enabled\n" , - __func__); +/* auto_zc_fallback depends on F_AUTO_BUF_REG */ +if (ctx.auto_zc_fallback && !(ctx.flags &UBLK_F_AUTO_BUF_REG )) { +ublk_err ("%s: auto_zc_fallback is set but F_AUTO_BUF_REG is disabled\n" , + __func__); +return -EINVAL ; + } + + if (!!(ctx.flags & UBLK_F_SUPPORT_ZERO_COPY) +Quoted 8 lines
tools/testing/selftests/ublk/kublk.c int main(int argc, char *argv[]) · line 1692
Quoted 6 lines
tools/testing/selftests/ublk/kublk.c +4
-0+ !!(ctx.flags & UBLK_F_NEED_GET_DATA) + + !!(ctx.flags & UBLK_F_USER_COPY) + + !!(ctx.flags & UBLK_F_AUTO_BUF_REG) > 1) { +fprintf (stderr,"too many data copy modes specified\n" );return -EINVAL ; }Actually most of them are allowed to co-exist, such as -z/--auto_zc/-u.
Yes, I know the ublk driver allows multiple copy mode flags to be set (though it will clear
UBLK_F_NEED_GET_DATAif any of the others are set). However, kublk will only actually use one of the modes. For example, --get_data --zero_copy will use zero copy for the data transfer, not get data. And --zero_copy --auto_zc will only use auto buffer registration. So I think it's confusing to allow multiple of these parameters to be passed to kublk. Or do you think there is value in testing ublk device creation with multiple data copy mode flags set, but only one of the modes actually used?Quoted 92 lines
Quoted 80 lines
tools/testing/selftests/ublk/kublk.c +0
-0i = optind;while (i < argc && ctx.nr_files <MAX_BACK_FILES ) {tools/testing/selftests/ublk/test_generic_09.sh +1
-1@@ -14,11 +14,11 @@ if ! _have_program fio; then exit "$UBLK_SKIP_CODE" fi _prep_test "null" "basic IO test" -dev_id=$(_add_ublk_dev -t null -z --auto_zc --auto_zc_fallback) +dev_id=$(_add_ublk_dev -t null --auto_zc --auto_zc_fallback) _check_add_dev $TID $? # 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=$?tools/testing/selftests/ublk/test_stress_03.sh +2
-2@@ -36,19 +36,19 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc & ublk_io_and_remove 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & ublk_io_and_remove 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & wait fi _cleanup_test "stress" _show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_stress_04.sh +1
-1@@ -35,11 +35,11 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc & ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks &tools/testing/selftests/ublk/test_stress_05.sh +2
-2@@ -56,21 +56,21 @@ for reissue in $(seq 0 1); do wait done if _have_feature "ZERO_COPY"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g -z -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 -z -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & wait donetools/testing/selftests/ublk/test_stress_05.sh for reissue in $(seq 0 1); do · line 71
Quoted 10 lines
tools/testing/selftests/ublk/test_stress_05.sh +3
-3fi if _have_feature "AUTO_BUF_REG"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g --auto_zc -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & - ublk_io_and_remove 8G -t null -q 4 -g -z --auto_zc --auto_zc_fallback -r 1 -i "$reissue" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback -r 1 -i "$reissue" &--auto_zc_fallback requires both -z and --auto_zc.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Ah, right, I forgot that the fallback path relies on normal zero copy buffer registration. I guess we are missing coverage of that, then, since the tests still passed with --zero_copy disabled.
Looks one regression from commit
0a9beafa7c63("ublk: refactor auto buffer register inublk_dispatch_req()")Is there a particular issue you see in that commit? I think the issue
Looks I overlooked.
Quoted 14 lines
is that if
UBLK_IO_F_NEED_REG_BUFis set in theublksrv_io_descbut zc isn't enabled, the null ublk server will just complete the I/O immediately. And --auto_zc_fallback isn't supported by any of the other ublk servers.if (
auto_zc&& !ublk_io_auto_zc_fallback(iod))queued = null_queue_auto_zc_io(t, q, tag); else if (zc) queued = null_queue_zc_io(t, q, tag); else { ublk_complete_io(t, q, tag, iod->nr_sectors << 9); return 0; }
Quoted 4 lines
Quoted 1 line
So it looks to me to just be an issue with my kublk change.
But
ublk_queue_auto_zc_fallback()is broken, so theauto_zc_fallbackcode path isn't examined actually.
How is it broken?
Re: [PATCH 6/8] selftests: ublk: forbid multiple data copy modes
Quoted 203 lines · Caleb Sander Mateos
Quoted 202 lines · Ming Lei
Quoted 176 lines · Caleb Sander Mateos
Quoted 175 lines · Ming Lei
Quoted 173 lines · Caleb Sander Mateos
Quoted 60 lines · Ming Lei
Quoted 58 lines · Caleb Sander Mateos
The kublk mock ublk server allows multiple data copy mode arguments to be passed on the command line (--zero_copy, --get_data, and --auto_zc). The ublk device will be created with all the requested feature flags, however kublk will only use one of the modes to interact with request data (arbitrarily preferring
auto_zcoverzero_copyoverget_data). To clarify the intent of the test, don't allow multiple data copy modes to be specified. Don't setUBLK_F_USER_COPYforzero_copy, as it's an independent feature. Don't requirezero_copyforauto_zc_fallback, as onlyauto_zcis needed. Fix the test cases passing multiple data copy mode arguments.Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/kublk.c | 21 ++++++++++++------- .../testing/selftests/ublk/test_generic_09.sh | 2 +- .../testing/selftests/ublk/test_stress_03.sh | 4 ++-- .../testing/selftests/ublk/test_stress_04.sh | 2 +- .../testing/selftests/ublk/test_stress_05.sh | 10 ++++----- 5 files changed, 22 insertions(+), 17 deletions(-)tools/testing/selftests/ublk/kublk.c +9
-8@@ -1611,11 +1611,11 @@ int main(int argc, char *argv[])break ;case 'd' : ctx.queue_depth =strtol (optarg,NULL ,10 );break ;case 'z' : - ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY |UBLK_F_USER_COPY ; + ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY ;break ;case 'r' : value =strtol (optarg,NULL ,10 );if (value) ctx.flags |=UBLK_F_USER_RECOVERY ;@@ -1674,17 +1674,22 @@ int main(int argc, char *argv[]) optind +=1 ;break ; } } -/* auto_zc_fallback depends on F_AUTO_BUF_REG & F_SUPPORT_ZERO_COPY */ -if (ctx.auto_zc_fallback && - !((ctx.flags &UBLK_F_AUTO_BUF_REG ) && - (ctx.flags &UBLK_F_SUPPORT_ZERO_COPY ))) { -ublk_err ("%s: auto_zc_fallback is set but neither " -"F_AUTO_BUF_REG nor F_SUPPORT_ZERO_COPY is enabled\n" , - __func__); +/* auto_zc_fallback depends on F_AUTO_BUF_REG */ +if (ctx.auto_zc_fallback && !(ctx.flags &UBLK_F_AUTO_BUF_REG )) { +ublk_err ("%s: auto_zc_fallback is set but F_AUTO_BUF_REG is disabled\n" , + __func__); +return -EINVAL ; + } + + if (!!(ctx.flags & UBLK_F_SUPPORT_ZERO_COPY) +Quoted 8 lines
tools/testing/selftests/ublk/kublk.c int main(int argc, char *argv[]) · line 1692
Quoted 6 lines
tools/testing/selftests/ublk/kublk.c +4
-0+ !!(ctx.flags & UBLK_F_NEED_GET_DATA) + + !!(ctx.flags & UBLK_F_USER_COPY) + + !!(ctx.flags & UBLK_F_AUTO_BUF_REG) > 1) { +fprintf (stderr,"too many data copy modes specified\n" );return -EINVAL ; }Actually most of them are allowed to co-exist, such as -z/--auto_zc/-u.
Yes, I know the ublk driver allows multiple copy mode flags to be set (though it will clear
UBLK_F_NEED_GET_DATAif any of the others are set). However, kublk will only actually use one of the modes. For example, --get_data --zero_copy will use zero copy for the data transfer, not get data. And --zero_copy --auto_zc will only use auto buffer registration. So I think it's confusing to allow multiple of these parameters to be passed to kublk. Or do you think there is value in testing ublk device creation with multiple data copy mode flags set, but only one of the modes actually used?Quoted 92 lines
Quoted 80 lines
tools/testing/selftests/ublk/kublk.c +0
-0i = optind;while (i < argc && ctx.nr_files <MAX_BACK_FILES ) {tools/testing/selftests/ublk/test_generic_09.sh +1
-1@@ -14,11 +14,11 @@ if ! _have_program fio; then exit "$UBLK_SKIP_CODE" fi _prep_test "null" "basic IO test" -dev_id=$(_add_ublk_dev -t null -z --auto_zc --auto_zc_fallback) +dev_id=$(_add_ublk_dev -t null --auto_zc --auto_zc_fallback) _check_add_dev $TID $? # 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=$?tools/testing/selftests/ublk/test_stress_03.sh +2
-2@@ -36,19 +36,19 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc & ublk_io_and_remove 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & ublk_io_and_remove 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & wait fi _cleanup_test "stress" _show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_stress_04.sh +1
-1@@ -35,11 +35,11 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc & ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks &tools/testing/selftests/ublk/test_stress_05.sh +2
-2@@ -56,21 +56,21 @@ for reissue in $(seq 0 1); do wait done if _have_feature "ZERO_COPY"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g -z -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 -z -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & wait donetools/testing/selftests/ublk/test_stress_05.sh for reissue in $(seq 0 1); do · line 71
Quoted 10 lines
tools/testing/selftests/ublk/test_stress_05.sh +3
-3fi if _have_feature "AUTO_BUF_REG"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g --auto_zc -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & - ublk_io_and_remove 8G -t null -q 4 -g -z --auto_zc --auto_zc_fallback -r 1 -i "$reissue" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback -r 1 -i "$reissue" &--auto_zc_fallback requires both -z and --auto_zc.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Ah, right, I forgot that the fallback path relies on normal zero copy buffer registration. I guess we are missing coverage of that, then, since the tests still passed with --zero_copy disabled.
Looks one regression from commit
0a9beafa7c63("ublk: refactor auto buffer register inublk_dispatch_req()")Is there a particular issue you see in that commit? I think the issue
Looks I overlooked.
Quoted 14 lines
is that if
UBLK_IO_F_NEED_REG_BUFis set in theublksrv_io_descbut zc isn't enabled, the null ublk server will just complete the I/O immediately. And --auto_zc_fallback isn't supported by any of the other ublk servers.if (
auto_zc&& !ublk_io_auto_zc_fallback(iod))queued = null_queue_auto_zc_io(t, q, tag); else if (zc) queued = null_queue_zc_io(t, q, tag); else { ublk_complete_io(t, q, tag, iod->nr_sectors << 9); return 0; }
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
So it looks to me to just be an issue with my kublk change.
But
ublk_queue_auto_zc_fallback()is broken, so theauto_zc_fallbackcode path isn't examined actually.How is it broken?
typeof(q->flags) is u64, but the return type is i32, so it is overflowed.
Thanks,
Ming
Re: [PATCH 6/8] selftests: ublk: forbid multiple data copy modes
Quoted 205 lines · Ming Lei
Quoted 203 lines · Caleb Sander Mateos
Quoted 202 lines · Ming Lei
Quoted 176 lines · Caleb Sander Mateos
Quoted 175 lines · Ming Lei
Quoted 173 lines · Caleb Sander Mateos
Quoted 60 lines · Ming Lei
Quoted 58 lines · Caleb Sander Mateos
The kublk mock ublk server allows multiple data copy mode arguments to be passed on the command line (--zero_copy, --get_data, and --auto_zc). The ublk device will be created with all the requested feature flags, however kublk will only use one of the modes to interact with request data (arbitrarily preferring
auto_zcoverzero_copyoverget_data). To clarify the intent of the test, don't allow multiple data copy modes to be specified. Don't setUBLK_F_USER_COPYforzero_copy, as it's an independent feature. Don't requirezero_copyforauto_zc_fallback, as onlyauto_zcis needed. Fix the test cases passing multiple data copy mode arguments.Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/kublk.c | 21 ++++++++++++------- .../testing/selftests/ublk/test_generic_09.sh | 2 +- .../testing/selftests/ublk/test_stress_03.sh | 4 ++-- .../testing/selftests/ublk/test_stress_04.sh | 2 +- .../testing/selftests/ublk/test_stress_05.sh | 10 ++++----- 5 files changed, 22 insertions(+), 17 deletions(-)tools/testing/selftests/ublk/kublk.c +9
-8@@ -1611,11 +1611,11 @@ int main(int argc, char *argv[])break ;case 'd' : ctx.queue_depth =strtol (optarg,NULL ,10 );break ;case 'z' : - ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY |UBLK_F_USER_COPY ; + ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY ;break ;case 'r' : value =strtol (optarg,NULL ,10 );if (value) ctx.flags |=UBLK_F_USER_RECOVERY ;@@ -1674,17 +1674,22 @@ int main(int argc, char *argv[]) optind +=1 ;break ; } } -/* auto_zc_fallback depends on F_AUTO_BUF_REG & F_SUPPORT_ZERO_COPY */ -if (ctx.auto_zc_fallback && - !((ctx.flags &UBLK_F_AUTO_BUF_REG ) && - (ctx.flags &UBLK_F_SUPPORT_ZERO_COPY ))) { -ublk_err ("%s: auto_zc_fallback is set but neither " -"F_AUTO_BUF_REG nor F_SUPPORT_ZERO_COPY is enabled\n" , - __func__); +/* auto_zc_fallback depends on F_AUTO_BUF_REG */ +if (ctx.auto_zc_fallback && !(ctx.flags &UBLK_F_AUTO_BUF_REG )) { +ublk_err ("%s: auto_zc_fallback is set but F_AUTO_BUF_REG is disabled\n" , + __func__); +return -EINVAL ; + } + + if (!!(ctx.flags & UBLK_F_SUPPORT_ZERO_COPY) +Quoted 8 lines
tools/testing/selftests/ublk/kublk.c int main(int argc, char *argv[]) · line 1692
Quoted 6 lines
tools/testing/selftests/ublk/kublk.c +4
-0+ !!(ctx.flags & UBLK_F_NEED_GET_DATA) + + !!(ctx.flags & UBLK_F_USER_COPY) + + !!(ctx.flags & UBLK_F_AUTO_BUF_REG) > 1) { +fprintf (stderr,"too many data copy modes specified\n" );return -EINVAL ; }Actually most of them are allowed to co-exist, such as -z/--auto_zc/-u.
Yes, I know the ublk driver allows multiple copy mode flags to be set (though it will clear
UBLK_F_NEED_GET_DATAif any of the others are set). However, kublk will only actually use one of the modes. For example, --get_data --zero_copy will use zero copy for the data transfer, not get data. And --zero_copy --auto_zc will only use auto buffer registration. So I think it's confusing to allow multiple of these parameters to be passed to kublk. Or do you think there is value in testing ublk device creation with multiple data copy mode flags set, but only one of the modes actually used?Quoted 92 lines
Quoted 80 lines
tools/testing/selftests/ublk/kublk.c +0
-0i = optind;while (i < argc && ctx.nr_files <MAX_BACK_FILES ) {tools/testing/selftests/ublk/test_generic_09.sh +1
-1@@ -14,11 +14,11 @@ if ! _have_program fio; then exit "$UBLK_SKIP_CODE" fi _prep_test "null" "basic IO test" -dev_id=$(_add_ublk_dev -t null -z --auto_zc --auto_zc_fallback) +dev_id=$(_add_ublk_dev -t null --auto_zc --auto_zc_fallback) _check_add_dev $TID $? # 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=$?tools/testing/selftests/ublk/test_stress_03.sh +2
-2@@ -36,19 +36,19 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc & ublk_io_and_remove 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & ublk_io_and_remove 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & wait fi _cleanup_test "stress" _show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_stress_04.sh +1
-1@@ -35,11 +35,11 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc & ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks &tools/testing/selftests/ublk/test_stress_05.sh +2
-2@@ -56,21 +56,21 @@ for reissue in $(seq 0 1); do wait done if _have_feature "ZERO_COPY"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g -z -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 -z -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & wait donetools/testing/selftests/ublk/test_stress_05.sh for reissue in $(seq 0 1); do · line 71
Quoted 10 lines
tools/testing/selftests/ublk/test_stress_05.sh +3
-3fi if _have_feature "AUTO_BUF_REG"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g --auto_zc -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & - ublk_io_and_remove 8G -t null -q 4 -g -z --auto_zc --auto_zc_fallback -r 1 -i "$reissue" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback -r 1 -i "$reissue" &--auto_zc_fallback requires both -z and --auto_zc.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Ah, right, I forgot that the fallback path relies on normal zero copy buffer registration. I guess we are missing coverage of that, then, since the tests still passed with --zero_copy disabled.
Looks one regression from commit
0a9beafa7c63("ublk: refactor auto buffer register inublk_dispatch_req()")Is there a particular issue you see in that commit? I think the issue
Looks I overlooked.
Quoted 14 lines
is that if
UBLK_IO_F_NEED_REG_BUFis set in theublksrv_io_descbut zc isn't enabled, the null ublk server will just complete the I/O immediately. And --auto_zc_fallback isn't supported by any of the other ublk servers.if (
auto_zc&& !ublk_io_auto_zc_fallback(iod))queued = null_queue_auto_zc_io(t, q, tag); else if (zc) queued = null_queue_zc_io(t, q, tag); else { ublk_complete_io(t, q, tag, iod->nr_sectors << 9); return 0; }
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
So it looks to me to just be an issue with my kublk change.
But
ublk_queue_auto_zc_fallback()is broken, so theauto_zc_fallbackcode path isn't examined actually.How is it broken?
typeof(q->flags)is u64, but the return type is i32, so it is overflowed.
Ah, good catch. Yeah, these ublk_queue flag query functions should probably return bool. Are you going to send out a patch?
Thanks,
Caleb
Re: [PATCH 6/8] selftests: ublk: forbid multiple data copy modes
Quoted 211 lines · Caleb Sander Mateos
Quoted 210 lines · Ming Lei
Quoted 208 lines · Caleb Sander Mateos
Quoted 206 lines · Ming Lei
Quoted 176 lines · Caleb Sander Mateos
Quoted 175 lines · Ming Lei
Quoted 173 lines · Caleb Sander Mateos
Quoted 60 lines · Ming Lei
Quoted 58 lines · Caleb Sander Mateos
The kublk mock ublk server allows multiple data copy mode arguments to be passed on the command line (--zero_copy, --get_data, and --auto_zc). The ublk device will be created with all the requested feature flags, however kublk will only use one of the modes to interact with request data (arbitrarily preferring
auto_zcoverzero_copyoverget_data). To clarify the intent of the test, don't allow multiple data copy modes to be specified. Don't setUBLK_F_USER_COPYforzero_copy, as it's an independent feature. Don't requirezero_copyforauto_zc_fallback, as onlyauto_zcis needed. Fix the test cases passing multiple data copy mode arguments.Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/kublk.c | 21 ++++++++++++------- .../testing/selftests/ublk/test_generic_09.sh | 2 +- .../testing/selftests/ublk/test_stress_03.sh | 4 ++-- .../testing/selftests/ublk/test_stress_04.sh | 2 +- .../testing/selftests/ublk/test_stress_05.sh | 10 ++++----- 5 files changed, 22 insertions(+), 17 deletions(-)tools/testing/selftests/ublk/kublk.c +9
-8@@ -1611,11 +1611,11 @@ int main(int argc, char *argv[])break ;case 'd' : ctx.queue_depth =strtol (optarg,NULL ,10 );break ;case 'z' : - ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY |UBLK_F_USER_COPY ; + ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY ;break ;case 'r' : value =strtol (optarg,NULL ,10 );if (value) ctx.flags |=UBLK_F_USER_RECOVERY ;@@ -1674,17 +1674,22 @@ int main(int argc, char *argv[]) optind +=1 ;break ; } } -/* auto_zc_fallback depends on F_AUTO_BUF_REG & F_SUPPORT_ZERO_COPY */ -if (ctx.auto_zc_fallback && - !((ctx.flags &UBLK_F_AUTO_BUF_REG ) && - (ctx.flags &UBLK_F_SUPPORT_ZERO_COPY ))) { -ublk_err ("%s: auto_zc_fallback is set but neither " -"F_AUTO_BUF_REG nor F_SUPPORT_ZERO_COPY is enabled\n" , - __func__); +/* auto_zc_fallback depends on F_AUTO_BUF_REG */ +if (ctx.auto_zc_fallback && !(ctx.flags &UBLK_F_AUTO_BUF_REG )) { +ublk_err ("%s: auto_zc_fallback is set but F_AUTO_BUF_REG is disabled\n" , + __func__); +return -EINVAL ; + } + + if (!!(ctx.flags & UBLK_F_SUPPORT_ZERO_COPY) +Quoted 8 lines
tools/testing/selftests/ublk/kublk.c int main(int argc, char *argv[]) · line 1692
Quoted 6 lines
tools/testing/selftests/ublk/kublk.c +4
-0+ !!(ctx.flags & UBLK_F_NEED_GET_DATA) + + !!(ctx.flags & UBLK_F_USER_COPY) + + !!(ctx.flags & UBLK_F_AUTO_BUF_REG) > 1) { +fprintf (stderr,"too many data copy modes specified\n" );return -EINVAL ; }Actually most of them are allowed to co-exist, such as -z/--auto_zc/-u.
Yes, I know the ublk driver allows multiple copy mode flags to be set (though it will clear
UBLK_F_NEED_GET_DATAif any of the others are set). However, kublk will only actually use one of the modes. For example, --get_data --zero_copy will use zero copy for the data transfer, not get data. And --zero_copy --auto_zc will only use auto buffer registration. So I think it's confusing to allow multiple of these parameters to be passed to kublk. Or do you think there is value in testing ublk device creation with multiple data copy mode flags set, but only one of the modes actually used?Quoted 92 lines
Quoted 80 lines
tools/testing/selftests/ublk/kublk.c +0
-0i = optind;while (i < argc && ctx.nr_files <MAX_BACK_FILES ) {tools/testing/selftests/ublk/test_generic_09.sh +1
-1@@ -14,11 +14,11 @@ if ! _have_program fio; then exit "$UBLK_SKIP_CODE" fi _prep_test "null" "basic IO test" -dev_id=$(_add_ublk_dev -t null -z --auto_zc --auto_zc_fallback) +dev_id=$(_add_ublk_dev -t null --auto_zc --auto_zc_fallback) _check_add_dev $TID $? # 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=$?tools/testing/selftests/ublk/test_stress_03.sh +2
-2@@ -36,19 +36,19 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc & ublk_io_and_remove 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & ublk_io_and_remove 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & wait fi _cleanup_test "stress" _show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_stress_04.sh +1
-1@@ -35,11 +35,11 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc & ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks &tools/testing/selftests/ublk/test_stress_05.sh +2
-2@@ -56,21 +56,21 @@ for reissue in $(seq 0 1); do wait done if _have_feature "ZERO_COPY"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g -z -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 -z -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & wait donetools/testing/selftests/ublk/test_stress_05.sh for reissue in $(seq 0 1); do · line 71
Quoted 10 lines
tools/testing/selftests/ublk/test_stress_05.sh +3
-3fi if _have_feature "AUTO_BUF_REG"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g --auto_zc -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & - ublk_io_and_remove 8G -t null -q 4 -g -z --auto_zc --auto_zc_fallback -r 1 -i "$reissue" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback -r 1 -i "$reissue" &--auto_zc_fallback requires both -z and --auto_zc.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Ah, right, I forgot that the fallback path relies on normal zero copy buffer registration. I guess we are missing coverage of that, then, since the tests still passed with --zero_copy disabled.
Looks one regression from commit
0a9beafa7c63("ublk: refactor auto buffer register inublk_dispatch_req()")Is there a particular issue you see in that commit? I think the issue
Looks I overlooked.
Quoted 14 lines
is that if
UBLK_IO_F_NEED_REG_BUFis set in theublksrv_io_descbut zc isn't enabled, the null ublk server will just complete the I/O immediately. And --auto_zc_fallback isn't supported by any of the other ublk servers.if (
auto_zc&& !ublk_io_auto_zc_fallback(iod))queued = null_queue_auto_zc_io(t, q, tag); else if (zc) queued = null_queue_zc_io(t, q, tag); else { ublk_complete_io(t, q, tag, iod->nr_sectors << 9); return 0; }Quoted 1 line
So it looks to me to just be an issue with my kublk change.
But
ublk_queue_auto_zc_fallback()is broken, so theauto_zc_fallbackcode path isn't examined actually.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
How is it broken?
typeof(q->flags)is u64, but the return type is i32, so it is overflowed.Ah, good catch. Yeah, these
ublk_queueflag query functions should probably return bool. Are you going to send out a patch?
I guess you may have to send V3 for fixing patch 4, I appreciate you may include the following fix in your V3, otherwise it may conflict with the added ublk_queue_use_user_copy().
From 62da81c7a9883dc251cc0daa2a3081226abc5da1 Mon Sep 17 00:00:00 2001
From: Ming Lei <[email protected]>
Date: Fri, 12 Dec 2025 11:23:56 +0000
Subject: [PATCH] selftests: ublk: fix overflow in
ublk_queue_auto_zc_fallback()
The functions ublk_queue_use_zc(), ublk_queue_use_auto_zc(), and ublk_queue_auto_zc_fallback() were returning int, but performing bitwise AND on q->flags which is __u64.
When a flag bit is set in the upper 32 bits (beyond INT_MAX), the result of the bitwise AND operation could overflow when cast to int, leading to incorrect boolean evaluation.
For example, if UBLKS_Q_AUTO_BUF_REG_FALLBACK is 0x8000000000000000:
- (u64)flags & 0x8000000000000000 = 0x8000000000000000
- Cast to int: undefined behavior / incorrect value
- Used in if(): may evaluate incorrectly
Fix by:
1. Changing return type from int to bool for semantic correctness
2. Using !! to explicitly convert to boolean (0 or 1)
This ensures the functions return proper boolean values regardless of which bit position the flags occupy in the 64-bit field.
--- tools/testing/selftests/ublk/kublk.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/ublk/kublk.h +6 -6
@@ -396,19 +396,19 @@ static inline int ublk_completed_tgt_io(struct ublk_thread *t,return --io->tgt_ios ==0 ; } -static inline int ublk_queue_use_zc (const struct ublk_queue *q) +static inline bool ublk_queue_use_zc (const struct ublk_queue *q) { -return q->flags &UBLK_F_SUPPORT_ZERO_COPY ; +return !!(q->flags &UBLK_F_SUPPORT_ZERO_COPY ); } -static inline int ublk_queue_use_auto_zc (const struct ublk_queue *q) +static inline bool ublk_queue_use_auto_zc (const struct ublk_queue *q) { -return q->flags &UBLK_F_AUTO_BUF_REG ; +return !!(q->flags &UBLK_F_AUTO_BUF_REG ); } -static inline int ublk_queue_auto_zc_fallback (const struct ublk_queue *q) +static inline bool ublk_queue_auto_zc_fallback (const struct ublk_queue *q) { -return q->flags &UBLKS_Q_AUTO_BUF_REG_FALLBACK ; +return !!(q->flags &UBLKS_Q_AUTO_BUF_REG_FALLBACK ); }static inline bool ublk_queue_use_user_copy (const struct ublk_queue *q)
Signature · 7 lines
2.47.1 Thanks, Ming
Re: [PATCH 6/8] selftests: ublk: forbid multiple data copy modes
Quoted 215 lines · Ming Lei
Quoted 213 lines · Caleb Sander Mateos
Quoted 212 lines · Ming Lei
Quoted 209 lines · Caleb Sander Mateos
Quoted 202 lines · Ming Lei
Quoted 176 lines · Caleb Sander Mateos
Quoted 175 lines · Ming Lei
Quoted 173 lines · Caleb Sander Mateos
Quoted 60 lines · Ming Lei
Quoted 58 lines · Caleb Sander Mateos
The kublk mock ublk server allows multiple data copy mode arguments to be passed on the command line (--zero_copy, --get_data, and --auto_zc). The ublk device will be created with all the requested feature flags, however kublk will only use one of the modes to interact with request data (arbitrarily preferring
auto_zcoverzero_copyoverget_data). To clarify the intent of the test, don't allow multiple data copy modes to be specified. Don't setUBLK_F_USER_COPYforzero_copy, as it's an independent feature. Don't requirezero_copyforauto_zc_fallback, as onlyauto_zcis needed. Fix the test cases passing multiple data copy mode arguments.Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/kublk.c | 21 ++++++++++++------- .../testing/selftests/ublk/test_generic_09.sh | 2 +- .../testing/selftests/ublk/test_stress_03.sh | 4 ++-- .../testing/selftests/ublk/test_stress_04.sh | 2 +- .../testing/selftests/ublk/test_stress_05.sh | 10 ++++----- 5 files changed, 22 insertions(+), 17 deletions(-)tools/testing/selftests/ublk/kublk.c +9
-8@@ -1611,11 +1611,11 @@ int main(int argc, char *argv[])break ;case 'd' : ctx.queue_depth =strtol (optarg,NULL ,10 );break ;case 'z' : - ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY |UBLK_F_USER_COPY ; + ctx.flags |=UBLK_F_SUPPORT_ZERO_COPY ;break ;case 'r' : value =strtol (optarg,NULL ,10 );if (value) ctx.flags |=UBLK_F_USER_RECOVERY ;@@ -1674,17 +1674,22 @@ int main(int argc, char *argv[]) optind +=1 ;break ; } } -/* auto_zc_fallback depends on F_AUTO_BUF_REG & F_SUPPORT_ZERO_COPY */ -if (ctx.auto_zc_fallback && - !((ctx.flags &UBLK_F_AUTO_BUF_REG ) && - (ctx.flags &UBLK_F_SUPPORT_ZERO_COPY ))) { -ublk_err ("%s: auto_zc_fallback is set but neither " -"F_AUTO_BUF_REG nor F_SUPPORT_ZERO_COPY is enabled\n" , - __func__); +/* auto_zc_fallback depends on F_AUTO_BUF_REG */ +if (ctx.auto_zc_fallback && !(ctx.flags &UBLK_F_AUTO_BUF_REG )) { +ublk_err ("%s: auto_zc_fallback is set but F_AUTO_BUF_REG is disabled\n" , + __func__); +return -EINVAL ; + } + + if (!!(ctx.flags & UBLK_F_SUPPORT_ZERO_COPY) +Quoted 8 lines
tools/testing/selftests/ublk/kublk.c int main(int argc, char *argv[]) · line 1692
Quoted 6 lines
tools/testing/selftests/ublk/kublk.c +4
-0+ !!(ctx.flags & UBLK_F_NEED_GET_DATA) + + !!(ctx.flags & UBLK_F_USER_COPY) + + !!(ctx.flags & UBLK_F_AUTO_BUF_REG) > 1) { +fprintf (stderr,"too many data copy modes specified\n" );return -EINVAL ; }Actually most of them are allowed to co-exist, such as -z/--auto_zc/-u.
Yes, I know the ublk driver allows multiple copy mode flags to be set (though it will clear
UBLK_F_NEED_GET_DATAif any of the others are set). However, kublk will only actually use one of the modes. For example, --get_data --zero_copy will use zero copy for the data transfer, not get data. And --zero_copy --auto_zc will only use auto buffer registration. So I think it's confusing to allow multiple of these parameters to be passed to kublk. Or do you think there is value in testing ublk device creation with multiple data copy mode flags set, but only one of the modes actually used?Quoted 92 lines
Quoted 80 lines
tools/testing/selftests/ublk/kublk.c +0
-0i = optind;while (i < argc && ctx.nr_files <MAX_BACK_FILES ) {tools/testing/selftests/ublk/test_generic_09.sh +1
-1@@ -14,11 +14,11 @@ if ! _have_program fio; then exit "$UBLK_SKIP_CODE" fi _prep_test "null" "basic IO test" -dev_id=$(_add_ublk_dev -t null -z --auto_zc --auto_zc_fallback) +dev_id=$(_add_ublk_dev -t null --auto_zc --auto_zc_fallback) _check_add_dev $TID $? # 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=$?tools/testing/selftests/ublk/test_stress_03.sh +2
-2@@ -36,19 +36,19 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc & ublk_io_and_remove 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_remove 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks & ublk_io_and_remove 256M -t loop -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 256M -t stripe -q 4 --auto_zc --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback --nthreads 8 --per_io_tasks & wait fi _cleanup_test "stress" _show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_stress_04.sh +1
-1@@ -35,11 +35,11 @@ wait if _have_feature "AUTO_BUF_REG"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc & ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc "${UBLK_BACKFILES[0]}" & ublk_io_and_kill_daemon 256M -t stripe -q 4 --auto_zc --no_ublk_fixed_fd "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & - ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback & + ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --auto_zc_fallback & wait fi if _have_feature "PER_IO_DAEMON"; then ublk_io_and_kill_daemon 8G -t null -q 4 --auto_zc --nthreads 8 --per_io_tasks &tools/testing/selftests/ublk/test_stress_05.sh +2
-2@@ -56,21 +56,21 @@ for reissue in $(seq 0 1); do wait done if _have_feature "ZERO_COPY"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g -z -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 -z -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & wait donetools/testing/selftests/ublk/test_stress_05.sh for reissue in $(seq 0 1); do · line 71
Quoted 10 lines
tools/testing/selftests/ublk/test_stress_05.sh +3
-3fi if _have_feature "AUTO_BUF_REG"; then for reissue in $(seq 0 1); do - ublk_io_and_remove 8G -t null -q 4 -g --auto_zc -r 1 -i "$reissue" & - ublk_io_and_remove 256M -t loop -q 4 -g --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & - ublk_io_and_remove 8G -t null -q 4 -g -z --auto_zc --auto_zc_fallback -r 1 -i "$reissue" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 --auto_zc --auto_zc_fallback -r 1 -i "$reissue" &--auto_zc_fallback requires both -z and --auto_zc.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Ah, right, I forgot that the fallback path relies on normal zero copy buffer registration. I guess we are missing coverage of that, then, since the tests still passed with --zero_copy disabled.
Looks one regression from commit
0a9beafa7c63("ublk: refactor auto buffer register inublk_dispatch_req()")Is there a particular issue you see in that commit? I think the issue
Looks I overlooked.
Quoted 14 lines
is that if
UBLK_IO_F_NEED_REG_BUFis set in theublksrv_io_descbut zc isn't enabled, the null ublk server will just complete the I/O immediately. And --auto_zc_fallback isn't supported by any of the other ublk servers.if (
auto_zc&& !ublk_io_auto_zc_fallback(iod))queued = null_queue_auto_zc_io(t, q, tag); else if (zc) queued = null_queue_zc_io(t, q, tag); else { ublk_complete_io(t, q, tag, iod->nr_sectors << 9); return 0; }Quoted 4 lines
Quoted 1 line
So it looks to me to just be an issue with my kublk change.
But
ublk_queue_auto_zc_fallback()is broken, so theauto_zc_fallbackcode path isn't examined actually.How is it broken?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
typeof(q->flags)is u64, but the return type is i32, so it is overflowed.Ah, good catch. Yeah, these
ublk_queueflag query functions should probably return bool. Are you going to send out a patch?I guess you may have to send V3 for fixing patch 4, I appreciate you may include the following fix in your V3, otherwise it may conflict with the added
ublk_queue_use_user_copy().
Sure, will do.
Thanks,
Caleb
Quoted 73 lines
From
62da81c7a9883dc251cc0daa2a3081226abc5da1Mon Sep 17 00:00:00 2001
From: Ming Lei <[email protected]>
Date: Fri, 12 Dec 2025 11:23:56 +0000
Subject: [PATCH] selftests: ublk: fix overflow in
ublk_queue_auto_zc_fallback()The functions
ublk_queue_use_zc(),ublk_queue_use_auto_zc(), andublk_queue_auto_zc_fallback()were returning int, but performing bitwise AND onq->flagswhich is__u64.When a flag bit is set in the upper 32 bits (beyond
INT_MAX), the result of the bitwise AND operation could overflow when cast to int, leading to incorrect boolean evaluation.For example, if
UBLKS_Q_AUTO_BUF_REG_FALLBACKis0x8000000000000000:
- (u64)flags &0x8000000000000000=0x8000000000000000
- Cast to int: undefined behavior / incorrect value
- Used inif(): may evaluate incorrectlyFix by:
1. Changing return type from int to bool for semantic correctness
2. Using !! to explicitly convert to boolean (0 or 1)This ensures the functions return proper boolean values regardless of which bit position the flags occupy in the 64-bit field.
Fixes c3a6d48f86da ("selftests: ublk: remove ublk queue self-defined flags")Signed-off-by Ming Lei <[email protected]>--- tools/testing/selftests/ublk/kublk.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)tools/testing/selftests/ublk/kublk.h +6
-7@@ -396,19 +396,19 @@ static inline int ublk_completed_tgt_io(struct ublk_thread *t,return --io->tgt_ios ==0 ; } -static inline int ublk_queue_use_zc (const struct ublk_queue *q) +static inline bool ublk_queue_use_zc (const struct ublk_queue *q) { -return q->flags &UBLK_F_SUPPORT_ZERO_COPY ; +return !!(q->flags &UBLK_F_SUPPORT_ZERO_COPY ); } -static inline int ublk_queue_use_auto_zc (const struct ublk_queue *q) +static inline bool ublk_queue_use_auto_zc (const struct ublk_queue *q) { -return q->flags &UBLK_F_AUTO_BUF_REG ; +return !!(q->flags &UBLK_F_AUTO_BUF_REG ); } -static inline int ublk_queue_auto_zc_fallback (const struct ublk_queue *q) +static inline bool ublk_queue_auto_zc_fallback (const struct ublk_queue *q) { -return q->flags &UBLKS_Q_AUTO_BUF_REG_FALLBACK ; +return !!(q->flags &UBLKS_Q_AUTO_BUF_REG_FALLBACK ); }static inline bool ublk_queue_use_user_copy (const struct ublk_queue *q) --2.47.1
Thanks,
Ming
PATCH 7/8 selftests: ublk: add support for user copy to kublk
In reply to Caleb Sander MateosThe ublk selftests mock ublk server kublk supports every data copy mode except user copy. Add support for user copy to kublk, enabled via the --user_copy (-u) command line argument. On writes, issue pread() calls to copy the write data into the ublk_io's buffer before dispatching the write to the target implementation. On reads, issue pwrite() calls to copy read data from the ublk_io's buffer before committing the request. Copy in 2 KB chunks to provide some coverage of the offseting logic.
--- tools/testing/selftests/ublk/file_backed.c | 7 +-- tools/testing/selftests/ublk/kublk.c | 53 ++++++++++++++++++++-- tools/testing/selftests/ublk/kublk.h | 11 +++++ tools/testing/selftests/ublk/stripe.c | 2 +- 4 files changed, 64 insertions(+), 9 deletions(-)
tools/testing/selftests/ublk/file_backed.c +4 -3
@@ -32,12 +32,13 @@ static int loop_queue_tgt_rw_io(struct ublk_thread *t, struct ublk_queue *q, {unsigned ublk_op =ublksrv_get_op (iod);unsigned zc =ublk_queue_use_zc (q);unsigned auto_zc =ublk_queue_use_auto_zc (q);enum io_uring_op op =ublk_to_uring_op (iod, zc | auto_zc); +struct ublk_io *io =ublk_get_io (q, tag);struct io_uring_sqe *sqe[3 ]; -void *addr = (zc | auto_zc) ?NULL : (void *)iod->addr; +void *addr = io->buf_addr;if (!zc || auto_zc) {ublk_io_alloc_sqes (t, sqe,1 );if (!sqe[0 ])return -ENOMEM ;
@@ -54,11 +55,11 @@ static int loop_queue_tgt_rw_io(struct ublk_thread *t, struct ublk_queue *q,return 1 ; }ublk_io_alloc_sqes (t, sqe,3 ); -io_uring_prep_buf_register (sqe[0 ], q, tag, q->q_id,ublk_get_io (q, tag)->buf_index); +io_uring_prep_buf_register (sqe[0 ], q, tag, q->q_id, io->buf_index); sqe[0 ]->flags |=IOSQE_CQE_SKIP_SUCCESS |IOSQE_IO_HARDLINK ; sqe[0 ]->user_data =build_user_data (tag,ublk_cmd_op_nr (sqe[0 ]->cmd_op),0 , q->q_id,1 ); io_uring_prep_rw(op, sqe[1], ublk_get_registered_fd(q, 1) /*fds[1]*/, 0,
@@ -66,11 +67,11 @@ static int loop_queue_tgt_rw_io(struct ublk_thread *t, struct ublk_queue *q, iod->start_sector << 9); sqe[1 ]->buf_index = tag; sqe[1 ]->flags |=IOSQE_FIXED_FILE |IOSQE_IO_HARDLINK ; sqe[1 ]->user_data =build_user_data (tag, ublk_op,0 , q->q_id,1 ); -io_uring_prep_buf_unregister (sqe[2 ], q, tag, q->q_id,ublk_get_io (q, tag)->buf_index); +io_uring_prep_buf_unregister (sqe[2 ], q, tag, q->q_id, io->buf_index); sqe[2 ]->user_data =build_user_data (tag,ublk_cmd_op_nr (sqe[2 ]->cmd_op),0 , q->q_id,1 );return 2 ; }
tools/testing/selftests/ublk/kublk.c +48 -5
134 lines not on this page · raw message
tools/testing/selftests/ublk/kublk.h +11 -0
@@ -206,10 +206,16 @@ extern int ublk_queue_io_cmd(struct ublk_thread *t, struct ublk_io *io);static inline int ublk_io_auto_zc_fallback (const struct ublksrv_io_desc *iod) {return !!(iod->op_flags &UBLK_IO_F_NEED_REG_BUF ); } +static inline __u64 ublk_user_copy_offset (unsigned q_id,unsigned tag) +{ +return UBLKSRV_IO_BUF_OFFSET + + ((__u64 )q_id <<UBLK_QID_OFF | (__u64 )tag <<UBLK_TAG_OFF ); +} +static inline int is_target_io (__u64 user_data) {return (user_data & (1ULL <<63 )) !=0 ; }
@@ -403,10 +409,15 @@ static inline int ublk_queue_use_auto_zc(const struct ublk_queue *q)static inline int ublk_queue_auto_zc_fallback (const struct ublk_queue *q) {return q->flags &UBLKS_Q_AUTO_BUF_REG_FALLBACK ; } +static inline bool ublk_queue_use_user_copy (const struct ublk_queue *q) +{ +return !!(q->flags &UBLK_F_USER_COPY ); +} +static inline int ublk_queue_no_buf (const struct ublk_queue *q) {return ublk_queue_use_zc (q) ||ublk_queue_use_auto_zc (q); }
tools/testing/selftests/ublk/stripe.c +1 -1
@@ -132,11 +132,11 @@ static int stripe_queue_tgt_rw_io(struct ublk_thread *t, struct ublk_queue *q,enum io_uring_op op =stripe_to_uring_op (iod, zc | auto_zc);struct io_uring_sqe *sqe[NR_STRIPE ];struct stripe_array *s =alloc_stripe_array (conf, iod);struct ublk_io *io =ublk_get_io (q, tag);int i, extra = zc ?2 :0 ; -void *base = (zc | auto_zc) ?NULL : (void *)iod->addr; +void *base = io->buf_addr; io->private_data = s;calculate_stripe_array (conf, iod, s, base);ublk_io_alloc_sqes (t, sqe, s->nr + extra);
Signature · 1 line
2.45.2
PATCH 8/8 selftests: ublk: add user copy test cases
In reply to Caleb Sander MateosThe ublk selftests cover every data copy mode except user copy. Add tests for user copy based on the existing test suite:
- generic_14 ("basic recover function verification (user copy)") based on generic_04 and generic_05
- null_03 ("basic IO test with user copy") based on null_01 and null_02
- loop_06 ("write and verify over user copy") based on loop_01 and loop_03
- loop_07 ("mkfs & mount & umount with user copy") based on loop_02 and loop_04
- stripe_05 ("write and verify test on user copy") based on stripe_03
- stripe_06 ("mkfs & mount & umount on user copy") based on stripe_02 and stripe_04
- Added test cases to stress_05 ("run IO and remove device with recovery enabled") for user copy
- stress_06 ("run IO and remove device (user copy)") based on stress_01 and stress_03
- stress_07 ("run IO and kill ublk server (user copy)") based on stress_02 and stress_04
--- tools/testing/selftests/ublk/Makefile | 8 ++++ .../testing/selftests/ublk/test_generic_14.sh | 40 +++++++++++++++++++ tools/testing/selftests/ublk/test_loop_06.sh | 25 ++++++++++++ tools/testing/selftests/ublk/test_loop_07.sh | 21 ++++++++++ tools/testing/selftests/ublk/test_null_03.sh | 24 +++++++++++ .../testing/selftests/ublk/test_stress_05.sh | 7 ++++ .../testing/selftests/ublk/test_stress_06.sh | 39 ++++++++++++++++++ .../testing/selftests/ublk/test_stress_07.sh | 39 ++++++++++++++++++ .../testing/selftests/ublk/test_stripe_05.sh | 26 ++++++++++++ .../testing/selftests/ublk/test_stripe_06.sh | 21 ++++++++++ 10 files changed, 250 insertions(+) create mode 100755 tools/testing/selftests/ublk/test_generic_14.sh create mode 100755 tools/testing/selftests/ublk/test_loop_06.sh create mode 100755 tools/testing/selftests/ublk/test_loop_07.sh create mode 100755 tools/testing/selftests/ublk/test_null_03.sh create mode 100755 tools/testing/selftests/ublk/test_stress_06.sh create mode 100755 tools/testing/selftests/ublk/test_stress_07.sh create mode 100755 tools/testing/selftests/ublk/test_stripe_05.sh create mode 100755 tools/testing/selftests/ublk/test_stripe_06.sh
tools/testing/selftests/ublk/Makefile +8 -0
@@ -19,28 +19,36 @@ TEST_PROGS += test_generic_08.sh TEST_PROGS += test_generic_09.sh TEST_PROGS += test_generic_10.sh TEST_PROGS += test_generic_11.sh TEST_PROGS += test_generic_12.sh TEST_PROGS += test_generic_13.sh +TEST_PROGS += test_generic_14.sh TEST_PROGS += test_null_01.sh TEST_PROGS += test_null_02.sh +TEST_PROGS += test_null_03.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_PROGS += test_loop_05.sh +TEST_PROGS += test_loop_06.sh +TEST_PROGS += test_loop_07.sh TEST_PROGS += test_stripe_01.sh TEST_PROGS += test_stripe_02.sh TEST_PROGS += test_stripe_03.sh TEST_PROGS += test_stripe_04.sh +TEST_PROGS += test_stripe_05.sh +TEST_PROGS += test_stripe_06.sh TEST_PROGS += test_stress_01.sh TEST_PROGS += test_stress_02.sh TEST_PROGS += test_stress_03.sh TEST_PROGS += test_stress_04.sh TEST_PROGS += test_stress_05.sh +TEST_PROGS += test_stress_06.sh +TEST_PROGS += test_stress_07.sh TEST_GEN_PROGS_EXTENDED = kublk include ../lib.mk
tools/testing/selftests/ublk/test_generic_14.sh new file +40 -0
@@ -0,0 +1,40 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="generic_14" +ERR_CODE=0 + +ublk_run_recover_test() +{ + run_io_and_recover 256M "kill_daemon" "$@" + ERR_CODE=$? + if [ ${ERR_CODE} -ne 0 ]; then + echo "$TID failure: $*" + _show_result $TID $ERR_CODE + fi +} + +if ! _have_program fio; then + exit "$UBLK_SKIP_CODE" +fi + +_prep_test "recover" "basic recover function verification (user copy)" + +_create_backfile 0 256M +_create_backfile 1 128M +_create_backfile 2 128M + +ublk_run_recover_test -t null -q 2 -r 1 -u & +ublk_run_recover_test -t loop -q 2 -r 1 -u "${UBLK_BACKFILES[0]}" & +ublk_run_recover_test -t stripe -q 2 -r 1 -u "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & +wait + +ublk_run_recover_test -t null -q 2 -r 1 -u -i 1 & +ublk_run_recover_test -t loop -q 2 -r 1 -u -i 1 "${UBLK_BACKFILES[0]}" & +ublk_run_recover_test -t stripe -q 2 -r 1 -u -i 1 "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & +wait + +_cleanup_test "recover" +_show_result $TID $ERR_CODE
tools/testing/selftests/ublk/test_loop_06.sh new file +25 -0
@@ -0,0 +1,25 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="loop_06" +ERR_CODE=0 + +if ! _have_program fio; then + exit "$UBLK_SKIP_CODE" +fi + +_prep_test "loop" "write and verify over user copy" + +_create_backfile 0 256M +dev_id=$(_add_ublk_dev -t loop -u "${UBLK_BACKFILES[0]}") +_check_add_dev $TID $? + +# run fio over the ublk disk +_run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=256M +ERR_CODE=$? + +_cleanup_test "loop" + +_show_result $TID $ERR_CODE
tools/testing/selftests/ublk/test_loop_07.sh new file +21 -0
@@ -0,0 +1,21 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="loop_07" +ERR_CODE=0 + +_prep_test "loop" "mkfs & mount & umount with user copy" + +_create_backfile 0 256M + +dev_id=$(_add_ublk_dev -t loop -u "${UBLK_BACKFILES[0]}") +_check_add_dev $TID $? + +_mkfs_mount_test /dev/ublkb"${dev_id}" +ERR_CODE=$? + +_cleanup_test "loop" + +_show_result $TID $ERR_CODE
tools/testing/selftests/ublk/test_null_03.sh new file +24 -0
@@ -0,0 +1,24 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="null_03" +ERR_CODE=0 + +if ! _have_program fio; then + exit "$UBLK_SKIP_CODE" +fi + +_prep_test "null" "basic IO test with user copy" + +dev_id=$(_add_ublk_dev -t null -u) +_check_add_dev $TID $? + +# 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 "null" + +_show_result $TID $ERR_CODE
tools/testing/selftests/ublk/test_stress_05.sh +7 -0
@@ -78,7 +78,14 @@ if _have_feature "PER_IO_DAEMON"; then ublk_io_and_remove 256M -t loop -q 4 --nthreads 8 --per_io_tasks -r 1 -i "$reissue" "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 8G -t null -q 4 --nthreads 8 --per_io_tasks -r 1 -i "$reissue" & fi wait +for reissue in $(seq 0 1); do + ublk_io_and_remove 8G -t null -q 4 -u -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 -u -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 -u -r 1 -i "$reissue" & + wait +done + _cleanup_test "stress" _show_result $TID $ERR_CODE
tools/testing/selftests/ublk/test_stress_06.sh new file +39 -0
@@ -0,0 +1,39 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh +TID="stress_06" +ERR_CODE=0 + +ublk_io_and_remove() +{ + run_io_and_remove "$@" + ERR_CODE=$? + if [ ${ERR_CODE} -ne 0 ]; then + echo "$TID failure: $*" + _show_result $TID $ERR_CODE + fi +} + +if ! _have_program fio; then + exit "$UBLK_SKIP_CODE" +fi + +_prep_test "stress" "run IO and remove device (user copy)" + +_create_backfile 0 256M +_create_backfile 1 128M +_create_backfile 2 128M + +ublk_io_and_remove 8G -t null -q 4 -u & +ublk_io_and_remove 256M -t loop -q 4 -u "${UBLK_BACKFILES[0]}" & +ublk_io_and_remove 256M -t stripe -q 4 -u "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & +wait + +ublk_io_and_remove 8G -t null -q 4 -u --nthreads 8 --per_io_tasks & +ublk_io_and_remove 256M -t loop -q 4 -u --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & +ublk_io_and_remove 256M -t stripe -q 4 -u --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & +wait + +_cleanup_test "stress" +_show_result $TID $ERR_CODE
tools/testing/selftests/ublk/test_stress_07.sh new file +39 -0
@@ -0,0 +1,39 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh +TID="stress_07" +ERR_CODE=0 + +ublk_io_and_kill_daemon() +{ + run_io_and_kill_daemon "$@" + ERR_CODE=$? + if [ ${ERR_CODE} -ne 0 ]; then + echo "$TID failure: $*" + _show_result $TID $ERR_CODE + fi +} + +if ! _have_program fio; then + exit "$UBLK_SKIP_CODE" +fi + +_prep_test "stress" "run IO and kill ublk server (user copy)" + +_create_backfile 0 256M +_create_backfile 1 128M +_create_backfile 2 128M + +ublk_io_and_kill_daemon 8G -t null -q 4 -u --no_ublk_fixed_fd & +ublk_io_and_kill_daemon 256M -t loop -q 4 -u --no_ublk_fixed_fd "${UBLK_BACKFILES[0]}" & +ublk_io_and_kill_daemon 256M -t stripe -q 4 -u "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & +wait + +ublk_io_and_kill_daemon 8G -t null -q 4 -u --nthreads 8 --per_io_tasks & +ublk_io_and_kill_daemon 256M -t loop -q 4 -u --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" & +ublk_io_and_kill_daemon 256M -t stripe -q 4 -u --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & +wait + +_cleanup_test "stress" +_show_result $TID $ERR_CODE
tools/testing/selftests/ublk/test_stripe_05.sh new file +26 -0
@@ -0,0 +1,26 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="stripe_05" +ERR_CODE=0 + +if ! _have_program fio; then + exit "$UBLK_SKIP_CODE" +fi + +_prep_test "stripe" "write and verify test on user copy" + +_create_backfile 0 256M +_create_backfile 1 256M + +dev_id=$(_add_ublk_dev -t stripe -q 2 -u "${UBLK_BACKFILES[0]}" "${UBLK_BACKFILES[1]}") +_check_add_dev $TID $? + +# run fio over the ublk disk +_run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=512M +ERR_CODE=$? + +_cleanup_test "stripe" +_show_result $TID $ERR_CODE
tools/testing/selftests/ublk/test_stripe_06.sh new file +21 -0
@@ -0,0 +1,21 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="stripe_06" +ERR_CODE=0 + +_prep_test "stripe" "mkfs & mount & umount on user copy" + +_create_backfile 0 256M +_create_backfile 1 256M + +dev_id=$(_add_ublk_dev -t stripe -u -q 2 "${UBLK_BACKFILES[0]}" "${UBLK_BACKFILES[1]}") +_check_add_dev $TID $? + +_mkfs_mount_test /dev/ublkb"${dev_id}" +ERR_CODE=$? + +_cleanup_test "stripe" +_show_result $TID $ERR_CODE
Signature · 1 line
2.45.2
Quoted 222 lines · Caleb Sander Mateos
The ublk selftests cover every data copy mode except user copy. Add tests for user copy based on the existing test suite:
-generic_14("basic recover function verification (user copy)") based ongeneric_04andgeneric_05
-null_03("basic IO test with user copy") based onnull_01andnull_02
-loop_06("write and verify over user copy") based onloop_01andloop_03
-loop_07("mkfs & mount & umount with user copy") based onloop_02andloop_04
-stripe_05("write and verify test on user copy") based onstripe_03
-stripe_06("mkfs & mount & umount on user copy") based onstripe_02andstripe_04
- Added test cases tostress_05("run IO and remove device with recovery enabled") for user copy
-stress_06("run IO and remove device (user copy)") based onstress_01andstress_03
-stress_07("run IO and kill ublk server (user copy)") based onstress_02andstress_04Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/Makefile | 8 ++++ .../testing/selftests/ublk/test_generic_14.sh | 40 +++++++++++++++++++ tools/testing/selftests/ublk/test_loop_06.sh | 25 ++++++++++++ tools/testing/selftests/ublk/test_loop_07.sh | 21 ++++++++++ tools/testing/selftests/ublk/test_null_03.sh | 24 +++++++++++ .../testing/selftests/ublk/test_stress_05.sh | 7 ++++ .../testing/selftests/ublk/test_stress_06.sh | 39 ++++++++++++++++++ .../testing/selftests/ublk/test_stress_07.sh | 39 ++++++++++++++++++ .../testing/selftests/ublk/test_stripe_05.sh | 26 ++++++++++++ .../testing/selftests/ublk/test_stripe_06.sh | 21 ++++++++++ 10 files changed, 250 insertions(+) create mode 100755 tools/testing/selftests/ublk/test_generic_14.sh create mode 100755 tools/testing/selftests/ublk/test_loop_06.sh create mode 100755 tools/testing/selftests/ublk/test_loop_07.sh create mode 100755 tools/testing/selftests/ublk/test_null_03.sh create mode 100755 tools/testing/selftests/ublk/test_stress_06.sh create mode 100755 tools/testing/selftests/ublk/test_stress_07.sh create mode 100755 tools/testing/selftests/ublk/test_stripe_05.sh create mode 100755 tools/testing/selftests/ublk/test_stripe_06.shtools/testing/selftests/ublk/Makefile +8
-0@@ -19,28 +19,36 @@ TEST_PROGS += test_generic_08.sh TEST_PROGS += test_generic_09.sh TEST_PROGS += test_generic_10.sh TEST_PROGS += test_generic_11.sh TEST_PROGS += test_generic_12.sh TEST_PROGS += test_generic_13.sh +TEST_PROGS += test_generic_14.sh TEST_PROGS += test_null_01.sh TEST_PROGS += test_null_02.sh +TEST_PROGS += test_null_03.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_PROGS += test_loop_05.sh +TEST_PROGS += test_loop_06.sh +TEST_PROGS += test_loop_07.sh TEST_PROGS += test_stripe_01.sh TEST_PROGS += test_stripe_02.sh TEST_PROGS += test_stripe_03.sh TEST_PROGS += test_stripe_04.sh +TEST_PROGS += test_stripe_05.sh +TEST_PROGS += test_stripe_06.sh TEST_PROGS += test_stress_01.sh TEST_PROGS += test_stress_02.sh TEST_PROGS += test_stress_03.sh TEST_PROGS += test_stress_04.sh TEST_PROGS += test_stress_05.sh +TEST_PROGS += test_stress_06.sh +TEST_PROGS += test_stress_07.sh TEST_GEN_PROGS_EXTENDED = kublk include ../lib.mktools/testing/selftests/ublk/test_generic_14.sh new file +40
-0@@ -0,0 +1,40 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="generic_14" +ERR_CODE=0 + +ublk_run_recover_test() +{ + run_io_and_recover 256M "kill_daemon" "$@" + ERR_CODE=$? + if [ ${ERR_CODE} -ne 0 ]; then + echo "$TID failure: $*" + _show_result $TID $ERR_CODE + fi +} + +if ! _have_program fio; then + exit "$UBLK_SKIP_CODE" +fi + +_prep_test "recover" "basic recover function verification (user copy)" + +_create_backfile 0 256M +_create_backfile 1 128M +_create_backfile 2 128M + +ublk_run_recover_test -t null -q 2 -r 1 -u & +ublk_run_recover_test -t loop -q 2 -r 1 -u "${UBLK_BACKFILES[0]}" & +ublk_run_recover_test -t stripe -q 2 -r 1 -u "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & +wait + +ublk_run_recover_test -t null -q 2 -r 1 -u -i 1 & +ublk_run_recover_test -t loop -q 2 -r 1 -u -i 1 "${UBLK_BACKFILES[0]}" & +ublk_run_recover_test -t stripe -q 2 -r 1 -u -i 1 "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & +wait + +_cleanup_test "recover" +_show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_loop_06.sh new file +25
-0@@ -0,0 +1,25 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="loop_06" +ERR_CODE=0 + +if ! _have_program fio; then + exit "$UBLK_SKIP_CODE" +fi + +_prep_test "loop" "write and verify over user copy" + +_create_backfile 0 256M +dev_id=$(_add_ublk_dev -t loop -u "${UBLK_BACKFILES[0]}") +_check_add_dev $TID $? + +# run fio over the ublk disk +_run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=256M +ERR_CODE=$? + +_cleanup_test "loop" + +_show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_loop_07.sh new file +21
-0@@ -0,0 +1,21 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="loop_07" +ERR_CODE=0 + +_prep_test "loop" "mkfs & mount & umount with user copy" + +_create_backfile 0 256M + +dev_id=$(_add_ublk_dev -t loop -u "${UBLK_BACKFILES[0]}") +_check_add_dev $TID $? + +_mkfs_mount_test /dev/ublkb"${dev_id}" +ERR_CODE=$? + +_cleanup_test "loop" + +_show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_null_03.sh new file +24
-0@@ -0,0 +1,24 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="null_03" +ERR_CODE=0 + +if ! _have_program fio; then + exit "$UBLK_SKIP_CODE" +fi + +_prep_test "null" "basic IO test with user copy" + +dev_id=$(_add_ublk_dev -t null -u) +_check_add_dev $TID $? + +# 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 "null" + +_show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_stress_05.sh +0
-0@@ -78,7 +78,14 @@ if _have_feature "PER_IO_DAEMON"; then ublk_io_and_remove 256M -t loop -q 4 --nthreads 8 --per_io_tasks -r 1 -i "$reissue" "${UBLK_BACKFILES[0]}" &
tools/testing/selftests/ublk/test_stress_05.sh if _have_feature "PER_IO_DAEMON"; then · line 88
Quoted 10 lines
tools/testing/selftests/ublk/test_stress_05.sh +6
-0ublk_io_and_remove 8G -t null -q 4 --nthreads 8 --per_io_tasks -r 1 -i "$reissue" & fi wait +for reissue in $(seq 0 1); do + ublk_io_and_remove 8G -t null -q 4 -u -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 -u -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 -u -r 1 -i "$reissue" & + wait +done
I'd suggest to not add new test coverage in old stress tests until default timeout is overrided, now it is close to default 45 seconds timeout.
Thanks,
Ming
Quoted 228 lines · Ming Lei
Quoted 226 lines · Caleb Sander Mateos
The ublk selftests cover every data copy mode except user copy. Add tests for user copy based on the existing test suite:
-generic_14("basic recover function verification (user copy)") based ongeneric_04andgeneric_05
-null_03("basic IO test with user copy") based onnull_01andnull_02
-loop_06("write and verify over user copy") based onloop_01andloop_03
-loop_07("mkfs & mount & umount with user copy") based onloop_02andloop_04
-stripe_05("write and verify test on user copy") based onstripe_03
-stripe_06("mkfs & mount & umount on user copy") based onstripe_02andstripe_04
- Added test cases tostress_05("run IO and remove device with recovery enabled") for user copy
-stress_06("run IO and remove device (user copy)") based onstress_01andstress_03
-stress_07("run IO and kill ublk server (user copy)") based onstress_02andstress_04Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/Makefile | 8 ++++ .../testing/selftests/ublk/test_generic_14.sh | 40 +++++++++++++++++++ tools/testing/selftests/ublk/test_loop_06.sh | 25 ++++++++++++ tools/testing/selftests/ublk/test_loop_07.sh | 21 ++++++++++ tools/testing/selftests/ublk/test_null_03.sh | 24 +++++++++++ .../testing/selftests/ublk/test_stress_05.sh | 7 ++++ .../testing/selftests/ublk/test_stress_06.sh | 39 ++++++++++++++++++ .../testing/selftests/ublk/test_stress_07.sh | 39 ++++++++++++++++++ .../testing/selftests/ublk/test_stripe_05.sh | 26 ++++++++++++ .../testing/selftests/ublk/test_stripe_06.sh | 21 ++++++++++ 10 files changed, 250 insertions(+) create mode 100755 tools/testing/selftests/ublk/test_generic_14.sh create mode 100755 tools/testing/selftests/ublk/test_loop_06.sh create mode 100755 tools/testing/selftests/ublk/test_loop_07.sh create mode 100755 tools/testing/selftests/ublk/test_null_03.sh create mode 100755 tools/testing/selftests/ublk/test_stress_06.sh create mode 100755 tools/testing/selftests/ublk/test_stress_07.sh create mode 100755 tools/testing/selftests/ublk/test_stripe_05.sh create mode 100755 tools/testing/selftests/ublk/test_stripe_06.shtools/testing/selftests/ublk/Makefile +8
-0@@ -19,28 +19,36 @@ TEST_PROGS += test_generic_08.sh TEST_PROGS += test_generic_09.sh TEST_PROGS += test_generic_10.sh TEST_PROGS += test_generic_11.sh TEST_PROGS += test_generic_12.sh TEST_PROGS += test_generic_13.sh +TEST_PROGS += test_generic_14.sh TEST_PROGS += test_null_01.sh TEST_PROGS += test_null_02.sh +TEST_PROGS += test_null_03.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_PROGS += test_loop_05.sh +TEST_PROGS += test_loop_06.sh +TEST_PROGS += test_loop_07.sh TEST_PROGS += test_stripe_01.sh TEST_PROGS += test_stripe_02.sh TEST_PROGS += test_stripe_03.sh TEST_PROGS += test_stripe_04.sh +TEST_PROGS += test_stripe_05.sh +TEST_PROGS += test_stripe_06.sh TEST_PROGS += test_stress_01.sh TEST_PROGS += test_stress_02.sh TEST_PROGS += test_stress_03.sh TEST_PROGS += test_stress_04.sh TEST_PROGS += test_stress_05.sh +TEST_PROGS += test_stress_06.sh +TEST_PROGS += test_stress_07.sh TEST_GEN_PROGS_EXTENDED = kublk include ../lib.mktools/testing/selftests/ublk/test_generic_14.sh new file +40
-0@@ -0,0 +1,40 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="generic_14" +ERR_CODE=0 + +ublk_run_recover_test() +{ + run_io_and_recover 256M "kill_daemon" "$@" + ERR_CODE=$? + if [ ${ERR_CODE} -ne 0 ]; then + echo "$TID failure: $*" + _show_result $TID $ERR_CODE + fi +} + +if ! _have_program fio; then + exit "$UBLK_SKIP_CODE" +fi + +_prep_test "recover" "basic recover function verification (user copy)" + +_create_backfile 0 256M +_create_backfile 1 128M +_create_backfile 2 128M + +ublk_run_recover_test -t null -q 2 -r 1 -u & +ublk_run_recover_test -t loop -q 2 -r 1 -u "${UBLK_BACKFILES[0]}" & +ublk_run_recover_test -t stripe -q 2 -r 1 -u "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & +wait + +ublk_run_recover_test -t null -q 2 -r 1 -u -i 1 & +ublk_run_recover_test -t loop -q 2 -r 1 -u -i 1 "${UBLK_BACKFILES[0]}" & +ublk_run_recover_test -t stripe -q 2 -r 1 -u -i 1 "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & +wait + +_cleanup_test "recover" +_show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_loop_06.sh new file +25
-0@@ -0,0 +1,25 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="loop_06" +ERR_CODE=0 + +if ! _have_program fio; then + exit "$UBLK_SKIP_CODE" +fi + +_prep_test "loop" "write and verify over user copy" + +_create_backfile 0 256M +dev_id=$(_add_ublk_dev -t loop -u "${UBLK_BACKFILES[0]}") +_check_add_dev $TID $? + +# run fio over the ublk disk +_run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=256M +ERR_CODE=$? + +_cleanup_test "loop" + +_show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_loop_07.sh new file +21
-0@@ -0,0 +1,21 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="loop_07" +ERR_CODE=0 + +_prep_test "loop" "mkfs & mount & umount with user copy" + +_create_backfile 0 256M + +dev_id=$(_add_ublk_dev -t loop -u "${UBLK_BACKFILES[0]}") +_check_add_dev $TID $? + +_mkfs_mount_test /dev/ublkb"${dev_id}" +ERR_CODE=$? + +_cleanup_test "loop" + +_show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_null_03.sh new file +24
-0@@ -0,0 +1,24 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="null_03" +ERR_CODE=0 + +if ! _have_program fio; then + exit "$UBLK_SKIP_CODE" +fi + +_prep_test "null" "basic IO test with user copy" + +dev_id=$(_add_ublk_dev -t null -u) +_check_add_dev $TID $? + +# 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 "null" + +_show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_stress_05.sh +0
-0@@ -78,7 +78,14 @@ if _have_feature "PER_IO_DAEMON"; then ublk_io_and_remove 256M -t loop -q 4 --nthreads 8 --per_io_tasks -r 1 -i "$reissue" "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 8G -t null -q 4 --nthreads 8 --per_io_tasks -r 1 -i "$reissue" & fi wait
Quoted 9 lines
tools/testing/selftests/ublk/test_stress_05.sh if _have_feature "PER_IO_DAEMON"; then · line 88
Quoted 6 lines
tools/testing/selftests/ublk/test_stress_05.sh +6
-0+for reissue in $(seq 0 1); do + ublk_io_and_remove 8G -t null -q 4 -u -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 -u -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 -u -r 1 -i "$reissue" & + wait +doneI'd suggest to not add new test coverage in old stress tests until default timeout is overrided, now it is close to default 45 seconds timeout.
Okay, I can just drop the changes in test_stress_05.sh if that sounds good to you?
Thanks,
Caleb
Quoted 239 lines · Caleb Sander Mateos
Quoted 228 lines · Ming Lei
Quoted 226 lines · Caleb Sander Mateos
The ublk selftests cover every data copy mode except user copy. Add tests for user copy based on the existing test suite:
-generic_14("basic recover function verification (user copy)") based ongeneric_04andgeneric_05
-null_03("basic IO test with user copy") based onnull_01andnull_02
-loop_06("write and verify over user copy") based onloop_01andloop_03
-loop_07("mkfs & mount & umount with user copy") based onloop_02andloop_04
-stripe_05("write and verify test on user copy") based onstripe_03
-stripe_06("mkfs & mount & umount on user copy") based onstripe_02andstripe_04
- Added test cases tostress_05("run IO and remove device with recovery enabled") for user copy
-stress_06("run IO and remove device (user copy)") based onstress_01andstress_03
-stress_07("run IO and kill ublk server (user copy)") based onstress_02andstress_04Signed-off-by Caleb Sander Mateos <[email protected]>--- tools/testing/selftests/ublk/Makefile | 8 ++++ .../testing/selftests/ublk/test_generic_14.sh | 40 +++++++++++++++++++ tools/testing/selftests/ublk/test_loop_06.sh | 25 ++++++++++++ tools/testing/selftests/ublk/test_loop_07.sh | 21 ++++++++++ tools/testing/selftests/ublk/test_null_03.sh | 24 +++++++++++ .../testing/selftests/ublk/test_stress_05.sh | 7 ++++ .../testing/selftests/ublk/test_stress_06.sh | 39 ++++++++++++++++++ .../testing/selftests/ublk/test_stress_07.sh | 39 ++++++++++++++++++ .../testing/selftests/ublk/test_stripe_05.sh | 26 ++++++++++++ .../testing/selftests/ublk/test_stripe_06.sh | 21 ++++++++++ 10 files changed, 250 insertions(+) create mode 100755 tools/testing/selftests/ublk/test_generic_14.sh create mode 100755 tools/testing/selftests/ublk/test_loop_06.sh create mode 100755 tools/testing/selftests/ublk/test_loop_07.sh create mode 100755 tools/testing/selftests/ublk/test_null_03.sh create mode 100755 tools/testing/selftests/ublk/test_stress_06.sh create mode 100755 tools/testing/selftests/ublk/test_stress_07.sh create mode 100755 tools/testing/selftests/ublk/test_stripe_05.sh create mode 100755 tools/testing/selftests/ublk/test_stripe_06.shtools/testing/selftests/ublk/Makefile +8
-0@@ -19,28 +19,36 @@ TEST_PROGS += test_generic_08.sh TEST_PROGS += test_generic_09.sh TEST_PROGS += test_generic_10.sh TEST_PROGS += test_generic_11.sh TEST_PROGS += test_generic_12.sh TEST_PROGS += test_generic_13.sh +TEST_PROGS += test_generic_14.sh TEST_PROGS += test_null_01.sh TEST_PROGS += test_null_02.sh +TEST_PROGS += test_null_03.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_PROGS += test_loop_05.sh +TEST_PROGS += test_loop_06.sh +TEST_PROGS += test_loop_07.sh TEST_PROGS += test_stripe_01.sh TEST_PROGS += test_stripe_02.sh TEST_PROGS += test_stripe_03.sh TEST_PROGS += test_stripe_04.sh +TEST_PROGS += test_stripe_05.sh +TEST_PROGS += test_stripe_06.sh TEST_PROGS += test_stress_01.sh TEST_PROGS += test_stress_02.sh TEST_PROGS += test_stress_03.sh TEST_PROGS += test_stress_04.sh TEST_PROGS += test_stress_05.sh +TEST_PROGS += test_stress_06.sh +TEST_PROGS += test_stress_07.sh TEST_GEN_PROGS_EXTENDED = kublk include ../lib.mktools/testing/selftests/ublk/test_generic_14.sh new file +40
-0@@ -0,0 +1,40 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="generic_14" +ERR_CODE=0 + +ublk_run_recover_test() +{ + run_io_and_recover 256M "kill_daemon" "$@" + ERR_CODE=$? + if [ ${ERR_CODE} -ne 0 ]; then + echo "$TID failure: $*" + _show_result $TID $ERR_CODE + fi +} + +if ! _have_program fio; then + exit "$UBLK_SKIP_CODE" +fi + +_prep_test "recover" "basic recover function verification (user copy)" + +_create_backfile 0 256M +_create_backfile 1 128M +_create_backfile 2 128M + +ublk_run_recover_test -t null -q 2 -r 1 -u & +ublk_run_recover_test -t loop -q 2 -r 1 -u "${UBLK_BACKFILES[0]}" & +ublk_run_recover_test -t stripe -q 2 -r 1 -u "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & +wait + +ublk_run_recover_test -t null -q 2 -r 1 -u -i 1 & +ublk_run_recover_test -t loop -q 2 -r 1 -u -i 1 "${UBLK_BACKFILES[0]}" & +ublk_run_recover_test -t stripe -q 2 -r 1 -u -i 1 "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & +wait + +_cleanup_test "recover" +_show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_loop_06.sh new file +25
-0@@ -0,0 +1,25 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="loop_06" +ERR_CODE=0 + +if ! _have_program fio; then + exit "$UBLK_SKIP_CODE" +fi + +_prep_test "loop" "write and verify over user copy" + +_create_backfile 0 256M +dev_id=$(_add_ublk_dev -t loop -u "${UBLK_BACKFILES[0]}") +_check_add_dev $TID $? + +# run fio over the ublk disk +_run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=256M +ERR_CODE=$? + +_cleanup_test "loop" + +_show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_loop_07.sh new file +21
-0@@ -0,0 +1,21 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="loop_07" +ERR_CODE=0 + +_prep_test "loop" "mkfs & mount & umount with user copy" + +_create_backfile 0 256M + +dev_id=$(_add_ublk_dev -t loop -u "${UBLK_BACKFILES[0]}") +_check_add_dev $TID $? + +_mkfs_mount_test /dev/ublkb"${dev_id}" +ERR_CODE=$? + +_cleanup_test "loop" + +_show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_null_03.sh new file +24
-0@@ -0,0 +1,24 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh + +TID="null_03" +ERR_CODE=0 + +if ! _have_program fio; then + exit "$UBLK_SKIP_CODE" +fi + +_prep_test "null" "basic IO test with user copy" + +dev_id=$(_add_ublk_dev -t null -u) +_check_add_dev $TID $? + +# 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 "null" + +_show_result $TID $ERR_CODEtools/testing/selftests/ublk/test_stress_05.sh +0
-0@@ -78,7 +78,14 @@ if _have_feature "PER_IO_DAEMON"; then ublk_io_and_remove 256M -t loop -q 4 --nthreads 8 --per_io_tasks -r 1 -i "$reissue" "${UBLK_BACKFILES[0]}" & ublk_io_and_remove 8G -t null -q 4 --nthreads 8 --per_io_tasks -r 1 -i "$reissue" & fi waitQuoted 9 lines
tools/testing/selftests/ublk/test_stress_05.sh if _have_feature "PER_IO_DAEMON"; then · line 88
Quoted 6 lines
tools/testing/selftests/ublk/test_stress_05.sh +6
-0+for reissue in $(seq 0 1); do + ublk_io_and_remove 8G -t null -q 4 -u -r 1 -i "$reissue" & + ublk_io_and_remove 256M -t loop -q 4 -u -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" & + ublk_io_and_remove 8G -t null -q 4 -u -r 1 -i "$reissue" & + wait +doneI'd suggest to not add new test coverage in old stress tests until default timeout is overrided, now it is close to default 45 seconds timeout.
Quoted 2 lines
Okay, I can just drop the changes in
test_stress_05.shif that sounds good to you?
Yeah, it is fine to drop it in test_stress_05.sh.
Thanks,
Ming