File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -544,15 +544,37 @@ _systemctl_stop() {
544544 done
545545}
546546
547- _drain_udev_events () {
547+ _systemctl_unit_is_active () {
548+ local unit=" $1 "
549+
548550 if command -v systemctl & > /dev/null &&
549- systemctl is-active --quiet systemd-udevd; then
550- systemctl restart systemd-udevd.service
551+ systemctl is-active --quiet " $unit " ; then
552+ return 0
553+ fi
554+ return 1
555+ }
556+
557+ _systemd_stop_udevd () {
558+ if _systemctl_unit_is_active " systemd-udevd" ; then
559+ systemctl --quiet stop systemd-udevd
560+ systemctl --quiet mask systemd-udevd
551561 else
552- udevadm settle --timeout=900
562+ echo " WARNING: systemd-udevd is not active "
553563 fi
554564}
555565
566+ _systemd_start_udevd () {
567+ if ! _systemctl_unit_is_active " systemd-udevd" ; then
568+ systemctl --quiet unmask systemd-udevd
569+ systemctl --quiet start systemd-udevd
570+ fi
571+ if ! _systemctl_unit_is_active " systemd-udevd" ; then
572+ echo " WARNING: systemd-udevd not started"
573+ return 1
574+ fi
575+ return 0
576+ }
577+
556578# Run the given command as NORMAL_USER
557579_run_user () {
558580 su " $NORMAL_USER " -c " $1 "
Original file line number Diff line number Diff line change 66# stale loop partitions when one process opens the loop partition and
77# another process detaches the loop device.
88#
9+ # Regression test for commit:
10+ # 18048c1af783 loop: Fix a race between loop detach and loop open
11+
912. tests/loop/rc
1013DESCRIPTION=" check stale loop partition"
1114TIMED=1
@@ -60,6 +63,11 @@ test() {
6063 mkfs.xfs --force " ${loop_device} p1" >& /dev/null
6164 losetup --detach " ${loop_device} " >& /dev/null
6265
66+ # This test generates udev events faster than the rate at which udevd
67+ # can process events. Stop systemd-udevd to prevent future test cases
68+ # fail.
69+ _systemd_stop_udevd
70+
6371 create_loop " ${loop_device} " &
6472 create_pid=$!
6573 detach_loop " ${loop_device} " &
@@ -68,8 +76,9 @@ test() {
6876 sleep " ${TIMEOUT:- 90} "
6977 {
7078 kill -9 $create_pid
79+ wait $create_pid
7180 kill -9 $detach_pid
72- wait
81+ wait $detach_pid
7382 sleep 1
7483 } 2> /dev/null
7584
@@ -79,10 +88,7 @@ test() {
7988 echo " Fail"
8089 fi
8190
82- # This test generates udev events faster than the rate at which udevd
83- # can process events. Drain udev events to prevent future test cases
84- # fail.
85- _drain_udev_events
91+ _systemd_start_udevd
8692
8793 echo " Test complete"
8894}
You can’t perform that action at this time.
0 commit comments