test/vhost: Use --force for all mkfs and wipefs calls

Also, drop some code that's essentially not needed to improve
readability.

Change-Id: I5fda1c179983ce905661918e6f821eca486bb58d
Signed-off-by: Michal Berger <michal.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17218
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Michal Berger 2023-03-17 02:48:50 +01:00 committed by Konrad Sztyber
parent 0c653409dc
commit eda86acfe0

View File

@ -5,64 +5,50 @@
# #
set -xe set -xe
err_wipe() { cleanup() {
[[ -n $devs ]] || return 0 local _devs=()
local _devs
_devs=($devs) _devs=("${_devs[@]/#//dev/}") ((${#devs[@]} > 0)) || return 0
_devs=("${devs[@]/#//dev/}")
umount "${_devs[@]}" || : umount "${_devs[@]}" || :
wipefs --all "${_devs[@]}" || : wipefs --all --force "${_devs[@]}" || :
} }
MAKE="make -j$(($(nproc) * 2))" MAKE="make -j$(($(nproc) * 2))"
devs=()
if [[ $1 == "spdk_vhost_scsi" ]]; then if [[ $1 == "spdk_vhost_scsi" ]]; then
devs=""
for entry in /sys/block/sd*; do for entry in /sys/block/sd*; do
if grep -Eq '(INTEL|RAWSCSI|LIO-ORG)' $entry/device/vendor; then if [[ $(< "$entry/device/vendor") =~ (INTEL|RAWSCSI|LIO-ORG) ]]; then
devs+="$(basename $entry) " devs+=("${entry##*/}")
fi fi
done done
elif [[ $1 == "spdk_vhost_blk" ]]; then elif [[ $1 == "spdk_vhost_blk" ]]; then
devs=$( devs=(/sys/block/vd*)
cd /sys/block
echo vd*
)
fi fi
fs=$2 fs=$2
devs=("${devs[@]##*/}")
trap "err_wipe; exit 1" SIGINT SIGTERM EXIT trap "cleanup; exit 1" SIGINT SIGTERM EXIT
for fs in $fs; do for fs in $fs; do
for dev in $devs; do for dev in "${devs[@]}"; do
i=0 [[ -b /dev/$dev ]]
parted_cmd="parted -s /dev/${dev}" wipefs --all --force "/dev/$dev"
echo "INFO: Creating partition table on $dev disk"
parted "/dev/$dev" -s mklabel gpt mkpart SPDK_TEST 2048s 100%
sleep 1s
wipefs --all --force "/dev/${dev}1"
echo "INFO: Creating filesystem on /dev/${dev}1"
echo "INFO: Creating partition table on disk using: $parted_cmd mklabel gpt" if [[ $fs == ext4 ]]; then
$parted_cmd mklabel gpt "mkfs.$fs" -F "/dev/${dev}1"
while ! ($parted_cmd print | grep -q gpt); do else
[[ $i -lt 100 ]] || break "mkfs.$fs" -f "/dev/${dev}1"
i=$((i + 1))
sleep 0.1
done
$parted_cmd mkpart SPDK_TEST 2048s 100%
mkfs_cmd="mkfs.$fs"
if [[ $fs == "ntfs" ]] || [[ $fs == "btrfs" ]]; then
mkfs_cmd+=" -f"
fi fi
mkfs_cmd+=" /dev/${dev}1"
echo "INFO: Creating filesystem using: $mkfs_cmd"
i=0
until wipefs -a /dev/${dev}1; do
[[ $i -lt 100 ]] || break
i=$((i + 1))
echo "Waiting for /dev/${dev}1"
sleep 0.1
done
$mkfs_cmd
mkdir -p /mnt/${dev}dir mkdir -p /mnt/${dev}dir
mount -o sync /dev/${dev}1 /mnt/${dev}dir mount -o sync /dev/${dev}1 /mnt/${dev}dir
@ -75,14 +61,10 @@ for fs in $fs; do
# Print out space consumed on target device # Print out space consumed on target device
df -h /dev/$dev df -h /dev/$dev
done
for dev in $devs; do
umount /mnt/${dev}dir umount /mnt/${dev}dir
rm -rf /mnt/${dev}dir rm -rf /mnt/${dev}dir
stats=($(cat /sys/block/$dev/stat)) stats=($(cat /sys/block/$dev/stat))
wipefs --all "/dev/$dev"
echo "" echo ""
echo "$dev stats" echo "$dev stats"
printf "READ IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \ printf "READ IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \
@ -96,3 +78,4 @@ for fs in $fs; do
done done
trap - SIGINT SIGTERM EXIT trap - SIGINT SIGTERM EXIT
cleanup