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: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/435086
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Darek Stojaczyk 2018-11-27 09:43:56 +01:00 committed by Ben Walker
parent 6f2e275aab
commit a036277baf

View File

@ -56,19 +56,22 @@ fi
timing_enter cleanup
# Remove old domain socket pathname just in case
rm -f /var/tmp/spdk*.sock
# Load the kernel driver
./scripts/setup.sh reset
# Let the kernel discover any filesystems or partitions
sleep 10
# 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 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
done
# Load RAM disk driver if available
modprobe brd || true
fi