pr_err for mdmon.
Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
e12b3daab7
commit
a88e119f6f
|
@ -713,7 +713,7 @@ static void manage_new(struct mdstat_ent *mdstat,
|
||||||
* 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) {
|
||||||
fprintf(stderr, "mdmon: failed to monitor %s\n",
|
pr_err("failed to monitor %s\n",
|
||||||
mdstat->metadata_version);
|
mdstat->metadata_version);
|
||||||
new->container = NULL;
|
new->container = NULL;
|
||||||
free_aa(new);
|
free_aa(new);
|
||||||
|
|
33
mdmon.c
33
mdmon.c
|
@ -374,7 +374,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!devnm) {
|
if (!devnm) {
|
||||||
fprintf(stderr, "mdmon: %s is not a valid md device name\n",
|
pr_err("%s is not a valid md device name\n",
|
||||||
container_name);
|
container_name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -398,26 +398,23 @@ static int mdmon(char *devnm, int must_fork, int takeover)
|
||||||
|
|
||||||
mdfd = open_dev(devnm);
|
mdfd = open_dev(devnm);
|
||||||
if (mdfd < 0) {
|
if (mdfd < 0) {
|
||||||
fprintf(stderr, "mdmon: %s: %s\n", devnm,
|
pr_err("%s: %s\n", devnm, strerror(errno));
|
||||||
strerror(errno));
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (md_get_version(mdfd) < 0) {
|
if (md_get_version(mdfd) < 0) {
|
||||||
fprintf(stderr, "mdmon: %s: Not an md device\n",
|
pr_err("%s: Not an md device\n", devnm);
|
||||||
devnm);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fork, and have the child tell us when they are ready */
|
/* Fork, and have the child tell us when they are ready */
|
||||||
if (must_fork) {
|
if (must_fork) {
|
||||||
if (pipe(pfd) != 0) {
|
if (pipe(pfd) != 0) {
|
||||||
fprintf(stderr, "mdmon: failed to create pipe\n");
|
pr_err("failed to create pipe\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
switch(fork()) {
|
switch(fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
fprintf(stderr, "mdmon: failed to fork: %s\n",
|
pr_err("failed to fork: %s\n", strerror(errno));
|
||||||
strerror(errno));
|
|
||||||
return 1;
|
return 1;
|
||||||
case 0: /* child */
|
case 0: /* child */
|
||||||
close(pfd[0]);
|
close(pfd[0]);
|
||||||
|
@ -441,25 +438,23 @@ static int mdmon(char *devnm, int must_fork, int takeover)
|
||||||
mdi = sysfs_read(mdfd, container->devnm, GET_VERSION|GET_LEVEL|GET_DEVS);
|
mdi = sysfs_read(mdfd, container->devnm, GET_VERSION|GET_LEVEL|GET_DEVS);
|
||||||
|
|
||||||
if (!mdi) {
|
if (!mdi) {
|
||||||
fprintf(stderr, "mdmon: failed to load sysfs info for %s\n",
|
pr_err("failed to load sysfs info for %s\n", container->devnm);
|
||||||
container->devnm);
|
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
if (mdi->array.level != UnSet) {
|
if (mdi->array.level != UnSet) {
|
||||||
fprintf(stderr, "mdmon: %s is not a container - cannot monitor\n",
|
pr_err("%s is not a container - cannot monitor\n", devnm);
|
||||||
devnm);
|
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
if (mdi->array.major_version != -1 ||
|
if (mdi->array.major_version != -1 ||
|
||||||
mdi->array.minor_version != -2) {
|
mdi->array.minor_version != -2) {
|
||||||
fprintf(stderr, "mdmon: %s does not use external metadata - cannot monitor\n",
|
pr_err("%s does not use external metadata - cannot monitor\n",
|
||||||
devnm);
|
devnm);
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
container->ss = version_to_superswitch(mdi->text_version);
|
container->ss = version_to_superswitch(mdi->text_version);
|
||||||
if (container->ss == NULL) {
|
if (container->ss == NULL) {
|
||||||
fprintf(stderr, "mdmon: %s uses unsupported metadata: %s\n",
|
pr_err("%s uses unsupported metadata: %s\n",
|
||||||
devnm, mdi->text_version);
|
devnm, mdi->text_version);
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
@ -495,16 +490,14 @@ static int mdmon(char *devnm, int must_fork, int takeover)
|
||||||
ignore = chdir("/");
|
ignore = chdir("/");
|
||||||
if (!takeover && victim > 0 && victim_sock >= 0) {
|
if (!takeover && victim > 0 && victim_sock >= 0) {
|
||||||
if (fping_monitor(victim_sock) == 0) {
|
if (fping_monitor(victim_sock) == 0) {
|
||||||
fprintf(stderr, "mdmon: %s already managed\n",
|
pr_err("%s already managed\n", container->devnm);
|
||||||
container->devnm);
|
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
close(victim_sock);
|
close(victim_sock);
|
||||||
victim_sock = -1;
|
victim_sock = -1;
|
||||||
}
|
}
|
||||||
if (container->ss->load_container(container, mdfd, devnm)) {
|
if (container->ss->load_container(container, mdfd, devnm)) {
|
||||||
fprintf(stderr, "mdmon: Cannot load metadata for %s\n",
|
pr_err("Cannot load metadata for %s\n", devnm);
|
||||||
devnm);
|
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
close(mdfd);
|
close(mdfd);
|
||||||
|
@ -520,14 +513,14 @@ static int mdmon(char *devnm, int must_fork, int takeover)
|
||||||
|
|
||||||
status = 0;
|
status = 0;
|
||||||
if (write(pfd[1], &status, sizeof(status)) < 0)
|
if (write(pfd[1], &status, sizeof(status)) < 0)
|
||||||
fprintf(stderr, "mdmon: failed to notify our parent: %d\n",
|
pr_err("failed to notify our parent: %d\n",
|
||||||
getppid());
|
getppid());
|
||||||
close(pfd[1]);
|
close(pfd[1]);
|
||||||
|
|
||||||
mlockall(MCL_CURRENT | MCL_FUTURE);
|
mlockall(MCL_CURRENT | MCL_FUTURE);
|
||||||
|
|
||||||
if (clone_monitor(container) < 0) {
|
if (clone_monitor(container) < 0) {
|
||||||
fprintf(stderr, "mdmon: failed to start monitor process: %s\n",
|
pr_err("failed to start monitor process: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
3
mdmon.h
3
mdmon.h
|
@ -18,6 +18,9 @@
|
||||||
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#undef pr_err
|
||||||
|
#define pr_err(fmt ...) fprintf(stderr, "mdmon: " fmt)
|
||||||
|
|
||||||
enum array_state { clear, inactive, suspended, readonly, read_auto,
|
enum array_state { clear, inactive, suspended, readonly, read_auto,
|
||||||
clean, active, write_pending, active_idle, bad_word};
|
clean, active, write_pending, active_idle, bad_word};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue