Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 1 | From 39b381252c32275079344d30de18b76fda4bba26 Mon Sep 17 00:00:00 2001 |
| 2 | From: Logan Gunthorpe <logang@deltatee.com> |
| 3 | Date: Wed, 27 Jul 2022 15:52:45 -0600 |
| 4 | Subject: [PATCH] tests/00readonly: Run udevadm settle before setting ro |
| 5 | |
| 6 | In 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 | |
| 11 | This was traced down to a race condition with udev holding a reference |
| 12 | to the block device at the same time as trying to set it read only. |
| 13 | |
| 14 | To fix this, call udevadm settle before setting the array read only. |
| 15 | |
| 16 | Upstream-Status: Backport [https://git.kernel.org/pub/scm/utils/mdadm/mdadm.git/commit/?id=39b381252c32275079344d30de18b76fda4bba26] |
| 17 | |
| 18 | Signed-off-by: Logan Gunthorpe <logang@deltatee.com> |
| 19 | Signed-off-by: Jes Sorensen <jsorensen@fb.com> |
| 20 | Signed-off-by: Mingli Yu <mingli.yu@windriver.com> |
| 21 | --- |
| 22 | tests/00readonly | 1 + |
| 23 | 1 file changed, 1 insertion(+) |
| 24 | |
| 25 | diff --git a/tests/00readonly b/tests/00readonly |
| 26 | index 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 | -- |
| 38 | 2.25.1 |
| 39 | |