2017-03-02 14:12:20 +00:00
|
|
|
#!/usr/bin/env bash
|
2016-12-14 20:34:03 +00:00
|
|
|
set -xe
|
2017-03-02 14:12:20 +00:00
|
|
|
|
2021-04-12 10:20:36 +00:00
|
|
|
err_wipe() {
|
|
|
|
[[ -n $devs ]] || return 0
|
|
|
|
local _devs
|
|
|
|
|
2021-04-15 09:29:02 +00:00
|
|
|
_devs=($devs) _devs=("${_devs[@]/#//dev/}")
|
2021-04-12 10:20:36 +00:00
|
|
|
|
|
|
|
umount "${_devs[@]}" || :
|
|
|
|
wipefs --all "${_devs[@]}" || :
|
|
|
|
}
|
|
|
|
|
2020-05-07 11:27:06 +00:00
|
|
|
MAKE="make -j$(($(nproc) * 2))"
|
2017-03-02 14:12:20 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
if [[ $1 == "spdk_vhost_scsi" ]]; then
|
|
|
|
devs=""
|
|
|
|
for entry in /sys/block/sd*; do
|
|
|
|
if grep -Eq '(INTEL|RAWSCSI|LIO-ORG)' $entry/device/vendor; then
|
|
|
|
devs+="$(basename $entry) "
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
elif [[ $1 == "spdk_vhost_blk" ]]; then
|
2020-05-07 11:27:06 +00:00
|
|
|
devs=$(
|
|
|
|
cd /sys/block
|
|
|
|
echo vd*
|
|
|
|
)
|
2017-08-09 10:38:11 +00:00
|
|
|
fi
|
2017-03-02 14:12:20 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
fs=$2
|
|
|
|
|
2021-04-12 10:20:36 +00:00
|
|
|
trap "err_wipe; exit 1" SIGINT SIGTERM EXIT
|
2016-12-14 20:34:03 +00:00
|
|
|
|
2017-12-07 11:14:29 +00:00
|
|
|
for fs in $fs; do
|
2018-02-06 11:20:21 +00:00
|
|
|
for dev in $devs; do
|
2019-12-03 14:54:38 +00:00
|
|
|
i=0
|
2018-02-06 11:20:21 +00:00
|
|
|
parted_cmd="parted -s /dev/${dev}"
|
|
|
|
|
|
|
|
echo "INFO: Creating partition table on disk using: $parted_cmd mklabel gpt"
|
|
|
|
$parted_cmd mklabel gpt
|
2019-12-03 14:54:38 +00:00
|
|
|
while ! ($parted_cmd print | grep -q gpt); do
|
|
|
|
[[ $i -lt 100 ]] || break
|
2020-05-07 11:27:06 +00:00
|
|
|
i=$((i + 1))
|
2019-12-03 14:54:38 +00:00
|
|
|
sleep 0.1
|
|
|
|
done
|
2018-02-06 11:20:21 +00:00
|
|
|
$parted_cmd mkpart primary 2048s 100%
|
2016-12-14 20:34:03 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
mkfs_cmd="mkfs.$fs"
|
2020-10-14 10:20:17 +00:00
|
|
|
if [[ $fs == "ntfs" ]] || [[ $fs == "btrfs" ]]; then
|
2018-02-06 11:20:21 +00:00
|
|
|
mkfs_cmd+=" -f"
|
|
|
|
fi
|
|
|
|
mkfs_cmd+=" /dev/${dev}1"
|
|
|
|
echo "INFO: Creating filesystem using: $mkfs_cmd"
|
2019-12-03 14:54:38 +00:00
|
|
|
i=0
|
|
|
|
until wipefs -a /dev/${dev}1; do
|
|
|
|
[[ $i -lt 100 ]] || break
|
2020-05-07 11:27:06 +00:00
|
|
|
i=$((i + 1))
|
2019-12-03 14:54:38 +00:00
|
|
|
echo "Waiting for /dev/${dev}1"
|
|
|
|
sleep 0.1
|
|
|
|
done
|
2018-02-06 11:20:21 +00:00
|
|
|
$mkfs_cmd
|
2016-12-14 20:34:03 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
mkdir -p /mnt/${dev}dir
|
|
|
|
mount -o sync /dev/${dev}1 /mnt/${dev}dir
|
2017-03-02 14:12:20 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
fio --name="integrity" --bsrange=4k-512k --iodepth=128 --numjobs=1 --direct=1 \
|
2020-05-07 11:27:06 +00:00
|
|
|
--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
|
2017-12-07 11:14:29 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
# Print out space consumed on target device
|
|
|
|
df -h /dev/$dev
|
|
|
|
done
|
2017-03-02 14:12:20 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
for dev in $devs; do
|
|
|
|
umount /mnt/${dev}dir
|
|
|
|
rm -rf /mnt/${dev}dir
|
2020-05-07 11:27:06 +00:00
|
|
|
stats=($(cat /sys/block/$dev/stat))
|
2021-04-12 10:20:36 +00:00
|
|
|
wipefs --all "/dev/$dev"
|
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
echo ""
|
|
|
|
echo "$dev stats"
|
|
|
|
printf "READ IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \
|
2020-05-07 11:27:06 +00:00
|
|
|
${stats[0]} ${stats[1]} ${stats[2]} ${stats[3]}
|
2018-02-06 11:20:21 +00:00
|
|
|
printf "WRITE IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \
|
2020-05-07 11:27:06 +00:00
|
|
|
${stats[4]} ${stats[5]} ${stats[6]} ${stats[7]}
|
2018-02-06 11:20:21 +00:00
|
|
|
printf "in flight: % 8u io ticks: % 8u time in queue: % 8u\n" \
|
2020-05-07 11:27:06 +00:00
|
|
|
${stats[8]} ${stats[9]} ${stats[10]}
|
2018-02-06 11:20:21 +00:00
|
|
|
echo ""
|
|
|
|
done
|
2017-03-02 14:12:20 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
trap - SIGINT SIGTERM EXIT
|