diff options
author | NeilBrown <neilb@suse.de> | 2008-04-30 03:52:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-30 11:29:32 -0400 |
commit | 648b629ed406233b0a607a3cf29d8a169876131f (patch) | |
tree | 4faf3a965c6f369608b5187a3ecdd25e00264d63 /drivers/md/md.c | |
parent | 31a59e3425d32743738e043c1df1668e0f22bbab (diff) |
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: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index ff9fef389608..32b2ad88a2f9 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -2594,15 +2594,20 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len) | |||
2594 | err = do_md_stop(mddev, 1); | 2594 | err = do_md_stop(mddev, 1); |
2595 | else { | 2595 | else { |
2596 | mddev->ro = 1; | 2596 | mddev->ro = 1; |
2597 | set_disk_ro(mddev->gendisk, 1); | ||
2597 | err = do_md_run(mddev); | 2598 | err = do_md_run(mddev); |
2598 | } | 2599 | } |
2599 | break; | 2600 | break; |
2600 | case read_auto: | 2601 | case read_auto: |
2601 | /* stopping an active array */ | ||
2602 | if (mddev->pers) { | 2602 | if (mddev->pers) { |
2603 | err = do_md_stop(mddev, 1); | 2603 | if (mddev->ro != 1) |
2604 | if (err == 0) | 2604 | err = do_md_stop(mddev, 1); |
2605 | mddev->ro = 2; /* FIXME mark devices writable */ | 2605 | else |
2606 | err = restart_array(mddev); | ||
2607 | if (err == 0) { | ||
2608 | mddev->ro = 2; | ||
2609 | set_disk_ro(mddev->gendisk, 0); | ||
2610 | } | ||
2606 | } else { | 2611 | } else { |
2607 | mddev->ro = 2; | 2612 | mddev->ro = 2; |
2608 | err = do_md_run(mddev); | 2613 | err = do_md_run(mddev); |
@@ -2640,6 +2645,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len) | |||
2640 | err = 0; | 2645 | err = 0; |
2641 | } else { | 2646 | } else { |
2642 | mddev->ro = 0; | 2647 | mddev->ro = 0; |
2648 | set_disk_ro(mddev->gendisk, 0); | ||
2643 | err = do_md_run(mddev); | 2649 | err = do_md_run(mddev); |
2644 | } | 2650 | } |
2645 | break; | 2651 | break; |