Blame SOURCES/0072-Incremental-Remove-redundant-spare-movement-logic.patch

33ddcd
From 69068584f9ed68b8b2736287a1c9863e11b741d5 Mon Sep 17 00:00:00 2001
33ddcd
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
33ddcd
Date: Fri, 11 Dec 2020 12:28:38 +0100
33ddcd
Subject: [PATCH 1/1] Incremental: Remove redundant spare movement logic
33ddcd
33ddcd
If policy is set then mdmonitor is responsible for moving spares.
33ddcd
This logic is reduntant and potentialy dangerus, spare could be moved at
33ddcd
initrd stage depending on drives appearance order.
33ddcd
33ddcd
Remove it.
33ddcd
33ddcd
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
33ddcd
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
33ddcd
---
33ddcd
 Incremental.c | 62 ---------------------------------------------------
33ddcd
 1 file changed, 62 deletions(-)
33ddcd
33ddcd
diff --git a/Incremental.c b/Incremental.c
33ddcd
index ad9ec1cc..e849bdda 100644
33ddcd
--- a/Incremental.c
33ddcd
+++ b/Incremental.c
33ddcd
@@ -1460,12 +1460,6 @@ static int Incremental_container(struct supertype *st, char *devname,
33ddcd
 	int trustworthy;
33ddcd
 	struct mddev_ident *match;
33ddcd
 	int rv = 0;
33ddcd
-	struct domainlist *domains;
33ddcd
-	struct map_ent *smp;
33ddcd
-	int suuid[4];
33ddcd
-	int sfd;
33ddcd
-	int ra_blocked = 0;
33ddcd
-	int ra_all = 0;
33ddcd
 	int result = 0;
33ddcd
 
33ddcd
 	st->ss->getinfo_super(st, &info, NULL);
33ddcd
@@ -1509,12 +1503,10 @@ static int Incremental_container(struct supertype *st, char *devname,
33ddcd
 		struct map_ent *mp;
33ddcd
 		struct mddev_ident *match = NULL;
33ddcd
 
33ddcd
-		ra_all++;
33ddcd
 		/* do not activate arrays blocked by metadata handler */
33ddcd
 		if (ra->array.state & (1 << MD_SB_BLOCK_VOLUME)) {
33ddcd
 			pr_err("Cannot activate array %s in %s.\n",
33ddcd
 				ra->text_version, devname);
33ddcd
-			ra_blocked++;
33ddcd
 			continue;
33ddcd
 		}
33ddcd
 		mp = map_by_uuid(&map, ra->uuid);
33ddcd
@@ -1617,60 +1609,6 @@ static int Incremental_container(struct supertype *st, char *devname,
33ddcd
 		}
33ddcd
 		printf("\n");
33ddcd
 	}
33ddcd
-
33ddcd
-	/* don't move spares to container with volume being activated
33ddcd
-	   when all volumes are blocked */
33ddcd
-	if (ra_all == ra_blocked)
33ddcd
-		return 0;
33ddcd
-
33ddcd
-	/* Now move all suitable spares from spare container */
33ddcd
-	domains = domain_from_array(list, st->ss->name);
33ddcd
-	memcpy(suuid, uuid_zero, sizeof(int[4]));
33ddcd
-	if (domains &&
33ddcd
-	    (smp = map_by_uuid(&map, suuid)) != NULL &&
33ddcd
-	    (sfd = open(smp->path, O_RDONLY)) >= 0) {
33ddcd
-		/* spare container found */
33ddcd
-		struct supertype *sst =
33ddcd
-			super_imsm.match_metadata_desc("imsm");
33ddcd
-		struct mdinfo *sinfo;
33ddcd
-
33ddcd
-		if (!sst->ss->load_container(sst, sfd, NULL)) {
33ddcd
-			struct spare_criteria sc = {0, 0};
33ddcd
-
33ddcd
-			if (st->ss->get_spare_criteria)
33ddcd
-				st->ss->get_spare_criteria(st, &sc);
33ddcd
-
33ddcd
-			close(sfd);
33ddcd
-			sinfo = container_choose_spares(sst, &sc,
33ddcd
-							domains, NULL,
33ddcd
-							st->ss->name, 0);
33ddcd
-			sst->ss->free_super(sst);
33ddcd
-			if (sinfo){
33ddcd
-				int count = 0;
33ddcd
-				struct mdinfo *disks = sinfo->devs;
33ddcd
-				while (disks) {
33ddcd
-					/* move spare from spare
33ddcd
-					 * container to currently
33ddcd
-					 * assembled one
33ddcd
-					 */
33ddcd
-					if (move_spare(
33ddcd
-						    smp->path,
33ddcd
-						    devname,
33ddcd
-						    makedev(disks->disk.major,
33ddcd
-							    disks->disk.minor)))
33ddcd
-						count++;
33ddcd
-					disks = disks->next;
33ddcd
-				}
33ddcd
-				if (count)
33ddcd
-					pr_err("Added %d spare%s to %s\n",
33ddcd
-					       count, count>1?"s":"", devname);
33ddcd
-			}
33ddcd
-			sysfs_free(sinfo);
33ddcd
-		} else
33ddcd
-			close(sfd);
33ddcd
-	}
33ddcd
-	domain_free(domains);
33ddcd
-	map_free(map);
33ddcd
 	return 0;
33ddcd
 }
33ddcd
 
33ddcd
-- 
33ddcd
2.31.1
33ddcd