summaryrefslogtreecommitdiff
path: root/Monitor.c
diff options
context:
space:
mode:
authorAnna Czarnowska <anna.czarnowska@intel.com>2010-12-03 14:11:29 +1100
committerNeilBrown <neilb@suse.de>2010-12-03 14:11:29 +1100
commite9a2ac028eb66fdc50c079fc9bf03aa4325bcd5f (patch)
treee07e987cf6d4b68e8f57717a10d7a3c1cda7773f /Monitor.c
parentf0b853063043b2e67521641db4524548841fa530 (diff)
Monitor: don't add more spares than needed
When we add a spare to a container it takes a while before it is noticed by mdmon and recovery starts. During this time the array remains degraded but we don't want to add any more spares to this container. Therefore we must check container with degraded array if it doesn't already have a suitable spare. container_choose_spare is reused with from=to Domain check is not needed in this situation. Ping_manager after moving disk is needed to be able to see newly added disk in container after coming back through the loop. Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Monitor.c')
-rw-r--r--Monitor.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/Monitor.c b/Monitor.c
index 8f1bfea9..61550ee0 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -743,6 +743,11 @@ static int move_spare(struct state *from, struct state *to,
devlist.disposition = 'a';
if (Manage_subdevs(to->devname, fd1, &devlist, -1, 0) == 0) {
alert("MoveSpare", to->devname, from->devname, info);
+ /* make sure we will see newly added spare before next
+ * time through loop
+ */
+ ping_manager(to->devname);
+ ping_manager(from->devname);
close(fd1);
close(fd2);
return 1;
@@ -853,13 +858,20 @@ static dev_t container_choose_spare(struct state *from, struct state *to,
dev = 0;
continue;
}
+ if (from == to)
+ /* Just checking if destination already has
+ * a spare, no need to check policy, we are
+ * done.
+ */
+ break;
+
pol = devnum_policy(dev);
if (from->spare_group)
pol_add(&pol, pol_domain,
from->spare_group, NULL);
if (!domain_test(domlist, pol, to->metadata->ss->name))
dev = 0;
-
+
dev_policy_free(pol);
}
}
@@ -887,6 +899,15 @@ static void try_spare_migration(struct state *statelist, struct alert_info *info
to = to->parent;
min_size = min_spare_size_required(to);
+ if (to->metadata->ss->external) {
+ /* We must make sure there is
+ * no suitable spare in container already.
+ * If there is we don't add more */
+ dev_t devid = container_choose_spare(
+ to, to, NULL, min_size);
+ if (devid > 0)
+ continue;
+ }
for (d = 0; d < MaxDisks; d++)
if (to->devid[d])
domainlist_add_dev(&domlist,