From: "Darrick J. Wong" <djwong@kernel.org>
To: Andrey Albershteyn <aalbersh@redhat.com>
Cc: xfs <linux-xfs@vger.kernel.org>, hch@lst.de
Subject: [PATCH v2] xfs_scrub_all.timer: don't run if /var/lib/xfsprogs is readonly
Date: Mon, 27 Jan 2025 13:36:34 -0800 [thread overview]
Message-ID: <20250127213634.GJ1611770@frogsfrogsfrogs> (raw)
In-Reply-To: <20250122020025.GL1611770@frogsfrogsfrogs>
From: Darrick J. Wong <djwong@kernel.org>
The xfs_scrub_all program wants to write a state file into the package
state dir to keep track of how recently it performed a media scan.
Don't allow the systemd timer to run if that path isn't writable.
Cc: <linux-xfs@vger.kernel.org> # v6.10.0
Fixes: 267ae610a3d90f ("xfs_scrub_all: enable periodic file data scrubs automatically")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
v2: add some comments to timer file
---
scrub/Makefile | 6 +++++-
scrub/xfs_scrub_all.timer | 16 ----------------
scrub/xfs_scrub_all.timer.in | 23 +++++++++++++++++++++++
3 files changed, 28 insertions(+), 17 deletions(-)
delete mode 100644 scrub/xfs_scrub_all.timer
create mode 100644 scrub/xfs_scrub_all.timer.in
diff --git a/scrub/Makefile b/scrub/Makefile
index 1e1109048c2a83..934b9062651bf1 100644
--- a/scrub/Makefile
+++ b/scrub/Makefile
@@ -108,10 +108,14 @@ endif
# Automatically trigger a media scan once per month
XFS_SCRUB_ALL_AUTO_MEDIA_SCAN_INTERVAL=1mo
-LDIRT = $(XFS_SCRUB_ALL_PROG) $(XFS_SCRUB_FAIL_PROG) *.service *.cron
+LDIRT = $(XFS_SCRUB_ALL_PROG) $(XFS_SCRUB_FAIL_PROG) *.service *.cron xfs_scrub_all.timer
default: depend $(LTCOMMAND) $(XFS_SCRUB_ALL_PROG) $(XFS_SCRUB_FAIL_PROG) $(OPTIONAL_TARGETS)
+xfs_scrub_all.timer: xfs_scrub_all.timer.in $(builddefs)
+ @echo " [SED] $@"
+ $(Q)$(SED) -e "s|@pkg_state_dir@|$(PKG_STATE_DIR)|g" < $< > $@
+
xfs_scrub_all: xfs_scrub_all.in $(builddefs)
@echo " [SED] $@"
$(Q)$(SED) -e "s|@sbindir@|$(PKG_SBIN_DIR)|g" \
diff --git a/scrub/xfs_scrub_all.timer b/scrub/xfs_scrub_all.timer
deleted file mode 100644
index f0c557fc380391..00000000000000
--- a/scrub/xfs_scrub_all.timer
+++ /dev/null
@@ -1,16 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-#
-# Copyright (C) 2018-2024 Oracle. All Rights Reserved.
-# Author: Darrick J. Wong <djwong@kernel.org>
-
-[Unit]
-Description=Periodic XFS Online Metadata Check for All Filesystems
-
-[Timer]
-# Run on Sunday at 3:10am, to avoid running afoul of DST changes
-OnCalendar=Sun *-*-* 03:10:00
-RandomizedDelaySec=60
-Persistent=true
-
-[Install]
-WantedBy=timers.target
diff --git a/scrub/xfs_scrub_all.timer.in b/scrub/xfs_scrub_all.timer.in
new file mode 100644
index 00000000000000..a6bde69e947e23
--- /dev/null
+++ b/scrub/xfs_scrub_all.timer.in
@@ -0,0 +1,23 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Copyright (C) 2018-2025 Oracle. All Rights Reserved.
+# Author: Darrick J. Wong <djwong@kernel.org>
+
+[Unit]
+Description=Periodic XFS Online Metadata Check for All Filesystems
+
+# The xfs_scrub_all program records the last time that it performed a media
+# scan in @pkg_state_dir@. If this path is not writable, the program
+# aborts and systemd records this as a failure. Disable the timer if the path
+# is not writable. This should be an uncommon situation since most
+# readonly-root systems set that up to be writable (and possibly volatile).
+ConditionPathIsReadWrite=@pkg_state_dir@
+
+[Timer]
+# Run on Sunday at 3:10am, to avoid running afoul of DST changes
+OnCalendar=Sun *-*-* 03:10:00
+RandomizedDelaySec=60
+Persistent=true
+
+[Install]
+WantedBy=timers.target
prev parent reply other threads:[~2025-01-27 21:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-22 2:00 [PATCH] xfs_scrub_all.timer: don't run if /var/lib/xfsprogs is readonly Darrick J. Wong
2025-01-22 6:02 ` Christoph Hellwig
2025-01-22 7:18 ` Darrick J. Wong
2025-01-22 7:22 ` Christoph Hellwig
2025-01-22 19:34 ` Darrick J. Wong
2025-01-27 8:57 ` Christoph Hellwig
2025-01-27 16:03 ` Darrick J. Wong
2025-01-27 21:36 ` Darrick J. Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250127213634.GJ1611770@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=aalbersh@redhat.com \
--cc=hch@lst.de \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox