提交 648b629e 编写于 作者: N NeilBrown 提交者: Linus Torvalds

md: fix up switching md arrays between read-only and read-write

When setting an array to 'readonly' or to 'active' via sysfs, we must make the
appropriate set_disk_ro call too.

Also when switching to "read_auto" (which is like readonly, but blocks on the
first write so that metadata can be marked 'dirty') we need to be more careful
about what state we are changing from.
Signed-off-by: NNeil Brown <neilb@suse.de>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 31a59e34
...@@ -2594,15 +2594,20 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len) ...@@ -2594,15 +2594,20 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len)
err = do_md_stop(mddev, 1); err = do_md_stop(mddev, 1);
else { else {
mddev->ro = 1; mddev->ro = 1;
set_disk_ro(mddev->gendisk, 1);
err = do_md_run(mddev); err = do_md_run(mddev);
} }
break; break;
case read_auto: case read_auto:
/* stopping an active array */
if (mddev->pers) { if (mddev->pers) {
if (mddev->ro != 1)
err = do_md_stop(mddev, 1); err = do_md_stop(mddev, 1);
if (err == 0) else
mddev->ro = 2; /* FIXME mark devices writable */ err = restart_array(mddev);
if (err == 0) {
mddev->ro = 2;
set_disk_ro(mddev->gendisk, 0);
}
} else { } else {
mddev->ro = 2; mddev->ro = 2;
err = do_md_run(mddev); err = do_md_run(mddev);
...@@ -2640,6 +2645,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len) ...@@ -2640,6 +2645,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len)
err = 0; err = 0;
} else { } else {
mddev->ro = 0; mddev->ro = 0;
set_disk_ro(mddev->gendisk, 0);
err = do_md_run(mddev); err = do_md_run(mddev);
} }
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册