autotest: Check if nvme devices are in use before the wipe
Signed-off-by: Michal Berger <michalx.berger@intel.com> Change-Id: I4f838df0bfb91398eb5d179a982165adb8af3476 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9291 Reviewed-by: Konrad Sztyber <konrad.sztyber@gmail.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
8419c294b4
commit
76f840c049
20
autotest.sh
20
autotest.sh
@ -87,6 +87,17 @@ rm -f /var/tmp/spdk*.sock
|
||||
# Load the kernel driver
|
||||
./scripts/setup.sh reset
|
||||
|
||||
# Delete all leftover lvols and gpt partitions
|
||||
# Matches both /dev/nvmeXnY on Linux and /dev/nvmeXnsY on BSD
|
||||
# Filter out nvme with partitions - the "p*" suffix
|
||||
for dev in $(ls /dev/nvme*n* | grep -v p || true); do
|
||||
if ! block_in_use "$dev"; then
|
||||
dd if=/dev/zero of="$dev" bs=1M count=1
|
||||
fi
|
||||
done
|
||||
|
||||
sync
|
||||
|
||||
if [ $(uname -s) = Linux ]; then
|
||||
# OCSSD devices drivers don't support IO issues by kernel so
|
||||
# detect OCSSD devices and block them (unbind from any driver).
|
||||
@ -130,15 +141,6 @@ if [[ $(uname -s) == Linux ]]; then
|
||||
nvme_namespace_revert
|
||||
fi
|
||||
|
||||
# Delete all leftover lvols and gpt partitions
|
||||
# Matches both /dev/nvmeXnY on Linux and /dev/nvmeXnsY on BSD
|
||||
# Filter out nvme with partitions - the "p*" suffix
|
||||
for dev in $(ls /dev/nvme*n* | grep -v p || true); do
|
||||
dd if=/dev/zero of="$dev" bs=1M count=1
|
||||
done
|
||||
|
||||
sync
|
||||
|
||||
timing_exit cleanup
|
||||
|
||||
# set up huge pages
|
||||
|
@ -316,6 +316,35 @@ ge() { cmp_versions "$1" ">=" "$2"; }
|
||||
eq() { cmp_versions "$1" "==" "$2"; }
|
||||
neq() { ! eq "$1" "$2"; }
|
||||
|
||||
block_in_use() {
|
||||
local block=$1 data pt
|
||||
# Skip devices that are in use - simple blkid it to see if
|
||||
# there's any metadata (pt, fs, etc.) present on the drive.
|
||||
# FIXME: Special case to ignore atari as a potential false
|
||||
# positive:
|
||||
# https://github.com/spdk/spdk/issues/2079
|
||||
# Devices with SPDK's GPT part type are not considered to
|
||||
# be in use.
|
||||
|
||||
if "$rootdir/scripts/spdk-gpt.py" "$block"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
data=$(blkid "/dev/${block##*/}") || data=none
|
||||
|
||||
if [[ $data == none ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
pt=$(blkid -s PTTYPE -o value "/dev/${block##*/}") || pt=none
|
||||
|
||||
if [[ $pt == none || $pt == atari ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
if [[ -e "$CONFIG_WPDK_DIR/bin/wpdk_common.sh" ]]; then
|
||||
# Adjust uname to report the operating system as WSL, Msys or Cygwin
|
||||
# and the kernel name as Windows. Define kill() to invoke the SIGTERM
|
||||
|
@ -175,15 +175,7 @@ min_disk_size=$((1024 ** 3 * 2)) # 2GB
|
||||
for block in "/sys/block/nvme"*; do
|
||||
pci=$(readlink -f "$block/device/device")
|
||||
pci=${pci##*/}
|
||||
# Skip devices that are in use - simple blkid it to see if
|
||||
# there's any metadata (pt, fs, etc.) present on the drive.
|
||||
# If the drive's size is less than 2G, skip it as we need
|
||||
# something bigger for the tests.
|
||||
# FIXME: Special case to ignore atari as a potential false
|
||||
# positive:
|
||||
# https://github.com/spdk/spdk/issues/2079
|
||||
pt=$(blkid -s PTTYPE -o value "/dev/${block##*/}") || pt=none
|
||||
if [[ $pt == none || $pt == atari ]] && (($(sec_size_to_bytes "${block##*/}") >= min_disk_size)); then
|
||||
if ! block_in_use "${block##*/}" && (($(sec_size_to_bytes "${block##*/}") >= min_disk_size)); then
|
||||
blocks+=("${block##*/}")
|
||||
blocks_to_pci["${block##*/}"]=$pci
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user