* [PATCH] Add monitor delay parameter to mdadm.conf
@ 2021-07-30 9:16 Mariusz Tkaczyk
2021-08-02 14:24 ` Jes Sorensen
0 siblings, 1 reply; 2+ messages in thread
From: Mariusz Tkaczyk @ 2021-07-30 9:16 UTC (permalink / raw)
To: jes; +Cc: linux-raid
From: oshchirs <oleksandr.shchirskyi@intel.com>
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>
---
config.c | 23 ++++++++++++++++++++++-
mdadm.c | 6 ++----
mdadm.conf.5 | 24 +++++++++++++++++++++---
mdadm.h | 1 +
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 493d70e4..fd61c25c 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -1657,10 +1657,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 1ee6c92e..c3334caf 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1521,6 +1521,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);
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Add monitor delay parameter to mdadm.conf
2021-07-30 9:16 [PATCH] Add monitor delay parameter to mdadm.conf Mariusz Tkaczyk
@ 2021-08-02 14:24 ` Jes Sorensen
0 siblings, 0 replies; 2+ messages in thread
From: Jes Sorensen @ 2021-08-02 14:24 UTC (permalink / raw)
To: Mariusz Tkaczyk; +Cc: linux-raid
On 7/30/21 5:16 AM, Mariusz Tkaczyk wrote:
> From: oshchirs <oleksandr.shchirskyi@intel.com>
>
> 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>
> ---
> config.c | 23 ++++++++++++++++++++++-
> mdadm.c | 6 ++----
> mdadm.conf.5 | 24 +++++++++++++++++++++---
> mdadm.h | 1 +
Applied!
Thanks,
Jes
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-02 14:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-30 9:16 [PATCH] Add monitor delay parameter to mdadm.conf Mariusz Tkaczyk
2021-08-02 14:24 ` Jes Sorensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox