[PATCH 1/2] Monitor: only get min_size once

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

 



>From 558fea1534f09051156480daf6c786f54369144e Mon Sep 17 00:00:00 2001
From: Anna Czarnowska <anna.czarnowska@xxxxxxxxx>
Date: Thu, 2 Dec 2010 16:44:58 +0100
Subject: [PATCH 1/2] Monitor: only get min_size once
Cc: linux-raid@xxxxxxxxxxxxxxx, Williams, Dan J <dan.j.williams@xxxxxxxxx>, Ciechanowski, Ed <ed.ciechanowski@xxxxxxxxx>

We may call chose_spare several times before we find a suitable one
so it is better to get the size beforehand.

Signed-off-by: Anna Czarnowska <anna.czarnowska@xxxxxxxxx>
---
 Monitor.c |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/Monitor.c b/Monitor.c
index e7f6d03..ab6eb2d 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -783,12 +783,10 @@ static int check_donor(struct state *from, struct state *to,
 }
 
 static dev_t choose_spare(struct state *from, struct state *to,
-			struct domainlist *domlist)
+			struct domainlist *domlist, unsigned long long min_size)
 {
 	int d;
 	dev_t dev = 0;
-	unsigned long long min_size
-		= min_spare_size_required(to);
 
 	for (d = from->raid; !dev && d < MaxDisks; d++) {
 		if (from->devid[d] > 0 &&
@@ -814,7 +812,7 @@ static dev_t choose_spare(struct state *from, struct state *to,
 }
 
 static dev_t container_choose_spare(struct state *from, struct state *to,
-				  struct domainlist *domlist)
+				  struct domainlist *domlist, unsigned long long min_size)
 {
 	/* This is similar to choose_spare, but we cannot trust devstate,
 	 * so we need to read the metadata instead
@@ -824,8 +822,6 @@ static dev_t container_choose_spare(struct state *from, struct state *to,
 	int fd = open(from->devname, O_RDONLY);
 	int err;
 	struct mdinfo *disks, *d;
-	unsigned long long min_size
-		= min_spare_size_required(to);
 	dev_t dev = 0;
 
 	if (fd < 0)
@@ -883,11 +879,13 @@ static void try_spare_migration(struct state *statelist, struct alert_info *info
 			struct domainlist *domlist = NULL;
 			int d;
 			struct state *to = st;
-
+			unsigned long long min_size;
+			
 			if (to->parent)
 				/* member of a container */
 				to = to->parent;
 
+			min_size = min_spare_size_required(to);
 			for (d = 0; d < MaxDisks; d++)
 				if (to->devid[d])
 					domainlist_add_dev(&domlist,
@@ -902,9 +900,10 @@ static void try_spare_migration(struct state *statelist, struct alert_info *info
 					continue;
 				if (from->metadata->ss->external)
 					devid = container_choose_spare(
-						from, to, domlist);
+						from, to, domlist, min_size);
 				else
-					devid = choose_spare(from, to, domlist);
+					devid = choose_spare(from, to, domlist,
+							     min_size);
 				if (devid > 0
 				    && move_spare(from, to, devid, info))
 						break;
-- 
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