Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Oct 2013 22:19:46 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r256356 - projects/zfsd/head/cddl/sbin/zfsd
Message-ID:  <201310112219.r9BMJksP051570@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Fri Oct 11 22:19:45 2013
New Revision: 256356
URL: http://svnweb.freebsd.org/changeset/base/256356

Log:
  General cleanup to facilitate unit testing.  The unit tests will be committed
  separately.
  
  	cddl/sbin/zfsd/zfsd.cc
  	cddl/sbin/zfsd/zfsd_main.cc
  	cddl/sbin/zfsd/Makefile
  		Split main() into a separate file.
  
  	cddl/sbin/zfsd/callout.cc
  	cddl/sbin/zfsd/zfsd_exception.h
  	cddl/sbin/zfsd/zfsd_exception.cc
  		Removed dead code and de-inlined functions.
  
  Submitted by:	alans
  Approved by:	ken (mentor)
  Sponsored by:	Spectra Logic Corporation

Added:
  projects/zfsd/head/cddl/sbin/zfsd/zfsd_main.cc
Modified:
  projects/zfsd/head/cddl/sbin/zfsd/Makefile
  projects/zfsd/head/cddl/sbin/zfsd/callout.cc
  projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc
  projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.cc
  projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.h

Modified: projects/zfsd/head/cddl/sbin/zfsd/Makefile
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/Makefile	Fri Oct 11 22:00:54 2013	(r256355)
+++ projects/zfsd/head/cddl/sbin/zfsd/Makefile	Fri Oct 11 22:19:45 2013	(r256356)
@@ -8,7 +8,8 @@ SRCS=		callout.cc		\
 		vdev_iterator.cc	\
 		zfsd.cc			\
 		zfsd_exception.cc	\
-		zpool_list.cc
+		zpool_list.cc	\
+		zfsd_main.cc
 
 NO_MAN=		YES
 

Modified: projects/zfsd/head/cddl/sbin/zfsd/callout.cc
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/callout.cc	Fri Oct 11 22:00:54 2013	(r256355)
+++ projects/zfsd/head/cddl/sbin/zfsd/callout.cc	Fri Oct 11 22:19:45 2013	(r256356)
@@ -53,7 +53,7 @@ Callout::Init()
 	signal(SIGALRM,  Callout::AlarmSignalHandler);
 }
 
-inline bool
+bool
 Callout::Stop()
 {
 	if (!IsPending())

Modified: projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc	Fri Oct 11 22:00:54 2013	(r256355)
+++ projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc	Fri Oct 11 22:19:45 2013	(r256356)
@@ -61,7 +61,6 @@
 #include <sstream>
 #include <string>
 #include <syslog.h>
-#include <unistd.h>
 
 #include <sys/fs/zfs.h>
 #include <libzfs.h>
@@ -683,33 +682,4 @@ ZfsDaemon::EventLoop()
 	}
 }
 
-/*=============================== Program Main ===============================*/
-static void
-usage()
-{
-	fprintf(stderr, "usage: %s [-d]\n", getprogname());
-	exit(1);
-}
-
-/**
- * Program entry point.
- */
-int
-main(int argc, char **argv)
-{
-	int ch;
 
-	while ((ch = getopt(argc, argv, "d")) != -1) {
-		switch (ch) {
-		case 'd':
-			g_debug++;
-			break;
-		default:
-			usage();
-		}
-	}
-
-	ZfsDaemon::Run();
-
-	return (0);
-}

Modified: projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.cc
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.cc	Fri Oct 11 22:00:54 2013	(r256355)
+++ projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.cc	Fri Oct 11 22:19:45 2013	(r256356)
@@ -93,32 +93,6 @@ ZfsdException::ZfsdException(nvlist_t *p
 	va_end(ap);
 }
 
