]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Assemble: add --update=no-bitmap
authorNeilBrown <neilb@suse.de>
Tue, 30 Nov 2010 05:46:01 +0000 (16:46 +1100)
committerNeilBrown <neilb@suse.de>
Tue, 30 Nov 2010 05:46:01 +0000 (16:46 +1100)
This allows an array with a corrupt internal bitmap to be assembled
without the bitmap.

Signed-off-by: NeilBrown <neilb@suse.de>
mdadm.8.in
mdadm.c
super0.c
super1.c

index 1cfd9170dc185a4ffa259882081d82f4d2936a18..4fc943963fc1f8ef68c3ca838ceba60371200457 100644 (file)
@@ -903,6 +903,7 @@ argument given to this flag can be one of
 .BR resync ,
 .BR byteorder ,
 .BR devicesize ,
+.BR no\-bitmap ,
 or
 .BR super\-minor .
 
@@ -985,7 +986,7 @@ counts of total, working, active, failed, and spare devices.
 
 The
 .B devicesize
-will rarely be of use.  It applies to version 1.1 and 1.2 metadata
+option will rarely be of use.  It applies to version 1.1 and 1.2 metadata
 only (where the metadata is at the start of the device) and is only
 useful when the component device has changed size (typically become
 larger).  The version 1 metadata records the amount of the device that
@@ -999,6 +1000,12 @@ This will cause
 to determine the maximum usable amount of space on each device and
 update the relevant field in the metadata.
 
+The
+.B no\-bitmap
+option can be used when an array has an internal bitmap which is
+corrupt in some way so that assembling the array normally fails.  It
+will cause any internal bitmap to be ignored.
+
 .ig
 .TP
 .B \-\-auto\-update\-homehost
diff --git a/mdadm.c b/mdadm.c
index aa41129bde105c0de86e5100d5a7a3c4a41ea70a..ea518f1520f76c29328f285e03e8df94a7986441 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -692,6 +692,8 @@ int main(int argc, char *argv[])
                                continue;
                        if (strcmp(update, "devicesize")==0)
                                continue;
+                       if (strcmp(update, "no-bitmap")==0)
+                               continue;
                        if (strcmp(update, "byteorder")==0) {
                                if (ss) {
                                        fprintf(stderr, Name ": must not set metadata type with --update=byteorder.\n");
@@ -718,7 +720,8 @@ int main(int argc, char *argv[])
                        }
                        fprintf(outf, "Valid --update options are:\n"
                "     'sparc2.2', 'super-minor', 'uuid', 'name', 'resync',\n"
-               "     'summaries', 'homehost', 'byteorder', 'devicesize'.\n");
+               "     'summaries', 'homehost', 'byteorder', 'devicesize',\n"
+               "     'no-bitmap'\n");
                        exit(outf == stdout ? 0 : 2);
 
                case O(INCREMENTAL,NoDegraded):
index 1fcdd24c37526e4adf1da065435458d39bc66b14..d69d0c049ad81d5337a1432158c91e4d0cf08e66 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -418,8 +418,9 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
                         char *devname, int verbose,
                         int uuid_set, char *homehost)
 {
-       /* NOTE: for 'assemble' and 'force' we need to return non-zero if any change was made.
-        * For others, the return value is ignored.
+       /* NOTE: for 'assemble' and 'force' we need to return non-zero
+        * if any change was made.  For others, the return value is
+        * ignored.
         */
        int rv = 0;
        mdp_super_t *sb = st->sb;
@@ -548,6 +549,8 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
                        bm = (struct bitmap_super_s*)(sb+1);
                        uuid_from_super0(st, (int*)bm->uuid);
                }
+       } else if (strcmp(update, "no-bitmap") == 0) {
+               sb->state &= ~(1<<MD_SB_BITMAP_PRESENT);
        } else if (strcmp(update, "_reshape_progress")==0)
                sb->reshape_position = info->reshape_progress;
        else
index 6974daa0fb304cc26aa794b3e13550d771278efe..ee940333c18956a1f35c85f9bc5c6c7d2fb0d076 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -662,8 +662,9 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
                         char *devname, int verbose,
                         int uuid_set, char *homehost)
 {
-       /* NOTE: for 'assemble' and 'force' we need to return non-zero if any change was made.
-        * For others, the return value is ignored.
+       /* NOTE: for 'assemble' and 'force' we need to return non-zero
+        * if any change was made.  For others, the return value is
+        * ignored.
         */
        int rv = 0;
        struct mdp_superblock_1 *sb = st->sb;
@@ -754,6 +755,8 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
                        bm = (struct bitmap_super_s*)(st->sb+1024);
                        memcpy(bm->uuid, sb->set_uuid, 16);
                }
+       } else if (strcmp(update, "no-bitmap") == 0) {
+               sb->feature_map &= ~__cpu_to_le32(MD_FEATURE_BITMAP_OFFSET);
        } else if (strcmp(update, "homehost") == 0 &&
            homehost) {
                char *c;