fstests: use udevadm settle after pvremove
authorLuis Chamberlain <mcgrof@kernel.org>
Wed, 11 Aug 2021 15:45:10 +0000 (08:45 -0700)
committerEryu Guan <guaneryu@gmail.com>
Sun, 15 Aug 2021 12:35:29 +0000 (20:35 +0800)
As with creation, we also need to use udevadm settle
when removing a pv, otherwise we can trip on races with
module removals for the block devices in use.

This reduces the amount of time in which a block device
module refcnt for test modules such as scsi_debug spends
outside of 0.

Races with the refcnt being greater than 0 means module
removal can fail causing false positives. This helps
ensure that the pv is really long gone. These issues
are tracked for scsi_debug [0] and later found to be a
generic issue regardless of filesystem with pvremove [1].

Using udevadm settle *helps*, it does not address all
possible races with the refcnt as noted in the generic
bug entry [1].

[0] https://bugzilla.kernel.org/show_bug.cgi?id=212337
[1] https://bugzilla.kernel.org/show_bug.cgi?id=214015

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/generic/081
tests/generic/108
tests/generic/459

index f795b2c1169bfd018ca5dc1cfff93118425a58e2..8e552074c72b53183fd7972735fcf8071774410f 100755 (executable)
@@ -12,6 +12,7 @@ _begin_fstest auto quick
 # Override the default cleanup function.
 _cleanup()
 {
+       local pv_ret
        cd /
        rm -f $tmp.*
 
@@ -34,7 +35,9 @@ _cleanup()
                $UMOUNT_PROG $mnt >> $seqres.full 2>&1
                $LVM_PROG vgremove -f $vgname >>$seqres.full 2>&1
                $LVM_PROG pvremove -f $SCRATCH_DEV >>$seqres.full 2>&1
-               test $? -eq 0 && break
+               pv_ret=$?
+               $UDEV_SETTLE_PROG
+               test $pv_ret -eq 0 && break
                sleep 2
        done
 }
index 7dd426c190308dfdbc90c4095d54a4ba6d49b032..b7797e8fac2b7d6d20f3831800317b60d7b996d7 100755 (executable)
@@ -21,6 +21,7 @@ _cleanup()
        $UMOUNT_PROG $SCRATCH_MNT >>$seqres.full 2>&1
        $LVM_PROG vgremove -f $vgname >>$seqres.full 2>&1
        $LVM_PROG pvremove -f $SCRATCH_DEV $SCSI_DEBUG_DEV >>$seqres.full 2>&1
+       $UDEV_SETTLE_PROG
        _put_scsi_debug_dev
        rm -f $tmp.*
 }
index e5e5e9abf0cb3f84bd04ecca6cf3bdb9e9fc117b..5b44e2451de4a1dd7e8917625a13533da8d71287 100755 (executable)
@@ -29,6 +29,7 @@ _cleanup()
        $UMOUNT_PROG $SCRATCH_MNT >>$seqres.full 2>&1
        $LVM_PROG vgremove -ff $vgname >>$seqres.full 2>&1
        $LVM_PROG pvremove -ff $SCRATCH_DEV >>$seqres.full 2>&1
+       $UDEV_SETTLE_PROG
 }
 
 # Import common functions.