]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
FIX: Bad block verification during assembling array
authorKrzysztof Wojcik <krzysztof.wojcik@intel.com>
Thu, 16 Dec 2010 13:34:54 +0000 (14:34 +0100)
committerNeilBrown <neilb@suse.de>
Sun, 26 Dec 2010 10:41:57 +0000 (21:41 +1100)
We need to refuse to assemble an arrays with bad blocks.
Initially there was condition in container_content function
that returns error value in the case when metadata store information
about bad blocks.
When the container_content function is called from functions NOT connected
with assemble (Kill_subarray, Detail) we get faulty error return value.
Patch introduces new flag in array.status - MD_SB_BBM_ERRORS. It is set
in container_content when bad blocks are detected and can be checked by
container_content caller.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Assemble.c
Incremental.c
md_p.h
super-intel.c

index ac489e8741c82af3c3f7fe36361a1cc81a3161ef..5405972ee4ef824346d38676157e13893f8688b0 100644 (file)
@@ -435,6 +435,13 @@ int Assemble(struct supertype *st, char *mddev,
                             content;
                             content = content->next) {
 
+                               /* do not assemble arrays that might have bad blocks */
+                               if (content->array.state & (1<<MD_SB_BBM_ERRORS)) {
+                                       fprintf(stderr, Name ": BBM log found in metadata. "
+                                                               "Cannot activate array(s).\n");
+                                       tmpdev->used = 2;
+                                       goto loop;
+                               }
                                if (!ident_matches(ident, content, tst,
                                                   homehost, update,
                                                   report_missmatch ? devname : NULL))
index a4ac1b583a53af155ea7aa3716fcbdb365414b8d..944ed6614a51eae7e4e125635dad18896cf8ac83 100644 (file)
@@ -1411,6 +1411,12 @@ static int Incremental_container(struct supertype *st, char *devname,
        if (map_lock(&map))
                fprintf(stderr, Name ": failed to get exclusive lock on "
                        "mapfile\n");
+       /* do not assemble arrays that might have bad blocks */
+       if (list->array.state & (1<<MD_SB_BBM_ERRORS)) {
+               fprintf(stderr, Name ": BBM log found in metadata. "
+                                       "Cannot activate array(s).\n");
+               list = NULL;
+       }
 
        for (ra = list ; ra ; ra = ra->next) {
                int mdfd;
diff --git a/md_p.h b/md_p.h
index 4594a36a89ff90217c6f0d9fbfcd87e3326c458e..6c79a3d12f347f54aa05ecfac01265f787e82dad 100644 (file)
--- a/md_p.h
+++ b/md_p.h
@@ -100,6 +100,7 @@ typedef struct mdp_device_descriptor_s {
  */
 #define MD_SB_CLEAN            0
 #define MD_SB_ERRORS           1
+#define MD_SB_BBM_ERRORS       2
 
 #define        MD_SB_BITMAP_PRESENT    8 /* bitmap may be present nearby */
 
index 3fc1c823b2ff447b24dc4734416823de338c9e26..adb85b23e085957433994524ed43bae28b8caf4b 100644 (file)
@@ -4520,13 +4520,11 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra
        struct imsm_super *mpb = super->anchor;
        struct mdinfo *rest = NULL;
        unsigned int i;
+       int bbm_errors = 0;
 
-       /* do not assemble arrays that might have bad blocks */
-       if (imsm_bbm_log_size(super->anchor)) {
-               fprintf(stderr, Name ": BBM log found in metadata. "
-                               "Cannot activate array(s).\n");
-               return NULL;
-       }
+       /* check for bad blocks */
+       if (imsm_bbm_log_size(super->anchor))
+               bbm_errors = 1;
 
        for (i = 0; i < mpb->num_raid_devs; i++) {
                struct imsm_dev *dev;
@@ -4635,6 +4633,10 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra
                rest = this;
        }
 
+       /* if array has bad blocks, set suitable bit in array status */
+       if (bbm_errors)
+               rest->array.state |= (1<<MD_SB_BBM_ERRORS);
+
        return rest;
 }