"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "managemon.c" between
mdadm-4.1.tar.gz and mdadm-4.2.tar.gz

About: mdadm is a tool for creating, managing and monitoring device arrays using the "md" driver in Linux, also known as Software RAID arrays.

managemon.c  (mdadm-4.1):managemon.c  (mdadm-4.2)
skipping to change at line 664 skipping to change at line 664
static void manage_new(struct mdstat_ent *mdstat, static void manage_new(struct mdstat_ent *mdstat,
struct supertype *container, struct supertype *container,
struct active_array *victim) struct active_array *victim)
{ {
/* A new array has appeared in this container. /* A new array has appeared in this container.
* Hopefully it is already recorded in the metadata. * Hopefully it is already recorded in the metadata.
* Check, then create the new array to report it to * Check, then create the new array to report it to
* the monitor. * the monitor.
*/ */
struct active_array *new; struct active_array *new = NULL;
struct mdinfo *mdi, *di; struct mdinfo *mdi = NULL, *di;
char *inst; int i, inst;
int i;
int failed = 0; int failed = 0;
char buf[40]; char buf[40];
/* check if array is ready to be monitored */ /* check if array is ready to be monitored */
if (!mdstat->active || !mdstat->level) if (!mdstat->active || !mdstat->level)
return; return;
if (strcmp(mdstat->level, "raid0") == 0 || if (strncmp(mdstat->level, "raid0", strlen("raid0")) == 0 ||
strcmp(mdstat->level, "linear") == 0) strncmp(mdstat->level, "linear", strlen("linear")) == 0)
return; return;
mdi = sysfs_read(-1, mdstat->devnm, mdi = sysfs_read(-1, mdstat->devnm,
GET_LEVEL|GET_CHUNK|GET_DISKS|GET_COMPONENT| GET_LEVEL|GET_CHUNK|GET_DISKS|GET_COMPONENT|
GET_SAFEMODE|GET_DEVS|GET_OFFSET|GET_SIZE|GET_STATE| GET_SAFEMODE|GET_DEVS|GET_OFFSET|GET_SIZE|GET_STATE|
GET_LAYOUT); GET_LAYOUT|GET_DEVS_ALL);
if (!mdi) if (!mdi)
return; return;
new = xcalloc(1, sizeof(*new)); new = xcalloc(1, sizeof(*new));
strcpy(new->info.sys_name, mdstat->devnm); strcpy(new->info.sys_name, mdstat->devnm);
new->prev_state = new->curr_state = new->next_state = inactive; new->prev_state = new->curr_state = new->next_state = inactive;
new->prev_action= new->curr_action= new->next_action= idle; new->prev_action= new->curr_action= new->next_action= idle;
new->container = container; new->container = container;
inst = to_subarray(mdstat, container->devnm); if (parse_num(&inst, to_subarray(mdstat, container->devnm)) != 0)
goto error;
new->info.array = mdi->array; new->info.array = mdi->array;
new->info.component_size = mdi->component_size; new->info.component_size = mdi->component_size;
for (i = 0; i < new->info.array.raid_disks; i++) { for (i = 0; i < new->info.array.raid_disks; i++) {
struct mdinfo *newd = xmalloc(sizeof(*newd)); struct mdinfo *newd = xmalloc(sizeof(*newd));
for (di = mdi->devs; di; di = di->next) for (di = mdi->devs; di; di = di->next)
if (i == di->disk.raid_disk) if (i == di->disk.raid_disk)
break; break;
skipping to change at line 727 skipping to change at line 727
} }
new->action_fd = sysfs_open2(new->info.sys_name, NULL, "sync_action"); new->action_fd = sysfs_open2(new->info.sys_name, NULL, "sync_action");
new->info.state_fd = sysfs_open2(new->info.sys_name, NULL, "array_state") ; new->info.state_fd = sysfs_open2(new->info.sys_name, NULL, "array_state") ;
new->resync_start_fd = sysfs_open2(new->info.sys_name, NULL, "resync_star t"); new->resync_start_fd = sysfs_open2(new->info.sys_name, NULL, "resync_star t");
new->metadata_fd = sysfs_open2(new->info.sys_name, NULL, "metadata_versio n"); new->metadata_fd = sysfs_open2(new->info.sys_name, NULL, "metadata_versio n");
new->sync_completed_fd = sysfs_open2(new->info.sys_name, NULL, "sync_comp leted"); new->sync_completed_fd = sysfs_open2(new->info.sys_name, NULL, "sync_comp leted");
new->safe_mode_delay_fd = sysfs_open2(new->info.sys_name, NULL, new->safe_mode_delay_fd = sysfs_open2(new->info.sys_name, NULL,
"safe_mode_delay"); "safe_mode_delay");
dprintf("inst: %s action: %d state: %d\n", inst, dprintf("inst: %d action: %d state: %d\n", inst,
new->action_fd, new->info.state_fd); new->action_fd, new->info.state_fd);
if (sigterm) if (mdi->safe_mode_delay >= 50)
new->info.safe_mode_delay = 1;
else if (mdi->safe_mode_delay >= 50)
/* Normal start, mdadm set this. */ /* Normal start, mdadm set this. */
new->info.safe_mode_delay = mdi->safe_mode_delay; new->info.safe_mode_delay = mdi->safe_mode_delay;
else else
/* Restart, just pick a number */ /* Restart, just pick a number */
new->info.safe_mode_delay = 5000; new->info.safe_mode_delay = 5000;
sysfs_set_safemode(&new->info, new->info.safe_mode_delay); sysfs_set_safemode(&new->info, new->info.safe_mode_delay);
/* reshape_position is set by mdadm in sysfs /* reshape_position is set by mdadm in sysfs
* read this information for new arrays only (empty victim) * read this information for new arrays only (empty victim)
*/ */
skipping to change at line 764 skipping to change at line 762
data_disks -= 2; data_disks -= 2;
new->last_checkpoint /= data_disks; new->last_checkpoint /= data_disks;
} }
dprintf("mdmon: New monitored array is under reshape.\n" dprintf("mdmon: New monitored array is under reshape.\n"
" Last checkpoint is: %llu\n", " Last checkpoint is: %llu\n",
new->last_checkpoint); new->last_checkpoint);
} }
sysfs_free(mdi); sysfs_free(mdi);
mdi = NULL;
/* if everything checks out tell the metadata handler we want to /* if everything checks out tell the metadata handler we want to
* manage this instance * manage this instance
*/ */
if (!aa_ready(new) || container->ss->open_new(container, new, inst) < 0) { if (!aa_ready(new) || container->ss->open_new(container, new, inst) < 0) {
pr_err("failed to monitor %s\n", goto error;
mdstat->metadata_version);
new->container = NULL;
free_aa(new);
} else { } else {
replace_array(container, victim, new); replace_array(container, victim, new);
if (failed) { if (failed) {
new->check_degraded = 1; new->check_degraded = 1;
manage_member(mdstat, new); manage_member(mdstat, new);
} }
} }
return;
error:
pr_err("failed to monitor %s\n", mdstat->metadata_version);
if (new) {
new->container = NULL;
free_aa(new);
}
if (mdi)
sysfs_free(mdi);
} }
void manage(struct mdstat_ent *mdstat, struct supertype *container) void manage(struct mdstat_ent *mdstat, struct supertype *container)
{ {
/* We have just read mdstat and need to compare it with /* We have just read mdstat and need to compare it with
* the known active arrays. * the known active arrays.
* Arrays with the wrong metadata are ignored. * Arrays with the wrong metadata are ignored.
*/ */
for ( ; mdstat ; mdstat = mdstat->next) { for ( ; mdstat ; mdstat = mdstat->next) {
skipping to change at line 806 skipping to change at line 812
/* Not for this array */ /* Not for this array */
continue; continue;
/* Looks like a member of this container */ /* Looks like a member of this container */
for (a = container->arrays; a; a = a->next) { for (a = container->arrays; a; a = a->next) {
if (strcmp(mdstat->devnm, a->info.sys_name) == 0) { if (strcmp(mdstat->devnm, a->info.sys_name) == 0) {
if (a->container && a->to_remove == 0) if (a->container && a->to_remove == 0)
manage_member(mdstat, a); manage_member(mdstat, a);
break; break;
} }
} }
if (a == NULL || !a->container) if ((a == NULL || !a->container) && !sigterm)
manage_new(mdstat, container, a); manage_new(mdstat, container, a);
} }
} }
static void handle_message(struct supertype *container, struct metadata_update * msg) static void handle_message(struct supertype *container, struct metadata_update * msg)
{ {
/* queue this metadata update through to the monitor */ /* queue this metadata update through to the monitor */
struct metadata_update *mu; struct metadata_update *mu;
 End of changes. 10 change blocks. 
17 lines changed or deleted 23 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)