dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/managemon-Dont-add-disk-to-the-array-after-it.patch

b7f731
commit a44c262abc49b3c69ee80c97813388e5d021d20b
b7f731
Author: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
b7f731
Date:   Thu Dec 7 10:23:54 2017 +0100
b7f731
b7f731
    managemon: Don't add disk to the array after it has started
b7f731
    
b7f731
    If disk has disappeared from the system and appears again, it is added to the
b7f731
    corresponding container as long the metadata matches and disk number is set.
b7f731
    This code had no effect on imsm until commit 20dc76d15b40 ("imsm: Set disk slot
b7f731
    number"). Now the disk is added to container but not to the array - it is
b7f731
    correct as the disk is out-of-sync. Rebuild should start for the disk but it
b7f731
    doesn't. There is the same behaviour for both imsm and ddf metadata.
b7f731
    
b7f731
    There is no point to handle out-of-sync disk as "good member of array" so
b7f731
    remove that part of code. There are no scenarios when monitor is already
b7f731
    running and disk can be safely added to the array. Just write initial metadata
b7f731
    to the disk so it's taken for rebuild.
b7f731
    
b7f731
    Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
b7f731
    Signed-off-by: Jes Sorensen <jsorensen@fb.com>
b7f731
b7f731
diff --git a/managemon.c b/managemon.c
b7f731
index 4e85398..101231c 100644
b7f731
--- a/managemon.c
b7f731
+++ b/managemon.c
b7f731
@@ -266,9 +266,7 @@ static void add_disk_to_container(struct supertype *st, struct mdinfo *sd)
b7f731
 {
b7f731
 	int dfd;
b7f731
 	char nm[20];
b7f731
-	struct supertype *st2;
b7f731
 	struct metadata_update *update = NULL;
b7f731
-	struct mdinfo info;
b7f731
 	mdu_disk_info_t dk = {
b7f731
 		.number = -1,
b7f731
 		.major = sd->disk.major,
b7f731
@@ -287,25 +285,6 @@ static void add_disk_to_container(struct supertype *st, struct mdinfo *sd)
b7f731
 	if (dfd < 0)
b7f731
 		return;
b7f731
 
b7f731
-	/* Check the metadata and see if it is already part of this
b7f731
-	 * array
b7f731
-	 */
b7f731
-	st2 = dup_super(st);
b7f731
-	if (st2->ss->load_super(st2, dfd, NULL) == 0) {
b7f731
-		st2->ss->getinfo_super(st2, &info, NULL);
b7f731
-		if (st->ss->compare_super(st, st2) == 0 &&
b7f731
-		    info.disk.raid_disk >= 0) {
b7f731
-			/* Looks like a good member of array.
b7f731
-			 * Just accept it.
b7f731
-			 * mdadm will incorporate any parts into
b7f731
-			 * active arrays.
b7f731
-			 */
b7f731
-			st2->ss->free_super(st2);
b7f731
-			return;
b7f731
-		}
b7f731
-	}
b7f731
-	st2->ss->free_super(st2);
b7f731
-
b7f731
 	st->update_tail = &update;
b7f731
 	st->ss->add_to_super(st, &dk, dfd, NULL, INVALID_SECTORS);
b7f731
 	st->ss->write_init_super(st);