svn commit: r256458 - projects/zfsd/head/cddl/sbin/zfsd

Alan Somers asomers at FreeBSD.org
Mon Oct 14 21:23:59 UTC 2013


Author: asomers
Date: Mon Oct 14 21:23:58 2013
New Revision: 256458
URL: http://svnweb.freebsd.org/changeset/base/256458

Log:
  zfsd will attempt to activate a hotspare in response to a drive becoming
  DEGRADED or FAULTED.
  
  	case_file.cc
  		Attempt to activate a spare whenver we get a
  		"resource.fs.zfs.statechange" event and the vdev state is
  		either DEGRADED or FAULTED.
  
  Submitted by:	alans
  Approved by:	ken (mentor)
  Sponsored by:	Spectra Logic Corporation

Modified:
  projects/zfsd/head/cddl/sbin/zfsd/case_file.cc

Modified: projects/zfsd/head/cddl/sbin/zfsd/case_file.cc
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/case_file.cc	Mon Oct 14 21:21:05 2013	(r256457)
+++ projects/zfsd/head/cddl/sbin/zfsd/case_file.cc	Mon Oct 14 21:23:58 2013	(r256458)
@@ -356,8 +356,19 @@ CaseFile::ReEvaluate(const ZfsEvent &eve
 		 * close the case
 		 */
 		consumed = spare_activated;
-	} else if (event.Value("class") == "ereport.fs.zfs.io"
-		|| event.Value("class") == "ereport.fs.zfs.checksum") {
+	} else if (event.Value("class") == "resource.fs.zfs.statechange") {
+		/*
+		 * If this vdev is DEGRADED or FAULTED, try to activate a
+		 * hotspare.  Otherwise, ignore the event
+		 */
+		if (VdevState() == VDEV_STATE_FAULTED ||
+		    VdevState() == VDEV_STATE_DEGRADED)
+			consumed = ActivateSpare();
+		else
+			consumed = true;
+	}
+	else if (event.Value("class") == "ereport.fs.zfs.io" ||
+	         event.Value("class") == "ereport.fs.zfs.checksum") {
 
 		m_tentativeEvents.push_front(event.DeepCopy());
 		RegisterCallout(event);
@@ -370,6 +381,10 @@ CaseFile::ReEvaluate(const ZfsEvent &eve
 }
 
 
+/*
+ * TODO: ensure that we don't activate a spare for a vdev that is already being
+ * replaced by another spare.
+ */
 bool
 CaseFile::ActivateSpare() {
 	nvlist_t	*config, *nvroot;
@@ -405,6 +420,8 @@ CaseFile::ActivateSpare() {
 				   &nspares);
 	if (nspares == 0) {
 		/* The pool has no spares configured */
+		syslog(LOG_INFO, "CaseFile::ActivateSpare: "
+		       "No spares available for pool %s", poolname);
 		return (false);
 	}
 	for (i = 0; i < nspares; i++) {


More information about the svn-src-projects mailing list