[PATCH 3/3] Incremental: move suitable spares to container when subarrays started.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From c558e3339abec25a12537498feea49f976639617 Mon Sep 17 00:00:00 2001
From: Anna Czarnowska <anna.czarnowska@xxxxxxxxx>
Date: Thu, 23 Dec 2010 13:55:41 +0100
Subject: [PATCH 3/3] Incremental: move suitable spares to container when subarrays started.
Cc: linux-raid@xxxxxxxxxxxxxxx, Williams, Dan J <dan.j.williams@xxxxxxxxx>, Ciechanowski, Ed <ed.ciechanowski@xxxxxxxxx>

By default Incremental places all imsm spares in separate container
with uuid=0:0:0:0. (patch giving spares uuid_zero needed)

When we find enough members to start an array
we are able to determine domain so we search spare container
for suitable spares and move them to the container that
is currently assembled.

Signed-off-by: Anna Czarnowska <anna.czarnowska@xxxxxxxxx>
---
 Incremental.c |   45 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/Incremental.c b/Incremental.c
index 4ee1981..a4cfffc 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -1553,6 +1553,51 @@ static int Incremental_container(struct supertype *st, char *devname,
 		assemble_container_content(st, mdfd, ra, runstop,
 					   chosen_name, verbose);
 	}
+
+	/* Now move all suitable spares from spare container */
+	struct domainlist *domains = domain_from_array(list, st->ss->name);
+	if (domains) {
+		struct map_ent *smp;
+		int suuid[4];
+		
+		memcpy(suuid, uuid_zero, sizeof(int[4]));
+		smp = map_by_uuid(&map, suuid);
+		if (smp) {
+			int sfd = open(smp->path, O_RDONLY);
+			if (sfd > 0) {
+				/* spare container found */
+				struct supertype *sst = super_imsm.match_metadata_desc("imsm");
+				struct mdinfo *sinfo;
+				unsigned long long min_size = 0;
+				if (st->ss->min_acceptable_spare_size)
+					min_size = st->ss->min_acceptable_spare_size(st);
+				if (!sst->ss->load_container(sst, sfd, NULL)) {
+					close(sfd);
+					sinfo = container_chose_spares(sst, min_size,
+								domains, NULL, st->ss->name, 0);
+					sst->ss->free_super(sst);
+					if (sinfo){
+						int count = 0;
+						struct mdinfo *disks = sinfo->devs;
+						while (disks) {
+							/* move spare from spare container
+							to currently assembled one */
+							if (move_spare(smp->path, devname,
+								makedev(disks->disk.major, disks->disk.minor)))
+								count++;
+							disks = disks->next;
+						}
+						if (count)
+							fprintf(stderr, Name ": Added %d spare%s to %s\n",
+								count, count>1?"s":"", devname) ;
+					}
+					sysfs_free(sinfo);
+				} else
+					close(sfd);
+			}
+		}
+	}
+	domain_free(domains);
 	map_unlock(&map);
 	return 0;
 }
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux