summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2013-02-28 11:59:03 +1100
committerNeilBrown <neilb@suse.de>2013-02-28 11:59:03 +1100
commitf3378b48705154b9089affb2d2e939622aea68f1 (patch)
treec86f47335ba1bd4fea0dfeb56b0484cebec8dc9b
parent51acbcec6c42b24482bac18e42befc822524535d (diff)
downloadlinux-3.10-f3378b48705154b9089affb2d2e939622aea68f1.tar.gz
linux-3.10-f3378b48705154b9089affb2d2e939622aea68f1.tar.bz2
linux-3.10-f3378b48705154b9089affb2d2e939622aea68f1.zip
md: expedite metadata update when switching read-auto -> active
If something has failed while the array was read-auto, then when we switch to 'active' we need to update the metadata. This will happen anyway but it is good to expedite it, and also to ensure any failed device has been released by the underlying device before we try to action the ioctl which caused us to switch to 'active' mode. Reported-by: Joe Lawrence <Joe.Lawrence@stratus.com> Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--drivers/md/md.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index f363135144f..fcb878f8879 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6532,7 +6532,17 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
mddev->ro = 0;
sysfs_notify_dirent_safe(mddev->sysfs_state);
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
- md_wakeup_thread(mddev->thread);
+ /* mddev_unlock will wake thread */
+ /* If a device failed while we were read-only, we
+ * need to make sure the metadata is updated now.
+ */
+ if (test_bit(MD_CHANGE_DEVS, &mddev->flags)) {
+ mddev_unlock(mddev);
+ wait_event(mddev->sb_wait,
+ !test_bit(MD_CHANGE_DEVS, &mddev->flags) &&
+ !test_bit(MD_CHANGE_PENDING, &mddev->flags));
+ mddev_lock(mddev);
+ }
} else {
err = -EROFS;
goto abort_unlock;