various updates
[distro-setup] / btrfsmaint
index 6423e26808e5da8a1279472a77962ef841e89284..d2263257d412b4da2d9e37e5c1678641e301e8f6 100755 (executable)
@@ -46,7 +46,8 @@ usage() {
 Usage: ${0##*/} [ARGS]
 Do btrfs maintence or stop if xprintidle shows a user
 
-force  Run regardless of user idle status on all disks.
+force  Run regardless of user idle status on all disks and do scrub
+       regardless of when it was last run.
 check  Only check if an existing maintence should be cancelled due to
          nonidle user. Also, runs in a loop every 20 seconds for 10
          minutes.
@@ -124,7 +125,7 @@ From: root@$HOSTNAME.b8.nz
 To: alerts@iankelling.org
 Subject: btrfsmaintstop: btrfs dev stats -c $mnt
 
-$(diff -u $stats_path $tmp)
+$(diff -u $stats_path $tmp ||:)
 EOF
           mv $stats_path $stats_path.1
           cat $tmp >$stats_path
@@ -175,7 +176,7 @@ EOF
           sed -rn 's/^\s*scrub started at (.*) and finished.*/\1/p'
           )
     fi
-    if [[ $date ]]; then
+    if ! $force && [[ $date ]]; then
       if $dryrun; then
         echo "$0: last scrub finish for $mnt: $date"
       fi
@@ -190,8 +191,8 @@ EOF
         continue
       fi
     fi
-    # -c 2 -n 4 is from btrfsmaintenance, does ionice
-    e btrfs scrub start -Bd -c 2 -n 4 $mnt
+    # btrfsmaintenance does -c 2 -n 4, but I want lowest pri.
+    e btrfs scrub start -Bd -c 3 $mnt
 
     # We normally only do one disk since this is meant to be run while I sleep
     # and if we try to do all disks, we invariably end up doing a scrub still