From owner-svn-src-projects@FreeBSD.ORG Mon Oct 14 21:23:59 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 2A493D7D; Mon, 14 Oct 2013 21:23:59 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id F19A92933; Mon, 14 Oct 2013 21:23:58 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9ELNwCx067747; Mon, 14 Oct 2013 21:23:58 GMT (envelope-from asomers@svn.freebsd.org) Received: (from asomers@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9ELNwiN067746; Mon, 14 Oct 2013 21:23:58 GMT (envelope-from asomers@svn.freebsd.org) Message-Id: <201310142123.r9ELNwiN067746@svn.freebsd.org> From: Alan Somers Date: Mon, 14 Oct 2013 21:23:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r256458 - projects/zfsd/head/cddl/sbin/zfsd X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Oct 2013 21:23:59 -0000 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++) {