-inline
-ZfsdException::ZfsdException(zpool_handle_t *pool, nvlist_t *vdevConfig,
-			     const char *fmt, ...)
- : m_poolConfig(zpool_get_config(pool, NULL)),
-   m_vdevConfig(vdevConfig)
-{
-	va_list ap;
-
-	va_start(ap, fmt);
-	FormatLog(fmt, ap);
-	va_end(ap);
-}
-
-inline
-ZfsdException::ZfsdException(nvlist_t *poolConfig, nvlist_t *vdevConfig,
-			     const char *fmt, ...)
- : m_poolConfig(poolConfig),
-   m_vdevConfig(vdevConfig)
-{
-	va_list ap;
-
-	va_start(ap, fmt);
-	FormatLog(fmt, ap);
-	va_end(ap);
-}
-
 void
 ZfsdException::Log() const
 {

Modified: projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.h
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.h	Fri Oct 11 22:00:54 2013	(r256355)
+++ projects/zfsd/head/cddl/sbin/zfsd/zfsd_exception.h	Fri Oct 11 22:19:45 2013	(r256356)
@@ -93,42 +93,6 @@ public:
 	ZfsdException(nvlist_t *poolConfig, const char *, ...);
 
 	/**
-	 * \brief ZfsdException constructor allowing arbitrary string
-	 *        data to be reported and associated with the configuration
-	 *        data for a single vdev and its parent pool.
-	 *
-	 * \param pool        Pool handle describing the pool to which this
-	 *                    exception is associated.
-	 * \param vdevConfig  A name/value list describing the vdev
-	 *                    to which this exception is associated.
-	 * \param fmt         Printf-like string format specifier.
-	 *
-	 * Instantiation with this method is used to report errors
-	 * associated with a vdev when both the vdev's config and
-	 * its pool membership are available.
-	 */
-	ZfsdException(zpool_handle_t *pool, nvlist_t *vdevConfig,
-		      const char *fmt, ...);
-
-	/**
-	 * \brief ZfsdException constructor allowing arbitrary string
-	 *        data to be reported and associated with the configuration
-	 *        data for a single vdev and its parent pool.
-	 *
-	 * \param poolConfig  Pool configuration describing the pool to
-	 *                    which this exception is associated.
-	 * \param vdevConfig  A name/value list describing the vdev
-	 *                    to which this exception is associated.
-	 * \param fmt         Printf-like string format specifier.
-	 *
-	 * Instantiation with this method is used to report errors
-	 * associated with a vdev when both the vdev's config and
-	 * its pool membership are available.
-	 */
-	ZfsdException(nvlist_t *poolConfig, nvlist_t *vdevConfig,
-		      const char *fmt, ...);
-
-	/**
 	 * \brief Augment/Modify a ZfsdException's string data.
 	 */
 	std::string& GetString();

Added: projects/zfsd/head/cddl/sbin/zfsd/zfsd_main.cc
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/zfsd/head/cddl/sbin/zfsd/zfsd_main.cc	Fri Oct 11 22:19:45 2013	(r256356)
@@ -0,0 +1,76 @@
+/*-
+ * Copyright (c) 2011 Spectra Logic Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * Authors: Alan Somers     (Spectra Logic Corporation)
+ */
+
+/**
+ * \file zfsd_main.cc
+ *
+ * main function for the ZFS Daemon.  Separated to facilitate testing.
+ *
+ */
+
+#include <cstdlib>
+#include <cstdio>
+#include <unistd.h>
+
+#include "zfsd.h"
+
+
+/*=============================== Program Main ===============================*/
+static void
+usage()
+{
+	fprintf(stderr, "usage: %s [-d]\n", getprogname());
+	exit(1);
+}
+
+/**
+ * Program entry point.
+ */
+int
+main(int argc, char **argv)
+{
+	int ch;
+
+	while ((ch = getopt(argc, argv, "d")) != -1) {
+		switch (ch) {
+		case 'd':
+			g_debug++;
+			break;
+		default:
+			usage();
+		}
+	}
+
+	ZfsDaemon::Run();
+
+	return (0);
+}



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