[PATCH] blktests: fix how we handle waiting for nbd to connect

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Because NBD has the old style configure the device directly config we
sometimes have spurious failures where the device wasn't quite ready
before the rest of the test continued.

nbd/002 had been using _wait_for_nbd_connect, however this helper waits
for the recv task to show up, which actually happens slightly before the
size is set and we're actually ready to be read from.  This means we
would sometimes fail nbd/002 because the device wasn't quite right.

Additionally nbd/001 has a similar issue where we weren't waiting for
the device to be ready before going ahead with the test, which would
cause spurious failures.

Fix this by adjusting _wait_for_nbd_connect to only exit once the size
for the device is being reported properly, meaning that it's ready to be
read from.

Then add this call to nbd/001 to eliminate the random failures we would
see with this test.

Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
---
 tests/nbd/001 | 1 +
 tests/nbd/rc  | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/nbd/001 b/tests/nbd/001
index 5fd0d43..0975af0 100755
--- a/tests/nbd/001
+++ b/tests/nbd/001
@@ -18,6 +18,7 @@ test() {
 	echo "Running ${TEST_NAME}"
 	_start_nbd_server
 	nbd-client -L -N export localhost /dev/nbd0 >> "$FULL" 2>&1
+	_wait_for_nbd_connect
 	udevadm settle
 
 	parted -s /dev/nbd0 print 2>> "$FULL" | grep 'Disk /dev/nbd0'
diff --git a/tests/nbd/rc b/tests/nbd/rc
index 9c1c15b..e96dc61 100644
--- a/tests/nbd/rc
+++ b/tests/nbd/rc
@@ -43,7 +43,8 @@ _have_nbd_netlink() {
 
 _wait_for_nbd_connect() {
 	for ((i = 0; i < 3; i++)); do
-		if [[ -e /sys/kernel/debug/nbd/nbd0/tasks ]]; then
+		sz=$(lsblk --raw --noheadings -o SIZE /dev/nbd0)
+		if [ "$sz" != "0B"  ]; then
 			return 0
 		fi
 		sleep 1
-- 
2.43.0





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux