dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

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

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