]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/bdev/nbd_common.sh
3 function nbd_start_disks
() {
8 for (( i
=0; i
<${#nbd_list[@]}; i
++ )); do
9 $rootdir/scripts
/rpc.py
-s $rpc_server start_nbd_disk \
10 ${bdev_list[$i]} ${nbd_list[$i]}
12 # Wait for nbd devices ready
13 for i
in ${nbd_list[@]}; do
18 function waitfornbd_exit
() {
21 for ((i
=1; i
<=20; i
++)); do
22 if grep -q -w $nbd_name /proc
/partitions
; then
32 function nbd_stop_disks
() {
36 for i
in ${nbd_list[@]}; do
37 $rootdir/scripts
/rpc.py
-s $rpc_server stop_nbd_disk
$i
39 for i
in ${nbd_list[@]}; do
40 waitfornbd_exit
${i:5}
44 function nbd_get_count
() {
45 # return = count of spdk nbd devices
48 nbd_disks_json
=`$rootdir/scripts/rpc.py -s $rpc_server get_nbd_disks`
49 nbd_disks_name
=`echo "${nbd_disks_json}" | jq -r '.[] | .nbd_device'`
50 count
=`echo "${nbd_disks_name}" | grep -c /dev/nbd || true`
54 function nbd_dd_data_verify
() {
57 local tmp_file
=/tmp
/nbdrandtest
59 if [ "$operation" = "write" ]; then
61 dd if=/dev
/urandom of
=$tmp_file bs
=4096 count
=256
62 for i
in ${nbd_list[@]}; do
63 dd if=$tmp_file of
=$i bs
=4096 count
=256 oflag
=direct
65 elif [ "$operation" = "verify" ]; then
66 # data read and verify
67 for i
in ${nbd_list[@]}; do
68 cmp -b -n 1M
$tmp_file $i
74 function nbd_rpc_data_verify
() {
79 nbd_start_disks
$rpc_server "${bdev_list[*]}" "${nbd_list[*]}"
80 count
=$
(nbd_get_count
$rpc_server)
81 if [ $count -ne ${#nbd_list[@]} ]; then
85 nbd_dd_data_verify
"${nbd_list[*]}" "write"
86 nbd_dd_data_verify
"${nbd_list[*]}" "verify"
88 nbd_stop_disks
$rpc_server "${nbd_list[*]}"
89 count
=$
(nbd_get_count
$rpc_server)
90 if [ $count -ne 0 ]; then