dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

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

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