summaryrefslogtreecommitdiff
path: root/Monitor.c
diff options
context:
space:
mode:
authorAnna Czarnowska <anna.czarnowska@intel.com>2011-01-05 14:34:32 +1100
committerNeilBrown <neilb@suse.de>2011-01-05 14:34:32 +1100
commitd52bb542d406071d7be6c180703d981a07eb8aed (patch)
tree39eda94f9caca4e59c34227e0912f0bcb82adb23 /Monitor.c
parent326727d9c985b8f58fd53d6efcc4bd6e1721bfb5 (diff)
move_spare function modified and moved to Manage.c
It will also be needed for Incremental. 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.c51
1 files changed, 4 insertions, 47 deletions
diff --git a/Monitor.c b/Monitor.c
index 00db53f2..18462f2f 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -722,51 +722,6 @@ unsigned long long min_spare_size_required(struct state *st)
return rv;
}
-static int move_spare(struct state *from, struct state *to,
- dev_t devid,
- struct alert_info *info)
-{
- struct mddev_dev devlist;
- char devname[20];
-
- /* try to remove and add */
- int fd1 = open(to->devname, O_RDONLY);
- int fd2 = open(from->devname, O_RDONLY);
-
- if (fd1 < 0 || fd2 < 0) {
- if (fd1>=0) close(fd1);
- if (fd2>=0) close(fd2);
- return 0;
- }
-
- devlist.next = NULL;
- devlist.used = 0;
- devlist.re_add = 0;
- devlist.writemostly = 0;
- devlist.devname = devname;
- sprintf(devname, "%d:%d", major(devid), minor(devid));
-
- devlist.disposition = 'r';
- if (Manage_subdevs(from->devname, fd2, &devlist, -1, 0, NULL) == 0) {
- devlist.disposition = 'a';
- if (Manage_subdevs(to->devname, fd1, &devlist, -1, 0, NULL) == 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;
- }
- else Manage_subdevs(from->devname, fd2, &devlist, -1, 0, NULL);
- }
- close(fd1);
- close(fd2);
- return 0;
-}
-
static int check_donor(struct state *from, struct state *to)
{
struct state *sub;
@@ -912,8 +867,10 @@ static void try_spare_migration(struct state *statelist, struct alert_info *info
devid = choose_spare(from, to, domlist,
min_size);
if (devid > 0
- && move_spare(from, to, devid, info))
- break;
+ && move_spare(from->devname, to->devname, devid)) {
+ alert("MoveSpare", to->devname, from->devname, info);
+ break;
+ }
}
domain_free(domlist);
}