From: Alan J. Pippin Date: Tue, 18 Mar 2008 02:03:10 +0000 (-0600) Subject: Fixed a race condition that could lead to 2 scrubs running simultaneously. X-Git-Url: http://git.pippins.net/embedvideo/.git/static/%7Blink_ppi%7D?a=commitdiff_plain;h=84dd3e2aec7bf7c4c61a3cc0deef0e37e2ee3412;p=zfs-ubuntu%2F.git Fixed a race condition that could lead to 2 scrubs running simultaneously. Added logging support. --- diff --git a/zfs-scrub b/zfs-scrub index f022a54..2bff3d3 100755 --- a/zfs-scrub +++ b/zfs-scrub @@ -7,6 +7,7 @@ # This serializes the zfs scrub process for each pool. maxsleeptime=360 +logfile=/var/log/zfs-scrub.log for i in tank storage do @@ -25,7 +26,9 @@ do fi done - echo "Scrubing zfs pool $i" + date=`date` + echo "$date: Scrub started for zfs pool $i" >> $logfile /sbin/zpool scrub $i + sleep 60 done diff --git a/zfs-scrub-usb-drive b/zfs-scrub-usb-drive index 8a07e5c..1b73505 100755 --- a/zfs-scrub-usb-drive +++ b/zfs-scrub-usb-drive @@ -8,6 +8,7 @@ maxsleeptime=360 mailto=root +logfile=/var/log/zfs-scrub.log for i in backups do @@ -26,8 +27,9 @@ do fi done - echo "Scrubing zfs pool $i" - /usr/local/etc/bin/usb-drive-power on + date=`date` + echo "$date: Scrub started for zfs pool $i" >> $logfile + /usr/local/etc/bin/usb-drive-power on >> /dev/null /sbin/zpool import $i /sbin/zpool scrub $i @@ -45,6 +47,9 @@ do fi done + date=`date` + echo "$date: Scrub completed for zfs pool $i" >> $logfile + # Check for any scrub errors /sbin/zpool status $i | grep scrub: | grep "with 0 errors" > /dev/null 2>&1 if [ $? != 0 ]; then @@ -54,7 +59,7 @@ do # Power off the USB drive /sbin/zpool export $i - /usr/local/etc/bin/usb-drive-power off + /usr/local/etc/bin/usb-drive-power off >> /dev/null done