dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

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

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