linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH blktests v2] loop/010, common/rc: drain udev events after test
@ 2025-07-15  4:32 Shin'ichiro Kawasaki
  2025-07-15  9:22 ` Daniel Wagner
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Shin'ichiro Kawasaki @ 2025-07-15  4:32 UTC (permalink / raw)
  To: linux-block
  Cc: Yi Zhang, Bart Van Assche, Gulam Mohamed, Daniel Wagner,
	Shin'ichiro Kawasaki

The test case repeats creating and deleting a loop device. This
generates many udev events and makes following test cases fail. To avoid
the unexpected test case failures, drain the udev events. For that
purpose, introduce the helper function _drain_udev_events(). When
systemd-udevd service is running, restart it to discard the events
quickly. When systemd-udevd service is not available, call
"udevadm settle", which takes longer time to drain the events.

Link: https://github.com/linux-blktests/blktests/issues/181
Reported-by: Yi Zhang <yi.zhang@redhat.com>
Suggested-by: Bart Van Assche <bvanassche@acm.org>
Suggested-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
Changes from v1:
* Added "udevadm settle" in case systemd-udevd.service is not available
* Introduced _drain_udev_events()

 common/rc      | 9 +++++++++
 tests/loop/010 | 5 +++++
 2 files changed, 14 insertions(+)

diff --git a/common/rc b/common/rc
index 72441ab..dfc389f 100644
--- a/common/rc
+++ b/common/rc
@@ -544,6 +544,15 @@ _systemctl_stop() {
 	done
 }
 
+_drain_udev_events() {
+	if command -v systemctl &>/dev/null &&
+			systemctl is-active --quiet systemd-udevd; then
+		systemctl restart systemd-udevd.service
+	else
+		udevadm settle --timeout=900
+	fi
+}
+
 # Run the given command as NORMAL_USER
 _run_user() {
 	su "$NORMAL_USER" -c "$1"
diff --git a/tests/loop/010 b/tests/loop/010
index 309fd8a..b1a4926 100755
--- a/tests/loop/010
+++ b/tests/loop/010
@@ -78,5 +78,10 @@ test() {
 	if _dmesg_since_test_start | grep --quiet "$grep_str"; then
 		echo "Fail"
 	fi
+
+	# The repeated loop device creations and deletions generated so many
+	# udev events. Drain the events to not influence following test cases.
+	_drain_udev_events
+
 	echo "Test complete"
 }
-- 
2.50.1


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

* Re: [PATCH blktests v2] loop/010, common/rc: drain udev events after test
  2025-07-15  4:32 [PATCH blktests v2] loop/010, common/rc: drain udev events after test Shin'ichiro Kawasaki
@ 2025-07-15  9:22 ` Daniel Wagner
  2025-07-15 12:58 ` Bart Van Assche
  2025-07-17  7:33 ` Shinichiro Kawasaki
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Wagner @ 2025-07-15  9:22 UTC (permalink / raw)
  To: Shin'ichiro Kawasaki
  Cc: linux-block, Yi Zhang, Bart Van Assche, Gulam Mohamed

On Tue, Jul 15, 2025 at 01:32:02PM +0900, Shin'ichiro Kawasaki wrote:
> The test case repeats creating and deleting a loop device. This
> generates many udev events and makes following test cases fail. To avoid
> the unexpected test case failures, drain the udev events. For that
> purpose, introduce the helper function _drain_udev_events(). When
> systemd-udevd service is running, restart it to discard the events
> quickly. When systemd-udevd service is not available, call
> "udevadm settle", which takes longer time to drain the events.
> 
> Link: https://github.com/linux-blktests/blktests/issues/181
> Reported-by: Yi Zhang <yi.zhang@redhat.com>
> Suggested-by: Bart Van Assche <bvanassche@acm.org>
> Suggested-by: Daniel Wagner <dwagner@suse.de>
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>

Looks good to me. Thanks!

Reviewed-by: Daniel Wagner <dwagner@suse.de>

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

