From 844c8ec38356933ebddd46757fe3c43d9298e7de Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Thu, 7 May 2020 13:27:06 +0200 Subject: [PATCH] check_format: Reformat the Bash code in compliance with shfmt Change-Id: I93e7b9d355870b0528a0ac3382fba1a10a558d45 Signed-off-by: Michal Berger Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1718 Community-CI: Mellanox Build Bot Reviewed-by: Karol Latecki Reviewed-by: Aleksey Marchuk Reviewed-by: Ben Walker Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- autobuild.sh | 18 +- autotest.sh | 26 +- scripts/ceph/start.sh | 16 +- scripts/check_format.sh | 37 +- scripts/common.sh | 72 +- scripts/detect_cc.sh | 16 +- scripts/gen_ftl.sh | 25 +- scripts/gen_nvme.sh | 14 +- scripts/pkgdep.sh | 56 +- scripts/prep_benchmarks.sh | 2 +- scripts/qat_setup.sh | 6 +- scripts/setup.sh | 252 ++-- scripts/vagrant/create_nvme_img.sh | 18 +- scripts/vagrant/create_vbox.sh | 90 +- scripts/vagrant/create_vhost_vm.sh | 47 +- scripts/vagrant/run-autorun.sh | 35 +- scripts/vagrant/update.sh | 10 +- test/bdev/bdev_raid.sh | 12 +- test/bdev/blockdev.sh | 90 +- test/bdev/nbd_common.sh | 6 +- test/blobfs/blobfs.sh | 8 +- test/blobfs/rocksdb/rocksdb.sh | 12 +- test/blobstore/blob_io_wait/blob_io_wait.sh | 6 +- test/blobstore/blobstore.sh | 10 +- test/common/applications.sh | 4 +- test/common/autotest_common.sh | 262 ++-- test/common/config/vm_setup.sh | 1247 +++++++++-------- test/compress/compress.sh | 12 +- test/ftl/bdevperf.sh | 2 +- test/ftl/common.sh | 18 +- test/ftl/dirty_shutdown.sh | 10 +- test/ftl/fio.sh | 5 +- test/ftl/ftl.sh | 5 +- test/ftl/json.sh | 3 +- test/ftl/restore.sh | 10 +- test/fuzz/autofuzz.sh | 4 +- test/fuzz/autofuzz_iscsi.sh | 13 +- test/fuzz/autofuzz_nvmf.sh | 13 +- test/fuzz/autofuzz_vhost.sh | 41 +- test/iscsi_tgt/common.sh | 22 +- test/iscsi_tgt/ext4test/ext4test.sh | 2 +- test/iscsi_tgt/filesystem/filesystem.sh | 2 +- test/iscsi_tgt/fio/fio.sh | 3 +- test/iscsi_tgt/fuzz/fuzz.sh | 2 +- test/iscsi_tgt/initiator/initiator.sh | 6 +- test/iscsi_tgt/ip_migration/ip_migration.sh | 8 +- test/iscsi_tgt/lvol/iscsi_lvol.sh | 2 +- test/iscsi_tgt/perf/iscsi_initiator.sh | 5 +- test/iscsi_tgt/perf/iscsi_target.sh | 53 +- test/iscsi_tgt/qos/qos.sh | 24 +- test/iscsi_tgt/rbd/rbd.sh | 6 +- test/iscsi_tgt/sock/sock.sh | 22 +- test/iscsi_tgt/trace_record/trace_record.sh | 26 +- test/json_config/json_config.sh | 130 +- test/lvol/basic.sh | 74 +- test/lvol/common.sh | 8 +- test/lvol/hotremove.sh | 6 +- test/lvol/rename.sh | 30 +- test/lvol/resize.sh | 62 +- test/lvol/snapshot_clone.sh | 100 +- test/lvol/tasting.sh | 24 +- test/lvol/thin_provisioning.sh | 52 +- test/make/check_so_deps.sh | 17 +- test/nvme/hotplug.sh | 7 +- test/nvme/hw_hotplug.sh | 2 +- test/nvme/nvme.sh | 8 +- test/nvme/perf/common.sh | 241 ++-- test/nvme/perf/run_perf.sh | 21 +- test/nvme/spdk_nvme_cli.sh | 4 +- test/nvme/spdk_nvme_cli_cuse.sh | 8 +- test/nvme/spdk_smartctl_cuse.sh | 18 +- test/nvmf/common.sh | 81 +- test/nvmf/host/bdevperf.sh | 4 +- test/nvmf/host/target_disconnect.sh | 16 +- test/nvmf/nvmf.sh | 2 +- test/nvmf/target/bdev_io_wait.sh | 4 +- test/nvmf/target/bdevio.sh | 2 +- test/nvmf/target/discovery.sh | 2 +- test/nvmf/target/filesystem.sh | 8 +- test/nvmf/target/fio.sh | 6 +- test/nvmf/target/fuzz.sh | 6 +- test/nvmf/target/identify_passthru.sh | 6 +- test/nvmf/target/initiator_timeout.sh | 8 +- test/nvmf/target/invalid.sh | 6 +- test/nvmf/target/multiconnection.sh | 3 +- test/nvmf/target/multitarget.sh | 6 +- test/nvmf/target/nvme_cli.sh | 8 +- test/nvmf/target/nvmf_example.sh | 32 +- test/nvmf/target/nvmf_vhost.sh | 2 +- test/nvmf/target/rpc.sh | 36 +- test/nvmf/target/shutdown.sh | 10 +- test/ocf/common.sh | 4 +- test/ocf/integrity/fio-modes.sh | 4 +- test/ocf/management/create-destruct.sh | 27 +- test/ocf/management/multicore.sh | 14 +- test/ocf/management/persistent-metadata.sh | 4 +- test/ocf/management/remove.sh | 2 +- test/openstack/install_devstack.sh | 23 +- test/openstack/run_openstack_tests.sh | 10 +- test/pmem/common.sh | 21 +- test/pmem/pmem.sh | 137 +- test/spdkcli/tcp.sh | 6 +- test/spdkcli/virtio.sh | 8 +- test/unit/unittest.sh | 26 +- test/vhost/common.sh | 272 ++-- test/vhost/fiotest/fio.sh | 50 +- test/vhost/fuzz/fuzz.sh | 6 +- test/vhost/hotplug/blk_hotremove.sh | 348 ++--- test/vhost/hotplug/common.sh | 293 ++-- test/vhost/hotplug/scsi_hotattach.sh | 108 +- test/vhost/hotplug/scsi_hotdetach.sh | 305 ++-- test/vhost/hotplug/scsi_hotplug.sh | 94 +- test/vhost/hotplug/scsi_hotremove.sh | 346 ++--- test/vhost/initiator/blockdev.sh | 7 +- test/vhost/integrity/integrity_start.sh | 35 +- test/vhost/integrity/integrity_vm.sh | 25 +- test/vhost/lvol/lvol_test.sh | 337 ++--- test/vhost/manual.sh | 14 +- test/vhost/migration/migration-tc1.sh | 14 +- test/vhost/migration/migration-tc2.sh | 21 +- test/vhost/migration/migration-tc3a.sh | 41 +- test/vhost/migration/migration-tc3b.sh | 8 +- test/vhost/migration/migration.sh | 27 +- test/vhost/other/negative.sh | 30 +- test/vhost/perf_bench/vhost_perf.sh | 127 +- test/vhost/readonly/delete_partition_vm.sh | 5 +- test/vhost/readonly/disabled_readonly_vm.sh | 5 +- test/vhost/readonly/enabled_readonly_vm.sh | 5 +- test/vhost/readonly/readonly.sh | 46 +- test/vhost/shared/shared.sh | 4 +- test/vhost/vhost.sh | 36 +- test/vhost/vhost_boot/vhost_boot.sh | 21 +- test/vhost/windows/windows.sh | 35 +- test/vhost/windows/windows_scsi_compliance.sh | 26 +- test/vmd/vmd.sh | 12 +- 135 files changed, 3368 insertions(+), 3397 deletions(-) diff --git a/autobuild.sh b/autobuild.sh index e2a50cdbb0..cd49c0a046 100755 --- a/autobuild.sh +++ b/autobuild.sh @@ -35,7 +35,7 @@ $MAKE cc_version $MAKE cxx_version echo "** END ** Info for Hostname: $HOSTNAME" -function ocf_precompile { +function ocf_precompile() { # We compile OCF sources ourselves # They don't need to be checked with scanbuild and code coverage is not applicable # So we precompile OCF now for further use as standalone static library @@ -48,7 +48,7 @@ function ocf_precompile { ./configure $config_params } -function make_fail_cleanup { +function make_fail_cleanup() { if [ -d $out/scan-build-tmp ]; then scanoutput=$(ls -1 $out/scan-build-tmp/) mv $out/scan-build-tmp/$scanoutput $out/scan-build @@ -58,7 +58,7 @@ function make_fail_cleanup { false } -function scanbuild_make { +function scanbuild_make() { pass=true $scanbuild $MAKE $MAKEFLAGS > $out/build_output.txt && rm -rf $out/scan-build-tmp || make_fail_cleanup xtrace_disable @@ -92,7 +92,7 @@ function scanbuild_make { $pass } -function porcelain_check { +function porcelain_check() { if [ $(git status --porcelain --ignore-submodules | wc -l) -ne 0 ]; then echo "Generated files missing from .gitignore:" git status --porcelain --ignore-submodules @@ -103,7 +103,7 @@ function porcelain_check { # Check that header file dependencies are working correctly by # capturing a binary's stat data before and after touching a # header file and re-making. -function header_dependency_check { +function header_dependency_check() { STAT1=$(stat app/spdk_tgt/spdk_tgt) sleep 1 touch lib/nvme/nvme_internal.h @@ -116,7 +116,7 @@ function header_dependency_check { fi } -function test_make_uninstall { +function test_make_uninstall() { # Create empty file to check if it is not deleted by target uninstall touch "$SPDK_WORKSPACE/usr/lib/sample_xyz.a" $MAKE $MAKEFLAGS uninstall DESTDIR="$SPDK_WORKSPACE" prefix=/usr @@ -127,14 +127,14 @@ function test_make_uninstall { fi } -function build_doc { +function build_doc() { $MAKE -C "$rootdir"/doc --no-print-directory $MAKEFLAGS &> "$out"/doxygen.log if [ -s "$out"/doxygen.log ]; then cat "$out"/doxygen.log echo "Doxygen errors found!" exit 1 fi - if hash pdflatex 2>/dev/null; then + if hash pdflatex 2> /dev/null; then $MAKE -C "$rootdir"/doc/output/latex --no-print-directory $MAKEFLAGS &>> "$out"/doxygen.log fi mkdir -p "$out"/doc @@ -149,7 +149,7 @@ function build_doc { rm -rf "$rootdir"/doc/output } -function autobuild_test_suite { +function autobuild_test_suite() { run_test "autobuild_check_format" ./scripts/check_format.sh run_test "autobuild_external_code" sudo -E $rootdir/test/external_code/test_make.sh $rootdir if [ "$SPDK_TEST_OCF" -eq 1 ]; then diff --git a/autotest.sh b/autotest.sh index af7f1668f1..f6efa9f6b9 100755 --- a/autotest.sh +++ b/autotest.sh @@ -82,17 +82,15 @@ if [ $(uname -s) = Linux ]; then # If some OCSSD device is bound to other driver than nvme we won't be able to # discover if it is OCSSD or not so load the kernel driver first. - - while IFS= read -r -d '' dev - do + while IFS= read -r -d '' dev; do # Send Open Channel 2.0 Geometry opcode "0xe2" - not supported by NVMe device. - if nvme admin-passthru $dev --namespace-id=1 --data-len=4096 --opcode=0xe2 --read >/dev/null; then + if nvme admin-passthru $dev --namespace-id=1 --data-len=4096 --opcode=0xe2 --read > /dev/null; then bdf="$(basename $(readlink -e /sys/class/nvme/${dev#/dev/}/device))" echo "INFO: blacklisting OCSSD device: $dev ($bdf)" PCI_BLACKLIST+=" $bdf" OCSSD_PCI_DEVICES+=" $bdf" fi - done < <(find /dev -maxdepth 1 -regex '/dev/nvme[0-9]+' -print0) + done < <(find /dev -maxdepth 1 -regex '/dev/nvme[0-9]+' -print0) export OCSSD_PCI_DEVICES @@ -102,8 +100,8 @@ if [ $(uname -s) = Linux ]; then if [[ -n "$PCI_BLACKLIST" ]]; then # shellcheck disable=SC2097,SC2098 PCI_WHITELIST="$PCI_BLACKLIST" \ - PCI_BLACKLIST="" \ - DRIVER_OVERRIDE="pci-stub" \ + PCI_BLACKLIST="" \ + DRIVER_OVERRIDE="pci-stub" \ ./scripts/setup.sh # Export our blacklist so it will take effect during next setup.sh @@ -161,7 +159,7 @@ if [ $SPDK_RUN_FUNCTIONAL_TEST -eq 1 ]; then run_test "json_config" ./test/json_config/json_config.sh run_test "alias_rpc" test/json_config/alias_rpc/alias_rpc.sh run_test "spdkcli_tcp" test/spdkcli/tcp.sh - run_test "dpdk_mem_utility" test/dpdk_memory_utility/test_dpdk_mem_info.sh + run_test "dpdk_mem_utility" test/dpdk_memory_utility/test_dpdk_mem_info.sh run_test "event" test/event/event.sh if [ $SPDK_TEST_BLOCKDEV -eq 1 ]; then @@ -231,8 +229,8 @@ if [ $SPDK_RUN_FUNCTIONAL_TEST -eq 1 ]; then run_test "spdkcli_nvmf_tcp" ./test/spdkcli/nvmf.sh run_test "nvmf_identify_passthru" test/nvmf/target/identify_passthru.sh --transport=$SPDK_TEST_NVMF_TRANSPORT elif [ "$SPDK_TEST_NVMF_TRANSPORT" = "fc" ]; then - run_test "nvmf_fc" ./test/nvmf/nvmf.sh --transport=$SPDK_TEST_NVMF_TRANSPORT - run_test "spdkcli_nvmf_fc" ./test/spdkcli/nvmf.sh + run_test "nvmf_fc" ./test/nvmf/nvmf.sh --transport=$SPDK_TEST_NVMF_TRANSPORT + run_test "spdkcli_nvmf_fc" ./test/spdkcli/nvmf.sh else echo "unknown NVMe transport, please specify rdma, tcp, or fc." exit 1 @@ -280,10 +278,10 @@ if [ $SPDK_RUN_FUNCTIONAL_TEST -eq 1 ]; then run_test "vmd" ./test/vmd/vmd.sh fi - if [ $SPDK_TEST_REDUCE -eq 1 ]; then - run_test "compress_qat" ./test/compress/compress.sh "qat" - run_test "compress_isal" ./test/compress/compress.sh "isal" - fi + if [ $SPDK_TEST_REDUCE -eq 1 ]; then + run_test "compress_qat" ./test/compress/compress.sh "qat" + run_test "compress_isal" ./test/compress/compress.sh "isal" + fi if [ $SPDK_TEST_OPAL -eq 1 ]; then run_test "nvme_opal" ./test/nvme/nvme_opal.sh diff --git a/scripts/ceph/start.sh b/scripts/ceph/start.sh index f3bb757c66..edff469f39 100755 --- a/scripts/ceph/start.sh +++ b/scripts/ceph/start.sh @@ -26,7 +26,7 @@ mkdir ${base_dir} cp ${script_dir}/ceph.conf $ceph_conf if [ ! -e $image ]; then - fallocate -l 4G $image + fallocate -l 4G $image fi mknod ${dev} b 7 200 || true @@ -39,8 +39,8 @@ echo "Partitioning ${dev}" ${PARTED} ${dev} mktable gpt sleep 2 -${PARTED} ${dev} mkpart primary 0% 2GiB -${PARTED} ${dev} mkpart primary 2GiB 100% +${PARTED} ${dev} mkpart primary 0% 2GiB +${PARTED} ${dev} mkpart primary 2GiB 100% partno=0 echo "Setting name on ${dev}" @@ -91,7 +91,7 @@ monmaptool --create --clobber --add a ${mon_ip}:12046 --print ${base_dir}/monmap sh -c "ulimit -c unlimited && exec ceph-mon --mkfs -c ${ceph_conf} -i a --monmap=${base_dir}/monmap --keyring=${base_dir}/keyring --mon-data=${mon_dir}" -if [ $update_config = true ] ;then +if [ $update_config = true ]; then sed -i 's/mon addr = /mon addr = v2:/g' $ceph_conf fi @@ -106,13 +106,13 @@ chmod a+r /etc/ceph/ceph.client.admin.keyring ceph-run sh -c "ulimit -n 16384 && ulimit -c unlimited && exec ceph-mon -c ${ceph_conf} -i a --keyring=${base_dir}/keyring --pid-file=${base_dir}/pid/root@$(hostname).pid --mon-data=${mon_dir}" || true # after ceph-mon creation, ceph -s should work. -if [ $update_config = true ] ;then - # start to get whole log. +if [ $update_config = true ]; then + # start to get whole log. ceph-conf --name mon.a --show-config-value log_file # add fsid to ceph config file. - fsid=$(ceph -s | grep id |awk '{print $2}') - sed -i 's/perf = true/perf = true\n\tfsid = '$fsid' \n/g' $ceph_conf + fsid=$(ceph -s | grep id | awk '{print $2}') + sed -i 's/perf = true/perf = true\n\tfsid = '$fsid' \n/g' $ceph_conf # unify the filesystem with the old versions. sed -i 's/perf = true/perf = true\n\tosd objectstore = filestore\n/g' $ceph_conf diff --git a/scripts/check_format.sh b/scripts/check_format.sh index ff510a8ff8..6eee1bf639 100755 --- a/scripts/check_format.sh +++ b/scripts/check_format.sh @@ -6,16 +6,16 @@ cd $BASEDIR # exit on errors set -e -if ! hash nproc 2>/dev/null; then +if ! hash nproc 2> /dev/null; then -function nproc() { - echo 8 -} + function nproc() { + echo 8 + } fi function version_lt() { - [ $( echo -e "$1\n$2" | sort -V | head -1 ) != "$1" ] + [ $(echo -e "$1\n$2" | sort -V | head -1) != "$1" ] } rc=0 @@ -30,13 +30,13 @@ while read -r perm _res0 _res1 path; do fname=$(basename -- "$path") case ${fname##*.} in - c|h|cpp|cc|cxx|hh|hpp|md|html|js|json|svg|Doxyfile|yml|LICENSE|README|conf|in|Makefile|mk|gitignore|go|txt) + c | h | cpp | cc | cxx | hh | hpp | md | html | js | json | svg | Doxyfile | yml | LICENSE | README | conf | in | Makefile | mk | gitignore | go | txt) # These file types should never be executable if [ "$perm" -eq 100755 ]; then echo "ERROR: $path is marked executable but is a code file." rc=1 fi - ;; + ;; *) shebang=$(head -n 1 $path | cut -c1-3) @@ -54,7 +54,7 @@ while read -r perm _res0 _res1 path; do rc=1 fi fi - ;; + ;; esac done <<< "$(git grep -I --name-only --untracked -e . | git ls-files -s)" @@ -65,8 +65,7 @@ fi if hash astyle; then echo -n "Checking coding style..." - if [ "$(astyle -V)" \< "Artistic Style Version 3" ] - then + if [ "$(astyle -V)" \< "Artistic Style Version 3" ]; then echo -n " Your astyle version is too old so skipping coding style checks. Please update astyle to at least 3.0.1 version..." else rm -f astyle.log @@ -75,9 +74,9 @@ if hash astyle; then # as-is to enable ongoing work to synch with a generic upstream DPDK vhost library, # rather than making diffs more complicated by a lot of changes to follow SPDK # coding standards. - git ls-files '*.[ch]' '*.cpp' '*.cc' '*.cxx' '*.hh' '*.hpp' | \ - grep -v rte_vhost | grep -v cpp_headers | \ - xargs -P$(nproc) -n10 astyle --options=.astylerc >> astyle.log + git ls-files '*.[ch]' '*.cpp' '*.cc' '*.cxx' '*.hh' '*.hpp' \ + | grep -v rte_vhost | grep -v cpp_headers \ + | xargs -P$(nproc) -n10 astyle --options=.astylerc >> astyle.log if grep -q "^Formatted" astyle.log; then echo " errors detected" git diff @@ -96,7 +95,7 @@ else echo "You do not have astyle installed so your code style is not being checked!" fi -GIT_VERSION=$( git --version | cut -d' ' -f3 ) +GIT_VERSION=$(git --version | cut -d' ' -f3) if version_lt "1.9.5" "${GIT_VERSION}"; then # git <1.9.5 doesn't support pathspec magic exclude @@ -171,8 +170,8 @@ rm -f badcunit.log echo -n "Checking blank lines at end of file..." -if ! git grep -I -l -e . -z './*' ':!*.patch' | \ - xargs -0 -P$(nproc) -n1 scripts/eofnl > eofnl.log; then +if ! git grep -I -l -e . -z './*' ':!*.patch' \ + | xargs -0 -P$(nproc) -n1 scripts/eofnl > eofnl.log; then echo " Incorrect end-of-file formatting detected" cat eofnl.log rc=1 @@ -203,9 +202,9 @@ else fi rm -f scripts/includes.log -if hash pycodestyle 2>/dev/null; then +if hash pycodestyle 2> /dev/null; then PEP8=pycodestyle -elif hash pep8 2>/dev/null; then +elif hash pep8 2> /dev/null; then PEP8=pep8 fi @@ -228,7 +227,7 @@ else echo "You do not have pycodestyle or pep8 installed so your Python style is not being checked!" fi -if hash shellcheck 2>/dev/null; then +if hash shellcheck 2> /dev/null; then echo -n "Checking Bash style..." shellcheck_v=$(shellcheck --version | grep -P "version: [0-9\.]+" | cut -d " " -f2) diff --git a/scripts/common.sh b/scripts/common.sh index c4bd8d9300..e641b2ce50 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -10,7 +10,7 @@ function pci_can_use() { local i # The '\ ' part is important - if [[ " $PCI_BLACKLIST " =~ \ $1\ ]] ; then + if [[ " $PCI_BLACKLIST " =~ \ $1\ ]]; then return 1 fi @@ -20,7 +20,7 @@ function pci_can_use() { fi for i in $PCI_WHITELIST; do - if [ "$i" == "$1" ] ; then + if [ "$i" == "$1" ]; then return 0 fi done @@ -28,7 +28,7 @@ function pci_can_use() { return 1 } -cache_pci_init () { +cache_pci_init() { local -gA pci_bus_cache [[ -z ${pci_bus_cache[*]} || $CMD == reset ]] || return 1 @@ -36,22 +36,22 @@ cache_pci_init () { pci_bus_cache=() } -cache_pci () { +cache_pci() { local pci=$1 class=$2 vendor=$3 device=$4 if [[ -n $class ]]; then - class=0x${class/0x} + class=0x${class/0x/} pci_bus_cache["$class"]="${pci_bus_cache["$class"]:+${pci_bus_cache["$class"]} }$pci" fi if [[ -n $vendor && -n $device ]]; then - vendor=0x${vendor/0x} device=0x${device/0x} + vendor=0x${vendor/0x/} device=0x${device/0x/} pci_bus_cache["$vendor"]="${pci_bus_cache["$vendor"]:+${pci_bus_cache["$vendor"]} }$pci" pci_bus_cache["$device"]="${pci_bus_cache["$device"]:+${pci_bus_cache["$device"]} }$pci" pci_bus_cache["$vendor:$device"]="${pci_bus_cache["$vendor:$device"]:+${pci_bus_cache["$vendor:$device"]} }$pci" fi } -cache_pci_bus_sysfs () { +cache_pci_bus_sysfs() { [[ -e /sys/bus/pci/devices ]] || return 1 cache_pci_init || return 0 @@ -60,13 +60,13 @@ cache_pci_bus_sysfs () { local class vendor device for pci in /sys/bus/pci/devices/*; do - class=$(<"$pci/class") vendor=$(<"$pci/vendor") device=$(<"$pci/device") + class=$(< "$pci/class") vendor=$(< "$pci/vendor") device=$(< "$pci/device") cache_pci "${pci##*/}" "$class" "$vendor" "$device" done } -cache_pci_bus_lspci () { - hash lspci 2>/dev/null || return 1 +cache_pci_bus_lspci() { + hash lspci 2> /dev/null || return 1 cache_pci_init || return 0 @@ -86,8 +86,8 @@ cache_pci_bus_lspci () { done < <(lspci -Dnmm) } -cache_pci_bus_pciconf () { - hash pciconf 2>/dev/null || return 1 +cache_pci_bus_pciconf() { + hash pciconf 2> /dev/null || return 1 cache_pci_init || return 0 @@ -95,25 +95,25 @@ cache_pci_bus_pciconf () { local pci domain bus device function while read -r pci class _ vd _; do - IFS=":" read -r domain bus device function _ <<<"${pci##*pci}" + IFS=":" read -r domain bus device function _ <<< "${pci##*pci}" pci=$(printf '%04x:%02x:%02x:%x' \ "$domain" "$bus" "$device" "$function") - class=$(printf '0x%06x' $(( class ))) - vendor=$(printf '0x%04x' $(( vd & 0xffff ))) - device=$(printf '0x%04x' $(( (vd >> 16) & 0xffff ))) + class=$(printf '0x%06x' $((class))) + vendor=$(printf '0x%04x' $((vd & 0xffff))) + device=$(printf '0x%04x' $(((vd >> 16) & 0xffff))) cache_pci "$pci" "$class" "$vendor" "$device" done < <(pciconf -l) } -cache_pci_bus () { +cache_pci_bus() { case "$(uname -s)" in Linux) cache_pci_bus_lspci || cache_pci_bus_sysfs ;; FreeBSD) cache_pci_bus_pciconf ;; esac } -iter_all_pci_sysfs () { +iter_all_pci_sysfs() { cache_pci_bus_sysfs || return 1 # default to class of the nvme devices @@ -121,9 +121,9 @@ iter_all_pci_sysfs () { local pci pcis [[ -n ${pci_bus_cache["$find"]} ]] || return 0 - read -ra pcis <<<"${pci_bus_cache["$find"]}" + read -ra pcis <<< "${pci_bus_cache["$find"]}" - if (( findx )); then + if ((findx)); then printf '%s\n' "${pcis[@]::findx}" else printf '%s\n' "${pcis[@]}" @@ -139,22 +139,22 @@ function iter_all_pci_class_code() { subclass="$(printf %02x $((0x$2)))" progif="$(printf %02x $((0x$3)))" - if hash lspci &>/dev/null; then + if hash lspci &> /dev/null; then if [ "$progif" != "00" ]; then - lspci -mm -n -D | \ - grep -i -- "-p${progif}" | \ - awk -v cc="\"${class}${subclass}\"" -F " " \ - '{if (cc ~ $2) print $1}' | tr -d '"' + lspci -mm -n -D \ + | grep -i -- "-p${progif}" \ + | awk -v cc="\"${class}${subclass}\"" -F " " \ + '{if (cc ~ $2) print $1}' | tr -d '"' else - lspci -mm -n -D | \ - awk -v cc="\"${class}${subclass}\"" -F " " \ - '{if (cc ~ $2) print $1}' | tr -d '"' + lspci -mm -n -D \ + | awk -v cc="\"${class}${subclass}\"" -F " " \ + '{if (cc ~ $2) print $1}' | tr -d '"' fi - elif hash pciconf &>/dev/null; then - local addr=($(pciconf -l | grep -i "class=0x${class}${subclass}${progif}" | \ - cut -d$'\t' -f1 | sed -e 's/^[a-zA-Z0-9_]*@pci//g' | tr ':' ' ')) + elif hash pciconf &> /dev/null; then + local addr=($(pciconf -l | grep -i "class=0x${class}${subclass}${progif}" \ + | cut -d$'\t' -f1 | sed -e 's/^[a-zA-Z0-9_]*@pci//g' | tr ':' ' ')) printf "%04x:%02x:%02x:%x\n" ${addr[0]} ${addr[1]} ${addr[2]} ${addr[3]} - elif iter_all_pci_sysfs "$(printf '0x%06x' $(( 0x$progif | 0x$subclass << 8 | 0x$class << 16 )))"; then + elif iter_all_pci_sysfs "$(printf '0x%06x' $((0x$progif | 0x$subclass << 8 | 0x$class << 16)))"; then : else echo "Missing PCI enumeration utility" >&2 @@ -169,12 +169,12 @@ function iter_all_pci_dev_id() { ven_id="$(printf %04x $((0x$1)))" dev_id="$(printf %04x $((0x$2)))" - if hash lspci &>/dev/null; then + if hash lspci &> /dev/null; then lspci -mm -n -D | awk -v ven="\"$ven_id\"" -v dev="\"${dev_id}\"" -F " " \ '{if (ven ~ $3 && dev ~ $4) print $1}' | tr -d '"' - elif hash pciconf &>/dev/null; then - local addr=($(pciconf -l | grep -i "chip=0x${dev_id}${ven_id}" | \ - cut -d$'\t' -f1 | sed -e 's/^[a-zA-Z0-9_]*@pci//g' | tr ':' ' ')) + elif hash pciconf &> /dev/null; then + local addr=($(pciconf -l | grep -i "chip=0x${dev_id}${ven_id}" \ + | cut -d$'\t' -f1 | sed -e 's/^[a-zA-Z0-9_]*@pci//g' | tr ':' ' ')) printf "%04x:%02x:%02x:%x\n" ${addr[0]} ${addr[1]} ${addr[2]} ${addr[3]} elif iter_all_pci_sysfs "0x$ven_id:0x$dev_id"; then : diff --git a/scripts/detect_cc.sh b/scripts/detect_cc.sh index 45fd518839..a05ff9adf2 100755 --- a/scripts/detect_cc.sh +++ b/scripts/detect_cc.sh @@ -2,13 +2,11 @@ set -e -function err() -{ +function err() { echo "$@" >&2 } -function usage() -{ +function usage() { err "Detect compiler and linker versions, generate mk/cc.mk" err "" err "Usage: ./detect_cc.sh [OPTION]..." @@ -24,11 +22,9 @@ function usage() err " --cross-prefix=prefix Use the given prefix for the cross compiler toolchain" } - - for i in "$@"; do case "$i" in - -h|--help) + -h | --help) usage exit 0 ;; @@ -64,6 +60,7 @@ for i in "$@"; do err "Unrecognized option $i" usage exit 1 + ;; esac done @@ -105,6 +102,7 @@ case "$LD_TYPE" in *) err "Unsupported linker: $LD" exit 1 + ;; esac CCAR="ar" @@ -128,7 +126,7 @@ if [ -n "$CROSS_PREFIX" ]; then # Try to fix this automatically. Maybe the user set CROSS_PREFIX but not CC. CC=$CROSS_PREFIX-$CC - if hash $CC 2>/dev/null; then + if hash $CC 2> /dev/null; then expected_prefix=$($CC -dumpmachine) if [ "$expected_prefix" = "$CROSS_PREFIX" ]; then @@ -151,7 +149,7 @@ if [ -n "$CROSS_PREFIX" ]; then # Try to fix this automatically. Maybe the user set CROSS_PREFIX but not CXX. CXX=$CROSS_PREFIX-$CXX - if hash $CXX 2>/dev/null; then + if hash $CXX 2> /dev/null; then expected_prefix=$($CXX -dumpmachine) if [ "$expected_prefix" = "$CROSS_PREFIX" ]; then diff --git a/scripts/gen_ftl.sh b/scripts/gen_ftl.sh index 5d7e4158a6..acde649624 100755 --- a/scripts/gen_ftl.sh +++ b/scripts/gen_ftl.sh @@ -4,7 +4,7 @@ set -e rootdir=$(readlink -f $(dirname $0))/.. -function usage { +function usage() { echo "Usage: [-j] $0 -n BDEV_NAME -d BASE_BDEV [-u UUID] [-c CACHE]" echo "UUID is required when restoring device state" echo @@ -14,8 +14,7 @@ function usage { echo "CACHE - name of the bdev to be used as write buffer cache" } -function create_json_config() -{ +function create_json_config() { echo "{" echo '"subsystem": "bdev",' echo '"config": [' @@ -40,14 +39,18 @@ uuid=00000000-0000-0000-0000-000000000000 while getopts ":c:d:hn:u:" arg; do case "$arg" in - n) name=$OPTARG ;; - d) base_bdev=$OPTARG ;; - u) uuid=$OPTARG ;; - c) cache=$OPTARG ;; - h) usage - exit 0 ;; - *) usage - exit 1 ;; + n) name=$OPTARG ;; + d) base_bdev=$OPTARG ;; + u) uuid=$OPTARG ;; + c) cache=$OPTARG ;; + h) + usage + exit 0 + ;; + *) + usage + exit 1 + ;; esac done diff --git a/scripts/gen_nvme.sh b/scripts/gen_nvme.sh index fbba7b15cd..150e71b458 100755 --- a/scripts/gen_nvme.sh +++ b/scripts/gen_nvme.sh @@ -5,22 +5,18 @@ set -e rootdir=$(readlink -f $(dirname $0))/.. source "$rootdir/scripts/common.sh" -function create_classic_config() -{ +function create_classic_config() { echo "[Nvme]" - for (( i=0; i < ${#bdfs[@]}; i++)) - do + for ((i = 0; i < ${#bdfs[@]}; i++)); do echo " TransportID \"trtype:PCIe traddr:${bdfs[i]}\" Nvme$i" done } -function create_json_config() -{ +function create_json_config() { echo "{" echo '"subsystem": "bdev",' echo '"config": [' - for (( i=0; i < ${#bdfs[@]}; i++)) - do + for ((i = 0; i < ${#bdfs[@]}; i++)); do echo '{' echo '"params": {' echo '"trtype": "PCIe",' @@ -28,7 +24,7 @@ function create_json_config() echo "\"traddr\": \"${bdfs[i]}\"" echo '},' echo '"method": "bdev_nvme_attach_controller"' - if [ -z ${bdfs[i+1]} ]; then + if [ -z ${bdfs[i + 1]} ]; then echo '}' else echo '},' diff --git a/scripts/pkgdep.sh b/scripts/pkgdep.sh index 5a1e136c87..456aa30629 100755 --- a/scripts/pkgdep.sh +++ b/scripts/pkgdep.sh @@ -3,8 +3,7 @@ set -e -function usage() -{ +function usage() { echo "" echo "This script is intended to automate the installation of package dependencies to build SPDK." echo "Please run this script as root user or with sudo -E." @@ -21,8 +20,7 @@ function usage() exit 0 } -function install_all_dependencies () -{ +function install_all_dependencies() { INSTALL_DEV_TOOLS=true INSTALL_PMEM=true INSTALL_FUSE=true @@ -40,27 +38,31 @@ INSTALL_DOCS=false while getopts 'abdfhipr-:' optchar; do case "$optchar" in -) - case "$OPTARG" in - help) usage;; - all) install_all_dependencies;; - developer-tools) INSTALL_DEV_TOOLS=true;; - pmem) INSTALL_PMEM=true;; - fuse) INSTALL_FUSE=true;; - rdma) INSTALL_RDMA=true;; - docs) INSTALL_DOCS=true;; - *) echo "Invalid argument '$OPTARG'" - usage;; - esac - ;; - h) usage;; - a) install_all_dependencies;; - d) INSTALL_DEV_TOOLS=true;; - p) INSTALL_PMEM=true;; - f) INSTALL_FUSE=true;; - r) INSTALL_RDMA=true;; - b) INSTALL_DOCS=true;; - *) echo "Invalid argument '$OPTARG'" - usage;; + case "$OPTARG" in + help) usage ;; + all) install_all_dependencies ;; + developer-tools) INSTALL_DEV_TOOLS=true ;; + pmem) INSTALL_PMEM=true ;; + fuse) INSTALL_FUSE=true ;; + rdma) INSTALL_RDMA=true ;; + docs) INSTALL_DOCS=true ;; + *) + echo "Invalid argument '$OPTARG'" + usage + ;; + esac + ;; + h) usage ;; + a) install_all_dependencies ;; + d) INSTALL_DEV_TOOLS=true ;; + p) INSTALL_PMEM=true ;; + f) INSTALL_FUSE=true ;; + r) INSTALL_RDMA=true ;; + b) INSTALL_DOCS=true ;; + *) + echo "Invalid argument '$OPTARG'" + usage + ;; esac done @@ -174,7 +176,7 @@ elif [ -f /etc/debian_version ]; then fi if [[ $INSTALL_FUSE == "true" ]]; then # Additional dependencies for FUSE and NVMe-CUSE - if [[ $NAME == "Ubuntu" ]] && (( VERSION_ID_NUM > 1400 && VERSION_ID_NUM < 1900 )); then + if [[ $NAME == "Ubuntu" ]] && ((VERSION_ID_NUM > 1400 && VERSION_ID_NUM < 1900)); then echo "Ubuntu $VERSION_ID does not have libfuse3-dev in mainline repository." echo "You can install it manually" else @@ -220,7 +222,7 @@ elif [ -f /etc/SuSE-release ] || [ -f /etc/SUSE-brand ]; then # Additional dependencies for building docs zypper install -y doxygen mscgen graphviz fi -elif [ $(uname -s) = "FreeBSD" ] ; then +elif [ $(uname -s) = "FreeBSD" ]; then # Minimal install pkg install -y gmake cunit openssl git bash misc/e2fsprogs-libuuid python \ ncurses diff --git a/scripts/prep_benchmarks.sh b/scripts/prep_benchmarks.sh index 2b0642b074..01d8c47da2 100755 --- a/scripts/prep_benchmarks.sh +++ b/scripts/prep_benchmarks.sh @@ -20,7 +20,7 @@ function configure_performance() { echo -n "Moving all interrupts off of core 0..." count=$(($(nproc) / 4)) cpumask="e" - for ((i=1; i/dev/null 2>&1; then + elif modinfo uio_pci_generic > /dev/null 2>&1; then driver_name=uio_pci_generic elif [[ -r "$rootdir/dpdk/build/kmod/igb_uio.ko" ]]; then driver_path="$rootdir/dpdk/build/kmod/igb_uio.ko" @@ -240,10 +242,9 @@ function configure_linux_pci { TMP=$(mktemp) #collect all the device_id info of ioat devices. grep "PCI_DEVICE_ID_INTEL_IOAT" $rootdir/include/spdk/pci_ids.h \ - | awk -F"x" '{print $2}' > $TMP + | awk -F"x" '{print $2}' > $TMP - while IFS= read -r dev_id - do + while IFS= read -r dev_id; do for bdf in ${pci_bus_cache["0x8086:0x$dev_id"]}; do if ! pci_can_use $bdf; then pci_dev_echo "$bdf" "Skipping un-whitelisted I/OAT device" @@ -255,33 +256,31 @@ function configure_linux_pci { done < $TMP rm $TMP - # IDXD - TMP=$(mktemp) - #collect all the device_id info of idxd devices. - grep "PCI_DEVICE_ID_INTEL_IDXD" $rootdir/include/spdk/pci_ids.h \ - | awk -F"x" '{print $2}' > $TMP + # IDXD + TMP=$(mktemp) + #collect all the device_id info of idxd devices. + grep "PCI_DEVICE_ID_INTEL_IDXD" $rootdir/include/spdk/pci_ids.h \ + | awk -F"x" '{print $2}' > $TMP - while IFS= read -r dev_id - do - for bdf in ${pci_bus_cache["0x8086:0x$dev_id"]}; do - if ! pci_can_use $bdf; then - pci_dev_echo "$bdf" "Skipping un-whitelisted IDXD device" - continue - fi + while IFS= read -r dev_id; do + for bdf in ${pci_bus_cache["0x8086:0x$dev_id"]}; do + if ! pci_can_use $bdf; then + pci_dev_echo "$bdf" "Skipping un-whitelisted IDXD device" + continue + fi - linux_bind_driver "$bdf" "$driver_name" - done - done < $TMP - rm $TMP + linux_bind_driver "$bdf" "$driver_name" + done + done < $TMP + rm $TMP # virtio TMP=$(mktemp) #collect all the device_id info of virtio devices. grep "PCI_DEVICE_ID_VIRTIO" $rootdir/include/spdk/pci_ids.h \ - | awk -F"x" '{print $2}' > $TMP + | awk -F"x" '{print $2}' > $TMP - while IFS= read -r dev_id - do + while IFS= read -r dev_id; do for bdf in ${pci_bus_cache["0x1af4:0x$dev_id"]}; do if ! pci_can_use $bdf; then pci_dev_echo "$bdf" "Skipping un-whitelisted Virtio device at $bdf" @@ -305,10 +304,9 @@ function configure_linux_pci { TMP=$(mktemp) #collect all the device_id info of vmd devices. grep "PCI_DEVICE_ID_INTEL_VMD" $rootdir/include/spdk/pci_ids.h \ - | awk -F"x" '{print $2}' > $TMP + | awk -F"x" '{print $2}' > $TMP - while IFS= read -r dev_id - do + while IFS= read -r dev_id; do for bdf in ${pci_bus_cache["0x8086:0x$dev_id"]}; do if [[ -z "$PCI_WHITELIST" ]] || ! pci_can_use $bdf; then echo "Skipping un-whitelisted VMD device at $bdf" @@ -316,7 +314,7 @@ function configure_linux_pci { fi linux_bind_driver "$bdf" "$driver_name" - echo " VMD generic kdrv: " "$bdf" "$driver_name" + echo " VMD generic kdrv: " "$bdf" "$driver_name" done done < $TMP rm $TMP @@ -324,7 +322,7 @@ function configure_linux_pci { echo "1" > "/sys/bus/pci/rescan" } -function cleanup_linux { +function cleanup_linux() { shopt -s extglob nullglob dirs_to_clean="" dirs_to_clean="$(echo {/var/run,/tmp}/dpdk/spdk{,_pid}+([0-9])) " @@ -338,12 +336,12 @@ function cleanup_linux { done shopt -u extglob nullglob - files_to_clean+="$(ls -1 /dev/shm/* | \ - grep -E '(spdk_tgt|iscsi|vhost|nvmf|rocksdb|bdevio|bdevperf|vhost_fuzz|nvme_fuzz)_trace|spdk_iscsi_conns' || true) " + files_to_clean+="$(ls -1 /dev/shm/* \ + | grep -E '(spdk_tgt|iscsi|vhost|nvmf|rocksdb|bdevio|bdevperf|vhost_fuzz|nvme_fuzz)_trace|spdk_iscsi_conns' || true) " files_to_clean="$(readlink -e assert_not_empty $files_to_clean || true)" if [[ -z "$files_to_clean" ]]; then echo "Clean" - return 0; + return 0 fi shopt -s extglob @@ -368,19 +366,19 @@ function cleanup_linux { done for dir in $dirs_to_clean; do - if ! echo "$opened_files" | grep -E -q "^$dir\$"; then - echo "Removing: $dir" - rmdir $dir - else - echo "Still open: $dir" - fi + if ! echo "$opened_files" | grep -E -q "^$dir\$"; then + echo "Removing: $dir" + rmdir $dir + else + echo "Still open: $dir" + fi done echo "Clean" unset dirs_to_clean files_to_clean opened_files } -function configure_linux { +function configure_linux() { configure_linux_pci hugetlbfs_mounts=$(linux_hugetlbfs_mounts) @@ -415,8 +413,8 @@ function configure_linux { fi MEMLOCK_AMNT=$(ulimit -l) - if [ "$MEMLOCK_AMNT" != "unlimited" ] ; then - MEMLOCK_MB=$(( MEMLOCK_AMNT / 1024 )) + if [ "$MEMLOCK_AMNT" != "unlimited" ]; then + MEMLOCK_MB=$((MEMLOCK_AMNT / 1024)) echo "" echo "Current user memlock limit: ${MEMLOCK_MB} MB" echo "" @@ -425,7 +423,7 @@ function configure_linux { echo -n "To change this, please adjust limits.conf memlock " echo "limit for current user." - if [ $MEMLOCK_AMNT -lt 65536 ] ; then + if [ $MEMLOCK_AMNT -lt 65536 ]; then echo "" echo "## WARNING: memlock limit is less than 64MB" echo -n "## DPDK with VFIO may not be able to initialize " @@ -442,7 +440,7 @@ function configure_linux { fi } -function reset_linux_pci { +function reset_linux_pci() { # NVMe set +e check_for_driver nvme @@ -464,14 +462,13 @@ function reset_linux_pci { TMP=$(mktemp) #collect all the device_id info of ioat devices. grep "PCI_DEVICE_ID_INTEL_IOAT" $rootdir/include/spdk/pci_ids.h \ - | awk -F"x" '{print $2}' > $TMP + | awk -F"x" '{print $2}' > $TMP set +e check_for_driver ioatdma driver_loaded=$? set -e - while IFS= read -r dev_id - do + while IFS= read -r dev_id; do for bdf in ${pci_bus_cache["0x8086:0x$dev_id"]}; do if ! pci_can_use $bdf; then pci_dev_echo "$bdf" "Skipping un-whitelisted I/OAT device" @@ -486,44 +483,42 @@ function reset_linux_pci { done < $TMP rm $TMP - # IDXD - TMP=$(mktemp) - #collect all the device_id info of idxd devices. - grep "PCI_DEVICE_ID_INTEL_IDXD" $rootdir/include/spdk/pci_ids.h \ - | awk -F"x" '{print $2}' > $TMP - set +e - check_for_driver idxd - driver_loaded=$? - set -e - while IFS= read -r dev_id - do - for bdf in ${pci_bus_cache["0x8086:0x$dev_id"]}; do - if ! pci_can_use $bdf; then - pci_dev_echo "$bdf" "Skipping un-whitelisted IDXD device" - continue - fi - if [ $driver_loaded -ne 0 ]; then - linux_bind_driver "$bdf" idxd - else - linux_unbind_driver "$bdf" - fi - done - done < $TMP - rm $TMP + # IDXD + TMP=$(mktemp) + #collect all the device_id info of idxd devices. + grep "PCI_DEVICE_ID_INTEL_IDXD" $rootdir/include/spdk/pci_ids.h \ + | awk -F"x" '{print $2}' > $TMP + set +e + check_for_driver idxd + driver_loaded=$? + set -e + while IFS= read -r dev_id; do + for bdf in ${pci_bus_cache["0x8086:0x$dev_id"]}; do + if ! pci_can_use $bdf; then + pci_dev_echo "$bdf" "Skipping un-whitelisted IDXD device" + continue + fi + if [ $driver_loaded -ne 0 ]; then + linux_bind_driver "$bdf" idxd + else + linux_unbind_driver "$bdf" + fi + done + done < $TMP + rm $TMP # virtio TMP=$(mktemp) #collect all the device_id info of virtio devices. grep "PCI_DEVICE_ID_VIRTIO" $rootdir/include/spdk/pci_ids.h \ - | awk -F"x" '{print $2}' > $TMP + | awk -F"x" '{print $2}' > $TMP # TODO: check if virtio-pci is loaded first and just unbind if it is not loaded # Requires some more investigation - for example, some kernels do not seem to have # virtio-pci but just virtio_scsi instead. Also need to make sure we get the # underscore vs. dash right in the virtio_scsi name. modprobe virtio-pci || true - while IFS= read -r dev_id - do + while IFS= read -r dev_id; do for bdf in ${pci_bus_cache["0x1af4:0x$dev_id"]}; do if ! pci_can_use $bdf; then pci_dev_echo "$bdf" "Skipping un-whitelisted Virtio device at" @@ -538,14 +533,13 @@ function reset_linux_pci { TMP=$(mktemp) #collect all the device_id info of vmd devices. grep "PCI_DEVICE_ID_INTEL_VMD" $rootdir/include/spdk/pci_ids.h \ - | awk -F"x" '{print $2}' > $TMP + | awk -F"x" '{print $2}' > $TMP set +e check_for_driver vmd driver_loaded=$? set -e - while IFS= read -r dev_id - do + while IFS= read -r dev_id; do for bdf in ${pci_bus_cache["0x8086:0x$dev_id"]}; do if ! pci_can_use $bdf; then echo "Skipping un-whitelisted VMD device at $bdf" @@ -563,7 +557,7 @@ function reset_linux_pci { echo "1" > "/sys/bus/pci/rescan" } -function reset_linux { +function reset_linux() { reset_linux_pci for mount in $(linux_hugetlbfs_mounts); do rm -f "$mount"/spdk*map_* @@ -571,9 +565,9 @@ function reset_linux { rm -f /run/.spdk* } -function status_linux { +function status_linux() { echo "Hugepages" - printf "%-6s %10s %8s / %6s\n" "node" "hugesize" "free" "total" + printf "%-6s %10s %8s / %6s\n" "node" "hugesize" "free" "total" numa_nodes=0 shopt -s nullglob @@ -606,7 +600,7 @@ function status_linux { echo -e "BDF\t\tVendor\tDevice\tNUMA\tDriver\t\tDevice name" for bdf in ${pci_bus_cache["0x010802"]}; do - driver=$(grep DRIVER /sys/bus/pci/devices/$bdf/uevent |awk -F"=" '{print $2}') + driver=$(grep DRIVER /sys/bus/pci/devices/$bdf/uevent | awk -F"=" '{print $2}') if [ "$numa_nodes" = "0" ]; then node="-" else @@ -615,11 +609,11 @@ function status_linux { device=$(cat /sys/bus/pci/devices/$bdf/device) vendor=$(cat /sys/bus/pci/devices/$bdf/vendor) if [ "$driver" = "nvme" ] && [ -d /sys/bus/pci/devices/$bdf/nvme ]; then - name="\t"$(ls /sys/bus/pci/devices/$bdf/nvme); + name="\t"$(ls /sys/bus/pci/devices/$bdf/nvme) else - name="-"; + name="-" fi - echo -e "$bdf\t${vendor#0x}\t${device#0x}\t$node\t${driver:--}\t\t$name"; + echo -e "$bdf\t${vendor#0x}\t${device#0x}\t$node\t${driver:--}\t\t$name" done echo "" @@ -627,11 +621,11 @@ function status_linux { #collect all the device_id info of ioat devices. TMP=$(grep "PCI_DEVICE_ID_INTEL_IOAT" $rootdir/include/spdk/pci_ids.h \ - | awk -F"x" '{print $2}') + | awk -F"x" '{print $2}') echo -e "BDF\t\tVendor\tDevice\tNUMA\tDriver" for dev_id in $TMP; do for bdf in ${pci_bus_cache["0x8086:0x$dev_id"]}; do - driver=$(grep DRIVER /sys/bus/pci/devices/$bdf/uevent |awk -F"=" '{print $2}') + driver=$(grep DRIVER /sys/bus/pci/devices/$bdf/uevent | awk -F"=" '{print $2}') if [ "$numa_nodes" = "0" ]; then node="-" else @@ -643,37 +637,37 @@ function status_linux { done done - echo "" - echo "IDXD DMA" + echo "" + echo "IDXD DMA" - #collect all the device_id info of idxd devices. - TMP=$(grep "PCI_DEVICE_ID_INTEL_IDXD" $rootdir/include/spdk/pci_ids.h \ - | awk -F"x" '{print $2}') - echo -e "BDF\t\tVendor\tDevice\tNUMA\tDriver" - for dev_id in $TMP; do - for bdf in ${pci_bus_cache["0x8086:0x$dev_id"]}; do - driver=$(grep DRIVER /sys/bus/pci/devices/$bdf/uevent |awk -F"=" '{print $2}') - if [ "$numa_nodes" = "0" ]; then - node="-" - else - node=$(cat /sys/bus/pci/devices/$bdf/numa_node) - fi - device=$(cat /sys/bus/pci/devices/$bdf/device) - vendor=$(cat /sys/bus/pci/devices/$bdf/vendor) - echo -e "$bdf\t${vendor#0x}\t${device#0x}\t$node\t${driver:--}" - done - done + #collect all the device_id info of idxd devices. + TMP=$(grep "PCI_DEVICE_ID_INTEL_IDXD" $rootdir/include/spdk/pci_ids.h \ + | awk -F"x" '{print $2}') + echo -e "BDF\t\tVendor\tDevice\tNUMA\tDriver" + for dev_id in $TMP; do + for bdf in ${pci_bus_cache["0x8086:0x$dev_id"]}; do + driver=$(grep DRIVER /sys/bus/pci/devices/$bdf/uevent | awk -F"=" '{print $2}') + if [ "$numa_nodes" = "0" ]; then + node="-" + else + node=$(cat /sys/bus/pci/devices/$bdf/numa_node) + fi + device=$(cat /sys/bus/pci/devices/$bdf/device) + vendor=$(cat /sys/bus/pci/devices/$bdf/vendor) + echo -e "$bdf\t${vendor#0x}\t${device#0x}\t$node\t${driver:--}" + done + done echo "" echo "virtio" #collect all the device_id info of virtio devices. TMP=$(grep "PCI_DEVICE_ID_VIRTIO" $rootdir/include/spdk/pci_ids.h \ - | awk -F"x" '{print $2}') + | awk -F"x" '{print $2}') echo -e "BDF\t\tVendor\tDevice\tNUMA\tDriver\t\tDevice name" for dev_id in $TMP; do for bdf in ${pci_bus_cache["0x1af4:0x$dev_id"]}; do - driver=$(grep DRIVER /sys/bus/pci/devices/$bdf/uevent |awk -F"=" '{print $2}') + driver=$(grep DRIVER /sys/bus/pci/devices/$bdf/uevent | awk -F"=" '{print $2}') if [ "$numa_nodes" = "0" ]; then node="-" else @@ -691,18 +685,18 @@ function status_linux { #collect all the device_id info of vmd devices. TMP=$(grep "PCI_DEVICE_ID_INTEL_VMD" $rootdir/include/spdk/pci_ids.h \ - | awk -F"x" '{print $2}') + | awk -F"x" '{print $2}') echo -e "BDF\t\tNuma Node\tDriver Name" for dev_id in $TMP; do for bdf in ${pci_bus_cache["0x8086:0x$dev_id"]}; do - driver=$(grep DRIVER /sys/bus/pci/devices/$bdf/uevent |awk -F"=" '{print $2}') - node=$(cat /sys/bus/pci/devices/$bdf/numa_node); + driver=$(grep DRIVER /sys/bus/pci/devices/$bdf/uevent | awk -F"=" '{print $2}') + node=$(cat /sys/bus/pci/devices/$bdf/numa_node) echo -e "$bdf\t$node\t\t$driver" done done } -function configure_freebsd_pci { +function configure_freebsd_pci() { local devs ids id local BDFS @@ -730,7 +724,7 @@ function configure_freebsd_pci { kldload nic_uio.ko } -function configure_freebsd { +function configure_freebsd() { configure_freebsd_pci # If contigmem is already loaded but the HUGEMEM specified doesn't match the # previous value, unload contigmem so that we can reload with the new value. @@ -746,7 +740,7 @@ function configure_freebsd { fi } -function reset_freebsd { +function reset_freebsd() { kldunload contigmem.ko || true kldunload nic_uio.ko || true } @@ -774,14 +768,14 @@ fi if [ -z "$TARGET_USER" ]; then TARGET_USER="$SUDO_USER" if [ -z "$TARGET_USER" ]; then - TARGET_USER=$(logname 2>/dev/null) || true + TARGET_USER=$(logname 2> /dev/null) || true fi fi if [ $(uname) = Linux ]; then - HUGEPGSZ=$(( $(grep Hugepagesize /proc/meminfo | cut -d : -f 2 | tr -dc '0-9') )) - HUGEPGSZ_MB=$(( HUGEPGSZ / 1024 )) - : ${NRHUGE=$(( (HUGEMEM + HUGEPGSZ_MB - 1) / HUGEPGSZ_MB ))} + HUGEPGSZ=$(($(grep Hugepagesize /proc/meminfo | cut -d : -f 2 | tr -dc '0-9'))) + HUGEPGSZ_MB=$((HUGEPGSZ / 1024)) + : ${NRHUGE=$(((HUGEMEM + HUGEPGSZ_MB - 1) / HUGEPGSZ_MB))} if [ "$mode" == "config" ]; then configure_linux diff --git a/scripts/vagrant/create_nvme_img.sh b/scripts/vagrant/create_nvme_img.sh index 35b5ee9ab7..db758bd879 100755 --- a/scripts/vagrant/create_nvme_img.sh +++ b/scripts/vagrant/create_nvme_img.sh @@ -19,25 +19,25 @@ while getopts "s:n:t:h-:" opt; do echo " Invalid argument: $OPTARG" usage exit 1 - ;; + ;; s) size=$OPTARG - ;; + ;; n) nvme_disk=$OPTARG - ;; + ;; t) type=$OPTARG - ;; + ;; h) usage exit 0 - ;; + ;; *) echo " Invalid argument: $OPTARG" usage exit 1 - ;; + ;; esac done @@ -46,18 +46,18 @@ if [ ! "${SYSTEM}" = "FreeBSD" ]; then case $type in "nvme") qemu-img create -f raw $nvme_disk $size - ;; + ;; "ocssd") if [ $size == "1024M" ]; then size="9G" fi fallocate -l $size $nvme_disk touch ${nvme_disk}_ocssd_md - ;; + ;; *) echo "We support only nvme and ocssd disks types" exit 1 - ;; + ;; esac #Change SE Policy on Fedora if [ $WHICH_OS == "Fedora" ]; then diff --git a/scripts/vagrant/create_vbox.sh b/scripts/vagrant/create_vbox.sh index 6a007e2cd6..b8422a9ab2 100755 --- a/scripts/vagrant/create_vbox.sh +++ b/scripts/vagrant/create_vbox.sh @@ -11,8 +11,8 @@ set -e VAGRANT_TARGET="$PWD" -DIR="$( cd "$( dirname $0 )" && pwd )" -SPDK_DIR="$( cd "${DIR}/../../" && pwd )" +DIR="$(cd "$(dirname $0)" && pwd)" +SPDK_DIR="$(cd "${DIR}/../../" && pwd)" # The command line help display_help() { @@ -85,103 +85,103 @@ VAGRANT_HUGE_MEM=0 while getopts ":b:n:s:x:p:u:vcraldHh-:" opt; do case "${opt}" in -) - case "${OPTARG}" in - package-box) VAGRANT_PACKAGE_BOX=1 ;; - qemu-emulator=*) SPDK_QEMU_EMULATOR="${OPTARG#*=}" ;; - vagrantfiles-dir=*) VAGRANTFILE_DIR="${OPTARG#*=}" ;; - *) echo "Invalid argument '$OPTARG'" ;; - esac - ;; + case "${OPTARG}" in + package-box) VAGRANT_PACKAGE_BOX=1 ;; + qemu-emulator=*) SPDK_QEMU_EMULATOR="${OPTARG#*=}" ;; + vagrantfiles-dir=*) VAGRANTFILE_DIR="${OPTARG#*=}" ;; + *) echo "Invalid argument '$OPTARG'" ;; + esac + ;; x) http_proxy=$OPTARG https_proxy=$http_proxy SPDK_VAGRANT_HTTP_PROXY="${http_proxy}" - ;; + ;; n) SPDK_VAGRANT_VMCPU=$OPTARG - ;; + ;; s) SPDK_VAGRANT_VMRAM=$OPTARG - ;; + ;; p) SPDK_VAGRANT_PROVIDER=$OPTARG - ;; + ;; v) VERBOSE=1 - ;; + ;; c) NVME_AUTO_CREATE=1 - ;; + ;; r) DRY_RUN=1 - ;; + ;; h) display_help >&2 exit 0 - ;; + ;; a) COPY_SPDK_ARTIFACTS=1 - ;; + ;; l) COPY_SPDK_DIR=0 - ;; + ;; d) DEPLOY_TEST_VM=1 - ;; + ;; b) NVME_FILE+="${OPTARG#*=} " - ;; + ;; u) VAGRANT_PASSWORD_AUTH=1 - ;; + ;; H) VAGRANT_HUGE_MEM=1 - ;; + ;; *) echo " Invalid argument: -$OPTARG" >&2 echo " Try: \"$0 -h\"" >&2 exit 1 - ;; + ;; esac done -shift "$((OPTIND-1))" # Discard the options and sentinel -- +shift "$((OPTIND - 1))" # Discard the options and sentinel -- SPDK_VAGRANT_DISTRO="$*" case "${SPDK_VAGRANT_DISTRO}" in centos7) export SPDK_VAGRANT_DISTRO - ;; + ;; centos8) export SPDK_VAGRANT_DISTRO - ;; + ;; ubuntu1604) export SPDK_VAGRANT_DISTRO - ;; + ;; ubuntu1804) export SPDK_VAGRANT_DISTRO - ;; + ;; fedora30) export SPDK_VAGRANT_DISTRO - ;; + ;; fedora31) export SPDK_VAGRANT_DISTRO - ;; + ;; freebsd11) export SPDK_VAGRANT_DISTRO - ;; + ;; freebsd12) export SPDK_VAGRANT_DISTRO - ;; + ;; arch) export SPDK_VAGRANT_DISTRO - ;; + ;; *) echo " Invalid argument \"${SPDK_VAGRANT_DISTRO}\"" echo " Try: \"$0 -h\"" >&2 exit 1 - ;; + ;; esac if ! echo "$SPDK_VAGRANT_DISTRO" | grep -q fedora && [ $DEPLOY_TEST_VM -eq 1 ]; then @@ -195,15 +195,15 @@ else TMP="" for args in $NVME_FILE; do while IFS=, read -r path type namespace; do - TMP+="$path,"; + TMP+="$path," if [ -z "$type" ]; then type="nvme" fi - NVME_DISKS_TYPE+="$type,"; + NVME_DISKS_TYPE+="$type," if [ -z "$namespace" ] && [ -n "$SPDK_QEMU_EMULATOR" ]; then namespace="1" fi - NVME_DISKS_NAMESPACES+="$namespace,"; + NVME_DISKS_NAMESPACES+="$namespace," if [ ${NVME_AUTO_CREATE} = 1 ]; then $SPDK_DIR/scripts/vagrant/create_nvme_img.sh -t $type -n $path fi @@ -247,15 +247,15 @@ export VAGRANT_PASSWORD_AUTH export VAGRANT_HUGE_MEM if [ -n "$SPDK_VAGRANT_PROVIDER" ]; then - provider="--provider=${SPDK_VAGRANT_PROVIDER}" + provider="--provider=${SPDK_VAGRANT_PROVIDER}" fi if [ -n "$SPDK_VAGRANT_PROVIDER" ]; then - export SPDK_VAGRANT_PROVIDER + export SPDK_VAGRANT_PROVIDER fi -if [ -n "$SPDK_QEMU_EMULATOR" ] && [ "$SPDK_VAGRANT_PROVIDER" == "libvirt" ]; then - export SPDK_QEMU_EMULATOR +if [ -n "$SPDK_QEMU_EMULATOR" ] && [ "$SPDK_VAGRANT_PROVIDER" == "libvirt" ]; then + export SPDK_QEMU_EMULATOR fi if [ ${DRY_RUN} = 1 ]; then @@ -296,7 +296,7 @@ if [ ${DRY_RUN} != 1 ]; then vagrant plugin install vagrant-proxyconf fi if echo "$SPDK_VAGRANT_DISTRO" | grep -q freebsd; then - cat >~/vagrant_pkg.conf < ~/vagrant_pkg.conf << EOF pkg_env: { http_proxy: ${http_proxy} } @@ -309,8 +309,8 @@ EOF vagrant ssh -c 'sudo spdk_repo/spdk/scripts/vagrant/update.sh' vagrant halt vagrant package --output spdk_${SPDK_VAGRANT_DISTRO}.box - vagrant box add spdk/${SPDK_VAGRANT_DISTRO} spdk_${SPDK_VAGRANT_DISTRO}.box && - rm spdk_${SPDK_VAGRANT_DISTRO}.box + vagrant box add spdk/${SPDK_VAGRANT_DISTRO} spdk_${SPDK_VAGRANT_DISTRO}.box \ + && rm spdk_${SPDK_VAGRANT_DISTRO}.box vagrant destroy fi echo "" diff --git a/scripts/vagrant/create_vhost_vm.sh b/scripts/vagrant/create_vhost_vm.sh index affc0fa3e8..5895639cf3 100755 --- a/scripts/vagrant/create_vhost_vm.sh +++ b/scripts/vagrant/create_vhost_vm.sh @@ -8,8 +8,8 @@ set -e VAGRANT_TARGET="$PWD" -DIR="$( cd "$( dirname $0 )" && pwd )" -SPDK_DIR="$( cd "${DIR}/../../" && pwd )" +DIR="$(cd "$(dirname $0)" && pwd)" +SPDK_DIR="$(cd "${DIR}/../../" && pwd)" USE_SSH_DIR="" MOVE_TO_DEFAULT_DIR=false INSTALL_DEPS=false @@ -37,54 +37,53 @@ display_help() { while getopts ":h-:" opt; do case "${opt}" in -) - case "${OPTARG}" in - use-ssh-dir=*) USE_SSH_DIR="${OPTARG#*=}" ;; - move-to-default-dir) MOVE_TO_DEFAULT_DIR=true ;; - install-deps) INSTALL_DEPS=true ;; - http-proxy=*) - http_proxy=$OPTARG - https_proxy=$http_proxy - SPDK_VAGRANT_HTTP_PROXY="${http_proxy}" + case "${OPTARG}" in + use-ssh-dir=*) USE_SSH_DIR="${OPTARG#*=}" ;; + move-to-default-dir) MOVE_TO_DEFAULT_DIR=true ;; + install-deps) INSTALL_DEPS=true ;; + http-proxy=*) + http_proxy=$OPTARG + https_proxy=$http_proxy + SPDK_VAGRANT_HTTP_PROXY="${http_proxy}" + ;; + *) + echo " Invalid argument -$OPTARG" >&2 + echo " Try \"$0 -h\"" >&2 + exit 1 + ;; + esac ;; - *) - echo " Invalid argument -$OPTARG" >&2 - echo " Try \"$0 -h\"" >&2 - exit 1 - ;; - esac - ;; h) display_help >&2 exit 0 - ;; + ;; *) echo " Invalid argument: -$OPTARG" >&2 echo " Try: \"$0 -h\"" >&2 exit 1 - ;; + ;; esac done export SPDK_DIR export SPDK_VAGRANT_HTTP_PROXY export INSTALL_DEPS - -shift "$((OPTIND-1))" # Discard the options and sentinel -- +shift "$((OPTIND - 1))" # Discard the options and sentinel -- SPDK_VAGRANT_DISTRO="$*" case "${SPDK_VAGRANT_DISTRO}" in ubuntu16) export SPDK_VAGRANT_DISTRO - ;; + ;; ubuntu18) export SPDK_VAGRANT_DISTRO - ;; + ;; *) echo " Invalid argument \"${SPDK_VAGRANT_DISTRO}\"" echo " Try: \"$0 -h\"" >&2 exit 1 - ;; + ;; esac mkdir -vp "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}" diff --git a/scripts/vagrant/run-autorun.sh b/scripts/vagrant/run-autorun.sh index 113cd7f2de..28cefe4749 100755 --- a/scripts/vagrant/run-autorun.sh +++ b/scripts/vagrant/run-autorun.sh @@ -70,25 +70,30 @@ set -e NOOP=0 METHOD=0 V=1 -OPTIND=1 # Reset in case getopts has been used previously in the shell. +OPTIND=1 # Reset in case getopts has been used previously in the shell. while getopts "d:qhn" opt; do case "$opt" in - d) SPDK_SOURCE_PATH=$($READLINK -f $OPTARG) + d) + SPDK_SOURCE_PATH=$($READLINK -f $OPTARG) echo Using SPDK source at ${SPDK_SOURCE_PATH} METHOD=1 - ;; - q) V=0 - ;; - n) NOOP=1 - ;; - h) display_help >&2 + ;; + q) + V=0 + ;; + n) + NOOP=1 + ;; + h) + display_help >&2 exit 0 - ;; - *) echo "Invalid option" + ;; + *) + echo "Invalid option" echo "" display_help >&2 exit 1 - ;; + ;; esac done @@ -141,12 +146,12 @@ case "$METHOD" in fi GIT_REPO_PATH="${SPDK_AUTOTEST_LOCAL_PATH}/${GIT_BRANCH}/${BUILD_NAME}" - ;; + ;; *) echo "Internal Error: Must specify a source path or branch name" display_help exit 1 - ;; + ;; esac AUTOTEST_RESULTS="${SPDK_AUTOTEST_LOCAL_PATH}/${GIT_BRANCH}/${BUILD_NAME}" @@ -203,12 +208,12 @@ if [[ ${NOOP} -eq 0 ]]; then sudo "${MAKE}" clean -j $(nproc) sudo "${GIT}" clean -d -f popd - ;; + ;; *) echo "Internal Error: Must specify a source path or branch name" display_help exit 1 - ;; + ;; esac trap "echo ERROR; exit" INT TERM EXIT diff --git a/scripts/vagrant/update.sh b/scripts/vagrant/update.sh index 207cd38e3c..87bb21c9d2 100755 --- a/scripts/vagrant/update.sh +++ b/scripts/vagrant/update.sh @@ -9,8 +9,8 @@ fi set -e -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -SPDK_DIR="$( cd "${DIR}/../../" && pwd )" +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +SPDK_DIR="$(cd "${DIR}/../../" && pwd)" echo "SPDK_DIR = $SPDK_DIR" # Bug fix for vagrant rsync problem @@ -50,7 +50,7 @@ else # get the requested number of hugepages without rebooting. # So do it here just in case sysctl -w vm.nr_hugepages=1024 - HUGEPAGES=$(sysctl -n vm.nr_hugepages) + HUGEPAGES=$(sysctl -n vm.nr_hugepages) if [ $HUGEPAGES != 1024 ]; then echo "Warning: Unable to get 1024 hugepages, only got $HUGEPAGES" echo "Warning: Adjusting HUGEMEM in /home/vagrant/autorun-spdk.conf" @@ -59,9 +59,9 @@ else fi # Figure out what system we are running on - if [ -f /etc/lsb-release ];then + if [ -f /etc/lsb-release ]; then . /etc/lsb-release - elif [ -f /etc/redhat-release ];then + elif [ -f /etc/redhat-release ]; then yum update -y yum install -y redhat-lsb DISTRIB_ID=$(lsb_release -si) diff --git a/test/bdev/bdev_raid.sh b/test/bdev/bdev_raid.sh index 99952d16a7..13582dfaae 100755 --- a/test/bdev/bdev_raid.sh +++ b/test/bdev/bdev_raid.sh @@ -14,10 +14,10 @@ function raid_unmap_data_verify() { local nbd=$1 local rpc_server=$2 local blksize - blksize=$(lsblk -o LOG-SEC $nbd | grep -v LOG-SEC | cut -d ' ' -f 5) + blksize=$(lsblk -o LOG-SEC $nbd | grep -v LOG-SEC | cut -d ' ' -f 5) local rw_blk_num=4096 local rw_len=$((blksize * rw_blk_num)) - local unmap_blk_offs=(0 1028 321) + local unmap_blk_offs=(0 1028 321) local unmap_blk_nums=(128 2035 456) local unmap_off local unmap_len @@ -30,7 +30,7 @@ function raid_unmap_data_verify() { # confirm random data is written correctly in raid0 device cmp -b -n $rw_len $tmp_file $nbd - for (( i=0; i<${#unmap_blk_offs[@]}; i++ )); do + for ((i = 0; i < ${#unmap_blk_offs[@]}; i++)); do unmap_off=$((blksize * ${unmap_blk_offs[$i]})) unmap_len=$((blksize * ${unmap_blk_nums[$i]})) @@ -63,9 +63,9 @@ function configure_raid_bdev() { rm -rf $testdir/rpcs.txt cat <<- EOL >> $testdir/rpcs.txt - bdev_malloc_create 32 512 -b Base_1 - bdev_malloc_create 32 512 -b Base_2 - bdev_raid_create -z 64 -r 0 -b "Base_1 Base_2" -n raid0 + bdev_malloc_create 32 512 -b Base_1 + bdev_malloc_create 32 512 -b Base_2 + bdev_raid_create -z 64 -r 0 -b "Base_1 Base_2" -n raid0 EOL $rpc_py < $testdir/rpcs.txt diff --git a/test/bdev/blockdev.sh b/test/bdev/blockdev.sh index 43c93cf1f8..b31f60d54f 100755 --- a/test/bdev/blockdev.sh +++ b/test/bdev/blockdev.sh @@ -8,7 +8,7 @@ source $testdir/nbd_common.sh rpc_py="$rootdir/scripts/rpc.py" conf_file="$testdir/bdev.json" # Make sure the configuration is clean -:>"$conf_file" +: > "$conf_file" function cleanup() { rm -f "/tmp/aiofile" @@ -28,7 +28,7 @@ function start_spdk_tgt() { } function setup_bdev_conf() { - "$rpc_py" <<-RPC + "$rpc_py" <<- RPC bdev_split_create Malloc1 2 bdev_split_create -s 4 Malloc2 8 bdev_malloc_create -b Malloc0 32 512 @@ -69,7 +69,8 @@ function setup_gpt_conf() { dev=/dev/${nvme_dev##*/} if ! pt=$(parted "$dev" -ms print 2>&1); then [[ $pt == *"$dev: unrecognised disk label"* ]] || continue - gpt_nvme=$dev; break + gpt_nvme=$dev + break fi done if [[ -n $gpt_nvme ]]; then @@ -78,7 +79,7 @@ function setup_gpt_conf() { # change the GUID to SPDK GUID value # FIXME: Hardcode this in some common place, this value should not be changed much IFS="()" read -r _ SPDK_GPT_GUID _ < <(grep SPDK_GPT_PART_TYPE_GUID module/bdev/gpt/gpt.h) - SPDK_GPT_GUID=${SPDK_GPT_GUID//, /-} SPDK_GPT_GUID=${SPDK_GPT_GUID//0x} + SPDK_GPT_GUID=${SPDK_GPT_GUID//, /-} SPDK_GPT_GUID=${SPDK_GPT_GUID//0x/} sgdisk -t "1:$SPDK_GPT_GUID" "$gpt_nvme" sgdisk -t "2:$SPDK_GPT_GUID" "$gpt_nvme" "$rootdir/scripts/setup.sh" @@ -89,7 +90,7 @@ function setup_gpt_conf() { "$rootdir/scripts/setup.sh" return 1 fi - else + else # Not supported platform or missing tooling, nothing to be done, simply exit the test # in a graceful manner. trap - SIGINT SIGTERM EXIT @@ -101,7 +102,7 @@ function setup_gpt_conf() { function setup_crypto_aesni_conf() { # Malloc0 and Malloc1 use AESNI - "$rpc_py" <<-RPC + "$rpc_py" <<- RPC bdev_malloc_create -b Malloc0 16 512 bdev_malloc_create -b Malloc1 16 512 bdev_crypto_create Malloc0 crypto_ram crypto_aesni_mb 0123456789123456 @@ -112,7 +113,7 @@ function setup_crypto_aesni_conf() { function setup_crypto_qat_conf() { # Malloc0 will use QAT AES_CBC # Malloc1 will use QAT AES_XTS - "$rpc_py" <<-RPC + "$rpc_py" <<- RPC bdev_malloc_create -b Malloc0 16 512 bdev_malloc_create -b Malloc1 16 512 bdev_crypto_create Malloc0 crypto_ram crypto_qat 0123456789123456 @@ -195,7 +196,7 @@ function fio_test_suite() { local fio_params="--ioengine=spdk_bdev --iodepth=8 --bs=4k --runtime=10 $testdir/bdev.fio --spdk_json_conf=$conf_file" run_test "bdev_fio_rw_verify" fio_bdev $fio_params --spdk_mem=$PRE_RESERVED_MEM \ - --output=$output_dir/blockdev_fio_verify.txt + --output=$output_dir/blockdev_fio_verify.txt rm -f ./*.state rm -f $testdir/bdev.fio @@ -227,20 +228,19 @@ function get_io_result() { iostat_result=$(awk '{print $6}' <<< $iostat_result) fi - echo ${iostat_result/.*} + echo ${iostat_result/.*/} } - function run_qos_test() { local qos_limit=$1 local qos_result=0 qos_result=$(get_io_result $2 $3) if [ $2 = BANDWIDTH ]; then - qos_limit=$((qos_limit*1024)) + qos_limit=$((qos_limit * 1024)) fi - lower_limit=$((qos_limit*9/10)) - upper_limit=$((qos_limit*11/10)) + lower_limit=$((qos_limit * 9 / 10)) + upper_limit=$((qos_limit * 11 / 10)) # QoS realization is related with bytes transfered. It currently has some variation. if [ $qos_result -lt $lower_limit ] || [ $qos_result -gt $upper_limit ]; then @@ -261,7 +261,7 @@ function qos_function_test() { io_result=$(get_io_result IOPS $QOS_DEV_1) # Set the IOPS limit as one quarter of the measured performance without QoS - iops_limit=$(((io_result/4)/qos_lower_iops_limit*qos_lower_iops_limit)) + iops_limit=$(((io_result / 4) / qos_lower_iops_limit * qos_lower_iops_limit)) if [ $iops_limit -gt $qos_lower_iops_limit ]; then # Run bdevperf with IOPS rate limit on bdev 1 @@ -271,7 +271,7 @@ function qos_function_test() { # Run bdevperf with bandwidth rate limit on bdev 2 # Set the bandwidth limit as 1/10 of the measure performance without QoS bw_limit=$(get_io_result BANDWIDTH $QOS_DEV_2) - bw_limit=$((bw_limit/1024/10)) + bw_limit=$((bw_limit / 1024 / 10)) if [ $bw_limit -lt $qos_lower_bw_limit ]; then bw_limit=$qos_lower_bw_limit fi @@ -325,34 +325,40 @@ fi test_type=${1:-bdev} start_spdk_tgt case "$test_type" in - bdev ) - setup_bdev_conf;; - nvme ) - setup_nvme_conf;; - gpt ) - setup_gpt_conf;; - crypto_aesni ) - setup_crypto_aesni_conf;; - crypto_qat ) - setup_crypto_qat_conf;; - pmem ) - setup_pmem_conf;; - rbd ) - setup_rbd_conf;; - * ) + bdev) + setup_bdev_conf + ;; + nvme) + setup_nvme_conf + ;; + gpt) + setup_gpt_conf + ;; + crypto_aesni) + setup_crypto_aesni_conf + ;; + crypto_qat) + setup_crypto_qat_conf + ;; + pmem) + setup_pmem_conf + ;; + rbd) + setup_rbd_conf + ;; + *) echo "invalid test name" exit 1 ;; esac # Generate json config and use it throughout all the tests -cat <<-CONF >"$conf_file" - {"subsystems":[ - $("$rpc_py" save_subsystem_config -n bdev) - ]} +cat <<- CONF > "$conf_file" + {"subsystems":[ + $("$rpc_py" save_subsystem_config -n bdev) + ]} CONF - bdevs=$("$rpc_py" bdev_get_bdevs | jq -r '.[] | select(.claimed == false)') bdevs_name=$(echo $bdevs | jq -r '.name') bdev_list=($bdevs_name) @@ -366,12 +372,12 @@ run_test "bdev_hello_world" $rootdir/examples/bdev/hello_world/hello_bdev --json run_test "bdev_bounds" bdev_bounds run_test "bdev_nbd" nbd_function_test $conf_file "$bdevs_name" if [[ $CONFIG_FIO_PLUGIN == y ]]; then - if [ "$test_type" = "nvme" ] || [ "$test_type" = "gpt" ]; then - # TODO: once we get real multi-ns drives, re-enable this test for NVMe. - echo "skipping fio tests on NVMe due to multi-ns failures." - else - run_test "bdev_fio" fio_test_suite - fi + if [ "$test_type" = "nvme" ] || [ "$test_type" = "gpt" ]; then + # TODO: once we get real multi-ns drives, re-enable this test for NVMe. + echo "skipping fio tests on NVMe due to multi-ns failures." + else + run_test "bdev_fio" fio_test_suite + fi else echo "FIO not available" exit 1 @@ -386,7 +392,7 @@ fi # Temporarily disabled - infinite loop # if [ $RUN_NIGHTLY -eq 1 ]; then - # run_test "bdev_reset" $testdir/bdevperf/bdevperf --json "$conf_file" -q 16 -w reset -o 4096 -t 60 +# run_test "bdev_reset" $testdir/bdevperf/bdevperf --json "$conf_file" -q 16 -w reset -o 4096 -t 60 # fi # Bdev and configuration cleanup below this line diff --git a/test/bdev/nbd_common.sh b/test/bdev/nbd_common.sh index 533845c0dd..d72dcffc15 100644 --- a/test/bdev/nbd_common.sh +++ b/test/bdev/nbd_common.sh @@ -6,7 +6,7 @@ function nbd_start_disks() { local nbd_list=($3) local i - for (( i=0; i<${#nbd_list[@]}; i++ )); do + for ((i = 0; i < ${#nbd_list[@]}; i++)); do $rootdir/scripts/rpc.py -s $rpc_server nbd_start_disk ${bdev_list[$i]} ${nbd_list[$i]} # Wait for nbd device ready waitfornbd $(basename ${nbd_list[$i]}) @@ -19,7 +19,7 @@ function nbd_start_disks_without_nbd_idx() { local i local nbd_device - for (( i=0; i<${#bdev_list[@]}; i++ )); do + for ((i = 0; i < ${#bdev_list[@]}; i++)); do nbd_device=$($rootdir/scripts/rpc.py -s $rpc_server nbd_start_disk ${bdev_list[$i]}) # Wait for nbd device ready waitfornbd $(basename ${nbd_device}) @@ -29,7 +29,7 @@ function nbd_start_disks_without_nbd_idx() { function waitfornbd_exit() { local nbd_name=$1 - for ((i=1; i<=20; i++)); do + for ((i = 1; i <= 20; i++)); do if grep -q -w $nbd_name /proc/partitions; then sleep 0.1 else diff --git a/test/blobfs/blobfs.sh b/test/blobfs/blobfs.sh index 820818325e..f8ca2c9eff 100755 --- a/test/blobfs/blobfs.sh +++ b/test/blobfs/blobfs.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash SYSTEM=$(uname -s) -if [ $SYSTEM = "FreeBSD" ] ; then - echo "blobfs.sh cannot run on FreeBSD currently." - exit 0 +if [ $SYSTEM = "FreeBSD" ]; then + echo "blobfs.sh cannot run on FreeBSD currently." + exit 0 fi testdir=$(readlink -f $(dirname $0)) @@ -28,7 +28,7 @@ function cleanup() { rm -f $conf_file } -function blobfs_start_app { +function blobfs_start_app() { $rootdir/test/app/bdev_svc/bdev_svc -r $rpc_server -c ${conf_file} & blobfs_pid=$! diff --git a/test/blobfs/rocksdb/rocksdb.sh b/test/blobfs/rocksdb/rocksdb.sh index d67666bb23..8a9cedddf9 100755 --- a/test/blobfs/rocksdb/rocksdb.sh +++ b/test/blobfs/rocksdb/rocksdb.sh @@ -10,7 +10,7 @@ dump_db_bench_on_err() { # Dump entire *.txt to stderr to clearly see what might have failed xtrace_disable - mapfile -t step_map <"$db_bench" + mapfile -t step_map < "$db_bench" printf '%s\n' "${step_map[@]/#/* $step (FAILED)}" >&2 xtrace_restore } @@ -22,9 +22,9 @@ run_step() { fi cat <<- EOL >> "$1"_flags.txt - --spdk=$ROCKSDB_CONF - --spdk_bdev=Nvme0n1 - --spdk_cache_size=$CACHE_SIZE + --spdk=$ROCKSDB_CONF + --spdk_bdev=Nvme0n1 + --spdk_cache_size=$CACHE_SIZE EOL db_bench=$1_db_bench.txt @@ -60,8 +60,8 @@ fi EXTRA_CXXFLAGS="" GCC_VERSION=$(cc -dumpversion | cut -d. -f1) -if (( GCC_VERSION >= 9 )); then - EXTRA_CXXFLAGS+="-Wno-deprecated-copy -Wno-pessimizing-move -Wno-error=stringop-truncation" +if ((GCC_VERSION >= 9)); then + EXTRA_CXXFLAGS+="-Wno-deprecated-copy -Wno-pessimizing-move -Wno-error=stringop-truncation" fi $MAKE db_bench $MAKEFLAGS $MAKECONFIG DEBUG_LEVEL=0 SPDK_DIR=$rootdir EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS" diff --git a/test/blobstore/blob_io_wait/blob_io_wait.sh b/test/blobstore/blob_io_wait/blob_io_wait.sh index 72f64416f2..4cdca98f04 100755 --- a/test/blobstore/blob_io_wait/blob_io_wait.sh +++ b/test/blobstore/blob_io_wait/blob_io_wait.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash SYSTEM=$(uname -s) -if [ $SYSTEM = "FreeBSD" ] ; then - echo "blob_io_wait.sh cannot run on FreeBSD currently." - exit 0 +if [ $SYSTEM = "FreeBSD" ]; then + echo "blob_io_wait.sh cannot run on FreeBSD currently." + exit 0 fi testdir=$(readlink -f $(dirname $0)) diff --git a/test/blobstore/blobstore.sh b/test/blobstore/blobstore.sh index 4baf5fbecc..7a076efaf8 100755 --- a/test/blobstore/blobstore.sh +++ b/test/blobstore/blobstore.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash SYSTEM=$(uname -s) -if [ $SYSTEM = "FreeBSD" ] ; then - echo "blobstore.sh cannot run on FreeBSD currently." - exit 0 +if [ $SYSTEM = "FreeBSD" ]; then + echo "blobstore.sh cannot run on FreeBSD currently." + exit 0 fi testdir=$(readlink -f $(dirname $0)) @@ -16,8 +16,8 @@ $rootdir/scripts/gen_nvme.sh > $testdir/blobcli.conf # generate random data file for import/export diff dd if=/dev/urandom of=$testdir/test.pattern bs=1M count=1 -(cd $testdir && -$rootdir/examples/blob/cli/blobcli -c $testdir/blobcli.conf -b Nvme0n1 -T $testdir/test.bs > $testdir/btest.out) +(cd $testdir \ + && $rootdir/examples/blob/cli/blobcli -c $testdir/blobcli.conf -b Nvme0n1 -T $testdir/test.bs > $testdir/btest.out) # the test script will import the test pattern generated by dd and then export # it to a file so we can compare and confirm basic read and write diff --git a/test/common/applications.sh b/test/common/applications.sh index e268e77cf4..837df0a8f8 100644 --- a/test/common/applications.sh +++ b/test/common/applications.sh @@ -12,8 +12,8 @@ VHOST_APP=("$_app_dir/vhost/vhost") # Check if apps should execute under debug flags if [[ -e $_root/include/spdk/config.h ]]; then - if [[ $(<"$_root/include/spdk/config.h") == *"#define SPDK_CONFIG_DEBUG"* ]] \ - && (( SPDK_AUTOTEST_DEBUG_APPS )); then + if [[ $(< "$_root/include/spdk/config.h") == *"#define SPDK_CONFIG_DEBUG"* ]] \ + && ((SPDK_AUTOTEST_DEBUG_APPS)); then VHOST_FUZZ_APP+=("--log-flags=all") ISCSI_APP+=("--log-flags=all") NVMF_APP+=("--log-flags=all") diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index b607f265d1..54553ae36a 100755 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -7,10 +7,10 @@ function xtrace_disable() { XTRACE_DISABLED="yes" fi set +x - elif [ -z $XTRACE_NESTING_LEVEL ]; then - XTRACE_NESTING_LEVEL=1 - else - XTRACE_NESTING_LEVEL=$((++XTRACE_NESTING_LEVEL)) + elif [ -z $XTRACE_NESTING_LEVEL ]; then + XTRACE_NESTING_LEVEL=1 + else + XTRACE_NESTING_LEVEL=$((++XTRACE_NESTING_LEVEL)) fi } @@ -22,7 +22,7 @@ source "$rootdir/test/common/applications.sh" if [[ -e $rootdir/test/common/build_config.sh ]]; then source "$rootdir/test/common/build_config.sh" elif [[ -e $rootdir/mk/config.mk ]]; then - build_config=$(<"$rootdir/mk/config.mk") + build_config=$(< "$rootdir/mk/config.mk") source <(echo "${build_config//\?=/=}") else source "$rootdir/CONFIG" @@ -39,8 +39,7 @@ function xtrace_enable() { # Keep it as alias to avoid xtrace_enable backtrace always pointing to xtrace_restore. # xtrace_enable will appear as called directly from the user script, from the same line # that "called" xtrace_restore. -alias xtrace_restore=\ -'if [ -z $XTRACE_NESTING_LEVEL ]; then +alias xtrace_restore='if [ -z $XTRACE_NESTING_LEVEL ]; then if [[ "$PREV_BASH_OPTS" == *"x"* ]]; then XTRACE_DISABLED="no"; PREV_BASH_OPTS=""; set -x; xtrace_enable; fi @@ -55,42 +54,78 @@ fi' export RUN_NIGHTLY # Set defaults for missing test config options -: ${SPDK_AUTOTEST_DEBUG_APPS:=0}; export SPDK_AUTOTEST_DEBUG_APPS -: ${SPDK_RUN_VALGRIND=0}; export SPDK_RUN_VALGRIND -: ${SPDK_RUN_FUNCTIONAL_TEST=0}; export SPDK_RUN_FUNCTIONAL_TEST -: ${SPDK_TEST_UNITTEST=0}; export SPDK_TEST_UNITTEST -: ${SPDK_TEST_AUTOBUILD=0}; export SPDK_TEST_AUTOBUILD -: ${SPDK_TEST_ISAL=0}; export SPDK_TEST_ISAL -: ${SPDK_TEST_ISCSI=0}; export SPDK_TEST_ISCSI -: ${SPDK_TEST_ISCSI_INITIATOR=0}; export SPDK_TEST_ISCSI_INITIATOR -: ${SPDK_TEST_NVME=0}; export SPDK_TEST_NVME -: ${SPDK_TEST_NVME_CLI=0}; export SPDK_TEST_NVME_CLI -: ${SPDK_TEST_NVME_CUSE=0}; export SPDK_TEST_NVME_CUSE -: ${SPDK_TEST_NVMF=0}; export SPDK_TEST_NVMF -: ${SPDK_TEST_NVMF_TRANSPORT="rdma"}; export SPDK_TEST_NVMF_TRANSPORT -: ${SPDK_TEST_RBD=0}; export SPDK_TEST_RBD -: ${SPDK_TEST_VHOST=0}; export SPDK_TEST_VHOST -: ${SPDK_TEST_BLOCKDEV=0}; export SPDK_TEST_BLOCKDEV -: ${SPDK_TEST_IOAT=0}; export SPDK_TEST_IOAT -: ${SPDK_TEST_BLOBFS=0}; export SPDK_TEST_BLOBFS -: ${SPDK_TEST_VHOST_INIT=0}; export SPDK_TEST_VHOST_INIT -: ${SPDK_TEST_PMDK=0}; export SPDK_TEST_PMDK -: ${SPDK_TEST_LVOL=0}; export SPDK_TEST_LVOL -: ${SPDK_TEST_JSON=0}; export SPDK_TEST_JSON -: ${SPDK_TEST_REDUCE=0}; export SPDK_TEST_REDUCE -: ${SPDK_TEST_VPP=0}; export SPDK_TEST_VPP -: ${SPDK_RUN_ASAN=0}; export SPDK_RUN_ASAN -: ${SPDK_RUN_UBSAN=0}; export SPDK_RUN_UBSAN -: ${SPDK_RUN_INSTALLED_DPDK=0}; export SPDK_RUN_INSTALLED_DPDK -: ${SPDK_RUN_NON_ROOT=0}; export SPDK_RUN_NON_ROOT -: ${SPDK_TEST_CRYPTO=0}; export SPDK_TEST_CRYPTO -: ${SPDK_TEST_FTL=0}; export SPDK_TEST_FTL -: ${SPDK_TEST_OCF=0}; export SPDK_TEST_OCF -: ${SPDK_TEST_FTL_EXTENDED=0}; export SPDK_TEST_FTL_EXTENDED -: ${SPDK_TEST_VMD=0}; export SPDK_TEST_VMD -: ${SPDK_TEST_OPAL=0}; export SPDK_TEST_OPAL -: ${SPDK_AUTOTEST_X=true}; export SPDK_AUTOTEST_X -: ${SPDK_TEST_RAID5=0}; export SPDK_TEST_RAID5 +: ${SPDK_AUTOTEST_DEBUG_APPS:=0} +export SPDK_AUTOTEST_DEBUG_APPS +: ${SPDK_RUN_VALGRIND=0} +export SPDK_RUN_VALGRIND +: ${SPDK_RUN_FUNCTIONAL_TEST=0} +export SPDK_RUN_FUNCTIONAL_TEST +: ${SPDK_TEST_UNITTEST=0} +export SPDK_TEST_UNITTEST +: ${SPDK_TEST_AUTOBUILD=0} +export SPDK_TEST_AUTOBUILD +: ${SPDK_TEST_ISAL=0} +export SPDK_TEST_ISAL +: ${SPDK_TEST_ISCSI=0} +export SPDK_TEST_ISCSI +: ${SPDK_TEST_ISCSI_INITIATOR=0} +export SPDK_TEST_ISCSI_INITIATOR +: ${SPDK_TEST_NVME=0} +export SPDK_TEST_NVME +: ${SPDK_TEST_NVME_CLI=0} +export SPDK_TEST_NVME_CLI +: ${SPDK_TEST_NVME_CUSE=0} +export SPDK_TEST_NVME_CUSE +: ${SPDK_TEST_NVMF=0} +export SPDK_TEST_NVMF +: ${SPDK_TEST_NVMF_TRANSPORT="rdma"} +export SPDK_TEST_NVMF_TRANSPORT +: ${SPDK_TEST_RBD=0} +export SPDK_TEST_RBD +: ${SPDK_TEST_VHOST=0} +export SPDK_TEST_VHOST +: ${SPDK_TEST_BLOCKDEV=0} +export SPDK_TEST_BLOCKDEV +: ${SPDK_TEST_IOAT=0} +export SPDK_TEST_IOAT +: ${SPDK_TEST_BLOBFS=0} +export SPDK_TEST_BLOBFS +: ${SPDK_TEST_VHOST_INIT=0} +export SPDK_TEST_VHOST_INIT +: ${SPDK_TEST_PMDK=0} +export SPDK_TEST_PMDK +: ${SPDK_TEST_LVOL=0} +export SPDK_TEST_LVOL +: ${SPDK_TEST_JSON=0} +export SPDK_TEST_JSON +: ${SPDK_TEST_REDUCE=0} +export SPDK_TEST_REDUCE +: ${SPDK_TEST_VPP=0} +export SPDK_TEST_VPP +: ${SPDK_RUN_ASAN=0} +export SPDK_RUN_ASAN +: ${SPDK_RUN_UBSAN=0} +export SPDK_RUN_UBSAN +: ${SPDK_RUN_INSTALLED_DPDK=0} +export SPDK_RUN_INSTALLED_DPDK +: ${SPDK_RUN_NON_ROOT=0} +export SPDK_RUN_NON_ROOT +: ${SPDK_TEST_CRYPTO=0} +export SPDK_TEST_CRYPTO +: ${SPDK_TEST_FTL=0} +export SPDK_TEST_FTL +: ${SPDK_TEST_OCF=0} +export SPDK_TEST_OCF +: ${SPDK_TEST_FTL_EXTENDED=0} +export SPDK_TEST_FTL_EXTENDED +: ${SPDK_TEST_VMD=0} +export SPDK_TEST_VMD +: ${SPDK_TEST_OPAL=0} +export SPDK_TEST_OPAL +: ${SPDK_AUTOTEST_X=true} +export SPDK_AUTOTEST_X +: ${SPDK_TEST_RAID5=0} +export SPDK_TEST_RAID5 # Export PYTHONPATH with addition of RPC framework. New scripts can be created # specific use cases for tests. @@ -194,7 +229,7 @@ for i in "$@"; do done # start rpc.py coprocess if it's not started yet -if [[ -z $RPC_PIPE_PID ]] || ! kill -0 "$RPC_PIPE_PID" &>/dev/null; then +if [[ -z $RPC_PIPE_PID ]] || ! kill -0 "$RPC_PIPE_PID" &> /dev/null; then coproc RPC_PIPE { "$rootdir/scripts/rpc.py" --server; } exec {RPC_PIPE_OUTPUT}<&${RPC_PIPE[0]} {RPC_PIPE_INPUT}>&${RPC_PIPE[1]} # all descriptors will automatically close together with this bash @@ -211,8 +246,8 @@ function get_config_params() { xtrace_disable config_params='--enable-debug --enable-werror' - if echo -e "#include \nint main(int argc, char *argv[]) {return 0;}\n" | \ - gcc -o /dev/null -lunwind -x c - 2>/dev/null; then + if echo -e "#include \nint main(int argc, char *argv[]) {return 0;}\n" \ + | gcc -o /dev/null -lunwind -x c - 2> /dev/null; then config_params+=' --enable-log-bt' fi @@ -221,13 +256,13 @@ function get_config_params() { config_params+=' --with-rdma' fi - if [ $(uname -s) == "FreeBSD" ]; then - intel="hw.model: Intel" - cpu_vendor=$(sysctl -a | grep hw.model | cut -c 1-15) - else - intel="GenuineIntel" - cpu_vendor=$(grep -i 'vendor' /proc/cpuinfo --max-count=1) - fi + if [ $(uname -s) == "FreeBSD" ]; then + intel="hw.model: Intel" + cpu_vendor=$(sysctl -a | grep hw.model | cut -c 1-15) + else + intel="GenuineIntel" + cpu_vendor=$(grep -i 'vendor' /proc/cpuinfo --max-count=1) + fi if [[ "$cpu_vendor" != *"$intel"* ]]; then config_params+=" --without-idxd" else @@ -268,7 +303,7 @@ function get_config_params() { fi fi - if [ -d /usr/include/rbd ] && [ -d /usr/include/rados ] && [ $SPDK_TEST_RBD -eq 1 ]; then + if [ -d /usr/include/rbd ] && [ -d /usr/include/rados ] && [ $SPDK_TEST_RBD -eq 1 ]; then config_params+=' --with-rbd' fi @@ -375,7 +410,7 @@ function rpc_cmd_simple_data_json() { while read -r elem val; do jq_out["$elem"]=$val done < <(rpc_cmd "$@" | jq -jr "$jq") - (( ${#jq_out[@]} > 0 )) || return 1 + ((${#jq_out[@]} > 0)) || return 1 } # invert error code of any command and also trigger ERR on 0 (unlike bash ! prefix) @@ -428,7 +463,7 @@ function timing_finish() { --nametype 'Step:' \ --countname seconds \ $output_dir/timing.txt \ - >$output_dir/timing.svg + > $output_dir/timing.svg fi } @@ -439,8 +474,8 @@ function create_test_list() { # Follow up with search in test directory recursively. completion+=$(grep -rshI --include="*.sh" --exclude="autotest_common.sh" -e "run_test " $rootdir/test) printf "%s" "$completion" | grep -v "#" \ - | sed 's/^.*run_test/run_test/' | awk '{print $2}' | \ - sed 's/\"//g' | sort > $output_dir/all_tests.txt || true + | sed 's/^.*run_test/run_test/' | awk '{print $2}' \ + | sed 's/\"//g' | sort > $output_dir/all_tests.txt || true xtrace_restore } @@ -464,15 +499,14 @@ function gdb_attach() { function process_core() { ret=0 - while IFS= read -r -d '' core; - do + while IFS= read -r -d '' core; do exe=$(eu-readelf -n "$core" | grep psargs | sed "s/.*psargs: \([^ \'\" ]*\).*/\1/") if [[ ! -f "$exe" ]]; then exe=$(eu-readelf -n "$core" | grep -oP -m1 "$exe.+") fi echo "exe for $core is $exe" if [[ -n "$exe" ]]; then - if hash gdb &>/dev/null; then + if hash gdb &> /dev/null; then gdb -batch -ex "thread apply all bt full" $exe $core fi cp $exe $output_dir @@ -521,7 +555,7 @@ function waitforlisten() { xtrace_disable local ret=0 local i - for (( i = 40; i != 0; i-- )); do + for ((i = 40; i != 0; i--)); do # if the process is no longer running, then exit the script # since it means the application crashed if ! kill -s 0 $1; then @@ -530,7 +564,7 @@ function waitforlisten() { break fi - if $rootdir/scripts/rpc.py -t 1 -s "$rpc_addr" rpc_get_methods &>/dev/null; then + if $rootdir/scripts/rpc.py -t 1 -s "$rpc_addr" rpc_get_methods &> /dev/null; then break fi @@ -538,7 +572,7 @@ function waitforlisten() { done xtrace_restore - if (( i == 0 )); then + if ((i == 0)); then echo "ERROR: timeout while waiting for process (pid: $1) to start listening on '$rpc_addr'" ret=1 fi @@ -549,7 +583,7 @@ function waitfornbd() { local nbd_name=$1 local i - for ((i=1; i<=20; i++)); do + for ((i = 1; i <= 20; i++)); do if grep -q -w $nbd_name /proc/partitions; then break else @@ -562,7 +596,7 @@ function waitfornbd() { # here trying to read the first block of the nbd block device to a temp # file. Note that dd returns success when reading an empty file, so we # need to check the size of the output file instead. - for ((i=1; i<=20; i++)); do + for ((i = 1; i <= 20; i++)); do dd if=/dev/$nbd_name of=/tmp/nbdtest bs=4096 count=1 iflag=direct size=$(stat -c %s /tmp/nbdtest) rm -f /tmp/nbdtest @@ -580,7 +614,7 @@ function waitforbdev() { local bdev_name=$1 local i - for ((i=1; i<=20; i++)); do + for ((i = 1; i <= 20; i++)); do if $rpc_py bdev_get_bdevs | jq -r '.[] .name' | grep -qw $bdev_name; then return 0 fi @@ -611,7 +645,7 @@ function make_filesystem() { if [ $i -ge 15 ]; then return 1 fi - i=$((i+1)) + i=$((i + 1)) sleep 1 done @@ -715,7 +749,7 @@ function _start_stub() { # but ASLR can still be unreliable in some cases. # We will reenable it again after multi-process testing is complete in kill_stub(). # Save current setting so it can be restored upon calling kill_stub(). - _randomize_va_space=$( /proc/sys/kernel/randomize_va_space $rootdir/test/app/stub/stub $1 & stubpid=$! @@ -739,7 +773,7 @@ function kill_stub() { if [[ -e /proc/$stubpid ]]; then kill $1 $stubpid wait $stubpid - fi 2>/dev/null || : + fi 2> /dev/null || : rm -f /var/run/spdk_stub0 # Re-enable ASLR now that we are done with multi-process testing # Note: "1" enables ASLR w/o randomizing data segments, "2" adds data segment @@ -811,12 +845,12 @@ function print_backtrace() { local bt="" cmdline=() if [[ -f $src ]]; then - bt=$(nl -w 4 -ba -nln $src | grep -B 5 -A 5 "^${line_nr}[^0-9]" | \ - sed "s/^/ /g" | sed "s/^ $line_nr /=> $line_nr /g") + bt=$(nl -w 4 -ba -nln $src | grep -B 5 -A 5 "^${line_nr}[^0-9]" \ + | sed "s/^/ /g" | sed "s/^ $line_nr /=> $line_nr /g") fi # If extdebug set the BASH_ARGC[i], try to fetch all the args - if (( BASH_ARGC[i] > 0 )); then + if ((BASH_ARGC[i] > 0)); then # Use argc as index to reverse the stack local argc=${BASH_ARGC[i]} arg for arg in "${args[@]::BASH_ARGC[i]}"; do @@ -825,7 +859,10 @@ function print_backtrace() { args=("${args[@]:BASH_ARGC[i]}") fi - echo "in $src:$line_nr -> $func($(IFS=","; printf '%s\n' "${cmdline[*]:-[]}"))" + echo "in $src:$line_nr -> $func($( + IFS="," + printf '%s\n' "${cmdline[*]:-[]}" + ))" echo " ..." echo "${bt:-backtrace unavailable}" echo " ..." @@ -836,8 +873,7 @@ function print_backtrace() { return 0 } -function discover_bdevs() -{ +function discover_bdevs() { local rootdir=$1 local config_file=$2 local cfg_type=$3 @@ -856,11 +892,11 @@ function discover_bdevs() # Start the bdev service to query for the list of available # bdevs. $rootdir/test/app/bdev_svc/bdev_svc -r $rpc_server -i 0 \ - $cfg_type $config_file &>/dev/null & + $cfg_type $config_file &> /dev/null & stubpid=$! while ! [ -e /var/run/spdk_bdev0 ]; do # If this counter drops to zero, errexit will be caught to abort the test - (( wait_for_spdk_bdev-- )) + ((wait_for_spdk_bdev--)) sleep 1 done @@ -873,8 +909,7 @@ function discover_bdevs() rm -f /var/run/spdk_bdev0 } -function waitforserial() -{ +function waitforserial() { local i=0 local nvme_device_counter=1 if [[ -n "$2" ]]; then @@ -883,7 +918,7 @@ function waitforserial() while [ $(lsblk -l -o NAME,SERIAL | grep -c $1) -lt $nvme_device_counter ]; do [ $i -lt 15 ] || break - i=$((i+1)) + i=$((i + 1)) echo "Waiting for devices" sleep 1 done @@ -892,15 +927,14 @@ function waitforserial() return 1 fi - return 0 + return 0 } -function waitforserial_disconnect() -{ +function waitforserial_disconnect() { local i=0 while lsblk -o NAME,SERIAL | grep -q -w $1; do [ $i -lt 15 ] || break - i=$((i+1)) + i=$((i + 1)) echo "Waiting for disconnect devices" sleep 1 done @@ -912,12 +946,11 @@ function waitforserial_disconnect() return 0 } -function waitforblk() -{ +function waitforblk() { local i=0 while ! lsblk -l -o NAME | grep -q -w $1; do [ $i -lt 15 ] || break - i=$((i+1)) + i=$((i + 1)) sleep 1 done @@ -928,12 +961,11 @@ function waitforblk() return 0 } -function waitforblk_disconnect() -{ +function waitforblk_disconnect() { local i=0 while lsblk -l -o NAME | grep -q -w $1; do [ $i -lt 15 ] || break - i=$((i+1)) + i=$((i + 1)) sleep 1 done @@ -944,12 +976,11 @@ function waitforblk_disconnect() return 0 } -function waitforfile() -{ +function waitforfile() { local i=0 while [ ! -e $1 ]; do [ $i -lt 200 ] || break - i=$((i+1)) + i=$((i + 1)) sleep 0.1 done @@ -960,8 +991,7 @@ function waitforfile() return 0 } -function fio_config_gen() -{ +function fio_config_gen() { local config_file=$1 local workload=$2 local bdev_type=$3 @@ -991,9 +1021,9 @@ EOL if [ "$workload" == "verify" ]; then cat <<- EOL >> $config_file - verify=sha1 - verify_backlog=1024 - rw=randwrite + verify=sha1 + verify_backlog=1024 + rw=randwrite EOL # To avoid potential data race issue due to the AIO device @@ -1011,8 +1041,7 @@ EOL fi } -function fio_bdev() -{ +function fio_bdev() { # Setup fio binary cmd line local fio_dir=$CONFIG_FIO_SOURCE_DIR local bdev_plugin="$rootdir/examples/bdev/fio_plugin/fio_plugin" @@ -1024,8 +1053,7 @@ function fio_bdev() LD_PRELOAD="$asan_lib $bdev_plugin" "$fio_dir"/fio "$@" } -function fio_nvme() -{ +function fio_nvme() { # Setup fio binary cmd line local fio_dir=$CONFIG_FIO_SOURCE_DIR local nvme_plugin="$rootdir/examples/nvme/fio_plugin/fio_plugin" @@ -1036,8 +1064,7 @@ function fio_nvme() LD_PRELOAD="$asan_lib $nvme_plugin" "$fio_dir"/fio "$@" } -function get_lvs_free_mb() -{ +function get_lvs_free_mb() { local lvs_uuid=$1 local lvs_info local fc @@ -1047,12 +1074,11 @@ function get_lvs_free_mb() cs=$(jq ".[] | select(.uuid==\"$lvs_uuid\") .cluster_size" <<< "$lvs_info") # Change to MB's - free_mb=$((fc*cs/1024/1024)) + free_mb=$((fc * cs / 1024 / 1024)) echo "$free_mb" } -function get_bdev_size() -{ +function get_bdev_size() { local bdev_name=$1 local bdev_info local bs @@ -1062,12 +1088,11 @@ function get_bdev_size() nb=$(jq ".[] .num_blocks" <<< "$bdev_info") # Change to MB's - bdev_size=$((bs*nb/1024/1024)) + bdev_size=$((bs * nb / 1024 / 1024)) echo "$bdev_size" } -function autotest_cleanup() -{ +function autotest_cleanup() { $rootdir/scripts/setup.sh reset $rootdir/scripts/setup.sh cleanup if [ $(uname -s) = "Linux" ]; then @@ -1080,8 +1105,7 @@ function autotest_cleanup() rm -rf "$asan_suppression_file" } -function freebsd_update_contigmem_mod() -{ +function freebsd_update_contigmem_mod() { if [ $(uname) = FreeBSD ]; then kldunload contigmem.ko || true if [ -n "$WITH_DPDK_DIR" ]; then @@ -1099,7 +1123,7 @@ function freebsd_update_contigmem_mod() fi } -function get_nvme_name_from_bdf { +function get_nvme_name_from_bdf() { blkname=() nvme_devs=$(lsblk -d --output NAME | grep "^nvme") || true @@ -1120,7 +1144,7 @@ function get_nvme_name_from_bdf { printf '%s\n' "${blkname[@]}" } -function opal_revert_cleanup { +function opal_revert_cleanup() { $rootdir/app/spdk_tgt/spdk_tgt & spdk_tgt_pid=$! waitforlisten $spdk_tgt_pid @@ -1138,14 +1162,14 @@ function opal_revert_cleanup { # Get BDF addresses of all NVMe drives currently attached to # uio-pci-generic or vfio-pci function get_nvme_bdfs() { - xtrace_disable - jq -r .config[].params.traddr <<< $(scripts/gen_nvme.sh --json) - xtrace_restore + xtrace_disable + jq -r .config[].params.traddr <<< $(scripts/gen_nvme.sh --json) + xtrace_restore } # Same as function above, but just get the first disks BDF address function get_first_nvme_bdf() { - head -1 <<< $(get_nvme_bdfs) + head -1 <<< $(get_nvme_bdfs) } set -o errtrace diff --git a/test/common/config/vm_setup.sh b/test/common/config/vm_setup.sh index 4001e59994..af3c73eb3e 100755 --- a/test/common/config/vm_setup.sh +++ b/test/common/config/vm_setup.sh @@ -28,678 +28,683 @@ CONF="librxe,iscsi,rocksdb,fio,flamegraph,tsocks,qemu,vpp,libiscsi,nvmecli,qat" LIBRXE_INSTALL=true if [ $(uname -s) == "FreeBSD" ]; then - OSID="freebsd" - OSVERSION=$(freebsd-version | cut -d. -f1) - PACKAGEMNG='pkg' + OSID="freebsd" + OSVERSION=$(freebsd-version | cut -d. -f1) + PACKAGEMNG='pkg' else - OSID=$(source /etc/os-release && echo $ID) - OSVERSION=$(source /etc/os-release && echo $VERSION_ID) - PACKAGEMNG='undefined' + OSID=$(source /etc/os-release && echo $ID) + OSVERSION=$(source /etc/os-release && echo $VERSION_ID) + PACKAGEMNG='undefined' fi -function install_rxe_cfg() -{ - if echo $CONF | grep -q librxe; then - # rxe_cfg is used in the NVMe-oF tests - # The librxe-dev repository provides a command line tool called rxe_cfg which makes it - # very easy to use Soft-RoCE. The build pool utilizes this command line tool in the absence - # of any real RDMA NICs to simulate one for the NVMe-oF tests. - if hash rxe_cfg 2> /dev/null; then - echo "rxe_cfg is already installed. skipping" - else - if [ -d librxe-dev ]; then - echo "librxe-dev source already present, not cloning" - else - git clone "${GIT_REPO_LIBRXE}" - fi +function install_rxe_cfg() { + if echo $CONF | grep -q librxe; then + # rxe_cfg is used in the NVMe-oF tests + # The librxe-dev repository provides a command line tool called rxe_cfg which makes it + # very easy to use Soft-RoCE. The build pool utilizes this command line tool in the absence + # of any real RDMA NICs to simulate one for the NVMe-oF tests. + if hash rxe_cfg 2> /dev/null; then + echo "rxe_cfg is already installed. skipping" + else + if [ -d librxe-dev ]; then + echo "librxe-dev source already present, not cloning" + else + git clone "${GIT_REPO_LIBRXE}" + fi - ./librxe-dev/configure --libdir=/usr/lib64/ --prefix= - make -C librxe-dev -j${jobs} - sudo make -C librxe-dev install - fi - fi -} - -function install_iscsi_adm() -{ - if echo $CONF | grep -q iscsi; then - # iscsiadm is used in the iscsi_tgt tests - # The version of iscsiadm that ships with fedora 26 was broken as of November 3 2017. - # There is already a bug report out about it, and hopefully it is fixed soon, but in the event that - # that version is still broken when you do your setup, the below steps will fix the issue. - CURRENT_VERSION=$(iscsiadm --version) - OPEN_ISCSI_VER='iscsiadm version 6.2.0.874' - if [ "$CURRENT_VERSION" == "$OPEN_ISCSI_VER" ]; then - if [ ! -d open-iscsi-install ]; then - mkdir -p open-iscsi-install/patches - sudo dnf download --downloaddir=./open-iscsi-install --source iscsi-initiator-utils - rpm2cpio open-iscsi-install/$(ls ~/open-iscsi-install) | cpio -D open-iscsi-install -idmv - mv open-iscsi-install/00* open-iscsi-install/patches/ - git clone "${GIT_REPO_OPEN_ISCSI}" open-iscsi-install/open-iscsi - - # the configurations of username and email are needed for applying patches to iscsiadm. - git -C open-iscsi-install/open-iscsi config user.name none - git -C open-iscsi-install/open-iscsi config user.email none - - git -C open-iscsi-install/open-iscsi checkout 86e8892 - for patch in open-iscsi-install/patches/*; do - git -C open-iscsi-install/open-iscsi am ../patches/$patch - done - sed -i '427s/.*/-1);/' open-iscsi-install/open-iscsi/usr/session_info.c - make -C open-iscsi-install/open-iscsi -j${jobs} - sudo make -C open-iscsi-install/open-iscsi install - else - echo "custom open-iscsi install located, not reinstalling" - fi - fi - fi -} - -function install_qat() -{ - - if [ "$PACKAGEMNG" = "dnf" ]; then - sudo dnf install -y libudev-devel - elif [ "$PACKAGEMNG" = "apt-get" ]; then - sudo apt-get install -y libudev-dev - fi - - if echo $CONF | grep -q qat; then - qat_tarball=$(basename $DRIVER_LOCATION_QAT) - kernel_maj=$(uname -r | cut -d'.' -f1) - kernel_min=$(uname -r | cut -d'.' -f2) - - sudo modprobe -r qat_c62x - if [ -d /QAT ]; then - sudo rm -rf /QAT/ - fi - - sudo mkdir /QAT - - wget $DRIVER_LOCATION_QAT - sudo cp $qat_tarball /QAT/ - (cd /QAT && sudo tar zxof /QAT/$qat_tarball) - - #The driver version 1.7.l.4.3.0-00033 contains a reference to a deprecated function. Remove it so the build won't fail. - if [ $kernel_maj -le 4 ]; then - if [ $kernel_min -le 17 ]; then - sudo sed -i 's/rdtscll(timestamp);/timestamp = rdtsc_ordered();/g' \ - /QAT/quickassist/utilities/osal/src/linux/kernel_space/OsalServices.c || true - fi - fi - - (cd /QAT && sudo ./configure --enable-icp-sriov=host && sudo make install) - - if sudo service qat_service start; then - echo "failed to start the qat service. Something may be wrong with your device or package." - fi - fi -} - -function install_rocksdb() -{ - if echo $CONF | grep -q rocksdb; then - # Rocksdb is installed for use with the blobfs tests. - if [ ! -d /usr/src/rocksdb ]; then - git clone "${GIT_REPO_ROCKSDB}" - git -C ./rocksdb checkout spdk-v5.6.1 - sudo mv rocksdb /usr/src/ - else - sudo git -C /usr/src/rocksdb checkout spdk-v5.6.1 - echo "rocksdb already in /usr/src. Not checking out again" - fi - fi -} - -function install_fio() -{ - if echo $CONF | grep -q fio; then - # This version of fio is installed in /usr/src/fio to enable - # building the spdk fio plugin. - local fio_version="fio-3.15" - - if [ ! -d /usr/src/fio ]; then - if [ ! -d fio ]; then - git clone "${GIT_REPO_FIO}" - sudo mv fio /usr/src/ - else - sudo mv fio /usr/src/ - fi - ( - git -C /usr/src/fio checkout master && - git -C /usr/src/fio pull && - git -C /usr/src/fio checkout $fio_version && - if [ $OSID == 'freebsd' ]; then - gmake -C /usr/src/fio -j${jobs} && - sudo gmake -C /usr/src/fio install - else - make -C /usr/src/fio -j${jobs} && - sudo make -C /usr/src/fio install - fi - ) - else - echo "fio already in /usr/src/fio. Not installing" - fi - fi -} - -function install_flamegraph() -{ - if echo $CONF | grep -q flamegraph; then - # Flamegraph is used when printing out timing graphs for the tests. - if [ ! -d /usr/local/FlameGraph ]; then - git clone "${GIT_REPO_FLAMEGRAPH}" - mkdir -p /usr/local - sudo mv FlameGraph /usr/local/FlameGraph - else - echo "flamegraph already installed. Skipping" - fi - fi -} - -function install_qemu() -{ - if echo $CONF | grep -q qemu; then - # Two versions of QEMU are used in the tests. - # Stock QEMU is used for vhost. A special fork - # is used to test OCSSDs. Install both. - - # Packaged QEMU - if [ "$PACKAGEMNG" = "dnf" ]; then - sudo dnf install -y qemu-system-x86 qemu-img - elif [ "$PACKAGEMNG" = "apt-get" ]; then - sudo apt-get install -y qemu-system-x86 qemu-img - elif [ "$PACKAGEMNG" = "pacman" ]; then - sudo pacman -Sy --needed --noconfirm qemu - fi - - # Forked QEMU - SPDK_QEMU_BRANCH=spdk-3.0.0 - mkdir -p qemu - if [ ! -d "qemu/$SPDK_QEMU_BRANCH" ]; then - git -C ./qemu clone "${GIT_REPO_QEMU}" -b "$SPDK_QEMU_BRANCH" "$SPDK_QEMU_BRANCH" - else - echo "qemu already checked out. Skipping" - fi - - declare -a opt_params=("--prefix=/usr/local/qemu/$SPDK_QEMU_BRANCH") - if [ "$PACKAGEMNG" = "pacman" ]; then - # GCC 9 on ArchLinux fails to compile Qemu due to some old warnings which were not detected by older versions. - opt_params+=("--extra-cflags=-Wno-error=stringop-truncation -Wno-error=deprecated-declarations -Wno-error=incompatible-pointer-types -Wno-error=format-truncation") - opt_params+=("--disable-glusterfs") - fi - - # Most tsocks proxies rely on a configuration file in /etc/tsocks.conf. - # If using tsocks, please make sure to complete this config before trying to build qemu. - if echo $CONF | grep -q tsocks; then - if hash tsocks 2> /dev/null; then - opt_params+=("--with-git='tsocks git'") - fi - fi - - sed -i s@git://git.qemu.org/@https://github.com/qemu/@g qemu/$SPDK_QEMU_BRANCH/.gitmodules - sed -i s@git://git.qemu.org/@https://github.com/qemu/@g qemu/$SPDK_QEMU_BRANCH/.git/config - sed -i s@git://git.qemu-project.org/@https://github.com/qemu/@g qemu/$SPDK_QEMU_BRANCH/.gitmodules - sed -i s@git://git.qemu-project.org/@https://github.com/qemu/@g qemu/$SPDK_QEMU_BRANCH/.git/config - # The qemu configure script places several output files in the CWD. - (cd qemu/$SPDK_QEMU_BRANCH && ./configure "${opt_params[@]}" --target-list="x86_64-softmmu" --enable-kvm --enable-linux-aio --enable-numa) - - make -C ./qemu/$SPDK_QEMU_BRANCH -j${jobs} - sudo make -C ./qemu/$SPDK_QEMU_BRANCH install - fi -} - -function install_vpp() -{ - if echo $CONF | grep -q vpp; then - if [ -d /usr/local/src/vpp ]; then - echo "vpp already cloned." - if [ ! -d /usr/local/src/vpp/build-root ]; then - echo "build-root has not been done" - echo "remove the $(pwd) and start again" - exit 1 - fi - else - git clone "${GIT_REPO_VPP}" - git -C ./vpp checkout v19.04.2 - - if [ "${OSID}" == 'fedora' ]; then - if [ ${OSVERSION} -eq 29 ]; then - git -C ./vpp apply ${VM_SETUP_PATH}/patch/vpp/fedora29-fix.patch - fi - if [ ${OSVERSION} -eq 30 ]; then - git -C ./vpp apply ${VM_SETUP_PATH}/patch/vpp/fedora30-fix.patch - fi - fi - - # Installing required dependencies for building VPP - yes | make -C ./vpp install-dep - - make -C ./vpp build -j${jobs} - - sudo mv ./vpp /usr/local/src/vpp-19.04 - fi - fi -} - -function install_nvmecli() -{ - if echo $CONF | grep -q nvmecli; then - SPDK_NVME_CLI_BRANCH=spdk-1.6 - if [ ! -d nvme-cli ]; then - git clone "${GIT_REPO_SPDK_NVME_CLI}" -b "$SPDK_NVME_CLI_BRANCH" - else - echo "nvme-cli already checked out. Skipping" - fi - if [ ! -d "/usr/local/src/nvme-cli" ]; then - git clone "https://review.spdk.io/spdk/nvme-cli" "nvme-cli-cuse" - git -C ./nvme-cli-cuse checkout nvme-cuse - make -C ./nvme-cli-cuse - sudo mv ./nvme-cli-cuse /usr/local/src/nvme-cli + ./librxe-dev/configure --libdir=/usr/lib64/ --prefix= + make -C librxe-dev -j${jobs} + sudo make -C librxe-dev install + fi fi - fi } +function install_iscsi_adm() { + if echo $CONF | grep -q iscsi; then + # iscsiadm is used in the iscsi_tgt tests + # The version of iscsiadm that ships with fedora 26 was broken as of November 3 2017. + # There is already a bug report out about it, and hopefully it is fixed soon, but in the event that + # that version is still broken when you do your setup, the below steps will fix the issue. + CURRENT_VERSION=$(iscsiadm --version) + OPEN_ISCSI_VER='iscsiadm version 6.2.0.874' + if [ "$CURRENT_VERSION" == "$OPEN_ISCSI_VER" ]; then + if [ ! -d open-iscsi-install ]; then + mkdir -p open-iscsi-install/patches + sudo dnf download --downloaddir=./open-iscsi-install --source iscsi-initiator-utils + rpm2cpio open-iscsi-install/$(ls ~/open-iscsi-install) | cpio -D open-iscsi-install -idmv + mv open-iscsi-install/00* open-iscsi-install/patches/ + git clone "${GIT_REPO_OPEN_ISCSI}" open-iscsi-install/open-iscsi -function install_libiscsi() -{ - if echo $CONF | grep -q libiscsi; then - # We currently don't make any changes to the libiscsi repository for our tests, but it is possible that we will need - # to later. Cloning from git is just future proofing the machines. - if [ ! -d libiscsi ]; then - git clone "${GIT_REPO_LIBISCSI}" - else - echo "libiscsi already checked out. Skipping" - fi - ( cd libiscsi && ./autogen.sh && ./configure --prefix=/usr/local/libiscsi) - make -C ./libiscsi -j${jobs} - sudo make -C ./libiscsi install - fi + # the configurations of username and email are needed for applying patches to iscsiadm. + git -C open-iscsi-install/open-iscsi config user.name none + git -C open-iscsi-install/open-iscsi config user.email none + + git -C open-iscsi-install/open-iscsi checkout 86e8892 + for patch in open-iscsi-install/patches/*; do + git -C open-iscsi-install/open-iscsi am ../patches/$patch + done + sed -i '427s/.*/-1);/' open-iscsi-install/open-iscsi/usr/session_info.c + make -C open-iscsi-install/open-iscsi -j${jobs} + sudo make -C open-iscsi-install/open-iscsi install + else + echo "custom open-iscsi install located, not reinstalling" + fi + fi + fi +} + +function install_qat() { + + if [ "$PACKAGEMNG" = "dnf" ]; then + sudo dnf install -y libudev-devel + elif [ "$PACKAGEMNG" = "apt-get" ]; then + sudo apt-get install -y libudev-dev + fi + + if echo $CONF | grep -q qat; then + qat_tarball=$(basename $DRIVER_LOCATION_QAT) + kernel_maj=$(uname -r | cut -d'.' -f1) + kernel_min=$(uname -r | cut -d'.' -f2) + + sudo modprobe -r qat_c62x + if [ -d /QAT ]; then + sudo rm -rf /QAT/ + fi + + sudo mkdir /QAT + + wget $DRIVER_LOCATION_QAT + sudo cp $qat_tarball /QAT/ + (cd /QAT && sudo tar zxof /QAT/$qat_tarball) + + #The driver version 1.7.l.4.3.0-00033 contains a reference to a deprecated function. Remove it so the build won't fail. + if [ $kernel_maj -le 4 ]; then + if [ $kernel_min -le 17 ]; then + sudo sed -i 's/rdtscll(timestamp);/timestamp = rdtsc_ordered();/g' \ + /QAT/quickassist/utilities/osal/src/linux/kernel_space/OsalServices.c || true + fi + fi + + (cd /QAT && sudo ./configure --enable-icp-sriov=host && sudo make install) + + if sudo service qat_service start; then + echo "failed to start the qat service. Something may be wrong with your device or package." + fi + fi +} + +function install_rocksdb() { + if echo $CONF | grep -q rocksdb; then + # Rocksdb is installed for use with the blobfs tests. + if [ ! -d /usr/src/rocksdb ]; then + git clone "${GIT_REPO_ROCKSDB}" + git -C ./rocksdb checkout spdk-v5.6.1 + sudo mv rocksdb /usr/src/ + else + sudo git -C /usr/src/rocksdb checkout spdk-v5.6.1 + echo "rocksdb already in /usr/src. Not checking out again" + fi + fi +} + +function install_fio() { + if echo $CONF | grep -q fio; then + # This version of fio is installed in /usr/src/fio to enable + # building the spdk fio plugin. + local fio_version="fio-3.15" + + if [ ! -d /usr/src/fio ]; then + if [ ! -d fio ]; then + git clone "${GIT_REPO_FIO}" + sudo mv fio /usr/src/ + else + sudo mv fio /usr/src/ + fi + ( + git -C /usr/src/fio checkout master \ + && git -C /usr/src/fio pull \ + && git -C /usr/src/fio checkout $fio_version \ + && if [ $OSID == 'freebsd' ]; then + gmake -C /usr/src/fio -j${jobs} \ + && sudo gmake -C /usr/src/fio install + else + make -C /usr/src/fio -j${jobs} \ + && sudo make -C /usr/src/fio install + fi + ) + else + echo "fio already in /usr/src/fio. Not installing" + fi + fi +} + +function install_flamegraph() { + if echo $CONF | grep -q flamegraph; then + # Flamegraph is used when printing out timing graphs for the tests. + if [ ! -d /usr/local/FlameGraph ]; then + git clone "${GIT_REPO_FLAMEGRAPH}" + mkdir -p /usr/local + sudo mv FlameGraph /usr/local/FlameGraph + else + echo "flamegraph already installed. Skipping" + fi + fi +} + +function install_qemu() { + if echo $CONF | grep -q qemu; then + # Two versions of QEMU are used in the tests. + # Stock QEMU is used for vhost. A special fork + # is used to test OCSSDs. Install both. + + # Packaged QEMU + if [ "$PACKAGEMNG" = "dnf" ]; then + sudo dnf install -y qemu-system-x86 qemu-img + elif [ "$PACKAGEMNG" = "apt-get" ]; then + sudo apt-get install -y qemu-system-x86 qemu-img + elif [ "$PACKAGEMNG" = "pacman" ]; then + sudo pacman -Sy --needed --noconfirm qemu + fi + + # Forked QEMU + SPDK_QEMU_BRANCH=spdk-3.0.0 + mkdir -p qemu + if [ ! -d "qemu/$SPDK_QEMU_BRANCH" ]; then + git -C ./qemu clone "${GIT_REPO_QEMU}" -b "$SPDK_QEMU_BRANCH" "$SPDK_QEMU_BRANCH" + else + echo "qemu already checked out. Skipping" + fi + + declare -a opt_params=("--prefix=/usr/local/qemu/$SPDK_QEMU_BRANCH") + if [ "$PACKAGEMNG" = "pacman" ]; then + # GCC 9 on ArchLinux fails to compile Qemu due to some old warnings which were not detected by older versions. + opt_params+=("--extra-cflags=-Wno-error=stringop-truncation -Wno-error=deprecated-declarations -Wno-error=incompatible-pointer-types -Wno-error=format-truncation") + opt_params+=("--disable-glusterfs") + fi + + # Most tsocks proxies rely on a configuration file in /etc/tsocks.conf. + # If using tsocks, please make sure to complete this config before trying to build qemu. + if echo $CONF | grep -q tsocks; then + if hash tsocks 2> /dev/null; then + opt_params+=("--with-git='tsocks git'") + fi + fi + + sed -i s@git://git.qemu.org/@https://github.com/qemu/@g qemu/$SPDK_QEMU_BRANCH/.gitmodules + sed -i s@git://git.qemu.org/@https://github.com/qemu/@g qemu/$SPDK_QEMU_BRANCH/.git/config + sed -i s@git://git.qemu-project.org/@https://github.com/qemu/@g qemu/$SPDK_QEMU_BRANCH/.gitmodules + sed -i s@git://git.qemu-project.org/@https://github.com/qemu/@g qemu/$SPDK_QEMU_BRANCH/.git/config + # The qemu configure script places several output files in the CWD. + (cd qemu/$SPDK_QEMU_BRANCH && ./configure "${opt_params[@]}" --target-list="x86_64-softmmu" --enable-kvm --enable-linux-aio --enable-numa) + + make -C ./qemu/$SPDK_QEMU_BRANCH -j${jobs} + sudo make -C ./qemu/$SPDK_QEMU_BRANCH install + fi +} + +function install_vpp() { + if echo $CONF | grep -q vpp; then + if [ -d /usr/local/src/vpp ]; then + echo "vpp already cloned." + if [ ! -d /usr/local/src/vpp/build-root ]; then + echo "build-root has not been done" + echo "remove the $(pwd) and start again" + exit 1 + fi + else + git clone "${GIT_REPO_VPP}" + git -C ./vpp checkout v19.04.2 + + if [ "${OSID}" == 'fedora' ]; then + if [ ${OSVERSION} -eq 29 ]; then + git -C ./vpp apply ${VM_SETUP_PATH}/patch/vpp/fedora29-fix.patch + fi + if [ ${OSVERSION} -eq 30 ]; then + git -C ./vpp apply ${VM_SETUP_PATH}/patch/vpp/fedora30-fix.patch + fi + fi + + # Installing required dependencies for building VPP + yes | make -C ./vpp install-dep + + make -C ./vpp build -j${jobs} + + sudo mv ./vpp /usr/local/src/vpp-19.04 + fi + fi +} + +function install_nvmecli() { + if echo $CONF | grep -q nvmecli; then + SPDK_NVME_CLI_BRANCH=spdk-1.6 + if [ ! -d nvme-cli ]; then + git clone "${GIT_REPO_SPDK_NVME_CLI}" -b "$SPDK_NVME_CLI_BRANCH" + else + echo "nvme-cli already checked out. Skipping" + fi + if [ ! -d "/usr/local/src/nvme-cli" ]; then + git clone "https://review.spdk.io/spdk/nvme-cli" "nvme-cli-cuse" + git -C ./nvme-cli-cuse checkout nvme-cuse + make -C ./nvme-cli-cuse + sudo mv ./nvme-cli-cuse /usr/local/src/nvme-cli + fi + fi +} + +function install_libiscsi() { + if echo $CONF | grep -q libiscsi; then + # We currently don't make any changes to the libiscsi repository for our tests, but it is possible that we will need + # to later. Cloning from git is just future proofing the machines. + if [ ! -d libiscsi ]; then + git clone "${GIT_REPO_LIBISCSI}" + else + echo "libiscsi already checked out. Skipping" + fi + (cd libiscsi && ./autogen.sh && ./configure --prefix=/usr/local/libiscsi) + make -C ./libiscsi -j${jobs} + sudo make -C ./libiscsi install + fi } function install_git() { - sudo yum install -y zlib-devel curl-devel - tar -xzof <(wget -qO- "$GIT_REPO_GIT") - (cd git-${GIT_VERSION} && \ - make configure && \ - ./configure --prefix=/usr/local/git && \ - sudo make -j${jobs} install) - sudo sh -c "echo 'export PATH=/usr/local/git/bin:$PATH' >> /etc/bashrc" - exec $SHELL + sudo yum install -y zlib-devel curl-devel + tar -xzof <(wget -qO- "$GIT_REPO_GIT") + (cd git-${GIT_VERSION} \ + && make configure \ + && ./configure --prefix=/usr/local/git \ + && sudo make -j${jobs} install) + sudo sh -c "echo 'export PATH=/usr/local/git/bin:$PATH' >> /etc/bashrc" + exec $SHELL } -function usage() -{ - echo "This script is intended to automate the environment setup for a linux virtual machine." - echo "Please run this script as your regular user. The script will make calls to sudo as needed." - echo "" - echo "./vm_setup.sh" - echo " -h --help" - echo " -u --upgrade Run $PACKAGEMNG upgrade" - echo " -i --install-deps Install $PACKAGEMNG based dependencies" - echo " -t --test-conf List of test configurations to enable (${CONF})" - echo " -c --conf-path Path to configuration file" - exit 0 +function usage() { + echo "This script is intended to automate the environment setup for a linux virtual machine." + echo "Please run this script as your regular user. The script will make calls to sudo as needed." + echo "" + echo "./vm_setup.sh" + echo " -h --help" + echo " -u --upgrade Run $PACKAGEMNG upgrade" + echo " -i --install-deps Install $PACKAGEMNG based dependencies" + echo " -t --test-conf List of test configurations to enable (${CONF})" + echo " -c --conf-path Path to configuration file" + exit 0 } # Get package manager # -if hash yum &>/dev/null; then - PACKAGEMNG=yum -elif hash dnf &>/dev/null; then - PACKAGEMNG=dnf -elif hash apt-get &>/dev/null; then - PACKAGEMNG=apt-get -elif hash pacman &>/dev/null; then - PACKAGEMNG=pacman -elif hash pkg &>/dev/null; then - PACKAGEMNG=pkg +if hash yum &> /dev/null; then + PACKAGEMNG=yum +elif hash dnf &> /dev/null; then + PACKAGEMNG=dnf +elif hash apt-get &> /dev/null; then + PACKAGEMNG=apt-get +elif hash pacman &> /dev/null; then + PACKAGEMNG=pacman +elif hash pkg &> /dev/null; then + PACKAGEMNG=pkg else - echo 'Supported package manager not found. Script supports "dnf" and "apt-get".' + echo 'Supported package manager not found. Script supports "dnf" and "apt-get".' fi if [ $PACKAGEMNG == 'apt-get' ] && [ $OSID != 'ubuntu' ]; then - echo 'Located apt-get package manager, but it was tested for Ubuntu only' + echo 'Located apt-get package manager, but it was tested for Ubuntu only' fi if [ $PACKAGEMNG == 'dnf' ] && [ $OSID != 'fedora' ]; then - echo 'Located dnf package manager, but it was tested for Fedora only' + echo 'Located dnf package manager, but it was tested for Fedora only' fi # Parse input arguments # while getopts 'iuht:c:-:' optchar; do - case "$optchar" in - -) - case "$OPTARG" in - help) usage;; - upgrade) UPGRADE=true;; - install-deps) INSTALL=true;; - test-conf=*) CONF="${OPTARG#*=}";; - conf-path=*) CONF_PATH="${OPTARG#*=}";; - *) echo "Invalid argument '$OPTARG'" - usage;; - esac - ;; - h) usage;; - u) UPGRADE=true;; - i) INSTALL=true;; - t) CONF="$OPTARG";; - c) CONF_PATH="$OPTARG";; - *) echo "Invalid argument '$OPTARG'" - usage;; - esac + case "$optchar" in + -) + case "$OPTARG" in + help) usage ;; + upgrade) UPGRADE=true ;; + install-deps) INSTALL=true ;; + test-conf=*) CONF="${OPTARG#*=}" ;; + conf-path=*) CONF_PATH="${OPTARG#*=}" ;; + *) + echo "Invalid argument '$OPTARG'" + usage + ;; + esac + ;; + h) usage ;; + u) UPGRADE=true ;; + i) INSTALL=true ;; + t) CONF="$OPTARG" ;; + c) CONF_PATH="$OPTARG" ;; + *) + echo "Invalid argument '$OPTARG'" + usage + ;; + esac done if [ -n "$CONF_PATH" ]; then - if [ ! -f "$CONF_PATH" ]; then - echo Configuration file does not exist: "$CONF_PATH" - exit 1 - else - source "$CONF_PATH" - fi + if [ ! -f "$CONF_PATH" ]; then + echo Configuration file does not exist: "$CONF_PATH" + exit 1 + else + source "$CONF_PATH" + fi fi cd ~ GIT_VERSION=2.25.1 -: ${GIT_REPO_SPDK=https://github.com/spdk/spdk.git}; export GIT_REPO_SPDK -: ${GIT_REPO_DPDK=https://github.com/spdk/dpdk.git}; export GIT_REPO_DPDK -: ${GIT_REPO_LIBRXE=https://github.com/SoftRoCE/librxe-dev.git}; export GIT_REPO_LIBRXE -: ${GIT_REPO_OPEN_ISCSI=https://github.com/open-iscsi/open-iscsi}; export GIT_REPO_OPEN_ISCSI -: ${GIT_REPO_ROCKSDB=https://review.spdk.io/spdk/rocksdb}; export GIT_REPO_ROCKSDB -: ${GIT_REPO_FIO=http://git.kernel.dk/fio.git}; export GIT_REPO_FIO -: ${GIT_REPO_FLAMEGRAPH=https://github.com/brendangregg/FlameGraph.git}; export GIT_REPO_FLAMEGRAPH -: ${GIT_REPO_QEMU=https://github.com/spdk/qemu}; export GIT_REPO_QEMU -: ${GIT_REPO_VPP=https://gerrit.fd.io/r/vpp}; export GIT_REPO_VPP -: ${GIT_REPO_LIBISCSI=https://github.com/sahlberg/libiscsi}; export GIT_REPO_LIBISCSI -: ${GIT_REPO_SPDK_NVME_CLI=https://github.com/spdk/nvme-cli}; export GIT_REPO_SPDK_NVME_CLI -: ${GIT_REPO_INTEL_IPSEC_MB=https://github.com/spdk/intel-ipsec-mb.git}; export GIT_REPO_INTEL_IPSEC_MB -: ${DRIVER_LOCATION_QAT=https://01.org/sites/default/files/downloads//qat1.7.l.4.9.0-00008.tar.gz}; export DRIVER_LOCATION_QAT -: ${GIT_REPO_GIT=https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz}; export GIT_REPO_GIT +: ${GIT_REPO_SPDK=https://github.com/spdk/spdk.git} +export GIT_REPO_SPDK +: ${GIT_REPO_DPDK=https://github.com/spdk/dpdk.git} +export GIT_REPO_DPDK +: ${GIT_REPO_LIBRXE=https://github.com/SoftRoCE/librxe-dev.git} +export GIT_REPO_LIBRXE +: ${GIT_REPO_OPEN_ISCSI=https://github.com/open-iscsi/open-iscsi} +export GIT_REPO_OPEN_ISCSI +: ${GIT_REPO_ROCKSDB=https://review.spdk.io/spdk/rocksdb} +export GIT_REPO_ROCKSDB +: ${GIT_REPO_FIO=http://git.kernel.dk/fio.git} +export GIT_REPO_FIO +: ${GIT_REPO_FLAMEGRAPH=https://github.com/brendangregg/FlameGraph.git} +export GIT_REPO_FLAMEGRAPH +: ${GIT_REPO_QEMU=https://github.com/spdk/qemu} +export GIT_REPO_QEMU +: ${GIT_REPO_VPP=https://gerrit.fd.io/r/vpp} +export GIT_REPO_VPP +: ${GIT_REPO_LIBISCSI=https://github.com/sahlberg/libiscsi} +export GIT_REPO_LIBISCSI +: ${GIT_REPO_SPDK_NVME_CLI=https://github.com/spdk/nvme-cli} +export GIT_REPO_SPDK_NVME_CLI +: ${GIT_REPO_INTEL_IPSEC_MB=https://github.com/spdk/intel-ipsec-mb.git} +export GIT_REPO_INTEL_IPSEC_MB +: ${DRIVER_LOCATION_QAT=https://01.org/sites/default/files/downloads//qat1.7.l.4.9.0-00008.tar.gz} +export DRIVER_LOCATION_QAT +: ${GIT_REPO_GIT=https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz} +export GIT_REPO_GIT if [ $PACKAGEMNG == 'pkg' ]; then - jobs=$(( $(sysctl -n hw.ncpu) * 2 )) + jobs=$(($(sysctl -n hw.ncpu) * 2)) else - jobs=$(($(nproc)*2)) + jobs=$(($(nproc) * 2)) fi if $UPGRADE; then - if [ $PACKAGEMNG == 'yum' ]; then - sudo $PACKAGEMNG upgrade -y - elif [ $PACKAGEMNG == 'dnf' ]; then - sudo $PACKAGEMNG upgrade -y - elif [ $PACKAGEMNG == 'apt-get' ]; then - sudo $PACKAGEMNG update - sudo $PACKAGEMNG upgrade -y - elif [ $PACKAGEMNG == 'pacman' ]; then - sudo $PACKAGEMNG -Syu --noconfirm --needed - elif [ $PACKAGEMNG == 'pkg' ]; then - sudo $PACKAGEMNG upgrade -y - fi + if [ $PACKAGEMNG == 'yum' ]; then + sudo $PACKAGEMNG upgrade -y + elif [ $PACKAGEMNG == 'dnf' ]; then + sudo $PACKAGEMNG upgrade -y + elif [ $PACKAGEMNG == 'apt-get' ]; then + sudo $PACKAGEMNG update + sudo $PACKAGEMNG upgrade -y + elif [ $PACKAGEMNG == 'pacman' ]; then + sudo $PACKAGEMNG -Syu --noconfirm --needed + elif [ $PACKAGEMNG == 'pkg' ]; then + sudo $PACKAGEMNG upgrade -y + fi fi if $INSTALL; then - if [ "${OSID} ${OSVERSION}" == 'centos 8' ]; then - #During install using vm_setup.sh there is error with AppStream, to fix it we need to refresh yum - sudo yum update -y --refresh - fi - sudo spdk_repo/spdk/scripts/pkgdep.sh --all + if [ "${OSID} ${OSVERSION}" == 'centos 8' ]; then + #During install using vm_setup.sh there is error with AppStream, to fix it we need to refresh yum + sudo yum update -y --refresh + fi + sudo spdk_repo/spdk/scripts/pkgdep.sh --all - if [ $PACKAGEMNG == 'pkg' ]; then - sudo pkg install -y pciutils \ - jq \ - gdb \ - fio \ - p5-extutils-pkgconfig \ - libtool \ - flex \ - bison \ - gdisk \ - socat \ - sshpass \ - py37-pandas \ - wget + if [ $PACKAGEMNG == 'pkg' ]; then + sudo pkg install -y pciutils \ + jq \ + gdb \ + fio \ + p5-extutils-pkgconfig \ + libtool \ + flex \ + bison \ + gdisk \ + socat \ + sshpass \ + py37-pandas \ + wget - elif [ $PACKAGEMNG == 'yum' ]; then - sudo yum install -y pciutils \ - valgrind \ - jq \ - nvme-cli \ - gdb \ - fio \ - librbd-devel \ - kernel-devel \ - gflags-devel \ - libasan \ - libubsan \ - autoconf \ - automake \ - libtool \ - libmount-devel \ - iscsi-initiator-utils \ - isns-utils-devel\ - pmempool \ - perl-open \ - glib2-devel \ - pixman-devel \ - astyle-devel \ - elfutils \ - elfutils-libelf-devel \ - flex \ - bison \ - targetcli \ - perl-Switch \ - librdmacm-utils \ - libibverbs-utils \ - gdisk \ - socat \ - sshfs \ - sshpass \ - python3-pandas \ - rpm-build \ - iptables \ - clang-analyzer \ - bc \ - kernel-modules-extra \ - systemd-devel \ - python3 \ - wget + elif [ $PACKAGEMNG == 'yum' ]; then + sudo yum install -y pciutils \ + valgrind \ + jq \ + nvme-cli \ + gdb \ + fio \ + librbd-devel \ + kernel-devel \ + gflags-devel \ + libasan \ + libubsan \ + autoconf \ + automake \ + libtool \ + libmount-devel \ + iscsi-initiator-utils \ + isns-utils-devel pmempool \ + perl-open \ + glib2-devel \ + pixman-devel \ + astyle-devel \ + elfutils \ + elfutils-libelf-devel \ + flex \ + bison \ + targetcli \ + perl-Switch \ + librdmacm-utils \ + libibverbs-utils \ + gdisk \ + socat \ + sshfs \ + sshpass \ + python3-pandas \ + rpm-build \ + iptables \ + clang-analyzer \ + bc \ + kernel-modules-extra \ + systemd-devel \ + python3 \ + wget - sudo yum install -y nbd || { - wget -O nbd.rpm https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/n/nbd-3.14-2.el7.x86_64.rpm - sudo yum install -y nbd.rpm - } + sudo yum install -y nbd || { + wget -O nbd.rpm https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/n/nbd-3.14-2.el7.x86_64.rpm + sudo yum install -y nbd.rpm + } - elif [ $PACKAGEMNG == 'dnf' ]; then - if echo $CONF | grep -q tsocks; then - # currently, tsocks package is retired in fedora 31, so don't exit in case - # installation failed - # FIXME: Review when fedora starts to successfully build this package again. - sudo dnf install -y tsocks || echo "Installation of the tsocks package failed, proxy may not be available" - fi + elif [ $PACKAGEMNG == 'dnf' ]; then + if echo $CONF | grep -q tsocks; then + # currently, tsocks package is retired in fedora 31, so don't exit in case + # installation failed + # FIXME: Review when fedora starts to successfully build this package again. + sudo dnf install -y tsocks || echo "Installation of the tsocks package failed, proxy may not be available" + fi - sudo dnf install -y \ - valgrind \ - jq \ - nvme-cli \ - ceph \ - gdb \ - fio \ - librbd-devel \ - kernel-devel \ - gflags-devel \ - libasan \ - libubsan \ - autoconf \ - automake \ - libtool \ - libmount-devel \ - iscsi-initiator-utils \ - isns-utils-devel \ - pmempool \ - perl-open \ - glib2-devel \ - pixman-devel \ - astyle-devel \ - elfutils \ - libabigail \ - elfutils-libelf-devel \ - flex \ - bison \ - targetcli \ - perl-Switch \ - librdmacm-utils \ - libibverbs-utils \ - gdisk \ - socat \ - sshfs \ - sshpass \ - python3-pandas \ - btrfs-progs \ - rpm-build \ - iptables \ - clang-analyzer \ - bc \ - kernel-modules-extra \ - systemd-devel \ - smartmontools \ - wget + sudo dnf install -y \ + valgrind \ + jq \ + nvme-cli \ + ceph \ + gdb \ + fio \ + librbd-devel \ + kernel-devel \ + gflags-devel \ + libasan \ + libubsan \ + autoconf \ + automake \ + libtool \ + libmount-devel \ + iscsi-initiator-utils \ + isns-utils-devel \ + pmempool \ + perl-open \ + glib2-devel \ + pixman-devel \ + astyle-devel \ + elfutils \ + libabigail \ + elfutils-libelf-devel \ + flex \ + bison \ + targetcli \ + perl-Switch \ + librdmacm-utils \ + libibverbs-utils \ + gdisk \ + socat \ + sshfs \ + sshpass \ + python3-pandas \ + btrfs-progs \ + rpm-build \ + iptables \ + clang-analyzer \ + bc \ + kernel-modules-extra \ + systemd-devel \ + smartmontools \ + wget - elif [ $PACKAGEMNG == 'apt-get' ]; then - echo "Package perl-open is not available at Ubuntu repositories" >&2 + elif [ $PACKAGEMNG == 'apt-get' ]; then + echo "Package perl-open is not available at Ubuntu repositories" >&2 - if echo $CONF | grep -q tsocks; then - sudo apt-get install -y tsocks - fi + if echo $CONF | grep -q tsocks; then + sudo apt-get install -y tsocks + fi - # asan an ubsan have to be installed together to not mix up gcc versions - if sudo apt-get install -y libasan5; then - sudo apt-get install -y libubsan1 - else - echo "Latest libasan5 is not available" >&2 - echo " installing libasan2 and corresponding libubsan0" >&2 - sudo apt-get install -y libasan2 - sudo apt-get install -y libubsan0 - fi - if ! sudo apt-get install -y rdma-core; then - echo "Package rdma-core is avaliable at Ubuntu 18 [universe] repositorium" >&2 - sudo apt-get install -y rdmacm-utils - sudo apt-get install -y ibverbs-utils - else - LIBRXE_INSTALL=false - fi - if ! sudo apt-get install -y libpmempool1; then - echo "Package libpmempool1 is available at Ubuntu 18 [universe] repositorium" >&2 - fi - if ! sudo apt-get install -y clang-tools; then - echo "Package clang-tools is available at Ubuntu 18 [universe] repositorium" >&2 - fi - if ! sudo apt-get install -y --no-install-suggests --no-install-recommends open-isns-utils; then - echo "Package open-isns-utils is available at Ubuntu 18 [universe] repositorium" >&2 - fi + # asan an ubsan have to be installed together to not mix up gcc versions + if sudo apt-get install -y libasan5; then + sudo apt-get install -y libubsan1 + else + echo "Latest libasan5 is not available" >&2 + echo " installing libasan2 and corresponding libubsan0" >&2 + sudo apt-get install -y libasan2 + sudo apt-get install -y libubsan0 + fi + if ! sudo apt-get install -y rdma-core; then + echo "Package rdma-core is avaliable at Ubuntu 18 [universe] repositorium" >&2 + sudo apt-get install -y rdmacm-utils + sudo apt-get install -y ibverbs-utils + else + LIBRXE_INSTALL=false + fi + if ! sudo apt-get install -y libpmempool1; then + echo "Package libpmempool1 is available at Ubuntu 18 [universe] repositorium" >&2 + fi + if ! sudo apt-get install -y clang-tools; then + echo "Package clang-tools is available at Ubuntu 18 [universe] repositorium" >&2 + fi + if ! sudo apt-get install -y --no-install-suggests --no-install-recommends open-isns-utils; then + echo "Package open-isns-utils is available at Ubuntu 18 [universe] repositorium" >&2 + fi - # Package name for Ubuntu 18 is targetcli-fb but for Ubuntu 16 it's targetcli - if ! sudo apt-get install -y targetcli-fb; then - sudo apt-get install -y targetcli - fi + # Package name for Ubuntu 18 is targetcli-fb but for Ubuntu 16 it's targetcli + if ! sudo apt-get install -y targetcli-fb; then + sudo apt-get install -y targetcli + fi - sudo apt-get install -y \ - valgrind \ - jq \ - nvme-cli \ - ceph \ - gdb \ - fio \ - librbd-dev \ - linux-headers-generic \ - libgflags-dev \ - autoconf \ - automake \ - libtool \ - libmount-dev \ - open-iscsi \ - libglib2.0-dev \ - libpixman-1-dev \ - astyle \ - elfutils \ - libelf-dev \ - flex \ - bison \ - libswitch-perl \ - gdisk \ - socat \ - sshfs \ - sshpass \ - python3-pandas \ - btrfs-tools \ - bc \ - smartmontools \ - wget + sudo apt-get install -y \ + valgrind \ + jq \ + nvme-cli \ + ceph \ + gdb \ + fio \ + librbd-dev \ + linux-headers-generic \ + libgflags-dev \ + autoconf \ + automake \ + libtool \ + libmount-dev \ + open-iscsi \ + libglib2.0-dev \ + libpixman-1-dev \ + astyle \ + elfutils \ + libelf-dev \ + flex \ + bison \ + libswitch-perl \ + gdisk \ + socat \ + sshfs \ + sshpass \ + python3-pandas \ + btrfs-tools \ + bc \ + smartmontools \ + wget - # rpm-build is not used - # iptables installed by default + # rpm-build is not used + # iptables installed by default - elif [ $PACKAGEMNG == 'pacman' ]; then - if echo $CONF | grep -q tsocks; then - sudo pacman -Sy --noconfirm --needed tsocks - fi + elif [ $PACKAGEMNG == 'pacman' ]; then + if echo $CONF | grep -q tsocks; then + sudo pacman -Sy --noconfirm --needed tsocks + fi - sudo pacman -Sy --noconfirm --needed valgrind \ - jq \ - nvme-cli \ - ceph \ - gdb \ - fio \ - linux-headers \ - gflags \ - autoconf \ - automake \ - libtool \ - libutil-linux \ - libiscsi \ - open-isns \ - glib2 \ - pixman \ - flex \ - bison \ - elfutils \ - libelf \ - astyle \ - gptfdisk \ - socat \ - sshfs \ - sshpass \ - python-pandas \ - btrfs-progs \ - iptables \ - clang \ - bc \ - perl-switch \ - open-iscsi \ - smartmontools \ - parted \ - wget + sudo pacman -Sy --noconfirm --needed valgrind \ + jq \ + nvme-cli \ + ceph \ + gdb \ + fio \ + linux-headers \ + gflags \ + autoconf \ + automake \ + libtool \ + libutil-linux \ + libiscsi \ + open-isns \ + glib2 \ + pixman \ + flex \ + bison \ + elfutils \ + libelf \ + astyle \ + gptfdisk \ + socat \ + sshfs \ + sshpass \ + python-pandas \ + btrfs-progs \ + iptables \ + clang \ + bc \ + perl-switch \ + open-iscsi \ + smartmontools \ + parted \ + wget - # TODO: - # These are either missing or require some other installation method - # than pacman: + # TODO: + # These are either missing or require some other installation method + # than pacman: - # librbd-devel - # perl-open - # targetcli + # librbd-devel + # perl-open + # targetcli - else - echo "Package manager is undefined, skipping INSTALL step" - fi + else + echo "Package manager is undefined, skipping INSTALL step" + fi - if [ "${OSID} ${OSVERSION}" == 'centos 7' ]; then - install_git - fi + if [ "${OSID} ${OSVERSION}" == 'centos 7' ]; then + install_git + fi fi mkdir -p spdk_repo/output || echo "Can not create spdk_repo/output directory." if [ -d spdk_repo/spdk ]; then - echo "spdk source already present, not cloning" + echo "spdk source already present, not cloning" else - git -C spdk_repo clone "${GIT_REPO_SPDK}" + git -C spdk_repo clone "${GIT_REPO_SPDK}" fi git -C spdk_repo/spdk config submodule.dpdk.url "${GIT_REPO_DPDK}" git -C spdk_repo/spdk config submodule.intel-ipsec-mb.url "${GIT_REPO_INTEL_IPSEC_MB}" @@ -708,21 +713,21 @@ git -C spdk_repo/spdk submodule update --init --recursive sudo mkdir -p /usr/src if [ $OSID != 'freebsd' ]; then - if [ $LIBRXE_INSTALL = true ]; then - #Ubuntu18 integrates librxe to rdma-core, libibverbs-dev no longer ships infiniband/driver.h. - #Don't compile librxe on ubuntu18 or later version, install package rdma-core instead. - install_rxe_cfg& - fi - install_iscsi_adm& - install_libiscsi& - install_vpp& - install_nvmecli& - install_qat& - install_rocksdb& - install_flamegraph& - install_qemu& + if [ $LIBRXE_INSTALL = true ]; then + #Ubuntu18 integrates librxe to rdma-core, libibverbs-dev no longer ships infiniband/driver.h. + #Don't compile librxe on ubuntu18 or later version, install package rdma-core instead. + install_rxe_cfg & + fi + install_iscsi_adm & + install_libiscsi & + install_vpp & + install_nvmecli & + install_qat & + install_rocksdb & + install_flamegraph & + install_qemu & fi -install_fio& +install_fio & wait # create autorun-spdk.conf in home folder. This is sourced by the autotest_common.sh file. diff --git a/test/compress/compress.sh b/test/compress/compress.sh index 3ebbebcae7..1db5351c59 100755 --- a/test/compress/compress.sh +++ b/test/compress/compress.sh @@ -63,11 +63,13 @@ function run_bdevperf() { test_type=$1 case "$test_type" in - qat ) - pmd=1;; - isal ) - pmd=2;; - * ) + qat) + pmd=1 + ;; + isal) + pmd=2 + ;; + *) echo "invalid pmd name" exit 1 ;; diff --git a/test/ftl/bdevperf.sh b/test/ftl/bdevperf.sh index 09b248d03d..c0cbc27b93 100755 --- a/test/ftl/bdevperf.sh +++ b/test/ftl/bdevperf.sh @@ -10,7 +10,7 @@ device=$1 use_append=$2 rpc_py=$rootdir/scripts/rpc.py -for (( i=0; i<${#tests[@]}; i++ )) do +for ((i = 0; i < ${#tests[@]}; i++)); do timing_enter "${tests[$i]}" "$rootdir/test/bdev/bdevperf/bdevperf" -z -T ftl0 ${tests[$i]} --json <(gen_ftl_nvme_conf) & bdevperf_pid=$! diff --git a/test/ftl/common.sh b/test/ftl/common.sh index b2cc5a5023..82c682a0ca 100644 --- a/test/ftl/common.sh +++ b/test/ftl/common.sh @@ -1,24 +1,24 @@ # Common utility functions to be sourced by the libftl test scripts function get_chunk_size() { - $rootdir/examples/nvme/identify/identify -r "trtype:PCIe traddr:$1" | - grep 'Logical blks per chunk' | sed 's/[^0-9]//g' + $rootdir/examples/nvme/identify/identify -r "trtype:PCIe traddr:$1" \ + | grep 'Logical blks per chunk' | sed 's/[^0-9]//g' } function get_num_group() { - $rootdir/examples/nvme/identify/identify -r "trtype:PCIe traddr:$1" | - grep 'Groups' | sed 's/[^0-9]//g' + $rootdir/examples/nvme/identify/identify -r "trtype:PCIe traddr:$1" \ + | grep 'Groups' | sed 's/[^0-9]//g' } function get_num_pu() { - $rootdir/examples/nvme/identify/identify -r "trtype:PCIe traddr:$1" | - grep 'PUs' | sed 's/[^0-9]//g' + $rootdir/examples/nvme/identify/identify -r "trtype:PCIe traddr:$1" \ + | grep 'PUs' | sed 's/[^0-9]//g' } function has_separate_md() { local md_type - md_type=$($rootdir/examples/nvme/identify/identify -r "trtype:PCIe traddr:$1" | \ - grep 'Metadata Transferred' | cut -d: -f2) + md_type=$($rootdir/examples/nvme/identify/identify -r "trtype:PCIe traddr:$1" \ + | grep 'Metadata Transferred' | cut -d: -f2) if [[ "$md_type" =~ Separate ]]; then return 0 else @@ -48,7 +48,7 @@ function create_nv_cache_bdev() { } function gen_ftl_nvme_conf() { - jq . <<-JSON + jq . <<- JSON { "subsystems": [ { diff --git a/test/ftl/dirty_shutdown.sh b/test/ftl/dirty_shutdown.sh index 4de012d3c5..e5b6816f7a 100755 --- a/test/ftl/dirty_shutdown.sh +++ b/test/ftl/dirty_shutdown.sh @@ -14,7 +14,7 @@ while getopts ':u:c:' opt; do ?) echo "Usage: $0 [-u UUID] [-c NV_CACHE_PCI_BDF] OCSSD_PCI_BDF" && exit 1 ;; esac done -shift $((OPTIND -1)) +shift $((OPTIND - 1)) device=$1 @@ -37,7 +37,8 @@ pu_count=$((num_group * num_pu)) # Write one band worth of data + one extra chunk data_size=$((chunk_size * (pu_count + 1))) -"$rootdir/app/spdk_tgt/spdk_tgt" --json <(gen_ftl_nvme_conf) & svcpid=$! +"$rootdir/app/spdk_tgt/spdk_tgt" --json <(gen_ftl_nvme_conf) & +svcpid=$! waitforlisten $svcpid if [ -n "$nv_cache" ]; then @@ -49,7 +50,7 @@ $rpc_py bdev_ocssd_create -c nvme0 -b nvme0n1 -n 1 ftl_construct_args="bdev_ftl_create -b ftl0 -d nvme0n1 -o" [ -n "$nvc_bdev" ] && ftl_construct_args+=" -c $nvc_bdev" -[ -n "$uuid" ] && ftl_construct_args+=" -u $uuid" +[ -n "$uuid" ] && ftl_construct_args+=" -u $uuid" $rpc_py $ftl_construct_args @@ -69,7 +70,8 @@ $rpc_py nbd_stop_disk /dev/nbd0 kill -9 $svcpid rm -f /dev/shm/spdk_tgt_trace.pid$svcpid -"$rootdir/app/spdk_tgt/spdk_tgt" --json <(gen_ftl_nvme_conf) -L ftl_init & svcpid=$! +"$rootdir/app/spdk_tgt/spdk_tgt" --json <(gen_ftl_nvme_conf) -L ftl_init & +svcpid=$! waitforlisten $svcpid $rpc_py load_config < $testdir/config/ftl.json diff --git a/test/ftl/fio.sh b/test/ftl/fio.sh index c43be5d45b..f7b4f5df98 100755 --- a/test/ftl/fio.sh +++ b/test/ftl/fio.sh @@ -35,7 +35,8 @@ export FTL_JSON_CONF=$testdir/config/ftl.json trap "fio_kill; exit 1" SIGINT SIGTERM EXIT -"$rootdir/app/spdk_tgt/spdk_tgt" --json <(gen_ftl_nvme_conf) & svcpid=$! +"$rootdir/app/spdk_tgt/spdk_tgt" --json <(gen_ftl_nvme_conf) & +svcpid=$! waitforlisten $svcpid $rpc_py bdev_nvme_attach_controller -b nvme0 -a $device -t pcie @@ -50,7 +51,7 @@ fi waitforbdev ftl0 ( - echo '{"subsystems": ['; + echo '{"subsystems": [' $rpc_py save_subsystem_config -n bdev echo ']}' ) > $FTL_JSON_CONF diff --git a/test/ftl/ftl.sh b/test/ftl/ftl.sh index 5f3c4611df..bc2576b3a1 100755 --- a/test/ftl/ftl.sh +++ b/test/ftl/ftl.sh @@ -31,7 +31,7 @@ PCI_WHITELIST="$device" PCI_BLACKLIST="" DRIVER_OVERRIDE="" ./scripts/setup.sh # Use first regular NVMe disk (non-OC) as non-volatile cache nvme_disks=$($rootdir/scripts/gen_nvme.sh --json | jq -r \ - ".config[] | select(.params.traddr != \"$device\").params.traddr") + ".config[] | select(.params.traddr != \"$device\").params.traddr") for disk in $nvme_disks; do if has_separate_md $disk; then @@ -62,7 +62,8 @@ run_test "ftl_json" $testdir/json.sh $device if [ $SPDK_TEST_FTL_EXTENDED -eq 1 ]; then run_test "ftl_fio_basic" $testdir/fio.sh $device basic - "$rootdir/app/spdk_tgt/spdk_tgt" --json <(gen_ftl_nvme_conf) & svcpid=$! + "$rootdir/app/spdk_tgt/spdk_tgt" --json <(gen_ftl_nvme_conf) & + svcpid=$! trap 'killprocess $svcpid; exit 1' SIGINT SIGTERM EXIT diff --git a/test/ftl/json.sh b/test/ftl/json.sh index 9901853778..2e13f27154 100755 --- a/test/ftl/json.sh +++ b/test/ftl/json.sh @@ -15,7 +15,8 @@ json_kill() { trap "json_kill; exit 1" SIGINT SIGTERM EXIT -"$rootdir/app/spdk_tgt/spdk_tgt" --json <(gen_ftl_nvme_conf) & svcpid=$! +"$rootdir/app/spdk_tgt/spdk_tgt" --json <(gen_ftl_nvme_conf) & +svcpid=$! waitforlisten $svcpid # Create new bdev from json configuration diff --git a/test/ftl/restore.sh b/test/ftl/restore.sh index bc71e76db4..e066ff90aa 100755 --- a/test/ftl/restore.sh +++ b/test/ftl/restore.sh @@ -16,7 +16,7 @@ while getopts ':u:c:' opt; do ?) echo "Usage: $0 [-u UUID] [-c NV_CACHE_PCI_BDF] OCSSD_PCI_BDF" && exit 1 ;; esac done -shift $((OPTIND -1)) +shift $((OPTIND - 1)) device=$1 num_group=$(get_num_group $device) num_pu=$(get_num_pu $device) @@ -37,7 +37,8 @@ restore_kill() { trap "restore_kill; exit 1" SIGINT SIGTERM EXIT -"$rootdir/app/spdk_tgt/spdk_tgt" --json <(gen_ftl_nvme_conf) & svcpid=$! +"$rootdir/app/spdk_tgt/spdk_tgt" --json <(gen_ftl_nvme_conf) & +svcpid=$! # Wait until spdk_tgt starts waitforlisten $svcpid @@ -49,7 +50,7 @@ $rpc_py bdev_nvme_attach_controller -b nvme0 -a $device -t pcie $rpc_py bdev_ocssd_create -c nvme0 -b nvme0n1 -n 1 ftl_construct_args="bdev_ftl_create -b ftl0 -d nvme0n1" -[ -n "$uuid" ] && ftl_construct_args+=" -u $uuid" +[ -n "$uuid" ] && ftl_construct_args+=" -u $uuid" [ -n "$nv_cache" ] && ftl_construct_args+=" -c $nvc_bdev" $rpc_py $ftl_construct_args @@ -73,7 +74,8 @@ md5sum $mount_dir/testfile > $testdir/testfile.md5 umount $mount_dir killprocess $svcpid -"$rootdir/app/spdk_tgt/spdk_tgt" --json <(gen_ftl_nvme_conf) -L ftl_init & svcpid=$! +"$rootdir/app/spdk_tgt/spdk_tgt" --json <(gen_ftl_nvme_conf) -L ftl_init & +svcpid=$! # Wait until spdk_tgt starts waitforlisten $svcpid diff --git a/test/fuzz/autofuzz.sh b/test/fuzz/autofuzz.sh index dfb3758be1..92766bb06c 100755 --- a/test/fuzz/autofuzz.sh +++ b/test/fuzz/autofuzz.sh @@ -27,12 +27,12 @@ done timing_enter autofuzz if [ "$TEST_MODULE" == "nvmf" ]; then - allowed_transports=( "${allowed_nvme_transports[@]}" ) + allowed_transports=("${allowed_nvme_transports[@]}") if [ $TEST_TRANSPORT == "rdma" ]; then config_params="$config_params --with-rdma" fi elif [ "$TEST_MODULE" == "vhost" ]; then - allowed_transports=( "${allowed_vhost_transports[@]}" ) + allowed_transports=("${allowed_vhost_transports[@]}") config_params="$config_params --with-vhost --with-virtio" else echo "Invalid module specified. Please specify either nvmf or vhost." diff --git a/test/fuzz/autofuzz_iscsi.sh b/test/fuzz/autofuzz_iscsi.sh index 7df572a3c6..8793e8bf1d 100755 --- a/test/fuzz/autofuzz_iscsi.sh +++ b/test/fuzz/autofuzz_iscsi.sh @@ -30,15 +30,16 @@ TEST_TIMEOUT=1200 # This argument is used in addition to the test arguments in autotest_common.sh for i in "$@"; do - case "$i" in - --timeout=*) - TEST_TIMEOUT="${i#*=}" - esac + case "$i" in + --timeout=*) + TEST_TIMEOUT="${i#*=}" + ;; + esac done timing_enter start_iscsi_tgt -"${ISCSI_APP[@]}" -m $ISCSI_TEST_CORE_MASK &>$output_dir/iscsi_autofuzz_tgt_output.txt & +"${ISCSI_APP[@]}" -m $ISCSI_TEST_CORE_MASK &> $output_dir/iscsi_autofuzz_tgt_output.txt & iscsipid=$! trap 'killprocess $iscsipid; exit 1' SIGINT SIGTERM EXIT @@ -58,7 +59,7 @@ sleep 1 trap 'killprocess $iscsipid; iscsitestfini $1 $2; exit 1' SIGINT SIGTERM EXIT -$rootdir/test/app/fuzz/iscsi_fuzz/iscsi_fuzz -m 0xF0 -T $TARGET_IP -t $TEST_TIMEOUT 2>$output_dir/iscsi_autofuzz_logs.txt +$rootdir/test/app/fuzz/iscsi_fuzz/iscsi_fuzz -m 0xF0 -T $TARGET_IP -t $TEST_TIMEOUT 2> $output_dir/iscsi_autofuzz_logs.txt $rpc_py iscsi_delete_target_node 'iqn.2016-06.io.spdk:disk1' diff --git a/test/fuzz/autofuzz_nvmf.sh b/test/fuzz/autofuzz_nvmf.sh index a8ca0c3f48..6fc36e23b6 100755 --- a/test/fuzz/autofuzz_nvmf.sh +++ b/test/fuzz/autofuzz_nvmf.sh @@ -11,10 +11,11 @@ TEST_TIMEOUT=1200 # This argument is used in addition to the test arguments in autotest_common.sh for i in "$@"; do - case "$i" in - --timeout=*) - TEST_TIMEOUT="${i#*=}" - esac + case "$i" in + --timeout=*) + TEST_TIMEOUT="${i#*=}" + ;; + esac done nvmftestinit @@ -24,7 +25,7 @@ timing_enter nvmf_fuzz_test echo "[Nvme]" > $testdir/nvmf_fuzz.conf echo " TransportID \"trtype:$TEST_TRANSPORT adrfam:IPv4 subnqn:nqn.2016-06.io.spdk:cnode1 traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT\" Nvme0" >> $testdir/nvmf_fuzz.conf -"${NVMF_APP[@]}" -m 0xF &>"$output_dir/nvmf_autofuzz_tgt_output.txt" & +"${NVMF_APP[@]}" -m 0xF &> "$output_dir/nvmf_autofuzz_tgt_output.txt" & nvmfpid=$! trap 'process_shm --id $NVMF_APP_SHM_ID; rm -f $testdir/nvmf_fuzz.conf; killprocess $nvmfpid; nvmftestfini $1; exit 1' SIGINT SIGTERM EXIT @@ -39,7 +40,7 @@ $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc0 $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT # Note that we chose a consistent seed to ensure that this test is consistent in nightly builds. -$rootdir/test/app/fuzz/nvme_fuzz/nvme_fuzz -m 0xF0 -r "/var/tmp/nvme_fuzz" -t $TEST_TIMEOUT -C $testdir/nvmf_fuzz.conf -N -a 2>$output_dir/nvmf_autofuzz_logs.txt +$rootdir/test/app/fuzz/nvme_fuzz/nvme_fuzz -m 0xF0 -r "/var/tmp/nvme_fuzz" -t $TEST_TIMEOUT -C $testdir/nvmf_fuzz.conf -N -a 2> $output_dir/nvmf_autofuzz_logs.txt rm -f $testdir/nvmf_fuzz.conf $rpc_py nvmf_delete_subsystem nqn.2016-06.io.spdk:cnode1 diff --git a/test/fuzz/autofuzz_vhost.sh b/test/fuzz/autofuzz_vhost.sh index 0fd7aed71f..4b040ba82f 100755 --- a/test/fuzz/autofuzz_vhost.sh +++ b/test/fuzz/autofuzz_vhost.sh @@ -16,10 +16,11 @@ fuzz_specific_rpc_py="$rootdir/test/app/fuzz/common/fuzz_rpc.py -s $FUZZ_RPC_SOC # This argument is used in addition to the test arguments in autotest_common.sh for i in "$@"; do - case "$i" in - --timeout=*) - TEST_TIMEOUT="${i#*=}" - esac + case "$i" in + --timeout=*) + TEST_TIMEOUT="${i#*=}" + ;; + esac done timing_enter vhost_fuzz_test @@ -29,39 +30,39 @@ timing_enter setup $rootdir/scripts/setup.sh timing_exit setup -"${VHOST_APP[@]}" &>"$output_dir/vhost_fuzz_tgt_output.txt" & +"${VHOST_APP[@]}" &> "$output_dir/vhost_fuzz_tgt_output.txt" & vhostpid=$! waitforlisten $vhostpid trap 'killprocess $vhostpid; exit 1' SIGINT SIGTERM exit -"${VHOST_FUZZ_APP[@]}" -t $TEST_TIMEOUT 2>"$output_dir/vhost_autofuzz_output1.txt" & +"${VHOST_FUZZ_APP[@]}" -t $TEST_TIMEOUT 2> "$output_dir/vhost_autofuzz_output1.txt" & fuzzpid=$! waitforlisten $fuzzpid $FUZZ_RPC_SOCK trap 'killprocess $vhostpid; killprocess $fuzzpid; exit 1' SIGINT SIGTERM exit if [ "$TEST_TRANSPORT" == "bdev" ] || [ "$TEST_TRANSPORT" == "all" ]; then - $vhost_rpc_py bdev_malloc_create -b Malloc0 64 512 - $vhost_rpc_py vhost_create_blk_controller Vhost.1 Malloc0 + $vhost_rpc_py bdev_malloc_create -b Malloc0 64 512 + $vhost_rpc_py vhost_create_blk_controller Vhost.1 Malloc0 - # test the vhost blk controller with valid data buffers. - $fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/Vhost.1 -b -v + # test the vhost blk controller with valid data buffers. + $fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/Vhost.1 -b -v fi if [ "$TEST_TRANSPORT" == "scsi" ] || [ "$TEST_TRANSPORT" == "all" ]; then - $vhost_rpc_py bdev_malloc_create -b Malloc1 64 512 - $vhost_rpc_py vhost_create_scsi_controller naa.VhostScsi0.1 - $vhost_rpc_py vhost_scsi_controller_add_target naa.VhostScsi0.1 0 Malloc1 + $vhost_rpc_py bdev_malloc_create -b Malloc1 64 512 + $vhost_rpc_py vhost_create_scsi_controller naa.VhostScsi0.1 + $vhost_rpc_py vhost_scsi_controller_add_target naa.VhostScsi0.1 0 Malloc1 - $vhost_rpc_py bdev_malloc_create -b Malloc2 64 512 - $vhost_rpc_py vhost_create_scsi_controller naa.VhostScsi0.2 - $vhost_rpc_py vhost_scsi_controller_add_target naa.VhostScsi0.2 0 Malloc2 + $vhost_rpc_py bdev_malloc_create -b Malloc2 64 512 + $vhost_rpc_py vhost_create_scsi_controller naa.VhostScsi0.2 + $vhost_rpc_py vhost_scsi_controller_add_target naa.VhostScsi0.2 0 Malloc2 - # test the vhost scsi I/O queue with valid data buffers on a valid lun. - $fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/naa.VhostScsi0.1 -l -v - # test the vhost scsi management queue with valid data buffers. - $fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/naa.VhostScsi0.2 -v -m + # test the vhost scsi I/O queue with valid data buffers on a valid lun. + $fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/naa.VhostScsi0.1 -l -v + # test the vhost scsi management queue with valid data buffers. + $fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/naa.VhostScsi0.2 -v -m fi # The test won't actually begin until this option is passed in. diff --git a/test/iscsi_tgt/common.sh b/test/iscsi_tgt/common.sh index 3e9465c0ab..d42a2a3a2f 100644 --- a/test/iscsi_tgt/common.sh +++ b/test/iscsi_tgt/common.sh @@ -78,8 +78,8 @@ function iscsitestinit() { function waitforiscsidevices() { local num=$1 - for ((i=1; i<=20; i++)); do - n=$( iscsiadm -m session -P 3 | grep -c "Attached scsi disk sd[a-z]*" || true) + for ((i = 1; i <= 20; i++)); do + n=$(iscsiadm -m session -P 3 | grep -c "Attached scsi disk sd[a-z]*" || true) if [ $n -ne $num ]; then sleep 0.1 else @@ -107,7 +107,7 @@ function start_vpp() { # for VPP side maximal size of MTU for TCP is 1460 and tests doesn't work # stable with larger packets MTU=1460 - MTU_W_HEADER=$((MTU+20)) + MTU_W_HEADER=$((MTU + 20)) ip link set dev $INITIATOR_INTERFACE mtu $MTU ethtool -K $INITIATOR_INTERFACE tso off ethtool -k $INITIATOR_INTERFACE @@ -119,8 +119,8 @@ function start_vpp() { session { evt_qs_memfd_seg } \ socksvr { socket-name /run/vpp-api.sock } \ plugins { \ - plugin default { disable } \ - plugin dpdk_plugin.so { enable } \ + plugin default { disable } \ + plugin dpdk_plugin.so { enable } \ } & vpp_pid=$! @@ -131,13 +131,13 @@ function start_vpp() { # Wait until VPP starts responding xtrace_disable counter=40 - while [ $counter -gt 0 ] ; do + while [ $counter -gt 0 ]; do vppctl show version | grep -E "vpp v[0-9]+\.[0-9]+" && break - counter=$(( counter - 1 )) + counter=$((counter - 1)) sleep 0.5 done xtrace_restore - if [ $counter -eq 0 ] ; then + if [ $counter -eq 0 ]; then return 1 fi @@ -171,8 +171,8 @@ function start_vpp() { sleep 3 # SC1010: ping -M do - in this case do is an option not bash special word # shellcheck disable=SC1010 - ping -c 1 $TARGET_IP -s $(( MTU - 28 )) -M do - vppctl ping $INITIATOR_IP repeat 1 size $(( MTU - (28 + 8) )) verbose | grep -E "$MTU_W_HEADER bytes from $INITIATOR_IP" + ping -c 1 $TARGET_IP -s $((MTU - 28)) -M do + vppctl ping $INITIATOR_IP repeat 1 size $((MTU - (28 + 8))) verbose | grep -E "$MTU_W_HEADER bytes from $INITIATOR_IP" } function kill_vpp() { @@ -187,7 +187,7 @@ function kill_vpp() { } function initiator_json_config() { # Prepare config file for iSCSI initiator - jq . <<-JSON + jq . <<- JSON { "subsystems": [ { diff --git a/test/iscsi_tgt/ext4test/ext4test.sh b/test/iscsi_tgt/ext4test/ext4test.sh index 396b0ac69b..8de4173678 100755 --- a/test/iscsi_tgt/ext4test/ext4test.sh +++ b/test/iscsi_tgt/ext4test/ext4test.sh @@ -69,7 +69,7 @@ echo "Error injection test done" if [ -z "$NO_NVME" ]; then bdev_size=$(get_bdev_size Nvme0n1) - split_size=$((bdev_size/2)) + split_size=$((bdev_size / 2)) if [ $split_size -gt 10000 ]; then split_size=10000 fi diff --git a/test/iscsi_tgt/filesystem/filesystem.sh b/test/iscsi_tgt/filesystem/filesystem.sh index 3813ee7ab6..156b5bde36 100755 --- a/test/iscsi_tgt/filesystem/filesystem.sh +++ b/test/iscsi_tgt/filesystem/filesystem.sh @@ -75,7 +75,7 @@ parted -s /dev/$dev mklabel msdos parted -s /dev/$dev mkpart primary '0%' '100%' sleep 1 -function filesystem_test { +function filesystem_test() { fstype=$1 make_filesystem ${fstype} /dev/${dev}1 diff --git a/test/iscsi_tgt/fio/fio.sh b/test/iscsi_tgt/fio/fio.sh index 0a3f3df5a0..ae3a2f3088 100755 --- a/test/iscsi_tgt/fio/fio.sh +++ b/test/iscsi_tgt/fio/fio.sh @@ -82,7 +82,7 @@ $rpc_py iscsi_create_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK malloc_bdevs="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE) " malloc_bdevs+="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)" $rpc_py bdev_raid_create -n raid0 -z 64 -r 0 -b "$malloc_bdevs" -bdev=$( $rpc_py bdev_malloc_create 1024 512 ) +bdev=$($rpc_py bdev_malloc_create 1024 512) # "raid0:0" ==> use raid0 blockdev for LUN0 # "1:2" ==> map PortalGroup1 to InitiatorGroup2 # "64" ==> iSCSI queue depth 64 @@ -131,7 +131,6 @@ $rpc_py bdev_malloc_delete ${bdev} fio_status=0 wait $fio_pid || fio_status=$? - if [ $fio_status -eq 0 ]; then echo "iscsi hotplug test: fio successful - expected failure" exit 1 diff --git a/test/iscsi_tgt/fuzz/fuzz.sh b/test/iscsi_tgt/fuzz/fuzz.sh index 79fdf34e99..bc290fa8f7 100755 --- a/test/iscsi_tgt/fuzz/fuzz.sh +++ b/test/iscsi_tgt/fuzz/fuzz.sh @@ -49,7 +49,7 @@ sleep 1 trap 'killprocess $iscsipid; iscsitestfini $1 $2; exit 1' SIGINT SIGTERM EXIT -$rootdir/test/app/fuzz/iscsi_fuzz/iscsi_fuzz -m 0xF0 -T $TARGET_IP -t 30 2>$output_dir/iscsi_autofuzz_logs.txt +$rootdir/test/app/fuzz/iscsi_fuzz/iscsi_fuzz -m 0xF0 -T $TARGET_IP -t 30 2> $output_dir/iscsi_autofuzz_logs.txt $rpc_py iscsi_delete_target_node 'iqn.2016-06.io.spdk:disk1' diff --git a/test/iscsi_tgt/initiator/initiator.sh b/test/iscsi_tgt/initiator/initiator.sh index 407ea516b3..5da1f320be 100755 --- a/test/iscsi_tgt/initiator/initiator.sh +++ b/test/iscsi_tgt/initiator/initiator.sh @@ -40,9 +40,9 @@ trap 'killprocess $pid; iscsitestfini $1 $2; exit 1' SIGINT SIGTERM EXIT "$rootdir/test/bdev/bdevperf/bdevperf" --json <(initiator_json_config) -q 128 -o 4096 -w verify -t 5 -s 512 if [ $RUN_NIGHTLY -eq 1 ]; then - "$rootdir/test/bdev/bdevperf/bdevperf" --json <(initiator_json_config) -q 128 -o 4096 -w unmap -t 5 -s 512 - "$rootdir/test/bdev/bdevperf/bdevperf" --json <(initiator_json_config) -q 128 -o 4096 -w flush -t 5 -s 512 - "$rootdir/test/bdev/bdevperf/bdevperf" --json <(initiator_json_config) -q 128 -o 4096 -w reset -t 10 -s 512 + "$rootdir/test/bdev/bdevperf/bdevperf" --json <(initiator_json_config) -q 128 -o 4096 -w unmap -t 5 -s 512 + "$rootdir/test/bdev/bdevperf/bdevperf" --json <(initiator_json_config) -q 128 -o 4096 -w flush -t 5 -s 512 + "$rootdir/test/bdev/bdevperf/bdevperf" --json <(initiator_json_config) -q 128 -o 4096 -w reset -t 10 -s 512 fi trap - SIGINT SIGTERM EXIT diff --git a/test/iscsi_tgt/ip_migration/ip_migration.sh b/test/iscsi_tgt/ip_migration/ip_migration.sh index a1f361fa2e..7e0b0c6219 100755 --- a/test/iscsi_tgt/ip_migration/ip_migration.sh +++ b/test/iscsi_tgt/ip_migration/ip_migration.sh @@ -47,12 +47,12 @@ function rpc_validate_ip() { echo "Add new IP succeeded." else echo "Add new IP failed. Expected to succeed..." - exit 1; + exit 1 fi # Add same IP again if $cmd; then echo "Same IP existed. Expected to fail..." - exit 1; + exit 1 fi cmd="$rpc_py -s $1 net_interface_delete_ip_address 1 $MIGRATION_ADDRESS" @@ -60,12 +60,12 @@ function rpc_validate_ip() { echo "Delete existing IP succeeded." else echo "Delete existing IP failed. Expected to succeed..." - exit 1; + exit 1 fi # Delete same IP again if $cmd; then echo "No required IP existed. Expected to fail..." - exit 1; + exit 1 fi } diff --git a/test/iscsi_tgt/lvol/iscsi_lvol.sh b/test/iscsi_tgt/lvol/iscsi_lvol.sh index 095149900e..e55899d56d 100755 --- a/test/iscsi_tgt/lvol/iscsi_lvol.sh +++ b/test/iscsi_tgt/lvol/iscsi_lvol.sh @@ -69,7 +69,7 @@ sleep 1 timing_enter discovery iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT -waitforiscsidevices $(( NUM_LVS * NUM_LVOL )) +waitforiscsidevices $((NUM_LVS * NUM_LVOL)) timing_exit discovery timing_enter fio diff --git a/test/iscsi_tgt/perf/iscsi_initiator.sh b/test/iscsi_tgt/perf/iscsi_initiator.sh index 500a7d8777..b7d08bbc22 100755 --- a/test/iscsi_tgt/perf/iscsi_initiator.sh +++ b/test/iscsi_tgt/perf/iscsi_initiator.sh @@ -11,7 +11,7 @@ if [ ! -x $FIO_PATH/fio ]; then error "Invalid path of fio binary" fi -function run_spdk_iscsi_fio(){ +function run_spdk_iscsi_fio() { $FIO_PATH/fio $testdir/perf.job "$@" --output-format=json } @@ -23,8 +23,7 @@ iscsiadm -m node --login -p $IP_T:$ISCSI_PORT waitforiscsidevices 1 disks=($(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}')) -for (( i=0; i < ${#disks[@]}; i++ )) -do +for ((i = 0; i < ${#disks[@]}; i++)); do filename+=$(printf /dev/%s: "${disks[i]}") waitforfile $filename echo noop > /sys/block/${disks[i]}/queue/scheduler diff --git a/test/iscsi_tgt/perf/iscsi_target.sh b/test/iscsi_tgt/perf/iscsi_target.sh index 94bafc8f93..6a5fd3fae1 100755 --- a/test/iscsi_tgt/perf/iscsi_target.sh +++ b/test/iscsi_tgt/perf/iscsi_target.sh @@ -20,9 +20,11 @@ NUM_JOBS=1 ISCSI_TGT_CM=0x02 # Performance test for iscsi_tgt, run on devices with proper hardware support (target and inititator) -function usage() -{ - [[ -n $2 ]] && ( echo "$2"; echo ""; ) +function usage() { + [[ -n $2 ]] && ( + echo "$2" + echo "" + ) echo "Usage: $(basename $1) [options]" echo "-h, --help Print help and exit" echo " --fiopath=PATH Path to fio directory on initiator. [default=$FIO_PATH]" @@ -36,19 +38,31 @@ function usage() while getopts 'h-:' optchar; do case "$optchar" in -) - case "$OPTARG" in - help) usage $0; exit 0 ;; - fiopath=*) FIO_BIN="${OPTARG#*=}" ;; - disk_no=*) DISKNO="${OPTARG#*=}" ;; - target_ip=*) TARGET_IP="${OPTARG#*=}" ;; - initiator_ip=*) INITIATOR_IP="${OPTARG#*=}" ;; - init_mgmnt_ip=*) IP_I_SSH="${OPTARG#*=}" ;; - iscsi_tgt_mask=*) ISCSI_TGT_CM="${OPTARG#*=}" ;; - *) usage $0 echo "Invalid argument '$OPTARG'"; exit 1 ;; - esac - ;; - h) usage $0; exit 0 ;; - *) usage $0 "Invalid argument '$optchar'"; exit 1 ;; + case "$OPTARG" in + help) + usage $0 + exit 0 + ;; + fiopath=*) FIO_BIN="${OPTARG#*=}" ;; + disk_no=*) DISKNO="${OPTARG#*=}" ;; + target_ip=*) TARGET_IP="${OPTARG#*=}" ;; + initiator_ip=*) INITIATOR_IP="${OPTARG#*=}" ;; + init_mgmnt_ip=*) IP_I_SSH="${OPTARG#*=}" ;; + iscsi_tgt_mask=*) ISCSI_TGT_CM="${OPTARG#*=}" ;; + *) + usage $0 echo "Invalid argument '$OPTARG'" + exit 1 + ;; + esac + ;; + h) + usage $0 + exit 0 + ;; + *) + usage $0 "Invalid argument '$optchar'" + exit 1 + ;; esac done @@ -68,7 +82,7 @@ if [ $EUID -ne 0 ]; then error "INFO: This script must be run with root privileges" fi -function ssh_initiator(){ +function ssh_initiator() { ssh -i $HOME/.ssh/spdk_vhost_id_rsa root@$IP_I_SSH "$@" } @@ -100,8 +114,7 @@ fi $rpc_py iscsi_create_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT $rpc_py iscsi_create_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK -for (( i=0; i < DISKNO; i++ )) -do +for ((i = 0; i < DISKNO; i++)); do $rpc_py iscsi_create_target_node Target${i} Target${i}_alias "${bdevs[i]}:0" "$PORTAL_TAG:$INITIATOR_TAG" 64 -d done @@ -110,7 +123,7 @@ rm -f $testdir/perf.job timing_exit iscsi_config timing_enter iscsi_initiator -ssh_initiator bash -s - < $testdir/iscsi_initiator.sh $FIO_PATH $TARGET_IP +ssh_initiator bash -s - $FIO_PATH $TARGET_IP < $testdir/iscsi_initiator.sh timing_exit iscsi_initiator ssh_initiator "cat perf_output/iscsi_fio.json" > $iscsi_fio_results diff --git a/test/iscsi_tgt/qos/qos.sh b/test/iscsi_tgt/qos/qos.sh index 0e013b7905..0a8015e18a 100755 --- a/test/iscsi_tgt/qos/qos.sh +++ b/test/iscsi_tgt/qos/qos.sh @@ -28,16 +28,16 @@ function run_fio() { end_io_count=$(jq -r '.bdevs[0].num_read_ops' <<< "$iostats") end_bytes_read=$(jq -r '.bdevs[0].bytes_read' <<< "$iostats") - IOPS_RESULT=$(((end_io_count-start_io_count)/run_time)) - BANDWIDTH_RESULT=$(((end_bytes_read-start_bytes_read)/run_time)) + IOPS_RESULT=$(((end_io_count - start_io_count) / run_time)) + BANDWIDTH_RESULT=$(((end_bytes_read - start_bytes_read) / run_time)) } function verify_qos_limits() { local result=$1 local limit=$2 - [ "$(bc <<< "$result > $limit*0.85")" -eq 1 ] && \ - [ "$(bc <<< "$result < $limit*1.05")" -eq 1 ] + [ "$(bc <<< "$result > $limit*0.85")" -eq 1 ] \ + && [ "$(bc <<< "$result < $limit*1.05")" -eq 1 ] } if [ -z "$TARGET_IP" ]; then @@ -87,19 +87,19 @@ trap 'iscsicleanup; killprocess $pid; iscsitestfini $1 $2; exit 1' SIGINT SIGTER run_fio Malloc0 # Set IOPS/bandwidth limit to 50% of the actual unrestrained performance. -IOPS_LIMIT=$((IOPS_RESULT/2)) -BANDWIDTH_LIMIT=$((BANDWIDTH_RESULT/2)) +IOPS_LIMIT=$((IOPS_RESULT / 2)) +BANDWIDTH_LIMIT=$((BANDWIDTH_RESULT / 2)) # Set READ bandwidth limit to 50% of the RW bandwidth limit to be able # to differentiate those two. -READ_BANDWIDTH_LIMIT=$((BANDWIDTH_LIMIT/2)) +READ_BANDWIDTH_LIMIT=$((BANDWIDTH_LIMIT / 2)) # Also round them down to nearest multiple of either 1000 IOPS or 1MB BW # which are the minimal QoS granularities -IOPS_LIMIT=$((IOPS_LIMIT/1000*1000)) -BANDWIDTH_LIMIT_MB=$((BANDWIDTH_LIMIT/1024/1024)) -BANDWIDTH_LIMIT=$((BANDWIDTH_LIMIT_MB*1024*1024)) -READ_BANDWIDTH_LIMIT_MB=$((READ_BANDWIDTH_LIMIT/1024/1024)) -READ_BANDWIDTH_LIMIT=$((READ_BANDWIDTH_LIMIT_MB*1024*1024)) +IOPS_LIMIT=$((IOPS_LIMIT / 1000 * 1000)) +BANDWIDTH_LIMIT_MB=$((BANDWIDTH_LIMIT / 1024 / 1024)) +BANDWIDTH_LIMIT=$((BANDWIDTH_LIMIT_MB * 1024 * 1024)) +READ_BANDWIDTH_LIMIT_MB=$((READ_BANDWIDTH_LIMIT / 1024 / 1024)) +READ_BANDWIDTH_LIMIT=$((READ_BANDWIDTH_LIMIT_MB * 1024 * 1024)) # Limit the I/O rate by RPC, then confirm the observed rate matches. $rpc_py bdev_set_qos_limit Malloc0 --rw_ios_per_sec $IOPS_LIMIT diff --git a/test/iscsi_tgt/rbd/rbd.sh b/test/iscsi_tgt/rbd/rbd.sh index 3532faa59b..060cc7af0d 100755 --- a/test/iscsi_tgt/rbd/rbd.sh +++ b/test/iscsi_tgt/rbd/rbd.sh @@ -37,10 +37,10 @@ rbd_bdev="$($rpc_py bdev_rbd_create $RBD_POOL $RBD_NAME 4096)" $rpc_py bdev_get_bdevs $rpc_py bdev_rbd_resize $rbd_bdev 2000 -num_block=$($rpc_py bdev_get_bdevs|grep num_blocks|sed 's/[^[:digit:]]//g') +num_block=$($rpc_py bdev_get_bdevs | grep num_blocks | sed 's/[^[:digit:]]//g') # get the bdev size in MiB. -total_size=$(( num_block * 4096/ 1048576 )) -if [ $total_size != 2000 ];then +total_size=$((num_block * 4096 / 1048576)) +if [ $total_size != 2000 ]; then echo "resize failed." exit 1 fi diff --git a/test/iscsi_tgt/sock/sock.sh b/test/iscsi_tgt/sock/sock.sh index 99879197b9..610b1a70c5 100755 --- a/test/iscsi_tgt/sock/sock.sh +++ b/test/iscsi_tgt/sock/sock.sh @@ -8,13 +8,13 @@ source $rootdir/test/iscsi_tgt/common.sh function waitfortcp() { local addr="$2" - if hash ip &>/dev/null; then + if hash ip &> /dev/null; then local have_ip_cmd=true else local have_ip_cmd=false fi - if hash ss &>/dev/null; then + if hash ss &> /dev/null; then local have_ss_cmd=true else local have_ss_cmd=false @@ -25,7 +25,7 @@ function waitfortcp() { xtrace_disable local ret=0 local i - for (( i = 40; i != 0; i-- )); do + for ((i = 40; i != 0; i--)); do # if the process is no longer running, then exit the script # since it means the application crashed if ! kill -s 0 $1; then @@ -55,7 +55,7 @@ function waitfortcp() { done xtrace_restore - if (( i == 0 )); then + if ((i == 0)); then echo "ERROR: timeout while waiting for process (pid: $1) to start listening on '$addr'" ret=1 fi @@ -77,8 +77,8 @@ if [ -z "$TEST_TYPE" ]; then fi if [ "$TEST_TYPE" != "posix" ] && [ "$TEST_TYPE" != "vpp" ]; then - echo "No correct sock implmentation specified" - exit 1 + echo "No correct sock implmentation specified" + exit 1 fi HELLO_SOCK_APP="${TARGET_NS_CMD[*]} $rootdir/examples/sock/hello_world/hello_sock" @@ -94,14 +94,15 @@ timing_enter sock_client echo "Testing client path" # start echo server using socat -$SOCAT_APP tcp-l:$ISCSI_PORT,fork,bind=$INITIATOR_IP exec:'/bin/cat' & server_pid=$! +$SOCAT_APP tcp-l:$ISCSI_PORT,fork,bind=$INITIATOR_IP exec:'/bin/cat' & +server_pid=$! trap 'killprocess $server_pid;iscsitestfini $1 $2; exit 1' SIGINT SIGTERM EXIT waitfortcp $server_pid $INITIATOR_IP:$ISCSI_PORT # send message using hello_sock client message="**MESSAGE:This is a test message from the client**" -response=$( echo $message | $HELLO_SOCK_APP -H $INITIATOR_IP -P $ISCSI_PORT -N $TEST_TYPE) +response=$(echo $message | $HELLO_SOCK_APP -H $INITIATOR_IP -P $ISCSI_PORT -N $TEST_TYPE) if ! echo "$response" | grep -q "$message"; then exit 1 @@ -120,13 +121,14 @@ timing_exit sock_client timing_enter sock_server # start echo server using hello_sock echo server -$HELLO_SOCK_APP -H $TARGET_IP -P $ISCSI_PORT -S -N $TEST_TYPE & server_pid=$! +$HELLO_SOCK_APP -H $TARGET_IP -P $ISCSI_PORT -S -N $TEST_TYPE & +server_pid=$! trap 'killprocess $server_pid; iscsitestfini $1 $2; exit 1' SIGINT SIGTERM EXIT waitforlisten $server_pid # send message to server using socat message="**MESSAGE:This is a test message to the server**" -response=$( echo $message | $SOCAT_APP - tcp:$TARGET_IP:$ISCSI_PORT 2>/dev/null ) +response=$(echo $message | $SOCAT_APP - tcp:$TARGET_IP:$ISCSI_PORT 2> /dev/null) if [ "$message" != "$response" ]; then exit 1 diff --git a/test/iscsi_tgt/trace_record/trace_record.sh b/test/iscsi_tgt/trace_record/trace_record.sh index e13f80893b..d98d58687a 100755 --- a/test/iscsi_tgt/trace_record/trace_record.sh +++ b/test/iscsi_tgt/trace_record/trace_record.sh @@ -51,7 +51,7 @@ echo "iscsi_tgt is listening. Running tests..." timing_exit start_iscsi_tgt mkdir -p ${TRACE_TMP_FOLDER} -./app/trace_record/spdk_trace_record -s iscsi -p ${iscsi_pid} -f ${TRACE_RECORD_OUTPUT} -q 1>${TRACE_RECORD_NOTICE_LOG} & +./app/trace_record/spdk_trace_record -s iscsi -p ${iscsi_pid} -f ${TRACE_RECORD_OUTPUT} -q 1> ${TRACE_RECORD_NOTICE_LOG} & record_pid=$! echo "Trace record pid: $record_pid" @@ -71,7 +71,7 @@ sleep 1 iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT -waitforiscsidevices $(( CONNECTION_NUMBER + 1 )) +waitforiscsidevices $((CONNECTION_NUMBER + 1)) trap 'iscsicleanup; killprocess $iscsi_pid; killprocess $record_pid; delete_tmp_files; iscsitestfini $1 $2; exit 1' SIGINT SIGTERM EXIT @@ -112,23 +112,23 @@ len_arr_record_num=${#arr_record_num[@]} len_arr_trace_tool_num=${#arr_trace_tool_num[@]} #lcore num check -if [ $len_arr_record_num -ne $len_arr_trace_tool_num ]; then +if [ $len_arr_record_num -ne $len_arr_trace_tool_num ]; then echo "trace record test on iscsi: failure on lcore number check" set -e exit 1 fi #trace entries num check for i in $(seq 0 $((len_arr_record_num - 1))); do -if [ ${arr_record_num[$i]} -le ${NUM_TRACE_ENTRIES} ]; then - echo "trace record test on iscsi: failure on inefficient entries number check" - set -e - exit 1 -fi -if [ ${arr_record_num[$i]} -ne ${arr_trace_tool_num[$i]} ]; then - echo "trace record test on iscsi: failure on entries number check" - set -e - exit 1 -fi + if [ ${arr_record_num[$i]} -le ${NUM_TRACE_ENTRIES} ]; then + echo "trace record test on iscsi: failure on inefficient entries number check" + set -e + exit 1 + fi + if [ ${arr_record_num[$i]} -ne ${arr_trace_tool_num[$i]} ]; then + echo "trace record test on iscsi: failure on entries number check" + set -e + exit 1 + fi done trap - SIGINT SIGTERM EXIT diff --git a/test/json_config/json_config.sh b/test/json_config/json_config.sh index e269fc50e8..867c65b6f2 100755 --- a/test/json_config/json_config.sh +++ b/test/json_config/json_config.sh @@ -14,13 +14,13 @@ if [[ $SPDK_TEST_VHOST -ne 1 && $SPDK_TEST_VHOST_INIT -eq 1 ]]; then echo " Setting SPDK_TEST_VHOST=1 for duration of current script." fi -if (( SPDK_TEST_BLOCKDEV + \ - SPDK_TEST_ISCSI + - SPDK_TEST_NVMF + - SPDK_TEST_VHOST + - SPDK_TEST_VHOST_INIT + - SPDK_TEST_PMDK + - SPDK_TEST_RBD == 0 )); then +if ((SPDK_TEST_BLOCKDEV + \ + SPDK_TEST_ISCSI + \ + SPDK_TEST_NVMF + \ + SPDK_TEST_VHOST + \ + SPDK_TEST_VHOST_INIT + \ + SPDK_TEST_PMDK + \ + SPDK_TEST_RBD == 0)); then echo "WARNING: No tests are enabled so not running JSON configuration tests" exit 0 fi @@ -58,41 +58,41 @@ function tgt_check_notification_types() { } function tgt_check_notifications() { - local event_line event ev_type ev_ctx - local rc="" + local event_line event ev_type ev_ctx + local rc="" - while read -r event_line; do - # remove ID - event="${event_line%:*}" + while read -r event_line; do + # remove ID + event="${event_line%:*}" - ev_type=${event%:*} - ev_ctx=${event#*:} + ev_type=${event%:*} + ev_ctx=${event#*:} - ex_ev_type=${1%%:*} - ex_ev_ctx=${1#*:} + ex_ev_type=${1%%:*} + ex_ev_ctx=${1#*:} - last_event_id=${event_line##*:} + last_event_id=${event_line##*:} - # set rc=false in case of failure so all errors can be printed - if (( $# == 0 )); then - echo "ERROR: got extra event: $event_line" - rc=false - continue - elif ! echo "$ev_type" | grep -E -q "^${ex_ev_type}\$" || ! echo "$ev_ctx" | grep -E -q "^${ex_ev_ctx}\$"; then - echo "ERROR: expected event '$1' but got '$event' (whole event line: $event_line)" - rc=false - fi + # set rc=false in case of failure so all errors can be printed + if (($# == 0)); then + echo "ERROR: got extra event: $event_line" + rc=false + continue + elif ! echo "$ev_type" | grep -E -q "^${ex_ev_type}\$" || ! echo "$ev_ctx" | grep -E -q "^${ex_ev_ctx}\$"; then + echo "ERROR: expected event '$1' but got '$event' (whole event line: $event_line)" + rc=false + fi - shift - done < <(tgt_rpc notify_get_notifications -i ${last_event_id} | jq -r '.[] | "\(.type):\(.ctx):\(.id)"') + shift + done < <(tgt_rpc notify_get_notifications -i ${last_event_id} | jq -r '.[] | "\(.type):\(.ctx):\(.id)"') - $rc + $rc - if (( $# != 0 )); then - echo "ERROR: missing events:" - echo "$@" - return 1 - fi + if (($# != 0)); then + echo "ERROR: missing events:" + echo "$@" + return 1 + fi } # $1 - target / initiator @@ -102,7 +102,7 @@ function json_config_test_start_app() { shift [[ -n "${#app_socket[$app]}" ]] # Check app type - [[ -z "${app_pid[$app]}" ]] # Assert if app is not running + [[ -z "${app_pid[$app]}" ]] # Assert if app is not running local app_extra_params="" if [[ $SPDK_TEST_VHOST -eq 1 || $SPDK_TEST_VHOST_INIT -eq 1 ]]; then @@ -129,8 +129,8 @@ function json_config_test_shutdown_app() { # spdk_kill_instance RPC will trigger ASAN kill -SIGINT ${app_pid[$app]} - for (( i=0; i<30; i++ )); do - if ! kill -0 ${app_pid[$app]} 2>/dev/null; then + for ((i = 0; i < 30; i++)); do + if ! kill -0 ${app_pid[$app]} 2> /dev/null; then app_pid[$app]= break fi @@ -152,7 +152,7 @@ function create_bdev_subsystem_config() { if [[ $SPDK_TEST_BLOCKDEV -eq 1 ]]; then local lvol_store_base_bdev=Nvme0n1 - if ! tgt_rpc get_bdevs --name ${lvol_store_base_bdev} >/dev/null; then + if ! tgt_rpc get_bdevs --name ${lvol_store_base_bdev} > /dev/null; then if [[ $(uname -s) = Linux ]]; then lvol_store_base_bdev=aio_disk echo "WARNING: No NVMe drive found. Using '$lvol_store_base_bdev' instead." @@ -191,7 +191,7 @@ function create_bdev_subsystem_config() { # This AIO bdev must be large enough to be used as LVOL store dd if=/dev/zero of=/tmp/sample_aio bs=1024 count=102400 tgt_rpc bdev_aio_create /tmp/sample_aio aio_disk 1024 - expected_notifications+=( bdev_register:aio_disk ) + expected_notifications+=(bdev_register:aio_disk) fi # For LVOLs use split to check for proper order of initialization. @@ -200,8 +200,8 @@ function create_bdev_subsystem_config() { tgt_rpc bdev_lvol_create_lvstore -c 1048576 ${lvol_store_base_bdev}p0 lvs_test tgt_rpc bdev_lvol_create -l lvs_test lvol0 32 tgt_rpc bdev_lvol_create -l lvs_test -t lvol1 32 - tgt_rpc bdev_lvol_snapshot lvs_test/lvol0 snapshot0 - tgt_rpc bdev_lvol_clone lvs_test/snapshot0 clone0 + tgt_rpc bdev_lvol_snapshot lvs_test/lvol0 snapshot0 + tgt_rpc bdev_lvol_clone lvs_test/snapshot0 clone0 expected_notifications+=( "bdev_register:$RE_UUID" @@ -231,13 +231,13 @@ function create_bdev_subsystem_config() { rm -f $pmem_pool_file tgt_rpc create_pmem_pool $pmem_pool_file 128 4096 tgt_rpc bdev_pmem_create -n pmem1 $pmem_pool_file - expected_notifications+=( bdev_register:pmem1 ) + expected_notifications+=(bdev_register:pmem1) fi if [[ $SPDK_TEST_RBD -eq 1 ]]; then rbd_setup 127.0.0.1 tgt_rpc bdev_rbd_create $RBD_POOL $RBD_NAME 4096 - expected_notifications+=( bdev_register:Ceph0 ) + expected_notifications+=(bdev_register:Ceph0) fi tgt_check_notifications "${expected_notifications[@]}" @@ -249,9 +249,9 @@ function cleanup_bdev_subsystem_config() { timing_enter "${FUNCNAME[0]}" if [[ $SPDK_TEST_BLOCKDEV -eq 1 ]]; then - tgt_rpc bdev_lvol_delete lvs_test/clone0 - tgt_rpc bdev_lvol_delete lvs_test/lvol0 - tgt_rpc bdev_lvol_delete lvs_test/snapshot0 + tgt_rpc bdev_lvol_delete lvs_test/clone0 + tgt_rpc bdev_lvol_delete lvs_test/lvol0 + tgt_rpc bdev_lvol_delete lvs_test/snapshot0 tgt_rpc bdev_lvol_delete_lvstore -l lvs_test fi @@ -278,16 +278,16 @@ function create_vhost_subsystem_config() { tgt_rpc bdev_malloc_create 64 1024 --name MallocForVhost0 tgt_rpc bdev_split_create MallocForVhost0 8 - tgt_rpc vhost_create_scsi_controller VhostScsiCtrlr0 - tgt_rpc vhost_scsi_controller_add_target VhostScsiCtrlr0 0 MallocForVhost0p3 - tgt_rpc vhost_scsi_controller_add_target VhostScsiCtrlr0 -1 MallocForVhost0p4 - tgt_rpc vhost_controller_set_coalescing VhostScsiCtrlr0 1 100 + tgt_rpc vhost_create_scsi_controller VhostScsiCtrlr0 + tgt_rpc vhost_scsi_controller_add_target VhostScsiCtrlr0 0 MallocForVhost0p3 + tgt_rpc vhost_scsi_controller_add_target VhostScsiCtrlr0 -1 MallocForVhost0p4 + tgt_rpc vhost_controller_set_coalescing VhostScsiCtrlr0 1 100 - tgt_rpc vhost_create_blk_controller VhostBlkCtrlr0 MallocForVhost0p5 + tgt_rpc vhost_create_blk_controller VhostBlkCtrlr0 MallocForVhost0p5 -# FIXME: enable after vhost-nvme is properly implemented against the latest rte_vhost (DPDK 19.05+) -# tgt_rpc vhost_create_nvme_controller VhostNvmeCtrlr0 16 -# tgt_rpc vhost_nvme_controller_add_ns VhostNvmeCtrlr0 MallocForVhost0p6 + # FIXME: enable after vhost-nvme is properly implemented against the latest rte_vhost (DPDK 19.05+) + # tgt_rpc vhost_create_nvme_controller VhostNvmeCtrlr0 16 + # tgt_rpc vhost_nvme_controller_add_ns VhostNvmeCtrlr0 MallocForVhost0p6 timing_exit "${FUNCNAME[0]}" } @@ -315,9 +315,9 @@ function create_nvmf_subsystem_config() { tgt_rpc bdev_malloc_create 4 1024 --name MallocForNvmf1 tgt_rpc nvmf_create_transport -t RDMA -u 8192 -c 0 - tgt_rpc nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001 - tgt_rpc nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 MallocForNvmf0 - tgt_rpc nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 MallocForNvmf1 + tgt_rpc nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001 + tgt_rpc nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 MallocForNvmf0 + tgt_rpc nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 MallocForNvmf1 tgt_rpc nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t RDMA -a $NVMF_FIRST_TARGET_IP -s "$NVMF_PORT" timing_exit "${FUNCNAME[0]}" @@ -326,14 +326,12 @@ function create_nvmf_subsystem_config() { function create_virtio_initiator_config() { timing_enter "${FUNCNAME[0]}" initiator_rpc bdev_virtio_attach_controller -t user -a /var/tmp/VhostScsiCtrlr0 -d scsi VirtioScsiCtrlr0 - initiator_rpc bdev_virtio_attach_controller -t user -a /var/tmp/VhostBlkCtrlr0 -d blk VirtioBlk0 + initiator_rpc bdev_virtio_attach_controller -t user -a /var/tmp/VhostBlkCtrlr0 -d blk VirtioBlk0 # TODO: initiator_rpc bdev_virtio_attach_controller -t user -a /var/tmp/VhostNvmeCtrlr0 -d nvme VirtioNvme0 timing_exit "${FUNCNAME[0]}" } - -function json_config_test_init() -{ +function json_config_test_init() { timing_enter "${FUNCNAME[0]}" timing_enter json_config_setup_target @@ -343,7 +341,7 @@ function json_config_test_init() # Load nvme configuration. The load_config will issue framework_start_init automatically ( - echo '{"subsystems": ['; + echo '{"subsystems": [' $rootdir/scripts/gen_nvme.sh --json | jq -r "del(.config[] | select(.params.name!=\"Nvme0\"))" echo ']}' ) | tgt_rpc load_config @@ -412,13 +410,13 @@ function json_config_clear() { # It causes that configuration may not be fully cleaned at this moment and # we should to wait a while. (See github issue #789) count=100 - while [ $count -gt 0 ] ; do + while [ $count -gt 0 ]; do $rootdir/scripts/rpc.py -s "${app_socket[$1]}" save_config | $config_filter -method delete_global_parameters | $config_filter -method check_empty && break - count=$(( count -1 )) + count=$((count - 1)) sleep 0.1 done - if [ $count -eq 0 ] ; then + if [ $count -eq 0 ]; then return 1 fi } @@ -465,7 +463,7 @@ fi echo "INFO: changing configuration and checking if this can be detected..." # Self test to check if configuration diff can be detected. tgt_rpc bdev_malloc_delete MallocBdevForConfigChangeCheck -if $rootdir/test/json_config/json_diff.sh <(tgt_rpc save_config) "${configs_path[target]}" >/dev/null; then +if $rootdir/test/json_config/json_diff.sh <(tgt_rpc save_config) "${configs_path[target]}" > /dev/null; then echo "ERROR: intentional configuration difference not detected!" false else diff --git a/test/lvol/basic.sh b/test/lvol/basic.sh index 97c62906cc..f8de5c2dcc 100755 --- a/test/lvol/basic.sh +++ b/test/lvol/basic.sh @@ -31,7 +31,7 @@ function test_construct_lvs() { [ "$cluster_size" = "$LVS_DEFAULT_CLUSTER_SIZE" ] total_clusters=$(jq -r '.[0].total_data_clusters' <<< "$lvs") [ "$(jq -r '.[0].free_clusters' <<< "$lvs")" = "$total_clusters" ] - [ "$(( total_clusters * cluster_size ))" = "$LVS_DEFAULT_CAPACITY" ] + [ "$((total_clusters * cluster_size))" = "$LVS_DEFAULT_CAPACITY" ] # remove the lvs and verify it's gone rpc_cmd bdev_lvol_delete_lvstore -u "$lvs_uuid" @@ -100,11 +100,11 @@ function test_construct_lvs_different_cluster_size() { # use the second malloc for some more lvs creation negative tests malloc2_name=$(rpc_cmd bdev_malloc_create $MALLOC_SIZE_MB $MALLOC_BS) # capacity bigger than malloc's - rpc_cmd bdev_lvol_create_lvstore "$malloc2_name" lvs2_test -c $(( MALLOC_SIZE + 1 )) && false + rpc_cmd bdev_lvol_create_lvstore "$malloc2_name" lvs2_test -c $((MALLOC_SIZE + 1)) && false # capacity equal to malloc's (no space left for metadata) rpc_cmd bdev_lvol_create_lvstore "$malloc2_name" lvs2_test -c $MALLOC_SIZE && false # capacity smaller than malloc's, but still no space left for metadata - rpc_cmd bdev_lvol_create_lvstore "$malloc2_name" lvs2_test -c $(( MALLOC_SIZE - 1 )) && false + rpc_cmd bdev_lvol_create_lvstore "$malloc2_name" lvs2_test -c $((MALLOC_SIZE - 1)) && false # cluster size smaller than the minimum (8192) rpc_cmd bdev_lvol_create_lvstore "$malloc2_name" lvs2_test -c 8191 && false @@ -137,7 +137,7 @@ function test_construct_lvs_clear_methods() { malloc_name=$(rpc_cmd bdev_malloc_create $MALLOC_SIZE_MB $MALLOC_BS) # first try to provide invalid clear method - rpc_cmd bdev_lvol_create_lvstore "$malloc2_name" lvs2_test --clear-method invalid123 && false + rpc_cmd bdev_lvol_create_lvstore "$malloc2_name" lvs2_test --clear-method invalid123 && false # no lvs should be created lvol_stores=$(rpc_cmd bdev_lvol_get_lvstores) @@ -154,7 +154,7 @@ function test_construct_lvs_clear_methods() { [ "$(jq -r '.[0].uuid' <<< "$lvol")" = "$lvol_uuid" ] [ "$(jq -r '.[0].aliases[0]' <<< "$lvol")" = "lvs_test/lvol_test" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$MALLOC_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( LVS_DEFAULT_CAPACITY / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((LVS_DEFAULT_CAPACITY / MALLOC_BS))" ] # clean up rpc_cmd bdev_lvol_delete "$lvol_uuid" @@ -181,10 +181,10 @@ function test_construct_lvol_fio_clear_method_none() { get_lvs_jq bdev_lvol_get_lvstores -u "$lvstore_uuid" lvol_uuid=$(rpc_cmd bdev_lvol_create \ - -c "$clear_method" \ - -u "$lvstore_uuid" \ - "$lvol_name" \ - $(( jq_out["cluster_size"] / 1024**2 ))) + -c "$clear_method" \ + -u "$lvstore_uuid" \ + "$lvol_name" \ + $((jq_out["cluster_size"] / 1024 ** 2))) nbd_start_disks "$DEFAULT_RPC_ADDR" "$lvol_uuid" "$nbd_name" run_fio_test "$nbd_name" 0 "${jq_out["cluster_size"]}" write 0xdd @@ -203,12 +203,12 @@ function test_construct_lvol_fio_clear_method_none() { metadata_pages=$(calc "1 + ${jq_out["total_data_clusters"]} + ceil(5 + ceil(${jq_out["total_data_clusters"]} / 8) / 4096) * 3") - last_metadata_lba=$(( metadata_pages * 4096 / MALLOC_BS )) - offset_metadata_end=$(( last_metadata_lba * MALLOC_BS )) + last_metadata_lba=$((metadata_pages * 4096 / MALLOC_BS)) + offset_metadata_end=$((last_metadata_lba * MALLOC_BS)) last_cluster_of_metadata=$(calc "ceil($metadata_pages / ${jq_out["cluster_size"]} / 4096)") - last_cluster_of_metadata=$(( last_cluster_of_metadata == 0 ? 1 : last_cluster_of_metadata )) - offset=$(( last_cluster_of_metadata * jq_out["cluster_size"] )) - size_metadata_end=$(( offset - offset_metadata_end )) + last_cluster_of_metadata=$((last_cluster_of_metadata == 0 ? 1 : last_cluster_of_metadata)) + offset=$((last_cluster_of_metadata * jq_out["cluster_size"])) + size_metadata_end=$((offset - offset_metadata_end)) # Check if data on area between end of metadata and first cluster of lvol bdev remained unchaged. run_fio_test "$nbd_name" "$offset_metadata_end" "$size_metadata_end" "read" 0x00 @@ -233,17 +233,17 @@ function test_construct_lvol_fio_clear_method_unmap() { malloc_dev=$(rpc_cmd bdev_malloc_create 256 "$MALLOC_BS") nbd_start_disks "$DEFAULT_RPC_ADDR" "$malloc_dev" "$nbd_name" - run_fio_test "$nbd_name" 0 $(( 256 * 1024**2 )) write 0xdd + run_fio_test "$nbd_name" 0 $((256 * 1024 ** 2)) write 0xdd nbd_stop_disks "$DEFAULT_RPC_ADDR" "$nbd_name" lvstore_uuid=$(rpc_cmd bdev_lvol_create_lvstore --clear-method none "$malloc_dev" "$lvstore_name") get_lvs_jq bdev_lvol_get_lvstores -u "$lvstore_uuid" lvol_uuid=$(rpc_cmd bdev_lvol_create \ - -c "$clear_method" \ - -u "$lvstore_uuid" \ - "$lvol_name" \ - $(( jq_out["cluster_size"] / 1024**2 ))) + -c "$clear_method" \ + -u "$lvstore_uuid" \ + "$lvol_name" \ + $((jq_out["cluster_size"] / 1024 ** 2))) nbd_start_disks "$DEFAULT_RPC_ADDR" "$lvol_uuid" "$nbd_name" run_fio_test "$nbd_name" 0 "${jq_out["cluster_size"]}" read 0xdd @@ -262,12 +262,12 @@ function test_construct_lvol_fio_clear_method_unmap() { metadata_pages=$(calc "1 + ${jq_out["total_data_clusters"]} + ceil(5 + ceil(${jq_out["total_data_clusters"]} / 8) / 4096) * 3") - last_metadata_lba=$(( metadata_pages * 4096 / MALLOC_BS )) - offset_metadata_end=$(( last_metadata_lba * MALLOC_BS )) + last_metadata_lba=$((metadata_pages * 4096 / MALLOC_BS)) + offset_metadata_end=$((last_metadata_lba * MALLOC_BS)) last_cluster_of_metadata=$(calc "ceil($metadata_pages / ${jq_out["cluster_size"]} / 4096)") - last_cluster_of_metadata=$(( last_cluster_of_metadata == 0 ? 1 : last_cluster_of_metadata )) - offset=$(( last_cluster_of_metadata * jq_out["cluster_size"] )) - size_metadata_end=$(( offset - offset_metadata_end )) + last_cluster_of_metadata=$((last_cluster_of_metadata == 0 ? 1 : last_cluster_of_metadata)) + offset=$((last_cluster_of_metadata * jq_out["cluster_size"])) + size_metadata_end=$((offset - offset_metadata_end)) # Check if data on area between end of metadata and first cluster of lvol bdev remained unchaged. run_fio_test "$nbd_name" "$offset_metadata_end" "$size_metadata_end" "read" 0xdd @@ -294,7 +294,7 @@ function test_construct_lvol() { [ "$(jq -r '.[0].uuid' <<< "$lvol")" = "$lvol_uuid" ] [ "$(jq -r '.[0].aliases[0]' <<< "$lvol")" = "lvs_test/lvol_test" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$MALLOC_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( LVS_DEFAULT_CAPACITY / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((LVS_DEFAULT_CAPACITY / MALLOC_BS))" ] [ "$(jq -r '.[0].driver_specific.lvol.lvol_store_uuid' <<< "$lvol")" = "$lvs_uuid" ] # clean up and create another lvol, this time use lvs alias instead of uuid @@ -307,7 +307,7 @@ function test_construct_lvol() { [ "$(jq -r '.[0].uuid' <<< "$lvol")" = "$lvol_uuid" ] [ "$(jq -r '.[0].aliases[0]' <<< "$lvol")" = "lvs_test/lvol_test" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$MALLOC_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( LVS_DEFAULT_CAPACITY / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((LVS_DEFAULT_CAPACITY / MALLOC_BS))" ] [ "$(jq -r '.[0].driver_specific.lvol.lvol_store_uuid' <<< "$lvol")" = "$lvs_uuid" ] # clean up @@ -326,10 +326,10 @@ function test_construct_multi_lvols() { lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test) # create 4 lvols - lvol_size_mb=$(( LVS_DEFAULT_CAPACITY_MB / 4 )) + lvol_size_mb=$((LVS_DEFAULT_CAPACITY_MB / 4)) # round down lvol size to the nearest cluster size boundary - lvol_size_mb=$(( lvol_size_mb / LVS_DEFAULT_CLUSTER_SIZE_MB * LVS_DEFAULT_CLUSTER_SIZE_MB )) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$((lvol_size_mb / LVS_DEFAULT_CLUSTER_SIZE_MB * LVS_DEFAULT_CLUSTER_SIZE_MB)) + lvol_size=$((lvol_size_mb * 1024 * 1024)) for i in $(seq 1 4); do lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" "lvol_test${i}" "$lvol_size_mb") lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") @@ -338,7 +338,7 @@ function test_construct_multi_lvols() { [ "$(jq -r '.[0].uuid' <<< "$lvol")" = "$lvol_uuid" ] [ "$(jq -r '.[0].aliases[0]' <<< "$lvol")" = "lvs_test/lvol_test${i}" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$MALLOC_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / MALLOC_BS))" ] done lvols=$(rpc_cmd bdev_get_bdevs | jq -r '[ .[] | select(.product_name == "Logical Volume") ]') @@ -361,7 +361,7 @@ function test_construct_multi_lvols() { [ "$(jq -r '.[0].uuid' <<< "$lvol")" = "$lvol_uuid" ] [ "$(jq -r '.[0].aliases[0]' <<< "$lvol")" = "lvs_test/lvol_test${i}" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$MALLOC_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / MALLOC_BS))" ] done lvols=$(rpc_cmd bdev_get_bdevs | jq -r '[ .[] | select(.product_name == "Logical Volume") ]') @@ -394,13 +394,13 @@ function test_construct_lvols_conflict_alias() { lvol1=$(rpc_cmd bdev_get_bdevs -b "$lvol1_uuid") # use a different size for second malloc to keep those differentiable - malloc2_size_mb=$(( MALLOC_SIZE_MB / 2 )) + malloc2_size_mb=$((MALLOC_SIZE_MB / 2)) # create an lvol store 2 malloc2_name=$(rpc_cmd bdev_malloc_create $malloc2_size_mb $MALLOC_BS) lvs2_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc2_name" lvs_test2) - lvol2_size_mb=$(round_down $(( LVS_DEFAULT_CAPACITY_MB / 2 )) ) + lvol2_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 2))) # create an lvol on lvs2 lvol2_uuid=$(rpc_cmd bdev_lvol_create -l lvs_test2 lvol_test "$lvol2_size_mb") @@ -474,7 +474,7 @@ function test_construct_lvol_alias_conflict() { lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test) # create valid lvol - lvol_size_mb=$(round_down $(( LVS_DEFAULT_CAPACITY_MB / 2 )) ) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 2))) lvol1_uuid=$(rpc_cmd bdev_lvol_create -l lvs_test lvol_test "$lvol_size_mb") lvol1=$(rpc_cmd bdev_get_bdevs -b "$lvol1_uuid") @@ -500,8 +500,8 @@ function test_construct_nested_lvol() { # create a nested lvs nested_lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$lvol_uuid" nested_lvs) - nested_lvol_size_mb=$(( LVS_DEFAULT_CAPACITY_MB - LVS_DEFAULT_CLUSTER_SIZE_MB )) - nested_lvol_size=$(( nested_lvol_size_mb * 1024 * 1024 )) + nested_lvol_size_mb=$((LVS_DEFAULT_CAPACITY_MB - LVS_DEFAULT_CLUSTER_SIZE_MB)) + nested_lvol_size=$((nested_lvol_size_mb * 1024 * 1024)) # create a nested lvol nested_lvol1_uuid=$(rpc_cmd bdev_lvol_create -u "$nested_lvs_uuid" nested_lvol1 "$nested_lvol_size_mb") @@ -511,7 +511,7 @@ function test_construct_nested_lvol() { [ "$(jq -r '.[0].uuid' <<< "$nested_lvol1")" = "$nested_lvol1_uuid" ] [ "$(jq -r '.[0].aliases[0]' <<< "$nested_lvol1")" = "nested_lvs/nested_lvol1" ] [ "$(jq -r '.[0].block_size' <<< "$nested_lvol1")" = "$MALLOC_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$nested_lvol1")" = "$(( nested_lvol_size / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$nested_lvol1")" = "$((nested_lvol_size / MALLOC_BS))" ] [ "$(jq -r '.[0].driver_specific.lvol.lvol_store_uuid' <<< "$nested_lvol1")" = "$nested_lvs_uuid" ] # try to create another nested lvol on a lvs that's already full diff --git a/test/lvol/common.sh b/test/lvol/common.sh index 695af9e5d5..b0fd119b3f 100644 --- a/test/lvol/common.sh +++ b/test/lvol/common.sh @@ -3,10 +3,10 @@ MALLOC_BS=512 AIO_SIZE_MB=400 AIO_BS=4096 LVS_DEFAULT_CLUSTER_SIZE_MB=4 -LVS_DEFAULT_CLUSTER_SIZE=$(( LVS_DEFAULT_CLUSTER_SIZE_MB * 1024 * 1024 )) +LVS_DEFAULT_CLUSTER_SIZE=$((LVS_DEFAULT_CLUSTER_SIZE_MB * 1024 * 1024)) # reserve some MBs for lvolstore metadata -LVS_DEFAULT_CAPACITY_MB=$(( MALLOC_SIZE_MB - LVS_DEFAULT_CLUSTER_SIZE_MB )) -LVS_DEFAULT_CAPACITY=$(( LVS_DEFAULT_CAPACITY_MB * 1024 * 1024 )) +LVS_DEFAULT_CAPACITY_MB=$((MALLOC_SIZE_MB - LVS_DEFAULT_CLUSTER_SIZE_MB)) +LVS_DEFAULT_CAPACITY=$((LVS_DEFAULT_CAPACITY_MB * 1024 * 1024)) function get_bdev_jq() { rpc_cmd_simple_data_json bdev "$@" @@ -28,7 +28,7 @@ function round_down() { if [ -n "$2" ]; then CLUSTER_SIZE_MB=$2 fi - echo $(( $1 / CLUSTER_SIZE_MB * CLUSTER_SIZE_MB )) + echo $(($1 / CLUSTER_SIZE_MB * CLUSTER_SIZE_MB)) } function run_fio_test() { diff --git a/test/lvol/hotremove.sh b/test/lvol/hotremove.sh index 381ca66e96..b451edaf2e 100755 --- a/test/lvol/hotremove.sh +++ b/test/lvol/hotremove.sh @@ -38,7 +38,7 @@ function test_hotremove_lvol_store_multiple_lvols() { lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test) # calculate lvol size - lvol_size_mb=$( round_down $(( (MALLOC_SIZE_MB- LVS_DEFAULT_CLUSTER_SIZE_MB) / 4 )) ) + lvol_size_mb=$(round_down $(((MALLOC_SIZE_MB - LVS_DEFAULT_CLUSTER_SIZE_MB) / 4))) # create 4 lvols for i in $(seq 1 4); do @@ -115,7 +115,7 @@ function test_bdev_lvol_delete_lvstore_with_clones() { [[ ${jq_out["name"]} == "$lvstore_name" ]] [[ ${jq_out["base_bdev"]} == "$malloc_dev" ]] - size=$(( jq_out["free_clusters"] * jq_out["cluster_size"] / 4 / 1024**2 )) + size=$((jq_out["free_clusters"] * jq_out["cluster_size"] / 4 / 1024 ** 2)) bdev_uuid=$(rpc_cmd bdev_lvol_create -u "$lvstore_uuid" "$lbd_name" "$size") @@ -169,7 +169,7 @@ function test_unregister_lvol_bdev() { [[ ${jq_out["name"]} == "$lvstore_name" ]] [[ ${jq_out["base_bdev"]} == "$malloc_dev" ]] - size=$(( jq_out["free_clusters"] * jq_out["cluster_size"] / 4 / 1024**2 )) + size=$((jq_out["free_clusters"] * jq_out["cluster_size"] / 4 / 1024 ** 2)) bdev_uuid=$(rpc_cmd bdev_lvol_create -u "$lvstore_uuid" "$lbd_name" "$size") diff --git a/test/lvol/rename.sh b/test/lvol/rename.sh index 7cf84f7202..84b1fba927 100755 --- a/test/lvol/rename.sh +++ b/test/lvol/rename.sh @@ -13,8 +13,8 @@ function test_rename_positive() { bdev_aliases=("lvs_test/lvol_test"{0..3}) # Calculate size and create two lvol bdevs on top - lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 4 )) ) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 4))) + lvol_size=$((lvol_size_mb * 1024 * 1024)) # Create 4 lvol bdevs on top of previously created lvol store bdev_uuids=() @@ -23,7 +23,7 @@ function test_rename_positive() { lvol=$(rpc_cmd bdev_get_bdevs -b $lvol_uuid) [ "$(jq -r '.[0].driver_specific.lvol.lvol_store_uuid' <<< "$lvol")" = "$lvs_uuid" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$MALLOC_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / MALLOC_BS))" ] [ "$(jq '.[0].aliases|sort' <<< "$lvol")" = "$(jq '.|sort' <<< '["'${bdev_aliases[i]}'"]')" ] bdev_uuids+=("$lvol_uuid") done @@ -46,13 +46,13 @@ function test_rename_positive() { cluster_size=$(jq -r '.[0].cluster_size' <<< "$lvs") [ "$cluster_size" = "$LVS_DEFAULT_CLUSTER_SIZE" ] total_clusters=$(jq -r '.[0].total_data_clusters' <<< "$lvs") - [ "$(( total_clusters * cluster_size ))" = "$LVS_DEFAULT_CAPACITY" ] + [ "$((total_clusters * cluster_size))" = "$LVS_DEFAULT_CAPACITY" ] for i in "${!bdev_uuids[@]}"; do lvol=$(rpc_cmd bdev_get_bdevs -b "${bdev_uuids[i]}") [ "$(jq -r '.[0].driver_specific.lvol.lvol_store_uuid' <<< "$lvol")" = "$lvs_uuid" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$MALLOC_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / MALLOC_BS))" ] [ "$(jq -r '.[0].aliases|sort' <<< "$lvol")" = "$(jq '.|sort' <<< '["'${bdev_aliases[i]}'"]')" ] done @@ -68,7 +68,7 @@ function test_rename_positive() { lvol=$(rpc_cmd bdev_get_bdevs -b "${bdev_uuids[i]}") [ "$(jq -r '.[0].driver_specific.lvol.lvol_store_uuid' <<< "$lvol")" = "$lvs_uuid" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$MALLOC_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / MALLOC_BS))" ] [ "$(jq -r '.[0].aliases|sort' <<< "$lvol")" = "$(jq '.|sort' <<< '["'${new_bdev_aliases[i]}'"]')" ] done @@ -104,8 +104,8 @@ function test_rename_lvs_negative() { bdev_aliases_2=("lvs_test2/lvol_test_2_"{0..3}) # Calculate size and create two lvol bdevs on top - lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 4 )) ) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 4))) + lvol_size=$((lvol_size_mb * 1024 * 1024)) # # Create 4 lvol bdevs on top of each lvol store bdev_uuids_1=() @@ -115,7 +115,7 @@ function test_rename_lvs_negative() { lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") [ "$(jq -r '.[0].driver_specific.lvol.lvol_store_uuid' <<< "$lvol")" = "$lvs_uuid1" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$MALLOC_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / MALLOC_BS))" ] [ "$(jq '.[0].aliases|sort' <<< "$lvol")" = "$(jq '.|sort' <<< '["'${bdev_aliases_1[i]}'"]')" ] bdev_uuids_1+=("$lvol_uuid") @@ -123,7 +123,7 @@ function test_rename_lvs_negative() { lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") [ "$(jq -r '.[0].driver_specific.lvol.lvol_store_uuid' <<< "$lvol")" = "$lvs_uuid2" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$MALLOC_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / MALLOC_BS))" ] [ "$(jq '.[0].aliases|sort' <<< "$lvol")" = "$(jq '.|sort' <<< '["'${bdev_aliases_2[i]}'"]')" ] bdev_uuids_2+=("$lvol_uuid") done @@ -148,13 +148,13 @@ function test_rename_lvs_negative() { lvol=$(rpc_cmd bdev_get_bdevs -b "${bdev_uuids_1[i]}") [ "$(jq -r '.[0].driver_specific.lvol.lvol_store_uuid' <<< "$lvol")" = "$lvs_uuid1" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$MALLOC_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / MALLOC_BS))" ] [ "$(jq '.[0].aliases|sort' <<< "$lvol")" = "$(jq '.|sort' <<< '["'${bdev_aliases_1[i]}'"]')" ] lvol=$(rpc_cmd bdev_get_bdevs -b "${bdev_uuids_2[i]}") [ "$(jq -r '.[0].driver_specific.lvol.lvol_store_uuid' <<< "$lvol")" = "$lvs_uuid2" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$MALLOC_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / MALLOC_BS))" ] [ "$(jq '.[0].aliases|sort' <<< "$lvol")" = "$(jq '.|sort' <<< '["'${bdev_aliases_2[i]}'"]')" ] done @@ -181,8 +181,8 @@ function test_lvol_rename_negative() { lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test) # Calculate lvol bdev size - lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 2 )) ) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 2))) + lvol_size=$((lvol_size_mb * 1024 * 1024)) # Create two lvol bdevs on top of previously created lvol store lvol_uuid1=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test1 "$lvol_size_mb") @@ -196,7 +196,7 @@ function test_lvol_rename_negative() { lvol=$(rpc_cmd bdev_get_bdevs -b $lvol_uuid1) [ "$(jq -r '.[0].driver_specific.lvol.lvol_store_uuid' <<< "$lvol")" = "$lvs_uuid" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$MALLOC_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / MALLOC_BS))" ] [ "$(jq -r '.[0].aliases|sort' <<< "$lvol")" = "$(jq '.|sort' <<< '["lvs_test/lvol_test1"]')" ] rpc_cmd bdev_lvol_delete lvs_test/lvol_test1 diff --git a/test/lvol/resize.sh b/test/lvol/resize.sh index ba9c9dc531..f65d26268f 100755 --- a/test/lvol/resize.sh +++ b/test/lvol/resize.sh @@ -13,8 +13,8 @@ function test_resize_lvol() { lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test) # calculate lvol size - lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 4 )) ) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 4))) + lvol_size=$((lvol_size_mb * 1024 * 1024)) # create an lvol on top lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test "$lvol_size_mb") @@ -23,28 +23,28 @@ function test_resize_lvol() { [ "$(jq -r '.[0].uuid' <<< "$lvol")" = "$lvol_uuid" ] [ "$(jq -r '.[0].aliases[0]' <<< "$lvol")" = "lvs_test/lvol_test" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$MALLOC_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / MALLOC_BS))" ] # resize the lvol to twice its original size - lvol_size_mb=$(( lvol_size_mb * 2 )) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$((lvol_size_mb * 2)) + lvol_size=$((lvol_size_mb * 1024 * 1024)) rpc_cmd bdev_lvol_resize "$lvol_uuid" "$lvol_size_mb" lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / MALLOC_BS))" ] # resize the lvol to four times its original size, use its name instead of uuid - lvol_size_mb=$(( lvol_size_mb * 2 )) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$((lvol_size_mb * 2)) + lvol_size=$((lvol_size_mb * 1024 * 1024)) rpc_cmd bdev_lvol_resize lvs_test/lvol_test "$lvol_size_mb" lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / MALLOC_BS))" ] # resize the lvol to 0 using lvol bdev alias lvol_size_mb=0 lvol_size=0 rpc_cmd bdev_lvol_resize "lvs_test/lvol_test" "$lvol_size_mb" lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / MALLOC_BS))" ] # clean up rpc_cmd bdev_lvol_delete "$lvol_uuid" @@ -70,13 +70,13 @@ function test_resize_lvol_negative() { rpc_cmd bdev_lvol_resize "$dummy_uuid" 0 && false # just make sure the size of the real lvol did not change lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( LVS_DEFAULT_CAPACITY / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((LVS_DEFAULT_CAPACITY / MALLOC_BS))" ] # try to resize an lvol to a size bigger than lvs rpc_cmd bdev_lvol_resize "$lvol_uuid" "$MALLOC_SIZE_MB" && false # just make sure the size of the real lvol did not change lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( LVS_DEFAULT_CAPACITY / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((LVS_DEFAULT_CAPACITY / MALLOC_BS))" ] # clean up rpc_cmd bdev_lvol_delete "$lvol_uuid" @@ -93,8 +93,8 @@ function test_resize_lvol_with_io_traffic() { lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test) # calculate lvol size - lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 2 )) ) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 2))) + lvol_size=$((lvol_size_mb * 1024 * 1024)) # create an lvol on top lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test "$lvol_size_mb") @@ -103,26 +103,26 @@ function test_resize_lvol_with_io_traffic() { [ "$(jq -r '.[0].uuid' <<< "$lvol")" = "$lvol_uuid" ] [ "$(jq -r '.[0].aliases[0]' <<< "$lvol")" = "lvs_test/lvol_test" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$MALLOC_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / MALLOC_BS))" ] # prepare to do some I/O trap 'nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0; exit 1' SIGINT SIGTERM EXIT nbd_start_disks "$DEFAULT_RPC_ADDR" "$lvol_uuid" /dev/nbd0 # write to the entire lvol - count=$(( lvol_size / LVS_DEFAULT_CLUSTER_SIZE )) + count=$((lvol_size / LVS_DEFAULT_CLUSTER_SIZE)) dd if=/dev/urandom of=/dev/nbd0 oflag=direct bs="$LVS_DEFAULT_CLUSTER_SIZE" count=$count # writing beyond lvol size should fail - offset=$(( lvol_size / LVS_DEFAULT_CLUSTER_SIZE + 1 )) + offset=$((lvol_size / LVS_DEFAULT_CLUSTER_SIZE + 1)) dd if=/dev/urandom of=/dev/nbd0 oflag=direct bs="$LVS_DEFAULT_CLUSTER_SIZE" seek=$offset count=1 && false # resize the lvol to twice its original size - lvol_size_mb=$(( lvol_size_mb * 2 )) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$((lvol_size_mb * 2)) + lvol_size=$((lvol_size_mb * 1024 * 1024)) rpc_cmd bdev_lvol_resize "$lvol_uuid" "$lvol_size_mb" lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / MALLOC_BS))" ] # writing beyond the original lvol size should now succeed, we need # to restart NBD though as it may still use the old, cached size @@ -137,7 +137,7 @@ function test_resize_lvol_with_io_traffic() { # resize lvol down to a single cluster rpc_cmd bdev_lvol_resize "$lvol_uuid" "$LVS_DEFAULT_CLUSTER_SIZE_MB" lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( LVS_DEFAULT_CLUSTER_SIZE / MALLOC_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((LVS_DEFAULT_CLUSTER_SIZE / MALLOC_BS))" ] # make sure we can't write beyond the first cluster trap 'nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0; exit 1' SIGINT SIGTERM EXIT @@ -168,7 +168,7 @@ function test_destroy_after_bdev_lvol_resize_positive() { [[ ${jq_out["uuid"]} == "$lvstore_uuid" ]] [[ ${jq_out["name"]} == "$lvstore_name" ]] - bdev_size=$(round_down $(( LVS_DEFAULT_CAPACITY_MB / 4 ))) + bdev_size=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 4))) bdev_uuid=$(rpc_cmd bdev_lvol_create -u "$lvstore_uuid" "$lbd_name" "$bdev_size") # start resizing in the following fashion: @@ -179,20 +179,20 @@ function test_destroy_after_bdev_lvol_resize_positive() { # - size is equal 0 MiB local resize for resize in \ - "$bdev_size" \ - $(( bdev_size + 4 )) \ - $(( bdev_size * 2 )) \ - $(( bdev_size * 3 )) \ - $(( bdev_size * 4 - 4 )) \ - 0; do - resize=$(round_down $(( resize / 4 ))) + "$bdev_size" \ + $((bdev_size + 4)) \ + $((bdev_size * 2)) \ + $((bdev_size * 3)) \ + $((bdev_size * 4 - 4)) \ + 0; do + resize=$(round_down $((resize / 4))) rpc_cmd bdev_lvol_resize "$bdev_uuid" "$resize" get_bdev_jq bdev_get_bdevs -b "$bdev_uuid" [[ ${jq_out["name"]} == "$bdev_uuid" ]] [[ ${jq_out["name"]} == "${jq_out["uuid"]}" ]] - (( jq_out["block_size"] == MALLOC_BS )) - (( jq_out["num_blocks"] * jq_out["block_size"] == resize * 1024**2 )) + ((jq_out["block_size"] == MALLOC_BS)) + ((jq_out["num_blocks"] * jq_out["block_size"] == resize * 1024 ** 2)) done # cleanup diff --git a/test/lvol/snapshot_clone.sh b/test/lvol/snapshot_clone.sh index 68df834b91..e13af71ed1 100755 --- a/test/lvol/snapshot_clone.sh +++ b/test/lvol/snapshot_clone.sh @@ -11,20 +11,20 @@ function test_snapshot_compare_with_lvol_bdev() { lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test) # Create two lvol bdevs - lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 6 )) ) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 6))) + lvol_size=$((lvol_size_mb * 1024 * 1024)) lvol_uuid1=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test1 "$lvol_size_mb" -t) lvol_uuid2=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test2 "$lvol_size_mb") # Fill thin provisoned lvol bdev with 50% of its space nbd_start_disks "$DEFAULT_RPC_ADDR" "$lvol_uuid1" /dev/nbd0 - count=$(( lvol_size / LVS_DEFAULT_CLUSTER_SIZE / 2 )) + count=$((lvol_size / LVS_DEFAULT_CLUSTER_SIZE / 2)) dd if=/dev/urandom of=/dev/nbd0 oflag=direct bs="$LVS_DEFAULT_CLUSTER_SIZE" count=$count nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0 # Fill whole thick provisioned lvol bdev nbd_start_disks "$DEFAULT_RPC_ADDR" "$lvol_uuid2" /dev/nbd0 - count=$(( lvol_size / LVS_DEFAULT_CLUSTER_SIZE )) + count=$((lvol_size / LVS_DEFAULT_CLUSTER_SIZE)) dd if=/dev/urandom of=/dev/nbd0 oflag=direct bs="$LVS_DEFAULT_CLUSTER_SIZE" count=$count nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0 @@ -35,7 +35,7 @@ function test_snapshot_compare_with_lvol_bdev() { nbd_start_disks "$DEFAULT_RPC_ADDR" "$snapshot_uuid1" /dev/nbd0 # Try to perform write operation on created snapshot # Check if filling snapshot of lvol bdev fails - count=$(( lvol_size / LVS_DEFAULT_CLUSTER_SIZE )) + count=$((lvol_size / LVS_DEFAULT_CLUSTER_SIZE)) dd if=/dev/urandom of=/dev/nbd0 oflag=direct bs="$LVS_DEFAULT_CLUSTER_SIZE" count=$count && false nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0 @@ -52,7 +52,7 @@ function test_snapshot_compare_with_lvol_bdev() { cmp "$lvol_nbd2" "$snapshot_nbd2" # Fill second half of thin provisioned lvol bdev - count=$(( lvol_size / LVS_DEFAULT_CLUSTER_SIZE / 2 )) + count=$((lvol_size / LVS_DEFAULT_CLUSTER_SIZE / 2)) dd if=/dev/urandom of="$lvol_nbd1" oflag=direct seek=$count bs="$LVS_DEFAULT_CLUSTER_SIZE" count=$count # Compare thin provisioned lvol bdev with its snapshot and check if it fails @@ -77,7 +77,6 @@ function test_snapshot_compare_with_lvol_bdev() { check_leftover_devices } - # Check that when writing to lvol bdev # creating snapshot ends with success function test_create_snapshot_with_io() { @@ -85,8 +84,8 @@ function test_create_snapshot_with_io() { lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test) # Create lvol bdev - lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 2 )) ) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 2))) + lvol_size=$((lvol_size_mb * 1024 * 1024)) lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test "$lvol_size_mb" -t) @@ -111,14 +110,13 @@ function test_create_snapshot_with_io() { check_leftover_devices } - # Check that creating snapshot of snapshot will fail function test_create_snapshot_of_snapshot() { malloc_name=$(rpc_cmd bdev_malloc_create $MALLOC_SIZE_MB $MALLOC_BS) lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test) # Create lvol bdev - lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 3 )) ) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 3))) lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test "$lvol_size_mb") lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") @@ -149,8 +147,8 @@ function test_clone_snapshot_relations() { lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test) # Calculate size and create lvol bdev - lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 6 )) ) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 6))) + lvol_size=$((lvol_size_mb * 1024 * 1024)) lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test "$lvol_size_mb") lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") @@ -176,7 +174,7 @@ function test_clone_snapshot_relations() { # Perform write operation to first clone # Change first half of its space nbd_start_disks "$DEFAULT_RPC_ADDR" "$clone_uuid1" /dev/nbd0 - fill_size=$(( lvol_size / 2 )) + fill_size=$((lvol_size / 2)) run_fio_test /dev/nbd0 0 $fill_size "write" "0xaa" # Compare snapshot with second clone. Data on both bdevs should be the same @@ -229,14 +227,14 @@ function test_clone_inflate() { lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test) # Calculate size and create lvol bdev - lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 4 )) ) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 4))) lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test "$lvol_size_mb") lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") # Fill lvol bdev with 100% of its space nbd_start_disks "$DEFAULT_RPC_ADDR" "$lvol_uuid" /dev/nbd0 - run_fio_test /dev/nbd0 0 $(( lvol_size_mb * 1024 * 1024 )) "write" "0xcc" + run_fio_test /dev/nbd0 0 $((lvol_size_mb * 1024 * 1024)) "write" "0xcc" nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0 # Create snapshots of lvol bdev @@ -249,9 +247,9 @@ function test_clone_inflate() { # Fill part of clone with data of known pattern nbd_start_disks "$DEFAULT_RPC_ADDR" "$lvol_uuid" /dev/nbd0 first_fill=0 - second_fill=$(( lvol_size_mb * 1024 * 1024 * 3 / 4 )) - run_fio_test /dev/nbd0 $first_fill $(( 1024 * 1024 )) "write" "0xdd" - run_fio_test /dev/nbd0 $second_fill $(( 1024 * 1024 )) "write" "0xdd" + second_fill=$((lvol_size_mb * 1024 * 1024 * 3 / 4)) + run_fio_test /dev/nbd0 $first_fill $((1024 * 1024)) "write" "0xdd" + run_fio_test /dev/nbd0 $second_fill $((1024 * 1024)) "write" "0xdd" nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0 # Do inflate @@ -264,10 +262,10 @@ function test_clone_inflate() { # Check data consistency nbd_start_disks "$DEFAULT_RPC_ADDR" "$lvol_uuid" /dev/nbd0 - run_fio_test /dev/nbd0 $first_fill $(( 1024 * 1024 )) "read" "0xdd" - run_fio_test /dev/nbd0 $(( (first_fill + 1) * 1024 * 1024 )) $(( second_fill - 1024 * 1024 )) "read" "0xcc" - run_fio_test /dev/nbd0 $second_fill $(( 1024 * 1024 )) "read" "0xdd" - run_fio_test /dev/nbd0 $(( second_fill + 1024 * 1024 )) $(( lvol_size_mb * 1024 * 1024 - ( second_fill + 1024 * 1024 ) )) "read" "0xcc" + run_fio_test /dev/nbd0 $first_fill $((1024 * 1024)) "read" "0xdd" + run_fio_test /dev/nbd0 $(((first_fill + 1) * 1024 * 1024)) $((second_fill - 1024 * 1024)) "read" "0xcc" + run_fio_test /dev/nbd0 $second_fill $((1024 * 1024)) "read" "0xdd" + run_fio_test /dev/nbd0 $((second_fill + 1024 * 1024)) $((lvol_size_mb * 1024 * 1024 - (second_fill + 1024 * 1024))) "read" "0xcc" nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0 # Clean up @@ -285,7 +283,7 @@ function test_clone_decouple_parent() { lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test) # Calculate size and create lvol bdev - lvol_size_mb=$(( 5 * LVS_DEFAULT_CLUSTER_SIZE_MB )) + lvol_size_mb=$((5 * LVS_DEFAULT_CLUSTER_SIZE_MB)) lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test "$lvol_size_mb" -t) lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") @@ -295,17 +293,17 @@ function test_clone_decouple_parent() { # Fill first four out of 5 clusters of clone with data of known pattern nbd_start_disks "$DEFAULT_RPC_ADDR" "$lvol_uuid" /dev/nbd0 begin_fill=0 - end_fill=$(( lvol_size_mb * 4 * 1024 * 1024 / 5 )) + end_fill=$((lvol_size_mb * 4 * 1024 * 1024 / 5)) run_fio_test /dev/nbd0 $begin_fill $end_fill "write" "0xdd" # Create snapshot (snapshot<-lvol_bdev) snapshot_uuid=$(rpc_cmd bdev_lvol_snapshot lvs_test/lvol_test lvol_snapshot) # Fill second and fourth cluster of clone with data of known pattern - start_fill=$(( lvol_size_mb * 1024 * 1024 / 5 )) + start_fill=$((lvol_size_mb * 1024 * 1024 / 5)) fill_range=$start_fill run_fio_test /dev/nbd0 $start_fill $fill_range "write" "0xcc" - start_fill=$(( lvol_size_mb * 3 * 1024 * 1024 / 5 )) + start_fill=$((lvol_size_mb * 3 * 1024 * 1024 / 5)) run_fio_test /dev/nbd0 $start_fill $fill_range "write" "0xcc" # Create snapshot (snapshot<-snapshot2<-lvol_bdev) @@ -316,9 +314,9 @@ function test_clone_decouple_parent() { run_fio_test /dev/nbd0 $start_fill $fill_range "write" "0xee" # Check data consistency - pattern=( "0xdd" "0xee" "0xdd" "0xcc" "0x00" ) + pattern=("0xdd" "0xee" "0xdd" "0xcc" "0x00") for i in "${!pattern[@]}"; do - start_fill=$(( lvol_size_mb * i * 1024 * 1024 / 5 )) + start_fill=$((lvol_size_mb * i * 1024 * 1024 / 5)) run_fio_test /dev/nbd0 $start_fill $fill_range "read" "${pattern[i]}" done @@ -341,7 +339,7 @@ function test_clone_decouple_parent() { # Check data consistency for i in "${!pattern[@]}"; do - start_fill=$(( lvol_size_mb * i * 1024 * 1024 / 5 )) + start_fill=$((lvol_size_mb * i * 1024 * 1024 / 5)) run_fio_test /dev/nbd0 $start_fill $fill_range "read" "${pattern[i]}" done @@ -361,7 +359,7 @@ function test_clone_decouple_parent() { # Check data consistency for i in "${!pattern[@]}"; do - start_fill=$(( lvol_size_mb * i * 1024 * 1024 / 5 )) + start_fill=$((lvol_size_mb * i * 1024 * 1024 / 5)) run_fio_test /dev/nbd0 $start_fill $fill_range "read" "${pattern[i]}" done @@ -378,7 +376,7 @@ function test_lvol_bdev_readonly() { lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test) # Calculate size and create lvol bdev - lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 2 )) ) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 2))) lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test "$lvol_size_mb") lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") @@ -413,8 +411,8 @@ function test_delete_snapshot_with_clone() { lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test) # Calculate size and create lvol bdev - lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 2 )) ) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 2))) + lvol_size=$((lvol_size_mb * 1024 * 1024)) lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test "$lvol_size_mb") lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") @@ -427,7 +425,7 @@ function test_delete_snapshot_with_clone() { snapshot_uuid=$(rpc_cmd bdev_lvol_snapshot lvs_test/lvol_test lvol_snapshot) # Fill first half of lvol bdev - half_size=$(( lvol_size / 2 - 1 )) + half_size=$((lvol_size / 2 - 1)) run_fio_test /dev/nbd0 0 $half_size "write" "0xee" # Check if snapshot was unchanged @@ -447,7 +445,7 @@ function test_delete_snapshot_with_clone() { lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") [ "$(jq '.[].driver_specific.lvol.clone' <<< "$lvol")" = "false" ] run_fio_test /dev/nbd0 0 $half_size "read" "0xee" - run_fio_test /dev/nbd0 $(( half_size + 1 )) $half_size "read" "0xcc" + run_fio_test /dev/nbd0 $((half_size + 1)) $half_size "read" "0xcc" # Clean up nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0 @@ -463,8 +461,8 @@ function test_delete_snapshot_with_snapshot() { lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test) # Calculate size and create lvol bdev - lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 5 )) ) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 5))) + lvol_size=$((lvol_size_mb * 1024 * 1024)) lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test "$lvol_size_mb") lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") @@ -479,9 +477,9 @@ function test_delete_snapshot_with_snapshot() { [ "$(jq '.[].driver_specific.lvol.base_snapshot' <<< "$lvol")" = '"lvol_snapshot"' ] # Fill second 1/3 of lvol bdev - first_part=$(( lvol_size / 3 )) - second_part=$(( lvol_size * 2 / 3 )) - run_fio_test /dev/nbd0 $first_part $(( second_part - first_part )) "write" "0xee" + first_part=$((lvol_size / 3)) + second_part=$((lvol_size * 2 / 3)) + run_fio_test /dev/nbd0 $first_part $((second_part - first_part)) "write" "0xee" # Check if snapshot was unchanged nbd_start_disks "$DEFAULT_RPC_ADDR" "$snapshot_uuid" /dev/nbd1 @@ -502,22 +500,22 @@ function test_delete_snapshot_with_snapshot() { # Verify snapshots run_fio_test /dev/nbd1 0 $size "read" "0xcc" nbd_start_disks "$DEFAULT_RPC_ADDR" "$snapshot_uuid2" /dev/nbd2 - run_fio_test /dev/nbd2 0 $(( first_part - 1 )) "read" "0xcc" - run_fio_test /dev/nbd2 $first_part $(( second_part - first_part )) "read" "0xee" - run_fio_test /dev/nbd2 $second_part $(( lvol_size - second_part )) "read" "0xcc" + run_fio_test /dev/nbd2 0 $((first_part - 1)) "read" "0xcc" + run_fio_test /dev/nbd2 $first_part $((second_part - first_part)) "read" "0xee" + run_fio_test /dev/nbd2 $second_part $((lvol_size - second_part)) "read" "0xcc" # Verify lvol bdev - run_fio_test /dev/nbd0 $first_part $(( second_part - first_part )) "read" "0xee" - run_fio_test /dev/nbd0 $second_part $(( lvol_size - second_part )) "read" "0xcc" + run_fio_test /dev/nbd0 $first_part $((second_part - first_part)) "read" "0xee" + run_fio_test /dev/nbd0 $second_part $((lvol_size - second_part)) "read" "0xcc" [ "$(jq '.[].driver_specific.lvol.clone' <<< "$lvol")" = "true" ] [ "$(jq '.[].driver_specific.lvol.base_snapshot' <<< "$lvol")" = '"lvol_snapshot2"' ] # Fill third part of lvol bdev - run_fio_test /dev/nbd0 $second_part $(( lvol_size - second_part )) "write" "0xdd" + run_fio_test /dev/nbd0 $second_part $((lvol_size - second_part)) "write" "0xdd" # Verify snapshots run_fio_test /dev/nbd1 0 $size "read" "0xcc" - run_fio_test /dev/nbd0 $second_part $(( lvol_size - second_part )) "read" "0xdd" + run_fio_test /dev/nbd0 $second_part $((lvol_size - second_part)) "read" "0xdd" nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd2 nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd1 @@ -530,8 +528,8 @@ function test_delete_snapshot_with_snapshot() { [ "$(jq '.[].driver_specific.lvol.clone' <<< "$lvol")" = "true" ] [ "$(jq '.[].driver_specific.lvol.base_snapshot' <<< "$lvol")" = '"lvol_snapshot"' ] [ "$(jq '.[].driver_specific.lvol.clones|sort' <<< "$snapshot")" = "$(jq '.|sort' <<< '["lvol_test"]')" ] - run_fio_test /dev/nbd0 $first_part $(( second_part - first_part )) "read" "0xee" - run_fio_test /dev/nbd0 $second_part $(( lvol_size - second_part )) "read" "0xdd" + run_fio_test /dev/nbd0 $first_part $((second_part - first_part)) "read" "0xee" + run_fio_test /dev/nbd0 $second_part $((lvol_size - second_part)) "read" "0xdd" # Clean up nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0 @@ -561,7 +559,7 @@ function test_bdev_lvol_delete_ordering() { [[ ${jq_out["name"]} == "$lvstore_name" ]] [[ ${jq_out["base_bdev"]} == "$malloc_dev" ]] - size=$(( jq_out["free_clusters"] * jq_out["cluster_size"] / 4 / 1024**2 )) + size=$((jq_out["free_clusters"] * jq_out["cluster_size"] / 4 / 1024 ** 2)) bdev_uuid=$(rpc_cmd bdev_lvol_create -t -u "$lvstore_uuid" "$lbd_name" "$size") diff --git a/test/lvol/tasting.sh b/test/lvol/tasting.sh index 5557cf0088..606a6c49d1 100755 --- a/test/lvol/tasting.sh +++ b/test/lvol/tasting.sh @@ -24,14 +24,14 @@ function test_tasting() { rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid" && false # Create a valid lvs - lvs1_cluster_size=$(( 1 * 1024 * 1024 )) - lvs2_cluster_size=$(( 32 * 1024 * 1024 )) + lvs1_cluster_size=$((1 * 1024 * 1024)) + lvs2_cluster_size=$((32 * 1024 * 1024)) lvs_uuid1=$(rpc_cmd bdev_lvol_create_lvstore aio_bdev0 lvs_test1 -c $lvs1_cluster_size) lvs_uuid2=$(rpc_cmd bdev_lvol_create_lvstore aio_bdev1 lvs_test2 -c $lvs2_cluster_size) # Create 5 lvols on first lvs - lvol_size_mb=$(round_down $(( LVS_DEFAULT_CAPACITY_MB / 10 ))) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 10))) + lvol_size=$((lvol_size_mb * 1024 * 1024)) for i in $(seq 1 5); do lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid1" "lvol_test${i}" "$lvol_size_mb") @@ -41,12 +41,12 @@ function test_tasting() { [ "$(jq -r '.[0].uuid' <<< "$lvol")" = "$lvol_uuid" ] [ "$(jq -r '.[0].aliases[0]' <<< "$lvol")" = "lvs_test1/lvol_test${i}" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$AIO_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / AIO_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / AIO_BS))" ] done # Create 5 lvols on second lvs - lvol2_size_mb=$(round_down $(( ( AIO_SIZE_MB - 16 ) / 5 )) 32) - lvol2_size=$(( lvol2_size_mb * 1024 * 1024 )) + lvol2_size_mb=$(round_down $(((AIO_SIZE_MB - 16) / 5)) 32) + lvol2_size=$((lvol2_size_mb * 1024 * 1024)) for i in $(seq 1 5); do lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid2" "lvol_test${i}" "$lvol2_size_mb") @@ -56,7 +56,7 @@ function test_tasting() { [ "$(jq -r '.[0].uuid' <<< "$lvol")" = "$lvol_uuid" ] [ "$(jq -r '.[0].aliases[0]' <<< "$lvol")" = "lvs_test2/lvol_test${i}" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$AIO_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol2_size / AIO_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol2_size / AIO_BS))" ] done old_lvols=$(rpc_cmd bdev_get_bdevs | jq -r '[ .[] | select(.product_name == "Logical Volume") ]') @@ -78,11 +78,11 @@ function test_tasting() { new_lvols=$(rpc_cmd bdev_get_bdevs | jq -r '[ .[] | select(.product_name == "Logical Volume") ]') [ "$(jq length <<< "$new_lvols")" == "10" ] new_lvs=$(rpc_cmd bdev_lvol_get_lvstores | jq .) - if ! diff <(jq '. | sort' <<<"$old_lvs") <(jq '. | sort' <<<"$new_lvs"); then + if ! diff <(jq '. | sort' <<< "$old_lvs") <(jq '. | sort' <<< "$new_lvs"); then echo "ERROR: old and loaded lvol store is not the same" return 1 fi - if ! diff <(jq '. | sort' <<<"$old_lvols") <(jq '. | sort' <<<"$new_lvols"); then + if ! diff <(jq '. | sort' <<< "$old_lvols") <(jq '. | sort' <<< "$new_lvols"); then echo "ERROR: old and loaded lvols are not the same" return 1 fi @@ -96,7 +96,7 @@ function test_tasting() { [ "$(jq -r '.[0].uuid' <<< "$lvol")" = "$lvol_uuid" ] [ "$(jq -r '.[0].aliases[0]' <<< "$lvol")" = "lvs_test1/lvol_test${i}" ] [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$AIO_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / AIO_BS ))" ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$((lvol_size / AIO_BS))" ] done for i in $(seq 1 10); do @@ -132,7 +132,7 @@ function test_delete_lvol_store_persistent_positive() { get_bdev_jq bdev_get_bdevs -b "$bdev_aio_name" [[ ${jq_out["name"]} == "$bdev_aio_name" ]] [[ ${jq_out["product_name"]} == "AIO disk" ]] - (( jq_out["block_size"] == bdev_block_size )) + ((jq_out["block_size"] == bdev_block_size)) lvstore_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$bdev_aio_name" "$lvstore_name") diff --git a/test/lvol/thin_provisioning.sh b/test/lvol/thin_provisioning.sh index 890f000021..3e99e5e151 100755 --- a/test/lvol/thin_provisioning.sh +++ b/test/lvol/thin_provisioning.sh @@ -15,7 +15,7 @@ function test_thin_lvol_check_space() { free_clusters_start="$(jq -r '.[0].free_clusters' <<< "$lvs")" # Create thin provision lvol bdev with size equals to lvol store space - lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB )) ) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB))) lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test "$lvol_size_mb" -t) lvs=$(rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid") @@ -28,31 +28,31 @@ function test_thin_lvol_check_space() { run_fio_test /dev/nbd0 0 $size "write" "0xcc" lvs=$(rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid") free_clusters_first_fio="$(jq -r '.[0].free_clusters' <<< "$lvs")" - [ $(( free_clusters_first_fio + 1 )) == $free_clusters_start ] + [ $((free_clusters_first_fio + 1)) == $free_clusters_start ] # Write data (lvs cluster size) to lvol bdev with offset set to one and half of cluster size - offset=$(( LVS_DEFAULT_CLUSTER_SIZE * 3 / 2 )) + offset=$((LVS_DEFAULT_CLUSTER_SIZE * 3 / 2)) size=$LVS_DEFAULT_CLUSTER_SIZE run_fio_test /dev/nbd0 $offset $size "write" "0xcc" lvs=$(rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid") free_clusters_second_fio="$(jq -r '.[0].free_clusters' <<< "$lvs")" - [ $(( free_clusters_second_fio + 3 )) == $free_clusters_start ] + [ $((free_clusters_second_fio + 3)) == $free_clusters_start ] # write data to lvol bdev to the end of its size - size=$(( LVS_DEFAULT_CLUSTER_SIZE * free_clusters_first_fio )) - offset=$(( 3 * LVS_DEFAULT_CLUSTER_SIZE )) + size=$((LVS_DEFAULT_CLUSTER_SIZE * free_clusters_first_fio)) + offset=$((3 * LVS_DEFAULT_CLUSTER_SIZE)) run_fio_test /dev/nbd0 $offset $size "write" "0xcc" lvs=$(rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid") # Check that lvol store free clusters number equals to 0 free_clusters_third_fio="$(jq -r '.[0].free_clusters' <<< "$lvs")" - [ $(( free_clusters_third_fio )) == 0 ] + [ $((free_clusters_third_fio)) == 0 ] nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0 rpc_cmd bdev_lvol_delete "$lvol_uuid" rpc_cmd bdev_get_bdevs -b "$lvol_uuid" && false lvs=$(rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid") free_clusters_end="$(jq -r '.[0].free_clusters' <<< "$lvs")" - [ $(( free_clusters_end )) == $free_clusters_start ] + [ $((free_clusters_end)) == $free_clusters_start ] # Clean up rpc_cmd bdev_lvol_delete_lvstore -u "$lvs_uuid" @@ -71,10 +71,10 @@ function test_thin_lvol_check_zeroes() { # Create thick and thin provisioned lvol bdevs with size equals to lvol store space lbd_name0=lvol_test0 lbd_name1=lvol_test1 - lvol_size_mb=$(( LVS_DEFAULT_CAPACITY_MB )) + lvol_size_mb=$((LVS_DEFAULT_CAPACITY_MB)) # Round down lvol size to the nearest cluster size boundary - lvol_size_mb=$(( lvol_size_mb / LVS_DEFAULT_CLUSTER_SIZE_MB * LVS_DEFAULT_CLUSTER_SIZE_MB )) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$((lvol_size_mb / LVS_DEFAULT_CLUSTER_SIZE_MB * LVS_DEFAULT_CLUSTER_SIZE_MB)) + lvol_size=$((lvol_size_mb * 1024 * 1024)) lvol_uuid0=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" $lbd_name0 "$lvol_size_mb") lvol_uuid1=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" $lbd_name1 "$lvol_size_mb" -t) @@ -104,10 +104,10 @@ function test_thin_lvol_check_integrity() { lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test) # Create thin provisioned lvol bdev with size equals to lvol store space - lvol_size_mb=$(( LVS_DEFAULT_CAPACITY_MB )) + lvol_size_mb=$((LVS_DEFAULT_CAPACITY_MB)) # Round down lvol size to the nearest cluster size boundary - lvol_size_mb=$(( lvol_size_mb / LVS_DEFAULT_CLUSTER_SIZE_MB * LVS_DEFAULT_CLUSTER_SIZE_MB )) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$((lvol_size_mb / LVS_DEFAULT_CLUSTER_SIZE_MB * LVS_DEFAULT_CLUSTER_SIZE_MB)) + lvol_size=$((lvol_size_mb * 1024 * 1024)) lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test "$lvol_size_mb" -t) nbd_start_disks "$DEFAULT_RPC_ADDR" "$lvol_uuid" /dev/nbd0 @@ -127,8 +127,8 @@ function test_thin_lvol_resize() { # Construct thin provisioned lvol bdevs on created lvol store # with size equal to 50% of lvol store - lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 2 )) ) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 2))) + lvol_size=$((lvol_size_mb * 1024 * 1024)) lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test "$lvol_size_mb" -t) # Fill all free space of lvol bdev with data @@ -140,15 +140,15 @@ function test_thin_lvol_resize() { lvs=$(rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid") free_clusters_start="$(jq -r '.[0].free_clusters' <<< "$lvs")" # Resize bdev to full size of lvs - lvol_size_full_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB )) ) - lvol_size_full=$(( lvol_size_full_mb * 1024 * 1024 )) + lvol_size_full_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB))) + lvol_size_full=$((lvol_size_full_mb * 1024 * 1024)) rpc_cmd bdev_lvol_resize $lvol_uuid $lvol_size_full_mb # Check if bdev size changed (total_data_clusters*cluster_size # equals to num_blocks*block_size) lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid") [ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$MALLOC_BS" ] - [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = $(( lvol_size_full / MALLOC_BS )) ] + [ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = $((lvol_size_full / MALLOC_BS)) ] # Check if free_clusters on lvs remain unaffected lvs=$(rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid") @@ -167,13 +167,13 @@ function test_thin_lvol_resize() { [ $free_clusters_start == 0 ] # Resize bdev to 25% of lvs and check if it ended with success - lvol_size_quarter_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 4 )) ) + lvol_size_quarter_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB / 4))) rpc_cmd bdev_lvol_resize $lvol_uuid $lvol_size_quarter_mb # Check free clusters on lvs lvs=$(rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid") free_clusters_resize_quarter="$(jq -r '.[0].free_clusters' <<< "$lvs")" - free_clusters_expected=$(( (lvol_size_full_mb - lvol_size_quarter_mb) / LVS_DEFAULT_CLUSTER_SIZE_MB )) + free_clusters_expected=$(((lvol_size_full_mb - lvol_size_quarter_mb) / LVS_DEFAULT_CLUSTER_SIZE_MB)) [ $free_clusters_resize_quarter == $free_clusters_expected ] rpc_cmd bdev_lvol_delete "$lvol_uuid" @@ -187,16 +187,16 @@ function test_thin_overprovisioning() { # Construct two thin provisioned lvol bdevs on created lvol store # with size equal to free lvol store size - lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB )) ) - lvol_size=$(( lvol_size_mb * 1024 * 1024 )) + lvol_size_mb=$(round_down $((LVS_DEFAULT_CAPACITY_MB))) + lvol_size=$((lvol_size_mb * 1024 * 1024)) lvol_uuid1=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test1 "$lvol_size_mb" -t) lvol_uuid2=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test2 "$lvol_size_mb" -t) nbd_start_disks "$DEFAULT_RPC_ADDR" "$lvol_uuid1" /dev/nbd0 nbd_start_disks "$DEFAULT_RPC_ADDR" "$lvol_uuid2" /dev/nbd1 # Fill first bdev to 50% of its space with specific pattern - fill_size=$(( lvol_size_mb * 5 / 10 / LVS_DEFAULT_CLUSTER_SIZE_MB * LVS_DEFAULT_CLUSTER_SIZE_MB )) - fill_size=$(( fill_size * 1024 * 1024)) + fill_size=$((lvol_size_mb * 5 / 10 / LVS_DEFAULT_CLUSTER_SIZE_MB * LVS_DEFAULT_CLUSTER_SIZE_MB)) + fill_size=$((fill_size * 1024 * 1024)) run_fio_test /dev/nbd0 0 $fill_size "write" "0xcc" # Fill second bdev up to 50% of its space @@ -205,7 +205,7 @@ function test_thin_overprovisioning() { # Fill rest of second bdev # Check that error message occured while filling second bdev with data offset=$fill_size - fill_size_rest=$(( lvol_size - fill_size )) + fill_size_rest=$((lvol_size - fill_size)) run_fio_test /dev/nbd1 "$offset" "$fill_size_rest" "write" "0xcc" && false # Check if data on first disk stayed unchanged diff --git a/test/make/check_so_deps.sh b/test/make/check_so_deps.sh index f7861c92d0..0ced7af166 100755 --- a/test/make/check_so_deps.sh +++ b/test/make/check_so_deps.sh @@ -26,7 +26,7 @@ function confirm_abi_deps() { return 1 fi - cat < ${suppression_file} + cat << EOF > ${suppression_file} [suppress_variable] name = SPDK_LOG_BDEV [suppress_variable] @@ -99,7 +99,7 @@ EOF touch $fail_file fi - if [ "$new_so_maj" != "$old_so_maj" ] && [ "$new_so_min" != "0" ]; then + if [ "$new_so_maj" != "$old_so_maj" ] && [ "$new_so_min" != "0" ]; then echo "SO major version for $so_file was bumped. Please reset the minor version to 0." touch $fail_file fi @@ -107,7 +107,7 @@ EOF continue fi - processed_so=$((processed_so+1)) + processed_so=$((processed_so + 1)) done rm -f $suppression_file echo "Processed $processed_so objects." @@ -131,7 +131,7 @@ function replace_defined_variables() { for dep in "${bad_values[@]}"; do dep_def_arr=($(grep -v "#" $libdeps_file | grep "${dep}" | cut -d "=" -f 2 | xargs)) new_values=($(replace_defined_variables "${dep_def_arr[@]}")) - good_values=( "${good_values[@]}" "${new_values[@]}" ) + good_values=("${good_values[@]}" "${new_values[@]}") done echo ${good_values[*]} } @@ -175,9 +175,9 @@ function confirm_deps() { done IFS=$'\n' # Ignore any event_* dependencies. Those are based on the subsystem configuration and not readelf. - lib_make_deps=( $(printf "%s\n" "${lib_make_deps[@]}" | sort | grep -v "event_") ) + lib_make_deps=($(printf "%s\n" "${lib_make_deps[@]}" | sort | grep -v "event_")) # Ignore the env_dpdk readelf dependency. We don't want people explicitly linking against it. - dep_names=( $(printf "%s\n" "${dep_names[@]}" | sort | uniq | grep -v "env_dpdk") ) + dep_names=($(printf "%s\n" "${dep_names[@]}" | sort | uniq | grep -v "env_dpdk")) unset IFS diff=$(echo "${dep_names[@]}" "${lib_make_deps[@]}" | tr ' ' '\n' | sort | uniq -u) if [ "$diff" != "" ]; then @@ -224,7 +224,10 @@ if grep -q 'CONFIG_VHOST_INTERNAL_LIB?=n' $rootdir/mk/config.mk; then IGNORED_LIBS+=("rte_vhost") fi -( for lib in $SPDK_LIBS; do confirm_deps $lib & done; wait ) +( + for lib in $SPDK_LIBS; do confirm_deps $lib & done + wait +) $MAKE $MAKEFLAGS clean git checkout "$rootdir/mk/spdk.lib.mk" diff --git a/test/nvme/hotplug.sh b/test/nvme/hotplug.sh index 672c985d41..35d267c402 100755 --- a/test/nvme/hotplug.sh +++ b/test/nvme/hotplug.sh @@ -12,7 +12,7 @@ fi function ssh_vm() { xtrace_disable sshpass -p "$password" ssh -o PubkeyAuthentication=no \ - -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 10022 root@localhost "$@" + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 10022 root@localhost "$@" xtrace_restore } @@ -110,7 +110,10 @@ ssh_vm 'echo ready' timing_exit wait_for_vm timing_enter copy_repo -(cd "$rootdir"; tar -cf - .) | (ssh_vm 'tar -xf -') +( + cd "$rootdir" + tar -cf - . +) | (ssh_vm 'tar -xf -') timing_exit copy_repo devices_initialization diff --git a/test/nvme/hw_hotplug.sh b/test/nvme/hw_hotplug.sh index ab83cfb941..489598646f 100755 --- a/test/nvme/hw_hotplug.sh +++ b/test/nvme/hw_hotplug.sh @@ -48,7 +48,7 @@ trap 'killprocess $example_pid; exit 1' SIGINT SIGTERM EXIT i=0 while ! grep "Starting I/O" log.txt; do [ $i -lt 20 ] || break - i=$((i+1)) + i=$((i + 1)) sleep 1 done diff --git a/test/nvme/nvme.sh b/test/nvme/nvme.sh index 759480b7c7..a698a9ba44 100755 --- a/test/nvme/nvme.sh +++ b/test/nvme/nvme.sh @@ -5,7 +5,7 @@ rootdir=$(readlink -f $testdir/../..) source $rootdir/scripts/common.sh source $rootdir/test/common/autotest_common.sh -function nvme_identify { +function nvme_identify() { $rootdir/examples/nvme/identify/identify -i 0 for bdf in $(get_nvme_bdfs); do $rootdir/examples/nvme/identify/identify -r "trtype:PCIe traddr:${bdf}" -i 0 @@ -13,7 +13,7 @@ function nvme_identify { timing_exit identify } -function nvme_perf { +function nvme_perf() { # enable no shutdown notification option $rootdir/examples/nvme/perf/perf -q 128 -w read -o 12288 -t 1 -LL -i 0 -N $rootdir/examples/nvme/perf/perf -q 128 -w write -o 12288 -t 1 -LL -i 0 @@ -23,7 +23,7 @@ function nvme_perf { fi } -function nvme_fio_test { +function nvme_fio_test() { PLUGIN_DIR=$rootdir/examples/nvme/fio_plugin for bdf in $(get_nvme_bdfs); do for blkname in $(get_nvme_name_from_bdf $bdf); do @@ -32,7 +32,7 @@ function nvme_fio_test { done } -function nvme_multi_secondary { +function nvme_multi_secondary() { $rootdir/examples/nvme/perf/perf -i 0 -q 16 -w read -o 4096 -t 3 -c 0x1 & pid0=$! $rootdir/examples/nvme/perf/perf -i 0 -q 16 -w read -o 4096 -t 3 -c 0x2 & diff --git a/test/nvme/perf/common.sh b/test/nvme/perf/common.sh index 024a1369d5..15e1b4208a 100755 --- a/test/nvme/perf/common.sh +++ b/test/nvme/perf/common.sh @@ -14,10 +14,10 @@ NVME_FIO_RESULTS=$BASE_DIR/result.json declare -A KERNEL_ENGINES KERNEL_ENGINES=( - ["kernel-libaio"]="--ioengine=libaio" - ["kernel-classic-polling"]="--ioengine=pvsync2 --hipri=100" - ["kernel-hybrid-polling"]="--ioengine=pvsync2 --hipri=100" - ["kernel-io-uring"]="--ioengine=io_uring" ) + ["kernel-libaio"]="--ioengine=libaio" + ["kernel-classic-polling"]="--ioengine=pvsync2 --hipri=100" + ["kernel-hybrid-polling"]="--ioengine=pvsync2 --hipri=100" + ["kernel-io-uring"]="--ioengine=io_uring") RW=randrw MIX=100 @@ -45,27 +45,27 @@ function is_bdf_not_mounted() { return $mountpoints } -function get_cores(){ +function get_cores() { local cpu_list="$1" for cpu in ${cpu_list//,/ }; do echo $cpu done } -function get_cores_numa_node(){ +function get_cores_numa_node() { local cores=$1 for core in $cores; do lscpu -p=cpu,node | grep "^$core\b" | awk -F ',' '{print $2}' done } -function get_numa_node(){ +function get_numa_node() { local plugin=$1 local disks=$2 if [[ "$plugin" =~ "nvme" ]]; then for bdf in $disks; do local driver - driver=$(grep DRIVER /sys/bus/pci/devices/$bdf/uevent |awk -F"=" '{print $2}') + driver=$(grep DRIVER /sys/bus/pci/devices/$bdf/uevent | awk -F"=" '{print $2}') # Use this check to ommit blacklisted devices ( not binded to driver with setup.sh script ) if [ "$driver" = "vfio-pci" ] || [ "$driver" = "uio_pci_generic" ]; then cat /sys/bus/pci/devices/$bdf/numa_node @@ -89,7 +89,7 @@ function get_numa_node(){ fi } -function get_disks(){ +function get_disks() { local plugin=$1 if [[ "$plugin" =~ "nvme" ]]; then for bdf in $(get_nvme_bdfs); do @@ -111,23 +111,22 @@ function get_disks(){ fi } -function get_disks_on_numa(){ +function get_disks_on_numa() { local devs=($1) local numas=($2) local numa_no=$3 local disks_on_numa="" local i - for (( i=0; i<${#devs[@]}; i++ )) - do + for ((i = 0; i < ${#devs[@]}; i++)); do if [ ${numas[$i]} = $numa_no ]; then - disks_on_numa=$((disks_on_numa+1)) + disks_on_numa=$((disks_on_numa + 1)) fi done echo $disks_on_numa } -function create_fio_config(){ +function create_fio_config() { local disk_no=$1 local plugin=$2 local disks=($3) @@ -139,35 +138,32 @@ function create_fio_config(){ local cores_numa cores_numa=($(get_cores_numa_node "$5")) - local disks_per_core=$((disk_no/no_cores)) - local disks_per_core_mod=$((disk_no%no_cores)) + local disks_per_core=$((disk_no / no_cores)) + local disks_per_core_mod=$((disk_no % no_cores)) # For kernel dirver, each disk will be alligned with all cpus on the same NUMA node if [[ "$plugin" =~ "kernel" ]]; then - for (( i=0; i> $BASE_DIR/config.fio + for ((j = 0; j < no_cores; j++)); do + core_numa=${cores_numa[$j]} + if [ "${disks_numa[$i]}" = "$core_numa" ]; then + cpu_used+="${cores[$j]}," + fi + done + sed -i -e "\$acpus_allowed=$cpu_used" $BASE_DIR/config.fio + echo "" >> $BASE_DIR/config.fio done else - for (( i=0; i/dev/null; do + until $cmd 2> /dev/null; do echo "Waiting for full nvme driver reload..." sleep 0.5 done @@ -374,7 +368,7 @@ function wait_for_nvme_reload() { function verify_disk_number() { # Check if we have appropriate number of disks to carry out the test if [[ "$PLUGIN" =~ "bdev" ]]; then - cat <<-JSON >"$BASE_DIR/bdev.conf" + cat <<- JSON > "$BASE_DIR/bdev.conf" {"subsystems":[ $("$ROOT_DIR/scripts/gen_nvme.sh" --json) ]} @@ -390,10 +384,12 @@ function verify_disk_number() { fi } -function usage() -{ +function usage() { set +x - [[ -n $2 ]] && ( echo "$2"; echo ""; ) + [[ -n $2 ]] && ( + echo "$2" + echo "" + ) echo "Run NVMe PMD/BDEV performance test. Change options for easier debug and setup configuration" echo "Usage: $(basename $1) [options]" echo "-h, --help Print help and exit" @@ -436,27 +432,42 @@ function usage() while getopts 'h-:' optchar; do case "$optchar" in -) - case "$OPTARG" in - help) usage $0; exit 0 ;; - rw=*) RW="${OPTARG#*=}" ;; - rwmixread=*) MIX="${OPTARG#*=}" ;; - iodepth=*) IODEPTH="${OPTARG#*=}" ;; - block-size=*) BLK_SIZE="${OPTARG#*=}" ;; - run-time=*) RUNTIME="${OPTARG#*=}" ;; - ramp-time=*) RAMP_TIME="${OPTARG#*=}" ;; - numjobs=*) NUMJOBS="${OPTARG#*=}" ;; - repeat-no=*) REPEAT_NO="${OPTARG#*=}" ;; - fio-bin=*) FIO_BIN="${OPTARG#*=}" ;; - driver=*) PLUGIN="${OPTARG#*=}" ;; - disk-no=*) DISKNO="${OPTARG#*=}"; ONEWORKLOAD=true ;; - max-disk=*) DISKNO="${OPTARG#*=}" ;; - cpu-allowed=*) CPUS_ALLOWED="${OPTARG#*=}" ;; - no-preconditioning) PRECONDITIONING=false ;; - no-io-scaling) NOIOSCALING=true ;; - *) usage $0 echo "Invalid argument '$OPTARG'"; exit 1 ;; - esac - ;; - h) usage $0; exit 0 ;; - *) usage $0 "Invalid argument '$optchar'"; exit 1 ;; + case "$OPTARG" in + help) + usage $0 + exit 0 + ;; + rw=*) RW="${OPTARG#*=}" ;; + rwmixread=*) MIX="${OPTARG#*=}" ;; + iodepth=*) IODEPTH="${OPTARG#*=}" ;; + block-size=*) BLK_SIZE="${OPTARG#*=}" ;; + run-time=*) RUNTIME="${OPTARG#*=}" ;; + ramp-time=*) RAMP_TIME="${OPTARG#*=}" ;; + numjobs=*) NUMJOBS="${OPTARG#*=}" ;; + repeat-no=*) REPEAT_NO="${OPTARG#*=}" ;; + fio-bin=*) FIO_BIN="${OPTARG#*=}" ;; + driver=*) PLUGIN="${OPTARG#*=}" ;; + disk-no=*) + DISKNO="${OPTARG#*=}" + ONEWORKLOAD=true + ;; + max-disk=*) DISKNO="${OPTARG#*=}" ;; + cpu-allowed=*) CPUS_ALLOWED="${OPTARG#*=}" ;; + no-preconditioning) PRECONDITIONING=false ;; + no-io-scaling) NOIOSCALING=true ;; + *) + usage $0 echo "Invalid argument '$OPTARG'" + exit 1 + ;; + esac + ;; + h) + usage $0 + exit 0 + ;; + *) + usage $0 "Invalid argument '$optchar'" + exit 1 + ;; esac done diff --git a/test/nvme/perf/run_perf.sh b/test/nvme/perf/run_perf.sh index 502957213e..8e4954f556 100755 --- a/test/nvme/perf/run_perf.sh +++ b/test/nvme/perf/run_perf.sh @@ -96,17 +96,15 @@ echo "run-time,ramp-time,fio-plugin,QD,block-size,num-cpu-cores,workload,workloa printf "%s,%s,%s,%s,%s,%s,%s,%s\n" $RUNTIME $RAMP_TIME $PLUGIN $IODEPTH $BLK_SIZE $NO_CORES $RW $MIX >> $result_file echo "num_of_disks,iops,avg_lat[usec],p99[usec],p99.99[usec],stdev[usec],avg_slat[usec],avg_clat[usec],bw[Kib/s]" >> $result_file #Run each workolad $REPEAT_NO times -for (( j=0; j < REPEAT_NO; j++ )) -do +for ((j = 0; j < REPEAT_NO; j++)); do #Start with $DISKNO disks and remove 2 disks for each run to avoid preconditioning before each run. - for (( k=DISKNO; k >= 1; k-=2 )) - do + for ((k = DISKNO; k >= 1; k -= 2)); do cp $BASE_DIR/config.fio.tmp $BASE_DIR/config.fio echo "" >> $BASE_DIR/config.fio #The SPDK fio plugin supports submitting/completing I/Os to multiple SSDs from a single thread. #Therefore, the per thread queue depth is set to the desired IODEPTH/device X the number of devices per thread. if [[ "$PLUGIN" =~ "spdk-plugin" ]] && [[ "$NOIOSCALING" = false ]]; then - qd=$(( IODEPTH * k )) + qd=$((IODEPTH * k)) else qd=$IODEPTH fi @@ -142,17 +140,17 @@ do time_based=1 description=$desc log_avg_msec=250 - EOF + EOF echo "USING CONFIG:" cat $BASE_DIR/config.fio if [[ "$PLUGIN" =~ "spdk-plugin" ]]; then run_spdk_nvme_fio $PLUGIN "--output=$NVME_FIO_RESULTS" \ - "--write_lat_log=$result_dir/perf_lat_${BLK_SIZE}BS_${IODEPTH}QD_${RW}_${MIX}MIX_${PLUGIN}_${DATE}_${k}disks_${j}" + "--write_lat_log=$result_dir/perf_lat_${BLK_SIZE}BS_${IODEPTH}QD_${RW}_${MIX}MIX_${PLUGIN}_${DATE}_${k}disks_${j}" else run_nvme_fio $fio_ioengine_opt "--output=$NVME_FIO_RESULTS" \ - "--write_lat_log=$result_dir/perf_lat_${BLK_SIZE}BS_${IODEPTH}QD_${RW}_${MIX}MIX_${PLUGIN}_${DATE}_${k}disks_${j}" + "--write_lat_log=$result_dir/perf_lat_${BLK_SIZE}BS_${IODEPTH}QD_${RW}_${MIX}MIX_${PLUGIN}_${DATE}_${k}disks_${j}" fi #Store values for every number of used disks @@ -177,8 +175,7 @@ do done done #Write results to csv file -for (( k=DISKNO; k >= 1; k-=2 )) -do +for ((k = DISKNO; k >= 1; k -= 2)); do iops_disks[$k]=$((${iops_disks[$k]} / REPEAT_NO)) if [[ "$PLUGIN" =~ "plugin" ]]; then @@ -206,8 +203,8 @@ do bw[$k]=$((${bw[$k]} / REPEAT_NO)) - printf "%s,%s,%s,%s,%s,%s,%s,%s,%s\n" ${k} ${iops_disks[$k]} ${mean_lat_disks_usec[$k]} ${p99_lat_disks_usec[$k]}\ - ${p99_99_lat_disks_usec[$k]} ${stdev_disks_usec[$k]} ${mean_slat_disks_usec[$k]} ${mean_clat_disks_usec[$k]} ${bw[$k]} >> $result_file + printf "%s,%s,%s,%s,%s,%s,%s,%s,%s\n" ${k} ${iops_disks[$k]} ${mean_lat_disks_usec[$k]} ${p99_lat_disks_usec[$k]} \ + ${p99_99_lat_disks_usec[$k]} ${stdev_disks_usec[$k]} ${mean_slat_disks_usec[$k]} ${mean_clat_disks_usec[$k]} ${bw[$k]} >> $result_file #if tested on only one numeber of disk if $ONEWORKLOAD; then diff --git a/test/nvme/spdk_nvme_cli.sh b/test/nvme/spdk_nvme_cli.sh index cc2ae50a45..eea1a8a205 100755 --- a/test/nvme/spdk_nvme_cli.sh +++ b/test/nvme/spdk_nvme_cli.sh @@ -6,8 +6,8 @@ source $rootdir/scripts/common.sh source $rootdir/test/common/autotest_common.sh if [ -z "${DEPENDENCY_DIR}" ]; then - echo DEPENDENCY_DIR not defined! - exit 1 + echo DEPENDENCY_DIR not defined! + exit 1 fi spdk_nvme_cli="${DEPENDENCY_DIR}/nvme-cli" diff --git a/test/nvme/spdk_nvme_cli_cuse.sh b/test/nvme/spdk_nvme_cli_cuse.sh index 3edf422a4f..e90b4537ea 100755 --- a/test/nvme/spdk_nvme_cli_cuse.sh +++ b/test/nvme/spdk_nvme_cli_cuse.sh @@ -18,20 +18,20 @@ bdf=$(get_first_nvme_bdf) PCI_WHITELIST="${bdf}" $rootdir/scripts/setup.sh reset sleep 1 -bdf_sysfs_path=$( readlink -f /sys/class/nvme/nvme* | grep "$bdf/nvme/nvme" ) +bdf_sysfs_path=$(readlink -f /sys/class/nvme/nvme* | grep "$bdf/nvme/nvme") if [ -z "$bdf_sysfs_path" ]; then echo "setup.sh failed bind kernel driver to ${bdf}" return 1 fi -nvme_name=$( basename $bdf_sysfs_path ) +nvme_name=$(basename $bdf_sysfs_path) set +e ctrlr="/dev/${nvme_name}" ns="/dev/${nvme_name}n1" -oacs=$( ${NVME_CMD} id-ctrl $ctrlr | grep oacs | cut -d: -f2 ) -oacs_firmware=$(( oacs & 0x4 )) +oacs=$(${NVME_CMD} id-ctrl $ctrlr | grep oacs | cut -d: -f2) +oacs_firmware=$((oacs & 0x4)) ${NVME_CMD} get-ns-id $ns > ${KERNEL_OUT}.1 ${NVME_CMD} id-ns $ns > ${KERNEL_OUT}.2 diff --git a/test/nvme/spdk_smartctl_cuse.sh b/test/nvme/spdk_smartctl_cuse.sh index 9de248f38f..1cdd3dd30c 100755 --- a/test/nvme/spdk_smartctl_cuse.sh +++ b/test/nvme/spdk_smartctl_cuse.sh @@ -12,19 +12,19 @@ bdf=$(get_first_nvme_bdf) PCI_WHITELIST="${bdf}" $rootdir/scripts/setup.sh reset sleep 1 -bdf_sysfs_path=$( readlink -f /sys/class/nvme/nvme* | grep "$bdf/nvme/nvme" ) +bdf_sysfs_path=$(readlink -f /sys/class/nvme/nvme* | grep "$bdf/nvme/nvme") if [ -z "$bdf_sysfs_path" ]; then echo "setup.sh failed bind kernel driver to ${bdf}" exit 1 fi -nvme_name=$( basename $bdf_sysfs_path ) +nvme_name=$(basename $bdf_sysfs_path) -KERNEL_SMART_JSON=$( ${SMARTCTL_CMD} --json=g -a /dev/${nvme_name} | grep -v "/dev/${nvme_name}" | sort || true ) +KERNEL_SMART_JSON=$(${SMARTCTL_CMD} --json=g -a /dev/${nvme_name} | grep -v "/dev/${nvme_name}" | sort || true) ${SMARTCTL_CMD} -i /dev/${nvme_name}n1 # logs are not provided by json output -KERNEL_SMART_ERRLOG=$( ${SMARTCTL_CMD} -l error /dev/${nvme_name} ) +KERNEL_SMART_ERRLOG=$(${SMARTCTL_CMD} -l error /dev/${nvme_name}) $rootdir/scripts/setup.sh @@ -43,19 +43,19 @@ if [ ! -c /dev/spdk/nvme0 ]; then exit 1 fi -CUSE_SMART_JSON=$( ${SMARTCTL_CMD} --json=g -a /dev/spdk/nvme0 | grep -v "/dev/spdk/nvme0" | sort || true ) +CUSE_SMART_JSON=$(${SMARTCTL_CMD} --json=g -a /dev/spdk/nvme0 | grep -v "/dev/spdk/nvme0" | sort || true) -DIFF_SMART_JSON=$( diff --changed-group-format='%<' --unchanged-group-format='' <(echo "$KERNEL_SMART_JSON") <(echo "$CUSE_SMART_JSON") || true) +DIFF_SMART_JSON=$(diff --changed-group-format='%<' --unchanged-group-format='' <(echo "$KERNEL_SMART_JSON") <(echo "$CUSE_SMART_JSON") || true) # Mask values can change -ERR_SMART_JSON=$( grep -v "json\.nvme_smart_health_information_log\.\|json\.local_time\.\|json\.temperature\.\|json\.power_on_time\.hours" <<< $DIFF_SMART_JSON || true ) +ERR_SMART_JSON=$(grep -v "json\.nvme_smart_health_information_log\.\|json\.local_time\.\|json\.temperature\.\|json\.power_on_time\.hours" <<< $DIFF_SMART_JSON || true) -if [ -n "$ERR_SMART_JSON" ] ; then +if [ -n "$ERR_SMART_JSON" ]; then echo "Wrong values for: $ERR_SMART_JSON" exit 1 fi -CUSE_SMART_ERRLOG=$( ${SMARTCTL_CMD} -l error /dev/spdk/nvme0 ) +CUSE_SMART_ERRLOG=$(${SMARTCTL_CMD} -l error /dev/spdk/nvme0) if [ "$CUSE_SMART_ERRLOG" != "$KERNEL_SMART_ERRLOG" ]; then echo "Wrong values in NVMe Error log" exit 1 diff --git a/test/nvmf/common.sh b/test/nvmf/common.sh index ac07f9ecf6..5040493d82 100644 --- a/test/nvmf/common.sh +++ b/test/nvmf/common.sh @@ -5,8 +5,7 @@ NVMF_TCP_IP_ADDRESS="127.0.0.1" NVMF_TRANSPORT_OPTS="" NVMF_SERIAL=SPDK00000000000001 -function build_nvmf_app_args() -{ +function build_nvmf_app_args() { if [ $SPDK_RUN_NON_ROOT -eq 1 ]; then NVMF_APP=(sudo -u "$USER" "${NVMF_APP[@]}") NVMF_APP+=(-i "$NVMF_APP_SHM_ID" -e 0xFFFF) @@ -15,13 +14,13 @@ function build_nvmf_app_args() fi } -: ${NVMF_APP_SHM_ID="0"}; export NVMF_APP_SHM_ID +: ${NVMF_APP_SHM_ID="0"} +export NVMF_APP_SHM_ID build_nvmf_app_args have_pci_nics=0 -function load_ib_rdma_modules() -{ +function load_ib_rdma_modules() { if [ $(uname) != Linux ]; then return 0 fi @@ -37,9 +36,7 @@ function load_ib_rdma_modules() modprobe rdma_ucm } - -function detect_soft_roce_nics() -{ +function detect_soft_roce_nics() { if hash rxe_cfg; then rxe_cfg start rdma_nics=$(get_rdma_if_list) @@ -54,12 +51,10 @@ function detect_soft_roce_nics() fi } - # args 1 and 2 represent the grep filters for finding our NICS. # subsequent args are all drivers that should be loaded if we find these NICs. # Those drivers should be supplied in the correct order. -function detect_nics_and_probe_drivers() -{ +function detect_nics_and_probe_drivers() { NIC_VENDOR="$1" NIC_CLASS="$2" @@ -80,9 +75,7 @@ function detect_nics_and_probe_drivers() fi } - -function detect_pci_nics() -{ +function detect_pci_nics() { if ! hash lspci; then return 0 @@ -101,38 +94,34 @@ function detect_pci_nics() sleep 5 } -function detect_rdma_nics() -{ +function detect_rdma_nics() { detect_pci_nics if [ "$have_pci_nics" -eq "0" ]; then detect_soft_roce_nics fi } -function allocate_nic_ips() -{ - (( count=NVMF_IP_LEAST_ADDR )) +function allocate_nic_ips() { + ((count = NVMF_IP_LEAST_ADDR)) for nic_name in $(get_rdma_if_list); do ip="$(get_ip_address $nic_name)" if [ -z $ip ]; then ip addr add $NVMF_IP_PREFIX.$count/24 dev $nic_name ip link set $nic_name up - (( count=count+1 )) + ((count = count + 1)) fi # dump configuration for debug log ip addr show $nic_name done } -function get_available_rdma_ips() -{ +function get_available_rdma_ips() { for nic_name in $(get_rdma_if_list); do get_ip_address $nic_name done } -function get_rdma_if_list() -{ +function get_rdma_if_list() { for nic_type in /sys/class/infiniband/*; do [[ -e "$nic_type" ]] || break for nic_name in /sys/class/infiniband/"$(basename ${nic_type})"/device/net/*; do @@ -142,14 +131,12 @@ function get_rdma_if_list() done } -function get_ip_address() -{ +function get_ip_address() { interface=$1 ip -o -4 addr show $interface | awk '{print $4}' | cut -d"/" -f1 } -function nvmfcleanup() -{ +function nvmfcleanup() { sync set +e for i in {1..20}; do @@ -170,8 +157,7 @@ function nvmfcleanup() modprobe -v -r nvme-fabrics } -function nvmftestinit() -{ +function nvmftestinit() { if [ -z $TEST_TRANSPORT ]; then echo "transport not specified - use --transport= to specify" return 1 @@ -205,8 +191,7 @@ function nvmftestinit() modprobe nvme-$TEST_TRANSPORT || true } -function nvmfappstart() -{ +function nvmfappstart() { timing_enter start_nvmf_tgt "${NVMF_APP[@]}" $1 & nvmfpid=$! @@ -215,8 +200,7 @@ function nvmfappstart() timing_exit start_nvmf_tgt } -function nvmftestfini() -{ +function nvmftestfini() { nvmfcleanup || : if [ -n "$nvmfpid" ]; then killprocess $nvmfpid @@ -229,15 +213,13 @@ function nvmftestfini() fi } -function rdma_device_init() -{ +function rdma_device_init() { load_ib_rdma_modules detect_rdma_nics allocate_nic_ips } -function revert_soft_roce() -{ +function revert_soft_roce() { if hash rxe_cfg; then interfaces="$(ip -o link | awk '{print $2}' | cut -d":" -f1)" for interface in $interfaces; do @@ -247,8 +229,7 @@ function revert_soft_roce() fi } -function check_ip_is_soft_roce() -{ +function check_ip_is_soft_roce() { IP=$1 if hash rxe_cfg; then dev=$(ip -4 -o addr show | grep $IP | cut -d" " -f2) @@ -262,8 +243,7 @@ function check_ip_is_soft_roce() fi } -function nvme_connect() -{ +function nvme_connect() { local init_count init_count=$(nvme list | wc -l) @@ -279,8 +259,7 @@ function nvme_connect() return 1 } -function get_nvme_devs() -{ +function get_nvme_devs() { local dev rest nvmes=() @@ -292,18 +271,17 @@ function get_nvme_devs() echo "$dev $rest" fi done < <(nvme list) - (( ${#nvmes[@]} )) || return 1 + ((${#nvmes[@]})) || return 1 echo "${#nvmes[@]}" >&2 } -function gen_nvmf_target_json() -{ +function gen_nvmf_target_json() { local subsystem config=() for subsystem in "${@:-1}"; do config+=( "$( - cat <<-EOF + cat <<- EOF { "params": { "name": "Nvme$subsystem", @@ -319,13 +297,16 @@ function gen_nvmf_target_json() )" ) done - jq . <<-JSON + jq . <<- JSON { "subsystems": [ { "subsystem": "bdev", "config": [ - $(IFS=","; printf '%s\n' "${config[*]}") + $( + IFS="," + printf '%s\n' "${config[*]}" + ) ] } ] diff --git a/test/nvmf/host/bdevperf.sh b/test/nvmf/host/bdevperf.sh index 7666640ad3..6f07c7ba45 100755 --- a/test/nvmf/host/bdevperf.sh +++ b/test/nvmf/host/bdevperf.sh @@ -10,8 +10,7 @@ MALLOC_BLOCK_SIZE=512 rpc_py="$rootdir/scripts/rpc.py" -function tgt_init() -{ +function tgt_init() { nvmfappstart "-m 0xF" $rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192 @@ -29,7 +28,6 @@ if [ $TEST_TRANSPORT == "rdma" ] && check_ip_is_soft_roce $NVMF_FIRST_TARGET_IP; exit 0 fi - tgt_init "$rootdir/test/bdev/bdevperf/bdevperf" --json <(gen_nvmf_target_json) -q 128 -o 4096 -w verify -t 1 diff --git a/test/nvmf/host/target_disconnect.sh b/test/nvmf/host/target_disconnect.sh index d32feba08c..4f11414b5b 100755 --- a/test/nvmf/host/target_disconnect.sh +++ b/test/nvmf/host/target_disconnect.sh @@ -12,8 +12,7 @@ MALLOC_BLOCK_SIZE=512 rpc_py="$rootdir/scripts/rpc.py" -function disconnect_init() -{ +function disconnect_init() { nvmfappstart "-m 0xF0" $rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc0 @@ -27,10 +26,10 @@ function disconnect_init() # Test to make sure we don't segfault or access null pointers when we try to connect to # a discovery controller that doesn't exist yet. -function nvmf_target_disconnect_tc1 { +function nvmf_target_disconnect_tc1() { set +e $rootdir/examples/nvme/reconnect/reconnect -q 32 -o 4096 -w randrw -M 50 -t 10 -c 0xF \ - -r "trtype:$TEST_TRANSPORT adrfam:IPv4 traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT" + -r "trtype:$TEST_TRANSPORT adrfam:IPv4 traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT" # If the program crashes, the high bit of $? will be set so we will get a value in the hundreds. # But if the reconnect code detects errors and exits normally it will return 1. if [ $? != 1 ]; then @@ -40,12 +39,12 @@ function nvmf_target_disconnect_tc1 { set -e } -function nvmf_target_disconnect_tc2 { +function nvmf_target_disconnect_tc2() { disconnect_init $NVMF_FIRST_TARGET_IP # If perf doesn't shut down, this test will time out. $rootdir/examples/nvme/reconnect/reconnect -q 32 -o 4096 -w randrw -M 50 -t 10 -c 0xF \ - -r "trtype:$TEST_TRANSPORT adrfam:IPv4 traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT" & + -r "trtype:$TEST_TRANSPORT adrfam:IPv4 traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT" & reconnectpid=$! sleep 2 @@ -58,9 +57,9 @@ function nvmf_target_disconnect_tc2 { sync } -function nvmf_target_disconnect_tc3 { +function nvmf_target_disconnect_tc3() { $rootdir/examples/nvme/reconnect/reconnect -q 32 -o 4096 -w randrw -M 50 -t 10 -c 0xF \ - -r "trtype:$TEST_TRANSPORT adrfam:IPv4 traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT alt_traddr:$NVMF_SECOND_TARGET_IP" & + -r "trtype:$TEST_TRANSPORT adrfam:IPv4 traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT alt_traddr:$NVMF_SECOND_TARGET_IP" & reconnectpid=$! sleep 2 @@ -86,6 +85,5 @@ else fi fi - trap - SIGINT SIGTERM EXIT nvmftestfini diff --git a/test/nvmf/nvmf.sh b/test/nvmf/nvmf.sh index 7ab5c88755..dc15788fff 100755 --- a/test/nvmf/nvmf.sh +++ b/test/nvmf/nvmf.sh @@ -11,7 +11,7 @@ source $rootdir/test/nvmf/common.sh trap "exit 1" SIGINT SIGTERM EXIT -TEST_ARGS=( "$@" ) +TEST_ARGS=("$@") run_test "nvmf_example" test/nvmf/target/nvmf_example.sh "${TEST_ARGS[@]}" run_test "nvmf_filesystem" test/nvmf/target/filesystem.sh "${TEST_ARGS[@]}" diff --git a/test/nvmf/target/bdev_io_wait.sh b/test/nvmf/target/bdev_io_wait.sh index 967af03c24..4230b1ff80 100755 --- a/test/nvmf/target/bdev_io_wait.sh +++ b/test/nvmf/target/bdev_io_wait.sh @@ -21,13 +21,13 @@ $rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192 $rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc0 $rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001 $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc0 -$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT +$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT "$rootdir/test/bdev/bdevperf/bdevperf" -m 0x10 -i 1 --json <(gen_nvmf_target_json) -q 128 -o 4096 -w write -t 1 & WRITE_PID=$! "$rootdir/test/bdev/bdevperf/bdevperf" -m 0x20 -i 2 --json <(gen_nvmf_target_json) -q 128 -o 4096 -w read -t 1 & READ_PID=$! -"$rootdir/test/bdev/bdevperf/bdevperf" -m 0x40 -i 3 --json <(gen_nvmf_target_json) -q 128 -o 4096 -w flush -t 1 & +"$rootdir/test/bdev/bdevperf/bdevperf" -m 0x40 -i 3 --json <(gen_nvmf_target_json) -q 128 -o 4096 -w flush -t 1 & FLUSH_PID=$! "$rootdir/test/bdev/bdevperf/bdevperf" -m 0x80 -i 4 --json <(gen_nvmf_target_json) -q 128 -o 4096 -w unmap -t 1 & UNMAP_PID=$! diff --git a/test/nvmf/target/bdevio.sh b/test/nvmf/target/bdevio.sh index f1ec789c2f..13dc469148 100755 --- a/test/nvmf/target/bdevio.sh +++ b/test/nvmf/target/bdevio.sh @@ -18,7 +18,7 @@ $rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192 $rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc0 $rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001 $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc0 -$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT +$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT $rootdir/test/bdev/bdevio/bdevio --json <(gen_nvmf_target_json) diff --git a/test/nvmf/target/discovery.sh b/test/nvmf/target/discovery.sh index 01fcad08b5..dd144965b7 100755 --- a/test/nvmf/target/discovery.sh +++ b/test/nvmf/target/discovery.sh @@ -25,7 +25,7 @@ for i in $(seq 1 4); do $rpc_py bdev_null_create Null$i $NULL_BDEV_SIZE $NULL_BLOCK_SIZE $rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode$i -a -s SPDK0000000000000$i $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode$i Null$i - $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode$i -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT + $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode$i -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT done nvme discover -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT diff --git a/test/nvmf/target/filesystem.sh b/test/nvmf/target/filesystem.sh index 262131d15f..ceb43fe216 100755 --- a/test/nvmf/target/filesystem.sh +++ b/test/nvmf/target/filesystem.sh @@ -12,7 +12,7 @@ rpc_py="$rootdir/scripts/rpc.py" nvmftestinit -function nvmf_filesystem_create { +function nvmf_filesystem_create() { fstype=$1 nvme_name=$2 @@ -27,7 +27,7 @@ function nvmf_filesystem_create { i=0 while ! umount /mnt/device; do [ $i -lt 15 ] || break - i=$((i+1)) + i=$((i + 1)) sleep 1 done @@ -41,7 +41,7 @@ function nvmf_filesystem_create { lsblk -l -o NAME | grep -q -w "${nvme_name}p1" } -function nvmf_filesystem_part { +function nvmf_filesystem_part() { incapsule=$1 nvmfappstart "-m 0xF" @@ -59,7 +59,7 @@ function nvmf_filesystem_part { mkdir -p /mnt/device - parted -s /dev/${nvme_name} mklabel msdos mkpart primary '0%' '100%' + parted -s /dev/${nvme_name} mklabel msdos mkpart primary '0%' '100%' partprobe sleep 1 diff --git a/test/nvmf/target/fio.sh b/test/nvmf/target/fio.sh index e53321a80d..82c691a960 100755 --- a/test/nvmf/target/fio.sh +++ b/test/nvmf/target/fio.sh @@ -59,11 +59,11 @@ wait $fio_pid || fio_status=$? nvme disconnect -n "nqn.2016-06.io.spdk:cnode1" || true if [ $fio_status -eq 0 ]; then - echo "nvmf hotplug test: fio successful - expected failure" + echo "nvmf hotplug test: fio successful - expected failure" nvmftestfini - exit 1 + exit 1 else - echo "nvmf hotplug test: fio failed as expected" + echo "nvmf hotplug test: fio failed as expected" fi $rpc_py nvmf_delete_subsystem nqn.2016-06.io.spdk:cnode1 diff --git a/test/nvmf/target/fuzz.sh b/test/nvmf/target/fuzz.sh index 538cb1d700..5a18be856f 100755 --- a/test/nvmf/target/fuzz.sh +++ b/test/nvmf/target/fuzz.sh @@ -9,7 +9,7 @@ rpc_py="$rootdir/scripts/rpc.py" nvmftestinit -"${NVMF_APP[@]}" -m 0xF >$output_dir/nvmf_fuzz_tgt_output.txt 2>&1 & +"${NVMF_APP[@]}" -m 0xF > $output_dir/nvmf_fuzz_tgt_output.txt 2>&1 & nvmfpid=$! trap 'process_shm --id $NVMF_APP_SHM_ID; rm -f $testdir/nvmf_fuzz.conf; killprocess $nvmfpid; nvmftestfini $1; exit 1' SIGINT SIGTERM EXIT @@ -27,9 +27,9 @@ echo "[Nvme]" > $testdir/nvmf_fuzz.conf echo " TransportID \"trtype:$TEST_TRANSPORT adrfam:IPv4 subnqn:nqn.2016-06.io.spdk:cnode1 traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT\" Nvme0" >> $testdir/nvmf_fuzz.conf # Note that we chose a consistent seed to ensure that this test is consistent in nightly builds. -$rootdir/test/app/fuzz/nvme_fuzz/nvme_fuzz -m 0xF0 -r "/var/tmp/nvme_fuzz" -t 30 -S 123456 -C $testdir/nvmf_fuzz.conf -N -a 2>$output_dir/nvmf_fuzz_logs1.txt +$rootdir/test/app/fuzz/nvme_fuzz/nvme_fuzz -m 0xF0 -r "/var/tmp/nvme_fuzz" -t 30 -S 123456 -C $testdir/nvmf_fuzz.conf -N -a 2> $output_dir/nvmf_fuzz_logs1.txt # We don't specify a seed for this test. Instead we run a static list of commands from example.json. -$rootdir/test/app/fuzz/nvme_fuzz/nvme_fuzz -m 0xF0 -r "/var/tmp/nvme_fuzz" -C $testdir/nvmf_fuzz.conf -j $rootdir/test/app/fuzz/nvme_fuzz/example.json -a 2>$output_dir/nvmf_fuzz_logs2.txt +$rootdir/test/app/fuzz/nvme_fuzz/nvme_fuzz -m 0xF0 -r "/var/tmp/nvme_fuzz" -C $testdir/nvmf_fuzz.conf -j $rootdir/test/app/fuzz/nvme_fuzz/example.json -a 2> $output_dir/nvmf_fuzz_logs2.txt rm -f $testdir/nvmf_fuzz.conf $rpc_py nvmf_delete_subsystem nqn.2016-06.io.spdk:cnode1 diff --git a/test/nvmf/target/identify_passthru.sh b/test/nvmf/target/identify_passthru.sh index ac8d7ee422..0f145f8acc 100755 --- a/test/nvmf/target/identify_passthru.sh +++ b/test/nvmf/target/identify_passthru.sh @@ -13,7 +13,7 @@ nvmftestinit timing_enter nvme_identify bdf=$(get_first_nvme_bdf) -if [ -z "${bdf}" ] ; then +if [ -z "${bdf}" ]; then echo "No NVMe drive found but test requires it. Failing the test." exit 1 fi @@ -59,12 +59,12 @@ nvmf_model_number=$($rootdir/examples/nvme/identify/identify -r "\ trsvcid:$NVMF_PORT \ subnqn:nqn.2016-06.io.spdk:cnode1" | grep "Model Number:" | awk '{print $3}') -if [ ${nvme_serial_number} != ${nvmf_serial_number} ] ; then +if [ ${nvme_serial_number} != ${nvmf_serial_number} ]; then echo "Serial number doesn't match" exit 1 fi -if [ ${nvme_model_number} != ${nvmf_model_number} ] ; then +if [ ${nvme_model_number} != ${nvmf_model_number} ]; then echo "Model number doesn't match" exit 1 fi diff --git a/test/nvmf/target/initiator_timeout.sh b/test/nvmf/target/initiator_timeout.sh index e2e483c891..8da75af266 100755 --- a/test/nvmf/target/initiator_timeout.sh +++ b/test/nvmf/target/initiator_timeout.sh @@ -55,11 +55,11 @@ wait $fio_pid || fio_status=$? nvme disconnect -n "nqn.2016-06.io.spdk:cnode1" || true if [ $fio_status -eq 0 ]; then - echo "nvmf hotplug test: fio successful as expected" + echo "nvmf hotplug test: fio successful as expected" else - echo "nvmf hotplug test: fio failed, expected success" - nvmftestfini - exit 1 + echo "nvmf hotplug test: fio failed, expected success" + nvmftestfini + exit 1 fi $rpc_py nvmf_delete_subsystem nqn.2016-06.io.spdk:cnode1 diff --git a/test/nvmf/target/invalid.sh b/test/nvmf/target/invalid.sh index e578e5b340..4a0b243222 100755 --- a/test/nvmf/target/invalid.sh +++ b/test/nvmf/target/invalid.sh @@ -12,14 +12,13 @@ target=foobar # pre-seed the rng to generate predictive values across different test runs RANDOM=0 - -gen_random_s () { +gen_random_s() { local length=$1 ll # generate ascii table which nvme supports local chars=({32..127}) local string - for (( ll = 0; ll < length; ll++ )); do + for ((ll = 0; ll < length; ll++)); do string+="$(echo -e "\x$(printf '%x' "${chars[RANDOM % ${#chars[@]}]}")")" done # Be nice to rpc.py's arg parser and escape `-` in case it's a first character @@ -34,7 +33,6 @@ nvmfappstart "-m 0xF" trap 'process_shm --id $NVMF_APP_SHM_ID; nvmftestfini $1; exit 1' SIGINT SIGTERM EXIT - # Attempt to create subsystem with non-existing target out=$("$rpc" nvmf_create_subsystem -t "$target" "$nqn$RANDOM" 2>&1) && false [[ $out == *"Unable to find target"* ]] diff --git a/test/nvmf/target/multiconnection.sh b/test/nvmf/target/multiconnection.sh index 5ced53e5b7..04405bc07c 100755 --- a/test/nvmf/target/multiconnection.sh +++ b/test/nvmf/target/multiconnection.sh @@ -25,8 +25,7 @@ fi $rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192 -for i in $(seq 1 $NVMF_SUBSYS) -do +for i in $(seq 1 $NVMF_SUBSYS); do $rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc$i $rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode$i -a -s SPDK$i $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode$i Malloc$i diff --git a/test/nvmf/target/multitarget.sh b/test/nvmf/target/multitarget.sh index ac786ec79b..a537b052ad 100755 --- a/test/nvmf/target/multitarget.sh +++ b/test/nvmf/target/multitarget.sh @@ -15,21 +15,21 @@ trap 'process_shm --id $NVMF_APP_SHM_ID; nvmftestfini $1; exit 1' SIGINT SIGTERM # Target application should start with a single target. if [ "$($rpc_py nvmf_get_targets | jq 'length')" != "1" ]; then -echo "SPDK application did not start with the proper number of targets." && false + echo "SPDK application did not start with the proper number of targets." && false fi $rpc_py nvmf_create_target -n nvmf_tgt_1 -s 32 $rpc_py nvmf_create_target -n nvmf_tgt_2 -s 32 if [ "$($rpc_py nvmf_get_targets | jq 'length')" != "3" ]; then -echo "nvmf_create_target RPC didn't properly create targets." && false + echo "nvmf_create_target RPC didn't properly create targets." && false fi $rpc_py nvmf_delete_target -n nvmf_tgt_1 $rpc_py nvmf_delete_target -n nvmf_tgt_2 if [ "$($rpc_py nvmf_get_targets | jq 'length')" != "1" ]; then -echo "nvmf_delete_target RPC didn't properly destroy targets." && false + echo "nvmf_delete_target RPC didn't properly destroy targets." && false fi trap - SIGINT SIGTERM EXIT diff --git a/test/nvmf/target/nvme_cli.sh b/test/nvmf/target/nvme_cli.sh index 37c81b253f..65f76ed776 100755 --- a/test/nvmf/target/nvme_cli.sh +++ b/test/nvmf/target/nvme_cli.sh @@ -6,8 +6,8 @@ source $rootdir/test/common/autotest_common.sh source $rootdir/test/nvmf/common.sh if [ -z "${DEPENDENCY_DIR}" ]; then - echo DEPENDENCY_DIR not defined! - exit 1 + echo DEPENDENCY_DIR not defined! + exit 1 fi spdk_nvme_cli="${DEPENDENCY_DIR}/nvme-cli" @@ -33,7 +33,7 @@ $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPOR nvme connect -t $TEST_TRANSPORT -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" waitforserial $NVMF_SERIAL 2 -if ! get_nvme_devs print 2>/dev/null; then +if ! get_nvme_devs print 2> /dev/null; then echo "Could not find any nvme devices to work with, aborting the test" >&2 exit 1 fi @@ -54,7 +54,7 @@ done nvme disconnect -n "nqn.2016-06.io.spdk:cnode1" -if [ -d $spdk_nvme_cli ]; then +if [ -d $spdk_nvme_cli ]; then # Test spdk/nvme-cli NVMe-oF commands: discover, connect and disconnect cd $spdk_nvme_cli sed -i 's/shm_id=.*/shm_id=-1/g' spdk.conf diff --git a/test/nvmf/target/nvmf_example.sh b/test/nvmf/target/nvmf_example.sh index e27203d5f4..0a3f05f05c 100755 --- a/test/nvmf/target/nvmf_example.sh +++ b/test/nvmf/target/nvmf_example.sh @@ -10,25 +10,23 @@ rpc_py="$rootdir/scripts/rpc.py" MALLOC_BDEV_SIZE=64 MALLOC_BLOCK_SIZE=512 -function build_nvmf_example_args() -{ - if [ $SPDK_RUN_NON_ROOT -eq 1 ]; then - echo "sudo -u $(logname) ./examples/nvmf/nvmf/nvmf -i $NVMF_APP_SHM_ID" - else - echo "./examples/nvmf/nvmf/nvmf -i $NVMF_APP_SHM_ID" - fi +function build_nvmf_example_args() { + if [ $SPDK_RUN_NON_ROOT -eq 1 ]; then + echo "sudo -u $(logname) ./examples/nvmf/nvmf/nvmf -i $NVMF_APP_SHM_ID" + else + echo "./examples/nvmf/nvmf/nvmf -i $NVMF_APP_SHM_ID" + fi } NVMF_EXAMPLE="$(build_nvmf_example_args)" -function nvmfexamplestart() -{ - timing_enter start_nvmf_example - $NVMF_EXAMPLE $1 & - nvmfpid=$! - trap 'process_shm --id $NVMF_APP_SHM_ID; nvmftestfini; exit 1' SIGINT SIGTERM EXIT - waitforlisten $nvmfpid - timing_exit start_nvmf_example +function nvmfexamplestart() { + timing_enter start_nvmf_example + $NVMF_EXAMPLE $1 & + nvmfpid=$! + trap 'process_shm --id $NVMF_APP_SHM_ID; nvmftestfini; exit 1' SIGINT SIGTERM EXIT + waitforlisten $nvmfpid + timing_exit start_nvmf_example } timing_enter nvmf_example_test @@ -44,7 +42,7 @@ $rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK0000000000000 #add ns to subsystem for malloc_bdev in $malloc_bdevs; do - $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 "$malloc_bdev" + $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 "$malloc_bdev" done #add listener to subsystem @@ -53,7 +51,7 @@ $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPOR perf="$rootdir/examples/nvme/perf/perf" $perf -q 64 -o 4096 -w randrw -M 30 -t 10 \ --r "trtype:${TEST_TRANSPORT} adrfam:IPv4 traddr:${NVMF_FIRST_TARGET_IP} trsvcid:${NVMF_PORT} \ + -r "trtype:${TEST_TRANSPORT} adrfam:IPv4 traddr:${NVMF_FIRST_TARGET_IP} trsvcid:${NVMF_PORT} \ subnqn:nqn.2016-06.io.spdk:cnode1" trap - SIGINT SIGTERM EXIT diff --git a/test/nvmf/target/nvmf_vhost.sh b/test/nvmf/target/nvmf_vhost.sh index 6fd53db8ca..48e78d6d28 100755 --- a/test/nvmf/target/nvmf_vhost.sh +++ b/test/nvmf/target/nvmf_vhost.sh @@ -52,7 +52,7 @@ $VHOST_RPC vhost_create_scsi_controller naa.VhostScsi0.3 $VHOST_RPC vhost_scsi_controller_add_target naa.VhostScsi0.3 0 "Nvme0n1" # start qemu based VM. -vm_setup --os="$VM_IMAGE" --disk-type=spdk_vhost_scsi --disks="VhostScsi0" --force=3 --vhost-name=3 +vm_setup --os="$VM_IMAGE" --disk-type=spdk_vhost_scsi --disks="VhostScsi0" --force=3 --vhost-name=3 vm_run 3 diff --git a/test/nvmf/target/rpc.sh b/test/nvmf/target/rpc.sh index ef73130598..ad42ec9ce6 100755 --- a/test/nvmf/target/rpc.sh +++ b/test/nvmf/target/rpc.sh @@ -7,16 +7,14 @@ source $rootdir/test/nvmf/common.sh rpc_py="$rootdir/scripts/rpc.py" -function jcount() -{ - local filter=$1 - jq "$filter" | wc -l +function jcount() { + local filter=$1 + jq "$filter" | wc -l } -function jsum() -{ - local filter=$1 - jq "$filter" | awk '{s+=$1}END{print s}' +function jsum() { + local filter=$1 + jq "$filter" | awk '{s+=$1}END{print s}' } nvmftestinit @@ -35,11 +33,11 @@ stats=$($rpc_py nvmf_get_stats) [ "0" -eq $(jsum .poll_groups[].io_qpairs <<< "$stats") ] # Transport statistics is currently implemented for RDMA only if [ 'rdma' == $TEST_TRANSPORT ]; then - # Expect RDMA transport and some devices - [ "1" -eq $(jcount .poll_groups[0].transports[].trtype <<< "$stats") ] - transport_type=$(jq -r .poll_groups[0].transports[0].trtype <<< "$stats") - [ "${transport_type,,}" == "${TEST_TRANSPORT,,}" ] - [ "0" -lt $(jcount .poll_groups[0].transports[0].devices[].name <<< "$stats") ] + # Expect RDMA transport and some devices + [ "1" -eq $(jcount .poll_groups[0].transports[].trtype <<< "$stats") ] + transport_type=$(jq -r .poll_groups[0].transports[0].trtype <<< "$stats") + [ "${transport_type,,}" == "${TEST_TRANSPORT,,}" ] + [ "0" -lt $(jcount .poll_groups[0].transports[0].devices[].name <<< "$stats") ] fi # set times for subsystem construct/delete @@ -82,8 +80,7 @@ nvme disconnect -n nqn.2016-06.io.spdk:cnode1 $rpc_py nvmf_delete_subsystem nqn.2016-06.io.spdk:cnode1 # do frequent add delete of namespaces with different nsid. -for i in $(seq 1 $times) -do +for i in $(seq 1 $times); do $rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -s $NVMF_SERIAL $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc1 -n 5 @@ -100,8 +97,7 @@ do done # do frequent add delete. -for i in $(seq 1 $times) -do +for i in $(seq 1 $times); do $rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -s $NVMF_SERIAL $rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc1 @@ -118,9 +114,9 @@ stats=$($rpc_py nvmf_get_stats) [ "0" -lt $(jsum .poll_groups[].io_qpairs <<< "$stats") ] # Transport statistics is currently implemented for RDMA only if [ 'rdma' == $TEST_TRANSPORT ]; then - # Expect non-zero completions and request latencies accumulated - [ "0" -lt $(jsum .poll_groups[].transports[].devices[].completions <<< "$stats") ] - [ "0" -lt $(jsum .poll_groups[].transports[].devices[].request_latency <<< "$stats") ] + # Expect non-zero completions and request latencies accumulated + [ "0" -lt $(jsum .poll_groups[].transports[].devices[].completions <<< "$stats") ] + [ "0" -lt $(jsum .poll_groups[].transports[].devices[].request_latency <<< "$stats") ] fi trap - SIGINT SIGTERM EXIT diff --git a/test/nvmf/target/shutdown.sh b/test/nvmf/target/shutdown.sh index 656f81a4e0..fb084080eb 100755 --- a/test/nvmf/target/shutdown.sh +++ b/test/nvmf/target/shutdown.sh @@ -59,7 +59,7 @@ function waitforio() { fi local ret=1 local i - for (( i = 10; i != 0; i-- )); do + for ((i = 10; i != 0; i--)); do read_io_count=$($rpc_py -s $1 bdev_get_iostat -b $2 | jq -r '.bdevs[0].num_read_ops') # A few I/O will happen during initial examine. So wait until at least 100 I/O # have completed to know that bdevperf is really generating the I/O. @@ -73,7 +73,7 @@ function waitforio() { } # Test 1: Kill the initiator unexpectedly with no I/O outstanding -function nvmf_shutdown_tc1 { +function nvmf_shutdown_tc1() { starttarget # Run bdev_svc, which connects but does not issue I/O @@ -97,7 +97,7 @@ function nvmf_shutdown_tc1 { } # Test 2: Kill initiator unexpectedly with I/O outstanding -function nvmf_shutdown_tc2 { +function nvmf_shutdown_tc2() { starttarget # Run bdevperf @@ -119,11 +119,11 @@ function nvmf_shutdown_tc2 { } # Test 3: Kill the target unexpectedly with I/O outstanding -function nvmf_shutdown_tc3 { +function nvmf_shutdown_tc3() { starttarget # Run bdevperf - $rootdir/test/bdev/bdevperf/bdevperf -r /var/tmp/bdevperf.sock --json <(gen_nvmf_target_json "${num_subsystems[@]}") -q 64 -o 65536 -w verify -t 10 & + $rootdir/test/bdev/bdevperf/bdevperf -r /var/tmp/bdevperf.sock --json <(gen_nvmf_target_json "${num_subsystems[@]}") -q 64 -o 65536 -w verify -t 10 & perfpid=$! waitforlisten $perfpid /var/tmp/bdevperf.sock $rpc_py -s /var/tmp/bdevperf.sock framework_wait_init diff --git a/test/ocf/common.sh b/test/ocf/common.sh index 970ec05753..0612367907 100644 --- a/test/ocf/common.sh +++ b/test/ocf/common.sh @@ -1,4 +1,3 @@ - source $rootdir/scripts/common.sh source $rootdir/test/common/autotest_common.sh @@ -11,8 +10,7 @@ function nvme_cfg() { echo "$ocf_nvme_cfg" } -function clear_nvme() -{ +function clear_nvme() { mapfile -t bdf < <(iter_all_pci_class_code 01 08 02) # Clear metadata on NVMe device diff --git a/test/ocf/integrity/fio-modes.sh b/test/ocf/integrity/fio-modes.sh index 6bbc38356d..64bee994ea 100755 --- a/test/ocf/integrity/fio-modes.sh +++ b/test/ocf/integrity/fio-modes.sh @@ -5,11 +5,11 @@ rootdir=$(readlink -f $curdir/../../..) source $rootdir/test/ocf/common.sh -function fio_verify(){ +function fio_verify() { fio_bdev $curdir/test.fio --aux-path=/tmp/ --ioengine=spdk_bdev "$@" } -function cleanup(){ +function cleanup() { rm -f $curdir/modes.conf } diff --git a/test/ocf/management/create-destruct.sh b/test/ocf/management/create-destruct.sh index 044581eaf4..99d3f7483e 100755 --- a/test/ocf/management/create-destruct.sh +++ b/test/ocf/management/create-destruct.sh @@ -6,13 +6,12 @@ source $rootdir/test/common/autotest_common.sh rpc_py=$rootdir/scripts/rpc.py -function bdev_check_claimed() -{ - if [ "$($rpc_py get_bdevs -b "$@" | jq '.[0].claimed')" = "true" ]; then - return 0; - else - return 1; - fi +function bdev_check_claimed() { + if [ "$($rpc_py get_bdevs -b "$@" | jq '.[0].claimed')" = "true" ]; then + return 0 + else + return 1 + fi } $rootdir/app/iscsi_tgt/iscsi_tgt & @@ -34,13 +33,13 @@ $rpc_py bdev_ocf_get_bdevs NonExisting | jq -e \ '.[0] | .name == "PartCache"' if ! bdev_check_claimed Malloc0; then - >&2 echo "Base device expected to be claimed now" + echo >&2 "Base device expected to be claimed now" exit 1 fi $rpc_py bdev_ocf_delete PartCache if bdev_check_claimed Malloc0; then - >&2 echo "Base device is not expected to be claimed now" + echo >&2 "Base device is not expected to be claimed now" exit 1 fi @@ -50,34 +49,34 @@ $rpc_py bdev_ocf_get_bdevs FullCache | jq -e \ '.[0] | .started and .cache.attached and .core.attached' if ! (bdev_check_claimed Malloc0 && bdev_check_claimed Malloc1); then - >&2 echo "Base devices expected to be claimed now" + echo >&2 "Base devices expected to be claimed now" exit 1 fi $rpc_py bdev_ocf_delete FullCache if bdev_check_claimed Malloc0 && bdev_check_claimed Malloc1; then - >&2 echo "Base devices are not expected to be claimed now" + echo >&2 "Base devices are not expected to be claimed now" exit 1 fi $rpc_py bdev_ocf_create HotCache wt Malloc0 Malloc1 if ! (bdev_check_claimed Malloc0 && bdev_check_claimed Malloc1); then - >&2 echo "Base devices expected to be claimed now" + echo >&2 "Base devices expected to be claimed now" exit 1 fi $rpc_py bdev_malloc_delete Malloc0 if bdev_check_claimed Malloc1; then - >&2 echo "Base device is not expected to be claimed now" + echo >&2 "Base device is not expected to be claimed now" exit 1 fi status=$($rpc_py get_bdevs) gone=$(echo $status | jq 'map(select(.name == "HotCache")) == []') if [[ $gone == false ]]; then - >&2 echo "OCF bdev is expected to unregister" + echo >&2 "OCF bdev is expected to unregister" exit 1 fi diff --git a/test/ocf/management/multicore.sh b/test/ocf/management/multicore.sh index 47be26d2d9..f01f4c2f50 100755 --- a/test/ocf/management/multicore.sh +++ b/test/ocf/management/multicore.sh @@ -7,15 +7,13 @@ source $rootdir/test/common/autotest_common.sh rpc_py=$rootdir/scripts/rpc.py spdk_pid='?' -function start_spdk() -{ +function start_spdk() { $rootdir/app/iscsi_tgt/iscsi_tgt & spdk_pid=$! trap 'killprocess $spdk_pid; exit 1' SIGINT SIGTERM EXIT waitforlisten $spdk_pid } -function stop_spdk() -{ +function stop_spdk() { killprocess $spdk_pid trap - SIGINT SIGTERM EXIT } @@ -24,8 +22,8 @@ start_spdk # Hotplug case -$rpc_py bdev_malloc_create 1 512 -b Core0 -$rpc_py bdev_malloc_create 1 512 -b Core1 +$rpc_py bdev_malloc_create 1 512 -b Core0 +$rpc_py bdev_malloc_create 1 512 -b Core1 $rpc_py bdev_ocf_create C1 wt Cache Core0 $rpc_py bdev_ocf_create C2 wt Cache Core1 @@ -43,7 +41,7 @@ waitforbdev C2 # Detaching cores -$rpc_py bdev_ocf_delete C2 +$rpc_py bdev_ocf_delete C2 $rpc_py bdev_ocf_get_bdevs C1 | jq -e \ '.[0] | .started' @@ -62,7 +60,7 @@ start_spdk $rpc_py bdev_malloc_create 101 512 -b Cache $rpc_py bdev_malloc_create 101 512 -b Malloc -$rpc_py bdev_malloc_create 1 512 -b Core +$rpc_py bdev_malloc_create 1 512 -b Core $rpc_py bdev_ocf_create C1 wt Cache Malloc $rpc_py bdev_ocf_create C2 wt Cache Core diff --git a/test/ocf/management/persistent-metadata.sh b/test/ocf/management/persistent-metadata.sh index b3ebb8330c..73a270b481 100755 --- a/test/ocf/management/persistent-metadata.sh +++ b/test/ocf/management/persistent-metadata.sh @@ -22,8 +22,8 @@ waitforlisten $spdk_pid # Create ocf on persistent storage -$rpc_py bdev_ocf_create ocfWT wt Nvme0n1p0 Nvme0n1p1 -$rpc_py bdev_ocf_create ocfPT pt Nvme0n1p2 Nvme0n1p3 +$rpc_py bdev_ocf_create ocfWT wt Nvme0n1p0 Nvme0n1p1 +$rpc_py bdev_ocf_create ocfPT pt Nvme0n1p2 Nvme0n1p3 $rpc_py bdev_ocf_create ocfWB0 wb Nvme0n1p4 Nvme0n1p5 $rpc_py bdev_ocf_create ocfWB1 wb Nvme0n1p4 Nvme0n1p6 diff --git a/test/ocf/management/remove.sh b/test/ocf/management/remove.sh index 84cf087067..9fcf889f29 100755 --- a/test/ocf/management/remove.sh +++ b/test/ocf/management/remove.sh @@ -23,7 +23,7 @@ waitforlisten $spdk_pid # Create ocf on persistent storage -$rpc_py bdev_ocf_create ocfWT wt aio0 aio1 +$rpc_py bdev_ocf_create ocfWT wt aio0 aio1 # Check that ocfWT was created properly diff --git a/test/openstack/install_devstack.sh b/test/openstack/install_devstack.sh index 2b90ac7af8..cb9c9acf8b 100755 --- a/test/openstack/install_devstack.sh +++ b/test/openstack/install_devstack.sh @@ -3,9 +3,11 @@ testdir=$(readlink -f $(dirname $0)) rootdir=$(readlink -f $testdir/../..) -function usage() -{ - [[ -n $2 ]] && ( echo "$2"; echo ""; ) +function usage() { + [[ -n $2 ]] && ( + echo "$2" + echo "" + ) echo "Devstack installation script" echo "Usage: $(basename $1) [OPTIONS]" echo "--branch=BRANCH Define which version of openstack" @@ -15,18 +17,17 @@ function usage() exit 0 } - branch="master" while getopts 'h-:' optchar; do case "$optchar" in -) - case "$OPTARG" in - help) usage $0 ;; - branch=*) branch="${OPTARG#*=}" ;; - esac - ;; - h) usage $0 ;; - *) usage $0 "Invalid argument '$OPTARG'" + case "$OPTARG" in + help) usage $0 ;; + branch=*) branch="${OPTARG#*=}" ;; + esac + ;; + h) usage $0 ;; + *) usage $0 "Invalid argument '$OPTARG'" ;; esac done diff --git a/test/openstack/run_openstack_tests.sh b/test/openstack/run_openstack_tests.sh index 38ccf9f6ea..01a7d8e1a2 100755 --- a/test/openstack/run_openstack_tests.sh +++ b/test/openstack/run_openstack_tests.sh @@ -9,15 +9,15 @@ TEST_TRANSPORT='rdma' nvmftestinit -function finish_test { +function finish_test() { { - "$rpc_py" bdev_lvol_delete_lvstore -l lvs0 - kill -9 $rpc_proxy_pid - rm "$testdir/conf.json" + "$rpc_py" bdev_lvol_delete_lvstore -l lvs0 + kill -9 $rpc_proxy_pid + rm "$testdir/conf.json" } || : } -cat <<-JSON >"$testdir/conf.json" +cat <<- JSON > "$testdir/conf.json" {"subsystems":[ $("$rootdir/scripts/gen_nvme.sh" --json) ]} diff --git a/test/pmem/common.sh b/test/pmem/common.sh index 4c6b6077d1..73edd2c4b1 100644 --- a/test/pmem/common.sh +++ b/test/pmem/common.sh @@ -1,8 +1,7 @@ # Prints error message and return error code, closes vhost app and remove # pmem pool file # input: error message, error code -function error() -{ +function error() { local error_code=${2:-1} echo "===========" echo -e "ERROR: $1" @@ -16,8 +15,7 @@ function error() # check if there is pool file & remove it # input: path to pool file # default: $default_pool_file -function pmem_clean_pool_file() -{ +function pmem_clean_pool_file() { local pool_file=${1:-$default_pool_file} if [ -f $pool_file ]; then @@ -29,8 +27,7 @@ function pmem_clean_pool_file() # create new pmem file # input: path to pool file, size in MB, block_size # default: $default_pool_file 32 512 -function pmem_create_pool_file() -{ +function pmem_create_pool_file() { local pool_file=${1:-$default_pool_file} local size=${2:-32} local block_size=${3:-512} @@ -46,8 +43,7 @@ function pmem_create_pool_file() fi } -function pmem_unmount_ramspace -{ +function pmem_unmount_ramspace() { if [ -d "$testdir/ramspace" ]; then if mount | grep -q "$testdir/ramspace"; then umount $testdir/ramspace @@ -57,16 +53,14 @@ function pmem_unmount_ramspace fi } -function pmem_print_tc_name -{ +function pmem_print_tc_name() { echo "" echo "===============================================================" echo "Now running: $1" echo "===============================================================" } -function vhost_start() -{ +function vhost_start() { local vhost_pid $rootdir/app/vhost/vhost & @@ -76,8 +70,7 @@ function vhost_start() waitforlisten $vhost_pid } -function vhost_kill() -{ +function vhost_kill() { local vhost_pid_file="$testdir/vhost.pid" local vhost_pid vhost_pid="$(cat $vhost_pid_file)" diff --git a/test/pmem/pmem.sh b/test/pmem/pmem.sh index e59ab38ef5..bca8b4db7c 100755 --- a/test/pmem/pmem.sh +++ b/test/pmem/pmem.sh @@ -19,9 +19,11 @@ default_pool_file="$testdir/pool_file" obj_pool_file="$testdir/obj_pool_file" bdev_name=pmem0 -function usage() -{ - [[ -n $2 ]] && ( echo "$2"; echo ""; ) +function usage() { + [[ -n $2 ]] && ( + echo "$2" + echo "" + ) echo "Shortcut script for automated RPC tests for PMEM" echo echo "Usage: $(basename $1) [OPTIONS]" @@ -40,20 +42,35 @@ function usage() while getopts 'xh-:' optchar; do case "$optchar" in -) - case "$OPTARG" in - help) usage $0 ;; - info) test_info=true; test_all=false;; - create) test_create=true; test_all=false;; - delete) test_delete=true; test_all=false;; - construct_bdev) test_construct_bdev=true; test_all=false;; - delete_bdev) test_delete_bdev=true; test_all=false;; - all) test_all_get=true;; - *) usage $0 "Invalid argument '$OPTARG'" ;; - esac - ;; - h) usage $0 ;; - x) enable_script_debug=true ;; - *) usage $0 "Invalid argument '$OPTARG'" + case "$OPTARG" in + help) usage $0 ;; + info) + test_info=true + test_all=false + ;; + create) + test_create=true + test_all=false + ;; + delete) + test_delete=true + test_all=false + ;; + construct_bdev) + test_construct_bdev=true + test_all=false + ;; + delete_bdev) + test_delete_bdev=true + test_all=false + ;; + all) test_all_get=true ;; + *) usage $0 "Invalid argument '$OPTARG'" ;; + esac + ;; + h) usage $0 ;; + x) enable_script_debug=true ;; + *) usage $0 "Invalid argument '$OPTARG'" ;; esac done @@ -69,8 +86,7 @@ fi #================================================ # bdev_pmem_get_pool_info tests #================================================ -function bdev_pmem_get_pool_info_tc1() -{ +function bdev_pmem_get_pool_info_tc1() { pmem_print_tc_name ${FUNCNAME[0]} if $rpc_py bdev_pmem_get_pool_info; then @@ -80,8 +96,7 @@ function bdev_pmem_get_pool_info_tc1() return 0 } -function bdev_pmem_get_pool_info_tc2() -{ +function bdev_pmem_get_pool_info_tc2() { pmem_print_tc_name ${FUNCNAME[0]} if $rpc_py bdev_pmem_get_pool_info $rootdir/non/existing/path/non_existent_file; then @@ -91,8 +106,7 @@ function bdev_pmem_get_pool_info_tc2() return 0 } -function bdev_pmem_get_pool_info_tc3() -{ +function bdev_pmem_get_pool_info_tc3() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file $obj_pool_file @@ -113,8 +127,7 @@ function bdev_pmem_get_pool_info_tc3() return 0 } -function bdev_pmem_get_pool_info_tc4() -{ +function bdev_pmem_get_pool_info_tc4() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file @@ -130,8 +143,7 @@ function bdev_pmem_get_pool_info_tc4() #================================================ # bdev_pmem_create_pool tests #================================================ -function bdev_pmem_create_pool_tc1() -{ +function bdev_pmem_create_pool_tc1() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file @@ -159,12 +171,11 @@ function bdev_pmem_create_pool_tc1() return 0 } -function bdev_pmem_create_pool_tc2() -{ +function bdev_pmem_create_pool_tc2() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file - if $rpc_py bdev_pmem_create_pool $rootdir/non/existing/path/non_existent_file 32 512; then + if $rpc_py bdev_pmem_create_pool $rootdir/non/existing/path/non_existent_file 32 512; then error "Mem pool file created with incorrect path!" fi @@ -176,8 +187,7 @@ function bdev_pmem_create_pool_tc2() return 0 } -function bdev_pmem_create_pool_tc3() -{ +function bdev_pmem_create_pool_tc3() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file @@ -205,8 +215,7 @@ function bdev_pmem_create_pool_tc3() return 0 } -function bdev_pmem_create_pool_tc4() -{ +function bdev_pmem_create_pool_tc4() { pmem_print_tc_name ${FUNCNAME[0]} pmem_unmount_ramspace @@ -236,8 +245,7 @@ function bdev_pmem_create_pool_tc4() return 0 } -function bdev_pmem_create_pool_tc5() -{ +function bdev_pmem_create_pool_tc5() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file local pmem_block_size @@ -278,14 +286,12 @@ function bdev_pmem_create_pool_tc5() return 0 } -function bdev_pmem_create_pool_tc6() -{ +function bdev_pmem_create_pool_tc6() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file local created_pmem_block_size - for i in 511 512 1024 2048 4096 131072 262144 - do + for i in 511 512 1024 2048 4096 131072 262144; do if ! $rpc_py bdev_pmem_create_pool $default_pool_file 256 $i; then error "Failed to create pmem pool!" fi @@ -307,8 +313,7 @@ function bdev_pmem_create_pool_tc6() return 0 } -function bdev_pmem_create_pool_tc7() -{ +function bdev_pmem_create_pool_tc7() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file @@ -316,7 +321,7 @@ function bdev_pmem_create_pool_tc7() error "Created pmem pool with invalid size!" fi - if $rpc_py bdev_pmem_get_pool_info $default_pool_file; then + if $rpc_py bdev_pmem_get_pool_info $default_pool_file; then error "Pmem file shouldn' exist!" fi @@ -324,8 +329,7 @@ function bdev_pmem_create_pool_tc7() return 0 } -function bdev_pmem_create_pool_tc8() -{ +function bdev_pmem_create_pool_tc8() { pmem_print_tc_name "bdev_pmem_create_pool_tc8" pmem_clean_pool_file @@ -333,7 +337,7 @@ function bdev_pmem_create_pool_tc8() error "Created pmem pool with invalid block number!" fi - if $rpc_py bdev_pmem_get_pool_info $default_pool_file; then + if $rpc_py bdev_pmem_get_pool_info $default_pool_file; then error "Pmem file shouldn' exist!" fi @@ -341,8 +345,7 @@ function bdev_pmem_create_pool_tc8() return 0 } -function bdev_pmem_create_pool_tc9() -{ +function bdev_pmem_create_pool_tc9() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file @@ -369,8 +372,7 @@ function bdev_pmem_create_pool_tc9() #================================================ # bdev_pmem_delete_pool tests #================================================ -function bdev_pmem_delete_pool_tc1() -{ +function bdev_pmem_delete_pool_tc1() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file @@ -381,8 +383,7 @@ function bdev_pmem_delete_pool_tc1() return 0 } -function bdev_pmem_delete_pool_tc2() -{ +function bdev_pmem_delete_pool_tc2() { pmem_print_tc_name "bdev_pmem_delete_pool_tc2" pmem_clean_pool_file $obj_pool_file @@ -403,8 +404,7 @@ function bdev_pmem_delete_pool_tc2() return 0 } -function bdev_pmem_delete_pool_tc3() -{ +function bdev_pmem_delete_pool_tc3() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file @@ -424,8 +424,7 @@ function bdev_pmem_delete_pool_tc3() return 0 } -function bdev_pmem_delete_pool_tc4() -{ +function bdev_pmem_delete_pool_tc4() { pmem_print_tc_name ${FUNCNAME[0]} bdev_pmem_delete_pool_tc3 @@ -439,8 +438,7 @@ function bdev_pmem_delete_pool_tc4() #================================================ # bdev_pmem_create tests #================================================ -function bdev_pmem_create_tc1() -{ +function bdev_pmem_create_tc1() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file @@ -453,8 +451,7 @@ function bdev_pmem_create_tc1() return 0 } -function bdev_pmem_create_tc2() -{ +function bdev_pmem_create_tc2() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file @@ -471,8 +468,7 @@ function bdev_pmem_create_tc2() return 0 } -function bdev_pmem_create_tc3() -{ +function bdev_pmem_create_tc3() { pmem_print_tc_name ${FUNCNAME[0]} truncate -s 32M $rootdir/test/pmem/random_file @@ -488,8 +484,7 @@ function bdev_pmem_create_tc3() return 0 } -function bdev_pmem_create_tc4() -{ +function bdev_pmem_create_tc4() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file $obj_pool_file @@ -510,8 +505,7 @@ function bdev_pmem_create_tc4() return 0 } -function bdev_pmem_create_tc5() -{ +function bdev_pmem_create_tc5() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file pmem_create_pool_file @@ -541,8 +535,7 @@ function bdev_pmem_create_tc5() return 0 } -function bdev_pmem_create_tc6() -{ +function bdev_pmem_create_tc6() { pmem_print_tc_name ${FUNCNAME[0]} local pmem_bdev_name pmem_clean_pool_file @@ -560,7 +553,7 @@ function bdev_pmem_create_tc6() error "Pmem bdev not found!" fi - if $rpc_py bdev_pmem_create -n $bdev_name $default_pool_file; then + if $rpc_py bdev_pmem_create -n $bdev_name $default_pool_file; then error "Constructed pmem bdev with occupied path!" fi @@ -579,8 +572,7 @@ function bdev_pmem_create_tc6() #================================================ # bdev_pmem_delete tests #================================================ -function delete_bdev_tc1() -{ +function delete_bdev_tc1() { pmem_print_tc_name ${FUNCNAME[0]} local pmem_bdev_name local bdevs_names @@ -612,8 +604,7 @@ function delete_bdev_tc1() return 0 } -function delete_bdev_tc2() -{ +function delete_bdev_tc2() { pmem_print_tc_name ${FUNCNAME[0]} pmem_clean_pool_file pmem_create_pool_file $default_pool_file 256 512 diff --git a/test/spdkcli/tcp.sh b/test/spdkcli/tcp.sh index 1d9f7f7eb8..a9b6237cd1 100755 --- a/test/spdkcli/tcp.sh +++ b/test/spdkcli/tcp.sh @@ -26,7 +26,7 @@ function waitfortcplisten() { xtrace_disable local ret=0 local i - for (( i = 40; i != 0; i-- )); do + for ((i = 40; i != 0; i--)); do # if the process is no longer running, then exit the script # since it means the application crashed if ! kill -s 0 $1; then @@ -35,7 +35,7 @@ function waitfortcplisten() { break fi - if $rootdir/scripts/rpc.py -t 1 -s "$ipaddr" -p $port rpc_get_methods &>/dev/null; then + if $rootdir/scripts/rpc.py -t 1 -s "$ipaddr" -p $port rpc_get_methods &> /dev/null; then break fi @@ -43,7 +43,7 @@ function waitfortcplisten() { done xtrace_restore - if (( i == 0 )); then + if ((i == 0)); then echo "ERROR: timeout while waiting for process (pid: $1) to start listening on '$ipaddr:$port'" ret=1 fi diff --git a/test/spdkcli/virtio.sh b/test/spdkcli/virtio.sh index c1f9e1cb59..a707d9dced 100755 --- a/test/spdkcli/virtio.sh +++ b/test/spdkcli/virtio.sh @@ -36,10 +36,10 @@ $spdkcli_job "'/vhost/scsi create sample_scsi' 'sample_scsi' True timing_exit spdkcli_create_virtio_pci_config timing_enter spdkcli_check_match -if [ -n "$pci_blk" ] && [ -n "$pci_scsi" ]; then - MATCH_FILE="spdkcli_virtio_pci.test" - SPDKCLI_BRANCH="/bdevs" - check_match +if [ -n "$pci_blk" ] && [ -n "$pci_scsi" ]; then + MATCH_FILE="spdkcli_virtio_pci.test" + SPDKCLI_BRANCH="/bdevs" + check_match fi timing_exit spdkcli_check_match diff --git a/test/unit/unittest.sh b/test/unit/unittest.sh index bd3cb62b60..cbca2ee7aa 100755 --- a/test/unit/unittest.sh +++ b/test/unit/unittest.sh @@ -12,7 +12,7 @@ source "$rootdir/test/common/autotest_common.sh" cd "$rootdir" -function unittest_bdev { +function unittest_bdev() { $valgrind $testdir/lib/bdev/bdev.c/bdev_ut $valgrind $testdir/lib/bdev/bdev_ocssd.c/bdev_ocssd_ut $valgrind $testdir/lib/bdev/raid/bdev_raid.c/bdev_raid_ut @@ -25,7 +25,7 @@ function unittest_bdev { $valgrind $testdir/lib/bdev/mt/bdev.c/bdev_ut } -function unittest_blob { +function unittest_blob() { $valgrind $testdir/lib/blob/blob.c/blob_ut $valgrind $testdir/lib/blobfs/tree.c/tree_ut $valgrind $testdir/lib/blobfs/blobfs_async_ut/blobfs_async_ut @@ -34,13 +34,13 @@ function unittest_blob { $valgrind $testdir/lib/blobfs/blobfs_bdev.c/blobfs_bdev_ut } -function unittest_event { +function unittest_event() { $valgrind $testdir/lib/event/subsystem.c/subsystem_ut $valgrind $testdir/lib/event/app.c/app_ut $valgrind $testdir/lib/event/reactor.c/reactor_ut } -function unittest_ftl { +function unittest_ftl() { $valgrind $testdir/lib/ftl/ftl_ppa/ftl_ppa_ut $valgrind $testdir/lib/ftl/ftl_band.c/ftl_band_ut $valgrind $testdir/lib/ftl/ftl_reloc.c/ftl_reloc_ut @@ -49,7 +49,7 @@ function unittest_ftl { $valgrind $testdir/lib/ftl/ftl_io.c/ftl_io_ut } -function unittest_iscsi { +function unittest_iscsi() { $valgrind $testdir/lib/iscsi/conn.c/conn_ut $valgrind $testdir/lib/iscsi/param.c/param_ut $valgrind $testdir/lib/iscsi/tgt_node.c/tgt_node_ut $testdir/lib/iscsi/tgt_node.c/tgt_node.conf @@ -58,14 +58,14 @@ function unittest_iscsi { $valgrind $testdir/lib/iscsi/portal_grp.c/portal_grp_ut $testdir/lib/iscsi/portal_grp.c/portal_grp.conf } -function unittest_json { +function unittest_json() { $valgrind $testdir/lib/json/json_parse.c/json_parse_ut $valgrind $testdir/lib/json/json_util.c/json_util_ut $valgrind $testdir/lib/json/json_write.c/json_write_ut $valgrind $testdir/lib/jsonrpc/jsonrpc_server.c/jsonrpc_server_ut } -function unittest_nvme { +function unittest_nvme() { $valgrind $testdir/lib/nvme/nvme.c/nvme_ut $valgrind $testdir/lib/nvme/nvme_ctrlr.c/nvme_ctrlr_ut $valgrind $testdir/lib/nvme/nvme_ctrlr_cmd.c/nvme_ctrlr_cmd_ut @@ -81,7 +81,7 @@ function unittest_nvme { $valgrind $testdir/lib/nvme/nvme_uevent.c/nvme_uevent_ut } -function unittest_nvmf { +function unittest_nvmf() { $valgrind $testdir/lib/nvmf/ctrlr.c/ctrlr_ut $valgrind $testdir/lib/nvmf/ctrlr_bdev.c/ctrlr_bdev_ut $valgrind $testdir/lib/nvmf/ctrlr_discovery.c/ctrlr_discovery_ut @@ -89,7 +89,7 @@ function unittest_nvmf { $valgrind $testdir/lib/nvmf/tcp.c/tcp_ut } -function unittest_scsi { +function unittest_scsi() { $valgrind $testdir/lib/scsi/dev.c/dev_ut $valgrind $testdir/lib/scsi/lun.c/lun_ut $valgrind $testdir/lib/scsi/scsi.c/scsi_ut @@ -97,12 +97,12 @@ function unittest_scsi { $valgrind $testdir/lib/scsi/scsi_pr.c/scsi_pr_ut } -function unittest_sock { - $valgrind $testdir/lib/sock/sock.c/sock_ut - $valgrind $testdir/lib/sock/posix.c/posix_ut +function unittest_sock() { + $valgrind $testdir/lib/sock/sock.c/sock_ut + $valgrind $testdir/lib/sock/posix.c/posix_ut } -function unittest_util { +function unittest_util() { $valgrind $testdir/lib/util/base64.c/base64_ut $valgrind $testdir/lib/util/bit_array.c/bit_array_ut $valgrind $testdir/lib/util/cpuset.c/cpuset_ut diff --git a/test/vhost/common.sh b/test/vhost/common.sh index f37d5ecf6c..4641f84c2b 100644 --- a/test/vhost/common.sh +++ b/test/vhost/common.sh @@ -25,8 +25,7 @@ mkdir -p $TARGET_DIR # source $rootdir/test/vhost/common/autotest.config -function vhosttestinit() -{ +function vhosttestinit() { if [ "$TEST_MODE" == "iso" ]; then $rootdir/scripts/setup.sh @@ -48,15 +47,13 @@ function vhosttestinit() fi } -function vhosttestfini() -{ +function vhosttestfini() { if [ "$TEST_MODE" == "iso" ]; then $rootdir/scripts/setup.sh reset fi } -function message() -{ +function message() { local verbose_out if ! $SPDK_VHOST_VERBOSE; then verbose_out="" @@ -71,16 +68,14 @@ function message() echo -e "${msg_type}${verbose_out}: $*" } -function fail() -{ +function fail() { echo "===========" >&2 message "FAIL" "$@" >&2 echo "===========" >&2 exit 1 } -function error() -{ +function error() { echo "===========" >&2 message "ERROR" "$@" >&2 echo "===========" >&2 @@ -88,18 +83,15 @@ function error() false } -function warning() -{ +function warning() { message "WARN" "$@" >&2 } -function notice() -{ +function notice() { message "INFO" "$@" } -function get_vhost_dir() -{ +function get_vhost_dir() { local vhost_name="$1" if [[ -z "$vhost_name" ]]; then @@ -110,8 +102,7 @@ function get_vhost_dir() echo "$TARGET_DIR/${vhost_name}" } -function vhost_run() -{ +function vhost_run() { local vhost_name="$1" local run_gen_nvme=true @@ -150,7 +141,8 @@ function vhost_run() notice "Command: $cmd" timing_enter vhost_start - cd $vhost_dir; $cmd & + cd $vhost_dir + $cmd & vhost_pid=$! echo $vhost_pid > $vhost_pid_file @@ -158,16 +150,14 @@ function vhost_run() waitforlisten "$vhost_pid" "$vhost_dir/rpc.sock" #do not generate nvmes if pci access is disabled if [[ "$cmd" != *"--no-pci"* ]] && [[ "$cmd" != *"-u"* ]] && $run_gen_nvme; then - $rootdir/scripts/gen_nvme.sh "--json" | $rootdir/scripts/rpc.py\ - -s $vhost_dir/rpc.sock load_subsystem_config + $rootdir/scripts/gen_nvme.sh "--json" | $rootdir/scripts/rpc.py -s $vhost_dir/rpc.sock load_subsystem_config fi notice "vhost started - pid=$vhost_pid" timing_exit vhost_start } -function vhost_kill() -{ +function vhost_kill() { local rc=0 local vhost_name="$1" @@ -192,7 +182,7 @@ function vhost_kill() if kill -INT $vhost_pid > /dev/null; then notice "sent SIGINT to vhost app - waiting 60 seconds to exit" - for ((i=0; i<60; i++)); do + for ((i = 0; i < 60; i++)); do if kill -0 $vhost_pid; then echo "." sleep 1 @@ -227,8 +217,7 @@ function vhost_kill() return $rc } -function vhost_rpc -{ +function vhost_rpc() { local vhost_name="$1" if [[ -z "$vhost_name" ]]; then @@ -244,20 +233,18 @@ function vhost_rpc # Mgmt functions ### -function assert_number() -{ +function assert_number() { [[ "$1" =~ [0-9]+ ]] && return 0 error "Invalid or missing paramter: need number but got '$1'" - return 1; + return 1 } # Run command on vm with given password # First argument - vm number # Second argument - ssh password for vm # -function vm_sshpass() -{ +function vm_sshpass() { vm_num_is_valid $1 || return 1 local ssh_cmd @@ -271,32 +258,27 @@ function vm_sshpass() $ssh_cmd "$@" } - # Helper to validate VM number # param $1 VM number # -function vm_num_is_valid() -{ +function vm_num_is_valid() { [[ "$1" =~ ^[0-9]+$ ]] && return 0 error "Invalid or missing paramter: vm number '$1'" - return 1; + return 1 } - # Print network socket for given VM number # param $1 virtual machine number # -function vm_ssh_socket() -{ +function vm_ssh_socket() { vm_num_is_valid $1 || return 1 local vm_dir="$VM_DIR/$1" cat $vm_dir/ssh_socket } -function vm_fio_socket() -{ +function vm_fio_socket() { vm_num_is_valid $1 || return 1 local vm_dir="$VM_DIR/$1" @@ -306,8 +288,7 @@ function vm_fio_socket() # Execute command on given VM # param $1 virtual machine number # -function vm_exec() -{ +function vm_exec() { vm_num_is_valid $1 || return 1 local vm_num="$1" @@ -324,8 +305,7 @@ function vm_exec() # Execute scp command on given VM # param $1 virtual machine number # -function vm_scp() -{ +function vm_scp() { vm_num_is_valid $1 || return 1 local vm_num="$1" @@ -339,11 +319,9 @@ function vm_scp() "$@" } - # check if specified VM is running # param $1 VM num -function vm_is_running() -{ +function vm_is_running() { vm_num_is_valid $1 || return 1 local vm_dir="$VM_DIR/$1" @@ -370,8 +348,7 @@ function vm_is_running() # check if specified VM is running # param $1 VM num -function vm_os_booted() -{ +function vm_os_booted() { vm_num_is_valid $1 || return 1 local vm_dir="$VM_DIR/$1" @@ -380,21 +357,19 @@ function vm_os_booted() return 1 fi - if ! VM_SSH_OPTIONS="-o ControlMaster=no" vm_exec $1 "true" 2>/dev/null; then + if ! VM_SSH_OPTIONS="-o ControlMaster=no" vm_exec $1 "true" 2> /dev/null; then # Shutdown existing master. Ignore errors as it might not exist. - VM_SSH_OPTIONS="-O exit" vm_exec $1 "true" 2>/dev/null + VM_SSH_OPTIONS="-O exit" vm_exec $1 "true" 2> /dev/null return 1 fi return 0 } - # Shutdown given VM # param $1 virtual machine number # return non-zero in case of error. -function vm_shutdown() -{ +function vm_shutdown() { vm_num_is_valid $1 || return 1 local vm_dir="$VM_DIR/$1" if [[ ! -d "$vm_dir" ]]; then @@ -419,8 +394,7 @@ function vm_shutdown() # Kill given VM # param $1 virtual machine number # -function vm_kill() -{ +function vm_kill() { vm_num_is_valid $1 || return 1 local vm_dir="$VM_DIR/$1" @@ -445,10 +419,12 @@ function vm_kill() # List all VM numbers in VM_DIR # -function vm_list_all() -{ +function vm_list_all() { local vms - vms="$(shopt -s nullglob; echo $VM_DIR/[0-9]*)" + vms="$( + shopt -s nullglob + echo $VM_DIR/[0-9]* + )" if [[ -n "$vms" ]]; then basename --multiple $vms fi @@ -456,8 +432,7 @@ function vm_list_all() # Kills all VM in $VM_DIR # -function vm_kill_all() -{ +function vm_kill_all() { local vm for vm in $(vm_list_all); do vm_kill $vm @@ -468,8 +443,7 @@ function vm_kill_all() # Shutdown all VM in $VM_DIR # -function vm_shutdown_all() -{ +function vm_shutdown_all() { # XXX: temporarily disable to debug shutdown issue # xtrace_disable @@ -498,7 +472,7 @@ function vm_shutdown_all() return 0 fi - ((timeo-=1)) + ((timeo -= 1)) sleep 1 done @@ -507,8 +481,7 @@ function vm_shutdown_all() xtrace_restore } -function vm_setup() -{ +function vm_setup() { xtrace_disable local OPTIND optchar vm_num @@ -530,30 +503,31 @@ function vm_setup() while getopts ':-:' optchar; do case "$optchar" in -) - case "$OPTARG" in - os=*) os="${OPTARG#*=}" ;; - os-mode=*) os_mode="${OPTARG#*=}" ;; - qemu-args=*) qemu_args+=("${OPTARG#*=}") ;; - disk-type=*) disk_type_g="${OPTARG#*=}" ;; - read-only=*) read_only="${OPTARG#*=}" ;; - disks=*) IFS=":" read -ra disks <<<"${OPTARG#*=}" ;; - raw-cache=*) raw_cache=",cache${OPTARG#*=}" ;; - force=*) force_vm=${OPTARG#*=} ;; - memory=*) guest_memory=${OPTARG#*=} ;; - queue_num=*) queue_number=${OPTARG#*=} ;; - incoming=*) vm_incoming="${OPTARG#*=}" ;; - migrate-to=*) vm_migrate_to="${OPTARG#*=}" ;; - vhost-name=*) vhost_dir="$(get_vhost_dir ${OPTARG#*=})" ;; - spdk-boot=*) local boot_from="${OPTARG#*=}" ;; - *) - error "unknown argument $OPTARG" - return 1 - esac - ;; + case "$OPTARG" in + os=*) os="${OPTARG#*=}" ;; + os-mode=*) os_mode="${OPTARG#*=}" ;; + qemu-args=*) qemu_args+=("${OPTARG#*=}") ;; + disk-type=*) disk_type_g="${OPTARG#*=}" ;; + read-only=*) read_only="${OPTARG#*=}" ;; + disks=*) IFS=":" read -ra disks <<< "${OPTARG#*=}" ;; + raw-cache=*) raw_cache=",cache${OPTARG#*=}" ;; + force=*) force_vm=${OPTARG#*=} ;; + memory=*) guest_memory=${OPTARG#*=} ;; + queue_num=*) queue_number=${OPTARG#*=} ;; + incoming=*) vm_incoming="${OPTARG#*=}" ;; + migrate-to=*) vm_migrate_to="${OPTARG#*=}" ;; + vhost-name=*) vhost_dir="$(get_vhost_dir ${OPTARG#*=})" ;; + spdk-boot=*) local boot_from="${OPTARG#*=}" ;; + *) + error "unknown argument $OPTARG" + return 1 + ;; + esac + ;; *) error "vm_create Unknown param $OPTARG" return 1 - ;; + ;; esac done @@ -568,7 +542,7 @@ function vm_setup() local vm_dir="" set +x - for (( i=0; i<=256; i++)); do + for ((i = 0; i <= 256; i++)); do local vm_dir="$VM_DIR/$i" [[ ! -d $vm_dir ]] && break done @@ -633,14 +607,14 @@ function vm_setup() notice "TASK MASK: $task_mask" local cmd=(taskset -a -c "$task_mask" "$QEMU_BIN") - local vm_socket_offset=$(( 10000 + 100 * vm_num )) + local vm_socket_offset=$((10000 + 100 * vm_num)) - local ssh_socket=$(( vm_socket_offset + 0 )) - local fio_socket=$(( vm_socket_offset + 1 )) - local monitor_port=$(( vm_socket_offset + 2 )) - local migration_port=$(( vm_socket_offset + 3 )) - local gdbserver_socket=$(( vm_socket_offset + 4 )) - local vnc_socket=$(( 100 + vm_num )) + local ssh_socket=$((vm_socket_offset + 0)) + local fio_socket=$((vm_socket_offset + 1)) + local monitor_port=$((vm_socket_offset + 2)) + local migration_port=$((vm_socket_offset + 3)) + local gdbserver_socket=$((vm_socket_offset + 4)) + local vnc_socket=$((100 + vm_num)) local qemu_pid_file="$vm_dir/qemu.pid" local cpu_num=0 @@ -652,13 +626,13 @@ function vm_setup() for c in $cpu_list; do # if range is detected - count how many cpus if [[ $c =~ [0-9]+-[0-9]+ ]]; then - val=$((c-1)) + val=$((c - 1)) val=${val#-} else val=1 fi - cpu_num=$((cpu_num+val)) - queue_number=$((queue_number+val)) + cpu_num=$((cpu_num + val)) + queue_number=$((queue_number + val)) done if [ -z $queue_number ]; then @@ -687,9 +661,9 @@ function vm_setup() cmd+=(-device "ide-hd,drive=os_disk,bootindex=0") fi - if (( ${#disks[@]} == 0 )) && [[ $disk_type_g == virtio* ]]; then + if ((${#disks[@]} == 0)) && [[ $disk_type_g == virtio* ]]; then disks=("default_virtio.img") - elif (( ${#disks[@]} == 0 )); then + elif ((${#disks[@]} == 0)); then error "No disks defined, aborting" return 1 fi @@ -697,7 +671,7 @@ function vm_setup() for disk in "${disks[@]}"; do # Each disk can define its type in a form of a disk_name,type. The remaining parts # of the string are dropped. - IFS="," read -r disk disk_type _ <<<"$disk" + IFS="," read -r disk disk_type _ <<< "$disk" [[ -z $disk_type ]] && disk_type=$disk_type_g case $disk_type in @@ -712,13 +686,13 @@ function vm_setup() fi # Create disk file if it not exist or it is smaller than 1G - if { [[ -f $raw_disk ]] && [[ $(stat --printf="%s" $raw_disk) -lt $((1024 * 1024 * 1024)) ]]; } || \ - [[ ! -e $raw_disk ]]; then + if { [[ -f $raw_disk ]] && [[ $(stat --printf="%s" $raw_disk) -lt $((1024 * 1024 * 1024)) ]]; } \ + || [[ ! -e $raw_disk ]]; then if [[ $raw_disk =~ /dev/.* ]]; then error \ "ERROR: Virtio disk point to missing device ($raw_disk) -\n" \ " this is probably not what you want." - return 1 + return 1 fi notice "Creating Virtio disc $raw_disk" @@ -772,9 +746,9 @@ function vm_setup() return 1 fi - (( ${#qemu_args[@]} )) && cmd+=("${qemu_args[@]}") + ((${#qemu_args[@]})) && cmd+=("${qemu_args[@]}") notice "Saving to $vm_dir/run.sh" - cat <<-RUN >"$vm_dir/run.sh" + cat <<- RUN > "$vm_dir/run.sh" #!/bin/bash qemu_log () { echo "=== qemu.log ===" @@ -819,8 +793,7 @@ function vm_setup() [[ -z $vm_migrate_to ]] || ln -fs $VM_DIR/$vm_migrate_to $vm_dir/vm_migrate_to } -function vm_run() -{ +function vm_run() { local OPTIND optchar vm local run_all=false local vms_to_run="" @@ -831,14 +804,14 @@ function vm_run() *) error "Unknown param $OPTARG" return 1 - ;; + ;; esac done if $run_all; then vms_to_run="$(vm_list_all)" else - shift $((OPTIND-1)) + shift $((OPTIND - 1)) for vm in "$@"; do vm_num_is_valid $1 || return 1 if [[ ! -x $VM_DIR/$vm/run.sh ]]; then @@ -863,8 +836,7 @@ function vm_run() done } -function vm_print_logs() -{ +function vm_print_logs() { vm_num=$1 warning "================" warning "QEMU LOG:" @@ -892,8 +864,7 @@ function vm_print_logs() # Wait for all created VMs to boot. # param $1 max wait time -function vm_wait_for_boot() -{ +function vm_wait_for_boot() { assert_number $1 xtrace_disable @@ -934,7 +905,7 @@ function vm_wait_for_boot() xtrace_restore return 1 fi - if (( i > 30 )); then + if ((i > 30)); then local i=0 echo fi @@ -957,24 +928,23 @@ function vm_wait_for_boot() return 0 } -function vm_start_fio_server() -{ +function vm_start_fio_server() { local OPTIND optchar local readonly='' while getopts ':-:' optchar; do case "$optchar" in -) - case "$OPTARG" in - fio-bin=*) local fio_bin="${OPTARG#*=}" ;; - readonly) local readonly="--readonly" ;; - *) error "Invalid argument '$OPTARG'" && return 1;; - esac - ;; - *) error "Invalid argument '$OPTARG'" && return 1;; + case "$OPTARG" in + fio-bin=*) local fio_bin="${OPTARG#*=}" ;; + readonly) local readonly="--readonly" ;; + *) error "Invalid argument '$OPTARG'" && return 1 ;; + esac + ;; + *) error "Invalid argument '$OPTARG'" && return 1 ;; esac done - shift $(( OPTIND - 1 )) + shift $((OPTIND - 1)) for vm_num in "$@"; do notice "Starting fio server on VM$vm_num" if [[ $fio_bin != "" ]]; then @@ -986,8 +956,7 @@ function vm_start_fio_server() done } -function vm_check_scsi_location() -{ +function vm_check_scsi_location() { # Script to find wanted disc local script='shopt -s nullglob; for entry in /sys/block/sd*; do @@ -1009,23 +978,22 @@ function vm_check_scsi_location() # Note: to use this function your VM should be run with # appropriate memory and with SPDK source already cloned # and compiled in /root/spdk. -function vm_check_virtio_location() -{ +function vm_check_virtio_location() { vm_exec $1 NRHUGE=512 /root/spdk/scripts/setup.sh vm_exec $1 "cat > /root/bdev.conf" <<- EOF - [VirtioPci] - Enable Yes -EOF + [VirtioPci] + Enable Yes + EOF vm_exec $1 "cat /root/bdev.conf" vm_exec $1 "bash -s" <<- EOF - set -e - rootdir="/root/spdk" - source /root/spdk/test/common/autotest_common.sh - discover_bdevs /root/spdk /root/bdev.conf | jq -r '[.[].name] | join(" ")' > /root/fio_bdev_filenames - exit 0 -EOF + set -e + rootdir="/root/spdk" + source /root/spdk/test/common/autotest_common.sh + discover_bdevs /root/spdk /root/bdev.conf | jq -r '[.[].name] | join(" ")' > /root/fio_bdev_filenames + exit 0 + EOF SCSI_DISK=$(vm_exec $1 cat /root/fio_bdev_filenames) if [[ -z "$SCSI_DISK" ]]; then @@ -1037,16 +1005,14 @@ EOF # Script to perform scsi device reset on all disks in VM # param $1 VM num # param $2..$n Disks to perform reset on -function vm_reset_scsi_devices() -{ +function vm_reset_scsi_devices() { for disk in "${@:2}"; do notice "VM$1 Performing device reset on disk $disk" vm_exec $1 sg_reset /dev/$disk -vNd done } -function vm_check_blk_location() -{ +function vm_check_blk_location() { local script='shopt -s nullglob; cd /sys/block; echo vd*' SCSI_DISK="$(echo "$script" | vm_exec $1 bash -s)" @@ -1056,8 +1022,7 @@ function vm_check_blk_location() fi } -function run_fio() -{ +function run_fio() { local arg local job_file="" local fio_bin="" @@ -1074,7 +1039,7 @@ function run_fio() case "$arg" in --job-file=*) local job_file="${arg#*=}" ;; --fio-bin=*) local fio_bin="${arg#*=}" ;; - --vm=*) vms+=( "${arg#*=}" ) ;; + --vm=*) vms+=("${arg#*=}") ;; --out=*) local out="${arg#*=}" mkdir -p $out @@ -1083,14 +1048,15 @@ function run_fio() --plugin) notice "Using plugin mode. Disabling server mode." run_plugin_mode=true - run_server_mode=false ;; + run_server_mode=false + ;; --json) fio_output_format="json" ;; --hide-results) hide_results=true ;; --no-wait-for-fio) wait_for_fio=false ;; - *) - error "Invalid argument '$arg'" - return 1 - ;; + *) + error "Invalid argument '$arg'" + return 1 + ;; esac done @@ -1162,8 +1128,7 @@ function run_fio() # Shutdown or kill any running VM and SPDK APP. # -function at_app_exit() -{ +function at_app_exit() { local vhost_name notice "APP EXITING" @@ -1179,8 +1144,7 @@ function at_app_exit() notice "EXIT DONE" } -function error_exit() -{ +function error_exit() { trap - ERR print_backtrace set +e diff --git a/test/vhost/fiotest/fio.sh b/test/vhost/fiotest/fio.sh index 569fd72efd..930948d6dd 100755 --- a/test/vhost/fiotest/fio.sh +++ b/test/vhost/fiotest/fio.sh @@ -17,9 +17,11 @@ used_vms="" x="" readonly="" -function usage() -{ - [[ -n $2 ]] && ( echo "$2"; echo ""; ) +function usage() { + [[ -n $2 ]] && ( + echo "$2" + echo "" + ) echo "Shortcut script for doing automated test" echo "Usage: $(basename $1) [OPTIONS]" echo @@ -49,25 +51,27 @@ function usage() while getopts 'xh-:' optchar; do case "$optchar" in -) - case "$OPTARG" in - help) usage $0 ;; - fio-bin=*) fio_bin="--fio-bin=${OPTARG#*=}" ;; - fio-job=*) fio_job="${OPTARG#*=}" ;; - dry-run) dry_run=true ;; - no-shutdown) no_shutdown=true ;; - test-type=*) test_type="${OPTARG#*=}" ;; - vm=*) vms+=("${OPTARG#*=}") ;; - readonly) readonly="--readonly" ;; - *) usage $0 "Invalid argument '$OPTARG'" ;; - esac - ;; - h) usage $0 ;; - x) set -x - x="-x" ;; - *) usage $0 "Invalid argument '$OPTARG'" + case "$OPTARG" in + help) usage $0 ;; + fio-bin=*) fio_bin="--fio-bin=${OPTARG#*=}" ;; + fio-job=*) fio_job="${OPTARG#*=}" ;; + dry-run) dry_run=true ;; + no-shutdown) no_shutdown=true ;; + test-type=*) test_type="${OPTARG#*=}" ;; + vm=*) vms+=("${OPTARG#*=}") ;; + readonly) readonly="--readonly" ;; + *) usage $0 "Invalid argument '$OPTARG'" ;; + esac + ;; + h) usage $0 ;; + x) + set -x + x="-x" + ;; + *) usage $0 "Invalid argument '$OPTARG'" ;; esac done -shift $(( OPTIND - 1 )) +shift $((OPTIND - 1)) if [[ ! -r "$fio_job" ]]; then fail "no fio job file specified" @@ -153,7 +157,7 @@ for vm_conf in "${vms[@]}"; do fi done done <<< "${conf[2]}" - unset IFS; + unset IFS $rpc_py vhost_get_controllers fi @@ -188,7 +192,7 @@ if [[ $test_type == "spdk_vhost_scsi" ]]; then $rpc_py vhost_scsi_controller_add_target naa.$disk.${conf[0]} 0 $based_disk done done <<< "${conf[2]}" - unset IFS; + unset IFS done fi @@ -233,7 +237,7 @@ run_fio $fio_bin --job-file="$fio_job" --out="$VHOST_DIR/fio_results" $fio_disks if [[ "$test_type" == "spdk_vhost_scsi" ]]; then for vm_num in $used_vms; do - vm_reset_scsi_devices $vm_num $SCSI_DISK + vm_reset_scsi_devices $vm_num $SCSI_DISK done fi diff --git a/test/vhost/fuzz/fuzz.sh b/test/vhost/fuzz/fuzz.sh index 2e57376ca8..7502f19763 100755 --- a/test/vhost/fuzz/fuzz.sh +++ b/test/vhost/fuzz/fuzz.sh @@ -13,13 +13,13 @@ vhost_rpc_py="$rootdir/scripts/rpc.py" fuzz_generic_rpc_py="$rootdir/scripts/rpc.py -s $FUZZ_RPC_SOCK" fuzz_specific_rpc_py="$rootdir/test/app/fuzz/common/fuzz_rpc.py -s $FUZZ_RPC_SOCK" -"${VHOST_APP[@]}" >"$output_dir/vhost_fuzz_tgt_output.txt" 2>&1 & +"${VHOST_APP[@]}" > "$output_dir/vhost_fuzz_tgt_output.txt" 2>&1 & vhostpid=$! waitforlisten $vhostpid trap 'killprocess $vhostpid; exit 1' SIGINT SIGTERM exit -"${VHOST_FUZZ_APP[@]}" -t 10 2>"$output_dir/vhost_fuzz_output1.txt" & +"${VHOST_FUZZ_APP[@]}" -t 10 2> "$output_dir/vhost_fuzz_output1.txt" & fuzzpid=$! waitforlisten $fuzzpid $FUZZ_RPC_SOCK @@ -47,7 +47,7 @@ $fuzz_generic_rpc_py framework_start_init wait $fuzzpid -"${VHOST_FUZZ_APP[@]}" -j "$rootdir/test/app/fuzz/vhost_fuzz/example.json" 2>"$output_dir/vhost_fuzz_output2.txt" & +"${VHOST_FUZZ_APP[@]}" -j "$rootdir/test/app/fuzz/vhost_fuzz/example.json" 2> "$output_dir/vhost_fuzz_output2.txt" & fuzzpid=$! waitforlisten $fuzzpid $FUZZ_RPC_SOCK diff --git a/test/vhost/hotplug/blk_hotremove.sh b/test/vhost/hotplug/blk_hotremove.sh index e2715b8145..d0edab83af 100644 --- a/test/vhost/hotplug/blk_hotremove.sh +++ b/test/vhost/hotplug/blk_hotremove.sh @@ -14,217 +14,217 @@ # 3. In test cases fio status is checked after every run if any errors occurred. function prepare_fio_cmd_tc1() { - print_test_fio_header + print_test_fio_header - run_fio="$fio_bin --eta=never " - for vm_num in $1; do - cp $fio_job $tmp_detach_job - vm_check_blk_location $vm_num - for disk in $SCSI_DISK; do - echo "[nvme-host$disk]" >> $tmp_detach_job - echo "filename=/dev/$disk" >> $tmp_detach_job - done - vm_scp "$vm_num" $tmp_detach_job 127.0.0.1:/root/default_integrity_2discs.job - run_fio+="--client=127.0.0.1,$(vm_fio_socket $vm_num) --remote-config /root/default_integrity_2discs.job " - rm $tmp_detach_job - done + run_fio="$fio_bin --eta=never " + for vm_num in $1; do + cp $fio_job $tmp_detach_job + vm_check_blk_location $vm_num + for disk in $SCSI_DISK; do + echo "[nvme-host$disk]" >> $tmp_detach_job + echo "filename=/dev/$disk" >> $tmp_detach_job + done + vm_scp "$vm_num" $tmp_detach_job 127.0.0.1:/root/default_integrity_2discs.job + run_fio+="--client=127.0.0.1,$(vm_fio_socket $vm_num) --remote-config /root/default_integrity_2discs.job " + rm $tmp_detach_job + done } function vhost_delete_controllers() { - $rpc_py vhost_delete_controller naa.Nvme0n1p0.0 - $rpc_py vhost_delete_controller naa.Nvme0n1p1.0 - $rpc_py vhost_delete_controller naa.Nvme0n1p2.1 - $rpc_py vhost_delete_controller naa.Nvme0n1p3.1 + $rpc_py vhost_delete_controller naa.Nvme0n1p0.0 + $rpc_py vhost_delete_controller naa.Nvme0n1p1.0 + $rpc_py vhost_delete_controller naa.Nvme0n1p2.1 + $rpc_py vhost_delete_controller naa.Nvme0n1p3.1 } # Vhost blk hot remove test cases # # Test Case 1 function blk_hotremove_tc1() { - echo "Blk hotremove test case 1" - traddr="" - # 1. Run the command to hot remove NVMe disk. - get_traddr "Nvme0" - delete_nvme "Nvme0" - # 2. If vhost had crashed then tests would stop running - sleep 1 - add_nvme "HotInNvme0" "$traddr" - sleep 1 + echo "Blk hotremove test case 1" + traddr="" + # 1. Run the command to hot remove NVMe disk. + get_traddr "Nvme0" + delete_nvme "Nvme0" + # 2. If vhost had crashed then tests would stop running + sleep 1 + add_nvme "HotInNvme0" "$traddr" + sleep 1 } # Test Case 2 function blk_hotremove_tc2() { - echo "Blk hotremove test case 2" - # 1. Use rpc command to create blk controllers. - $rpc_py vhost_create_blk_controller naa.Nvme0n1p0.0 HotInNvme0n1p0 - $rpc_py vhost_create_blk_controller naa.Nvme0n1p1.0 Mallocp0 - $rpc_py vhost_create_blk_controller naa.Nvme0n1p2.1 Mallocp1 - $rpc_py vhost_create_blk_controller naa.Nvme0n1p3.1 Mallocp2 - # 2. Run two VMs and attach every VM to two blk controllers. - vm_run_with_arg "0 1" - vms_prepare "0" + echo "Blk hotremove test case 2" + # 1. Use rpc command to create blk controllers. + $rpc_py vhost_create_blk_controller naa.Nvme0n1p0.0 HotInNvme0n1p0 + $rpc_py vhost_create_blk_controller naa.Nvme0n1p1.0 Mallocp0 + $rpc_py vhost_create_blk_controller naa.Nvme0n1p2.1 Mallocp1 + $rpc_py vhost_create_blk_controller naa.Nvme0n1p3.1 Mallocp2 + # 2. Run two VMs and attach every VM to two blk controllers. + vm_run_with_arg "0 1" + vms_prepare "0" - traddr="" - get_traddr "Nvme0" - prepare_fio_cmd_tc1 "0" - # 3. Run FIO I/O traffic with verification enabled on NVMe disk. - $run_fio & - local last_pid=$! - sleep 3 - # 4. Run the command to hot remove NVMe disk. - delete_nvme "HotInNvme0" - local retcode=0 - wait_for_finish $last_pid || retcode=$? - # 5. Check that fio job run on hot-removed device stopped. - # Expected: Fio should return error message and return code != 0. - check_fio_retcode "Blk hotremove test case 2: Iteration 1." 1 $retcode + traddr="" + get_traddr "Nvme0" + prepare_fio_cmd_tc1 "0" + # 3. Run FIO I/O traffic with verification enabled on NVMe disk. + $run_fio & + local last_pid=$! + sleep 3 + # 4. Run the command to hot remove NVMe disk. + delete_nvme "HotInNvme0" + local retcode=0 + wait_for_finish $last_pid || retcode=$? + # 5. Check that fio job run on hot-removed device stopped. + # Expected: Fio should return error message and return code != 0. + check_fio_retcode "Blk hotremove test case 2: Iteration 1." 1 $retcode - # 6. Reboot VM - reboot_all_and_prepare "0" - # 7. Run FIO I/O traffic with verification enabled on NVMe disk. - $run_fio & - local retcode=0 - wait_for_finish $! || retcode=$? - # 8. Check that fio job run on hot-removed device stopped. - # Expected: Fio should return error message and return code != 0. - check_fio_retcode "Blk hotremove test case 2: Iteration 2." 1 $retcode - vm_shutdown_all - vhost_delete_controllers - add_nvme "HotInNvme1" "$traddr" - sleep 1 + # 6. Reboot VM + reboot_all_and_prepare "0" + # 7. Run FIO I/O traffic with verification enabled on NVMe disk. + $run_fio & + local retcode=0 + wait_for_finish $! || retcode=$? + # 8. Check that fio job run on hot-removed device stopped. + # Expected: Fio should return error message and return code != 0. + check_fio_retcode "Blk hotremove test case 2: Iteration 2." 1 $retcode + vm_shutdown_all + vhost_delete_controllers + add_nvme "HotInNvme1" "$traddr" + sleep 1 } # ## Test Case 3 function blk_hotremove_tc3() { - echo "Blk hotremove test case 3" - # 1. Use rpc command to create blk controllers. - $rpc_py vhost_create_blk_controller naa.Nvme0n1p0.0 HotInNvme1n1p0 - $rpc_py vhost_create_blk_controller naa.Nvme0n1p1.0 Mallocp0 - $rpc_py vhost_create_blk_controller naa.Nvme0n1p2.1 HotInNvme1n1p1 - $rpc_py vhost_create_blk_controller naa.Nvme0n1p3.1 Mallocp1 - # 2. Run two VMs and attach every VM to two blk controllers. - vm_run_with_arg "0 1" - vms_prepare "0 1" + echo "Blk hotremove test case 3" + # 1. Use rpc command to create blk controllers. + $rpc_py vhost_create_blk_controller naa.Nvme0n1p0.0 HotInNvme1n1p0 + $rpc_py vhost_create_blk_controller naa.Nvme0n1p1.0 Mallocp0 + $rpc_py vhost_create_blk_controller naa.Nvme0n1p2.1 HotInNvme1n1p1 + $rpc_py vhost_create_blk_controller naa.Nvme0n1p3.1 Mallocp1 + # 2. Run two VMs and attach every VM to two blk controllers. + vm_run_with_arg "0 1" + vms_prepare "0 1" - traddr="" - get_traddr "Nvme0" - prepare_fio_cmd_tc1 "0" - # 3. Run FIO I/O traffic with verification enabled on first NVMe disk. - $run_fio & - local last_pid=$! - sleep 3 - # 4. Run the command to hot remove of first NVMe disk. - delete_nvme "HotInNvme1" - local retcode=0 - wait_for_finish $last_pid || retcode=$? - # 6. Check that fio job run on hot-removed device stopped. - # Expected: Fio should return error message and return code != 0. - check_fio_retcode "Blk hotremove test case 3: Iteration 1." 1 $retcode + traddr="" + get_traddr "Nvme0" + prepare_fio_cmd_tc1 "0" + # 3. Run FIO I/O traffic with verification enabled on first NVMe disk. + $run_fio & + local last_pid=$! + sleep 3 + # 4. Run the command to hot remove of first NVMe disk. + delete_nvme "HotInNvme1" + local retcode=0 + wait_for_finish $last_pid || retcode=$? + # 6. Check that fio job run on hot-removed device stopped. + # Expected: Fio should return error message and return code != 0. + check_fio_retcode "Blk hotremove test case 3: Iteration 1." 1 $retcode - # 7. Reboot VM - reboot_all_and_prepare "0" - local retcode=0 - # 8. Run FIO I/O traffic with verification enabled on removed NVMe disk. - $run_fio & - wait_for_finish $! || retcode=$? - # 9. Check that fio job run on hot-removed device stopped. - # Expected: Fio should return error message and return code != 0. - check_fio_retcode "Blk hotremove test case 3: Iteration 2." 1 $retcode - vm_shutdown_all - vhost_delete_controllers - add_nvme "HotInNvme2" "$traddr" - sleep 1 + # 7. Reboot VM + reboot_all_and_prepare "0" + local retcode=0 + # 8. Run FIO I/O traffic with verification enabled on removed NVMe disk. + $run_fio & + wait_for_finish $! || retcode=$? + # 9. Check that fio job run on hot-removed device stopped. + # Expected: Fio should return error message and return code != 0. + check_fio_retcode "Blk hotremove test case 3: Iteration 2." 1 $retcode + vm_shutdown_all + vhost_delete_controllers + add_nvme "HotInNvme2" "$traddr" + sleep 1 } # Test Case 4 function blk_hotremove_tc4() { - echo "Blk hotremove test case 4" - # 1. Use rpc command to create blk controllers. - $rpc_py vhost_create_blk_controller naa.Nvme0n1p0.0 HotInNvme2n1p0 - $rpc_py vhost_create_blk_controller naa.Nvme0n1p1.0 Mallocp0 - $rpc_py vhost_create_blk_controller naa.Nvme0n1p2.1 HotInNvme2n1p1 - $rpc_py vhost_create_blk_controller naa.Nvme0n1p3.1 Mallocp1 - # 2. Run two VM, attached to blk controllers. - vm_run_with_arg "0 1" - vms_prepare "0 1" + echo "Blk hotremove test case 4" + # 1. Use rpc command to create blk controllers. + $rpc_py vhost_create_blk_controller naa.Nvme0n1p0.0 HotInNvme2n1p0 + $rpc_py vhost_create_blk_controller naa.Nvme0n1p1.0 Mallocp0 + $rpc_py vhost_create_blk_controller naa.Nvme0n1p2.1 HotInNvme2n1p1 + $rpc_py vhost_create_blk_controller naa.Nvme0n1p3.1 Mallocp1 + # 2. Run two VM, attached to blk controllers. + vm_run_with_arg "0 1" + vms_prepare "0 1" - prepare_fio_cmd_tc1 "0" - # 3. Run FIO I/O traffic on first VM with verification enabled on both NVMe disks. - $run_fio & - local last_pid_vm0=$! + prepare_fio_cmd_tc1 "0" + # 3. Run FIO I/O traffic on first VM with verification enabled on both NVMe disks. + $run_fio & + local last_pid_vm0=$! - prepare_fio_cmd_tc1 "1" - # 4. Run FIO I/O traffic on second VM with verification enabled on both NVMe disks. - $run_fio & - local last_pid_vm1=$! + prepare_fio_cmd_tc1 "1" + # 4. Run FIO I/O traffic on second VM with verification enabled on both NVMe disks. + $run_fio & + local last_pid_vm1=$! - sleep 3 - prepare_fio_cmd_tc1 "0 1" - # 5. Run the command to hot remove of first NVMe disk. - delete_nvme "HotInNvme2" - local retcode_vm0=0 - local retcode_vm1=0 - wait_for_finish $last_pid_vm0 || retcode_vm0=$? - wait_for_finish $last_pid_vm1 || retcode_vm1=$? - # 6. Check that fio job run on hot-removed device stopped. - # Expected: Fio should return error message and return code != 0. - check_fio_retcode "Blk hotremove test case 4: Iteration 1." 1 $retcode_vm0 - check_fio_retcode "Blk hotremove test case 4: Iteration 2." 1 $retcode_vm1 + sleep 3 + prepare_fio_cmd_tc1 "0 1" + # 5. Run the command to hot remove of first NVMe disk. + delete_nvme "HotInNvme2" + local retcode_vm0=0 + local retcode_vm1=0 + wait_for_finish $last_pid_vm0 || retcode_vm0=$? + wait_for_finish $last_pid_vm1 || retcode_vm1=$? + # 6. Check that fio job run on hot-removed device stopped. + # Expected: Fio should return error message and return code != 0. + check_fio_retcode "Blk hotremove test case 4: Iteration 1." 1 $retcode_vm0 + check_fio_retcode "Blk hotremove test case 4: Iteration 2." 1 $retcode_vm1 - # 7. Reboot all VMs. - reboot_all_and_prepare "0 1" - # 8. Run FIO I/O traffic with verification enabled on removed NVMe disk. - $run_fio & - local retcode=0 - wait_for_finish $! || retcode=$? - # 9. Check that fio job run on hot-removed device stopped. - # Expected: Fio should return error message and return code != 0. - check_fio_retcode "Blk hotremove test case 4: Iteration 3." 1 $retcode + # 7. Reboot all VMs. + reboot_all_and_prepare "0 1" + # 8. Run FIO I/O traffic with verification enabled on removed NVMe disk. + $run_fio & + local retcode=0 + wait_for_finish $! || retcode=$? + # 9. Check that fio job run on hot-removed device stopped. + # Expected: Fio should return error message and return code != 0. + check_fio_retcode "Blk hotremove test case 4: Iteration 3." 1 $retcode - vm_shutdown_all - vhost_delete_controllers - add_nvme "HotInNvme3" "$traddr" - sleep 1 + vm_shutdown_all + vhost_delete_controllers + add_nvme "HotInNvme3" "$traddr" + sleep 1 } # Test Case 5 function blk_hotremove_tc5() { - echo "Blk hotremove test case 5" - # 1. Use rpc command to create blk controllers. - $rpc_py vhost_create_blk_controller naa.Nvme0n1p0.0 HotInNvme3n1p0 - $rpc_py vhost_create_blk_controller naa.Nvme0n1p1.0 Mallocp0 - $rpc_py vhost_create_blk_controller naa.Nvme0n1p2.1 Mallocp1 - $rpc_py vhost_create_blk_controller naa.Nvme0n1p3.1 Mallocp2 - # 2. Run two VM, attached to blk controllers. - vm_run_with_arg "0 1" - vms_prepare "0 1" + echo "Blk hotremove test case 5" + # 1. Use rpc command to create blk controllers. + $rpc_py vhost_create_blk_controller naa.Nvme0n1p0.0 HotInNvme3n1p0 + $rpc_py vhost_create_blk_controller naa.Nvme0n1p1.0 Mallocp0 + $rpc_py vhost_create_blk_controller naa.Nvme0n1p2.1 Mallocp1 + $rpc_py vhost_create_blk_controller naa.Nvme0n1p3.1 Mallocp2 + # 2. Run two VM, attached to blk controllers. + vm_run_with_arg "0 1" + vms_prepare "0 1" - prepare_fio_cmd_tc1 "0" - # 3. Run FIO I/O traffic on first VM with verification enabled on both NVMe disks. - $run_fio & - local last_pid=$! - sleep 3 - # 4. Run the command to hot remove of first NVMe disk. - delete_nvme "HotInNvme3" - local retcode=0 - wait_for_finish $last_pid || retcode=$? - # 5. Check that fio job run on hot-removed device stopped. - # Expected: Fio should return error message and return code != 0. - check_fio_retcode "Blk hotremove test case 5: Iteration 1." 1 $retcode + prepare_fio_cmd_tc1 "0" + # 3. Run FIO I/O traffic on first VM with verification enabled on both NVMe disks. + $run_fio & + local last_pid=$! + sleep 3 + # 4. Run the command to hot remove of first NVMe disk. + delete_nvme "HotInNvme3" + local retcode=0 + wait_for_finish $last_pid || retcode=$? + # 5. Check that fio job run on hot-removed device stopped. + # Expected: Fio should return error message and return code != 0. + check_fio_retcode "Blk hotremove test case 5: Iteration 1." 1 $retcode - # 6. Reboot VM. - reboot_all_and_prepare "0" - local retcode=0 - # 7. Run FIO I/O traffic with verification enabled on removed NVMe disk. - $run_fio & - wait_for_finish $! || retcode=$? - # 8. Check that fio job run on hot-removed device stopped. - # Expected: Fio should return error message and return code != 0. - check_fio_retcode "Blk hotremove test case 5: Iteration 2." 1 $retcode - vm_shutdown_all - vhost_delete_controllers - add_nvme "HotInNvme4" "$traddr" - sleep 1 + # 6. Reboot VM. + reboot_all_and_prepare "0" + local retcode=0 + # 7. Run FIO I/O traffic with verification enabled on removed NVMe disk. + $run_fio & + wait_for_finish $! || retcode=$? + # 8. Check that fio job run on hot-removed device stopped. + # Expected: Fio should return error message and return code != 0. + check_fio_retcode "Blk hotremove test case 5: Iteration 2." 1 $retcode + vm_shutdown_all + vhost_delete_controllers + add_nvme "HotInNvme4" "$traddr" + sleep 1 } vms_setup diff --git a/test/vhost/hotplug/common.sh b/test/vhost/hotplug/common.sh index adf7cd44b0..b7b05ee74e 100644 --- a/test/vhost/hotplug/common.sh +++ b/test/vhost/hotplug/common.sh @@ -17,52 +17,56 @@ scsi_hot_remove_test=0 blk_hot_remove_test=0 readonly="" - function usage() { - [[ -n $2 ]] && ( echo "$2"; echo ""; ) - echo "Shortcut script for doing automated hotattach/hotdetach test" - echo "Usage: $(basename $1) [OPTIONS]" - echo - echo "-h, --help print help and exit" - echo " --test-type=TYPE Perform specified test:" - echo " virtio - test host virtio-scsi-pci using file as disk image" - echo " kernel_vhost - use kernel driver vhost-scsi" - echo " spdk_vhost_scsi - use spdk vhost scsi" - echo " spdk_vhost_blk - use spdk vhost block" - echo "-x set -x for script debug" - echo " --fio-bin=FIO Use specific fio binary (will be uploaded to VM)" - echo " --fio-jobs= Fio configs to use for tests. Can point to a directory or" - echo " --vm=NUM[,OS][,DISKS] VM configuration. This parameter might be used more than once:" - echo " NUM - VM number (mandatory)" - echo " OS - VM os disk path (optional)" - echo " DISKS - VM os test disks/devices path (virtio - optional, kernel_vhost - mandatory)" - echo " --scsi-hotremove-test Run scsi hotremove tests" - echo " --readonly Use readonly for fio" - exit 0 + [[ -n $2 ]] && ( + echo "$2" + echo "" + ) + echo "Shortcut script for doing automated hotattach/hotdetach test" + echo "Usage: $(basename $1) [OPTIONS]" + echo + echo "-h, --help print help and exit" + echo " --test-type=TYPE Perform specified test:" + echo " virtio - test host virtio-scsi-pci using file as disk image" + echo " kernel_vhost - use kernel driver vhost-scsi" + echo " spdk_vhost_scsi - use spdk vhost scsi" + echo " spdk_vhost_blk - use spdk vhost block" + echo "-x set -x for script debug" + echo " --fio-bin=FIO Use specific fio binary (will be uploaded to VM)" + echo " --fio-jobs= Fio configs to use for tests. Can point to a directory or" + echo " --vm=NUM[,OS][,DISKS] VM configuration. This parameter might be used more than once:" + echo " NUM - VM number (mandatory)" + echo " OS - VM os disk path (optional)" + echo " DISKS - VM os test disks/devices path (virtio - optional, kernel_vhost - mandatory)" + echo " --scsi-hotremove-test Run scsi hotremove tests" + echo " --readonly Use readonly for fio" + exit 0 } while getopts 'xh-:' optchar; do - case "$optchar" in - -) - case "$OPTARG" in - help) usage $0 ;; - fio-bin=*) fio_bin="${OPTARG#*=}" ;; - fio-jobs=*) fio_jobs="${OPTARG#*=}" ;; - test-type=*) test_type="${OPTARG#*=}" ;; - vm=*) vms+=("${OPTARG#*=}") ;; - scsi-hotremove-test) scsi_hot_remove_test=1 ;; - blk-hotremove-test) blk_hot_remove_test=1 ;; - readonly) readonly="--readonly" ;; - *) usage $0 "Invalid argument '$OPTARG'" ;; - esac - ;; - h) usage $0 ;; - x) set -x - x="-x" ;; - *) usage $0 "Invalid argument '$OPTARG'" - esac + case "$optchar" in + -) + case "$OPTARG" in + help) usage $0 ;; + fio-bin=*) fio_bin="${OPTARG#*=}" ;; + fio-jobs=*) fio_jobs="${OPTARG#*=}" ;; + test-type=*) test_type="${OPTARG#*=}" ;; + vm=*) vms+=("${OPTARG#*=}") ;; + scsi-hotremove-test) scsi_hot_remove_test=1 ;; + blk-hotremove-test) blk_hot_remove_test=1 ;; + readonly) readonly="--readonly" ;; + *) usage $0 "Invalid argument '$OPTARG'" ;; + esac + ;; + h) usage $0 ;; + x) + set -x + x="-x" + ;; + *) usage $0 "Invalid argument '$OPTARG'" ;; + esac done -shift $(( OPTIND - 1 )) +shift $((OPTIND - 1)) fio_job=$testdir/fio_jobs/default_integrity.job tmp_attach_job=$testdir/fio_jobs/fio_attach.job.tmp @@ -71,157 +75,156 @@ tmp_detach_job=$testdir/fio_jobs/fio_detach.job.tmp rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock" function print_test_fio_header() { - notice "===============" - notice "" - notice "Testing..." + notice "===============" + notice "" + notice "Testing..." - notice "Running fio jobs ..." - if [ $# -gt 0 ]; then - echo $1 - fi + notice "Running fio jobs ..." + if [ $# -gt 0 ]; then + echo $1 + fi } function vms_setup() { - for vm_conf in "${vms[@]}"; do - IFS=',' read -ra conf <<< "$vm_conf" - if [[ x"${conf[0]}" == x"" ]] || ! assert_number ${conf[0]}; then - fail "invalid VM configuration syntax $vm_conf" - fi + for vm_conf in "${vms[@]}"; do + IFS=',' read -ra conf <<< "$vm_conf" + if [[ x"${conf[0]}" == x"" ]] || ! assert_number ${conf[0]}; then + fail "invalid VM configuration syntax $vm_conf" + fi - # Sanity check if VM is not defined twice - for vm_num in $used_vms; do - if [[ $vm_num -eq ${conf[0]} ]]; then - fail "VM$vm_num defined more than twice ( $(printf "'%s' " "${vms[@]}"))!" - fi - done + # Sanity check if VM is not defined twice + for vm_num in $used_vms; do + if [[ $vm_num -eq ${conf[0]} ]]; then + fail "VM$vm_num defined more than twice ( $(printf "'%s' " "${vms[@]}"))!" + fi + done - used_vms+=" ${conf[0]}" + used_vms+=" ${conf[0]}" - setup_cmd="vm_setup --disk-type=$test_type --force=${conf[0]}" - [[ x"${conf[1]}" != x"" ]] && setup_cmd+=" --os=${conf[1]}" - [[ x"${conf[2]}" != x"" ]] && setup_cmd+=" --disks=${conf[2]}" - $setup_cmd - done + setup_cmd="vm_setup --disk-type=$test_type --force=${conf[0]}" + [[ x"${conf[1]}" != x"" ]] && setup_cmd+=" --os=${conf[1]}" + [[ x"${conf[2]}" != x"" ]] && setup_cmd+=" --disks=${conf[2]}" + $setup_cmd + done } function vm_run_with_arg() { - local vms_to_run="$*" - vm_run $vms_to_run - vm_wait_for_boot 300 $vms_to_run + local vms_to_run="$*" + vm_run $vms_to_run + vm_wait_for_boot 300 $vms_to_run } function vms_setup_and_run() { - local vms_to_run="$*" - vms_setup - vm_run_with_arg $vms_to_run + local vms_to_run="$*" + vms_setup + vm_run_with_arg $vms_to_run } function vms_prepare() { - for vm_num in $1; do - qemu_mask_param="VM_${vm_num}_qemu_mask" + for vm_num in $1; do + qemu_mask_param="VM_${vm_num}_qemu_mask" - host_name="VM-${vm_num}-${!qemu_mask_param}" - notice "Setting up hostname: $host_name" - vm_exec $vm_num "hostname $host_name" - vm_start_fio_server --fio-bin=$fio_bin $readonly $vm_num - done + host_name="VM-${vm_num}-${!qemu_mask_param}" + notice "Setting up hostname: $host_name" + vm_exec $vm_num "hostname $host_name" + vm_start_fio_server --fio-bin=$fio_bin $readonly $vm_num + done } function vms_reboot_all() { - notice "Rebooting all vms " - for vm_num in $1; do - vm_exec $vm_num "reboot" || true - while vm_os_booted $vm_num; do - sleep 0.5 - done - done + notice "Rebooting all vms " + for vm_num in $1; do + vm_exec $vm_num "reboot" || true + while vm_os_booted $vm_num; do + sleep 0.5 + done + done - vm_wait_for_boot 300 $1 + vm_wait_for_boot 300 $1 } function check_fio_retcode() { - local fio_retcode=$3 - echo $1 - local retcode_expected=$2 - if [ $retcode_expected == 0 ]; then - if [ $fio_retcode != 0 ]; then - error " Fio test ended with error." - else - notice " Fio test ended with success." - fi - else - if [ $fio_retcode != 0 ]; then - notice " Fio test ended with expected error." - else - error " Fio test ended with unexpected success." - fi - fi + local fio_retcode=$3 + echo $1 + local retcode_expected=$2 + if [ $retcode_expected == 0 ]; then + if [ $fio_retcode != 0 ]; then + error " Fio test ended with error." + else + notice " Fio test ended with success." + fi + else + if [ $fio_retcode != 0 ]; then + notice " Fio test ended with expected error." + else + error " Fio test ended with unexpected success." + fi + fi } function wait_for_finish() { - local wait_for_pid=$1 - local sequence=${2:-30} - for i in $(seq 1 $sequence); do - if kill -0 $wait_for_pid; then - sleep 0.5 - continue - else - break - fi - done - if kill -0 $wait_for_pid; then - error "Timeout for fio command" - fi + local wait_for_pid=$1 + local sequence=${2:-30} + for i in $(seq 1 $sequence); do + if kill -0 $wait_for_pid; then + sleep 0.5 + continue + else + break + fi + done + if kill -0 $wait_for_pid; then + error "Timeout for fio command" + fi - wait $wait_for_pid + wait $wait_for_pid } - function reboot_all_and_prepare() { - vms_reboot_all "$1" - vms_prepare "$1" + vms_reboot_all "$1" + vms_prepare "$1" } function post_test_case() { - vm_shutdown_all - vhost_kill 0 + vm_shutdown_all + vhost_kill 0 } function on_error_exit() { - set +e - echo "Error on $1 - $2" - post_test_case - print_backtrace - exit 1 + set +e + echo "Error on $1 - $2" + post_test_case + print_backtrace + exit 1 } function check_disks() { - if [ "$1" == "$2" ]; then - echo "Disk has not been deleted" - exit 1 - fi + if [ "$1" == "$2" ]; then + echo "Disk has not been deleted" + exit 1 + fi } function get_traddr() { - local nvme_name=$1 - local nvme - nvme="$( $rootdir/scripts/gen_nvme.sh )" - while read -r line; do - if [[ $line == *"TransportID"* ]] && [[ $line == *$nvme_name* ]]; then - local word_array=($line) - for word in "${word_array[@]}"; do - if [[ $word == *"traddr"* ]]; then - traddr=$( echo $word | sed 's/traddr://' | sed 's/"//' ) - fi - done - fi - done <<< "$nvme" + local nvme_name=$1 + local nvme + nvme="$($rootdir/scripts/gen_nvme.sh)" + while read -r line; do + if [[ $line == *"TransportID"* ]] && [[ $line == *$nvme_name* ]]; then + local word_array=($line) + for word in "${word_array[@]}"; do + if [[ $word == *"traddr"* ]]; then + traddr=$(echo $word | sed 's/traddr://' | sed 's/"//') + fi + done + fi + done <<< "$nvme" } function delete_nvme() { - $rpc_py bdev_nvme_detach_controller $1 + $rpc_py bdev_nvme_detach_controller $1 } function add_nvme() { - $rpc_py bdev_nvme_attach_controller -b $1 -t PCIe -a $2 + $rpc_py bdev_nvme_attach_controller -b $1 -t PCIe -a $2 } diff --git a/test/vhost/hotplug/scsi_hotattach.sh b/test/vhost/hotplug/scsi_hotattach.sh index c952b64ea0..4b9e26ab83 100755 --- a/test/vhost/hotplug/scsi_hotattach.sh +++ b/test/vhost/hotplug/scsi_hotattach.sh @@ -7,93 +7,93 @@ source $rootdir/test/vhost/common.sh source $rootdir/test/vhost/hotplug/common.sh function prepare_fio_cmd_tc1() { - print_test_fio_header + print_test_fio_header - run_fio="$fio_bin --eta=never " - for vm_num in $1; do - cp $fio_job $tmp_attach_job - vm_check_scsi_location $vm_num - for disk in $SCSI_DISK; do - echo "[nvme-host$disk]" >> $tmp_attach_job - echo "filename=/dev/$disk" >> $tmp_attach_job - done - vm_scp $vm_num $tmp_attach_job 127.0.0.1:/root/default_integrity_discs.job - run_fio+="--client=127.0.0.1,$(vm_fio_socket ${vm_num}) --remote-config /root/default_integrity_discs.job " - rm $tmp_attach_job - done + run_fio="$fio_bin --eta=never " + for vm_num in $1; do + cp $fio_job $tmp_attach_job + vm_check_scsi_location $vm_num + for disk in $SCSI_DISK; do + echo "[nvme-host$disk]" >> $tmp_attach_job + echo "filename=/dev/$disk" >> $tmp_attach_job + done + vm_scp $vm_num $tmp_attach_job 127.0.0.1:/root/default_integrity_discs.job + run_fio+="--client=127.0.0.1,$(vm_fio_socket ${vm_num}) --remote-config /root/default_integrity_discs.job " + rm $tmp_attach_job + done } # Check if fio test passes on device attached to first controller. function hotattach_tc1() { - notice "Hotattach test case 1" + notice "Hotattach test case 1" - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p0.0 0 Nvme0n1p0 + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p0.0 0 Nvme0n1p0 - sleep 3 - prepare_fio_cmd_tc1 "0" - $run_fio - check_fio_retcode "Hotattach test case 1: Iteration 1." 0 $? + sleep 3 + prepare_fio_cmd_tc1 "0" + $run_fio + check_fio_retcode "Hotattach test case 1: Iteration 1." 0 $? } # Run fio test for previously attached device. # During test attach another device to first controller and check fio status. function hotattach_tc2() { - notice "Hotattach test case 2" - prepare_fio_cmd_tc1 "0" + notice "Hotattach test case 2" + prepare_fio_cmd_tc1 "0" - $run_fio & - last_pid=$! - sleep 3 - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p0.0 1 Nvme0n1p1 - wait $last_pid - check_fio_retcode "Hotattach test case 2: Iteration 1." 0 $? + $run_fio & + last_pid=$! + sleep 3 + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p0.0 1 Nvme0n1p1 + wait $last_pid + check_fio_retcode "Hotattach test case 2: Iteration 1." 0 $? } # Run fio test for previously attached devices. # During test attach another device to second controller and check fio status. function hotattach_tc3() { - notice "Hotattach test case 3" - prepare_fio_cmd_tc1 "0" + notice "Hotattach test case 3" + prepare_fio_cmd_tc1 "0" - $run_fio & - last_pid=$! - sleep 3 - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p1.0 0 Nvme0n1p2 - wait $last_pid - check_fio_retcode "Hotattach test case 3: Iteration 1." 0 $? + $run_fio & + last_pid=$! + sleep 3 + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p1.0 0 Nvme0n1p2 + wait $last_pid + check_fio_retcode "Hotattach test case 3: Iteration 1." 0 $? } # Run fio test for previously attached devices. # During test attach another device to third controller(VM2) and check fio status. # At the end after rebooting VMs run fio test for all devices and check fio status. function hotattach_tc4() { - notice "Hotattach test case 4" + notice "Hotattach test case 4" - prepare_fio_cmd_tc1 "0" + prepare_fio_cmd_tc1 "0" - $run_fio & - last_pid=$! - sleep 3 - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p2.1 0 Nvme0n1p3 - wait $last_pid - check_fio_retcode "Hotattach test case 4: Iteration 1." 0 $? + $run_fio & + last_pid=$! + sleep 3 + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p2.1 0 Nvme0n1p3 + wait $last_pid + check_fio_retcode "Hotattach test case 4: Iteration 1." 0 $? - prepare_fio_cmd_tc1 "0 1" - $run_fio - check_fio_retcode "Hotattach test case 4: Iteration 2." 0 $? + prepare_fio_cmd_tc1 "0 1" + $run_fio + check_fio_retcode "Hotattach test case 4: Iteration 2." 0 $? - reboot_all_and_prepare "0 1" + reboot_all_and_prepare "0 1" - prepare_fio_cmd_tc1 "0 1" - $run_fio - check_fio_retcode "Hotattach test case 4: Iteration 3." 0 $? + prepare_fio_cmd_tc1 "0 1" + $run_fio + check_fio_retcode "Hotattach test case 4: Iteration 3." 0 $? } function cleanup_after_tests() { - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p0.0 0 - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p0.0 1 - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p1.0 0 - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p2.1 0 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p0.0 0 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p0.0 1 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p1.0 0 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p2.1 0 } hotattach_tc1 diff --git a/test/vhost/hotplug/scsi_hotdetach.sh b/test/vhost/hotplug/scsi_hotdetach.sh index 35d5ad22c1..8a7cb264fa 100755 --- a/test/vhost/hotplug/scsi_hotdetach.sh +++ b/test/vhost/hotplug/scsi_hotdetach.sh @@ -7,165 +7,164 @@ source $rootdir/test/vhost/common.sh source $rootdir/test/vhost/hotplug/common.sh function get_first_disk() { - vm_check_scsi_location $1 - disk_array=( $SCSI_DISK ) - eval "$2=${disk_array[0]}" + vm_check_scsi_location $1 + disk_array=($SCSI_DISK) + eval "$2=${disk_array[0]}" } function check_disks() { - if [ "$1" == "$2" ]; then - fail "Disk has not been deleted" - fi + if [ "$1" == "$2" ]; then + fail "Disk has not been deleted" + fi } function prepare_fio_cmd_tc1_iter1() { - print_test_fio_header + print_test_fio_header - run_fio="$fio_bin --eta=never " - for vm_num in $1; do - cp $fio_job $tmp_detach_job - vm_check_scsi_location $vm_num - for disk in $SCSI_DISK; do - echo "[nvme-host$disk]" >> $tmp_detach_job - echo "filename=/dev/$disk" >> $tmp_detach_job - done - vm_scp "$vm_num" $tmp_detach_job 127.0.0.1:/root/default_integrity_4discs.job - run_fio+="--client=127.0.0.1,$(vm_fio_socket $vm_num) --remote-config /root/default_integrity_4discs.job " - rm $tmp_detach_job - done + run_fio="$fio_bin --eta=never " + for vm_num in $1; do + cp $fio_job $tmp_detach_job + vm_check_scsi_location $vm_num + for disk in $SCSI_DISK; do + echo "[nvme-host$disk]" >> $tmp_detach_job + echo "filename=/dev/$disk" >> $tmp_detach_job + done + vm_scp "$vm_num" $tmp_detach_job 127.0.0.1:/root/default_integrity_4discs.job + run_fio+="--client=127.0.0.1,$(vm_fio_socket $vm_num) --remote-config /root/default_integrity_4discs.job " + rm $tmp_detach_job + done } function prepare_fio_cmd_tc2_iter1() { - print_test_fio_header + print_test_fio_header - run_fio="$fio_bin --eta=never " - for vm_num in $1; do - cp $fio_job $tmp_detach_job - vm_check_scsi_location $vm_num - disk_array=($SCSI_DISK) - disk=${disk_array[0]} - echo "[nvme-host$disk]" >> $tmp_detach_job - echo "filename=/dev/$disk" >> $tmp_detach_job - vm_scp "$vm_num" $tmp_detach_job 127.0.0.1:/root/default_integrity.job - run_fio+="--client=127.0.0.1,$(vm_fio_socket $vm_num) --remote-config /root/default_integrity.job " - rm $tmp_detach_job - done + run_fio="$fio_bin --eta=never " + for vm_num in $1; do + cp $fio_job $tmp_detach_job + vm_check_scsi_location $vm_num + disk_array=($SCSI_DISK) + disk=${disk_array[0]} + echo "[nvme-host$disk]" >> $tmp_detach_job + echo "filename=/dev/$disk" >> $tmp_detach_job + vm_scp "$vm_num" $tmp_detach_job 127.0.0.1:/root/default_integrity.job + run_fio+="--client=127.0.0.1,$(vm_fio_socket $vm_num) --remote-config /root/default_integrity.job " + rm $tmp_detach_job + done } function prepare_fio_cmd_tc2_iter2() { - print_test_fio_header + print_test_fio_header - run_fio="$fio_bin --eta=never " - for vm_num in $1; do - cp $fio_job $tmp_detach_job - if [ $vm_num == 2 ]; then - vm_job_name=default_integrity_3discs.job - else - vm_job_name=default_integrity_4discs.job - fi - vm_check_scsi_location $vm_num - for disk in $SCSI_DISK; do - echo "[nvme-host$disk]" >> $tmp_detach_job - echo "filename=/dev/$disk" >> $tmp_detach_job - done - vm_scp "$vm_num" $tmp_detach_job 127.0.0.1:/root/$vm_job_name - run_fio+="--client=127.0.0.1,$(vm_fio_socket $vm_num) --remote-config /root/${vm_job_name} " - rm $tmp_detach_job - done + run_fio="$fio_bin --eta=never " + for vm_num in $1; do + cp $fio_job $tmp_detach_job + if [ $vm_num == 2 ]; then + vm_job_name=default_integrity_3discs.job + else + vm_job_name=default_integrity_4discs.job + fi + vm_check_scsi_location $vm_num + for disk in $SCSI_DISK; do + echo "[nvme-host$disk]" >> $tmp_detach_job + echo "filename=/dev/$disk" >> $tmp_detach_job + done + vm_scp "$vm_num" $tmp_detach_job 127.0.0.1:/root/$vm_job_name + run_fio+="--client=127.0.0.1,$(vm_fio_socket $vm_num) --remote-config /root/${vm_job_name} " + rm $tmp_detach_job + done } - function prepare_fio_cmd_tc3_iter1() { - print_test_fio_header + print_test_fio_header - run_fio="$fio_bin --eta=never " - for vm_num in $1; do - cp $fio_job $tmp_detach_job - if [ $vm_num == 2 ]; then - vm_job_name=default_integrity_3discs.job - else - vm_job_name=default_integrity_4discs.job - fi - vm_check_scsi_location $vm_num - j=1 - for disk in $SCSI_DISK; do - if [ $vm_num == 2 ]; then - if [ $j == 1 ]; then - (( j++ )) - continue - fi - fi - echo "[nvme-host$disk]" >> $tmp_detach_job - echo "filename=/dev/$disk" >> $tmp_detach_job - (( j++ )) - done - vm_scp "$vm_num" $tmp_detach_job 127.0.0.1:/root/$vm_job_name - run_fio+="--client=127.0.0.1,$(vm_fio_socket $vm_num) --remote-config /root/$vm_job_name " - rm $tmp_detach_job - done + run_fio="$fio_bin --eta=never " + for vm_num in $1; do + cp $fio_job $tmp_detach_job + if [ $vm_num == 2 ]; then + vm_job_name=default_integrity_3discs.job + else + vm_job_name=default_integrity_4discs.job + fi + vm_check_scsi_location $vm_num + j=1 + for disk in $SCSI_DISK; do + if [ $vm_num == 2 ]; then + if [ $j == 1 ]; then + ((j++)) + continue + fi + fi + echo "[nvme-host$disk]" >> $tmp_detach_job + echo "filename=/dev/$disk" >> $tmp_detach_job + ((j++)) + done + vm_scp "$vm_num" $tmp_detach_job 127.0.0.1:/root/$vm_job_name + run_fio+="--client=127.0.0.1,$(vm_fio_socket $vm_num) --remote-config /root/$vm_job_name " + rm $tmp_detach_job + done } # During fio test for all devices remove first device from fifth controller and check if fio fails. # Also check if disc has been removed from VM. function hotdetach_tc1() { - notice "Hotdetach test case 1" - first_disk="" - get_first_disk "2" first_disk - prepare_fio_cmd_tc1_iter1 "2 3" - $run_fio & - last_pid=$! - sleep 3 - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p4.2 0 - set +xe - wait $last_pid - check_fio_retcode "Hotdetach test case 1: Iteration 1." 1 $? - set -xe - second_disk="" - get_first_disk "2" second_disk - check_disks $first_disk $second_disk - clear_after_tests + notice "Hotdetach test case 1" + first_disk="" + get_first_disk "2" first_disk + prepare_fio_cmd_tc1_iter1 "2 3" + $run_fio & + last_pid=$! + sleep 3 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p4.2 0 + set +xe + wait $last_pid + check_fio_retcode "Hotdetach test case 1: Iteration 1." 1 $? + set -xe + second_disk="" + get_first_disk "2" second_disk + check_disks $first_disk $second_disk + clear_after_tests } # During fio test for device from third VM remove first device from fifth controller and check if fio fails. # Also check if disc has been removed from VM. function hotdetach_tc2() { - notice "Hotdetach test case 2" - sleep 2 - first_disk="" - get_first_disk "2" first_disk - prepare_fio_cmd_tc2_iter1 "2" - $run_fio & - last_pid=$! - sleep 3 - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p4.2 0 - set +xe - wait $last_pid - check_fio_retcode "Hotdetach test case 2: Iteration 1." 1 $? - set -xe - second_disk="" - get_first_disk "2" second_disk - check_disks $first_disk $second_disk - clear_after_tests + notice "Hotdetach test case 2" + sleep 2 + first_disk="" + get_first_disk "2" first_disk + prepare_fio_cmd_tc2_iter1 "2" + $run_fio & + last_pid=$! + sleep 3 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p4.2 0 + set +xe + wait $last_pid + check_fio_retcode "Hotdetach test case 2: Iteration 1." 1 $? + set -xe + second_disk="" + get_first_disk "2" second_disk + check_disks $first_disk $second_disk + clear_after_tests } # Run fio test for all devices except one, then remove this device and check if fio passes. # Also check if disc has been removed from VM. function hotdetach_tc3() { - notice "Hotdetach test case 3" - sleep 2 - first_disk="" - get_first_disk "2" first_disk - prepare_fio_cmd_tc3_iter1 "2 3" - $run_fio & - last_pid=$! - sleep 3 - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p4.2 0 - wait $last_pid - check_fio_retcode "Hotdetach test case 3: Iteration 1." 0 $? - second_disk="" - get_first_disk "2" second_disk - check_disks $first_disk $second_disk - clear_after_tests + notice "Hotdetach test case 3" + sleep 2 + first_disk="" + get_first_disk "2" first_disk + prepare_fio_cmd_tc3_iter1 "2 3" + $run_fio & + last_pid=$! + sleep 3 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p4.2 0 + wait $last_pid + check_fio_retcode "Hotdetach test case 3: Iteration 1." 0 $? + second_disk="" + get_first_disk "2" second_disk + check_disks $first_disk $second_disk + clear_after_tests } # Run fio test for all devices except one and run separate fio test for this device. @@ -173,38 +172,38 @@ function hotdetach_tc3() { # Also check if disc has been removed from VM. # After reboot run fio test for remaining devices and check if fio passes. function hotdetach_tc4() { - notice "Hotdetach test case 4" - sleep 2 - first_disk="" - get_first_disk "2" first_disk - prepare_fio_cmd_tc2_iter1 "2" - $run_fio & - first_fio_pid=$! - prepare_fio_cmd_tc3_iter1 "2 3" - $run_fio & - second_fio_pid=$! - sleep 3 - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p4.2 0 - set +xe - wait $first_fio_pid - check_fio_retcode "Hotdetach test case 4: Iteration 1." 1 $? - set -xe - wait $second_fio_pid - check_fio_retcode "Hotdetach test case 4: Iteration 2." 0 $? - second_disk="" - get_first_disk "2" second_disk - check_disks $first_disk $second_disk + notice "Hotdetach test case 4" + sleep 2 + first_disk="" + get_first_disk "2" first_disk + prepare_fio_cmd_tc2_iter1 "2" + $run_fio & + first_fio_pid=$! + prepare_fio_cmd_tc3_iter1 "2 3" + $run_fio & + second_fio_pid=$! + sleep 3 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p4.2 0 + set +xe + wait $first_fio_pid + check_fio_retcode "Hotdetach test case 4: Iteration 1." 1 $? + set -xe + wait $second_fio_pid + check_fio_retcode "Hotdetach test case 4: Iteration 2." 0 $? + second_disk="" + get_first_disk "2" second_disk + check_disks $first_disk $second_disk - reboot_all_and_prepare "2 3" - sleep 2 - prepare_fio_cmd_tc2_iter2 "2 3" - $run_fio - check_fio_retcode "Hotdetach test case 4: Iteration 3." 0 $? - clear_after_tests + reboot_all_and_prepare "2 3" + sleep 2 + prepare_fio_cmd_tc2_iter2 "2 3" + $run_fio + check_fio_retcode "Hotdetach test case 4: Iteration 3." 0 $? + clear_after_tests } function clear_after_tests() { - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p4.2 0 Nvme0n1p8 + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p4.2 0 Nvme0n1p8 } hotdetach_tc1 diff --git a/test/vhost/hotplug/scsi_hotplug.sh b/test/vhost/hotplug/scsi_hotplug.sh index fca504b0aa..40132ab8a6 100755 --- a/test/vhost/hotplug/scsi_hotplug.sh +++ b/test/vhost/hotplug/scsi_hotplug.sh @@ -7,50 +7,50 @@ source $rootdir/test/vhost/common.sh source $rootdir/test/vhost/hotplug/common.sh if [[ $scsi_hot_remove_test == 1 ]] && [[ $blk_hot_remove_test == 1 ]]; then - notice "Vhost-scsi and vhost-blk hotremove tests cannot be run together" + notice "Vhost-scsi and vhost-blk hotremove tests cannot be run together" fi # Run spdk by calling run_vhost from hotplug/common.sh. # Then prepare vhost with rpc calls and setup and run 4 VMs. function pre_hot_attach_detach_test_case() { - used_vms="" - $rpc_py vhost_create_scsi_controller naa.Nvme0n1p0.0 - $rpc_py vhost_create_scsi_controller naa.Nvme0n1p1.0 - $rpc_py vhost_create_scsi_controller naa.Nvme0n1p2.1 - $rpc_py vhost_create_scsi_controller naa.Nvme0n1p3.1 - $rpc_py vhost_create_scsi_controller naa.Nvme0n1p4.2 - $rpc_py vhost_create_scsi_controller naa.Nvme0n1p5.2 - $rpc_py vhost_create_scsi_controller naa.Nvme0n1p6.3 - $rpc_py vhost_create_scsi_controller naa.Nvme0n1p7.3 - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p4.2 0 Nvme0n1p8 - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p4.2 1 Nvme0n1p9 - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p5.2 0 Nvme0n1p10 - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p5.2 1 Nvme0n1p11 - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p6.3 0 Nvme0n1p12 - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p6.3 1 Nvme0n1p13 - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p7.3 0 Nvme0n1p14 - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p7.3 1 Nvme0n1p15 - vms_setup_and_run "0 1 2 3" - vms_prepare "0 1 2 3" + used_vms="" + $rpc_py vhost_create_scsi_controller naa.Nvme0n1p0.0 + $rpc_py vhost_create_scsi_controller naa.Nvme0n1p1.0 + $rpc_py vhost_create_scsi_controller naa.Nvme0n1p2.1 + $rpc_py vhost_create_scsi_controller naa.Nvme0n1p3.1 + $rpc_py vhost_create_scsi_controller naa.Nvme0n1p4.2 + $rpc_py vhost_create_scsi_controller naa.Nvme0n1p5.2 + $rpc_py vhost_create_scsi_controller naa.Nvme0n1p6.3 + $rpc_py vhost_create_scsi_controller naa.Nvme0n1p7.3 + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p4.2 0 Nvme0n1p8 + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p4.2 1 Nvme0n1p9 + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p5.2 0 Nvme0n1p10 + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p5.2 1 Nvme0n1p11 + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p6.3 0 Nvme0n1p12 + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p6.3 1 Nvme0n1p13 + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p7.3 0 Nvme0n1p14 + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p7.3 1 Nvme0n1p15 + vms_setup_and_run "0 1 2 3" + vms_prepare "0 1 2 3" } function clear_vhost_config() { - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p4.2 0 - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p4.2 1 - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p5.2 0 - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p5.2 1 - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p6.3 0 - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p6.3 1 - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p7.3 0 - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p7.3 1 - $rpc_py vhost_delete_controller naa.Nvme0n1p0.0 - $rpc_py vhost_delete_controller naa.Nvme0n1p1.0 - $rpc_py vhost_delete_controller naa.Nvme0n1p2.1 - $rpc_py vhost_delete_controller naa.Nvme0n1p3.1 - $rpc_py vhost_delete_controller naa.Nvme0n1p4.2 - $rpc_py vhost_delete_controller naa.Nvme0n1p5.2 - $rpc_py vhost_delete_controller naa.Nvme0n1p6.3 - $rpc_py vhost_delete_controller naa.Nvme0n1p7.3 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p4.2 0 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p4.2 1 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p5.2 0 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p5.2 1 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p6.3 0 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p6.3 1 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p7.3 0 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p7.3 1 + $rpc_py vhost_delete_controller naa.Nvme0n1p0.0 + $rpc_py vhost_delete_controller naa.Nvme0n1p1.0 + $rpc_py vhost_delete_controller naa.Nvme0n1p2.1 + $rpc_py vhost_delete_controller naa.Nvme0n1p3.1 + $rpc_py vhost_delete_controller naa.Nvme0n1p4.2 + $rpc_py vhost_delete_controller naa.Nvme0n1p5.2 + $rpc_py vhost_delete_controller naa.Nvme0n1p6.3 + $rpc_py vhost_delete_controller naa.Nvme0n1p7.3 } trap 'error_exit "${FUNCNAME}" "${LINENO}"' ERR @@ -73,20 +73,20 @@ $rpc_py bdev_split_create HotInNvme3n1 2 $rpc_py bdev_get_bdevs if [[ $scsi_hot_remove_test == 0 ]] && [[ $blk_hot_remove_test == 0 ]]; then - pre_hot_attach_detach_test_case - $testdir/scsi_hotattach.sh --fio-bin=$fio_bin & - first_script=$! - $testdir/scsi_hotdetach.sh --fio-bin=$fio_bin & - second_script=$! - wait $first_script - wait $second_script - vm_shutdown_all - clear_vhost_config + pre_hot_attach_detach_test_case + $testdir/scsi_hotattach.sh --fio-bin=$fio_bin & + first_script=$! + $testdir/scsi_hotdetach.sh --fio-bin=$fio_bin & + second_script=$! + wait $first_script + wait $second_script + vm_shutdown_all + clear_vhost_config fi if [[ $scsi_hot_remove_test == 1 ]]; then - source $testdir/scsi_hotremove.sh + source $testdir/scsi_hotremove.sh fi if [[ $blk_hot_remove_test == 1 ]]; then - source $testdir/blk_hotremove.sh + source $testdir/blk_hotremove.sh fi post_test_case diff --git a/test/vhost/hotplug/scsi_hotremove.sh b/test/vhost/hotplug/scsi_hotremove.sh index c234c4d2e1..1dee4ac7f7 100644 --- a/test/vhost/hotplug/scsi_hotremove.sh +++ b/test/vhost/hotplug/scsi_hotremove.sh @@ -16,213 +16,213 @@ set -xe # which results in also performing read operations. function prepare_fio_cmd_tc1() { - print_test_fio_header + print_test_fio_header - run_fio="$fio_bin --eta=never " - for vm_num in $1; do - cp $fio_job $tmp_detach_job - vm_check_scsi_location $vm_num - for disk in $SCSI_DISK; do - cat <<- EOL >> $tmp_detach_job - [nvme-host$disk] - filename=/dev/$disk - size=100% - EOL - done - vm_scp "$vm_num" $tmp_detach_job 127.0.0.1:/root/default_integrity_2discs.job - run_fio+="--client=127.0.0.1,$(vm_fio_socket $vm_num) --remote-config /root/default_integrity_2discs.job " - rm $tmp_detach_job - done + run_fio="$fio_bin --eta=never " + for vm_num in $1; do + cp $fio_job $tmp_detach_job + vm_check_scsi_location $vm_num + for disk in $SCSI_DISK; do + cat <<- EOL >> $tmp_detach_job + [nvme-host$disk] + filename=/dev/$disk + size=100% + EOL + done + vm_scp "$vm_num" $tmp_detach_job 127.0.0.1:/root/default_integrity_2discs.job + run_fio+="--client=127.0.0.1,$(vm_fio_socket $vm_num) --remote-config /root/default_integrity_2discs.job " + rm $tmp_detach_job + done } # Vhost SCSI hot-remove test cases. # Test Case 1 function scsi_hotremove_tc1() { - echo "Scsi hotremove test case 1" - traddr="" - get_traddr "Nvme0" - # 1. Run the command to hot remove NVMe disk. - delete_nvme "Nvme0" - # 2. If vhost had crashed then tests would stop running - sleep 1 - add_nvme "HotInNvme0" "$traddr" + echo "Scsi hotremove test case 1" + traddr="" + get_traddr "Nvme0" + # 1. Run the command to hot remove NVMe disk. + delete_nvme "Nvme0" + # 2. If vhost had crashed then tests would stop running + sleep 1 + add_nvme "HotInNvme0" "$traddr" } # Test Case 2 function scsi_hotremove_tc2() { - echo "Scsi hotremove test case 2" - # 1. Attach split NVMe bdevs to scsi controller. - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p0.0 0 HotInNvme0n1p0 - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p1.0 0 Mallocp0 - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p2.1 0 HotInNvme0n1p1 - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p3.1 0 Mallocp1 + echo "Scsi hotremove test case 2" + # 1. Attach split NVMe bdevs to scsi controller. + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p0.0 0 HotInNvme0n1p0 + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p1.0 0 Mallocp0 + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p2.1 0 HotInNvme0n1p1 + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p3.1 0 Mallocp1 - # 2. Run two VMs, attached to scsi controllers. - vms_setup - vm_run_with_arg 0 1 - vms_prepare "0 1" + # 2. Run two VMs, attached to scsi controllers. + vms_setup + vm_run_with_arg 0 1 + vms_prepare "0 1" - vm_check_scsi_location "0" - local disks="$SCSI_DISK" + vm_check_scsi_location "0" + local disks="$SCSI_DISK" - traddr="" - get_traddr "Nvme0" - prepare_fio_cmd_tc1 "0 1" - # 3. Run FIO I/O traffic with verification enabled on on both NVMe disks in VM. - $run_fio & - local last_pid=$! - sleep 3 - # 4. Run the command to hot remove NVMe disk. - delete_nvme "HotInNvme0" + traddr="" + get_traddr "Nvme0" + prepare_fio_cmd_tc1 "0 1" + # 3. Run FIO I/O traffic with verification enabled on on both NVMe disks in VM. + $run_fio & + local last_pid=$! + sleep 3 + # 4. Run the command to hot remove NVMe disk. + delete_nvme "HotInNvme0" - # 5. Check that fio job run on hot-remove device stopped on VM. - # Expected: Fio should return error message and return code != 0. - wait_for_finish $last_pid || retcode=$? - check_fio_retcode "Scsi hotremove test case 2: Iteration 1." 1 $retcode + # 5. Check that fio job run on hot-remove device stopped on VM. + # Expected: Fio should return error message and return code != 0. + wait_for_finish $last_pid || retcode=$? + check_fio_retcode "Scsi hotremove test case 2: Iteration 1." 1 $retcode - # 6. Check if removed devices are gone from VM. - vm_check_scsi_location "0" - local new_disks="$SCSI_DISK" - check_disks "$disks" "$new_disks" - # 7. Reboot both VMs. - reboot_all_and_prepare "0 1" - # 8. Run FIO I/O traffic with verification enabled on on both VMs. - local retcode=0 - $run_fio & - wait_for_finish $! || retcode=$? - # 9. Check that fio job run on hot-remove device stopped on both VMs. - # Expected: Fio should return error message and return code != 0. - check_fio_retcode "Scsi hotremove test case 2: Iteration 2." 1 $retcode - vm_shutdown_all - add_nvme "HotInNvme1" "$traddr" - sleep 1 + # 6. Check if removed devices are gone from VM. + vm_check_scsi_location "0" + local new_disks="$SCSI_DISK" + check_disks "$disks" "$new_disks" + # 7. Reboot both VMs. + reboot_all_and_prepare "0 1" + # 8. Run FIO I/O traffic with verification enabled on on both VMs. + local retcode=0 + $run_fio & + wait_for_finish $! || retcode=$? + # 9. Check that fio job run on hot-remove device stopped on both VMs. + # Expected: Fio should return error message and return code != 0. + check_fio_retcode "Scsi hotremove test case 2: Iteration 2." 1 $retcode + vm_shutdown_all + add_nvme "HotInNvme1" "$traddr" + sleep 1 } # Test Case 3 function scsi_hotremove_tc3() { - echo "Scsi hotremove test case 3" - # 1. Attach added NVMe bdev to scsi controller. - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p0.0 0 HotInNvme1n1p0 - # 2. Run two VM, attached to scsi controllers. - vm_run_with_arg 0 1 - vms_prepare "0 1" - vm_check_scsi_location "0" - local disks="$SCSI_DISK" - traddr="" - get_traddr "Nvme0" - # 3. Run FIO I/O traffic with verification enabled on on both NVMe disks in VMs. - prepare_fio_cmd_tc1 "0" - $run_fio & - local last_pid=$! - sleep 3 - # 4. Run the command to hot remove NVMe disk. - delete_nvme "HotInNvme1" - # 5. Check that fio job run on hot-remove device stopped on first VM. - # Expected: Fio should return error message and return code != 0. - wait_for_finish $last_pid || retcode=$? - check_fio_retcode "Scsi hotremove test case 3: Iteration 1." 1 $retcode - # 6. Check if removed devices are gone from lsblk. - vm_check_scsi_location "0" - local new_disks="$SCSI_DISK" - check_disks "$disks" "$new_disks" - # 7. Reboot both VMs. - reboot_all_and_prepare "0 1" - # 8. Run FIO I/O traffic with verification enabled on on both VMs. - local retcode=0 - $run_fio & - wait_for_finish $! || retcode=$? - # 9. Check that fio job run on hot-remove device stopped on both VMs. - # Expected: Fio should return error message and return code != 0. - check_fio_retcode "Scsi hotremove test case 3: Iteration 2." 1 $retcode - vm_shutdown_all - add_nvme "HotInNvme2" "$traddr" - sleep 1 + echo "Scsi hotremove test case 3" + # 1. Attach added NVMe bdev to scsi controller. + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p0.0 0 HotInNvme1n1p0 + # 2. Run two VM, attached to scsi controllers. + vm_run_with_arg 0 1 + vms_prepare "0 1" + vm_check_scsi_location "0" + local disks="$SCSI_DISK" + traddr="" + get_traddr "Nvme0" + # 3. Run FIO I/O traffic with verification enabled on on both NVMe disks in VMs. + prepare_fio_cmd_tc1 "0" + $run_fio & + local last_pid=$! + sleep 3 + # 4. Run the command to hot remove NVMe disk. + delete_nvme "HotInNvme1" + # 5. Check that fio job run on hot-remove device stopped on first VM. + # Expected: Fio should return error message and return code != 0. + wait_for_finish $last_pid || retcode=$? + check_fio_retcode "Scsi hotremove test case 3: Iteration 1." 1 $retcode + # 6. Check if removed devices are gone from lsblk. + vm_check_scsi_location "0" + local new_disks="$SCSI_DISK" + check_disks "$disks" "$new_disks" + # 7. Reboot both VMs. + reboot_all_and_prepare "0 1" + # 8. Run FIO I/O traffic with verification enabled on on both VMs. + local retcode=0 + $run_fio & + wait_for_finish $! || retcode=$? + # 9. Check that fio job run on hot-remove device stopped on both VMs. + # Expected: Fio should return error message and return code != 0. + check_fio_retcode "Scsi hotremove test case 3: Iteration 2." 1 $retcode + vm_shutdown_all + add_nvme "HotInNvme2" "$traddr" + sleep 1 } # Test Case 4 function scsi_hotremove_tc4() { - echo "Scsi hotremove test case 4" - # 1. Attach NVMe bdevs to scsi controllers. - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p0.0 0 HotInNvme2n1p0 - $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p2.1 0 HotInNvme2n1p1 - # 2. Run two VMs, attach to scsi controller. - vm_run_with_arg 0 1 - vms_prepare "0 1" + echo "Scsi hotremove test case 4" + # 1. Attach NVMe bdevs to scsi controllers. + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p0.0 0 HotInNvme2n1p0 + $rpc_py vhost_scsi_controller_add_target naa.Nvme0n1p2.1 0 HotInNvme2n1p1 + # 2. Run two VMs, attach to scsi controller. + vm_run_with_arg 0 1 + vms_prepare "0 1" - # 3. Run FIO I/O traffic with verification enabled on first VM. - vm_check_scsi_location "0" - local disks_vm0="$SCSI_DISK" - # 4. Run FIO I/O traffic with verification enabled on second VM. - prepare_fio_cmd_tc1 "0" - $run_fio & - last_pid_vm0=$! + # 3. Run FIO I/O traffic with verification enabled on first VM. + vm_check_scsi_location "0" + local disks_vm0="$SCSI_DISK" + # 4. Run FIO I/O traffic with verification enabled on second VM. + prepare_fio_cmd_tc1 "0" + $run_fio & + last_pid_vm0=$! - vm_check_scsi_location "1" - local disks_vm1="$SCSI_DISK" - prepare_fio_cmd_tc1 "1" - $run_fio & - local last_pid_vm1=$! - prepare_fio_cmd_tc1 "0 1" - sleep 3 - # 5. Run the command to hot remove NVMe disk. - traddr="" - get_traddr "Nvme0" - delete_nvme "HotInNvme2" - # 6. Check that fio job run on hot-removed devices stopped. - # Expected: Fio should return error message and return code != 0. - local retcode_vm0=0 - wait_for_finish $last_pid_vm0 || retcode_vm0=$? - local retcode_vm1=0 - wait_for_finish $last_pid_vm1 || retcode_vm1=$? - check_fio_retcode "Scsi hotremove test case 4: Iteration 1." 1 $retcode_vm0 - check_fio_retcode "Scsi hotremove test case 4: Iteration 2." 1 $retcode_vm1 + vm_check_scsi_location "1" + local disks_vm1="$SCSI_DISK" + prepare_fio_cmd_tc1 "1" + $run_fio & + local last_pid_vm1=$! + prepare_fio_cmd_tc1 "0 1" + sleep 3 + # 5. Run the command to hot remove NVMe disk. + traddr="" + get_traddr "Nvme0" + delete_nvme "HotInNvme2" + # 6. Check that fio job run on hot-removed devices stopped. + # Expected: Fio should return error message and return code != 0. + local retcode_vm0=0 + wait_for_finish $last_pid_vm0 || retcode_vm0=$? + local retcode_vm1=0 + wait_for_finish $last_pid_vm1 || retcode_vm1=$? + check_fio_retcode "Scsi hotremove test case 4: Iteration 1." 1 $retcode_vm0 + check_fio_retcode "Scsi hotremove test case 4: Iteration 2." 1 $retcode_vm1 - # 7. Check if removed devices are gone from lsblk. - vm_check_scsi_location "0" - local new_disks_vm0="$SCSI_DISK" - check_disks "$disks_vm0" "$new_disks_vm0" - vm_check_scsi_location "1" - local new_disks_vm1="$SCSI_DISK" - check_disks "$disks_vm1" "$new_disks_vm1" + # 7. Check if removed devices are gone from lsblk. + vm_check_scsi_location "0" + local new_disks_vm0="$SCSI_DISK" + check_disks "$disks_vm0" "$new_disks_vm0" + vm_check_scsi_location "1" + local new_disks_vm1="$SCSI_DISK" + check_disks "$disks_vm1" "$new_disks_vm1" - # 8. Reboot both VMs. - reboot_all_and_prepare "0 1" - # 9. Run FIO I/O traffic with verification enabled on on not-removed NVMe disk. - local retcode=0 - $run_fio & - wait_for_finish $! || retcode=$? - # 10. Check that fio job run on hot-removed device stopped. - # Expect: Fio should return error message and return code != 0. - check_fio_retcode "Scsi hotremove test case 4: Iteration 3." 1 $retcode - prepare_fio_cmd_tc1 "0 1" - # 11. Run FIO I/O traffic with verification enabled on on not-removed NVMe disk. - local retcode=0 - $run_fio & - wait_for_finish $! || retcode=$? - # 12. Check finished status FIO. Write and read in the not-removed. - # NVMe disk should be successful. - # Expected: Fio should return return code == 0. - check_fio_retcode "Scsi hotremove test case 4: Iteration 4." 0 $retcode - vm_shutdown_all - add_nvme "HotInNvme3" "$traddr" - sleep 1 - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p1.0 0 - $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p3.1 0 + # 8. Reboot both VMs. + reboot_all_and_prepare "0 1" + # 9. Run FIO I/O traffic with verification enabled on on not-removed NVMe disk. + local retcode=0 + $run_fio & + wait_for_finish $! || retcode=$? + # 10. Check that fio job run on hot-removed device stopped. + # Expect: Fio should return error message and return code != 0. + check_fio_retcode "Scsi hotremove test case 4: Iteration 3." 1 $retcode + prepare_fio_cmd_tc1 "0 1" + # 11. Run FIO I/O traffic with verification enabled on on not-removed NVMe disk. + local retcode=0 + $run_fio & + wait_for_finish $! || retcode=$? + # 12. Check finished status FIO. Write and read in the not-removed. + # NVMe disk should be successful. + # Expected: Fio should return return code == 0. + check_fio_retcode "Scsi hotremove test case 4: Iteration 4." 0 $retcode + vm_shutdown_all + add_nvme "HotInNvme3" "$traddr" + sleep 1 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p1.0 0 + $rpc_py vhost_scsi_controller_remove_target naa.Nvme0n1p3.1 0 } function pre_scsi_hotremove_test_case() { - $rpc_py vhost_create_scsi_controller naa.Nvme0n1p0.0 - $rpc_py vhost_create_scsi_controller naa.Nvme0n1p1.0 - $rpc_py vhost_create_scsi_controller naa.Nvme0n1p2.1 - $rpc_py vhost_create_scsi_controller naa.Nvme0n1p3.1 + $rpc_py vhost_create_scsi_controller naa.Nvme0n1p0.0 + $rpc_py vhost_create_scsi_controller naa.Nvme0n1p1.0 + $rpc_py vhost_create_scsi_controller naa.Nvme0n1p2.1 + $rpc_py vhost_create_scsi_controller naa.Nvme0n1p3.1 } function post_scsi_hotremove_test_case() { - $rpc_py vhost_delete_controller naa.Nvme0n1p0.0 - $rpc_py vhost_delete_controller naa.Nvme0n1p1.0 - $rpc_py vhost_delete_controller naa.Nvme0n1p2.1 - $rpc_py vhost_delete_controller naa.Nvme0n1p3.1 + $rpc_py vhost_delete_controller naa.Nvme0n1p0.0 + $rpc_py vhost_delete_controller naa.Nvme0n1p1.0 + $rpc_py vhost_delete_controller naa.Nvme0n1p2.1 + $rpc_py vhost_delete_controller naa.Nvme0n1p3.1 } pre_scsi_hotremove_test_case diff --git a/test/vhost/initiator/blockdev.sh b/test/vhost/initiator/blockdev.sh index 36e41ae7bd..86e87788cb 100755 --- a/test/vhost/initiator/blockdev.sh +++ b/test/vhost/initiator/blockdev.sh @@ -14,8 +14,7 @@ function run_spdk_fio() { fio_bdev --ioengine=spdk_bdev "$@" --spdk_mem=1024 --spdk_single_seg=1 } -function create_bdev_config() -{ +function create_bdev_config() { if [ -z "$($RPC_PY bdev_get_bdevs | jq '.[] | select(.name=="Nvme0n1")')" ]; then error "Nvme0n1 bdev not found!" fi @@ -43,7 +42,7 @@ function create_bdev_config() function err_cleanup() { rm -f $testdir/bdev.json vhost_kill 0 - if [[ -n "$dummy_spdk_pid" ]] && kill -0 $dummy_spdk_pid &>/dev/null; then + if [[ -n "$dummy_spdk_pid" ]] && kill -0 $dummy_spdk_pid &> /dev/null; then killprocess $dummy_spdk_pid fi vhosttestfini @@ -70,7 +69,7 @@ rpc_cmd -s /tmp/spdk2.sock bdev_virtio_attach_controller --trtype user --traddr rpc_cmd -s /tmp/spdk2.sock bdev_virtio_attach_controller --trtype user --traddr 'naa.Malloc0.0' -d scsi --vq-count 8 'VirtioScsi1' rpc_cmd -s /tmp/spdk2.sock bdev_virtio_attach_controller --trtype user --traddr 'naa.Malloc1.0' -d scsi --vq-count 8 'VirtioScsi2' -cat <<-CONF > $testdir/bdev.json +cat <<- CONF > $testdir/bdev.json {"subsystems":[ $(rpc_cmd -s /tmp/spdk2.sock save_subsystem_config -n bdev) ]} diff --git a/test/vhost/integrity/integrity_start.sh b/test/vhost/integrity/integrity_start.sh index 2534d9a103..ff3e98bda8 100755 --- a/test/vhost/integrity/integrity_start.sh +++ b/test/vhost/integrity/integrity_start.sh @@ -8,9 +8,11 @@ source $rootdir/test/vhost/common.sh ctrl_type="spdk_vhost_scsi" vm_fs="ext4" -function usage() -{ - [[ -n $2 ]] && ( echo "$2"; echo ""; ) +function usage() { + [[ -n $2 ]] && ( + echo "$2" + echo "" + ) echo "Shortcut script for doing automated test" echo "Usage: $(basename $1) [OPTIONS]" echo @@ -25,8 +27,7 @@ function usage() exit 0 } -function clean_lvol_cfg() -{ +function clean_lvol_cfg() { notice "Removing lvol bdev and lvol store" $rpc_py bdev_lvol_delete lvol_store/lvol_bdev $rpc_py bdev_lvol_delete_lvstore -l lvol_store @@ -35,17 +36,19 @@ function clean_lvol_cfg() while getopts 'xh-:' optchar; do case "$optchar" in -) - case "$OPTARG" in - help) usage $0 ;; - ctrl-type=*) ctrl_type="${OPTARG#*=}" ;; - fs=*) vm_fs="${OPTARG#*=}" ;; - *) usage $0 "Invalid argument '$OPTARG'" ;; - esac - ;; - h) usage $0 ;; - x) set -x - x="-x" ;; - *) usage $0 "Invalid argument '$OPTARG'" + case "$OPTARG" in + help) usage $0 ;; + ctrl-type=*) ctrl_type="${OPTARG#*=}" ;; + fs=*) vm_fs="${OPTARG#*=}" ;; + *) usage $0 "Invalid argument '$OPTARG'" ;; + esac + ;; + h) usage $0 ;; + x) + set -x + x="-x" + ;; + *) usage $0 "Invalid argument '$OPTARG'" ;; esac done diff --git a/test/vhost/integrity/integrity_vm.sh b/test/vhost/integrity/integrity_vm.sh index 683a1851a1..5e83fef955 100755 --- a/test/vhost/integrity/integrity_vm.sh +++ b/test/vhost/integrity/integrity_vm.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -xe -MAKE="make -j$(( $(nproc) * 2 ))" +MAKE="make -j$(($(nproc) * 2))" if [[ $1 == "spdk_vhost_scsi" ]]; then devs="" @@ -11,7 +11,10 @@ if [[ $1 == "spdk_vhost_scsi" ]]; then fi done elif [[ $1 == "spdk_vhost_blk" ]]; then - devs=$(cd /sys/block; echo vd*) + devs=$( + cd /sys/block + echo vd* + ) fi fs=$2 @@ -27,7 +30,7 @@ for fs in $fs; do $parted_cmd mklabel gpt while ! ($parted_cmd print | grep -q gpt); do [[ $i -lt 100 ]] || break - i=$((i+1)) + i=$((i + 1)) sleep 0.1 done $parted_cmd mkpart primary 2048s 100% @@ -41,7 +44,7 @@ for fs in $fs; do i=0 until wipefs -a /dev/${dev}1; do [[ $i -lt 100 ]] || break - i=$((i+1)) + i=$((i + 1)) echo "Waiting for /dev/${dev}1" sleep 0.1 done @@ -51,9 +54,9 @@ for fs in $fs; do mount -o sync /dev/${dev}1 /mnt/${dev}dir fio --name="integrity" --bsrange=4k-512k --iodepth=128 --numjobs=1 --direct=1 \ - --thread=1 --group_reporting=1 --rw=randrw --rwmixread=70 \ - --filename=/mnt/${dev}dir/test_file --verify=md5 --do_verify=1 \ - --verify_backlog=1024 --fsync_on_close=1 --runtime=20 --time_based=1 --size=512m + --thread=1 --group_reporting=1 --rw=randrw --rwmixread=70 \ + --filename=/mnt/${dev}dir/test_file --verify=md5 --do_verify=1 \ + --verify_backlog=1024 --fsync_on_close=1 --runtime=20 --time_based=1 --size=512m # Print out space consumed on target device df -h /dev/$dev @@ -64,15 +67,15 @@ for fs in $fs; do rm -rf /mnt/${dev}dir parted -s /dev/${dev} rm 1 - stats=( $(cat /sys/block/$dev/stat) ) + stats=($(cat /sys/block/$dev/stat)) echo "" echo "$dev stats" printf "READ IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \ - ${stats[0]} ${stats[1]} ${stats[2]} ${stats[3]} + ${stats[0]} ${stats[1]} ${stats[2]} ${stats[3]} printf "WRITE IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \ - ${stats[4]} ${stats[5]} ${stats[6]} ${stats[7]} + ${stats[4]} ${stats[5]} ${stats[6]} ${stats[7]} printf "in flight: % 8u io ticks: % 8u time in queue: % 8u\n" \ - ${stats[8]} ${stats[9]} ${stats[10]} + ${stats[8]} ${stats[9]} ${stats[10]} echo "" done done diff --git a/test/vhost/lvol/lvol_test.sh b/test/vhost/lvol/lvol_test.sh index 6d0bc5bf9a..fba38e0598 100755 --- a/test/vhost/lvol/lvol_test.sh +++ b/test/vhost/lvol/lvol_test.sh @@ -15,86 +15,89 @@ use_fs=false nested_lvol=false distribute_cores=false -function usage() -{ - [[ -n $2 ]] && ( echo "$2"; echo ""; ) - echo "Shortcut script for doing automated test" - echo "Usage: $(basename $1) [OPTIONS]" - echo - echo "-h, --help Print help and exit" - echo " --fio-bin=PATH Path to FIO binary.;" - echo " --vm-count=INT Virtual machines to use in test;" - echo " Each VM will get one lvol bdev on each NVMe." - echo " Default: 1" - echo " --max-disks=INT Maximum number of NVMe drives to use in test." - echo " Default: will use all available NVMes." - echo " --ctrl-type=TYPE Controller type to use for test:" - echo " spdk_vhost_scsi - use spdk vhost scsi" - echo " spdk_vhost_blk - use spdk vhost block" - echo " --nested-lvol If enabled will create additional lvol bdev" - echo " on each NVMe for use as base device for next" - echo " lvol store and lvol bdevs." - echo " (NVMe->lvol_store->lvol_bdev->lvol_store->lvol_bdev)" - echo " Default: False" - echo " --thin-provisioning Create lvol bdevs thin provisioned instead of" - echo " allocating space up front" - echo " --distribute-cores Use custom config file and run vhost controllers" - echo " on different CPU cores instead of single core." - echo " Default: False" - echo "-x set -x for script debug" - echo " --multi-os Run tests on different os types in VMs" - echo " Default: False" - exit 0 +function usage() { + [[ -n $2 ]] && ( + echo "$2" + echo "" + ) + echo "Shortcut script for doing automated test" + echo "Usage: $(basename $1) [OPTIONS]" + echo + echo "-h, --help Print help and exit" + echo " --fio-bin=PATH Path to FIO binary.;" + echo " --vm-count=INT Virtual machines to use in test;" + echo " Each VM will get one lvol bdev on each NVMe." + echo " Default: 1" + echo " --max-disks=INT Maximum number of NVMe drives to use in test." + echo " Default: will use all available NVMes." + echo " --ctrl-type=TYPE Controller type to use for test:" + echo " spdk_vhost_scsi - use spdk vhost scsi" + echo " spdk_vhost_blk - use spdk vhost block" + echo " --nested-lvol If enabled will create additional lvol bdev" + echo " on each NVMe for use as base device for next" + echo " lvol store and lvol bdevs." + echo " (NVMe->lvol_store->lvol_bdev->lvol_store->lvol_bdev)" + echo " Default: False" + echo " --thin-provisioning Create lvol bdevs thin provisioned instead of" + echo " allocating space up front" + echo " --distribute-cores Use custom config file and run vhost controllers" + echo " on different CPU cores instead of single core." + echo " Default: False" + echo "-x set -x for script debug" + echo " --multi-os Run tests on different os types in VMs" + echo " Default: False" + exit 0 } -function clean_lvol_cfg() -{ - notice "Removing nested lvol bdevs" - for lvol_bdev in "${nest_lvol_bdevs[@]}"; do - $rpc_py bdev_lvol_delete $lvol_bdev - notice "nested lvol bdev $lvol_bdev removed" - done +function clean_lvol_cfg() { + notice "Removing nested lvol bdevs" + for lvol_bdev in "${nest_lvol_bdevs[@]}"; do + $rpc_py bdev_lvol_delete $lvol_bdev + notice "nested lvol bdev $lvol_bdev removed" + done - notice "Removing nested lvol stores" - for lvol_store in "${nest_lvol_stores[@]}"; do - $rpc_py bdev_lvol_delete_lvstore -u $lvol_store - notice "nested lvol store $lvol_store removed" - done + notice "Removing nested lvol stores" + for lvol_store in "${nest_lvol_stores[@]}"; do + $rpc_py bdev_lvol_delete_lvstore -u $lvol_store + notice "nested lvol store $lvol_store removed" + done - notice "Removing lvol bdevs" - for lvol_bdev in "${lvol_bdevs[@]}"; do - $rpc_py bdev_lvol_delete $lvol_bdev - notice "lvol bdev $lvol_bdev removed" - done + notice "Removing lvol bdevs" + for lvol_bdev in "${lvol_bdevs[@]}"; do + $rpc_py bdev_lvol_delete $lvol_bdev + notice "lvol bdev $lvol_bdev removed" + done - notice "Removing lvol stores" - for lvol_store in "${lvol_stores[@]}"; do - $rpc_py bdev_lvol_delete_lvstore -u $lvol_store - notice "lvol store $lvol_store removed" - done + notice "Removing lvol stores" + for lvol_store in "${lvol_stores[@]}"; do + $rpc_py bdev_lvol_delete_lvstore -u $lvol_store + notice "lvol store $lvol_store removed" + done } while getopts 'xh-:' optchar; do - case "$optchar" in - -) - case "$OPTARG" in - help) usage $0 ;; - fio-bin=*) fio_bin="--fio-bin=${OPTARG#*=}" ;; - vm-count=*) vm_count="${OPTARG#*=}" ;; - max-disks=*) max_disks="${OPTARG#*=}" ;; - ctrl-type=*) ctrl_type="${OPTARG#*=}" ;; - nested-lvol) nested_lvol=true ;; - distribute-cores) distribute_cores=true ;; - thin-provisioning) thin=" -t " ;; - multi-os) multi_os=true ;; - *) usage $0 "Invalid argument '$OPTARG'" ;; - esac - ;; - h) usage $0 ;; - x) set -x - x="-x" ;; - *) usage $0 "Invalid argument '$OPTARG'" - esac + case "$optchar" in + -) + case "$OPTARG" in + help) usage $0 ;; + fio-bin=*) fio_bin="--fio-bin=${OPTARG#*=}" ;; + vm-count=*) vm_count="${OPTARG#*=}" ;; + max-disks=*) max_disks="${OPTARG#*=}" ;; + ctrl-type=*) ctrl_type="${OPTARG#*=}" ;; + nested-lvol) nested_lvol=true ;; + distribute-cores) distribute_cores=true ;; + thin-provisioning) thin=" -t " ;; + multi-os) multi_os=true ;; + *) usage $0 "Invalid argument '$OPTARG'" ;; + esac + ;; + h) usage $0 ;; + x) + set -x + x="-x" + ;; + *) usage $0 "Invalid argument '$OPTARG'" ;; + esac done vhosttestinit @@ -103,16 +106,16 @@ notice "Get NVMe disks:" nvmes=($(get_nvme_bdfs)) if [[ -z $max_disks ]]; then - max_disks=${#nvmes[@]} + max_disks=${#nvmes[@]} fi -if (( ${#nvmes[@]} < max_disks )); then - fail "Number of NVMe drives (${#nvmes[@]}) is lower than number of requested disks for test ($max_disks)" +if ((${#nvmes[@]} < max_disks)); then + fail "Number of NVMe drives (${#nvmes[@]}) is lower than number of requested disks for test ($max_disks)" fi if $distribute_cores; then - # FIXME: this need to be handled entirely in common.sh - source $testdir/autotest.config + # FIXME: this need to be handled entirely in common.sh + source $testdir/autotest.config fi trap 'error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR @@ -132,41 +135,41 @@ nest_lvol_bdevs=() used_vms="" # On each NVMe create one lvol store -for (( i=0; i$share_dir/output.log &" @@ -188,15 +177,13 @@ function host_2_start_vhost() wait_for_remote } -function setup_share() -{ +function setup_share() { trap 'cleanup_share; error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT host_1_create_share host_2_create_share } -function migration_tc3() -{ +function migration_tc3() { check_rdma_connection setup_share host1_start_nvmf diff --git a/test/vhost/migration/migration-tc3b.sh b/test/vhost/migration/migration-tc3b.sh index d3d5364102..22d54df731 100644 --- a/test/vhost/migration/migration-tc3b.sh +++ b/test/vhost/migration/migration-tc3b.sh @@ -10,8 +10,7 @@ target_vm_ctrl=naa.VhostScsi0.$target_vm rpc="$rootdir/scripts/rpc.py -s $(get_vhost_dir 1)/rpc.sock" share_dir=$VHOST_DIR/share -function host_2_cleanup_vhost() -{ +function host_2_cleanup_vhost() { notice "Shutting down VM $target_vm" vm_kill $target_vm @@ -24,8 +23,7 @@ function host_2_cleanup_vhost() sleep 1 } -function host_2_start_vhost() -{ +function host_2_start_vhost() { echo "BASE DIR $VHOST_DIR" vhost_work_dir=$VHOST_DIR/vhost1 mkdir -p $vhost_work_dir @@ -67,7 +65,7 @@ timeout=40 while is_fio_running $target_vm; do sleep 1 echo -n "." - if (( timeout-- == 0 )); then + if ((timeout-- == 0)); then error "timeout while waiting for FIO!" fi done diff --git a/test/vhost/migration/migration.sh b/test/vhost/migration/migration.sh index 9afdb7655c..8f461e6ca6 100755 --- a/test/vhost/migration/migration.sh +++ b/test/vhost/migration/migration.sh @@ -7,7 +7,6 @@ source $rootdir/test/vhost/common.sh source $testdir/migration-tc1.sh source $testdir/migration-tc2.sh - vms=() declare -A vms_os declare -A vms_raw_disks @@ -20,9 +19,11 @@ MGMT_TARGET_IP="" MGMT_INITIATOR_IP="" RDMA_TARGET_IP="" RDMA_INITIATOR_IP="" -function usage() -{ - [[ -n $2 ]] && ( echo "$2"; echo ""; ) +function usage() { + [[ -n $2 ]] && ( + echo "$2" + echo "" + ) echo "Shortcut script for doing automated test of live migration." echo "Usage: $(basename $1) [OPTIONS]" echo @@ -37,7 +38,7 @@ function usage() for param in "$@"; do case "$param" in - --help|-h) + --help | -h) usage $0 exit 0 ;; @@ -48,10 +49,11 @@ for param in "$@"; do --rdma-tgt-ip=*) RDMA_TARGET_IP="${param#*=}" ;; --rdma-init-ip=*) RDMA_INITIATOR_IP="${param#*=}" ;; -x) set -x ;; - -v) SPDK_VHOST_VERBOSE=true ;; + -v) SPDK_VHOST_VERBOSE=true ;; *) usage $0 "Invalid argument '$param'" - exit 1;; + exit 1 + ;; esac done @@ -59,8 +61,7 @@ vhosttestinit trap 'error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT -function vm_monitor_send() -{ +function vm_monitor_send() { local vm_num=$1 local cmd_result_file="$2" local vm_dir="$VM_DIR/$1" @@ -74,8 +75,7 @@ function vm_monitor_send() } # Migrate VM $1 -function vm_migrate() -{ +function vm_migrate() { local from_vm_dir="$VM_DIR/$1" local target_vm_dir local target_vm @@ -103,7 +103,7 @@ function vm_migrate() "quit" | vm_monitor_send $1 "$from_vm_dir/migration_result" # Post migration checks: - if ! grep "Migration status: completed" $from_vm_dir/migration_result -q; then + if ! grep "Migration status: completed" $from_vm_dir/migration_result -q; then cat $from_vm_dir/migration_result fail "Migration failed:\n" fi @@ -122,8 +122,7 @@ function vm_migrate() timing_exit vm_migrate } -function is_fio_running() -{ +function is_fio_running() { xtrace_disable if vm_exec $1 'kill -0 $(cat /root/fio.pid)'; then diff --git a/test/vhost/other/negative.sh b/test/vhost/other/negative.sh index 1e73efe713..81461c26f3 100755 --- a/test/vhost/other/negative.sh +++ b/test/vhost/other/negative.sh @@ -5,9 +5,11 @@ rootdir=$(readlink -f $testdir/../../..) source $rootdir/test/common/autotest_common.sh source $rootdir/test/vhost/common.sh -function usage() -{ - [[ -n $2 ]] && ( echo "$2"; echo ""; ) +function usage() { + [[ -n $2 ]] && ( + echo "$2" + echo "" + ) echo "Shortcut script for running vhost app." echo "Usage: $(basename $1) [-x] [-h|--help] [--clean-build]" echo "-h, --help print help and exit" @@ -20,15 +22,15 @@ run_in_background=false while getopts 'xh-:' optchar; do case "$optchar" in -) - case "$OPTARG" in - help) usage $0 ;; - conf-dir=*) CONF_DIR="${OPTARG#*=}" ;; - *) usage $0 echo "Invalid argument '$OPTARG'" ;; - esac - ;; - h) usage $0 ;; - x) set -x ;; - *) usage $0 "Invalid argument '$optchar'" ;; + case "$OPTARG" in + help) usage $0 ;; + conf-dir=*) CONF_DIR="${OPTARG#*=}" ;; + *) usage $0 echo "Invalid argument '$OPTARG'" ;; + esac + ;; + h) usage $0 ;; + x) set -x ;; + *) usage $0 "Invalid argument '$optchar'" ;; esac done @@ -57,7 +59,7 @@ if "${VHOST_APP[@]}" -x -h; then fi # Passing trace flags if spdk is build without CONFIG_DEBUG=y option make vhost exit with error -if ! "${VHOST_APP[@]}" -t vhost_scsi -h; then +if ! "${VHOST_APP[@]}" -t vhost_scsi -h; then warning "vhost did not started with trace flags enabled but ignoring this as it might not be a debug build" fi @@ -171,7 +173,7 @@ $rpc_py vhost_scsi_controller_add_target naa.0 0 Malloc0 # BLK notice "Trying to create block controller with incorrect cpumask" -if $rpc_py vhost_create_blk_controller vhost.invalid.cpumask Malloc0 --cpumask 0x2; then +if $rpc_py vhost_create_blk_controller vhost.invalid.cpumask Malloc0 --cpumask 0x2; then error "Creating block controller with incorrect cpumask succeeded, but it shouldn't" fi diff --git a/test/vhost/perf_bench/vhost_perf.sh b/test/vhost/perf_bench/vhost_perf.sh index aa1bd91b64..1b06cf7271 100755 --- a/test/vhost/perf_bench/vhost_perf.sh +++ b/test/vhost/perf_bench/vhost_perf.sh @@ -34,9 +34,11 @@ disk_cfg_splits=() disk_cfg_vms=() disk_cfg_kernel_names=() -function usage() -{ - [[ -n $2 ]] && ( echo "$2"; echo ""; ) +function usage() { + [[ -n $2 ]] && ( + echo "$2" + echo "" + ) echo "Shortcut script for doing automated test" echo "Usage: $(basename $1) [OPTIONS]" echo @@ -77,8 +79,7 @@ function usage() exit 0 } -function cleanup_lvol_cfg() -{ +function cleanup_lvol_cfg() { notice "Removing lvol bdevs" for lvol_bdev in "${lvol_bdevs[@]}"; do $rpc_py bdev_lvol_delete $lvol_bdev @@ -92,24 +93,21 @@ function cleanup_lvol_cfg() done } -function cleanup_split_cfg() -{ +function cleanup_split_cfg() { notice "Removing split vbdevs" for disk in "${disk_cfg_spdk_names[@]}"; do $rpc_py bdev_split_delete ${disk}n1 done } -function cleanup_parted_config() -{ +function cleanup_parted_config() { notice "Removing parted disk configuration" for disk in "${disk_cfg_kernel_names[@]}"; do parted -s /dev/${disk}n1 rm 1 done } -function cleanup_kernel_vhost() -{ +function cleanup_kernel_vhost() { notice "Cleaning kernel vhost configration" targetcli clearconfig confirm=True cleanup_parted_config @@ -148,33 +146,35 @@ function create_spdk_controller() { while getopts 'xh-:' optchar; do case "$optchar" in -) - case "$OPTARG" in - help) usage $0 ;; - fio-bin=*) fio_bin="--fio-bin=${OPTARG#*=}" ;; - fio-jobs=*) fio_jobs="${OPTARG#*=}" ;; - fio-iterations=*) fio_iterations="${OPTARG#*=}" ;; - vm-memory=*) vm_memory="${OPTARG#*=}" ;; - vm-image=*) VM_IMAGE="${OPTARG#*=}" ;; - vm-sar-enable) vm_sar_enable=true ;; - host-sar-enable) host_sar_enable=true ;; - sar-delay=*) sar_delay="${OPTARG#*=}" ;; - sar-interval=*) sar_interval="${OPTARG#*=}" ;; - sar-count=*) sar_count="${OPTARG#*=}" ;; - vm-throttle-iops=*) vm_throttle="${OPTARG#*=}" ;; - ctrl-type=*) ctrl_type="${OPTARG#*=}" ;; - use-split) use_split=true ;; - run-precondition) run_precondition=true ;; - precond-fio-bin=*) precond_fio_bin="${OPTARG#*=}" ;; - limit-kernel-vhost=*) kernel_cpus="${OPTARG#*=}" ;; - custom-cpu-cfg=*) custom_cpu_cfg="${OPTARG#*=}" ;; - disk-map=*) disk_map="${OPTARG#*=}" ;; - *) usage $0 "Invalid argument '$OPTARG'" ;; - esac - ;; - h) usage $0 ;; - x) set -x - x="-x" ;; - *) usage $0 "Invalid argument '$OPTARG'" + case "$OPTARG" in + help) usage $0 ;; + fio-bin=*) fio_bin="--fio-bin=${OPTARG#*=}" ;; + fio-jobs=*) fio_jobs="${OPTARG#*=}" ;; + fio-iterations=*) fio_iterations="${OPTARG#*=}" ;; + vm-memory=*) vm_memory="${OPTARG#*=}" ;; + vm-image=*) VM_IMAGE="${OPTARG#*=}" ;; + vm-sar-enable) vm_sar_enable=true ;; + host-sar-enable) host_sar_enable=true ;; + sar-delay=*) sar_delay="${OPTARG#*=}" ;; + sar-interval=*) sar_interval="${OPTARG#*=}" ;; + sar-count=*) sar_count="${OPTARG#*=}" ;; + vm-throttle-iops=*) vm_throttle="${OPTARG#*=}" ;; + ctrl-type=*) ctrl_type="${OPTARG#*=}" ;; + use-split) use_split=true ;; + run-precondition) run_precondition=true ;; + precond-fio-bin=*) precond_fio_bin="${OPTARG#*=}" ;; + limit-kernel-vhost=*) kernel_cpus="${OPTARG#*=}" ;; + custom-cpu-cfg=*) custom_cpu_cfg="${OPTARG#*=}" ;; + disk-map=*) disk_map="${OPTARG#*=}" ;; + *) usage $0 "Invalid argument '$OPTARG'" ;; + esac + ;; + h) usage $0 ;; + x) + set -x + x="-x" + ;; + *) usage $0 "Invalid argument '$OPTARG'" ;; esac done @@ -202,20 +202,20 @@ fi if [[ $run_precondition == true ]]; then # Using the same precondition routine possible for lvols thanks # to --clear-method option. Lvols should not UNMAP on creation. - json_cfg=$rootdir/nvme.json - cat <<-JSON >"$json_cfg" - {"subsystems":[ - $("$rootdir/scripts/gen_nvme.sh" --json) - ]} -JSON - mapfile -t nvmes < <(grep -oP "Nvme\d+" "$json_cfg") - fio_filename=$(printf ":%sn1" "${nvmes[@]}") - fio_filename=${fio_filename:1} - $precond_fio_bin --name="precondition" \ - --ioengine="${rootdir}/examples/bdev/fio_plugin/fio_plugin" \ - --rw="write" --spdk_json_conf="$json_cfg" --thread="1" \ - --group_reporting --direct="1" --size="100%" --loops="2" --bs="256k" \ - --iodepth=32 --filename="${fio_filename}" || true + json_cfg=$rootdir/nvme.json + cat <<- JSON > "$json_cfg" + {"subsystems":[ + $("$rootdir/scripts/gen_nvme.sh" --json) + ]} + JSON + mapfile -t nvmes < <(grep -oP "Nvme\d+" "$json_cfg") + fio_filename=$(printf ":%sn1" "${nvmes[@]}") + fio_filename=${fio_filename:1} + $precond_fio_bin --name="precondition" \ + --ioengine="${rootdir}/examples/bdev/fio_plugin/fio_plugin" \ + --rw="write" --spdk_json_conf="$json_cfg" --thread="1" \ + --group_reporting --direct="1" --size="100%" --loops="2" --bs="256k" \ + --iodepth=32 --filename="${fio_filename}" || true fi set +x @@ -239,7 +239,6 @@ done unset IFS set -x - if [[ "$ctrl_type" == "kernel_vhost" ]]; then notice "Configuring kernel vhost..." trap 'vm_kill_all; sleep 1; cleanup_kernel_vhost; error_exit "${FUNCNAME}" "${LINENO}"' INT ERR @@ -247,18 +246,18 @@ if [[ "$ctrl_type" == "kernel_vhost" ]]; then # Split disks using parted for kernel vhost newline=$'\n' backstores=() - for (( i=0; i<${#disk_cfg_kernel_names[@]}; i++ )); do + for ((i = 0; i < ${#disk_cfg_kernel_names[@]}; i++)); do nvme=${disk_cfg_kernel_names[$i]} splits=${disk_cfg_splits[$i]} notice " Creating extended partition on disk /dev/${nvme}n1" parted -s /dev/${nvme}n1 mklabel msdos parted -s /dev/${nvme}n1 mkpart extended 2048s 100% - part_size=$((100/${disk_cfg_splits[$i]})) # Split 100% of disk into roughly even parts + part_size=$((100 / ${disk_cfg_splits[$i]})) # Split 100% of disk into roughly even parts echo " Creating ${splits} partitions of relative disk size ${part_size}" for p in $(seq 0 $((splits - 1))); do - p_start=$((p*part_size)) - p_end=$((p_start+part_size)) + p_start=$((p * part_size)) + p_end=$((p_start + part_size)) parted -s /dev/${nvme}n1 mkpart logical ${p_start}% ${p_end}% sleep 3 done @@ -278,7 +277,7 @@ if [[ "$ctrl_type" == "kernel_vhost" ]]; then # Create kernel vhost controllers and add LUNs # Setup VM configurations vms_to_run=(${disk_cfg_vms[i]}) - for (( j=0; j<${#vms_to_run[@]}; j++ )); do + for ((j = 0; j < ${#vms_to_run[@]}; j++)); do # WWPN prefix misses 3 characters. Need to complete it # using block backstore number x=$(printf %03d ${vms_to_run[$j]}) @@ -298,7 +297,7 @@ else if [[ $use_split == true ]]; then notice "Configuring split bdevs configuration..." trap 'cleanup_split_cfg; error_exit "${FUNCNAME}" "${LINENO}"' INT ERR - for (( i=0; i<${#disk_cfg_bdfs[@]}; i++ )); do + for ((i = 0; i < ${#disk_cfg_bdfs[@]}; i++)); do nvme_bdev=$($rpc_py bdev_nvme_attach_controller -b ${disk_cfg_spdk_names[$i]} -t pcie -a ${disk_cfg_bdfs[$i]}) notice "Created NVMe Bdev: $nvme_bdev with BDF ${disk_cfg_bdfs[$i]}" @@ -310,7 +309,7 @@ else done vms_to_run=(${disk_cfg_vms[i]}) - for (( j=0; j<${#vms_to_run[@]}; j++ )); do + for ((j = 0; j < ${#vms_to_run[@]}; j++)); do notice "Setting up VM ${vms_to_run[j]}" create_spdk_controller "${vms_to_run[j]}" ${splits[j]} create_vm ${vms_to_run[j]} @@ -321,7 +320,7 @@ else else notice "Configuring LVOLs..." trap 'cleanup_lvol_cfg; error_exit "${FUNCNAME}" "${LINENO}"' INT ERR - for (( i=0; i<${#disk_cfg_bdfs[@]}; i++ )); do + for ((i = 0; i < ${#disk_cfg_bdfs[@]}; i++)); do nvme_bdev=$($rpc_py bdev_nvme_attach_controller -b ${disk_cfg_spdk_names[$i]} -t pcie -a ${disk_cfg_bdfs[$i]}) notice "Created NVMe Bdev: $nvme_bdev with BDF ${disk_cfg_bdfs[$i]}" @@ -330,9 +329,9 @@ else notice "Created Lvol Store: $ls_guid on Bdev $nvme_bdev" vms_to_run=(${disk_cfg_vms[i]}) - for (( j=0; j<${disk_cfg_splits[$i]}; j++)); do + for ((j = 0; j < ${disk_cfg_splits[$i]}; j++)); do free_mb=$(get_lvs_free_mb "$ls_guid") - size=$((free_mb / ((${disk_cfg_splits[$i]}-j)) )) + size=$((free_mb / ((${disk_cfg_splits[$i]} - j)))) lb_name=$($rpc_py bdev_lvol_create -u $ls_guid lbd_$j $size --clear-method none) lvol_bdevs+=("$lb_name") notice "Created LVOL Bdev $lb_name on Lvol Store $ls_guid on Bdev $nvme_bdev" @@ -423,7 +422,7 @@ for fio_job in ${fio_jobs//,/ }; do fi for j in $pids; do - wait $j + wait $j done if $vm_sar_enable; then diff --git a/test/vhost/readonly/delete_partition_vm.sh b/test/vhost/readonly/delete_partition_vm.sh index 01e230d0e9..efba257f0d 100755 --- a/test/vhost/readonly/delete_partition_vm.sh +++ b/test/vhost/readonly/delete_partition_vm.sh @@ -8,8 +8,7 @@ disk_name="vda" test_folder_name="readonly_test" test_file_name="some_test_file" -function error() -{ +function error() { echo "===========" echo -e "ERROR: $*" echo "===========" @@ -26,7 +25,7 @@ if [[ ! -d "/sys/block/$disk_name" ]]; then error "No vhost-blk disk found!" fi -if (( $(lsblk -r -n -o RO -d "/dev/$disk_name") == 1 )); then +if (($(lsblk -r -n -o RO -d "/dev/$disk_name") == 1)); then error "Vhost-blk disk is set as readonly!" fi diff --git a/test/vhost/readonly/disabled_readonly_vm.sh b/test/vhost/readonly/disabled_readonly_vm.sh index 61c664be53..2aec5b80a1 100755 --- a/test/vhost/readonly/disabled_readonly_vm.sh +++ b/test/vhost/readonly/disabled_readonly_vm.sh @@ -8,8 +8,7 @@ disk_name="vda" test_folder_name="readonly_test" test_file_name="some_test_file" -function error() -{ +function error() { echo "===========" echo -e "ERROR: $*" echo "===========" @@ -26,7 +25,7 @@ if [[ ! -d "/sys/block/$disk_name" ]]; then error "No vhost-blk disk found!" fi -if (( $(lsblk -r -n -o RO -d "/dev/$disk_name") == 1 )); then +if (($(lsblk -r -n -o RO -d "/dev/$disk_name") == 1)); then error "Vhost-blk disk is set as readonly!" fi diff --git a/test/vhost/readonly/enabled_readonly_vm.sh b/test/vhost/readonly/enabled_readonly_vm.sh index 29be1e4ce1..939af6f087 100755 --- a/test/vhost/readonly/enabled_readonly_vm.sh +++ b/test/vhost/readonly/enabled_readonly_vm.sh @@ -8,8 +8,7 @@ disk_name="vda" test_folder_name="readonly_test" test_file_name="some_test_file" -function error() -{ +function error() { echo "===========" echo -e "ERROR: $*" echo "===========" @@ -22,7 +21,7 @@ if [[ ! -d "/sys/block/$disk_name" ]]; then error "No vhost-blk disk found!" fi -if (( $(lsblk -r -n -o RO -d "/dev/$disk_name") == 0 )); then +if (($(lsblk -r -n -o RO -d "/dev/$disk_name") == 0)); then error "Vhost-blk disk is not set as readonly!" fi diff --git a/test/vhost/readonly/readonly.sh b/test/vhost/readonly/readonly.sh index 657696c7e3..ad66f72e02 100755 --- a/test/vhost/readonly/readonly.sh +++ b/test/vhost/readonly/readonly.sh @@ -11,9 +11,11 @@ vm_img="" disk="Nvme0n1" x="" -function usage() -{ - [[ -n $2 ]] && ( echo "$2"; echo ""; ) +function usage() { + [[ -n $2 ]] && ( + echo "$2" + echo "" + ) echo "Shortcut script for automated readonly test for vhost-block" echo "For test details check test_plan.md" echo @@ -29,18 +31,20 @@ function usage() while getopts 'xh-:' optchar; do case "$optchar" in - -) - case "$OPTARG" in - help) usage $0 && exit 0;; - vm_image=*) vm_img="${OPTARG#*=}" ;; - disk=*) disk="${OPTARG#*=}" ;; - *) usage $0 "Invalid argument '$OPTARG'" && exit 1 - esac - ;; - h) usage $0 && exit 0 ;; - x) set -x - x="-x" ;; - *) usage $0 "Invalid argument '$OPTARG'" && exit 1 + -) + case "$OPTARG" in + help) usage $0 && exit 0 ;; + vm_image=*) vm_img="${OPTARG#*=}" ;; + disk=*) disk="${OPTARG#*=}" ;; + *) usage $0 "Invalid argument '$OPTARG'" && exit 1 ;; + esac + ;; + h) usage $0 && exit 0 ;; + x) + set -x + x="-x" + ;; + *) usage $0 "Invalid argument '$OPTARG'" && exit 1 ;; esac done @@ -52,16 +56,14 @@ if [[ $EUID -ne 0 ]]; then fail "Go away user come back as root" fi -function print_tc_name() -{ +function print_tc_name() { notice "" notice "===============================================================" notice "Now running: $1" notice "===============================================================" } -function blk_ro_tc1() -{ +function blk_ro_tc1() { print_tc_name ${FUNCNAME[0]} local vm_no="0" local disk_name=$disk @@ -81,7 +83,7 @@ function blk_ro_tc1() fi fi -#Create controller and create file on disk for later test + #Create controller and create file on disk for later test notice "Creating vhost_blk controller" vhost_blk_name="naa.$disk_name.$vm_no" $rpc_py vhost_create_blk_controller $vhost_blk_name $disk_name @@ -94,7 +96,7 @@ function blk_ro_tc1() sleep 1 vm_shutdown_all -#Create readonly controller and test readonly feature + #Create readonly controller and test readonly feature notice "Removing controller and creating new one with readonly flag" $rpc_py vhost_delete_controller $vhost_blk_name $rpc_py vhost_create_blk_controller -r $vhost_blk_name $disk_name @@ -106,7 +108,7 @@ function blk_ro_tc1() sleep 3 vm_shutdown_all -#Delete file from disk and delete partition + #Delete file from disk and delete partition echo "INFO: Removing controller and creating new one" $rpc_py vhost_delete_controller $vhost_blk_name $rpc_py vhost_create_blk_controller $vhost_blk_name $disk_name diff --git a/test/vhost/shared/shared.sh b/test/vhost/shared/shared.sh index eee7f73de4..bbf0fd8580 100755 --- a/test/vhost/shared/shared.sh +++ b/test/vhost/shared/shared.sh @@ -9,8 +9,8 @@ rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock" function run_spdk_fio() { fio_bdev --ioengine=spdk_bdev \ - "$rootdir/test/vhost/common/fio_jobs/default_initiator.job" --runtime=10 --rw=randrw \ - --spdk_mem=1024 --spdk_single_seg=1 --spdk_json_conf=$testdir/bdev.json "$@" + "$rootdir/test/vhost/common/fio_jobs/default_initiator.job" --runtime=10 --rw=randrw \ + --spdk_mem=1024 --spdk_single_seg=1 --spdk_json_conf=$testdir/bdev.json "$@" } vhosttestinit diff --git a/test/vhost/vhost.sh b/test/vhost/vhost.sh index 9015efb3b3..5b050fe40b 100755 --- a/test/vhost/vhost.sh +++ b/test/vhost/vhost.sh @@ -25,7 +25,7 @@ if [[ ! -r "${VM_IMAGE}" ]]; then exit 1 fi -DISKS_NUMBER=$(lspci -mm -n | grep 0108 | tr -d '"' | awk -F " " '{print "0000:"$1}'| wc -l) +DISKS_NUMBER=$(lspci -mm -n | grep 0108 | tr -d '"' | awk -F " " '{print "0000:"$1}' | wc -l) WORKDIR=$(readlink -f $(dirname $0)) @@ -36,15 +36,15 @@ run_test "vhost_boot" $WORKDIR/vhost_boot/vhost_boot.sh --vm_image=$VM_IMAGE if [ $RUN_NIGHTLY -eq 1 ]; then echo 'Running blk integrity suite...' run_test "vhost_blk_integrity" $WORKDIR/fiotest/fio.sh -x --fio-bin=$FIO_BIN \ - --vm=0,$VM_IMAGE,Nvme0n1p0:RaidBdev0:RaidBdev1:RaidBdev2 \ - --test-type=spdk_vhost_blk \ - --fio-job=$WORKDIR/common/fio_jobs/default_integrity.job + --vm=0,$VM_IMAGE,Nvme0n1p0:RaidBdev0:RaidBdev1:RaidBdev2 \ + --test-type=spdk_vhost_blk \ + --fio-job=$WORKDIR/common/fio_jobs/default_integrity.job echo 'Running SCSI integrity suite...' run_test "vhost_scsi_integrity" $WORKDIR/fiotest/fio.sh -x --fio-bin=$FIO_BIN \ - --vm=0,$VM_IMAGE,Nvme0n1p0:RaidBdev0:RaidBdev1:RaidBdev2 \ - --test-type=spdk_vhost_scsi \ - --fio-job=$WORKDIR/common/fio_jobs/default_integrity.job + --vm=0,$VM_IMAGE,Nvme0n1p0:RaidBdev0:RaidBdev1:RaidBdev2 \ + --test-type=spdk_vhost_scsi \ + --fio-job=$WORKDIR/common/fio_jobs/default_integrity.job echo 'Running filesystem integrity suite with SCSI...' run_test "vhost_scsi_fs_integrity" $WORKDIR/integrity/integrity_start.sh --ctrl-type=spdk_vhost_scsi --fs="xfs ntfs btrfs ext4" @@ -55,53 +55,53 @@ if [ $RUN_NIGHTLY -eq 1 ]; then if [[ $DISKS_NUMBER -ge 2 ]]; then echo 'Running lvol integrity nightly suite with two cores and two controllers' run_test "vhost_scsi_2core_2ctrl" $WORKDIR/lvol/lvol_test.sh --fio-bin=$FIO_BIN \ - --ctrl-type=spdk_vhost_scsi --max-disks=2 --distribute-cores --vm-count=2 + --ctrl-type=spdk_vhost_scsi --max-disks=2 --distribute-cores --vm-count=2 echo 'Running lvol integrity nightly suite with one core and two controllers' run_test "vhost_scsi_1core_2ctrl" $WORKDIR/lvol/lvol_test.sh --fio-bin=$FIO_BIN \ - --ctrl-type=spdk_vhost_scsi --max-disks=2 --vm-count=2 + --ctrl-type=spdk_vhost_scsi --max-disks=2 --vm-count=2 fi if [[ -e $CENTOS_VM_IMAGE ]]; then echo 'Running lvol integrity nightly suite with different os types' run_test "vhost_scsi_nightly" $WORKDIR/lvol/lvol_test.sh --fio-bin=$CENTOS_FIO_BIN \ - --ctrl-type=spdk_vhost_scsi --vm-count=2 --multi-os + --ctrl-type=spdk_vhost_scsi --vm-count=2 --multi-os fi echo 'Running lvol integrity nightly suite with one core and one controller' run_test "vhost_scsi_1core_1ctrl" $WORKDIR/lvol/lvol_test.sh --fio-bin=$FIO_BIN \ - --ctrl-type=spdk_vhost_scsi --max-disks=1 + --ctrl-type=spdk_vhost_scsi --max-disks=1 if [[ $DISKS_NUMBER -ge 2 ]]; then echo 'Running lvol integrity nightly suite with two cores and two controllers' run_test "vhost_blk_2core_2ctrl" $WORKDIR/lvol/lvol_test.sh --fio-bin=$FIO_BIN \ - --ctrl-type=spdk_vhost_blk --max-disks=2 --distribute-cores --vm-count=2 + --ctrl-type=spdk_vhost_blk --max-disks=2 --distribute-cores --vm-count=2 echo 'Running lvol integrity nightly suite with one core and two controllers' run_test "vhost_blk_1core_2ctrl" $WORKDIR/lvol/lvol_test.sh --fio-bin=$FIO_BIN \ - --ctrl-type=spdk_vhost_blk --max-disks=2 --vm-count=2 + --ctrl-type=spdk_vhost_blk --max-disks=2 --vm-count=2 fi if [[ -e $CENTOS_VM_IMAGE ]]; then echo 'Running lvol integrity nightly suite with different os types' run_test "vhost_blk_nightly" $WORKDIR/lvol/lvol_test.sh --fio-bin=$CENTOS_FIO_BIN \ - --ctrl-type=spdk_vhost_blk --vm-count=2 --multi-os + --ctrl-type=spdk_vhost_blk --vm-count=2 --multi-os fi echo 'Running lvol integrity nightly suite with one core and one controller' run_test "vhost_lvol_integrity_1core_1ctrl" $WORKDIR/lvol/lvol_test.sh --fio-bin=$FIO_BIN \ - --ctrl-type=spdk_vhost_blk --max-disks=1 + --ctrl-type=spdk_vhost_blk --max-disks=1 echo 'Running readonly tests suite...' run_test "vhost_readonly" $WORKDIR/readonly/readonly.sh --vm_image=$VM_IMAGE --disk=Nvme0n1 -x echo 'Running migration suite...' run_test "vhost_migration" $WORKDIR/migration/migration.sh -x \ - --fio-bin=$FIO_BIN --os=$VM_IMAGE + --fio-bin=$FIO_BIN --os=$VM_IMAGE fi echo 'Running lvol integrity suite...' run_test "vhost_scsi_lvol_integrity" $WORKDIR/lvol/lvol_test.sh -x --fio-bin=$FIO_BIN \ ---ctrl-type=spdk_vhost_scsi --thin-provisioning + --ctrl-type=spdk_vhost_scsi --thin-provisioning echo 'Running lvol integrity suite...' run_test "vhost_blk_lvol_integrity" $WORKDIR/lvol/lvol_test.sh -x --fio-bin=$FIO_BIN \ ---ctrl-type=spdk_vhost_blk + --ctrl-type=spdk_vhost_blk run_test "spdkcli_vhost" ./test/spdkcli/vhost.sh diff --git a/test/vhost/vhost_boot/vhost_boot.sh b/test/vhost/vhost_boot/vhost_boot.sh index 51882c0089..9df2bd9708 100755 --- a/test/vhost/vhost_boot/vhost_boot.sh +++ b/test/vhost/vhost_boot/vhost_boot.sh @@ -10,8 +10,7 @@ source $rootdir/test/bdev/nbd_common.sh rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock" vm_no="0" -function err_clean -{ +function err_clean() { trap - ERR print_backtrace set +e @@ -25,9 +24,11 @@ function err_clean exit 1 } -function usage() -{ - [[ -n $2 ]] && ( echo "$2"; echo ""; ) +function usage() { + [[ -n $2 ]] && ( + echo "$2" + echo "" + ) echo "Usage: $(basename $1) vm_image=PATH [-h|--help]" echo "-h, --help Print help and exit" echo " --vm_image=PATH Path to VM image used in these tests" @@ -36,11 +37,11 @@ function usage() while getopts 'h-:' optchar; do case "$optchar" in -) - case "$OPTARG" in - vm_image=*) os_image="${OPTARG#*=}" ;; - *) usage $0 echo "Invalid argument '$OPTARG'" && exit 1 ;; - esac - ;; + case "$OPTARG" in + vm_image=*) os_image="${OPTARG#*=}" ;; + *) usage $0 echo "Invalid argument '$OPTARG'" && exit 1 ;; + esac + ;; h) usage $0 && exit 0 ;; *) usage $0 "Invalid argument '$optchar'" && exit 1 ;; esac diff --git a/test/vhost/windows/windows.sh b/test/vhost/windows/windows.sh index 8c716e62a2..182f1ae645 100755 --- a/test/vhost/windows/windows.sh +++ b/test/vhost/windows/windows.sh @@ -11,9 +11,11 @@ ssh_pass="" vm_num="0" vm_image="/home/sys_sgsw/windows_server.qcow2" -function usage() -{ - [[ -n $2 ]] && ( echo "$2"; echo ""; ) +function usage() { + [[ -n $2 ]] && ( + echo "$2" + echo "" + ) echo "Windows Server automated test" echo "Usage: $(basename $1) [OPTIONS]" echo "--vm-ssh-pass=PASSWORD Text password for the VM" @@ -30,17 +32,19 @@ function usage() while getopts 'xh-:' optchar; do case "$optchar" in -) - case "$OPTARG" in - help) usage $0 ;; - vm-ssh-pass=*) ssh_pass="${OPTARG#*=}" ;; - vm-image=*) vm_image="${OPTARG#*=}" ;; - ctrl-type=*) ctrl_type="${OPTARG#*=}" ;; - esac - ;; - h) usage $0 ;; - x) set -x - x="-x" ;; - *) usage $0 "Invalid argument '$OPTARG'" + case "$OPTARG" in + help) usage $0 ;; + vm-ssh-pass=*) ssh_pass="${OPTARG#*=}" ;; + vm-image=*) vm_image="${OPTARG#*=}" ;; + ctrl-type=*) ctrl_type="${OPTARG#*=}" ;; + esac + ;; + h) usage $0 ;; + x) + set -x + x="-x" + ;; + *) usage $0 "Invalid argument '$OPTARG'" ;; esac done @@ -53,8 +57,7 @@ done # But they apply to rather old Windows distributions. # Potentially using Windows Server 2016 and newer may solve the issue # due to OpenSSH being available directly from Windows Store. -function vm_sshpass() -{ +function vm_sshpass() { vm_num_is_valid $1 || return 1 local ssh_cmd diff --git a/test/vhost/windows/windows_scsi_compliance.sh b/test/vhost/windows/windows_scsi_compliance.sh index 1479a83c7c..e95a4f6e15 100755 --- a/test/vhost/windows/windows_scsi_compliance.sh +++ b/test/vhost/windows/windows_scsi_compliance.sh @@ -16,9 +16,11 @@ vm_num=1 keep_results_dir=false rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock" -function usage() -{ - [[ -n $2 ]] && ( echo "$2"; echo ""; ) +function usage() { + [[ -n $2 ]] && ( + echo "$2" + echo "" + ) echo "Windows Server scsi compliance test" echo "Usage: $(basename $1) [OPTIONS]" echo " --vm-ssh-pass=PASSWORD Text password for the VM" @@ -31,15 +33,15 @@ function usage() while getopts 'h-:' optchar; do case "$optchar" in -) - case "$OPTARG" in - help) usage $0 ;; - vm-ssh-pass=*) ssh_pass="${OPTARG#*=}" ;; - vm-image-path=*) WINDOWS_IMG="${OPTARG#*=}" ;; - keep_results*) keep_results_dir=true ;; - esac - ;; - h) usage $0 ;; - *) usage $0 "Invalid argument '$OPTARG'" + case "$OPTARG" in + help) usage $0 ;; + vm-ssh-pass=*) ssh_pass="${OPTARG#*=}" ;; + vm-image-path=*) WINDOWS_IMG="${OPTARG#*=}" ;; + keep_results*) keep_results_dir=true ;; + esac + ;; + h) usage $0 ;; + *) usage $0 "Invalid argument '$OPTARG'" ;; esac done diff --git a/test/vmd/vmd.sh b/test/vmd/vmd.sh index 480372afab..f108a1f315 100755 --- a/test/vmd/vmd.sh +++ b/test/vmd/vmd.sh @@ -8,27 +8,28 @@ source $rootdir/test/common/autotest_common.sh rpc_py=$rootdir/scripts/rpc.py VMD_WHITELIST=() -function vmd_identify { +function vmd_identify() { for bdf in $pci_devs; do $rootdir/examples/nvme/identify/identify -i 0 -V -r "trtype:PCIe traddr:$bdf" done } -function vmd_perf { +function vmd_perf() { for bdf in $pci_devs; do $rootdir/examples/nvme/perf/perf -q 128 -w read -o 12288 -t 1 -LL -i 0 -V -r "trtype:PCIe traddr:$bdf" done } -function vmd_fio { +function vmd_fio() { PLUGIN_DIR=$rootdir/examples/nvme/fio_plugin for bdf in $pci_devs; do fio_nvme $testdir/config/config.fio --filename="trtype=PCIe traddr=${bdf//:/.} ns=1" done } -function vmd_bdev_svc { - $rootdir/test/app/bdev_svc/bdev_svc --wait-for-rpc & svcpid=$! +function vmd_bdev_svc() { + $rootdir/test/app/bdev_svc/bdev_svc --wait-for-rpc & + svcpid=$! trap 'killprocess $svcpid; exit 1' SIGINT SIGTERM EXIT # Wait until bdev_svc starts @@ -45,7 +46,6 @@ function vmd_bdev_svc { killprocess $svcpid } - # Re-run setup.sh script and only attach VMD devices to uio/vfio. $rootdir/scripts/setup.sh reset