diff mbox series

[blktests,v2] dm/002: avoid device access by udev at dmsetup remove

Message ID 20240719042318.265227-1-shinichiro.kawasaki@wdc.com (mailing list archive)
State Superseded, archived
Delegated to: Mike Snitzer
Headers show
Series [blktests,v2] dm/002: avoid device access by udev at dmsetup remove | expand

Commit Message

Shinichiro Kawasaki July 19, 2024, 4:23 a.m. UTC
The test case dm/002 rarely fails with the message below:

dm/002 => nvme0n1 (dm-dust general functionality test)       [failed]
    runtime  0.204s  ...  0.174s
    --- tests/dm/002.out        2024-06-14 14:37:40.480794693 +0900
    +++ /home/shin/Blktests/blktests/results/nvme0n1/dm/002.out.bad     2024-06-14 21:38:18.588976499 +0900
    @@ -7,4 +7,6 @@
     countbadblocks: 0 badblock(s) found
     countbadblocks: 3 badblock(s) found
     countbadblocks: 0 badblock(s) found
    +device-mapper: remove ioctl on dust1  failed: Device or resource busy
    +Command failed.
     Test complete
modprobe: FATAL: Module dm_dust is in use.

This failure happens when udev opens the dm device at "dmsetup remove"
command. To avoid the failure, call "udevadm settle" before the "dmsetup
remove" command.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
This patch addresses a failure found during the debug work for another
dm/002 failure [1]. Per discussion on v1 patch [2], do "udevadm settle"
instead of retrying "dmsetup remove".

[1] https://lore.kernel.org/linux-block/42ecobcsduvlqh77iavjj2p3ewdh7u4opdz4xruauz4u5ddljz@yr7ye4fq72tr/
[2] https://lore.kernel.org/linux-block/o5wik4yvo2teffpjlwycbaek6znrtde5kml3hkof5r2w5rxttj@bhokt2ksdcbj/

 tests/dm/002 | 1 +
 1 file changed, 1 insertion(+)

Comments

Milan Broz July 19, 2024, 7:14 a.m. UTC | #1
On 7/19/24 6:23 AM, Shin'ichiro Kawasaki wrote:
> The test case dm/002 rarely fails with the message below:
> 
> dm/002 => nvme0n1 (dm-dust general functionality test)       [failed]
>      runtime  0.204s  ...  0.174s
>      --- tests/dm/002.out        2024-06-14 14:37:40.480794693 +0900
>      +++ /home/shin/Blktests/blktests/results/nvme0n1/dm/002.out.bad     2024-06-14 21:38:18.588976499 +0900
>      @@ -7,4 +7,6 @@
>       countbadblocks: 0 badblock(s) found
>       countbadblocks: 3 badblock(s) found
>       countbadblocks: 0 badblock(s) found
>      +device-mapper: remove ioctl on dust1  failed: Device or resource busy
>      +Command failed.
>       Test complete
> modprobe: FATAL: Module dm_dust is in use.
> 
> This failure happens when udev opens the dm device at "dmsetup remove"
> command. To avoid the failure, call "udevadm settle" before the "dmsetup
> remove" command.

I think udevadm settle is overkill as it waits for everything, not only that device.

Did you consider to use "dmsetup remove --retry <dev>"? This is one
liner and you do not need to implement the retry yourself.

We have many such situations in cryptsetup tests and --retry was enough
to fix it (as the busy comes usually from blkid scan that is fast enough).
It will print a few benign messages while retrying, though.

(Just a hint, I am not nacking the patch :)

Milan

> 
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> ---
> This patch addresses a failure found during the debug work for another
> dm/002 failure [1]. Per discussion on v1 patch [2], do "udevadm settle"
> instead of retrying "dmsetup remove".
> 
> [1] https://lore.kernel.org/linux-block/42ecobcsduvlqh77iavjj2p3ewdh7u4opdz4xruauz4u5ddljz@yr7ye4fq72tr/
> [2] https://lore.kernel.org/linux-block/o5wik4yvo2teffpjlwycbaek6znrtde5kml3hkof5r2w5rxttj@bhokt2ksdcbj/
> 
>   tests/dm/002 | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/tests/dm/002 b/tests/dm/002
> index fae3986..afa174a 100755
> --- a/tests/dm/002
> +++ b/tests/dm/002
> @@ -37,6 +37,7 @@ test_device() {
>   	sync
>   	dmsetup message dust1 0 countbadblocks
>   	sync
> +	udevadm settle
>   	dmsetup remove dust1
>   
>   	echo "Test complete"
Shinichiro Kawasaki July 23, 2024, 3:51 a.m. UTC | #2
On Jul 19, 2024 / 09:14, Milan Broz wrote:
> On 7/19/24 6:23 AM, Shin'ichiro Kawasaki wrote:
> > The test case dm/002 rarely fails with the message below:
> > 
> > dm/002 => nvme0n1 (dm-dust general functionality test)       [failed]
> >      runtime  0.204s  ...  0.174s
> >      --- tests/dm/002.out        2024-06-14 14:37:40.480794693 +0900
> >      +++ /home/shin/Blktests/blktests/results/nvme0n1/dm/002.out.bad     2024-06-14 21:38:18.588976499 +0900
> >      @@ -7,4 +7,6 @@
> >       countbadblocks: 0 badblock(s) found
> >       countbadblocks: 3 badblock(s) found
> >       countbadblocks: 0 badblock(s) found
> >      +device-mapper: remove ioctl on dust1  failed: Device or resource busy
> >      +Command failed.
> >       Test complete
> > modprobe: FATAL: Module dm_dust is in use.
> > 
> > This failure happens when udev opens the dm device at "dmsetup remove"
> > command. To avoid the failure, call "udevadm settle" before the "dmsetup
> > remove" command.
> 
> I think udevadm settle is overkill as it waits for everything, not only that device.
> 
> Did you consider to use "dmsetup remove --retry <dev>"? This is one
> liner and you do not need to implement the retry yourself.
> 
> We have many such situations in cryptsetup tests and --retry was enough
> to fix it (as the busy comes usually from blkid scan that is fast enough).
> It will print a few benign messages while retrying, though.
> 
> (Just a hint, I am not nacking the patch :)

Thanks Milan, I was not aware of the --retry option. I confirmed it avoids the
failure. I think it's the better than "udevadm settle". Will post v3.
diff mbox series

Patch

diff --git a/tests/dm/002 b/tests/dm/002
index fae3986..afa174a 100755
--- a/tests/dm/002
+++ b/tests/dm/002
@@ -37,6 +37,7 @@  test_device() {
 	sync
 	dmsetup message dust1 0 countbadblocks
 	sync
+	udevadm settle
 	dmsetup remove dust1
 
 	echo "Test complete"