bdev/ftl: Add json config generation
Change-Id: I0baa6cfb4e4cb2a5ae68de730edb75011bd8e49d Signed-off-by: Wojciech Malikowski <wojciech.malikowski@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/445254 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
51a65776ee
commit
afc4f91341
@ -5,9 +5,10 @@ set -e
|
|||||||
rootdir=$(readlink -f $(dirname $0))/..
|
rootdir=$(readlink -f $(dirname $0))/..
|
||||||
|
|
||||||
function usage {
|
function usage {
|
||||||
echo "Usage: $0 -a TRANSPORT_ADDR -n BDEV_NAME -l PUNITS [-u UUID] [-c CACHE]"
|
echo "Usage: [-j] $0 -a TRANSPORT_ADDR -n BDEV_NAME -l PUNITS [-u UUID] [-c CACHE]"
|
||||||
echo "UUID is required when restoring device state"
|
echo "UUID is required when restoring device state"
|
||||||
echo
|
echo
|
||||||
|
echo "-j json format"
|
||||||
echo "TRANSPORT_ADDR - SSD's PCIe address"
|
echo "TRANSPORT_ADDR - SSD's PCIe address"
|
||||||
echo "BDEV_NAME - name of the bdev"
|
echo "BDEV_NAME - name of the bdev"
|
||||||
echo "PUNITS - bdev's parallel unit range (e.g. 0-3)"
|
echo "PUNITS - bdev's parallel unit range (e.g. 0-3)"
|
||||||
@ -15,15 +16,40 @@ function usage {
|
|||||||
echo "CACHE - name of the bdev to be used as write buffer cache"
|
echo "CACHE - name of the bdev to be used as write buffer cache"
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate_config {
|
function create_classic_config {
|
||||||
echo "[Ftl]"
|
echo "[Ftl]"
|
||||||
echo " TransportID \"trtype:PCIe traddr:$1\" $2 $3 $4 $5"
|
echo " TransportID \"trtype:PCIe traddr:$1\" $2 $3 $4 $5"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_json_config()
|
||||||
|
{
|
||||||
|
echo "{"
|
||||||
|
echo '"subsystem": "bdev",'
|
||||||
|
echo '"config": ['
|
||||||
|
echo '{'
|
||||||
|
echo '"method": "construct_ftl_bdev",'
|
||||||
|
echo '"params": {'
|
||||||
|
echo "\"name\": \"$2\","
|
||||||
|
echo '"trtype": "PCIe",'
|
||||||
|
echo "\"traddr\": \"$1\","
|
||||||
|
echo "\"punits\": \"$3\","
|
||||||
|
if [ -n "$5" ]; then
|
||||||
|
echo "\"uuid\": \"$4\","
|
||||||
|
echo "\"cache\": \"$5\""
|
||||||
|
else
|
||||||
|
echo "\"uuid\": \"$4\""
|
||||||
|
fi
|
||||||
|
echo '}'
|
||||||
|
echo '}'
|
||||||
|
echo ']'
|
||||||
|
echo '}'
|
||||||
|
}
|
||||||
|
|
||||||
uuid=00000000-0000-0000-0000-000000000000
|
uuid=00000000-0000-0000-0000-000000000000
|
||||||
|
|
||||||
while getopts ":a:n:l:m:u:c:" arg; do
|
while getopts "ja:n:l:m:u:c:" arg; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
|
j) json=1 ;;
|
||||||
a) addr=$OPTARG ;;
|
a) addr=$OPTARG ;;
|
||||||
n) name=$OPTARG ;;
|
n) name=$OPTARG ;;
|
||||||
l) punits=$OPTARG ;;
|
l) punits=$OPTARG ;;
|
||||||
@ -41,4 +67,8 @@ if [[ -z "$addr" || -z "$name" || -z "$punits" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
generate_config $addr $name $punits $uuid $cache
|
if [ -n "$json" ]; then
|
||||||
|
create_json_config $addr $name $punits $uuid $cache
|
||||||
|
else
|
||||||
|
create_classic_config $addr $name $punits $uuid $cache
|
||||||
|
fi
|
||||||
|
@ -41,6 +41,10 @@ timing_enter restore
|
|||||||
run_test suite $testdir/restore.sh $device
|
run_test suite $testdir/restore.sh $device
|
||||||
timing_exit restore
|
timing_exit restore
|
||||||
|
|
||||||
|
timing_enter json
|
||||||
|
run_test suite $testdir/json.sh $device
|
||||||
|
timing_exit json
|
||||||
|
|
||||||
if [ $SPDK_TEST_FTL_EXTENDED -eq 1 ]; then
|
if [ $SPDK_TEST_FTL_EXTENDED -eq 1 ]; then
|
||||||
timing_enter fio_basic
|
timing_enter fio_basic
|
||||||
run_test suite $testdir/fio.sh $device basic
|
run_test suite $testdir/fio.sh $device basic
|
||||||
|
44
test/ftl/json.sh
Executable file
44
test/ftl/json.sh
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
testdir=$(readlink -f $(dirname $0))
|
||||||
|
rootdir=$(readlink -f $testdir/../..)
|
||||||
|
rpc_py=$rootdir/scripts/rpc.py
|
||||||
|
|
||||||
|
source $rootdir/test/common/autotest_common.sh
|
||||||
|
|
||||||
|
device=$1
|
||||||
|
FTL_BDEV_CONF=$testdir/config/ftl.json
|
||||||
|
|
||||||
|
json_kill() {
|
||||||
|
killprocess $svcpid
|
||||||
|
}
|
||||||
|
|
||||||
|
trap "json_kill; exit 1" SIGINT SIGTERM EXIT
|
||||||
|
|
||||||
|
$rootdir/test/app/bdev_svc/bdev_svc & svcpid=$!
|
||||||
|
waitforlisten $svcpid
|
||||||
|
|
||||||
|
# Create new bdev from json configuration
|
||||||
|
$rootdir/scripts/gen_ftl.sh -j -a $device -n nvme0 -l 0-3 | $rpc_py load_subsystem_config
|
||||||
|
|
||||||
|
uuid=$($rpc_py get_bdevs | jq -r '.[0].uuid')
|
||||||
|
|
||||||
|
$rpc_py delete_ftl_bdev -b nvme0
|
||||||
|
|
||||||
|
# Restore bdev from json configuration
|
||||||
|
$rootdir/scripts/gen_ftl.sh -j -a $device -n nvme0 -l 0-3 -u $uuid | $rpc_py load_subsystem_config
|
||||||
|
# Create new bdev from json configuration
|
||||||
|
$rootdir/scripts/gen_ftl.sh -j -a $device -n nvme1 -l 4-5 | $rpc_py load_subsystem_config
|
||||||
|
# Create new bdev from RPC
|
||||||
|
$rpc_py construct_ftl_bdev -b nvme2 -a $device -l 7-7
|
||||||
|
|
||||||
|
$rpc_py delete_ftl_bdev -b nvme2
|
||||||
|
$rpc_py delete_ftl_bdev -b nvme0
|
||||||
|
$rpc_py delete_ftl_bdev -b nvme1
|
||||||
|
|
||||||
|
# TODO: add negative test cases
|
||||||
|
|
||||||
|
trap - SIGINT SIGTERM EXIT
|
||||||
|
json_kill
|
Loading…
Reference in New Issue
Block a user