Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: ublk: add --batch/-b for enabling F_BATCH_IO

Add --batch/-b for enabling F_BATCH_IO.

Add batch_01 for covering its basic function.

Add stress_08 and stress_09 for covering stress test.

Add recovery test for F_BATCH_IO in generic_04 and generic_05.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Ming Lei and committed by
Jens Axboe
20aeab0b 4968fb7c

+148 -2
+4
tools/testing/selftests/ublk/Makefile
··· 25 25 TEST_PROGS += test_generic_15.sh 26 26 TEST_PROGS += test_generic_16.sh 27 27 28 + TEST_PROGS += test_batch_01.sh 29 + 28 30 TEST_PROGS += test_null_01.sh 29 31 TEST_PROGS += test_null_02.sh 30 32 TEST_PROGS += test_null_03.sh ··· 53 51 TEST_PROGS += test_stress_05.sh 54 52 TEST_PROGS += test_stress_06.sh 55 53 TEST_PROGS += test_stress_07.sh 54 + TEST_PROGS += test_stress_08.sh 55 + TEST_PROGS += test_stress_09.sh 56 56 57 57 TEST_FILES := settings 58 58
+13 -2
tools/testing/selftests/ublk/kublk.c
··· 1593 1593 FEAT_NAME(UBLK_F_PER_IO_DAEMON), 1594 1594 FEAT_NAME(UBLK_F_BUF_REG_OFF_DAEMON), 1595 1595 FEAT_NAME(UBLK_F_INTEGRITY), 1596 - FEAT_NAME(UBLK_F_SAFE_STOP_DEV) 1596 + FEAT_NAME(UBLK_F_SAFE_STOP_DEV), 1597 + FEAT_NAME(UBLK_F_BATCH_IO), 1597 1598 }; 1598 1599 struct ublk_dev *dev; 1599 1600 __u64 features = 0; ··· 1692 1691 printf("\t[--nthreads threads] [--per_io_tasks]\n"); 1693 1692 printf("\t[--integrity_capable] [--integrity_reftag] [--metadata_size SIZE] " 1694 1693 "[--pi_offset OFFSET] [--csum_type ip|t10dif|nvme] [--tag_size SIZE]\n"); 1694 + printf("\t[--batch|-b]\n"); 1695 1695 printf("\t[target options] [backfile1] [backfile2] ...\n"); 1696 1696 printf("\tdefault: nr_queues=2(max 32), depth=128(max 1024), dev_id=-1(auto allocation)\n"); 1697 1697 printf("\tdefault: nthreads=nr_queues"); ··· 1765 1763 { "csum_type", 1, NULL, 0 }, 1766 1764 { "tag_size", 1, NULL, 0 }, 1767 1765 { "safe", 0, NULL, 0 }, 1766 + { "batch", 0, NULL, 'b'}, 1768 1767 { 0, 0, 0, 0 } 1769 1768 }; 1770 1769 const struct ublk_tgt_ops *ops = NULL; ··· 1788 1785 1789 1786 opterr = 0; 1790 1787 optind = 2; 1791 - while ((opt = getopt_long(argc, argv, "t:n:d:q:r:e:i:s:gazu", 1788 + while ((opt = getopt_long(argc, argv, "t:n:d:q:r:e:i:s:gazub", 1792 1789 longopts, &option_idx)) != -1) { 1793 1790 switch (opt) { 1794 1791 case 'a': 1795 1792 ctx.all = 1; 1793 + break; 1794 + case 'b': 1795 + ctx.flags |= UBLK_F_BATCH_IO; 1796 1796 break; 1797 1797 case 'n': 1798 1798 ctx.dev_id = strtol(optarg, NULL, 10); ··· 1899 1893 optind += 1; 1900 1894 break; 1901 1895 } 1896 + } 1897 + 1898 + if (ctx.per_io_tasks && (ctx.flags & UBLK_F_BATCH_IO)) { 1899 + ublk_err("per_io_task and F_BATCH_IO conflict\n"); 1900 + return -EINVAL; 1902 1901 } 1903 1902 1904 1903 /* auto_zc_fallback depends on F_AUTO_BUF_REG & F_SUPPORT_ZERO_COPY */
+32
tools/testing/selftests/ublk/test_batch_01.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh 5 + 6 + TID="batch_01" 7 + ERR_CODE=0 8 + 9 + if ! _have_feature "BATCH_IO"; then 10 + exit "$UBLK_SKIP_CODE" 11 + fi 12 + 13 + _prep_test "generic" "test basic function of UBLK_F_BATCH_IO" 14 + 15 + _create_backfile 0 256M 16 + _create_backfile 1 256M 17 + 18 + dev_id=$(_add_ublk_dev -t loop -q 2 -b "${UBLK_BACKFILES[0]}") 19 + _check_add_dev $TID $? 20 + 21 + if ! _mkfs_mount_test /dev/ublkb"${dev_id}"; then 22 + _cleanup_test "generic" 23 + _show_result $TID 255 24 + fi 25 + 26 + dev_id=$(_add_ublk_dev -t stripe -b --auto_zc "${UBLK_BACKFILES[0]}" "${UBLK_BACKFILES[1]}") 27 + _check_add_dev $TID $? 28 + _mkfs_mount_test /dev/ublkb"${dev_id}" 29 + ERR_CODE=$? 30 + 31 + _cleanup_test "generic" 32 + _show_result $TID $ERR_CODE
+5
tools/testing/selftests/ublk/test_generic_04.sh
··· 26 26 _create_backfile 1 128M 27 27 _create_backfile 2 128M 28 28 29 + ublk_run_recover_test -t null -q 2 -r 1 -b & 30 + ublk_run_recover_test -t loop -q 2 -r 1 -b "${UBLK_BACKFILES[0]}" & 31 + ublk_run_recover_test -t stripe -q 2 -r 1 -b "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & 32 + wait 33 + 29 34 ublk_run_recover_test -t null -q 2 -r 1 & 30 35 ublk_run_recover_test -t loop -q 2 -r 1 "${UBLK_BACKFILES[0]}" & 31 36 ublk_run_recover_test -t stripe -q 2 -r 1 "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" &
+5
tools/testing/selftests/ublk/test_generic_05.sh
··· 30 30 _create_backfile 1 128M 31 31 _create_backfile 2 128M 32 32 33 + ublk_run_recover_test -t null -q 2 -r 1 -z -b & 34 + ublk_run_recover_test -t loop -q 2 -r 1 -z -b "${UBLK_BACKFILES[0]}" & 35 + ublk_run_recover_test -t stripe -q 2 -r 1 -z -b "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & 36 + wait 37 + 33 38 ublk_run_recover_test -t null -q 2 -r 1 -z & 34 39 ublk_run_recover_test -t loop -q 2 -r 1 -z "${UBLK_BACKFILES[0]}" & 35 40 ublk_run_recover_test -t stripe -q 2 -r 1 -z "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" &
+45
tools/testing/selftests/ublk/test_stress_08.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh 5 + TID="stress_06" 6 + ERR_CODE=0 7 + 8 + ublk_io_and_remove() 9 + { 10 + run_io_and_remove "$@" 11 + ERR_CODE=$? 12 + if [ ${ERR_CODE} -ne 0 ]; then 13 + echo "$TID failure: $*" 14 + _show_result $TID $ERR_CODE 15 + fi 16 + } 17 + 18 + if ! _have_program fio; then 19 + exit "$UBLK_SKIP_CODE" 20 + fi 21 + 22 + if ! _have_feature "ZERO_COPY"; then 23 + exit "$UBLK_SKIP_CODE" 24 + fi 25 + if ! _have_feature "AUTO_BUF_REG"; then 26 + exit "$UBLK_SKIP_CODE" 27 + fi 28 + if ! _have_feature "BATCH_IO"; then 29 + exit "$UBLK_SKIP_CODE" 30 + fi 31 + 32 + _prep_test "stress" "run IO and remove device(zero copy)" 33 + 34 + _create_backfile 0 256M 35 + _create_backfile 1 128M 36 + _create_backfile 2 128M 37 + 38 + ublk_io_and_remove 8G -t null -q 4 -b & 39 + ublk_io_and_remove 256M -t loop -q 4 --auto_zc -b "${UBLK_BACKFILES[0]}" & 40 + ublk_io_and_remove 256M -t stripe -q 4 --auto_zc -b "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & 41 + ublk_io_and_remove 8G -t null -q 4 -z --auto_zc --auto_zc_fallback -b & 42 + wait 43 + 44 + _cleanup_test "stress" 45 + _show_result $TID $ERR_CODE
+44
tools/testing/selftests/ublk/test_stress_09.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh 5 + TID="stress_07" 6 + ERR_CODE=0 7 + 8 + ublk_io_and_kill_daemon() 9 + { 10 + run_io_and_kill_daemon "$@" 11 + ERR_CODE=$? 12 + if [ ${ERR_CODE} -ne 0 ]; then 13 + echo "$TID failure: $*" 14 + _show_result $TID $ERR_CODE 15 + fi 16 + } 17 + 18 + if ! _have_program fio; then 19 + exit "$UBLK_SKIP_CODE" 20 + fi 21 + if ! _have_feature "ZERO_COPY"; then 22 + exit "$UBLK_SKIP_CODE" 23 + fi 24 + if ! _have_feature "AUTO_BUF_REG"; then 25 + exit "$UBLK_SKIP_CODE" 26 + fi 27 + if ! _have_feature "BATCH_IO"; then 28 + exit "$UBLK_SKIP_CODE" 29 + fi 30 + 31 + _prep_test "stress" "run IO and kill ublk server(zero copy)" 32 + 33 + _create_backfile 0 256M 34 + _create_backfile 1 128M 35 + _create_backfile 2 128M 36 + 37 + ublk_io_and_kill_daemon 8G -t null -q 4 -z -b & 38 + ublk_io_and_kill_daemon 256M -t loop -q 4 --auto_zc -b "${UBLK_BACKFILES[0]}" & 39 + ublk_io_and_kill_daemon 256M -t stripe -q 4 -b "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" & 40 + ublk_io_and_kill_daemon 8G -t null -q 4 -z --auto_zc --auto_zc_fallback -b & 41 + wait 42 + 43 + _cleanup_test "stress" 44 + _show_result $TID $ERR_CODE