diff mbox series

[mdadm,v3,1/2] tests/00readonly: Run udevadm settle before setting ro

Message ID 20220727215246.121365-2-logang@deltatee.com (mailing list archive)
State Mainlined, archived
Delegated to: Jes Sorensen
Headers show
Series Couple more testing fixes | expand

Commit Message

Logan Gunthorpe July 27, 2022, 9:52 p.m. UTC
In some recent kernel versions, 00readonly fails with:

  mdadm: failed to set readonly for /dev/md0: Device or resource busy
  ERROR: array is not read-only!

This was traced down to a race condition with udev holding a reference
to the block device at the same time as trying to set it read only.

To fix this, call udevadm settle before setting the array read only.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
---
 tests/00readonly | 1 +
 1 file changed, 1 insertion(+)

Comments

Jes Sorensen Aug. 23, 2022, 1:50 p.m. UTC | #1
On 7/27/22 17:52, Logan Gunthorpe wrote:
> In some recent kernel versions, 00readonly fails with:
> 
>   mdadm: failed to set readonly for /dev/md0: Device or resource busy
>   ERROR: array is not read-only!
> 
> This was traced down to a race condition with udev holding a reference
> to the block device at the same time as trying to set it read only.
> 
> To fix this, call udevadm settle before setting the array read only.
> 
> Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
> ---
>  tests/00readonly | 1 +
>  1 file changed, 1 insertion(+)

Applied,

Thanks,
Jes
diff mbox series

Patch

diff --git a/tests/00readonly b/tests/00readonly
index 39202487f614..afe243b3a0b0 100644
--- a/tests/00readonly
+++ b/tests/00readonly
@@ -12,6 +12,7 @@  do
 			$dev1 $dev2 $dev3 $dev4 --assume-clean
 		check nosync
 		check $level
+		udevadm settle
 		mdadm -ro $md0
 		check readonly
 		state=$(cat /sys/block/md0/md/array_state)