1From 39b381252c32275079344d30de18b76fda4bba26 Mon Sep 17 00:00:00 2001
2From: Logan Gunthorpe <logang@deltatee.com>
3Date: Wed, 27 Jul 2022 15:52:45 -0600
4Subject: [PATCH] tests/00readonly: Run udevadm settle before setting ro
5
6In some recent kernel versions, 00readonly fails with:
7
8  mdadm: failed to set readonly for /dev/md0: Device or resource busy
9  ERROR: array is not read-only!
10
11This was traced down to a race condition with udev holding a reference
12to the block device at the same time as trying to set it read only.
13
14To fix this, call udevadm settle before setting the array read only.
15
16Upstream-Status: Backport [https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/commit/?id=39b381252c32275079344d30de18b76fda4bba26]
17
18Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
19Signed-off-by: Jes Sorensen <jsorensen@fb.com>
20Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
21---
22 tests/00readonly | 1 +
23 1 file changed, 1 insertion(+)
24
25diff --git a/tests/00readonly b/tests/00readonly
26index 39202487..afe243b3 100644
27--- a/tests/00readonly
28+++ b/tests/00readonly
29@@ -12,6 +12,7 @@ do
30 			$dev1 $dev2 $dev3 $dev4 --assume-clean
31 		check nosync
32 		check $level
33+		udevadm settle
34 		mdadm -ro $md0
35 		check readonly
36 		state=$(cat /sys/block/md0/md/array_state)
37--
382.25.1
39
40