aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2012-03-18 21:46:37 -0400
committerNeilBrown <neilb@suse.de>2012-03-18 21:46:37 -0400
commitc744a65c1e2d59acc54333ce80a5b0702a98010b (patch)
treec76ff42e8f799030636d07c82879cc2bef7798db /drivers/md
parentdc10c643e8a8d008fd16dd6706e9e0018eadf8d2 (diff)
md: don't set md arrays to readonly on shutdown.
It seems that with recent kernel, writeback can still be happening while shutdown is happening, and consequently data can be written after the md reboot notifier switches all arrays to read-only. This causes a BUG. So don't switch them to read-only - just mark them clean and set 'safemode' to '2' which mean that immediately after any write the array will be switch back to 'clean'. This could result in the shutdown happening when array is marked dirty, thus forcing a resync on reboot. However if you reboot without performing a "sync" first, you get to keep both halves. This is suitable for any stable kernel (though there might be some conflicts with obvious fixes in earlier kernels). Cc: stable@vger.kernel.org Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/md.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index ce88755baf4a..115a6dd85837 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -8157,30 +8157,23 @@ static int md_notify_reboot(struct notifier_block *this,
8157 struct mddev *mddev; 8157 struct mddev *mddev;
8158 int need_delay = 0; 8158 int need_delay = 0;
8159 8159
8160 if ((code == SYS_DOWN) || (code == SYS_HALT) || (code == SYS_POWER_OFF)) { 8160 for_each_mddev(mddev, tmp) {
8161 8161 if (mddev_trylock(mddev)) {
8162 printk(KERN_INFO "md: stopping all md devices.\n"); 8162 __md_stop_writes(mddev);
8163 8163 mddev->safemode = 2;
8164 for_each_mddev(mddev, tmp) { 8164 mddev_unlock(mddev);
8165 if (mddev_trylock(mddev)) {
8166 /* Force a switch to readonly even array
8167 * appears to still be in use. Hence
8168 * the '100'.
8169 */
8170 md_set_readonly(mddev, 100);
8171 mddev_unlock(mddev);
8172 }
8173 need_delay = 1;
8174 } 8165 }
8175 /* 8166 need_delay = 1;
8176 * certain more exotic SCSI devices are known to be
8177 * volatile wrt too early system reboots. While the
8178 * right place to handle this issue is the given
8179 * driver, we do want to have a safe RAID driver ...
8180 */
8181 if (need_delay)
8182 mdelay(1000*1);
8183 } 8167 }
8168 /*
8169 * certain more exotic SCSI devices are known to be
8170 * volatile wrt too early system reboots. While the
8171 * right place to handle this issue is the given
8172 * driver, we do want to have a safe RAID driver ...
8173 */
8174 if (need_delay)
8175 mdelay(1000*1);
8176
8184 return NOTIFY_DONE; 8177 return NOTIFY_DONE;
8185} 8178}
8186 8179