svn commit: r256358 - projects/zfsd/head/cddl/sbin/zfsd
Alan Somers
asomers at FreeBSD.org
Fri Oct 11 22:54:03 UTC 2013
Author: asomers
Date: Fri Oct 11 22:54:02 2013
New Revision: 256358
URL: http://svnweb.freebsd.org/changeset/base/256358
Log:
Miscellaneous bug fixes in zfsd.
cddl/sbin/zfsd/zfsd.cc
Properly handle POLLHUP, POLLER, and EINTR on the devd
socket. Ignore POLLHUP led to zfsd spinning the cpu.
cddl/sbin/zfsd/case_file.cc:
cddl/sbin/zfsd/dev_ctl_event.cc:
Use a constant format string so that syslog() cannot be
confused by random '%' characters in the string we are
logging. Fixes a warning with Clang.
cddl/sbin/zfsd/zfsd.cc:
In EventBuffer::ExtractEvent(), add a missing argument to
one syslog() invocation and specify that an integer is a
size_t in another. Fixes warnings in Clang.
Submitted by: asomers, gibbs
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/dev_ctl_event.cc
projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc
Modified: projects/zfsd/head/cddl/sbin/zfsd/case_file.cc
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/case_file.cc Fri Oct 11 22:44:15 2013 (r256357)
+++ projects/zfsd/head/cddl/sbin/zfsd/case_file.cc Fri Oct 11 22:54:02 2013 (r256358)
@@ -167,7 +167,7 @@ CaseFile::RefreshVdevState()
stringstream msg;
msg << "CaseFile::RefreshVdevState: Unknown pool for Vdev(";
msg << m_poolGUID << "," << m_vdevGUID << ").";
- syslog(LOG_INFO, msg.str().c_str());
+ syslog(LOG_INFO, "%s", msg.str().c_str());
return (false);
}
Modified: projects/zfsd/head/cddl/sbin/zfsd/dev_ctl_event.cc
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/dev_ctl_event.cc Fri Oct 11 22:44:15 2013 (r256357)
+++ projects/zfsd/head/cddl/sbin/zfsd/dev_ctl_event.cc Fri Oct 11 22:54:02 2013 (r256358)
@@ -642,7 +642,7 @@ ZfsEvent::Process() const
stringstream msg;
msg << "No replicas available for pool " << poolGUID;
msg << ", ignoring";
- syslog(LOG_INFO, msg.str().c_str());
+ syslog(LOG_INFO, "%s", msg.str().c_str());
return;
}
@@ -658,7 +658,7 @@ ZfsEvent::Process() const
msg << "ZfsEvent::Process: Event for unknown pool ";
msg << poolGUID << " ";
msg << (queued ? "queued" : "dropped");
- syslog(priority, msg.str().c_str());
+ syslog(priority, "%s", msg.str().c_str());
return;
}
@@ -670,7 +670,7 @@ ZfsEvent::Process() const
msg << "ZfsEvent::Process: Event for unknown vdev ";
msg << VdevGUID() << " ";
msg << (queued ? "queued" : "dropped");
- syslog(priority, msg.str().c_str());
+ syslog(priority, "%s", msg.str().c_str());
return;
}
Modified: projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc
==============================================================================
--- projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc Fri Oct 11 22:44:15 2013 (r256357)
+++ projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc Fri Oct 11 22:54:02 2013 (r256358)
@@ -181,7 +181,8 @@ EventBuffer::ExtractEvent(string &eventS
continue;
}
syslog(LOG_WARNING,
- "Event exceeds event size limit of %d bytes.");
+ "Event exceeds event size limit of %d bytes.",
+ MAX_EVENT_SIZE);
} else {
/*
* Include the normal terminator in the extracted
@@ -206,7 +207,7 @@ EventBuffer::ExtractEvent(string &eventS
m_synchronized = false;
syslog(LOG_WARNING,
- "Truncated %d characters from event.",
+ "Truncated %zd characters from event.",
eventLen - fieldEnd);
}
@@ -512,10 +513,31 @@ ZfsDaemon::EventsPending()
struct pollfd fds[1];
int result;
- fds->fd = s_devdSockFD;
- fds->events = POLLIN;
- fds->revents = 0;
- result = poll(fds, NUM_ELEMENTS(fds), /*timeout*/0);
+ do {
+ fds->fd = s_devdSockFD;
+ fds->events = POLLIN;
+ fds->revents = 0;
+ result = poll(fds, NUM_ELEMENTS(fds), /*timeout*/0);
+ } while ( (result == -1) && (errno == EINTR) ) ;
+
+ if (result == -1) {
+ /* Unexpected error; try reconnecting the socket */
+ throw ZfsdException(
+ "ZfsdDaemon::EventsPending(): Unexpected error from poll()");
+ }
+
+ if ((fds->revents & POLLHUP) != 0) {
+ /* The other end hung up the socket. Throw an exception
+ * so ZfsDaemon will try to reconnect
+ */
+ throw ZfsdException("ZfsDaemon::EventsPending(): Got POLLHUP");
+ }
+
+ if ((fds->revents & POLLERR) != 0) {
+ /* Try reconnecting. */
+ throw ZfsdException(
+ "ZfsdDaemon:EventsPending(): Got POLLERR. Reconnecting.");
+ }
return ((fds->revents & POLLIN) != 0);
}
More information about the svn-src-projects
mailing list