summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroshchirs <oleksandr.shchirskyi@intel.com>2021-07-30 11:16:00 +0200
committerJes Sorensen <jsorensen@fb.com>2021-08-02 16:24:20 +0200
commit0663137c77bc848b2927075c077b545fceeb4dae (patch)
tree096e70e328bc0d2e5b7309a19b80d9c3275e7dac
parenttests: Avoid passing chunk size when creating RAID 1 (diff)
downloadmdadm-0663137c77bc848b2927075c077b545fceeb4dae.tar.xz
mdadm-0663137c77bc848b2927075c077b545fceeb4dae.zip
Add monitor delay parameter to mdadm.conf
Add possibility to configure delay for mdadm in monitoring mode using mdadm.conf. --delay command line argument takes precedence over config file. Signed-off-by: Oleksandr Shchirskyi <oleksandr.shchirskyi@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
-rw-r--r--config.c23
-rw-r--r--mdadm.c6
-rw-r--r--mdadm.conf.524
-rw-r--r--mdadm.h1
4 files changed, 46 insertions, 8 deletions
diff --git a/config.c b/config.c
index 7592b2d7..9c725457 100644
--- a/config.c
+++ b/config.c
@@ -81,7 +81,7 @@ char DefaultAltConfDir[] = CONFFILE2 ".d";
enum linetype { Devices, Array, Mailaddr, Mailfrom, Program, CreateDev,
Homehost, HomeCluster, AutoMode, Policy, PartPolicy, Sysfs,
- LTEnd };
+ MonitorDelay, LTEnd };
char *keywords[] = {
[Devices] = "devices",
[Array] = "array",
@@ -95,6 +95,7 @@ char *keywords[] = {
[Policy] = "policy",
[PartPolicy]="part-policy",
[Sysfs] = "sysfs",
+ [MonitorDelay] = "monitordelay",
[LTEnd] = NULL
};
@@ -588,6 +589,17 @@ void homeclusterline(char *line)
}
}
+static int monitor_delay;
+void monitordelayline(char *line)
+{
+ char *w;
+
+ for (w = dl_next(line); w != line; w = dl_next(w)) {
+ if (monitor_delay == 0)
+ monitor_delay = strtol(w, NULL, 10);
+ }
+}
+
char auto_yes[] = "yes";
char auto_no[] = "no";
char auto_homehost[] = "homehost";
@@ -769,6 +781,9 @@ void conf_file(FILE *f)
case Sysfs:
sysfsline(line);
break;
+ case MonitorDelay:
+ monitordelayline(line);
+ break;
default:
pr_err("Unknown keyword %s\n", line);
}
@@ -925,6 +940,12 @@ char *conf_get_homecluster(void)
return home_cluster;
}
+int conf_get_monitor_delay(void)
+{
+ load_conffile();
+ return monitor_delay;
+}
+
struct createinfo *conf_get_create_info(void)
{
load_conffile();
diff --git a/mdadm.c b/mdadm.c
index dcc26ba8..073b7241 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -1659,10 +1659,8 @@ int main(int argc, char *argv[])
break;
}
if (c.delay == 0) {
- if (get_linux_version() > 2006016)
- /* mdstat responds to poll */
- c.delay = 1000;
- else
+ c.delay = conf_get_monitor_delay();
+ if (!c.delay)
c.delay = 60;
}
rv = Monitor(devlist, mailaddr, program,
diff --git a/mdadm.conf.5 b/mdadm.conf.5
index 27dbab18..74a21c5f 100644
--- a/mdadm.conf.5
+++ b/mdadm.conf.5
@@ -505,7 +505,7 @@ Keywords used in the
.I POLICY
line and supported values are:
-.RS 7
+.RS 4
.TP
.B domain=
any arbitrary string
@@ -589,7 +589,9 @@ found.
.TP
.B SYSFS
-The SYSFS line lists custom values of MD device's sysfs attributes which will be
+The
+.B SYSFS
+line lists custom values of MD device's sysfs attributes which will be
stored in sysfs after the array is assembled. Multiple lines are allowed and each
line has to contain the uuid or the name of the device to which it relates.
.RS 4
@@ -604,8 +606,22 @@ name of the MD device as was given to
when the array was created. It will be ignored if
.B uuid
is not empty.
+.RE
+
.TP
-.RS 7
+.B MONITORDELAY
+The
+.B monitordelay
+line gives a delay in seconds
+.I mdadm
+shall wait before pooling md arrays
+when
+.I mdadm
+is running in
+.B \-\-monitor
+mode.
+.B \-d/\-\-delay
+command line argument takes precedence over the config file
.SH EXAMPLE
DEVICE /dev/sd[bcdjkl]1
@@ -682,6 +698,8 @@ SYSFS name=/dev/md/raid5 group_thread_cnt=4 sync_speed_max=1000000
.br
SYSFS uuid=bead5eb6:31c17a27:da120ba2:7dfda40d group_thread_cnt=4
sync_speed_max=1000000
+.br
+MONITORDELAY 60
.SH SEE ALSO
.BR mdadm (8),
diff --git a/mdadm.h b/mdadm.h
index 273fa509..8f8841d8 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1525,6 +1525,7 @@ extern char *conf_get_mailfrom(void);
extern char *conf_get_program(void);
extern char *conf_get_homehost(int *require_homehostp);
extern char *conf_get_homecluster(void);
+extern int conf_get_monitor_delay(void);
extern char *conf_line(FILE *file);
extern char *conf_word(FILE *file, int allow_key);
extern void print_quoted(char *str);