Blame SOURCES/0004-mdcheck-add-systemd-unit-files-to-run-mdcheck.patch

5eacff
From 4199d3c629c14866505923d19fa50017ee92d2e1 Mon Sep 17 00:00:00 2001
5eacff
From: NeilBrown <neilb@suse.com>
5eacff
Date: Wed, 5 Dec 2018 16:35:00 +1100
5eacff
Subject: [RHEL7.7 PATCH 04/24] mdcheck: add systemd unit files to run mdcheck.
5eacff
5eacff
Having the mdcheck script is not use if is never run.
5eacff
This patch adds systemd unit files so that it can easily
5eacff
be run on the first Sunday of each month for 6 hours,
5eacff
then on every subsequent morning until the check is
5eacff
finished.
5eacff
5eacff
The units still need to be enabled with
5eacff
  systemctl enable mdcheck_start.timer
5eacff
5eacff
The timer will only actually be started when an array
5eacff
which might need it becomes active.
5eacff
5eacff
Signed-off-by: NeilBrown <neilb@suse.com>
5eacff
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
5eacff
---
5eacff
 Makefile                         |  5 ++++-
5eacff
 systemd/mdcheck_continue.service | 18 ++++++++++++++++++
5eacff
 systemd/mdcheck_continue.timer   | 13 +++++++++++++
5eacff
 systemd/mdcheck_start.service    | 17 +++++++++++++++++
5eacff
 systemd/mdcheck_start.timer      | 15 +++++++++++++++
5eacff
 5 files changed, 67 insertions(+), 1 deletion(-)
5eacff
 create mode 100644 systemd/mdcheck_continue.service
5eacff
 create mode 100644 systemd/mdcheck_continue.timer
5eacff
 create mode 100644 systemd/mdcheck_start.service
5eacff
 create mode 100644 systemd/mdcheck_start.timer
5eacff
5eacff
diff --git a/Makefile b/Makefile
5eacff
index 2767ac6..afb62cc 100644
5eacff
--- a/Makefile
5eacff
+++ b/Makefile
5eacff
@@ -276,7 +276,10 @@ install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules udev-md-raid
5eacff
 
5eacff
 install-systemd: systemd/mdmon@.service
5eacff
 	@for file in mdmon@.service mdmonitor.service mdadm-last-resort@.timer \
5eacff
-		mdadm-last-resort@.service mdadm-grow-continue@.service; \
5eacff
+		mdadm-last-resort@.service mdadm-grow-continue@.service \
5eacff
+		mdcheck_start.timer mdcheck_start.service \
5eacff
+		mdcheck_continue.timer mdcheck_continue.service \
5eacff
+		; \
5eacff
 	do sed -e 's,BINDIR,$(BINDIR),g' systemd/$$file > .install.tmp.2 && \
5eacff
 	   $(ECHO) $(INSTALL) -D -m 644 systemd/$$file $(DESTDIR)$(SYSTEMD_DIR)/$$file ; \
5eacff
 	   $(INSTALL) -D -m 644 .install.tmp.2 $(DESTDIR)$(SYSTEMD_DIR)/$$file ; \
5eacff
diff --git a/systemd/mdcheck_continue.service b/systemd/mdcheck_continue.service
5eacff
new file mode 100644
5eacff
index 0000000..592c607
5eacff
--- /dev/null
5eacff
+++ b/systemd/mdcheck_continue.service
5eacff
@@ -0,0 +1,18 @@
5eacff
+#  This file is part of mdadm.
5eacff
+#
5eacff
+#  mdadm is free software; you can redistribute it and/or modify it
5eacff
+#  under the terms of the GNU General Public License as published by
5eacff
+#  the Free Software Foundation; either version 2 of the License, or
5eacff
+#  (at your option) any later version.
5eacff
+
5eacff
+[Unit]
5eacff
+Description=MD array scrubbing - continuation
5eacff
+ConditionPathExistsGlob = /var/lib/mdcheck/MD_UUID_*
5eacff
+
5eacff
+[Service]
5eacff
+Type=oneshot
5eacff
+Environment= MDADM_CHECK_DURATION='"6 hours"'
5eacff
+EnvironmentFile=-/run/sysconfig/mdadm
5eacff
+ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh
5eacff
+ExecStart=/usr/share/mdadm/mdcheck --continue --duration $MDADM_CHECK_DURATION
5eacff
+
5eacff
diff --git a/systemd/mdcheck_continue.timer b/systemd/mdcheck_continue.timer
5eacff
new file mode 100644
5eacff
index 0000000..3ccfd78
5eacff
--- /dev/null
5eacff
+++ b/systemd/mdcheck_continue.timer
5eacff
@@ -0,0 +1,13 @@
5eacff
+#  This file is part of mdadm.
5eacff
+#
5eacff
+#  mdadm is free software; you can redistribute it and/or modify it
5eacff
+#  under the terms of the GNU General Public License as published by
5eacff
+#  the Free Software Foundation; either version 2 of the License, or
5eacff
+#  (at your option) any later version.
5eacff
+
5eacff
+[Unit]
5eacff
+Description=MD array scrubbing - continuation
5eacff
+
5eacff
+[Timer]
5eacff
+OnCalendar= 1:05:00
5eacff
+
5eacff
diff --git a/systemd/mdcheck_start.service b/systemd/mdcheck_start.service
5eacff
new file mode 100644
5eacff
index 0000000..812141b
5eacff
--- /dev/null
5eacff
+++ b/systemd/mdcheck_start.service
5eacff
@@ -0,0 +1,17 @@
5eacff
+#  This file is part of mdadm.
5eacff
+#
5eacff
+#  mdadm is free software; you can redistribute it and/or modify it
5eacff
+#  under the terms of the GNU General Public License as published by
5eacff
+#  the Free Software Foundation; either version 2 of the License, or
5eacff
+#  (at your option) any later version.
5eacff
+
5eacff
+[Unit]
5eacff
+Description=MD array scrubbing
5eacff
+Wants=mdcheck_continue.timer
5eacff
+
5eacff
+[Service]
5eacff
+Type=oneshot
5eacff
+Environment= MDADM_CHECK_DURATION='"6 hours"'
5eacff
+EnvironmentFile=-/run/sysconfig/mdadm
5eacff
+ExecStartPre=-/usr/lib/mdadm/mdadm_env.sh
5eacff
+ExecStart=/usr/share/mdadm/mdcheck --duration $MDADM_CHECK_DURATION
5eacff
diff --git a/systemd/mdcheck_start.timer b/systemd/mdcheck_start.timer
5eacff
new file mode 100644
5eacff
index 0000000..6480736
5eacff
--- /dev/null
5eacff
+++ b/systemd/mdcheck_start.timer
5eacff
@@ -0,0 +1,15 @@
5eacff
+#  This file is part of mdadm.
5eacff
+#
5eacff
+#  mdadm is free software; you can redistribute it and/or modify it
5eacff
+#  under the terms of the GNU General Public License as published by
5eacff
+#  the Free Software Foundation; either version 2 of the License, or
5eacff
+#  (at your option) any later version.
5eacff
+
5eacff
+[Unit]
5eacff
+Description=MD array scrubbing
5eacff
+
5eacff
+[Timer]
5eacff
+OnCalendar=Sun *-*-1..7 1:00:00
5eacff
+
5eacff
+[Install]
5eacff
+WantedBy= mdmonitor.service
5eacff
-- 
5eacff
2.7.5
5eacff