* Re: [PATCH blktests v2] loop/010, common/rc: drain udev events after test
  2025-07-15  4:32 [PATCH blktests v2] loop/010, common/rc: drain udev events after test Shin'ichiro Kawasaki
  2025-07-15  9:22 ` Daniel Wagner
@ 2025-07-15 12:58 ` Bart Van Assche
  2025-07-17  7:33 ` Shinichiro Kawasaki
  2 siblings, 0 replies; 4+ messages in thread
From: Bart Van Assche @ 2025-07-15 12:58 UTC (permalink / raw)
  To: Shin'ichiro Kawasaki, linux-block
  Cc: Yi Zhang, Gulam Mohamed, Daniel Wagner

On 7/14/25 9:32 PM, Shin'ichiro Kawasaki wrote:
> The test case repeats creating and deleting a loop device. This
> generates many udev events and makes following test cases fail. To avoid
> the unexpected test case failures, drain the udev events. For that
> purpose, introduce the helper function _drain_udev_events(). When
> systemd-udevd service is running, restart it to discard the events
> quickly. When systemd-udevd service is not available, call
> "udevadm settle", which takes longer time to drain the events.
> 
> Link: https://github.com/linux-blktests/blktests/issues/181
> Reported-by: Yi Zhang <yi.zhang@redhat.com>
> Suggested-by: Bart Van Assche <bvanassche@acm.org>
> Suggested-by: Daniel Wagner <dwagner@suse.de>
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> ---
> Changes from v1:
> * Added "udevadm settle" in case systemd-udevd.service is not available
> * Introduced _drain_udev_events()
> 
>   common/rc      | 9 +++++++++
>   tests/loop/010 | 5 +++++
>   2 files changed, 14 insertions(+)
> 
> diff --git a/common/rc b/common/rc
> index 72441ab..dfc389f 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -544,6 +544,15 @@ _systemctl_stop() {
>   	done
>   }
>   
> +_drain_udev_events() {
> +	if command -v systemctl &>/dev/null &&
> +			systemctl is-active --quiet systemd-udevd; then
> +		systemctl restart systemd-udevd.service
> +	else
> +		udevadm settle --timeout=900
> +	fi
> +}
> +
>   # Run the given command as NORMAL_USER
>   _run_user() {
>   	su "$NORMAL_USER" -c "$1"
> diff --git a/tests/loop/010 b/tests/loop/010
> index 309fd8a..b1a4926 100755
> --- a/tests/loop/010
> +++ b/tests/loop/010
> @@ -78,5 +78,10 @@ test() {
>   	if _dmesg_since_test_start | grep --quiet "$grep_str"; then
>   		echo "Fail"
>   	fi
> +
> +	# The repeated loop device creations and deletions generated so many
> +	# udev events. Drain the events to not influence following test cases.
> +	_drain_udev_events
> +

How about changing the above comment into the following to make it more 
clear? "This test generates udev events faster than the rate at which
udevd can process events. Drain udev events to prevent that future test
cases fail." Anyway:

Reviewed-by: Bart Van Assche <bvanassche@acm.org>


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

* Re: [PATCH blktests v2] loop/010, common/rc: drain udev events after test
  2025-07-15  4:32 [PATCH blktests v2] loop/010, common/rc: drain udev events after test Shin'ichiro Kawasaki
  2025-07-15  9:22 ` Daniel Wagner
  2025-07-15 12:58 ` Bart Van Assche
@ 2025-07-17  7:33 ` Shinichiro Kawasaki
  2 siblings, 0 replies; 4+ messages in thread
From: Shinichiro Kawasaki @ 2025-07-17  7:33 UTC (permalink / raw)
  To: linux-block@vger.kernel.org
  Cc: Yi Zhang, Bart Van Assche, Gulam Mohamed, Daniel Wagner

On Jul 15, 2025 / 13:32, Shin'ichiro Kawasaki wrote:
> The test case repeats creating and deleting a loop device. This
> generates many udev events and makes following test cases fail. To avoid
> the unexpected test case failures, drain the udev events. For that
> purpose, introduce the helper function _drain_udev_events(). When
> systemd-udevd service is running, restart it to discard the events
> quickly. When systemd-udevd service is not available, call
> "udevadm settle", which takes longer time to drain the events.
> 
> Link: https://github.com/linux-blktests/blktests/issues/181
> Reported-by: Yi Zhang <yi.zhang@redhat.com>
> Suggested-by: Bart Van Assche <bvanassche@acm.org>
> Suggested-by: Daniel Wagner <dwagner@suse.de>
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>

FYI, I have applied this patch with the comment improvement Bart suggested.
Thanks!

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

end of thread, other threads:[~2025-07-17  7:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-15  4:32 [PATCH blktests v2] loop/010, common/rc: drain udev events after test Shin'ichiro Kawasaki
2025-07-15  9:22 ` Daniel Wagner
2025-07-15 12:58 ` Bart Van Assche
2025-07-17  7:33 ` Shinichiro Kawasaki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).