]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
tests/00readonly: Run udevadm settle before setting ro
authorLogan Gunthorpe <logang@deltatee.com>
Wed, 27 Jul 2022 21:52:45 +0000 (15:52 -0600)
committerJes Sorensen <jsorensen@fb.com>
Tue, 23 Aug 2022 13:41:28 +0000 (09:41 -0400)
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>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
tests/00readonly

index 39202487f61498f61e1e71b754e53c70325551a6..afe243b3a0b031e687488f7ec6a959c2e4a2fde0 100644 (file)
@@ -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)