Commit 0e13e309 authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

test/nvmf: Acquire lock on $nvme_name to stop racing with udev



This is needed to make sure parted can safely issue re-read of the
partition table.

Fixes: #2961

Change-Id: Ifab148bbb42b6d37e9df65a1bf0dbac324e7ec31
Signed-off-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21022


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 796e672e
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -83,7 +83,12 @@ function nvmf_filesystem_part() {
		run_test "filesystem_in_capsule_xfs" nvmf_filesystem_create "xfs" ${nvme_name}
	fi

	parted -s /dev/${nvme_name} rm 1
	# Make sure the target block device is not hold by udev-worker when we attempt to
	# remove the partition - the removal here forces parted to send BLKRRPART which may
	# fail in case the device is already locked. By acquiring a lock of our own we make
	# sure to either block until device is available or make the udev-worker to back off.
	# See https://github.com/spdk/spdk/issues/2961 for details.
	flock "/dev/$nvme_name" parted -s "/dev/${nvme_name}" rm 1

	sync
	nvme disconnect -n "nqn.2016-06.io.spdk:cnode1"