1#!/usr/bin/env bash 2 3testdir=$(readlink -f $(dirname $0)) 4rootdir=$(readlink -f $testdir/../../..) 5source $rootdir/test/common/autotest_common.sh 6source $rootdir/test/nvmf/common.sh 7 8if [ "$TEST_TRANSPORT" != "rdma" ]; then 9 exit 0 10fi 11 12MALLOC_BDEV_SIZE=256 13MALLOC_BLOCK_SIZE=512 14subsystem="0" 15 16function gen_malloc_json() { 17 jq . <<- JSON 18 { 19 "subsystems": [ 20 { 21 "subsystem": "bdev", 22 "config": [ 23 { 24 "method": "bdev_malloc_create", 25 "params": { 26 "name": "Malloc0", 27 "num_blocks": 131072, 28 "block_size": 512, 29 "uuid": "e1c24cb1-dd44-4be6-8d67-de92a332013f", 30 "optimal_io_boundary": 2 31 } 32 }, 33 { 34 "method": "bdev_wait_for_examine" 35 } 36 ] 37 } 38 ] 39 } 40 JSON 41} 42 43function gen_lvol_nvme_json() { 44 local subsystem=$1 45 46 jq . <<- JSON 47 { 48 "subsystems": [ 49 { 50 "subsystem": "bdev", 51 "config": [ 52 { 53 "method": "bdev_nvme_attach_controller", 54 "params": { 55 "name": "Nvme${subsystem}", 56 "trtype": "$TEST_TRANSPORT", 57 "adrfam": "IPv4", 58 "traddr": "$NVMF_FIRST_TARGET_IP", 59 "trsvcid": "$NVMF_PORT", 60 "subnqn": "nqn.2016-06.io.spdk:cnode${subsystem}" 61 } 62 }, 63 { 64 "method": "bdev_lvol_create_lvstore", 65 "params": { 66 "bdev_name": "Nvme${subsystem}n1", 67 "lvs_name": "lvs${subsystem}" 68 } 69 }, 70 { 71 "method": "bdev_lvol_create", 72 "params": { 73 "lvol_name": "lvol${subsystem}", 74 "size": 134217728, 75 "thin_provision": true, 76 "lvs_name": "lvs${subsystem}" 77 } 78 }, 79 { 80 "method": "bdev_wait_for_examine" 81 } 82 ] 83 } 84 ] 85 } 86 JSON 87} 88 89nvmftestinit 90nvmfappstart -m 0x3 91 92$rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS 93$rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc0 94$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode$subsystem -a -s SPDK00000000000001 95$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode$subsystem Malloc0 96$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode$subsystem -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT 97 98# test memory translation 99# test_dma doesn't use RPC, but we change the sock path since nvmf target is already using the default RPC sock 100"$rootdir/test/dma/test_dma/test_dma" -q 16 -o 4096 -w randrw -M 70 -t 5 -m 0xc --json <(gen_nvmf_target_json $subsystem) -b "Nvme${subsystem}n1" -f -x translate -r /var/tmp/dma.sock 101 102# test data pull/push with split against local malloc 103"$rootdir/test/dma/test_dma/test_dma" -q 16 -o 4096 -w randrw -M 70 -t 5 -m 0xc --json <(gen_malloc_json) -b "Malloc0" -x pull_push -r /var/tmp/dma.sock 104 105# test memzero with logical volumes. All clusters are unallocated, read should trigger memzero 106"$rootdir/test/dma/test_dma/test_dma" -q 16 -o 4096 -w randread -M 70 -t 5 -m 0xc --json <(gen_lvol_nvme_json $subsystem) -b "lvs${subsystem}/lvol${subsystem}" -f -x memzero -r /var/tmp/dma.sock 107 108# clear blob metadata 109$rootdir/build/examples/perf -q 16 -o 4096 -w write -t 1 -r "trtype:$TEST_TRANSPORT adrfam:IPV4 traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT" 110 111# test memory translation with logical volumes 112"$rootdir/test/dma/test_dma/test_dma" -q 16 -o 4096 -w randrw -M 70 -t 5 -m 0xc --json <(gen_lvol_nvme_json $subsystem) -b "lvs${subsystem}/lvol${subsystem}" -f -x translate -r /var/tmp/dma.sock 113 114trap - SIGINT SIGTERM EXIT 115 116nvmftestfini 117