Skip to content

Commit

Permalink
blktests: fix how we handle waiting for nbd to connect
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
  • Loading branch information
josefbacik authored and kawasaki committed May 27, 2024
1 parent 7308e11 commit 698f1a0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/nbd/001
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 2 additions & 1 deletion tests/nbd/rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 698f1a0

Please sign in to comment.