svn commit: r256481 - projects/zfsd/head/lib/libdevctl
Alan Somers
asomers at FreeBSD.org
Mon Oct 14 23:56:40 UTC 2013
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 at 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 at 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 at ntier-verde ~]# zfs snapshot tpool/foo/0 at 0
Aug 2 20:46:41 ntier-verde zfsd: ZFS: Notify "dsid"="50"
"dsname"="tpool/foo/0 at 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 at ntier-verde ~]# zfs destroy -r tpool/foo
Aug 2 20:46:46 ntier-verde zfsd: ZFS: Notify "dsid"="50"
"dsname"="tpool/foo/0 at 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 " <key>=" 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__);
More information about the svn-src-projects
mailing list