raid5-cache: start raid5 readonly if journal is missing
authorShaohua Li <shli@fb.com>
Fri, 9 Oct 2015 04:54:10 +0000 (21:54 -0700)
committerNeilBrown <neilb@suse.com>
Sun, 1 Nov 2015 02:48:29 +0000 (13:48 +1100)
If raid array is expected to have journal (eg, journal is set in MD
superblock feature map) and the array is started without journal disk,
start the array readonly.

Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: NeilBrown <neilb@suse.com>
drivers/md/raid5-cache.c
drivers/md/raid5.c

index 62e5fe4afae8b5b924007400fcd62462d54bd55b..b887e04d7e5c2554b3112de0f9fa5e61b93ed40b 100644 (file)
@@ -806,8 +806,9 @@ void r5l_quiesce(struct r5l_log *log, int state)
 
 bool r5l_log_disk_error(struct r5conf *conf)
 {
+       /* don't allow write if journal disk is missing */
        if (!conf->log)
-               return false;
+               return test_bit(MD_HAS_JOURNAL, &conf->mddev->flags);
        return test_bit(Faulty, &conf->log->rdev->flags);
 }
 
index 68c36ce4fe8ebd4b4eda7837b036dfcc03e46e6f..e1d18be67243a682193747805258abf3a09146cb 100644 (file)
@@ -6810,6 +6810,13 @@ static int run(struct mddev *mddev)
        if (IS_ERR(conf))
                return PTR_ERR(conf);
 
+       if (test_bit(MD_HAS_JOURNAL, &mddev->flags) && !journal_dev) {
+               printk(KERN_ERR "md/raid:%s: journal disk is missing, force array readonly\n",
+                      mdname(mddev));
+               mddev->ro = 1;
+               set_disk_ro(mddev->gendisk, 1);
+       }
+
        conf->min_offset_diff = min_offset_diff;
        mddev->thread = conf->thread;
        conf->thread = NULL;