Accepting request 567778 from home:dsterba:branches:filesystems
- update to version 0.4 OBS-URL: https://build.opensuse.org/request/show/567778 OBS-URL: https://build.opensuse.org/package/show/filesystems/btrfsmaintenance?expand=0&rev=31
This commit is contained in:
parent
dfd880466e
commit
d8536ea64f
@ -1,18 +0,0 @@
|
||||
RPM database location has changed from /var/lib/rpm to /usr/lib/sysimage/rpm
|
||||
for openSUSE Tumbleweed.
|
||||
|
||||
See https://lists.opensuse.org/opensuse-factory/2017-11/msg00188.html.
|
||||
---
|
||||
diff -up ./btrfs-defrag-plugin.py.orig ./btrfs-defrag-plugin.py
|
||||
--- ./btrfs-defrag-plugin.py.orig 2017-11-07 22:56:51.559813001 +0100
|
||||
+++ ./btrfs-defrag-plugin.py 2017-11-07 22:57:38.027814927 +0100
|
||||
@@ -24,7 +24,7 @@ import subprocess
|
||||
DEBUG=False
|
||||
EXTENT_SIZE=64*1024*1024
|
||||
LOGFILE='/tmp/btrfs-defrag-plugin.log'
|
||||
-PATH='/var/lib/rpm'
|
||||
+PATH='/usr/lib/sysimage/rpm/'
|
||||
|
||||
def dbg(args):
|
||||
if not DEBUG: return
|
||||
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:65304ed51c7402ece2989f155a5da4be8380b85c4418dcd48a0c631f89c9ca1d
|
||||
size 16240
|
3
btrfsmaintenance-0.4.tar.bz2
Normal file
3
btrfsmaintenance-0.4.tar.bz2
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:46fb835cf45ed27f9fb957d49c4569bbff0a346a60f437f46bf130f1bd394092
|
||||
size 17511
|
@ -1,24 +0,0 @@
|
||||
--- btrfsmaintenance-refresh-cron.sh
|
||||
+++ btrfsmaintenance-refresh-cron.sh 2017/12/17 11:12:22
|
||||
@@ -91,6 +91,10 @@
|
||||
|
||||
case "$BTRFS_TIMER_IMPLEMENTATION" in
|
||||
systemd-timer)
|
||||
+ # Deinstall cron jobs, don't run it twice.
|
||||
+ for SCRIPT in btrfs-scrub btrfs-defrag btrfs-balance btrfs-trim; do
|
||||
+ refresh_cron uninstall ${SCRIPT}.sh
|
||||
+ done
|
||||
refresh_timer "$BTRFS_SCRUB_PERIOD" btrfs-scrub
|
||||
refresh_timer "$BTRFS_DEFRAG_PERIOD" btrfs-defrag
|
||||
refresh_timer "$BTRFS_BALANCE_PERIOD" btrfs-balance
|
||||
--- btrfsmaintenance-refresh.service
|
||||
+++ btrfsmaintenance-refresh.service 2017/12/17 11:04:07
|
||||
@@ -3,7 +3,7 @@
|
||||
After=local-fs.target
|
||||
|
||||
[Service]
|
||||
-ExecStart=/usr/share/btrfsmaintenance/btrfsmaintenance-refresh-cron.sh
|
||||
+ExecStart=/usr/share/btrfsmaintenance/btrfsmaintenance-refresh-cron.sh systemd-timer
|
||||
Type=oneshot
|
||||
|
||||
[Install]
|
@ -1,8 +1,24 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon Jan 15 00:00:00 CET 2018 - dsterba@suse.cz
|
||||
|
||||
- update to version 0.4
|
||||
- add support for systemd timers and use them by default; the alternative
|
||||
cron scripts are still present (#29, #36)
|
||||
- add automatic monitoring (via systemd.path) of the config file,
|
||||
no manual updates by btrfsmaintenance-refresh.service needed (#38)
|
||||
- fix RPM database path detection
|
||||
- spec file cleanups
|
||||
- documentation updates
|
||||
- removed patches:
|
||||
- btrfsmaintenance-0.3.1-fix-rpm-db-path.patch (upstream)
|
||||
- btrfsmaintenance-switch-to-timer.patch (upstream)
|
||||
- pull-request-36.patch (upstream)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Dec 22 18:42:10 UTC 2017 - antoine.belvire@opensuse.org
|
||||
|
||||
- Fix systemd timers enabled even if period is set to none:
|
||||
* Micro change in pull-request-36.patch.
|
||||
* Micro change in pull-request-36.patch (bsc#1075884)
|
||||
- Clean spec file:
|
||||
* Removed support for suse_version <= 1210.
|
||||
* Removed call to btrfsmaintenance-refresh-cron.sh upon deletion
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package btrfsmaintenance
|
||||
#
|
||||
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -20,20 +20,15 @@
|
||||
%if ! %{defined _fillupdir}
|
||||
%define _fillupdir /var/adm/fillup-templates
|
||||
%endif
|
||||
|
||||
Name: btrfsmaintenance
|
||||
Version: 0.3.1
|
||||
Version: 0.4
|
||||
Release: 0
|
||||
Summary: Scripts for btrfs periodic maintenance tasks
|
||||
License: GPL-2.0
|
||||
Group: System/Base
|
||||
Url: https://github.com/kdave/btrfsmaintenance
|
||||
Source0: %{name}-%{version}.tar.bz2
|
||||
# PATCH-FIX-OPENSUSE btrfsmaintenance-0.3.1-fix-rpm-db-path.patch -- Fix RPM database path for Tumbleweed
|
||||
Patch0: btrfsmaintenance-0.3.1-fix-rpm-db-path.patch
|
||||
# PATCH-FIX-UPSTREAM pull-request-36.patch -- Add systemd timer
|
||||
Patch1: pull-request-36.patch
|
||||
# PATCH-FIX-UPSTREAM btrfsmaintenance-switch-to-timer.patch -- Refresh systemd timers, not cron tasks
|
||||
Patch2: btrfsmaintenance-switch-to-timer.patch
|
||||
BuildRequires: systemd
|
||||
Requires: btrfsprogs
|
||||
Requires: zypp-plugin-python
|
||||
@ -48,11 +43,6 @@ on selected mountpoints or directories.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%if 0%{?suse_version} > 1320
|
||||
%patch0
|
||||
%endif
|
||||
%patch1 -p1
|
||||
%patch2
|
||||
|
||||
%build
|
||||
|
||||
|
@ -1,300 +0,0 @@
|
||||
From a192d335442d2fe74b3b6f7feb83a07325441361 Mon Sep 17 00:00:00 2001
|
||||
From: Luigi 'Comio' Mantellini <luigi.mantellini@gmail.com>
|
||||
Date: Wed, 2 Aug 2017 17:27:21 +0200
|
||||
Subject: [PATCH 1/2] Add support for systemd timers.
|
||||
|
||||
---
|
||||
btrfs-balance.service | 10 +++++
|
||||
btrfs-balance.timer | 11 ++++++
|
||||
btrfs-defrag.service | 10 +++++
|
||||
btrfs-defrag.timer | 11 ++++++
|
||||
btrfs-scrub.service | 10 +++++
|
||||
btrfs-scrub.timer | 11 ++++++
|
||||
btrfs-trim.service | 10 +++++
|
||||
btrfs-trim.timer | 11 ++++++
|
||||
btrfsmaintenance-refresh-cron.sh | 80 ++++++++++++++++++++++++++++++++--------
|
||||
btrfsmaintenance.spec | 16 ++++++++
|
||||
prepare-release.sh | 1 +
|
||||
11 files changed, 165 insertions(+), 16 deletions(-)
|
||||
create mode 100644 btrfs-balance.service
|
||||
create mode 100644 btrfs-balance.timer
|
||||
create mode 100644 btrfs-defrag.service
|
||||
create mode 100644 btrfs-defrag.timer
|
||||
create mode 100644 btrfs-scrub.service
|
||||
create mode 100644 btrfs-scrub.timer
|
||||
create mode 100644 btrfs-trim.service
|
||||
create mode 100644 btrfs-trim.timer
|
||||
|
||||
diff --git a/btrfs-balance.service b/btrfs-balance.service
|
||||
new file mode 100644
|
||||
index 0000000..146f997
|
||||
--- /dev/null
|
||||
+++ b/btrfs-balance.service
|
||||
@@ -0,0 +1,10 @@
|
||||
+[Unit]
|
||||
+Description=Balance block groups on a btrfs filesystem
|
||||
+Documentation=man:btrfs-balance
|
||||
+After=fstrim.service btrfs-trim.service btrfs-scrub.service
|
||||
+
|
||||
+[Service]
|
||||
+Type=oneshot
|
||||
+ExecStart=/usr/share/btrfsmaintenance/btrfs-balance.sh
|
||||
+IOSchedulingClass=idle
|
||||
+CPUSchedulingPolicy=idle
|
||||
diff --git a/btrfs-balance.timer b/btrfs-balance.timer
|
||||
new file mode 100644
|
||||
index 0000000..72f9f1f
|
||||
--- /dev/null
|
||||
+++ b/btrfs-balance.timer
|
||||
@@ -0,0 +1,11 @@
|
||||
+[Unit]
|
||||
+Description=Balance block groups on a btrfs filesystem
|
||||
+Documentation=man:btrfs-balance
|
||||
+
|
||||
+[Timer]
|
||||
+OnCalendar=monthly
|
||||
+AccuracySec=1h
|
||||
+Persistent=true
|
||||
+
|
||||
+[Install]
|
||||
+WantedBy=timers.target
|
||||
diff --git a/btrfs-defrag.service b/btrfs-defrag.service
|
||||
new file mode 100644
|
||||
index 0000000..12d3c92
|
||||
--- /dev/null
|
||||
+++ b/btrfs-defrag.service
|
||||
@@ -0,0 +1,10 @@
|
||||
+[Unit]
|
||||
+Description=Defragment file data on a mounted filesystem
|
||||
+Documentation=man:btrfs-filesystem
|
||||
+After=fstrim.service btrfs-trim.service btrfs-scrub.service
|
||||
+
|
||||
+[Service]
|
||||
+Type=oneshot
|
||||
+ExecStart=/usr/share/btrfsmaintenance/btrfs-defrag.sh
|
||||
+IOSchedulingClass=idle
|
||||
+CPUSchedulingPolicy=idle
|
||||
diff --git a/btrfs-defrag.timer b/btrfs-defrag.timer
|
||||
new file mode 100644
|
||||
index 0000000..dd5b867
|
||||
--- /dev/null
|
||||
+++ b/btrfs-defrag.timer
|
||||
@@ -0,0 +1,11 @@
|
||||
+[Unit]
|
||||
+Description=Defragment file data and/or directory metadata
|
||||
+Documentation=man:btrfs-filesystem
|
||||
+
|
||||
+[Timer]
|
||||
+OnCalendar=monthly
|
||||
+AccuracySec=1h
|
||||
+Persistent=true
|
||||
+
|
||||
+[Install]
|
||||
+WantedBy=timers.target
|
||||
diff --git a/btrfs-scrub.service b/btrfs-scrub.service
|
||||
new file mode 100644
|
||||
index 0000000..40012f3
|
||||
--- /dev/null
|
||||
+++ b/btrfs-scrub.service
|
||||
@@ -0,0 +1,10 @@
|
||||
+[Unit]
|
||||
+Description=Scrub btrfs filesystem, verify block checksums
|
||||
+Documentation=man:fstrim
|
||||
+After=fstrim.service btrfs-trim.service
|
||||
+
|
||||
+[Service]
|
||||
+Type=oneshot
|
||||
+ExecStart=/usr/share/btrfsmaintenance/btrfs-scrub.sh
|
||||
+IOSchedulingClass=idle
|
||||
+CPUSchedulingPolicy=idle
|
||||
diff --git a/btrfs-scrub.timer b/btrfs-scrub.timer
|
||||
new file mode 100644
|
||||
index 0000000..2ceabdf
|
||||
--- /dev/null
|
||||
+++ b/btrfs-scrub.timer
|
||||
@@ -0,0 +1,11 @@
|
||||
+[Unit]
|
||||
+Description=Scrub btrfs filesystem, verify block checksums
|
||||
+Documentation=man:btrfs-scrub
|
||||
+
|
||||
+[Timer]
|
||||
+OnCalendar=monthly
|
||||
+AccuracySec=1h
|
||||
+Persistent=true
|
||||
+
|
||||
+[Install]
|
||||
+WantedBy=timers.target
|
||||
diff --git a/btrfs-trim.service b/btrfs-trim.service
|
||||
new file mode 100644
|
||||
index 0000000..d09da40
|
||||
--- /dev/null
|
||||
+++ b/btrfs-trim.service
|
||||
@@ -0,0 +1,10 @@
|
||||
+[Unit]
|
||||
+Description=Discard unused blocks on a mounted filesystem
|
||||
+Documentation=man:fstrim
|
||||
+Conflicts=fstrim.service
|
||||
+
|
||||
+[Service]
|
||||
+Type=oneshot
|
||||
+ExecStart=/usr/share/btrfsmaintenance/btrfs-trim.sh
|
||||
+IOSchedulingClass=idle
|
||||
+CPUSchedulingPolicy=idle
|
||||
diff --git a/btrfs-trim.timer b/btrfs-trim.timer
|
||||
new file mode 100644
|
||||
index 0000000..03e824f
|
||||
--- /dev/null
|
||||
+++ b/btrfs-trim.timer
|
||||
@@ -0,0 +1,11 @@
|
||||
+[Unit]
|
||||
+Description=Discard unused blocks on a mounted filesystem
|
||||
+Documentation=man:fstrim
|
||||
+
|
||||
+[Timer]
|
||||
+OnCalendar=monthly
|
||||
+AccuracySec=1h
|
||||
+Persistent=true
|
||||
+
|
||||
+[Install]
|
||||
+WantedBy=timers.target
|
||||
diff --git a/btrfsmaintenance-refresh-cron.sh b/btrfsmaintenance-refresh-cron.sh
|
||||
index ed1053e..da68283 100755
|
||||
--- a/btrfsmaintenance-refresh-cron.sh
|
||||
+++ b/btrfsmaintenance-refresh-cron.sh
|
||||
@@ -16,17 +16,6 @@ export PATH
|
||||
|
||||
SCRIPTS=/usr/share/btrfsmaintenance
|
||||
|
||||
-if [ "$1" = 'uninstall' ]; then
|
||||
- for SCRIPT in btrfs-scrub.sh btrfs-defrag.sh btrfs-balance.sh btrfs-trim.sh; do
|
||||
- for PERIOD in daily weekly monthly; do
|
||||
- LINK="${SCRIPT%.*}"
|
||||
- FILE="/etc/cron.$PERIOD/$LINK"
|
||||
- rm -f "$FILE"
|
||||
- done
|
||||
- done
|
||||
- exit 0
|
||||
-fi
|
||||
-
|
||||
if [ -f /etc/sysconfig/btrfsmaintenance ]; then
|
||||
. /etc/sysconfig/btrfsmaintenance
|
||||
fi
|
||||
@@ -35,7 +24,18 @@ if [ -f /etc/default/btrfsmaintenance ]; then
|
||||
. /etc/default/btrfsmaintenance
|
||||
fi
|
||||
|
||||
-refresh_period() {
|
||||
+case "$1" in
|
||||
+ cron)
|
||||
+ BTRFS_TIMER_IMPLEMENTATION="cron"
|
||||
+ shift
|
||||
+ ;;
|
||||
+ systemd-timer|timer)
|
||||
+ BTRFS_TIMER_IMPLEMENTATION="systemd-timer"
|
||||
+ shift
|
||||
+ ;;
|
||||
+esac
|
||||
+
|
||||
+refresh_cron() {
|
||||
EXPECTED="$1"
|
||||
SCRIPT="$2"
|
||||
echo "Refresh script $SCRIPT for $EXPECTED"
|
||||
@@ -52,7 +52,55 @@ refresh_period() {
|
||||
done
|
||||
}
|
||||
|
||||
-refresh_period "$BTRFS_SCRUB_PERIOD" btrfs-scrub.sh
|
||||
-refresh_period "$BTRFS_DEFRAG_PERIOD" btrfs-defrag.sh
|
||||
-refresh_period "$BTRFS_BALANCE_PERIOD" btrfs-balance.sh
|
||||
-refresh_period "$BTRFS_TRIM_PERIOD" btrfs-trim.sh
|
||||
+refresh_timer() {
|
||||
+ PERIOD="$1"
|
||||
+ SERVICE="$2"
|
||||
+ echo "Refresh timer $SERVICE for $PERIOD"
|
||||
+
|
||||
+ case "$PERIOD" in
|
||||
+ daily|weekly|monthly)
|
||||
+ mkdir -p /etc/systemd/system/"$SERVICE".timer.d/
|
||||
+ cat << EOF > /etc/systemd/system/"$SERVICE".timer.d/schedule.conf
|
||||
+[Timer]
|
||||
+OnCalendar=$PERIOD
|
||||
+EOF
|
||||
+ systemctl enable "$SERVICE".timer &> /dev/null
|
||||
+ systemctl start "$SERVICE".timer &> /dev/null
|
||||
+ ;;
|
||||
+ *)
|
||||
+ systemctl stop "$SERVICE".timer &> /dev/null
|
||||
+ systemctl disable "$SERVICE".timer &> /dev/null
|
||||
+ rm -rf /etc/systemd/system/"$SERVICE".timer.d
|
||||
+ ;;
|
||||
+ esac
|
||||
+}
|
||||
+
|
||||
+if [ "$1" = 'uninstall' ]; then
|
||||
+ for SCRIPT in btrfs-scrub btrfs-defrag btrfs-balance btrfs-trim; do
|
||||
+ case "$BTRFS_TIMER_IMPLEMENTATION" in
|
||||
+ systemd-timer)
|
||||
+ refresh_timer uninstall ${SCRIPT}
|
||||
+ ;;
|
||||
+ *)
|
||||
+ refresh_cron uninstall ${SCRIPT}.sh
|
||||
+ ;;
|
||||
+ esac
|
||||
+ done
|
||||
+ exit 0
|
||||
+fi
|
||||
+
|
||||
+case "$BTRFS_TIMER_IMPLEMENTATION" in
|
||||
+ systemd-timer)
|
||||
+ refresh_timer "$BTRFS_SCRUB_PERIOD" btrfs-scrub
|
||||
+ refresh_timer "$BTRFS_DEFRAG_PERIOD" btrfs-defrag
|
||||
+ refresh_timer "$BTRFS_BALANCE_PERIOD" btrfs-balance
|
||||
+ refresh_timer "$BTRFS_TRIM_PERIOD" btrfs-trim
|
||||
+ ;;
|
||||
+ *)
|
||||
+ refresh_cron "$BTRFS_SCRUB_PERIOD" btrfs-scrub.sh
|
||||
+ refresh_cron "$BTRFS_DEFRAG_PERIOD" btrfs-defrag.sh
|
||||
+ refresh_cron "$BTRFS_BALANCE_PERIOD" btrfs-balance.sh
|
||||
+ refresh_cron "$BTRFS_TRIM_PERIOD" btrfs-trim.sh
|
||||
+ ;;
|
||||
+esac
|
||||
+
|
||||
From e5e26ffaa50d7cfdef8291d4ff72e95061438fcc Mon Sep 17 00:00:00 2001
|
||||
From: Luigi 'Comio' Mantellini <luigi.mantellini@gmail.com>
|
||||
Date: Wed, 6 Dec 2017 14:31:06 +0100
|
||||
Subject: [PATCH 2/2] Don't limit OnCalendar to daily, weekly and monthly.
|
||||
|
||||
---
|
||||
btrfsmaintenance-refresh-cron.sh | 12 ++++++------
|
||||
1 file changed, 6 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/btrfsmaintenance-refresh-cron.sh b/btrfsmaintenance-refresh-cron.sh
|
||||
index da68283..7e92170 100755
|
||||
--- a/btrfsmaintenance-refresh-cron.sh
|
||||
+++ b/btrfsmaintenance-refresh-cron.sh
|
||||
@@ -58,7 +58,12 @@ refresh_timer() {
|
||||
echo "Refresh timer $SERVICE for $PERIOD"
|
||||
|
||||
case "$PERIOD" in
|
||||
- daily|weekly|monthly)
|
||||
+ uninstall|none)
|
||||
+ systemctl stop "$SERVICE".timer &> /dev/null
|
||||
+ systemctl disable "$SERVICE".timer &> /dev/null
|
||||
+ rm -rf /etc/systemd/system/"$SERVICE".timer.d
|
||||
+ ;;
|
||||
+ *)
|
||||
mkdir -p /etc/systemd/system/"$SERVICE".timer.d/
|
||||
cat << EOF > /etc/systemd/system/"$SERVICE".timer.d/schedule.conf
|
||||
[Timer]
|
||||
@@ -67,11 +72,6 @@ EOF
|
||||
systemctl enable "$SERVICE".timer &> /dev/null
|
||||
systemctl start "$SERVICE".timer &> /dev/null
|
||||
;;
|
||||
- *)
|
||||
- systemctl stop "$SERVICE".timer &> /dev/null
|
||||
- systemctl disable "$SERVICE".timer &> /dev/null
|
||||
- rm -rf /etc/systemd/system/"$SERVICE".timer.d
|
||||
- ;;
|
||||
esac
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user