]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdadm.c
Enable create array with write journal (--write-journal DEVICE).
[thirdparty/mdadm.git] / mdadm.c
diff --git a/mdadm.c b/mdadm.c
index 183f6c8067cec52276041dab01296144b652fae2..f32a3d4713d206bd29f0278c7df310b370c2044b 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -74,6 +74,7 @@ int main(int argc, char *argv[])
                .require_homehost = 1,
        };
        struct shape s = {
+               .journaldisks   = 0,
                .level          = UnSet,
                .layout         = UnSet,
                .bitmap_chunk   = UnSet,
@@ -1170,6 +1171,23 @@ int main(int argc, char *argv[])
                case O(INCREMENTAL, IncrementalPath):
                        remove_path = optarg;
                        continue;
+               case O(CREATE, WriteJournal):
+                       if (s.journaldisks) {
+                               pr_err("Please specify only one journal device for the array.\n");
+                               pr_err("Ignoring --write-journal %s...\n", optarg);
+                               continue;
+                       }
+                       dv = xmalloc(sizeof(*dv));
+                       dv->devname = optarg;
+                       dv->disposition = 'j';  /* WriteJournal */
+                       dv->used = 0;
+                       dv->next = NULL;
+                       *devlistend = dv;
+                       devlistend = &dv->next;
+                       devs_found++;
+
+                       s.journaldisks = 1;
+                       continue;
                }
                /* We have now processed all the valid options. Anything else is
                 * an error
@@ -1197,6 +1215,11 @@ int main(int argc, char *argv[])
                exit(0);
        }
 
+       if (s.journaldisks && (s.level < 4 || s.level > 6)) {
+               pr_err("--write-journal is only supported for RAID level 4/5/6.\n");
+               exit(2);
+       }
+
        if (!mode && devs_found) {
                mode = MISC;
                devmode = 'Q';