]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Add monitor delay parameter to mdadm.conf
authoroshchirs <oleksandr.shchirskyi@intel.com>
Fri, 30 Jul 2021 09:16:00 +0000 (11:16 +0200)
committerJes Sorensen <jsorensen@fb.com>
Mon, 2 Aug 2021 14:24:20 +0000 (10:24 -0400)
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>
config.c
mdadm.c
mdadm.conf.5
mdadm.h

index 7592b2d7aea94a623270fb1029aefd4d54539593..9c725457fac98913186896f881edeae149a86d72 100644 (file)
--- 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 dcc26ba8f1a130212449e85d976707860d1f0ec7..073b72416858cd5a0daad78adf7dabfbc0182155 100644 (file)
--- 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,
index 27dbab18455d145790e502e101b1a02947ef7d13..74a21c5f0844b081184f06da5dc41eec7b48ef63 100644 (file)
@@ -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 273fa5098b93ecb0d7bbbb9fce6f078ed7fc2c64..8f8841d870bc1a3181c1d5709299ec3dcc211e19 100644 (file)
--- 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);