Skip to content

Commit 52bc483

Browse files
calebsanderaxboe
authored andcommitted
selftests: ublk: forbid multiple data copy modes
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_zc over zero_copy over get_data). To clarify the intent of the test, don't allow multiple data copy modes to be specified. --zero_copy and --auto_zc are allowed together for --auto_zc_fallback, which uses both copy modes. Don't set UBLK_F_USER_COPY for zero_copy, as it's a separate feature. Fix the test cases in test_stress_05 passing --get_data along with --zero_copy or --auto_zc. Signed-off-by: Caleb Sander Mateos <csander@purestorage.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent d829540 commit 52bc483

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

tools/testing/selftests/ublk/kublk.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,7 @@ int main(int argc, char *argv[])
16131613
ctx.queue_depth = strtol(optarg, NULL, 10);
16141614
break;
16151615
case 'z':
1616-
ctx.flags |= UBLK_F_SUPPORT_ZERO_COPY | UBLK_F_USER_COPY;
1616+
ctx.flags |= UBLK_F_SUPPORT_ZERO_COPY;
16171617
break;
16181618
case 'r':
16191619
value = strtol(optarg, NULL, 10);
@@ -1686,6 +1686,15 @@ int main(int argc, char *argv[])
16861686
return -EINVAL;
16871687
}
16881688

1689+
if (!!(ctx.flags & UBLK_F_NEED_GET_DATA) +
1690+
!!(ctx.flags & UBLK_F_USER_COPY) +
1691+
(ctx.flags & UBLK_F_SUPPORT_ZERO_COPY && !ctx.auto_zc_fallback) +
1692+
(ctx.flags & UBLK_F_AUTO_BUF_REG && !ctx.auto_zc_fallback) +
1693+
ctx.auto_zc_fallback > 1) {
1694+
fprintf(stderr, "too many data copy modes specified\n");
1695+
return -EINVAL;
1696+
}
1697+
16891698
i = optind;
16901699
while (i < argc && ctx.nr_files < MAX_BACK_FILES) {
16911700
ctx.files[ctx.nr_files++] = argv[i++];

tools/testing/selftests/ublk/test_stress_05.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ done
5858

5959
if _have_feature "ZERO_COPY"; then
6060
for reissue in $(seq 0 1); do
61-
ublk_io_and_remove 8G -t null -q 4 -g -z -r 1 -i "$reissue" &
62-
ublk_io_and_remove 256M -t loop -q 4 -g -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" &
61+
ublk_io_and_remove 8G -t null -q 4 -z -r 1 -i "$reissue" &
62+
ublk_io_and_remove 256M -t loop -q 4 -z -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" &
6363
wait
6464
done
6565
fi
6666

6767
if _have_feature "AUTO_BUF_REG"; then
6868
for reissue in $(seq 0 1); do
69-
ublk_io_and_remove 8G -t null -q 4 -g --auto_zc -r 1 -i "$reissue" &
70-
ublk_io_and_remove 256M -t loop -q 4 -g --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" &
71-
ublk_io_and_remove 8G -t null -q 4 -g -z --auto_zc --auto_zc_fallback -r 1 -i "$reissue" &
69+
ublk_io_and_remove 8G -t null -q 4 --auto_zc -r 1 -i "$reissue" &
70+
ublk_io_and_remove 256M -t loop -q 4 --auto_zc -r 1 -i "$reissue" "${UBLK_BACKFILES[1]}" &
71+
ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback -r 1 -i "$reissue" &
7272
wait
7373
done
7474
fi

0 commit comments

Comments
 (0)