From owner-svn-src-projects@freebsd.org Wed Dec 16 22:01:27 2015 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7CAAAA498A0 for ; Wed, 16 Dec 2015 22:01:27 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 54B4E1EED; Wed, 16 Dec 2015 22:01:27 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tBGM1QDG090216; Wed, 16 Dec 2015 22:01:26 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tBGM1Qf3090214; Wed, 16 Dec 2015 22:01:26 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201512162201.tBGM1Qf3090214@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Wed, 16 Dec 2015 22:01:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r292378 - in projects/zfsd/head: cddl/sbin/zfsd tests/sys/cddl/zfs/tests/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.20 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: Wed, 16 Dec 2015 22:01:27 -0000 Author: asomers Date: Wed Dec 16 22:01:26 2015 New Revision: 292378 URL: https://svnweb.freebsd.org/changeset/base/292378 Log: zfsd(8) should activate spares at startup cddl/sbin/zfsd/zfsd.cc On startup, or after the devd event buffer overflows, generate synthetic config_sync events for every zpool. This will force any open casefiles on those pools to be reevaluated. This fixes a bug where zfsd wouldn't activate a spare for disks that failed while zfsd was not running, or if the disk failure generated an event storm that caused zfsd to drop devd events. tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh Clear the expected failure Sponsored by: Spectra Logic Corp Modified: projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh Modified: projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc ============================================================================== --- projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc Wed Dec 16 21:58:48 2015 (r292377) +++ projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc Wed Dec 16 22:01:26 2015 (r292378) @@ -212,14 +212,48 @@ ZfsDaemon::VdevAddCaseFile(Vdev &vdev, v void ZfsDaemon::BuildCaseFiles() { - /* Add CaseFiles for vdevs with issues. */ ZpoolList zpl; + ZpoolList::iterator pool; - for (ZpoolList::iterator pool = zpl.begin(); pool != zpl.end(); pool++) + /* Add CaseFiles for vdevs with issues. */ + for (pool = zpl.begin(); pool != zpl.end(); pool++) VdevIterator(*pool).Each(VdevAddCaseFile, NULL); /* De-serialize any saved cases. */ CaseFile::DeSerialize(); + + /* Simulate config_sync events to force CaseFile reevaluation */ + for (pool = zpl.begin(); pool != zpl.end(); pool++) { + char evString[160]; + Event *event; + nvlist_t *config; + uint64_t poolGUID; + const char *poolname; + + poolname = zpool_get_name(*pool); + config = zpool_get_config(*pool, NULL); + if (config == NULL) { + syslog(LOG_ERR, "ZFSDaemon::BuildCaseFiles: Could not " + "find pool config for pool %s", poolname); + continue; + } + if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID, + &poolGUID) != 0) { + syslog(LOG_ERR, "ZFSDaemon::BuildCaseFiles: Could not " + "find pool guid for pool %s", poolname); + continue; + } + + + snprintf(evString, 160, "!system=ZFS subsystem=ZFS " + "type=misc.fs.zfs.config_sync sub_type=synthesized " + "pool_name=%s pool_guid=%lu\n", poolname, poolGUID); + event = Event::CreateEvent(GetFactory(), string(evString)); + if (event != NULL) { + event->Process(); + delete event; + } + } } void @@ -254,10 +288,11 @@ ZfsDaemon::RescanSystem() string evString(evStart + pp->lg_name + "\n"); event = Event::CreateEvent(GetFactory(), evString); - if (event != NULL) + if (event != NULL) { if (event->Process()) SaveEvent(*event); delete event; + } } } } Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh ============================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh Wed Dec 16 21:58:48 2015 (r292377) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh Wed Dec 16 22:01:26 2015 (r292378) @@ -326,7 +326,6 @@ zfsd_hotspare_007_pos_head() } zfsd_hotspare_007_pos_body() { - atf_expect_fail "P3_28731: ZFSD will not replace a vdev that dissappears while power is off" export TESTCASE_ID=$(echo $(atf_get ident) | cksum -o 2 | cut -f 1 -d " ") . $(atf_get_srcdir)/../../include/default.cfg . $(atf_get_srcdir)/../hotspare/hotspare.kshlib