All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] generic/081: wait for lv to be settled before creating fs on it
@ 2015-04-03  9:41 Eryu Guan
  2015-05-04  6:27 ` Dave Chinner
  2015-05-07  3:33 ` [PATCH v3] " Eryu Guan
  0 siblings, 2 replies; 7+ messages in thread
From: Eryu Guan @ 2015-04-03  9:41 UTC (permalink / raw)
  To: fstests; +Cc: Eryu Guan

Call 'udevadm settle' or 'udevsettle' or 'sleep 1' to make sure new lv
is ready for use before making filesystem on it, depends on which
command is available on the system.

Also sleep 1 before removing the test vg, as the snapshot may block the
test vg from removal for a while.

Signed-off-by: Eryu Guan <eguan@redhat.com>
---
 tests/generic/081 | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/tests/generic/081 b/tests/generic/081
index e242c4c..8e1828b 100755
--- a/tests/generic/081
+++ b/tests/generic/081
@@ -36,6 +36,9 @@ _cleanup()
 	rm -f $tmp.*
 	# lvm may have umounted it on I/O error, but in case it does not
 	$UMOUNT_PROG $mnt >/dev/null 2>&1
+	# fsync from xfs_io pins the snapshot in use for a while and blocks
+	# vgremove, sleep 1 to avoid such failure
+	sleep 1
 	$LVM_PROG vgremove -f $vgname >>$seqres.full 2>&1
 	$LVM_PROG pvremove -f $SCRATCH_DEV >>$seqres.full 2>&1
 }
@@ -62,11 +65,30 @@ snapname=snap_$seq
 mnt=$TEST_DIR/mnt_$seq
 mkdir -p $mnt
 
+# use 'udevadm settle' or 'udevsettle' to wait for lv to be settled.
+# newer systems have udevadm command but older systems like RHEL5 don't.
+# But if neither one is available, just set it to "sleep 1" to wait for lv to
+# be settled
+UDEV_SETTLE_PROG="`set_prog_path udevadm`"
+if [ "$UDEV_SETTLE_PROG" == "" ]; then
+	# try udevsettle command
+	UDEV_SETTLE_PROG="`set_prog_path udevsettle`"
+else
+	# udevadm is available, add 'settle' as subcommand
+	UDEV_SETTLE_PROG="$UDEV_SETTLE_PROG settle"
+fi
+# neither command is available, use sleep 1
+if [ "$UDEV_SETTLE_PROG" == "" ]; then
+	UDEV_SETTLE_PROG="sleep 1"
+fi
+
 # make sure there's enough disk space for 256M lv, test for 300M here in case
 # lvm uses some space for metadata
 _scratch_mkfs_sized $((300 * 1024 * 1024)) >>$seqres.full 2>&1
 $LVM_PROG vgcreate -f $vgname $SCRATCH_DEV >>$seqres.full 2>&1
 $LVM_PROG lvcreate --yes -L 256M -n $lvname $vgname >>$seqres.full 2>&1
+# wait for lv to be settled
+$UDEV_SETTLE_PROG >>$seqres.full 2>&1
 
 # _mkfs_dev exits the test on failure, this can make sure lv is created in
 # above vgcreate/lvcreate steps
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-05-07  3:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-03  9:41 [PATCH] generic/081: wait for lv to be settled before creating fs on it Eryu Guan
2015-05-04  6:27 ` Dave Chinner
2015-05-06  7:32   ` Eryu Guan
2015-05-06  7:58     ` [PATCH v2] " Eryu Guan
2015-05-06 23:13     ` [PATCH] " Dave Chinner
2015-05-07  3:11       ` Eryu Guan
2015-05-07  3:33 ` [PATCH v3] " Eryu Guan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.