From owner-svn-src-projects@FreeBSD.ORG Fri Oct 11 21:55:14 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D2BD4241; Fri, 11 Oct 2013 21:55:14 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A428B26D9; Fri, 11 Oct 2013 21:55:14 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9BLtEQ5039628; Fri, 11 Oct 2013 21:55:14 GMT (envelope-from asomers@svn.freebsd.org) Received: (from asomers@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9BLtDX0039618; Fri, 11 Oct 2013 21:55:13 GMT (envelope-from asomers@svn.freebsd.org) Message-Id: <201310112155.r9BLtDX0039618@svn.freebsd.org> From: Alan Somers Date: Fri, 11 Oct 2013 21:55:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r256354 - projects/zfsd/head/cddl/sbin/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.14 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: Fri, 11 Oct 2013 21:55:15 -0000 Author: asomers Date: Fri Oct 11 21:55:12 2013 New Revision: 256354 URL: http://svnweb.freebsd.org/changeset/base/256354 Log: cddl/sbin/zfsd/callout.cc: cddl/sbin/zfsd/callout.h: cddl/sbin/zfsd/case_file.cc: cddl/sbin/zfsd/case_file.h: cddl/sbin/zfsd/dev_ctl_event.h: cddl/sbin/zfsd/zfsd.cc: cddl/sbin/zfsd/zfsd.h: Style and spelling in comments fixes. No functional changes. Submitted by: gibbs Approved by: ken (mentor) Sponsored by: Spectra Logic Corporation Modified: projects/zfsd/head/cddl/sbin/zfsd/callout.cc projects/zfsd/head/cddl/sbin/zfsd/callout.h 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.h projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc projects/zfsd/head/cddl/sbin/zfsd/zfsd.h Modified: projects/zfsd/head/cddl/sbin/zfsd/callout.cc ============================================================================== --- projects/zfsd/head/cddl/sbin/zfsd/callout.cc Fri Oct 11 21:50:04 2013 (r256353) +++ projects/zfsd/head/cddl/sbin/zfsd/callout.cc Fri Oct 11 21:55:12 2013 (r256354) @@ -181,7 +181,7 @@ Callout::TimeRemaining() const timeval timeToExpiry; std::list::iterator it; - if (! IsPending() ) { + if (!IsPending()) { timeToExpiry.tv_sec = INT_MAX; timeToExpiry.tv_usec = 999999; /*maximum normalized value*/ return (timeToExpiry); Modified: projects/zfsd/head/cddl/sbin/zfsd/callout.h ============================================================================== --- projects/zfsd/head/cddl/sbin/zfsd/callout.h Fri Oct 11 21:50:04 2013 (r256353) +++ projects/zfsd/head/cddl/sbin/zfsd/callout.h Fri Oct 11 21:55:12 2013 (r256354) @@ -84,7 +84,7 @@ public: Callout(); /** - * returns true if callout has not been stopped, + * Returns true if callout has not been stopped, * or deactivated since the last time the callout was * reset. */ @@ -105,7 +105,7 @@ public: * * \param interval Timeval indicating the time which must elapse * before this callout fires. - * \param func Pointer to the callback funtion + * \param func Pointer to the callback funtion * \param arg Argument pointer to pass to callback function * * \return Cancelation status. @@ -119,7 +119,7 @@ public: /** * \brief Calculate the remaining time until this Callout's timer - * expires. + * expires. * * The return value will be slightly greater than the actual time to * expiry. Modified: projects/zfsd/head/cddl/sbin/zfsd/case_file.cc ============================================================================== --- projects/zfsd/head/cddl/sbin/zfsd/case_file.cc Fri Oct 11 21:50:04 2013 (r256353) +++ projects/zfsd/head/cddl/sbin/zfsd/case_file.cc Fri Oct 11 21:55:12 2013 (r256354) @@ -220,7 +220,7 @@ CaseFile::ReEvaluate(const string &devPa * use a newly inserted spare to replace a degraded * or faulted device. */ - return (false); + return (/*consumed*/false); } if (vdev != NULL @@ -255,17 +255,17 @@ CaseFile::ReEvaluate(const string &devPa PoolGUIDString().c_str(), VdevGUIDString().c_str(), zpool_state_to_name(VdevState(), VDEV_AUX_NONE)); - return (false); + return (/*consumed*/false); } if (PhysicalPath().empty()) { syslog(LOG_INFO, - "CaseFile(%s:%s:%s): No vdev physical path information. " + "CaseFile(%s:%s:%s): No physical path information. " "Ignoring device insertion.\n", PoolGUIDString().c_str(), VdevGUIDString().c_str(), zpool_state_to_name(VdevState(), VDEV_AUX_NONE)); - return (false); + return (/*consumed*/false); } if (physPath != PhysicalPath()) { @@ -275,7 +275,7 @@ CaseFile::ReEvaluate(const string &devPa PoolGUIDString().c_str(), VdevGUIDString().c_str(), zpool_state_to_name(VdevState(), VDEV_AUX_NONE)); - return (false); + return (/*consumed*/false); } /* Write a label on the newly inserted disk. */ @@ -315,7 +315,7 @@ CaseFile::ReEvaluate(const string &devPa zpool_get_name(pool), VdevGUIDString().c_str()); nvlist_free(newvd); nvlist_free(nvroot); - return (1); + return (/*consumed*/true); } /* Data was copied when added to the root vdev. */ @@ -405,11 +405,11 @@ CaseFile::ReEvaluate(const ZfsEvent &eve return (consumed || closed); } - void CaseFile::RegisterCallout(const DevCtlEvent &event) -{ +{ timeval now, countdown, elapsed, timestamp, zero, remaining; + gettimeofday(&now, 0); timestamp = event.GetTimestamp(); timersub(&now, ×tamp, &elapsed); @@ -427,7 +427,7 @@ CaseFile::RegisterCallout(const DevCtlEv remaining = m_tentativeTimer.TimeRemaining(); if (!m_tentativeTimer.IsPending() - || timercmp(&countdown, &remaining, <)) + || timercmp(&countdown, &remaining, <)) m_tentativeTimer.Reset(countdown, OnGracePeriodEnded, this); } @@ -559,13 +559,12 @@ CaseFile::DeSerializeFile(const char *fi } ifstream caseStream(fullName.c_str()); - if (! caseStream) { + if (!caseStream) { throw ZfsdException("CaseFile::DeSerialize: Unable to " - "read %s.\n", fileName); + "read %s.\n", fileName); return; } - stringstream fakeDevdSocket(stringstream::in - | stringstream::out); + stringstream fakeDevdSocket(stringstream::in|stringstream::out); IstreamReader caseReader(&fakeDevdSocket); /* Re-load EventData */ @@ -604,7 +603,6 @@ CaseFile::DeSerializeFile(const char *fi } } } - } catch (const ParseException &exp) { exp.Log(evString); @@ -673,7 +671,6 @@ CaseFile::PurgeTentativeEvents() m_tentativeEvents.clear(); } - void CaseFile::SerializeEvList(const DevCtlEventList events, int fd, const char* prefix) const Modified: projects/zfsd/head/cddl/sbin/zfsd/case_file.h ============================================================================== --- projects/zfsd/head/cddl/sbin/zfsd/case_file.h Fri Oct 11 21:50:04 2013 (r256353) +++ projects/zfsd/head/cddl/sbin/zfsd/case_file.h Fri Oct 11 21:55:12 2013 (r256354) @@ -210,13 +210,14 @@ protected: * * \param dirEntry Directory entry for the file to filter. * - * \return Non-zero for a file to include in the selection, otherwise 0. + * \return Non-zero for a file to include in the selection, + * otherwise 0. */ static int DeSerializeSelector(const struct dirent *dirEntry); /** * \brief Given the name of a file containing serialized events from a - * CaseFile object, create/update an in-core CaseFile object + * CaseFile object, create/update an in-core CaseFile object * representing the serialized data. * * \param fileName The name of a file containing serialized events @@ -253,14 +254,14 @@ protected: */ void Serialize(); - /** + /** * \brief Serializes the supplied event list and writes it to fd * - * \param prefix If not NULL, this prefix will be prepended to - * every event in the file. + * \param prefix If not NULL, this prefix will be prepended to + * every event in the file. */ void SerializeEvList(const DevCtlEventList events, int fd, - const char* prefix=NULL) const; + const char* prefix=NULL) const; /** * \brief Unconditionally close a CaseFile. @@ -309,9 +310,9 @@ protected: uint64_t m_poolGUID; uint64_t m_vdevGUID; vdev_state m_vdevState; - string m_poolGUIDString; - string m_vdevGUIDString; - string m_vdevPhysPath; + string m_poolGUIDString; + string m_vdevGUIDString; + string m_vdevPhysPath; /** * \brief Callout activated when a grace period Modified: projects/zfsd/head/cddl/sbin/zfsd/dev_ctl_event.h ============================================================================== --- projects/zfsd/head/cddl/sbin/zfsd/dev_ctl_event.h Fri Oct 11 21:50:04 2013 (r256353) +++ projects/zfsd/head/cddl/sbin/zfsd/dev_ctl_event.h Fri Oct 11 21:55:12 2013 (r256354) @@ -95,7 +95,7 @@ public: * Accessor * * \return The offset into the event string where this exception - * occurred. + * occurred. */ size_t GetOffset() const; @@ -158,7 +158,7 @@ typedef map NVPairMap; * * All name => value data for events can be accessed via the Contains() * and Value() methods. name => value pairs for data not explicitly - * recieved as a name => value pair are synthesized during parsing. For + * received as a name => value pair are synthesized during parsing. For * example, ATTACH and DETACH events have "device-name" and "parent" * name => value pairs added. */ @@ -219,7 +219,7 @@ public: * associated value. * * \return A const reference to the string representing the - * value associated with key. + * value associated with key. * * \note For key's with no registered value, the empty string * is returned. @@ -265,7 +265,7 @@ public: * Create and return a fully independent clone * of this event. */ - virtual DevCtlEvent *DeepCopy() const = 0; + virtual DevCtlEvent *DeepCopy() const = 0; /** Destructor */ virtual ~DevCtlEvent(); @@ -358,8 +358,8 @@ private: /** * Ingest event data from the supplied string. * - * \param[in] eventString The string of devd event data to parse. - * \param[out] nvpairs Returns the parsed data + * \param[in] eventString The string of devd event data to parse. + * \param[out] nvpairs Returns the parsed data */ static void ParseEventString(Type type, const string &eventString, NVPairMap &nvpairs); @@ -470,11 +470,11 @@ public: * Interpret and perform any actions necessary to * consume the event. */ - virtual void Process() const; + virtual void Process() const; - const string &PoolName() const; - uint64_t PoolGUID() const; - uint64_t VdevGUID() const; + const string &PoolName() const; + uint64_t PoolGUID() const; + uint64_t VdevGUID() const; protected: /** Constructor */ @@ -483,7 +483,7 @@ protected: /** Deep copy constructor. */ ZfsEvent(const ZfsEvent &src); - void ProcessPoolEvent() const; + void ProcessPoolEvent() const; uint64_t m_poolGUID; uint64_t m_vdevGUID; Modified: projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc ============================================================================== --- projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc Fri Oct 11 21:50:04 2013 (r256353) +++ projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc Fri Oct 11 21:55:12 2013 (r256354) @@ -215,10 +215,10 @@ EventBuffer::ExtractEvent(string &eventS * Add a timestamp as the final field of the event if it is * not already present. */ - if ( eventString.find("timestamp=") == string::npos) { - eventString.insert( - eventString.find_last_not_of('\n') + 1, - tsField.str()); + if (eventString.find("timestamp=") == string::npos) { + size_t eventEnd(eventString.find_last_not_of('\n') + 1); + + eventString.insert(eventEnd, tsField.str()); } return (true); Modified: projects/zfsd/head/cddl/sbin/zfsd/zfsd.h ============================================================================== --- projects/zfsd/head/cddl/sbin/zfsd/zfsd.h Fri Oct 11 21:50:04 2013 (r256353) +++ projects/zfsd/head/cddl/sbin/zfsd/zfsd.h Fri Oct 11 21:55:12 2013 (r256354) @@ -79,15 +79,14 @@ typedef int LeafIterFunc(zpool_handle_t /*-------------------------------- Reader -------------------------------*/ /** - * \brief A class that presents a common interface to both file descriptors and - * istreams . + * \brief A class that presents a common interface to both file descriptors + * and istreams. * * Standard C++ provides no way to create an iostream from a file descriptor or * a FILE. The GNU, Apache, HPUX, and Solaris C++ libraries all provide * non-standard ways to construct such a stream using similar semantics, but - * LLVM does not. Therefore this class is needed to ensure that zfsd can - * compile under LLVM. This class supports only the functionality needed by - * ZFSD; it does not implement the iostream API. + * FreeBSD's C++ library does not. This class supports only the functionality + * needed by ZFSD; it does not implement the iostream API. */ class Reader { @@ -104,9 +103,9 @@ public: * On error, -1 is returned, and errno will be set by the underlying * source. * - * \param buf Destination for the data - * \param count Maximum amount of data to read - * \returns Amount of data that was actually read + * \param buf Destination for the data + * \param count Maximum amount of data to read + * \returns Amount of data that was actually read */ virtual ssize_t read(char* buf, size_t count) = 0; }; @@ -122,12 +121,12 @@ public: /** * \brief Constructor * - * \param fd An open file descriptor. It will not be garbage - * collected by the destructor. + * \param fd An open file descriptor. It will not be garbage + * collected by the destructor. */ FDReader(int fd); - virtual size_t in_avail() const; + virtual size_t in_avail() const; virtual ssize_t read(char* buf, size_t count); @@ -137,8 +136,9 @@ protected: }; //- FDReader Inline Public Methods ----------------------------------------- -inline FDReader::FDReader(int fd) - : m_fd(fd) +inline +FDReader::FDReader(int fd) + : m_fd(fd) { } @@ -148,7 +148,6 @@ FDReader::read(char* buf, size_t count) return (::read(m_fd, buf, count)); } - /*-------------------------------- IstreamReader------------------------------*/ /** * \brief Specialization of Reader that uses a std::istream @@ -159,8 +158,8 @@ public: /** * Constructor * - * \param stream Pointer to an open istream. It will not be - * garbage collected by the destructor. + * \param stream Pointer to an open istream. It will not be + * garbage collected by the destructor. */ IstreamReader(istream* stream); @@ -170,12 +169,13 @@ public: protected: /** Copy of the underlying stream */ - istream* m_stream; + istream *m_stream; }; //- IstreamReader Inline Public Methods ---------------------------------------- -inline IstreamReader::IstreamReader(istream* stream) - : m_stream(stream) +inline +IstreamReader::IstreamReader(istream* stream) + : m_stream(stream) { } @@ -189,7 +189,7 @@ IstreamReader::in_avail() const /*-------------------------------- EventBuffer -------------------------------*/ /** * \brief Class buffering event data from Devd or a similar source and - * splitting it into individual event strings. + * splitting it into individual event strings. * * Users of this class initialize it with a Reader associated with the unix * domain socket connection with devd or a compatible source. The lifetime of @@ -276,7 +276,7 @@ private: char m_buf[EVENT_BUFSIZE]; /** Reference to the reader linked to devd's domain socket. */ - Reader& m_reader; + Reader& m_reader; /** Valid bytes in m_buf. */ size_t m_validLen;