From: Darrick J. Wong <djwong@xxxxxxxxxx> Teach the xfs_scrub_all background service to trigger an automatic scan of all file data once per month. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> Reviewed-by: Christoph Hellwig <hch@xxxxxx> --- scrub/Makefile | 8 +++++++- scrub/xfs_scrub_all.cron.in | 2 +- scrub/xfs_scrub_all.service.in | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/scrub/Makefile b/scrub/Makefile index 091a5c94b..0e09ed127 100644 --- a/scrub/Makefile +++ b/scrub/Makefile @@ -108,6 +108,9 @@ CFILES += unicrash.c LCFLAGS += -DHAVE_LIBICU $(LIBICU_CFLAGS) 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 default: depend $(LTCOMMAND) $(XFS_SCRUB_ALL_PROG) $(XFS_SCRUB_FAIL_PROG) $(OPTIONAL_TARGETS) @@ -143,11 +146,14 @@ install: $(INSTALL_SCRUB) -e "s|@scrub_args@|$(XFS_SCRUB_ARGS)|g" \ -e "s|@pkg_libexec_dir@|$(PKG_LIBEXEC_DIR)|g" \ -e "s|@pkg_state_dir@|$(PKG_STATE_DIR)|g" \ + -e "s|@media_scan_interval@|$(XFS_SCRUB_ALL_AUTO_MEDIA_SCAN_INTERVAL)|g" \ < $< > $@ %.cron: %.cron.in $(builddefs) @echo " [SED] $@" - $(Q)$(SED) -e "s|@sbindir@|$(PKG_SBIN_DIR)|g" < $< > $@ + $(Q)$(SED) -e "s|@sbindir@|$(PKG_SBIN_DIR)|g" \ + -e "s|@media_scan_interval@|$(XFS_SCRUB_ALL_AUTO_MEDIA_SCAN_INTERVAL)|g" \ + < $< > $@ install-systemd: default $(SYSTEMD_SERVICES) $(INSTALL) -m 755 -d $(SYSTEMD_SYSTEM_UNIT_DIR) diff --git a/scrub/xfs_scrub_all.cron.in b/scrub/xfs_scrub_all.cron.in index e08a9daf9..e6633e091 100644 --- a/scrub/xfs_scrub_all.cron.in +++ b/scrub/xfs_scrub_all.cron.in @@ -3,4 +3,4 @@ # Copyright (C) 2018-2024 Oracle. All Rights Reserved. # Author: Darrick J. Wong <djwong@xxxxxxxxxx> # -10 3 * * 0 root test -e /run/systemd/system || @sbindir@/xfs_scrub_all +10 3 * * 0 root test -e /run/systemd/system || @sbindir@/xfs_scrub_all --auto-media-scan-interval @media_scan_interval@ diff --git a/scrub/xfs_scrub_all.service.in b/scrub/xfs_scrub_all.service.in index 9ecc3af0c..8ed682989 100644 --- a/scrub/xfs_scrub_all.service.in +++ b/scrub/xfs_scrub_all.service.in @@ -12,7 +12,7 @@ After=paths.target multi-user.target network.target network-online.target system [Service] Type=oneshot Environment=SERVICE_MODE=1 -ExecStart=@sbindir@/xfs_scrub_all +ExecStart=@sbindir@/xfs_scrub_all --auto-media-scan-interval @media_scan_interval@ SyslogIdentifier=xfs_scrub_all # Create the service underneath the scrub background service slice so that we