diff options
Diffstat (limited to 'usr/src/lib/varpd/libvarpd')
-rw-r--r-- | usr/src/lib/varpd/libvarpd/Makefile | 2 | ||||
-rw-r--r-- | usr/src/lib/varpd/libvarpd/Makefile.com | 5 | ||||
-rw-r--r-- | usr/src/lib/varpd/libvarpd/common/libvarpd.c | 15 | ||||
-rw-r--r-- | usr/src/lib/varpd/libvarpd/common/libvarpd_impl.h | 1 | ||||
-rw-r--r-- | usr/src/lib/varpd/libvarpd/common/libvarpd_overlay.c | 2 | ||||
-rw-r--r-- | usr/src/lib/varpd/libvarpd/common/libvarpd_plugin.c | 53 | ||||
-rw-r--r-- | usr/src/lib/varpd/libvarpd/common/libvarpd_provider.h | 6 | ||||
-rw-r--r-- | usr/src/lib/varpd/libvarpd/common/llib-lvarpd | 19 | ||||
-rw-r--r-- | usr/src/lib/varpd/libvarpd/sparc/Makefile | 18 | ||||
-rw-r--r-- | usr/src/lib/varpd/libvarpd/sparcv9/Makefile | 19 |
10 files changed, 114 insertions, 26 deletions
diff --git a/usr/src/lib/varpd/libvarpd/Makefile b/usr/src/lib/varpd/libvarpd/Makefile index 034ba30c1d..2dbc8d7c5d 100644 --- a/usr/src/lib/varpd/libvarpd/Makefile +++ b/usr/src/lib/varpd/libvarpd/Makefile @@ -10,7 +10,7 @@ # # -# Copyright 2015 Joyent, Inc. +# Copyright 2021 Joyent, Inc. # include ../../Makefile.lib diff --git a/usr/src/lib/varpd/libvarpd/Makefile.com b/usr/src/lib/varpd/libvarpd/Makefile.com index dc51193367..7f45bd30e2 100644 --- a/usr/src/lib/varpd/libvarpd/Makefile.com +++ b/usr/src/lib/varpd/libvarpd/Makefile.com @@ -10,7 +10,7 @@ # # -# Copyright 2015 Joyent, Inc. +# Copyright 2021 Joyent, Inc. # LIBRARY = libvarpd.a @@ -32,7 +32,8 @@ include ../../../Makefile.lib include ../../../Makefile.rootfs LIBS = $(DYNLIB) -LDLIBS += -lc -lavl -lumem -lidspace -lnvpair -lmd -lrename +LDLIBS += -lc -lavl -lumem -lidspace -lnvpair -lmd -lrename \ + -lbunyan CPPFLAGS += -I../common CERRWARN += -erroff=E_STRUCT_DERIVED_FROM_FLEX_MBR diff --git a/usr/src/lib/varpd/libvarpd/common/libvarpd.c b/usr/src/lib/varpd/libvarpd/common/libvarpd.c index 4e4c189a43..e4460089cc 100644 --- a/usr/src/lib/varpd/libvarpd/common/libvarpd.c +++ b/usr/src/lib/varpd/libvarpd/common/libvarpd.c @@ -98,6 +98,14 @@ libvarpd_create(varpd_handle_t **vphp) return (ret); } + if ((ret = bunyan_init("varpd", &vip->vdi_bunyan)) != 0) { + libvarpd_overlay_fini(vip); + umem_cache_destroy(vip->vdi_qcache); + id_space_destroy(vip->vdi_idspace); + umem_free(vip, sizeof (varpd_impl_t)); + return (ret); + } + libvarpd_persist_init(vip); avl_create(&vip->vdi_plugins, libvarpd_plugin_comparator, @@ -315,6 +323,13 @@ out: return (ret); } +const bunyan_logger_t * +libvarpd_plugin_bunyan(varpd_provider_handle_t *vhp) +{ + varpd_instance_t *inst = (varpd_instance_t *)vhp; + return (inst->vri_impl->vdi_bunyan); +} + static void libvarpd_prefork(void) { diff --git a/usr/src/lib/varpd/libvarpd/common/libvarpd_impl.h b/usr/src/lib/varpd/libvarpd/common/libvarpd_impl.h index f8530a7112..60f0dc5fff 100644 --- a/usr/src/lib/varpd/libvarpd/common/libvarpd_impl.h +++ b/usr/src/lib/varpd/libvarpd/common/libvarpd_impl.h @@ -53,6 +53,7 @@ typedef struct varpd_impl { avl_tree_t vdi_linstances; /* vdi_lock */ id_space_t *vdi_idspace; /* RO */ umem_cache_t *vdi_qcache; /* RO */ + bunyan_logger_t *vdi_bunyan; /* RO */ int vdi_overlayfd; /* RO */ int vdi_doorfd; /* vdi_lock */ int vdi_persistfd; /* vdi_plock */ diff --git a/usr/src/lib/varpd/libvarpd/common/libvarpd_overlay.c b/usr/src/lib/varpd/libvarpd/common/libvarpd_overlay.c index 167c004a90..f314440056 100644 --- a/usr/src/lib/varpd/libvarpd/common/libvarpd_overlay.c +++ b/usr/src/lib/varpd/libvarpd/common/libvarpd_overlay.c @@ -10,7 +10,7 @@ */ /* - * Copyright 2015 Joyent, Inc. + * Copyright 2021 Joyent, Inc. */ /* diff --git a/usr/src/lib/varpd/libvarpd/common/libvarpd_plugin.c b/usr/src/lib/varpd/libvarpd/common/libvarpd_plugin.c index 176306a3f7..ac73286fdd 100644 --- a/usr/src/lib/varpd/libvarpd/common/libvarpd_plugin.c +++ b/usr/src/lib/varpd/libvarpd/common/libvarpd_plugin.c @@ -25,6 +25,7 @@ #include <dlfcn.h> #include <link.h> #include <stdio.h> +#include <bunyan.h> static varpd_impl_t *varpd_load_handle; static const char *varpd_load_path; @@ -58,18 +59,21 @@ libvarpd_plugin_alloc(uint_t version, int *errp) errp = &err; if (version != VARPD_VERSION_ONE) { - (void) fprintf(stderr, - "unsupported registration version %u - %s\n", - version, varpd_load_path); + (void) bunyan_warn(varpd_load_handle->vdi_bunyan, + "unsupported registration version", + BUNYAN_T_STRING, "module_path", varpd_load_path, + BUNYAN_T_INT32, "module_version", version, + BUNYAN_T_END); *errp = EINVAL; return (NULL); } vprp = umem_alloc(sizeof (varpd_plugin_register_t), UMEM_DEFAULT); if (vprp == NULL) { - (void) fprintf(stderr, - "failed to allocate registration handle - %s\n", - varpd_load_path); + (void) bunyan_warn(varpd_load_handle->vdi_bunyan, + "failed to allocate registration handle", + BUNYAN_T_STRING, "module_path", varpd_load_path, + BUNYAN_T_END); *errp = ENOMEM; return (NULL); } @@ -93,17 +97,20 @@ libvarpd_plugin_register(varpd_plugin_register_t *vprp) vpp = umem_alloc(sizeof (varpd_plugin_t), UMEM_DEFAULT); if (vpp == NULL) { - (void) fprintf(stderr, - "failed to allocate memory for the varpd_plugin_t - %s\n", - varpd_load_path); + (void) bunyan_warn(varpd_load_handle->vdi_bunyan, + "failed to allocate memory for the varpd_plugin_t", + BUNYAN_T_STRING, "module_path", varpd_load_path, + BUNYAN_T_END); return (ENOMEM); } /* Watch out for an evil plugin */ if (vprp->vpr_version != VARPD_VERSION_ONE) { - (void) fprintf(stderr, - "unsupported registration version %u - %s\n", - vprp->vpr_version, varpd_load_path); + (void) bunyan_warn(varpd_load_handle->vdi_bunyan, + "unsupported registration version", + BUNYAN_T_STRING, "module_path", varpd_load_path, + BUNYAN_T_INT32, "module_version", vprp->vpr_version, + BUNYAN_T_END); return (EINVAL); } @@ -114,9 +121,11 @@ libvarpd_plugin_register(varpd_plugin_register_t *vprp) mutex_enter(&varpd_load_handle->vdi_lock); lookup.vpp_name = vprp->vpr_name; if (avl_find(&varpd_load_handle->vdi_plugins, &lookup, NULL) != NULL) { - (void) fprintf(stderr, - "module already exists with requested name '%s' - %s\n", - vprp->vpr_name, varpd_load_path); + (void) bunyan_warn(varpd_load_handle->vdi_bunyan, + "module already exists with requested name", + BUNYAN_T_STRING, "module_path", varpd_load_path, + BUNYAN_T_STRING, "name", vprp->vpr_name, + BUNYAN_T_END); mutex_exit(&varpd_load_handle->vdi_lock); mutex_exit(&varpd_load_lock); umem_free(vpp, sizeof (varpd_plugin_t)); @@ -124,9 +133,10 @@ libvarpd_plugin_register(varpd_plugin_register_t *vprp) } vpp->vpp_name = strdup(vprp->vpr_name); if (vpp->vpp_name == NULL) { - (void) fprintf(stderr, - "failed to allocate memory to duplicate name - %s\n", - varpd_load_path); + (void) bunyan_warn(varpd_load_handle->vdi_bunyan, + "failed to allocate memory to duplicate name", + BUNYAN_T_STRING, "module_path", varpd_load_path, + BUNYAN_T_END); mutex_exit(&varpd_load_handle->vdi_lock); mutex_exit(&varpd_load_lock); umem_free(vpp, sizeof (varpd_plugin_t)); @@ -167,8 +177,11 @@ libvarpd_plugin_load_cb(varpd_impl_t *vip, const char *path, void *unused) varpd_load_path = path; dlp = dlopen(path, RTLD_LOCAL | RTLD_NOW); - if (dlp == NULL) - (void) fprintf(stderr, "dlopen failed - %s\n", path); + if (dlp == NULL) { + (void) bunyan_error(vip->vdi_bunyan, "dlopen failed", + BUNYAN_T_STRING, "module path", path, + BUNYAN_T_END); + } path = NULL; return (0); diff --git a/usr/src/lib/varpd/libvarpd/common/libvarpd_provider.h b/usr/src/lib/varpd/libvarpd/common/libvarpd_provider.h index b6910b9ed5..050b9e600a 100644 --- a/usr/src/lib/varpd/libvarpd/common/libvarpd_provider.h +++ b/usr/src/lib/varpd/libvarpd/common/libvarpd_provider.h @@ -36,8 +36,8 @@ * succeeds, then it should proceed to fill out the registration and then call, * libvarpd_plugin_register() with it. Regardless of whether it succeeds or * fails, it should call libvarpd_plugin_free(). In the case of failure, there - * is not much that the module should do, other than log some message to - * stderr. + * is not much that the module should do, other than log some message to the + * standard bunyan logger that exists. * * Once libvarpd_plugin_register() returns, the module should assume that any * of the operations it defined in the operation vector may be called and @@ -287,6 +287,7 @@ * context, including from the operation vectors. */ +#include <bunyan.h> #include <libvarpd.h> #include <libnvpair.h> #include <sys/socket.h> @@ -366,6 +367,7 @@ extern int libvarpd_plugin_register(varpd_plugin_register_t *); * Blowing up and logging */ extern void libvarpd_panic(const char *, ...) __NORETURN; +extern const bunyan_logger_t *libvarpd_plugin_bunyan(varpd_provider_handle_t *); /* * Misc. Information APIs diff --git a/usr/src/lib/varpd/libvarpd/common/llib-lvarpd b/usr/src/lib/varpd/libvarpd/common/llib-lvarpd new file mode 100644 index 0000000000..85150d3463 --- /dev/null +++ b/usr/src/lib/varpd/libvarpd/common/llib-lvarpd @@ -0,0 +1,19 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2015 Joyent, Inc. + */ + +/* LINTLIBRARY */ +/* PROTOLIB1 */ + +#include <libvarpd.h> diff --git a/usr/src/lib/varpd/libvarpd/sparc/Makefile b/usr/src/lib/varpd/libvarpd/sparc/Makefile new file mode 100644 index 0000000000..f2b4f63da5 --- /dev/null +++ b/usr/src/lib/varpd/libvarpd/sparc/Makefile @@ -0,0 +1,18 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2015 Joyent, Inc. +# + +include ../Makefile.com + +install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/lib/varpd/libvarpd/sparcv9/Makefile b/usr/src/lib/varpd/libvarpd/sparcv9/Makefile new file mode 100644 index 0000000000..d552642882 --- /dev/null +++ b/usr/src/lib/varpd/libvarpd/sparcv9/Makefile @@ -0,0 +1,19 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2015 Joyent, Inc. +# + +include ../Makefile.com +include ../../../Makefile.lib.64 + +install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64) |