|
|
2c1b57 |
From f566ef45d356f6dcd4ec54d294be8664770d8b84 Mon Sep 17 00:00:00 2001
|
|
|
2c1b57 |
From: Jes Sorensen <jsorensen@fb.com>
|
|
|
2c1b57 |
Date: Thu, 11 May 2017 16:56:55 -0400
|
|
|
2c1b57 |
Subject: [RHEL7.5 PATCH 139/169] Monitor: Fixup a pile of whitespace
|
|
|
2c1b57 |
issues
|
|
|
2c1b57 |
|
|
|
2c1b57 |
No code was hurt in this event
|
|
|
2c1b57 |
|
|
|
2c1b57 |
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
|
|
|
2c1b57 |
---
|
|
|
2c1b57 |
Monitor.c | 110 +++++++++++++++++++++++++++++++-------------------------------
|
|
|
2c1b57 |
1 file changed, 55 insertions(+), 55 deletions(-)
|
|
|
2c1b57 |
|
|
|
2c1b57 |
diff --git a/Monitor.c b/Monitor.c
|
|
|
2c1b57 |
index 83a6d10..0198a34 100644
|
|
|
2c1b57 |
--- a/Monitor.c
|
|
|
2c1b57 |
+++ b/Monitor.c
|
|
|
2c1b57 |
@@ -139,7 +139,7 @@ int Monitor(struct mddev_dev *devlist,
|
|
|
2c1b57 |
|
|
|
2c1b57 |
if (!alert_cmd) {
|
|
|
2c1b57 |
alert_cmd = conf_get_program();
|
|
|
2c1b57 |
- if (alert_cmd && ! c->scan)
|
|
|
2c1b57 |
+ if (alert_cmd && !c->scan)
|
|
|
2c1b57 |
pr_err("Monitor using program \"%s\" from config file\n",
|
|
|
2c1b57 |
alert_cmd);
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
@@ -164,8 +164,9 @@ int Monitor(struct mddev_dev *devlist,
|
|
|
2c1b57 |
|
|
|
2c1b57 |
if (devlist == NULL) {
|
|
|
2c1b57 |
mdlist = conf_get_ident(NULL);
|
|
|
2c1b57 |
- for (; mdlist; mdlist=mdlist->next) {
|
|
|
2c1b57 |
+ for (; mdlist; mdlist = mdlist->next) {
|
|
|
2c1b57 |
struct state *st;
|
|
|
2c1b57 |
+
|
|
|
2c1b57 |
if (mdlist->devname == NULL)
|
|
|
2c1b57 |
continue;
|
|
|
2c1b57 |
if (strcasecmp(mdlist->devname, "<ignore>") == 0)
|
|
|
2c1b57 |
@@ -189,7 +190,8 @@ int Monitor(struct mddev_dev *devlist,
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
} else {
|
|
|
2c1b57 |
struct mddev_dev *dv;
|
|
|
2c1b57 |
- for (dv=devlist ; dv; dv=dv->next) {
|
|
|
2c1b57 |
+
|
|
|
2c1b57 |
+ for (dv = devlist; dv; dv = dv->next) {
|
|
|
2c1b57 |
struct state *st = xcalloc(1, sizeof *st);
|
|
|
2c1b57 |
mdlist = conf_get_ident(dv->devname);
|
|
|
2c1b57 |
st->devname = xstrdup(dv->devname);
|
|
|
2c1b57 |
@@ -206,18 +208,18 @@ int Monitor(struct mddev_dev *devlist,
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
|
|
|
2c1b57 |
- while (! finished) {
|
|
|
2c1b57 |
+ while (!finished) {
|
|
|
2c1b57 |
int new_found = 0;
|
|
|
2c1b57 |
struct state *st, **stp;
|
|
|
2c1b57 |
int anydegraded = 0;
|
|
|
2c1b57 |
|
|
|
2c1b57 |
if (mdstat)
|
|
|
2c1b57 |
free_mdstat(mdstat);
|
|
|
2c1b57 |
- mdstat = mdstat_read(oneshot?0:1, 0);
|
|
|
2c1b57 |
+ mdstat = mdstat_read(oneshot ? 0 : 1, 0);
|
|
|
2c1b57 |
if (!mdstat)
|
|
|
2c1b57 |
mdstat_close();
|
|
|
2c1b57 |
|
|
|
2c1b57 |
- for (st=statelist; st; st=st->next)
|
|
|
2c1b57 |
+ for (st = statelist; st; st = st->next)
|
|
|
2c1b57 |
if (check_array(st, mdstat, c->test, &info,
|
|
|
2c1b57 |
increments, c->prefer))
|
|
|
2c1b57 |
anydegraded = 1;
|
|
|
2c1b57 |
@@ -291,8 +293,8 @@ static int make_daemon(char *pidfile)
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
close(0);
|
|
|
2c1b57 |
open("/dev/null", O_RDWR);
|
|
|
2c1b57 |
- dup2(0,1);
|
|
|
2c1b57 |
- dup2(0,2);
|
|
|
2c1b57 |
+ dup2(0, 1);
|
|
|
2c1b57 |
+ dup2(0, 2);
|
|
|
2c1b57 |
setsid();
|
|
|
2c1b57 |
return -1;
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
@@ -323,8 +325,7 @@ static int check_one_sharer(int scan)
|
|
|
2c1b57 |
fclose(fp);
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
if (scan) {
|
|
|
2c1b57 |
- if (mkdir(MDMON_DIR, S_IRWXU) < 0 &&
|
|
|
2c1b57 |
- errno != EEXIST) {
|
|
|
2c1b57 |
+ if (mkdir(MDMON_DIR, S_IRWXU) < 0 && errno != EEXIST) {
|
|
|
2c1b57 |
pr_err("Can't create autorebuild.pid file\n");
|
|
|
2c1b57 |
} else {
|
|
|
2c1b57 |
fp = fopen(path, "w");
|
|
|
2c1b57 |
@@ -347,7 +348,8 @@ static void alert(char *event, char *dev, char *disc, struct alert_info *info)
|
|
|
2c1b57 |
if (!info->alert_cmd && !info->mailaddr && !info->dosyslog) {
|
|
|
2c1b57 |
time_t now = time(0);
|
|
|
2c1b57 |
|
|
|
2c1b57 |
- printf("%1.15s: %s on %s %s\n", ctime(&now)+4, event, dev, disc?disc:"unknown device");
|
|
|
2c1b57 |
+ printf("%1.15s: %s on %s %s\n", ctime(&now) + 4,
|
|
|
2c1b57 |
+ event, dev, disc?disc:"unknown device");
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
if (info->alert_cmd) {
|
|
|
2c1b57 |
int pid = fork();
|
|
|
2c1b57 |
@@ -363,11 +365,10 @@ static void alert(char *event, char *dev, char *disc, struct alert_info *info)
|
|
|
2c1b57 |
exit(2);
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
- if (info->mailaddr &&
|
|
|
2c1b57 |
- (strncmp(event, "Fail", 4)==0 ||
|
|
|
2c1b57 |
- strncmp(event, "Test", 4)==0 ||
|
|
|
2c1b57 |
- strncmp(event, "Spares", 6)==0 ||
|
|
|
2c1b57 |
- strncmp(event, "Degrade", 7)==0)) {
|
|
|
2c1b57 |
+ if (info->mailaddr && (strncmp(event, "Fail", 4) == 0 ||
|
|
|
2c1b57 |
+ strncmp(event, "Test", 4) == 0 ||
|
|
|
2c1b57 |
+ strncmp(event, "Spares", 6) == 0 ||
|
|
|
2c1b57 |
+ strncmp(event, "Degrade", 7) == 0)) {
|
|
|
2c1b57 |
FILE *mp = popen(Sendmail, "w");
|
|
|
2c1b57 |
if (mp) {
|
|
|
2c1b57 |
FILE *mdstat;
|
|
|
2c1b57 |
@@ -377,7 +378,8 @@ static void alert(char *event, char *dev, char *disc, struct alert_info *info)
|
|
|
2c1b57 |
if (info->mailfrom)
|
|
|
2c1b57 |
fprintf(mp, "From: %s\n", info->mailfrom);
|
|
|
2c1b57 |
else
|
|
|
2c1b57 |
- fprintf(mp, "From: %s monitoring <root>\n", Name);
|
|
|
2c1b57 |
+ fprintf(mp, "From: %s monitoring <root>\n",
|
|
|
2c1b57 |
+ Name);
|
|
|
2c1b57 |
fprintf(mp, "To: %s\n", info->mailaddr);
|
|
|
2c1b57 |
fprintf(mp, "Subject: %s event on %s:%s\n\n",
|
|
|
2c1b57 |
event, dev, hname);
|
|
|
2c1b57 |
@@ -403,8 +405,9 @@ static void alert(char *event, char *dev, char *disc, struct alert_info *info)
|
|
|
2c1b57 |
int n;
|
|
|
2c1b57 |
fprintf(mp,
|
|
|
2c1b57 |
"\nP.S. The /proc/mdstat file currently contains the following:\n\n");
|
|
|
2c1b57 |
- while ( (n=fread(buf, 1, sizeof(buf), mdstat)) > 0)
|
|
|
2c1b57 |
- n=fwrite(buf, 1, n, mp);
|
|
|
2c1b57 |
+ while ((n = fread(buf, 1, sizeof(buf),
|
|
|
2c1b57 |
+ mdstat)) > 0)
|
|
|
2c1b57 |
+ n = fwrite(buf, 1, n, mp);
|
|
|
2c1b57 |
fclose(mdstat);
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
pclose(mp);
|
|
|
2c1b57 |
@@ -416,13 +419,13 @@ static void alert(char *event, char *dev, char *disc, struct alert_info *info)
|
|
|
2c1b57 |
/* Log at a different severity depending on the event.
|
|
|
2c1b57 |
*
|
|
|
2c1b57 |
* These are the critical events: */
|
|
|
2c1b57 |
- if (strncmp(event, "Fail", 4)==0 ||
|
|
|
2c1b57 |
- strncmp(event, "Degrade", 7)==0 ||
|
|
|
2c1b57 |
- strncmp(event, "DeviceDisappeared", 17)==0)
|
|
|
2c1b57 |
+ if (strncmp(event, "Fail", 4) == 0 ||
|
|
|
2c1b57 |
+ strncmp(event, "Degrade", 7) == 0 ||
|
|
|
2c1b57 |
+ strncmp(event, "DeviceDisappeared", 17) == 0)
|
|
|
2c1b57 |
priority = LOG_CRIT;
|
|
|
2c1b57 |
/* Good to know about, but are not failures: */
|
|
|
2c1b57 |
- else if (strncmp(event, "Rebuild", 7)==0 ||
|
|
|
2c1b57 |
- strncmp(event, "MoveSpare", 9)==0 ||
|
|
|
2c1b57 |
+ else if (strncmp(event, "Rebuild", 7) == 0 ||
|
|
|
2c1b57 |
+ strncmp(event, "MoveSpare", 9) == 0 ||
|
|
|
2c1b57 |
strncmp(event, "Spares", 6) != 0)
|
|
|
2c1b57 |
priority = LOG_WARNING;
|
|
|
2c1b57 |
/* Everything else: */
|
|
|
2c1b57 |
@@ -497,7 +500,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
|
|
|
2c1b57 |
goto out;
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
|
|
|
2c1b57 |
- for (mse2 = mdstat ; mse2 ; mse2=mse2->next)
|
|
|
2c1b57 |
+ for (mse2 = mdstat; mse2; mse2 = mse2->next)
|
|
|
2c1b57 |
if (strcmp(mse2->devnm, st->devnm) == 0) {
|
|
|
2c1b57 |
mse2->devnm[0] = 0; /* flag it as "used" */
|
|
|
2c1b57 |
mse = mse2;
|
|
|
2c1b57 |
@@ -568,7 +571,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
|
|
|
2c1b57 |
char cnt[80];
|
|
|
2c1b57 |
snprintf(cnt, sizeof(cnt),
|
|
|
2c1b57 |
" mismatches found: %d (on raid level %d)",
|
|
|
2c1b57 |
- sra->mismatch_cnt, sra->array.level);
|
|
|
2c1b57 |
+ sra->mismatch_cnt, sra->array.level);
|
|
|
2c1b57 |
alert("RebuildFinished", dev, cnt, ainfo);
|
|
|
2c1b57 |
} else
|
|
|
2c1b57 |
alert("RebuildFinished", dev, NULL, ainfo);
|
|
|
2c1b57 |
@@ -594,7 +597,7 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
|
|
|
2c1b57 |
strncmp(mse->metadata_version, "external:", 9) == 0 &&
|
|
|
2c1b57 |
is_subarray(mse->metadata_version+9)) {
|
|
|
2c1b57 |
char *sl;
|
|
|
2c1b57 |
- strcpy(st->parent_devnm, mse->metadata_version+10);
|
|
|
2c1b57 |
+ strcpy(st->parent_devnm, mse->metadata_version + 10);
|
|
|
2c1b57 |
sl = strchr(st->parent_devnm, '/');
|
|
|
2c1b57 |
if (sl)
|
|
|
2c1b57 |
*sl = 0;
|
|
|
2c1b57 |
@@ -603,9 +606,9 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat,
|
|
|
2c1b57 |
if (st->metadata == NULL && st->parent_devnm[0] == 0)
|
|
|
2c1b57 |
st->metadata = super_by_fd(fd, NULL);
|
|
|
2c1b57 |
|
|
|
2c1b57 |
- for (i=0; i
|
|
|
2c1b57 |
- mdu_disk_info_t disc = {0,0,0,0,0};
|
|
|
2c1b57 |
- int newstate=0;
|
|
|
2c1b57 |
+ for (i = 0; i < MAX_DISKS; i++) {
|
|
|
2c1b57 |
+ mdu_disk_info_t disc = {0, 0, 0, 0, 0};
|
|
|
2c1b57 |
+ int newstate = 0;
|
|
|
2c1b57 |
int change;
|
|
|
2c1b57 |
char *dv = NULL;
|
|
|
2c1b57 |
disc.number = i;
|
|
|
2c1b57 |
@@ -668,12 +671,10 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
|
|
|
2c1b57 |
int new_found = 0;
|
|
|
2c1b57 |
char *name;
|
|
|
2c1b57 |
|
|
|
2c1b57 |
- for (mse=mdstat; mse; mse=mse->next)
|
|
|
2c1b57 |
- if (mse->devnm[0] &&
|
|
|
2c1b57 |
- (!mse->level || /* retrieve containers */
|
|
|
2c1b57 |
- (strcmp(mse->level, "raid0") != 0 &&
|
|
|
2c1b57 |
- strcmp(mse->level, "linear") != 0))
|
|
|
2c1b57 |
- ) {
|
|
|
2c1b57 |
+ for (mse = mdstat; mse; mse = mse->next)
|
|
|
2c1b57 |
+ if (mse->devnm[0] && (!mse->level || /* retrieve containers */
|
|
|
2c1b57 |
+ (strcmp(mse->level, "raid0") != 0 &&
|
|
|
2c1b57 |
+ strcmp(mse->level, "linear") != 0))) {
|
|
|
2c1b57 |
struct state *st = xcalloc(1, sizeof *st);
|
|
|
2c1b57 |
mdu_array_info_t array;
|
|
|
2c1b57 |
int fd;
|
|
|
2c1b57 |
@@ -707,7 +708,8 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
|
|
|
2c1b57 |
st->percent = RESYNC_UNKNOWN;
|
|
|
2c1b57 |
st->expected_spares = -1;
|
|
|
2c1b57 |
if (mse->metadata_version &&
|
|
|
2c1b57 |
- strncmp(mse->metadata_version, "external:", 9) == 0 &&
|
|
|
2c1b57 |
+ strncmp(mse->metadata_version,
|
|
|
2c1b57 |
+ "external:", 9) == 0 &&
|
|
|
2c1b57 |
is_subarray(mse->metadata_version+9)) {
|
|
|
2c1b57 |
char *sl;
|
|
|
2c1b57 |
strcpy(st->parent_devnm,
|
|
|
2c1b57 |
@@ -729,8 +731,7 @@ static int get_required_spare_criteria(struct state *st,
|
|
|
2c1b57 |
{
|
|
|
2c1b57 |
int fd;
|
|
|
2c1b57 |
|
|
|
2c1b57 |
- if (!st->metadata ||
|
|
|
2c1b57 |
- !st->metadata->ss->get_spare_criteria) {
|
|
|
2c1b57 |
+ if (!st->metadata || !st->metadata->ss->get_spare_criteria) {
|
|
|
2c1b57 |
sc->min_size = 0;
|
|
|
2c1b57 |
sc->sector_size = 0;
|
|
|
2c1b57 |
return 0;
|
|
|
2c1b57 |
@@ -779,14 +780,13 @@ static int check_donor(struct state *from, struct state *to)
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
|
|
|
2c1b57 |
static dev_t choose_spare(struct state *from, struct state *to,
|
|
|
2c1b57 |
- struct domainlist *domlist, struct spare_criteria *sc)
|
|
|
2c1b57 |
+ struct domainlist *domlist, struct spare_criteria *sc)
|
|
|
2c1b57 |
{
|
|
|
2c1b57 |
int d;
|
|
|
2c1b57 |
dev_t dev = 0;
|
|
|
2c1b57 |
|
|
|
2c1b57 |
for (d = from->raid; !dev && d < MAX_DISKS; d++) {
|
|
|
2c1b57 |
- if (from->devid[d] > 0 &&
|
|
|
2c1b57 |
- from->devstate[d] == 0) {
|
|
|
2c1b57 |
+ if (from->devid[d] > 0 && from->devstate[d] == 0) {
|
|
|
2c1b57 |
struct dev_policy *pol;
|
|
|
2c1b57 |
unsigned long long dev_size;
|
|
|
2c1b57 |
unsigned int dev_sector_size;
|
|
|
2c1b57 |
@@ -810,7 +810,8 @@ static dev_t choose_spare(struct state *from, struct state *to,
|
|
|
2c1b57 |
if (from->spare_group)
|
|
|
2c1b57 |
pol_add(&pol, pol_domain,
|
|
|
2c1b57 |
from->spare_group, NULL);
|
|
|
2c1b57 |
- if (domain_test(domlist, pol, to->metadata->ss->name) == 1)
|
|
|
2c1b57 |
+ if (domain_test(domlist, pol,
|
|
|
2c1b57 |
+ to->metadata->ss->name) == 1)
|
|
|
2c1b57 |
dev = from->devid[d];
|
|
|
2c1b57 |
dev_policy_free(pol);
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
@@ -857,8 +858,8 @@ static dev_t container_choose_spare(struct state *from, struct state *to,
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
dp = list->devs;
|
|
|
2c1b57 |
while (dp) {
|
|
|
2c1b57 |
- if (dp->disk.state & (1<
|
|
|
2c1b57 |
- !(dp->disk.state & (1<
|
|
|
2c1b57 |
+ if (dp->disk.state & (1 << MD_DISK_SYNC) &&
|
|
|
2c1b57 |
+ !(dp->disk.state & (1 << MD_DISK_FAULTY)))
|
|
|
2c1b57 |
active_cnt++;
|
|
|
2c1b57 |
dp = dp->next;
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
@@ -891,8 +892,7 @@ static void try_spare_migration(struct state *statelist, struct alert_info *info
|
|
|
2c1b57 |
|
|
|
2c1b57 |
link_containers_with_subarrays(statelist);
|
|
|
2c1b57 |
for (st = statelist; st; st = st->next)
|
|
|
2c1b57 |
- if (st->active < st->raid &&
|
|
|
2c1b57 |
- st->spare == 0 && !st->err) {
|
|
|
2c1b57 |
+ if (st->active < st->raid && st->spare == 0 && !st->err) {
|
|
|
2c1b57 |
struct domainlist *domlist = NULL;
|
|
|
2c1b57 |
int d;
|
|
|
2c1b57 |
struct state *to = st;
|
|
|
2c1b57 |
@@ -940,9 +940,11 @@ static void try_spare_migration(struct state *statelist, struct alert_info *info
|
|
|
2c1b57 |
else
|
|
|
2c1b57 |
devid = choose_spare(from, to, domlist,
|
|
|
2c1b57 |
&sc);
|
|
|
2c1b57 |
- if (devid > 0
|
|
|
2c1b57 |
- && move_spare(from->devname, to->devname, devid)) {
|
|
|
2c1b57 |
- alert("MoveSpare", to->devname, from->devname, info);
|
|
|
2c1b57 |
+ if (devid > 0 &&
|
|
|
2c1b57 |
+ move_spare(from->devname, to->devname,
|
|
|
2c1b57 |
+ devid)) {
|
|
|
2c1b57 |
+ alert("MoveSpare", to->devname,
|
|
|
2c1b57 |
+ from->devname, info);
|
|
|
2c1b57 |
break;
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
}
|
|
|
2c1b57 |
@@ -967,8 +969,7 @@ static void link_containers_with_subarrays(struct state *list)
|
|
|
2c1b57 |
for (st = list; st; st = st->next)
|
|
|
2c1b57 |
if (st->parent_devnm[0])
|
|
|
2c1b57 |
for (cont = list; cont; cont = cont->next)
|
|
|
2c1b57 |
- if (!cont->err &&
|
|
|
2c1b57 |
- cont->parent_devnm[0] == 0 &&
|
|
|
2c1b57 |
+ if (!cont->err && cont->parent_devnm[0] == 0 &&
|
|
|
2c1b57 |
strcmp(cont->devnm, st->parent_devnm) == 0) {
|
|
|
2c1b57 |
st->parent = cont;
|
|
|
2c1b57 |
st->subarray = cont->subarray;
|
|
|
2c1b57 |
@@ -992,7 +993,7 @@ int Wait(char *dev)
|
|
|
2c1b57 |
struct mdstat_ent *ms = mdstat_read(1, 0);
|
|
|
2c1b57 |
struct mdstat_ent *e;
|
|
|
2c1b57 |
|
|
|
2c1b57 |
- for (e=ms ; e; e=e->next)
|
|
|
2c1b57 |
+ for (e = ms; e; e = e->next)
|
|
|
2c1b57 |
if (strcmp(e->devnm, devnm) == 0)
|
|
|
2c1b57 |
break;
|
|
|
2c1b57 |
|
|
|
2c1b57 |
@@ -1115,8 +1116,7 @@ int WaitClean(char *dev, int sock, int verbose)
|
|
|
2c1b57 |
} else
|
|
|
2c1b57 |
rv = 1;
|
|
|
2c1b57 |
if (rv && verbose)
|
|
|
2c1b57 |
- pr_err("Error waiting for %s to be clean\n",
|
|
|
2c1b57 |
- dev);
|
|
|
2c1b57 |
+ pr_err("Error waiting for %s to be clean\n", dev);
|
|
|
2c1b57 |
|
|
|
2c1b57 |
/* restore the original safe_mode_delay */
|
|
|
2c1b57 |
sysfs_set_safemode(mdi, mdi->safe_mode_delay);
|
|
|
2c1b57 |
--
|
|
|
2c1b57 |
2.7.4
|
|
|
2c1b57 |
|