From a036277bafc6f29145a0e5a76cf033cd89e8a3d3 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Tue, 27 Nov 2018 09:43:56 +0100 Subject: [PATCH] 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 Reviewed-on: https://review.gerrithub.io/435086 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Pawel Wodkowski Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- autotest.sh | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/autotest.sh b/autotest.sh index a064a3468..b26991dd3 100755 --- a/autotest.sh +++ b/autotest.sh @@ -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