[pve-devel] [PATCH zfsonlinux 2/4] cron: Do not error if already scrubbing

Stoiko Ivanov s.ivanov at proxmox.com
Fri Mar 20 17:28:41 CET 2020


From: Richard Laager <rlaager at wiktel.com>

If a pool is already scrubbing, zpool scrub will return an error.  This
breaks the cron scrub script.  It outputs that error and then does not
scrub any further pools.

This change checks to see if the pool is scrubbing before attempting to
start a scrub.  This addresses long-running scrubs.  Note that a
"long-running" scrub here is not necessarily a month long.  If the
system is shut off or the pool is exported, the scrub will resume later.

(cherry picked from 41e457da7bfc837a52f3389cb6961bc6737b874d [0])

[0]  https://salsa.debian.org/zfsonlinux-team/zfs.git

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 debian/tree/zfsutils-linux/usr/lib/zfs-linux/scrub | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/debian/tree/zfsutils-linux/usr/lib/zfs-linux/scrub b/debian/tree/zfsutils-linux/usr/lib/zfs-linux/scrub
index 29b77096..38f071af 100755
--- a/debian/tree/zfsutils-linux/usr/lib/zfs-linux/scrub
+++ b/debian/tree/zfsutils-linux/usr/lib/zfs-linux/scrub
@@ -1,9 +1,12 @@
 #!/bin/sh -eu
 
-# Scrub all healthy pools.
+# Scrub all healthy pools that are not already scrubbing.
 zpool list -H -o health,name 2>&1 | \
 	awk 'BEGIN {FS="\t"} {if ($1 ~ /^ONLINE/) print $2}' | \
 while read pool
 do
-	zpool scrub "$pool"
+	if ! zpool status "$pool" | grep -q "scrub in progress"
+	then
+		zpool scrub "$pool"
+	fi
 done
-- 
2.20.1





More information about the pve-devel mailing list