Commit 88724bfa authored by NeilBrown's avatar NeilBrown

md: wait for pending superblock updates before switching to read-only

If a superblock update is pending, wait for it to complete before
letting md_set_readonly() switch to readonly.
Otherwise we might lose important information about a device having

For external arrays, waiting for superblock updates can wait on
user-space, so in that case, just return an error.
Reported-and-tested-by: default avatarShaohua Li <>
Signed-off-by: default avatarNeilBrown <>
parent bcee19f4
......@@ -5409,9 +5409,13 @@ static int md_set_readonly(struct mddev *mddev, struct block_device *bdev)
* which will now never happen */
if (mddev->external && test_bit(MD_CHANGE_PENDING, &mddev->flags))
return -EBUSY;
wait_event(resync_wait, !test_bit(MD_RECOVERY_RUNNING,
!test_bit(MD_CHANGE_PENDING, &mddev->flags));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment