From owner-svn-src-all@freebsd.org Thu Oct 26 15:28:19 2017 Return-Path: Delivered-To: svn-src-all@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 82D5FE4C3E7; Thu, 26 Oct 2017 15:28:19 +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 5E95B81FAC; Thu, 26 Oct 2017 15:28:19 +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 v9QFSIeX017945; Thu, 26 Oct 2017 15:28:18 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9QFSIDX017941; Thu, 26 Oct 2017 15:28:18 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201710261528.v9QFSIDX017941@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Thu, 26 Oct 2017 15:28:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r325011 - in head: cddl/usr.sbin/zfsd lib/libdevdctl X-SVN-Group: head X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in head: cddl/usr.sbin/zfsd lib/libdevdctl X-SVN-Commit-Revision: 325011 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Oct 2017 15:28:19 -0000 Author: asomers Date: Thu Oct 26 15:28:18 2017 New Revision: 325011 URL: https://svnweb.freebsd.org/changeset/base/325011 Log: zfsd should be able to online an L2ARC that disappears and returns Previously, this didn't work because L2ARC devices' labels don't contain pool GUIDs. Modify zfsd so that the pool GUID won't be required: lib/libdevdctl/guid.h Change INVALID_GUID from a uint64_t constant to a function that returns an invalid Guid object. Remove the void constructor. Nothing uses it, and it violates RAII. cddl/usr.sbin/zfsd/case_file.h cddl/usr.sbin/zfsd/case_file.cc Allow CaseFile::Find to match a CaseFile based on Vdev GUID alone. In CaseFile::ReEvaluate, attempt to online devices even if the newly arrived device has no pool GUID. cddl/usr.sbin/zfsd/vdev_iterator.cc Iterate through a pool's cache devices as well as its regular devices. Reported by: avg Reviewed by: avg MFC after: 3 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D12791 Modified: head/cddl/usr.sbin/zfsd/case_file.cc head/cddl/usr.sbin/zfsd/case_file.h head/cddl/usr.sbin/zfsd/vdev_iterator.cc head/lib/libdevdctl/guid.h Modified: head/cddl/usr.sbin/zfsd/case_file.cc ============================================================================== --- head/cddl/usr.sbin/zfsd/case_file.cc Thu Oct 26 13:23:13 2017 (r325010) +++ head/cddl/usr.sbin/zfsd/case_file.cc Thu Oct 26 15:28:18 2017 (r325011) @@ -102,7 +102,8 @@ CaseFile::Find(Guid poolGUID, Guid vdevGUID) for (CaseFileList::iterator curCase = s_activeCases.begin(); curCase != s_activeCases.end(); curCase++) { - if ((*curCase)->PoolGUID() != poolGUID + if (((*curCase)->PoolGUID() != poolGUID + && Guid::InvalidGuid() != poolGUID) || (*curCase)->VdevGUID() != vdevGUID) continue; @@ -268,7 +269,8 @@ CaseFile::ReEvaluate(const string &devPath, const stri } if (vdev != NULL - && vdev->PoolGUID() == m_poolGUID + && ( vdev->PoolGUID() == m_poolGUID + || vdev->PoolGUID() == Guid::InvalidGuid()) && vdev->GUID() == m_vdevGUID) { zpool_vdev_online(pool, vdev->GUIDString().c_str(), Modified: head/cddl/usr.sbin/zfsd/case_file.h ============================================================================== --- head/cddl/usr.sbin/zfsd/case_file.h Thu Oct 26 13:23:13 2017 (r325010) +++ head/cddl/usr.sbin/zfsd/case_file.h Thu Oct 26 15:28:18 2017 (r325011) @@ -89,6 +89,8 @@ class CaseFile (public) * \brief Find a CaseFile object by a vdev's pool/vdev GUID tuple. * * \param poolGUID Pool GUID for the vdev of the CaseFile to find. + * If InvalidGuid, then only match the vdev GUID + * instead of both pool and vdev GUIDs. * \param vdevGUID Vdev GUID for the vdev of the CaseFile to find. * * \return If found, a pointer to a valid CaseFile object. Modified: head/cddl/usr.sbin/zfsd/vdev_iterator.cc ============================================================================== --- head/cddl/usr.sbin/zfsd/vdev_iterator.cc Thu Oct 26 13:23:13 2017 (r325010) +++ head/cddl/usr.sbin/zfsd/vdev_iterator.cc Thu Oct 26 15:28:18 2017 (r325011) @@ -76,7 +76,9 @@ void VdevIterator::Reset() { nvlist_t *rootVdev; + nvlist **cache_child; int result; + uint_t cache_children; result = nvlist_lookup_nvlist(m_poolConfig, ZPOOL_CONFIG_VDEV_TREE, @@ -85,6 +87,13 @@ VdevIterator::Reset() throw ZfsdException(m_poolConfig, "Unable to extract " "ZPOOL_CONFIG_VDEV_TREE from pool."); m_vdevQueue.assign(1, rootVdev); + result = nvlist_lookup_nvlist_array(rootVdev, + ZPOOL_CONFIG_L2CACHE, + &cache_child, + &cache_children); + if (result == 0) + for (uint_t c = 0; c < cache_children; c++) + m_vdevQueue.push_back(cache_child[c]); } nvlist_t * Modified: head/lib/libdevdctl/guid.h ============================================================================== --- head/lib/libdevdctl/guid.h Thu Oct 26 13:23:13 2017 (r325010) +++ head/lib/libdevdctl/guid.h Thu Oct 26 15:28:18 2017 (r325011) @@ -62,9 +62,9 @@ class Guid { public: /* Constructors */ - Guid(); Guid(uint64_t guid); Guid(const std::string &guid); + static Guid InvalidGuid(); /* Assignment */ Guid& operator=(const Guid& rhs); @@ -80,23 +80,24 @@ class Guid operator uint64_t() const; operator bool() const; - static const uint64_t INVALID_GUID = 0; protected: + static const uint64_t INVALID_GUID = 0; + /* The integer value of the GUID. */ uint64_t m_GUID; }; //- Guid Inline Public Methods ------------------------------------------------ inline -Guid::Guid() - : m_GUID(INVALID_GUID) +Guid::Guid(uint64_t guid) + : m_GUID(guid) { } -inline -Guid::Guid(uint64_t guid) - : m_GUID(guid) +inline Guid +Guid::InvalidGuid() { + return (Guid(INVALID_GUID)); } inline Guid&