svn commit: r326321 - in stable/11: cddl/usr.sbin/zfsd lib/libdevdctl

Alan Somers asomers at FreeBSD.org
Tue Nov 28 16:52:40 UTC 2017


Author: asomers
Date: Tue Nov 28 16:52:38 2017
New Revision: 326321
URL: https://svnweb.freebsd.org/changeset/base/326321

Log:
  MFC r325011, r325016
  
  r325011:
  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
  Sponsored by:	Spectra Logic Corp
  Differential Revision:	https://reviews.freebsd.org/D12791
  
  r325016:
  Partially revert r325011: restore Guid's default constructor
  
  Reported by:	ohartmann
  X-MFC-With:	325011
  Sponsored by:	Spectra Logic Corp

Modified:
  stable/11/cddl/usr.sbin/zfsd/case_file.cc
  stable/11/cddl/usr.sbin/zfsd/case_file.h
  stable/11/cddl/usr.sbin/zfsd/vdev_iterator.cc
  stable/11/lib/libdevdctl/guid.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/usr.sbin/zfsd/case_file.cc
==============================================================================
--- stable/11/cddl/usr.sbin/zfsd/case_file.cc	Tue Nov 28 16:49:16 2017	(r326320)
+++ stable/11/cddl/usr.sbin/zfsd/case_file.cc	Tue Nov 28 16:52:38 2017	(r326321)
@@ -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: stable/11/cddl/usr.sbin/zfsd/case_file.h
==============================================================================
--- stable/11/cddl/usr.sbin/zfsd/case_file.h	Tue Nov 28 16:49:16 2017	(r326320)
+++ stable/11/cddl/usr.sbin/zfsd/case_file.h	Tue Nov 28 16:52:38 2017	(r326321)
@@ -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: stable/11/cddl/usr.sbin/zfsd/vdev_iterator.cc
==============================================================================
--- stable/11/cddl/usr.sbin/zfsd/vdev_iterator.cc	Tue Nov 28 16:49:16 2017	(r326320)
+++ stable/11/cddl/usr.sbin/zfsd/vdev_iterator.cc	Tue Nov 28 16:52:38 2017	(r326321)
@@ -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: stable/11/lib/libdevdctl/guid.h
==============================================================================
--- stable/11/lib/libdevdctl/guid.h	Tue Nov 28 16:49:16 2017	(r326320)
+++ stable/11/lib/libdevdctl/guid.h	Tue Nov 28 16:52:38 2017	(r326321)
@@ -62,9 +62,13 @@ class Guid
 {
 public:
 	/* Constructors */
+	/* Default constructor: an Invalid guid */
 	Guid();
+	/* Construct a guid from a provided integer */
 	Guid(uint64_t guid);
+	/* Construct a guid from a string in base 8, 10, or 16 */
 	Guid(const std::string &guid);
+	static Guid InvalidGuid();
 
 	/* Assignment */
 	Guid& operator=(const Guid& rhs);
@@ -80,8 +84,9 @@ 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;
 };
@@ -97,6 +102,12 @@ inline
 Guid::Guid(uint64_t guid)
   : m_GUID(guid)
 {
+}
+
+inline Guid
+Guid::InvalidGuid()
+{
+	return (Guid(INVALID_GUID));
 }
 
 inline Guid&


More information about the svn-src-stable mailing list