dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

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

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