3 testdir
=$
(readlink
-f $
(dirname $0))
4 rootdir
=$
(readlink
-f $testdir/..
/..
)
5 source $rootdir/test
/common
/autotest_common.sh
6 source $testdir/common.sh
8 rpc_py
=$rootdir/scripts
/rpc.py
10 mount_dir
=$
(mktemp
-d)
12 while getopts ':u:c:' opt
; do
15 c
) nv_cache
=$OPTARG ;;
16 ?
) echo "Usage: $0 [-u UUID] [-c NV_CACHE_PCI_BDF] OCSSD_PCI_BDF" && exit 1 ;;
21 num_group
=$
(get_num_group
$device)
22 num_pu
=$
(get_num_pu
$device)
23 pu_count
=$
((num_group
* num_pu
))
26 if mount |
grep $mount_dir; then
30 rm -f $testdir/testfile.md5
31 rm -f $testdir/testfile2.md5
32 rm -f $testdir/config
/ftl.json
38 trap "restore_kill; exit 1" SIGINT SIGTERM EXIT
40 "$SPDK_BIN_DIR/spdk_tgt" --json <(gen_ftl_nvme_conf
) &
42 # Wait until spdk_tgt starts
45 if [ -n "$nv_cache" ]; then
46 nvc_bdev
=$
(create_nv_cache_bdev nvc0
$device $nv_cache $pu_count)
49 $rpc_py bdev_nvme_attach_controller
-b nvme0
-a $device -t pcie
50 $rpc_py bdev_ocssd_create
-c nvme0
-b nvme0n1
-n 1
51 ftl_construct_args
="bdev_ftl_create -b ftl0 -d nvme0n1"
53 [ -n "$uuid" ] && ftl_construct_args
+=" -u $uuid"
54 [ -n "$nv_cache" ] && ftl_construct_args
+=" -c $nvc_bdev"
56 $rpc_py $ftl_construct_args
60 $rpc_py nbd_start_disk ftl0
/dev
/nbd0
63 $rpc_py save_config
> $testdir/config
/ftl.json
65 # Prepare the disk by creating ext4 fs and putting a file on it
66 make_filesystem ext4
/dev
/nbd0
67 mount
/dev
/nbd0
$mount_dir
68 dd if=/dev
/urandom of
=$mount_dir/testfile bs
=4K count
=256K
70 mount
-o remount
/dev
/nbd0
$mount_dir
71 md5sum $mount_dir/testfile
> $testdir/testfile.md5
73 # Kill bdev service and start it again
77 "$SPDK_BIN_DIR/spdk_tgt" --json <(gen_ftl_nvme_conf
) -L ftl_init
&
79 # Wait until spdk_tgt starts
82 $rpc_py load_config
< $testdir/config
/ftl.json
85 mount
/dev
/nbd0
$mount_dir
87 # Write second file, to make sure writer thread has restored properly
88 dd if=/dev
/urandom of
=$mount_dir/testfile2 bs
=4K count
=256K
89 md5sum $mount_dir/testfile2
> $testdir/testfile2.md5
91 # Make sure second file will be read from disk
92 echo 3 > /proc
/sys
/vm
/drop_caches
94 # Check both files have proper data
95 md5sum -c $testdir/testfile.md5
96 md5sum -c $testdir/testfile2.md5
98 trap - SIGINT SIGTERM EXIT