Commit a036277b authored by Darek Stojaczyk's avatar Darek Stojaczyk Committed by Ben Walker
Browse files

test: erase the first 1MB on NVMe disks at the start of each test



Some tests intermittently fail due to leftover lvols
from previous runs:

$ hello_bdev -b Nvme0n1
*ERROR*: Could not open Nvme0n1 - lvol module already claimed it

Fix this by zeroing the first 1MB of each NVMe at the
start of autotest. That will remove the lvolstore, and
will get also rid of any GPT partitions - that's why
this patch also removes the explicit `parted` calls that
would try to do the same.

Since there's no way to do direct I/O with the standard
dd shipped in FreeBSD, we do the `sync` after the normal,
buffered dd.

Change-Id: I18a01bda064f836901327f1dd3cfab1f08e87b1a
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/435086


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarPawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 6f2e275a
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -56,19 +56,22 @@ fi
timing_enter cleanup
# Remove old domain socket pathname just in case
rm -f /var/tmp/spdk*.sock
if [ $(uname -s) = Linux ]; then

# Load the kernel driver
./scripts/setup.sh reset

# Let the kernel discover any filesystems or partitions
sleep 10

	# Delete all partitions on NVMe devices
	devs=`lsblk -l -o NAME | grep nvme | grep -v p` || true
	for dev in $devs; do
		parted -s /dev/$dev mklabel msdos
# Delete all leftover lvols and gpt partitions
# Matches both /dev/nvmeXnY on Linux and /dev/nvmeXnsY on BSD
for dev in $(ls /dev/nvme*n* | grep -v p || true); do
	dd if=/dev/zero of="$dev" bs=1M count=1
done

sync

if [ $(uname -s) = Linux ]; then
	# Load RAM disk driver if available
	modprobe brd || true
fi