Hello community, here is the log from the commit of package btrfsmaintenance for openSUSE:Factory checked in at 2018-03-16 10:44:46 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/btrfsmaintenance (Old) and /work/SRC/openSUSE:Factory/.btrfsmaintenance.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "btrfsmaintenance" Fri Mar 16 10:44:46 2018 rev:17 rq:587598 version:0.4.1 Changes: -------- --- /work/SRC/openSUSE:Factory/btrfsmaintenance/btrfsmaintenance.changes 2018-03-13 10:24:41.756357201 +0100 +++ /work/SRC/openSUSE:Factory/.btrfsmaintenance.new/btrfsmaintenance.changes 2018-03-16 10:45:39.475485056 +0100 @@ -1,0 +2,10 @@ +Thu Mar 15 00:00:00 CET 2018 - [email protected] + +- update to version 0.4.1 + - defrag plugin: python2 and 3 compatibility + - defrag plugin: target extent size lowered to 32MiB (#43) + - shell compatibility fixes + - systemd unit type fixes +- Removed patch: python3-support-bsc1070322.diff (upstream) + +------------------------------------------------------------------- Old: ---- btrfsmaintenance-0.4.tar.bz2 python3-support-bsc1070322.diff New: ---- btrfsmaintenance-0.4.1.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ btrfsmaintenance.spec ++++++ --- /var/tmp/diff_new_pack.u0Bwql/_old 2018-03-16 10:45:40.323454522 +0100 +++ /var/tmp/diff_new_pack.u0Bwql/_new 2018-03-16 10:45:40.327454378 +0100 @@ -22,14 +22,13 @@ %endif Name: btrfsmaintenance -Version: 0.4 +Version: 0.4.1 Release: 0 Summary: Scripts for btrfs periodic maintenance tasks License: GPL-2.0-only Group: System/Base Url: https://github.com/kdave/btrfsmaintenance Source0: %{name}-%{version}.tar.bz2 -Patch0: python3-support-bsc1070322.diff BuildRequires: systemd Requires: btrfsprogs Requires: python3-zypp-plugin @@ -40,11 +39,11 @@ %description Scripts for btrfs maintenance tasks like periodic scrub, balance, trim or defrag -on selected mountpoints or directories. +on selected mountpoints or directories. Hints for periodic snapshot tuning (eg. +for snapper). %prep %setup -q -%patch0 -p1 %build ++++++ btrfsmaintenance-0.4.tar.bz2 -> btrfsmaintenance-0.4.1.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.4/btrfs-balance.service new/btrfsmaintenance-0.4.1/btrfs-balance.service --- old/btrfsmaintenance-0.4/btrfs-balance.service 2018-01-15 17:40:06.389987125 +0100 +++ new/btrfsmaintenance-0.4.1/btrfs-balance.service 2018-03-15 18:49:36.417244400 +0100 @@ -4,7 +4,7 @@ After=fstrim.service btrfs-trim.service btrfs-scrub.service [Service] -Type=oneshot +Type=simple ExecStart=/usr/share/btrfsmaintenance/btrfs-balance.sh IOSchedulingClass=idle CPUSchedulingPolicy=idle diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.4/btrfs-balance.sh new/btrfsmaintenance-0.4.1/btrfs-balance.sh --- old/btrfsmaintenance-0.4/btrfs-balance.sh 2018-01-15 17:40:06.385987125 +0100 +++ new/btrfsmaintenance-0.4.1/btrfs-balance.sh 2018-03-15 18:49:36.413244400 +0100 @@ -15,7 +15,7 @@ fi LOGIDENTIFIER='btrfs-balance' -. $(dirname $(realpath $0))/btrfsmaintenance-functions +. $(dirname $(realpath "$0"))/btrfsmaintenance-functions { evaluate_auto_mountpoint BTRFS_BALANCE_MOUNTPOINTS @@ -24,7 +24,7 @@ exec 2>&1 # redirect stderr to stdout to catch all output to log destination for MM in $BTRFS_BALANCE_MOUNTPOINTS; do IFS="$OIFS" - if [ $(stat -f --format=%T "$MM") != "btrfs" ]; then + if ! is_btrfs "$MM"; then echo "Path $MM is not btrfs, skipping" continue fi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.4/btrfs-defrag-plugin.py new/btrfsmaintenance-0.4.1/btrfs-defrag-plugin.py --- old/btrfsmaintenance-0.4/btrfs-defrag-plugin.py 2018-01-15 17:40:06.381987125 +0100 +++ new/btrfsmaintenance-0.4.1/btrfs-defrag-plugin.py 2018-03-15 18:49:36.409244400 +0100 @@ -3,28 +3,33 @@ # This plugin defragments rpm files after update. # # If the filesystem is btrfs, run defrag command in the RPM database -# folder, set the desired extent size to 64MiB, but this may change in the +# folder, set the desired extent size to 32MiB, but this may change in the # result depending on the fragmentation of the free space. # -# Why 64MB: +# Why 32MiB: # - the worst fragmentation has been observed on Packages # - this can grow up to several hundred of megabytes # - the file gets updated at random places -# - although the file will be composed of several extents, it's faster to +# - although the file will be composed of many extents, it's faster to # merge only the extents that affect some portions of the file, instead # of the whole file; the difference is negligible # - due to the free space fragmentation over time, it's hard to find # contiguous space, the bigger the extent is, the worse and the extent # size hint is not reached anyway -from sys import stderr +import sys +if sys.version_info[0] >= 3: + from builtins import str + popen_kwargs = { 'encoding': 'ascii' } +else: + popen_kwargs = { } from zypp_plugin import Plugin import subprocess DEBUG=False -EXTENT_SIZE=64*1024*1024 +EXTENT_SIZE=32*1024*1024 LOGFILE='/tmp/btrfs-defrag-plugin.log' -PATH=subprocess.check_output(["rpm", "--eval", "%_dbpath"]).strip() +PATH=subprocess.check_output(["rpm", "--eval", "%_dbpath"], **popen_kwargs).strip() def dbg(args): if not DEBUG: return @@ -34,7 +39,7 @@ f.close() def qx(args): - out=subprocess.Popen(args, shell=True, stdout=subprocess.PIPE).stdout + out=subprocess.Popen(args, shell=True, stdout=subprocess.PIPE, **popen_kwargs).stdout outstr="".join(out.readlines()) out.close() return outstr @@ -59,6 +64,11 @@ if DEBUG: dbg('--- Fragmentation before') dbg(qx('filefrag %s/*' % (PATH))) + # defrag options: + # - verbose + # - recursive + # - flush each file before going to the next one + # - set the extent target hint ret = qx('btrfs filesystem defragment -v -f -r -t %s "%s"' % \ (str(EXTENT_SIZE), PATH)) if DEBUG: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.4/btrfs-defrag.service new/btrfsmaintenance-0.4.1/btrfs-defrag.service --- old/btrfsmaintenance-0.4/btrfs-defrag.service 2018-01-15 17:40:06.389987125 +0100 +++ new/btrfsmaintenance-0.4.1/btrfs-defrag.service 2018-03-15 18:49:36.417244400 +0100 @@ -4,7 +4,7 @@ After=fstrim.service btrfs-trim.service btrfs-scrub.service [Service] -Type=oneshot +Type=simple ExecStart=/usr/share/btrfsmaintenance/btrfs-defrag.sh IOSchedulingClass=idle CPUSchedulingPolicy=idle diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.4/btrfs-defrag.sh new/btrfsmaintenance-0.4.1/btrfs-defrag.sh --- old/btrfsmaintenance-0.4/btrfs-defrag.sh 2018-01-15 17:40:06.385987125 +0100 +++ new/btrfsmaintenance-0.4.1/btrfs-defrag.sh 2018-03-15 18:49:36.413244400 +0100 @@ -22,7 +22,7 @@ exec 2>&1 # redirect stderr to stdout to catch all output to log destination for P in $BTRFS_DEFRAG_PATHS; do IFS="$OIFS" - if [ $(stat -f --format=%T "$P") != "btrfs" ]; then + if ! is_btrfs "$P"; then echo "Path $P is not btrfs, skipping" continue fi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.4/btrfs-scrub.service new/btrfsmaintenance-0.4.1/btrfs-scrub.service --- old/btrfsmaintenance-0.4/btrfs-scrub.service 2018-01-15 17:40:06.389987125 +0100 +++ new/btrfsmaintenance-0.4.1/btrfs-scrub.service 2018-03-15 18:49:36.417244400 +0100 @@ -4,7 +4,7 @@ After=fstrim.service btrfs-trim.service [Service] -Type=oneshot +Type=simple ExecStart=/usr/share/btrfsmaintenance/btrfs-scrub.sh IOSchedulingClass=idle CPUSchedulingPolicy=idle diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.4/btrfs-scrub.sh new/btrfsmaintenance-0.4.1/btrfs-scrub.sh --- old/btrfsmaintenance-0.4/btrfs-scrub.sh 2018-01-15 17:40:06.385987125 +0100 +++ new/btrfsmaintenance-0.4.1/btrfs-scrub.sh 2018-03-15 18:49:36.413244400 +0100 @@ -15,7 +15,7 @@ fi LOGIDENTIFIER='btrfs-scrub' -. $(dirname $(realpath $0))/btrfsmaintenance-functions +. $(dirname $(realpath "$0"))/btrfsmaintenance-functions readonly= if [ "$BTRFS_SCRUB_READ_ONLY" = "true" ]; then @@ -36,7 +36,7 @@ for MNT in $BTRFS_SCRUB_MOUNTPOINTS; do IFS="$OIFS" echo "Running scrub on $MNT" - if [ $(stat -f --format=%T "$MNT") != "btrfs" ]; then + if ! is_btrfs "$MNT"; then echo "Path $MNT is not btrfs, skipping" continue fi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.4/btrfs-trim.service new/btrfsmaintenance-0.4.1/btrfs-trim.service --- old/btrfsmaintenance-0.4/btrfs-trim.service 2018-01-15 17:40:06.389987125 +0100 +++ new/btrfsmaintenance-0.4.1/btrfs-trim.service 2018-03-15 18:49:36.417244400 +0100 @@ -4,7 +4,7 @@ Conflicts=fstrim.service [Service] -Type=oneshot +Type=simple ExecStart=/usr/share/btrfsmaintenance/btrfs-trim.sh IOSchedulingClass=idle CPUSchedulingPolicy=idle diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.4/btrfs-trim.sh new/btrfsmaintenance-0.4.1/btrfs-trim.sh --- old/btrfsmaintenance-0.4/btrfs-trim.sh 2018-01-15 17:40:06.385987125 +0100 +++ new/btrfsmaintenance-0.4.1/btrfs-trim.sh 2018-03-15 18:49:36.413244400 +0100 @@ -15,7 +15,7 @@ fi LOGIDENTIFIER='btrfs-trim' -. $(dirname $(realpath $0))/btrfsmaintenance-functions +. $(dirname $(realpath "$0"))/btrfsmaintenance-functions { evaluate_auto_mountpoint BTRFS_TRIM_MOUNTPOINTS @@ -24,7 +24,7 @@ exec 2>&1 # redirect stderr to stdout to catch all output to log destination for MNT in $BTRFS_TRIM_MOUNTPOINTS; do IFS="$OIFS" - if [ $(stat -f --format=%T "$MNT") != "btrfs" ]; then + if ! is_btrfs "$MNT"; then echo "Path $MNT is not btrfs, skipping" continue fi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.4/btrfsmaintenance-functions new/btrfsmaintenance-0.4.1/btrfsmaintenance-functions --- old/btrfsmaintenance-0.4/btrfsmaintenance-functions 2018-01-15 17:40:06.397987125 +0100 +++ new/btrfsmaintenance-0.4.1/btrfsmaintenance-functions 2018-03-15 18:49:36.433244400 +0100 @@ -11,7 +11,7 @@ # are put into the parameter variable evaluate_auto_mountpoint() { MOUNTPOINTSVAR=\$"$1" - if [ "$(eval "expr \"$MOUNTPOINTSVAR\"")" = "auto" ]; then + if [ "$(eval expr \"$MOUNTPOINTSVAR\")" = "auto" ]; then local BTRFS_DEVICES="" local DEVICE="" local MNT="" @@ -66,3 +66,13 @@ fi return 0 } + +# function: is_btrfs +# parameter: path to a mounted filesystem +# +# check if filesystem is a btrfs +is_btrfs() { + local FS=$(stat -f --format=%T "$1") + [ "$FS" = "btrfs" ] && return 0 + return 1 +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/btrfsmaintenance-0.4/btrfsmaintenance-refresh-cron.sh new/btrfsmaintenance-0.4.1/btrfsmaintenance-refresh-cron.sh --- old/btrfsmaintenance-0.4/btrfsmaintenance-refresh-cron.sh 2018-01-15 17:40:06.385987125 +0100 +++ new/btrfsmaintenance-0.4.1/btrfsmaintenance-refresh-cron.sh 2018-03-15 18:49:36.413244400 +0100 @@ -74,10 +74,10 @@ for SCRIPT in btrfs-scrub btrfs-defrag btrfs-balance btrfs-trim; do case "$BTRFS_TIMER_IMPLEMENTATION" in systemd-timer) - refresh_timer uninstall ${SCRIPT} + refresh_timer uninstall "${SCRIPT}" ;; *) - refresh_cron uninstall ${SCRIPT}.sh + refresh_cron uninstall "${SCRIPT}.sh" ;; esac done @@ -88,7 +88,7 @@ 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 + refresh_cron uninstall "${SCRIPT}.sh" done refresh_timer "$BTRFS_SCRUB_PERIOD" btrfs-scrub refresh_timer "$BTRFS_DEFRAG_PERIOD" btrfs-defrag
