if (pending_discard == discard_this)
pending_discard = NULL;
discard_this = NULL;
+ wakeup_monitor();
}
}
*/
remove_old();
while (pending_discard) {
- wakeup_monitor();
while (discard_this == NULL)
sleep(1);
remove_old();
* and open files for each newdev */
for (d = newdev; d ; d = d->next) {
struct mdinfo *newd;
- if (sysfs_add_disk(&newa->info, d))
+ if (sysfs_add_disk(&newa->info, d) < 0)
continue;
newd = newa->info.devs;
newd->state_fd = sysfs_open(a->devnum,
inst = &mdstat->metadata_version[10+strlen(container->devname)+1];
mdi = sysfs_read(-1, new->devnum,
- GET_LEVEL|GET_CHUNK|GET_DISKS|
+ GET_LEVEL|GET_CHUNK|GET_DISKS|GET_COMPONENT|
GET_DEVS|GET_OFFSET|GET_SIZE|GET_STATE);
if (!mdi) {
/* Eeek. Cannot monitor this array.
}
new->info.array = mdi->array;
+ new->info.component_size = mdi->component_size;
for (i = 0; i < new->info.array.raid_disks; i++) {
struct mdinfo *newd = malloc(sizeof(*newd));
new->action_fd = sysfs_open(new->devnum, NULL, "sync_action");
new->info.state_fd = sysfs_open(new->devnum, NULL, "array_state");
new->resync_start_fd = sysfs_open(new->devnum, NULL, "resync_start");
- new->resync_start = 0;
+ get_resync_start(new);
dprintf("%s: inst: %d action: %d state: %d\n", __func__, atoi(inst),
new->action_fd, new->info.state_fd);
}
}
-static int handle_message(struct supertype *container, struct md_message *msg)
+static void handle_message(struct supertype *container, struct metadata_update *msg)
{
- return -1;
+ /* queue this metadata update through to the monitor */
+
+ struct metadata_update *mu;
+
+ if (msg->len == 0) {
+ int cnt = monitor_loop_cnt;
+ if (cnt & 1)
+ cnt += 2; /* wait until next pselect */
+ else
+ cnt += 3; /* wait for 2 pselects */
+ wakeup_monitor();
+ wait_update_handled();
+ while (monitor_loop_cnt - cnt < 0)
+ usleep(10 * 1000);
+ } else {
+ mu = malloc(sizeof(*mu));
+ mu->len = msg->len;
+ mu->buf = msg->buf;
+ msg->buf = NULL;
+ mu->space = NULL;
+ mu->next = NULL;
+ if (container->ss->prepare_update)
+ container->ss->prepare_update(container, mu);
+ queue_metadata_update(mu);
+ }
}
void read_sock(struct supertype *container)
{
int fd;
- struct md_message msg;
+ struct metadata_update msg;
int terminate = 0;
long fl;
int tmo = 3; /* 3 second timeout before hanging up the socket */
fcntl(fd, F_SETFL, fl);
do {
- int err;
-
msg.buf = NULL;
/* read and validate the message */
if (receive_message(fd, &msg, tmo) == 0) {
- err = handle_message(container, &msg);
- if (!err)
- ack(fd, msg.seq, tmo);
- else
- nack(fd, err, tmo);
- } else {
+ handle_message(container, &msg);
+ if (ack(fd, tmo) < 0)
+ terminate = 1;
+ } else
terminate = 1;
- nack(fd, -1, tmo);
- }
- if (msg.buf)
- free(msg.buf);
} while (!terminate);
close(fd);