Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Oct 2013 21:21:05 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r256457 - projects/zfsd/head/cddl/sbin/zfsd
Message-ID:  <201310142121.r9ELL5xk067076@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Mon Oct 14 21:21:05 2013
New Revision: 256457
URL: http://svnweb.freebsd.org/changeset/base/256457

Log:
  Style, comment, and warning message improvements to zfsd.
  
  	* zfsd.h
  	  Clarified member documentation
  
  	* zfsd.cc
  	  Clarified warning message
  
  	* case_file.cc
  	  Omits a space before the { of a control block
  
  	* vdev_iterator.cc
  	* zfsd.cc
  	  Return statements must enclose their values in parenthesis
  
  	* dev_ctl_event.cc:
  	  Omit a space after flow control keywords
  
  	* case_file.cc:
  	* vdev_iterator.cc
  	* zfsd.cc
  	* case_file.h
  	* dev_ctl_event.h
  	* guid.h
  	* zfsd_exception.h
  	* zpool_list.h
  	* dev_ctl_event.cc
  	  Trailing whitespace
  
  	* zfsd.cc
  	* zpool_list.cc
  	  Braces around a single line statement following a control block
  
  Submitted by:	alans
  Approved by:	ken (mentor)
  Sponsored by:	Spectra Logic Corporation

Modified:
  projects/zfsd/head/cddl/sbin/zfsd/case_file.cc
  projects/zfsd/head/cddl/sbin/zfsd/case_file.h
  projects/zfsd/head/cddl/sbin/zfsd/dev_ctl_event.cc
  projects/zfsd/head/cddl/sbin/zfsd/dev_ctl_event.h
  projects/zfsd/head/cddl/sbin/zfsd/guid.h
  projects/zfsd/head/cddl/sbin/zfsd/vdev_iterator.cc
  projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc
  projects/zfsd/head/cddl/sbin/zfsd/zfsd.h
  projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.h
  projects/zfsd/head/cddl/sbin/zfsd/zpool_list.cc
  projects/zfsd/head/cddl/sbin/zfsd/zpool_list.h

Modified: projects/zfsd/head/cddl/sbin/zfsd/case_file.cc
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/case_file.cc	Mon Oct 14 21:08:31 2013	(r256456)
+++ projects/zfsd/head/cddl/sbin/zfsd/case_file.cc	Mon Oct 14 21:21:05 2013	(r256457)
@@ -202,7 +202,7 @@ CaseFile::ReEvaluate(const string &devPa
 		 */
 		syslog(LOG_INFO,
 		       "CaseFile::ReEvaluate(%s,%s) Pool/Vdev unconfigured.  "
-		       "Closing\n", 
+		       "Closing\n",
 		       PoolGUIDString().c_str(),
 		       VdevGUIDString().c_str());
 		Close();
@@ -308,7 +308,7 @@ CaseFile::ReEvaluate(const ZfsEvent &eve
 		 */
 		syslog(LOG_INFO,
 		       "CaseFile::ReEvaluate(%s,%s) Pool/Vdev unconfigured.  "
-		       "Closing\n", 
+		       "Closing\n",
 		       PoolGUIDString().c_str(),
 		       VdevGUIDString().c_str());
 		Close();
@@ -349,7 +349,7 @@ CaseFile::ReEvaluate(const ZfsEvent &eve
 		 */
 		ZfsDaemon::RequestSystemRescan();
 
-		/* 
+		/*
 		 * Consume the event if we successfully activated a spare.
 		 * Otherwise, leave it in the unconsumed events list so that the
 		 * future addition of a spare to this pool might be able to
@@ -394,7 +394,8 @@ CaseFile::ActivateSpare() {
 		       "config for pool %s", poolname);
 		return (false);
 	}
-	if (nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, &nvroot) != 0){
+	error = nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, &nvroot);
+	if (error != 0){
 		syslog(LOG_ERR, "CaseFile::ActivateSpare: Could not find vdev "
 		       "tree for pool %s", poolname);
 		return (false);
@@ -453,7 +454,7 @@ CaseFile::ActivateSpare() {
 
 void
 CaseFile::RegisterCallout(const DevCtlEvent &event)
-{   
+{
 	timeval now, countdown, elapsed, timestamp, zero, remaining;
 
 	gettimeofday(&now, 0);
@@ -484,7 +485,7 @@ CaseFile::CloseIfSolved()
 	if (m_events.empty()
 	 && m_tentativeEvents.empty()) {
 
-		/* 
+		/*
 		 * We currently do not track or take actions on
 		 * devices in the degraded or faulted state.
 		 * Once we have support for spare pools, we'll
@@ -774,7 +775,7 @@ CaseFile::Close()
 	syslog(LOG_INFO, "CaseFile(%s,%s) closed - State %s\n",
 	       PoolGUIDString().c_str(), VdevGUIDString().c_str(),
 	       zpool_state_to_name(VdevState(), VDEV_AUX_NONE));
-	
+
 	/*
 	 * Serialization of a Case with no event data, clears the
 	 * Serialization data for that event.
@@ -809,7 +810,7 @@ CaseFile::OnGracePeriodEnded()
 				       VDEV_AUX_ERR_EXCEEDED) == 0) {
 			syslog(LOG_INFO, "Degrading vdev(%s/%s)",
 			       PoolGUIDString().c_str(),
-			       VdevGUIDString().c_str()); 
+			       VdevGUIDString().c_str());
 			Close();
 			return;
 		}

Modified: projects/zfsd/head/cddl/sbin/zfsd/case_file.h
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/case_file.h	Mon Oct 14 21:08:31 2013	(r256456)
+++ projects/zfsd/head/cddl/sbin/zfsd/case_file.h	Mon Oct 14 21:21:05 2013	(r256457)
@@ -154,7 +154,7 @@ public:
 	 *                  the disk resource.
 	 * \param vdev      If the disk contains ZFS label information,
 	 *                  a pointer to the disk label's vdev object
-	 *                  data.  Otherwise NULL. 
+	 *                  data.  Otherwise NULL.
 	 *
 	 * \return  True if this event was consumed by this CaseFile.
 	 */
@@ -346,7 +346,7 @@ protected:
 	string		m_vdevPhysPath;
 
 	/**
-	 * \brief Callout activated when a grace period 
+	 * \brief Callout activated when a grace period
 	 */
 	Callout		m_tentativeTimer;
 };

Modified: projects/zfsd/head/cddl/sbin/zfsd/dev_ctl_event.cc
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/dev_ctl_event.cc	Mon Oct 14 21:08:31 2013	(r256456)
+++ projects/zfsd/head/cddl/sbin/zfsd/dev_ctl_event.cc	Mon Oct 14 21:21:05 2013	(r256457)
@@ -67,7 +67,7 @@ ParseException::ToString() const
 
 	result << "Parsing ";
 
-	switch(Type()) {
+	switch (Type()) {
 	case INVALID_FORMAT:
 		result << "invalid format ";
 		break;
@@ -131,7 +131,7 @@ DevCtlEvent::Init()
 	EventFactoryRecord *rec(s_factoryTable);
 	EventFactoryRecord *lastRec(s_factoryTable
 				  + NUM_ELEMENTS(s_factoryTable) - 1);
-		
+
 	for (; rec <= lastRec; rec++) {
 		EventFactoryKey key(rec->m_type, rec->m_subsystem);
 
@@ -434,10 +434,10 @@ DevfsEvent::IsWholeDev(const string &dev
 	/* alpha prefix followed only by digits. */
 	for (; i < devName.end() && !isdigit(*i); i++)
 		;
- 
+
 	if (i == devName.end())
 		return (false);
-	
+
 	for (; i < devName.end() && isdigit(*i); i++)
 		;
 

Modified: projects/zfsd/head/cddl/sbin/zfsd/dev_ctl_event.h
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/dev_ctl_event.h	Mon Oct 14 21:08:31 2013	(r256456)
+++ projects/zfsd/head/cddl/sbin/zfsd/dev_ctl_event.h	Mon Oct 14 21:21:05 2013	(r256457)
@@ -143,7 +143,7 @@ ParseException::ParseException(Type type
 }
 
 //- ParseException Inline Const Public Methods ---------------------------------
-inline ParseException::Type  
+inline ParseException::Type
 ParseException::GetType() const
 {
 	return (m_type);
@@ -271,7 +271,7 @@ public:
 	 */
 	void Log(int priority)			const;
 
-	/** 
+	/**
 	 * Create and return a fully independent clone
 	 * of this event.
 	 */

Modified: projects/zfsd/head/cddl/sbin/zfsd/guid.h
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/guid.h	Mon Oct 14 21:08:31 2013	(r256456)
+++ projects/zfsd/head/cddl/sbin/zfsd/guid.h	Mon Oct 14 21:21:05 2013	(r256457)
@@ -47,7 +47,7 @@
  *
  * It can generally be manipulated as a uint64_t, but with a special
  * value INVALID_GUID that does not equal any valid guid.
- * 
+ *
  * As of this writing, spa_generate_guid() in spa_misc.c explicitly
  * refuses to return a guid of 0.  So this class uses 0 as the value
  * for INVALID_GUID.  In the future, if 0 is allowed to be a valid

Modified: projects/zfsd/head/cddl/sbin/zfsd/vdev_iterator.cc
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/vdev_iterator.cc	Mon Oct 14 21:08:31 2013	(r256456)
+++ projects/zfsd/head/cddl/sbin/zfsd/vdev_iterator.cc	Mon Oct 14 21:21:05 2013	(r256457)
@@ -69,7 +69,7 @@ VdevIterator::Reset()
 	result = nvlist_lookup_nvlist(m_poolConfig,
 				      ZPOOL_CONFIG_VDEV_TREE,
 				      &rootVdev);
-	if (result != 0) 
+	if (result != 0)
 		throw ZfsdException(m_poolConfig, "Unable to extract "
 				    "ZPOOL_CONFIG_VDEV_TREE from pool.");
 	m_vdevQueue.assign(1, rootVdev);
@@ -135,7 +135,7 @@ VdevIterator::Find(Guid vdevGUID)
 		Vdev vdev(m_poolConfig, vdevConfig);
 
 		if (vdev.GUID() == vdevGUID)
-			return vdevConfig;
+			return (vdevConfig);
 	}
 	return (NULL);
 }

Modified: projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc	Mon Oct 14 21:08:31 2013	(r256456)
+++ projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc	Mon Oct 14 21:21:05 2013	(r256457)
@@ -35,7 +35,7 @@
  *
  * The ZFS daemon consumes kernel devctl(4) event data via devd(8)'s
  * unix domain socket in order to react to system changes that impact
- * the function of ZFS storage pools.  The goal of this daemon is to 
+ * the function of ZFS storage pools.  The goal of this daemon is to
  * provide similar functionality to the Solaris ZFS Diagnostic Engine
  * (zfs-diagnosis), the Solaris ZFS fault handler (zfs-retire), and
  * the Solaris ZFS vdev insertion agent (zfs-mod sysevent handler).
@@ -180,9 +180,9 @@ EventBuffer::ExtractEvent(string &eventS
 				 */
 				continue;
 			}
-			syslog(LOG_WARNING,
-			       "Event exceeds event size limit of %d bytes.",
-			       MAX_EVENT_SIZE);
+			syslog(LOG_WARNING, "Overran event buffer\n\tm_nextEventOffset"
+			       "=%d\n\tm_parsedLen=%d\n\tm_validLen=%d",
+			       m_nextEventOffset, m_parsedLen, m_validLen);
 		} else {
 			/*
 			 * Include the normal terminator in the extracted
@@ -250,11 +250,10 @@ EventBuffer::Fill()
 		want = std::min(avail, MAX_READ_SIZE - m_validLen);
 		consumed = m_reader.read(m_buf + m_validLen, want);
 		if (consumed == -1) {
-			if (errno == EINTR) {
+			if (errno == EINTR)
 				return (false);
-			} else {
+			else
 				err(1, "EventBuffer::Fill(): Read failed");
-			}
 		}
 	}
 
@@ -430,7 +429,7 @@ ZfsDaemon::ConnectToDevd()
 	sLen = SUN_LEN(&devdAddr);
 
 	s_devdSockFD = socket(AF_UNIX, SOCK_STREAM, 0);
-	if (s_devdSockFD == -1) 
+	if (s_devdSockFD == -1)
 		err(1, "Unable to create socket");
 	result = connect(s_devdSockFD,
 			 reinterpret_cast<sockaddr *>(&devdAddr),
@@ -482,9 +481,9 @@ bool
 ZfsDaemon::SaveEvent(const DevCtlEvent &event)
 {
 	if (s_consumingEvents)
-		return false;
+		return (false);
 	s_unconsumedEvents.push_back(event.DeepCopy());
-	return true;
+	return (true);
 }
 
 /* Capture and process buffered events. */

Modified: projects/zfsd/head/cddl/sbin/zfsd/zfsd.h
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/zfsd.h	Mon Oct 14 21:08:31 2013	(r256456)
+++ projects/zfsd/head/cddl/sbin/zfsd/zfsd.h	Mon Oct 14 21:21:05 2013	(r256457)
@@ -272,19 +272,39 @@ private:
 	/** Characters found between successive "key=value" strings. */
 	static const char   s_keyPairSepTokens[];
 
-	/** Temporary space for event data during our parsing. */
+	/** Temporary space for event data during our parsing.  Laid out like
+	 * this:
+	 *         <--------------------------------------------------------->
+	 *         |         |    |           |                              |
+	 * m_buf---|         |    |           |                              |
+	 * m_nextEventOffset--    |           |                              |
+	 * m_parsedLen-------------           |                              |
+	 * m_validLen--------------------------                              |
+	 * EVENT_BUFSIZE------------------------------------------------------
+	 *
+	 * Data before m_nextEventOffset has already been processed.
+	 *
+	 * Data between m_nextEvenOffset and m_parsedLen has been parsed, but
+	 * not processed as a single event.
+	 *
+	 * Data between m_parsedLen and m_validLen has been read from the
+	 * source, but not yet parsed.
+	 *
+	 * Between m_validLen and EVENT_BUFSIZE is empty space.
+	 *
+	 * */
 	char		    m_buf[EVENT_BUFSIZE];
 
 	/** Reference to the reader linked to devd's domain socket. */
 	Reader&		    m_reader;
 
-	/** Valid bytes in m_buf. */
+	/** Offset within m_buf to the beginning of free space. */
 	size_t		    m_validLen;
 
-	/** The amount of data in m_buf we have looked at. */
+	/** Offset within m_buf to the beginning of data not yet parsed */
 	size_t		    m_parsedLen;
 
-	/** Offset to the start token of the next event. */
+	/** Offset within m_buf to the start token of the next event. */
 	size_t		    m_nextEventOffset;
 
 	/** The EventBuffer is aligned and tracking event records. */

Modified: projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.h
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.h	Mon Oct 14 21:08:31 2013	(r256456)
+++ projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.h	Mon Oct 14 21:21:05 2013	(r256457)
@@ -96,7 +96,7 @@ public:
 	 * \brief Augment/Modify a ZfsdException's string data.
 	 */
 	std::string& GetString();
-	
+
 	/**
 	 * \brief Emit exception data to syslog(3).
 	 */

Modified: projects/zfsd/head/cddl/sbin/zfsd/zpool_list.cc
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/zpool_list.cc	Mon Oct 14 21:08:31 2013	(r256456)
+++ projects/zfsd/head/cddl/sbin/zfsd/zpool_list.cc	Mon Oct 14 21:21:05 2013	(r256457)
@@ -75,11 +75,10 @@ ZpoolList::LoadIterator(zpool_handle_t *
 	ZpoolList *zpl(reinterpret_cast<ZpoolList *>(data));
 	nvlist_t  *poolConfig(zpool_get_config(pool, NULL));
 
-	if (zpl->m_filter(pool, poolConfig, zpl->m_filterArg)) {
+	if (zpl->m_filter(pool, poolConfig, zpl->m_filterArg))
 		zpl->push_back(pool);
-	} else {
+	else
 		zpool_close(pool);
-	}
 	return (0);
 }
 

Modified: projects/zfsd/head/cddl/sbin/zfsd/zpool_list.h
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/zpool_list.h	Mon Oct 14 21:08:31 2013	(r256456)
+++ projects/zfsd/head/cddl/sbin/zfsd/zpool_list.h	Mon Oct 14 21:21:05 2013	(r256457)
@@ -54,7 +54,7 @@ class Vdev;
 /*============================= Class Definitions ============================*/
 /*--------------------------------- ZpoolList --------------------------------*/
 class ZpoolList;
-typedef bool PoolFilter_t(zpool_handle_t *pool, nvlist_t *poolConfig, 
+typedef bool PoolFilter_t(zpool_handle_t *pool, nvlist_t *poolConfig,
 			  void *filterArg);
 
 /**
@@ -82,7 +82,7 @@ public:
 
 	/**
 	 * \brief Utility ZpoolList construction filter that causes only
-	 *        pools known to the system and having the specified name 
+	 *        pools known to the system and having the specified name
 	 *        to be included in the intantiated ZpoolList.
 	 */
 	static PoolFilter_t ZpoolByName;
@@ -103,9 +103,9 @@ public:
 private:
 	/**
 	 * \brief Helper routine used to populate the internal
-	 *        data store of ZFS pool objects using libzfs's 
+	 *        data store of ZFS pool objects using libzfs's
 	 *        zpool_iter() function.
-	 * 
+	 *
 	 * \param pool  The ZFS pool object to filter.
 	 * \param data  User argument passed through zpool_iter().
 	 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310142121.r9ELL5xk067076>