Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Sep 2010 15:34:30 GMT
From:      Josh Paetzel <jpaetzel@FreeBSD.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/150228: [PATCH] /etc/periodic/daily/800.scrub-zfs errors with faulted zpools
Message-ID:  <201009021534.o82FYU0P050050@www.freebsd.org>
Resent-Message-ID: <201009021540.o82Fe6B1010056@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         150228
>Category:       bin
>Synopsis:       [PATCH] /etc/periodic/daily/800.scrub-zfs errors with faulted zpools
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 02 15:40:06 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Josh Paetzel
>Release:        9.0-CURRENT
>Organization:
>Environment:
FreeBSD tcbug.ixsystems.com 9.0-CURRENT FreeBSD 9.0-CURRENT #2: Mon Jul 12 22:22:49 CDT 2010     jpaetzel@ix.tcbug.org:/usr/obj/usr/src/sys/IX  amd64
>Description:
800.scrub-zfs is a periodic script you can enable to perform periodic scrubs of ZFS filesystems.  If you have faulted zpools the script generates sh errors due to some of the zpool commands generating no output.

Faulted zpools can happen for reasons other than hardware failure, for example if you use ZFS on removable devices when they are unplugged zpool status will show them as faulted.
>How-To-Repeat:
Put ZFS on a removable device, export and detach it from the system.
# echo 'daily_scrub_zfs_enable="YES"' >> /etc/periodic.conf
# /etc/periodic/daily/800.scrub-zfs
>Fix:
Apply attached patch

Patch attached with submission follows:

Index: 800.scrub-zfs
===================================================================
--- 800.scrub-zfs	(revision 212149)
+++ 800.scrub-zfs	(working copy)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD$
+# $FreeBSD: src/etc/periodic/daily/800.scrub-zfs,v 1.1 2010/06/15 08:58:16 netchild Exp $
 #
 
 # If there is a global system configuration file, suck it in.
@@ -24,13 +24,17 @@
 
 	for pool in ${daily_scrub_zfs_pools}; do
 		# sanity check
-		zpool list ${pool} >/dev/null 2>&1
+		_status=`zpool list ${pool} | sed -n -e '$p'` >/dev/null 2>&1
 		if [ $? -ne 0 ]; then
 			echo "   WARNING: pool '${pool}' specified in"
 			echo "            '/etc/periodic.conf:daily_scrub_zfs_pools'"
 			echo "            does not exist"
 			continue
 		fi
+		if echo ${_status} | grep FAULTED >/dev/null 2>&1; then
+			echo "Skipping faulted pool: ${pool}"
+			continue
+		fi
 
 		# successful only if there is at least one pool to scrub
 		rc=0


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009021534.o82FYU0P050050>