Remove --offroot argument and default to always setting argv[0] to @
We still allow --offroot to be given - for compatibility with scripts - but ignore it. The whole point of --offroot is to get systemd to not auto-kill mdmon, and we always want that. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
e31dec228b
commit
3e23ba9d7b
4
ReadMe.c
4
ReadMe.c
|
@ -259,10 +259,6 @@ char OptionHelp[] =
|
||||||
" --query -Q : Display general information about how a\n"
|
" --query -Q : Display general information about how a\n"
|
||||||
" device relates to the md driver\n"
|
" device relates to the md driver\n"
|
||||||
" --auto-detect : Start arrays auto-detected by the kernel\n"
|
" --auto-detect : Start arrays auto-detected by the kernel\n"
|
||||||
" --offroot : Set first character of argv[0] to @ to indicate the\n"
|
|
||||||
" application was launched from initrd/initramfs and\n"
|
|
||||||
" should not be shutdown by systemd as part of the\n"
|
|
||||||
" regular shutdown process.\n"
|
|
||||||
;
|
;
|
||||||
/*
|
/*
|
||||||
"\n"
|
"\n"
|
||||||
|
|
11
mdadm.8.in
11
mdadm.8.in
|
@ -255,17 +255,6 @@ Avoid printing purely informative messages. With this,
|
||||||
.I mdadm
|
.I mdadm
|
||||||
will be silent unless there is something really important to report.
|
will be silent unless there is something really important to report.
|
||||||
|
|
||||||
.TP
|
|
||||||
.BR \-\-offroot
|
|
||||||
Set first character of argv[0] to @ to indicate mdadm was launched
|
|
||||||
from initrd/initramfs and should not be shutdown by systemd as part of
|
|
||||||
the regular shutdown process. This option is normally only used by
|
|
||||||
the system's initscripts. Please see here for more details on how
|
|
||||||
systemd handled argv[0]:
|
|
||||||
.IP
|
|
||||||
.B http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons
|
|
||||||
.PP
|
|
||||||
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BR \-f ", " \-\-force
|
.BR \-f ", " \-\-force
|
||||||
|
|
15
mdadm.c
15
mdadm.c
|
@ -116,6 +116,13 @@ int main(int argc, char *argv[])
|
||||||
ident.container = NULL;
|
ident.container = NULL;
|
||||||
ident.member = NULL;
|
ident.member = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* set first char of argv[0] to @. This is used by
|
||||||
|
* systemd to signal that the task was launched from
|
||||||
|
* initrd/initramfs and should be preserved during shutdown
|
||||||
|
*/
|
||||||
|
argv[0][0] = '@';
|
||||||
|
|
||||||
while ((option_index = -1) ,
|
while ((option_index = -1) ,
|
||||||
(opt=getopt_long(argc, argv,
|
(opt=getopt_long(argc, argv,
|
||||||
shortopt, long_options,
|
shortopt, long_options,
|
||||||
|
@ -159,14 +166,8 @@ int main(int argc, char *argv[])
|
||||||
c.homehost = optarg;
|
c.homehost = optarg;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
|
||||||
* --offroot sets first char of argv[0] to @. This is used
|
|
||||||
* by systemd to signal that the task was launched from
|
|
||||||
* initrd/initramfs and should be preserved during shutdown
|
|
||||||
*/
|
|
||||||
case OffRootOpt:
|
case OffRootOpt:
|
||||||
argv[0][0] = '@';
|
/* Silently ignore old option */
|
||||||
__offroot = 1;
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case Prefer:
|
case Prefer:
|
||||||
|
|
2
mdadm.h
2
mdadm.h
|
@ -1487,5 +1487,3 @@ char *xstrdup(const char *str);
|
||||||
#define INVALID_SECTORS 1
|
#define INVALID_SECTORS 1
|
||||||
/* And another special number needed for --data_offset=variable */
|
/* And another special number needed for --data_offset=variable */
|
||||||
#define VARIABLE_OFFSET 3
|
#define VARIABLE_OFFSET 3
|
||||||
|
|
||||||
extern int __offroot;
|
|
||||||
|
|
11
mdmon.8
11
mdmon.8
|
@ -5,7 +5,7 @@ mdmon \- monitor MD external metadata arrays
|
||||||
|
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
|
||||||
.BI mdmon " [--all] [--takeover] [--offroot] CONTAINER"
|
.BI mdmon " [--all] [--takeover] CONTAINER"
|
||||||
|
|
||||||
.SH OVERVIEW
|
.SH OVERVIEW
|
||||||
The 2.6.27 kernel brings the ability to support external metadata arrays.
|
The 2.6.27 kernel brings the ability to support external metadata arrays.
|
||||||
|
@ -166,15 +166,6 @@ containers with names longer than 5 characters, this argument can be
|
||||||
arbitrarily extended, e.g. to
|
arbitrarily extended, e.g. to
|
||||||
.BR \-\-all-active-arrays .
|
.BR \-\-all-active-arrays .
|
||||||
.TP
|
.TP
|
||||||
.BR \-\-offroot
|
|
||||||
Set first character of argv[0] to @ to indicate mdmon was launched
|
|
||||||
from initrd/initramfs and should not be shutdown by systemd as part of
|
|
||||||
the regular shutdown process. This option is normally only used by
|
|
||||||
the system's initscripts. Please see here for more details on how
|
|
||||||
systemd handled argv[0]:
|
|
||||||
.IP
|
|
||||||
.B http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons
|
|
||||||
.PP
|
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
Note that
|
Note that
|
||||||
|
|
14
mdmon.c
14
mdmon.c
|
@ -184,9 +184,6 @@ static void try_kill_monitor(pid_t pid, char *devname, int sock)
|
||||||
buf[sizeof(buf)-1] = 0;
|
buf[sizeof(buf)-1] = 0;
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
/* Note that if started with --offroot, the name
|
|
||||||
* might be "@dmon"
|
|
||||||
*/
|
|
||||||
if (n < 0 || !(strstr(buf, "mdmon") ||
|
if (n < 0 || !(strstr(buf, "mdmon") ||
|
||||||
strstr(buf, "@dmon")))
|
strstr(buf, "@dmon")))
|
||||||
return;
|
return;
|
||||||
|
@ -276,10 +273,6 @@ void usage(void)
|
||||||
" --help -h : This message\n"
|
" --help -h : This message\n"
|
||||||
" --all : All devices\n"
|
" --all : All devices\n"
|
||||||
" --takeover -t : Takeover container\n"
|
" --takeover -t : Takeover container\n"
|
||||||
" --offroot : Set first character of argv[0] to @ to indicate the\n"
|
|
||||||
" application was launched from initrd/initramfs and\n"
|
|
||||||
" should not be shutdown by systemd as part of the\n"
|
|
||||||
" regular shutdown process.\n"
|
|
||||||
);
|
);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
@ -303,6 +296,11 @@ int main(int argc, char *argv[])
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Always change process name to @dmon to avoid systemd killing it
|
||||||
|
*/
|
||||||
|
argv[0][0] = '@';
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv, "tha", options, NULL)) != -1) {
|
while ((opt = getopt_long(argc, argv, "tha", options, NULL)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'a':
|
case 'a':
|
||||||
|
@ -313,7 +311,7 @@ int main(int argc, char *argv[])
|
||||||
takeover = 1;
|
takeover = 1;
|
||||||
break;
|
break;
|
||||||
case OffRootOpt:
|
case OffRootOpt:
|
||||||
argv[0][0] = '@';
|
/* silently ignore old option */
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
default:
|
default:
|
||||||
|
|
13
util.c
13
util.c
|
@ -32,8 +32,6 @@
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
int __offroot;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* following taken from linux/blkpg.h because they aren't
|
* following taken from linux/blkpg.h because they aren't
|
||||||
* anywhere else and it isn't safe to #include linux/ * stuff.
|
* anywhere else and it isn't safe to #include linux/ * stuff.
|
||||||
|
@ -1674,15 +1672,8 @@ int start_mdmon(int devnum)
|
||||||
|
|
||||||
for (i = 0; paths[i]; i++)
|
for (i = 0; paths[i]; i++)
|
||||||
if (paths[i][0]) {
|
if (paths[i][0]) {
|
||||||
if (__offroot) {
|
execl(paths[i], "mdmon",
|
||||||
execl(paths[i], "mdmon", "--offroot",
|
devnum2devname(devnum), NULL);
|
||||||
devnum2devname(devnum),
|
|
||||||
NULL);
|
|
||||||
} else {
|
|
||||||
execl(paths[i], "mdmon",
|
|
||||||
devnum2devname(devnum),
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
exit(1);
|
exit(1);
|
||||||
case -1: pr_err("cannot run mdmon. "
|
case -1: pr_err("cannot run mdmon. "
|
||||||
|
|
Loading…
Reference in New Issue