From owner-svn-src-projects@FreeBSD.ORG Mon Oct 14 23:56:40 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 E5A2576F; Mon, 14 Oct 2013 23:56:39 +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 C33D520F6; Mon, 14 Oct 2013 23:56:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9ENud4B046199; Mon, 14 Oct 2013 23:56:39 GMT (envelope-from asomers@svn.freebsd.org) Received: (from asomers@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9ENudWa046198; Mon, 14 Oct 2013 23:56:39 GMT (envelope-from asomers@svn.freebsd.org) Message-Id: <201310142356.r9ENudWa046198@svn.freebsd.org> From: Alan Somers Date: Mon, 14 Oct 2013 23:56:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r256481 - projects/zfsd/head/lib/libdevctl 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 23:56:40 -0000 Author: asomers Date: Mon Oct 14 23:56:38 2013 New Revision: 256481 URL: http://svnweb.freebsd.org/changeset/base/256481 Log: Emit many more ZFS events to devctl, especially for zfs(8) commands. The intention is to make it easier for a devctl consumer (such as zfsd or the zfs worker) to receive events for commands like zfs create/snapshot/destroy/clone/promote. Instead of polling "zfs list", such consumers can now receive notifications when the requested operations complete. While I'm here, make devctl/libdevctl support key/value strings that have spaces in them. Some of the key/value pairs in these events contain strings that screw up rendering & parsing. It seems more appropriate to pass on strings as they were provided than to require all emitters to adopt a "no spaces" rule. The logging format is open to modification/tweaking. Example event logs from zfsd: [root@ntier-verde ~]# zfs create tpool/foo Aug 2 20:46:35 ntier-verde zfsd: ZFS: Notify "dsid"="40" "dsname"="tpool/foo" "history internal str"="" "history txg"="90" "internal_name"="create" "pool_guid"="83985999112536669" "pool_name"="tpool" "subsystem"="ZFS" "timestamp"="1375476395" "type"="misc.fs.zfs.pool_history" [root@ntier-verde ~]# zfs create tpool/foo/0 Aug 2 20:46:36 ntier-verde zfsd: ZFS: Notify "dsid"="47" "dsname"="tpool/foo/0" "history internal str"="" "history txg"="91" "internal_name"="create" "pool_guid"="83985999112386669" "pool_name"="tpool" "subsystem"="ZFS" "timestamp"="1375476396" "type"="misc.fs.zfs.pool_history" [root@ntier-verde ~]# zfs snapshot tpool/foo/0@0 Aug 2 20:46:41 ntier-verde zfsd: ZFS: Notify "dsid"="50" "dsname"="tpool/foo/0@0" "history internal str"="" "history txg"="92" "internal_name"="snapshot" "pool_guid"="83985991253386669" "pool_name"="tpool" "subsystem"="ZFS" "timestamp"="1375476401" "type"="misc.fs.zfs.pool_history" [root@ntier-verde ~]# zfs destroy -r tpool/foo Aug 2 20:46:46 ntier-verde zfsd: ZFS: Notify "dsid"="50" "dsname"="tpool/foo/0@0" "history internal str"="" "history txg"="94" "internal_name"="destroy" "pool_guid"="83985999253386669" "pool_name"="tpool" "subsystem"="ZFS" "timestamp"="1375476406" "type"="misc.fs.zfs.pool_history" Aug 2 20:46:46 ntier-verde zfsd: ZFS: Notify "dsid"="47" "dsname"="tpool/foo/0" "history internal str"="" "history txg"="95" "internal_name"="destroy" "pool_guid"="83985999113386669" "pool_name"="tpool" "subsystem"="ZFS" "timestamp"="1375476406" "type"="misc.fs.zfs.pool_history" Aug 2 20:46:46 ntier-verde zfsd: ZFS: Notify "dsid"="40" "dsname"="tpool/foo" "history internal str"="" "history txg"="97" "internal_name"="destroy" "pool_guid"="83985999112586669" "pool_name"="tpool" "subsystem"="ZFS" "timestamp"="1375476406" "type"="misc.fs.zfs.pool_history" lib/libdevctl/event.cc: sys/cddl/compat/opensolaris/kern/opensolaris_sysevent.c: - Add a rudimentary mechanism for serializing and deserializing spaces in strings representing keys and their values, by converting spaces to %20, and %s to %%s, and vice versa. lib/libdevctl/event.cc: - Add normalize_string(), which deserializes inbound key and value strings, acting as a substitute for string.substr(), as it is used in DevCtl::Event::ParseEventString(). - DevCtl::Event::Log(): Quote key and value strings. sys/cddl/compat/opensolaris/kern/opensolaris_sysevent.c: - Add a common routine, log_sysevent_add_string(), which performs serialization of spaces and %s in strings. - Add log_sysevent_add_elem(), which uses log_sysevent_add_string() to provide the " =" part of the string. sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c: - spa_create(): Change the "create" history log generated here to "pool create", so it can be more easily distinguished from "create", which means "filesystem create". sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fm.c: sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/eventdefs.h: - Add zfs_ereport_spa_history(), a new ZFS event call which allows emitting events for pool history logging. It takes a nvlist of metadata representing the history log, temporarily appends the pool name and guid, then forwards it on to ddi_log_sysevent(). The FreeBSD implementation of ddi_log_sysevent() then serializes the event and forwards the serialized string to devctl_notify(). sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c: - log_internal(): When logging internal events, once the nvlist has been fully populated with data, call zfs_ereport_spa_history(). lib/libdevctl/consumer.cc - Demote ConnectToDevd() "Already connected." syslog from INFO to DEBUG. This function gets called by the devctl ruby gem whenever it polls devctl, resulting in useless log spamming in production. Submitted by: will Approved by: ken (mentor) Sponsored by: Spectra Logic Corporation Modified: projects/zfsd/head/lib/libdevctl/consumer.cc Modified: projects/zfsd/head/lib/libdevctl/consumer.cc ============================================================================== --- projects/zfsd/head/lib/libdevctl/consumer.cc Mon Oct 14 23:43:30 2013 (r256480) +++ projects/zfsd/head/lib/libdevctl/consumer.cc Mon Oct 14 23:56:38 2013 (r256481) @@ -100,7 +100,7 @@ Consumer::ConnectToDevd() if (m_devdSockFD != -1) { /* Already connected. */ - syslog(LOG_INFO, "%s: Already connected.", __func__); + syslog(LOG_DEBUG, "%s: Already connected.", __func__); return (true); } syslog(LOG_INFO, "%s: Connecting to devd.", __func__);