Date: Fri, 1 Jul 2011 06:05:19 GMT From: Josh Carroll <josh.carroll@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: misc/158551: Enhance periodic 800.scrub-zfs script to handle scrub -s Message-ID: <201107010605.p6165JSh069125@red.freebsd.org> Resent-Message-ID: <201107010610.p616A5K5037647@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 158551 >Category: misc >Synopsis: Enhance periodic 800.scrub-zfs script to handle scrub -s >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Jul 01 06:10:05 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Josh Carroll >Release: 8.2-RELEASE-p2 >Organization: n/a >Environment: FreeBSD pflog.net 8.2-RELEASE-p2 FreeBSD 8.2-RELEASE-p2 #0 r223479M: Mon Jun 27 11:14:32 PDT 2011 root@pflog.net:/usr/obj/usr/src/sys/PFLOG amd64 >Description: Currently, the periodic script to scrub all zpools looks at the last scrub date via zpool history, but it does not consider cases where a scrub was stopped with zpool scrub -s. For example, consider the zpool history of all scrubs for a zpool like this: 2011-06-05.03:08:27 zpool scrub data 2011-06-13.03:03:50 zpool scrub data 2011-06-19.22:28:49 zpool scrub data 2011-06-19.22:41:49 zpool scrub -s data With the existing logic, the script would consider the last scrub date to be "2011-06-19.22:28:49". However, that particular scrub was stopped, so the last fully completed scrub was actually on "2011-06-13.03:03:50". I have updated the 800.scrub-zfs periodic script to understand when a scrub operation was stopped. As of now, scrub -s will not generate a history entry if a zpool scrub -s is issued while no scrub is in progress. So there is no risk of two scrub -s appearing sequentially. The attached patch handles more than one scrub/scrub -s in a row, e.g. something like this: 2011-06-05.03:08:27 zpool scrub data 2011-06-13.03:03:50 zpool scrub data 2011-06-19.22:28:49 zpool scrub data 2011-06-19.22:41:49 zpool scrub -s data 2011-06-25.03:08:27 zpool scrub data 2011-06-29.03:11:49 zpool scrub -s data It would properly set the last successful scrub date to "2011-06-13.03:03:50". The attached patch is against the 800.scrub-zfs from HEAD, but it should apply cleanly to 8.2-RELEASE and 8.2-STABLE as well. Thanks! Josh >How-To-Repeat: Issue a zpool scrub <poolname> then zpool scrub -s <poolname> and the periodic script will think the last successful scrub was today, instead of the last uninterrupted scrub. >Fix: See attached patch. Patch attached with submission follows: --- 800.scrub-zfs.orig 2011-06-30 22:52:01.291279403 -0700 +++ 800.scrub-zfs 2011-06-30 22:52:08.707039940 -0700 @@ -51,10 +51,11 @@ _pool_threshold=${daily_scrub_zfs_default_threshold} fi - _last_scrub=$(zpool history ${pool} | \ - egrep "^[0-9\.\:\-]{19} zpool scrub ${pool}\$" | tail -1 |\ - cut -d ' ' -f 1) - if [ -z "${_last_scrub}" ]; then + _last_successful_scrub=$(zpool history ${pool} | \ + egrep "^[0-9\.\:\-]{19} zpool scrub( -s | )${pool}\$" | \ + awk 'BEGIN { scrub1="" }; /zpool scrub -s/{ scrub1=scrub2 }; \ + /zpool scrub/ && ! / -s /{ scrub2=scrub1; scrub1=$1 }; END { print scrub1 }') + if [ -z "${_last_successful_scrub}" ]; then # creation time of the pool if no scrub was done _last_scrub=$(zpool history ${pool} | \ sed -ne '2s/ .*$//p') >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107010605.p6165JSh069125>