From owner-svn-src-projects@FreeBSD.ORG Mon Oct 14 20:59:18 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 3AC24584; Mon, 14 Oct 2013 20:59:18 +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 27A4127CC; Mon, 14 Oct 2013 20:59:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9EKxIkq053353; Mon, 14 Oct 2013 20:59:18 GMT (envelope-from asomers@svn.freebsd.org) Received: (from asomers@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9EKxIs7053352; Mon, 14 Oct 2013 20:59:18 GMT (envelope-from asomers@svn.freebsd.org) Message-Id: <201310142059.r9EKxIs7053352@svn.freebsd.org> From: Alan Somers Date: Mon, 14 Oct 2013 20:59:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r256454 - 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: Mon, 14 Oct 2013 20:59:18 -0000 Author: asomers Date: Mon Oct 14 20:59:17 2013 New Revision: 256454 URL: http://svnweb.freebsd.org/changeset/base/256454 Log: Remove information about devd reconnection policies that was distributed within comments and syslog() strings in functions well below where these decisions are made. stable/cddl/sbin/zfsd/zfsd.cc: o In ZfsDaemon::DisconnectFromDevd(), log when the connection is torn down. This removes the need to guess that this will happen in comments or log strings in code that all eventually sends us to this function. o In ZfsDaemon::EventsPending(), treat poll returning -1 with an errno other than EINTR, or 0 as a program terminating event just as it is in the other case where we invoke poll. These events indicate poll or our code is seriously broken. o In ZfsDaemon::EventsPending(), prioritize emitting a POLLERR event over POLLHUP in case they are both set. POLLHUP is benign, but POLLERR may indicate something we need to investigate. o In ZfsDaemon::EventLoop(), remove comments and log strings that claim knowledge of policy implemented in EventLoop's caller, ZfsDaemon::Run(). Submitted by: gibbs Approved by: ken (mentor) Obtained from: Spectra Logic Corporation Modified: projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc Modified: projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc ============================================================================== --- projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc Mon Oct 14 20:56:51 2013 (r256453) +++ projects/zfsd/head/cddl/sbin/zfsd/zfsd.cc Mon Oct 14 20:59:17 2013 (r256454) @@ -450,6 +450,9 @@ ZfsDaemon::ConnectToDevd() void ZfsDaemon::DisconnectFromDevd() { + if (s_devdSockFD != -1) + syslog(LOG_INFO, "Disconnecting from devd."); + delete s_reader; s_reader = NULL; close(s_devdSockFD); @@ -520,25 +523,19 @@ ZfsDaemon::EventsPending() 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 (result == -1) + err(1, "Polling for devd events failed"); - 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 (result == 0) + errx(1, "Unexpected result of 0 from poll. Exiting"); - if ((fds->revents & POLLERR) != 0) { - /* Try reconnecting. */ - throw ZfsdException("ZfsdDaemon:EventsPending(): Got POLLERR. " - " Reconnecting."); - } + if ((fds->revents & POLLERR) != 0) + throw ZfsdException("ZfsdDaemon:EventsPending(): " + "POLLERR detected on devd socket."); + + if ((fds->revents & POLLHUP) != 0) + throw ZfsdException("ZfsDaemon::EventsPending(): " + "POLLHUP detected on devd socket."); return ((fds->revents & POLLIN) != 0); } @@ -692,14 +689,12 @@ ZfsDaemon::EventLoop() } if ((fds[0].revents & POLLERR) != 0) { - /* Try reconnecting. */ - syslog(LOG_INFO, "Error on socket. Disconnecting."); + syslog(LOG_INFO, "POLLERROR detected on devd socket."); break; } if ((fds[0].revents & POLLHUP) != 0) { - /* Try reconnecting. */ - syslog(LOG_INFO, "Hup on socket. Disconnecting."); + syslog(LOG_INFO, "POLLHUP detected on devd socket."); break; } }