summaryrefslogtreecommitdiff
path: root/usr/src/cmd/avs/dsstat
diff options
context:
space:
mode:
authorYuri Pankov <yuri.pankov@nexenta.com>2018-08-07 16:46:21 -0700
committerJoshua M. Clulow <josh@sysmgr.org>2018-08-07 16:46:22 -0700
commitcb41b9c565d4eec9e1f06e24d429696f59f2f07d (patch)
treeee8675f196c2ea84b5ac5c6f0dff8c9e5305f0ee /usr/src/cmd/avs/dsstat
parent0e986b9d87352cd82909c748e7f684afe0ed579f (diff)
downloadillumos-joyent-cb41b9c565d4eec9e1f06e24d429696f59f2f07d.tar.gz
9674 Let's scrap AVS/sdbc
Reviewed by: Dan McDonald <danmcd@joyent.com> Reviewed by: Peter Tribble <peter.tribble@gmail.com> Approved by: Joshua M. Clulow <josh@sysmgr.org>
Diffstat (limited to 'usr/src/cmd/avs/dsstat')
-rw-r--r--usr/src/cmd/avs/dsstat/Makefile91
-rw-r--r--usr/src/cmd/avs/dsstat/common.c187
-rw-r--r--usr/src/cmd/avs/dsstat/common.h43
-rw-r--r--usr/src/cmd/avs/dsstat/dsstat.c546
-rw-r--r--usr/src/cmd/avs/dsstat/dsstat.h111
-rw-r--r--usr/src/cmd/avs/dsstat/ii_stats.c811
-rw-r--r--usr/src/cmd/avs/dsstat/ii_stats.h82
-rw-r--r--usr/src/cmd/avs/dsstat/multi_stats.c206
-rw-r--r--usr/src/cmd/avs/dsstat/multi_stats.h43
-rw-r--r--usr/src/cmd/avs/dsstat/report.c439
-rw-r--r--usr/src/cmd/avs/dsstat/report.h122
-rw-r--r--usr/src/cmd/avs/dsstat/sdbc_stats.c788
-rw-r--r--usr/src/cmd/avs/dsstat/sdbc_stats.h92
-rw-r--r--usr/src/cmd/avs/dsstat/sndr_stats.c852
-rw-r--r--usr/src/cmd/avs/dsstat/sndr_stats.h70
15 files changed, 0 insertions, 4483 deletions
diff --git a/usr/src/cmd/avs/dsstat/Makefile b/usr/src/cmd/avs/dsstat/Makefile
deleted file mode 100644
index 8a865c34a7..0000000000
--- a/usr/src/cmd/avs/dsstat/Makefile
+++ /dev/null
@@ -1,91 +0,0 @@
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-#
-
-DYNPROG = dsstat
-
-include ../../Makefile.cmd
-include ../Makefile.com
-
-PROG = $(DYNPROG)
-
-SUBDIRS=
-
-dsstat := POBJS = dsstat.o ii_stats.o sndr_stats.o \
- sdbc_stats.o multi_stats.o common.o report.o
-
-OBJS= dsstat.o ii_stats.o sndr_stats.o sdbc_stats.o \
- multi_stats.o common.o report.o
-SRCS= $(OBJS:%.o=%.c)
-
-CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
-CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-clobbered
-LDLIBS += -lkstat
-LINTFLAGS += -Xa -n -s -x -m -u -Dlint -errhdr=%user
-LINTFLAGS += -erroff=E_SEC_PRINTF_VAR_FMT -erroff=E_SEC_SPRINTF_UNBOUNDED_COPY
-LINTDIR = $(KBASE)/lintdir
-POFILE = dsstat_all.po
-POFILES = $(OBJS:%.o=%.po)
-LFILE = $(LINTDIR)/dsstat.ln
-ROOTLINK = $(ROOTUSRSBIN)/$(PROG)
-
-all := TARGET= all
-install := TARGET= install
-clean := TARGET= clean
-clobber := TARGET= clobber
-lint := TARGET= lint
-
-.KEEP_STATE:
-
-.PARALLEL: $(OBJS)
-
-all: $(SUBDIRS) $(PROG)
-
-install: $(SUBDIRS) all $(ROOTPROG) $(ROOTLINK)
-
-lint: $(SUBDIRS) lint_SRCS
-
-clean: $(SUBDIRS)
- $(RM) *.o
-
-$(PROG): $$(POBJS)
- $(LINK.c) $(POBJS) -o $@ $(LDLIBS)
- $(POST_PROCESS)
-
-$(POFILE): $(POFILES)
- $(RM) $@
- $(CAT) $(POFILES) > $@
-
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-$(ROOTLINK): $(ROOTUSRSBIN) $(ROOTPROG)
- -$(RM) $@; $(LN) $(ROOTPROG) $@
-
-FRC:
-
-include ../../Makefile.targ
diff --git a/usr/src/cmd/avs/dsstat/common.c b/usr/src/cmd/avs/dsstat/common.c
deleted file mode 100644
index 45f8145591..0000000000
--- a/usr/src/cmd/avs/dsstat/common.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include <errno.h>
-#include <kstat.h>
-#include <signal.h>
-#include <setjmp.h>
-
-#include "sdbc_stats.h"
-#include "report.h"
-#include "common.h"
-
-static sigjmp_buf env;
-static sig_atomic_t sig_raised = 0;
-static void sig_handler(int);
-
-void
-sig_handler(int sig)
-{
- switch (sig) {
- case SIGSEGV:
- sig_raised = 1;
- siglongjmp(env, sig);
- default:
- exit(sig);
- }
-}
-
-/*
- * kstat_retrieve() - populate the ks_data field of the kstat_t structure
- *
- * This function is a user-land equivalent of a ks_snapshot
- *
- * parameters
- * kstat_ctl_t *kc - kstat_ctl_t structure representing returned from
- * kstat_open()
- * kstat_t *ksp - kstat_t strcture to popluate ks_data into
- *
- * returns
- * NULL pointer on failure
- * kstat_t * structure on success
- */
-kstat_t *
-kstat_retrieve(kstat_ctl_t *kc, kstat_t *ksp)
-{
-
- kstat_t *rval;
- kstat_named_t *knp;
- char *end;
- int i;
- struct sigaction segv_act; /* default actions */
-
- if (ksp == NULL)
- return (NULL);
-
- if (ksp->ks_data == NULL &&
- kstat_read(kc, ksp, NULL) == -1)
- return (NULL);
-
- rval = (kstat_t *)calloc(1, sizeof (*ksp));
- (void) memcpy(rval, ksp, sizeof (*ksp));
-
- rval->ks_data = (void *) calloc(1, ksp->ks_data_size);
- (void) memcpy(rval->ks_data, ksp->ks_data,
- sizeof (kstat_named_t) * ksp->ks_ndata);
-
- /* special handling for variable length string KSTAT_DATA_STRING */
- knp = (kstat_named_t *)rval->ks_data;
- end = (char *)(knp + ksp->ks_ndata);
- for (i = 0; i < ksp->ks_ndata; i++, knp++) {
- if (knp->data_type == KSTAT_DATA_STRING &&
- KSTAT_NAMED_STR_PTR(knp) != NULL) {
- /* catch SIGSEGV (bug 6384130) */
- sig_raised = 0;
- (void) sigaction(SIGSEGV, NULL, &segv_act);
- (void) signal(SIGSEGV, sig_handler);
-
- (void) strncpy(end, KSTAT_NAMED_STR_PTR(knp),
- KSTAT_NAMED_STR_BUFLEN(knp));
- KSTAT_NAMED_STR_PTR(knp) = end;
- end += KSTAT_NAMED_STR_BUFLEN(knp);
-
- /* bug 6384130 */
- (void) sigsetjmp(env, 0);
- if (sig_raised) {
- bzero(end, KSTAT_NAMED_STR_BUFLEN(knp));
- KSTAT_NAMED_STR_PTR(knp) = end;
- end += KSTAT_NAMED_STR_BUFLEN(knp);
- }
- (void) sigaction(SIGSEGV, &segv_act, NULL);
- }
- }
-
- return (rval);
-}
-
-/*
- * kstat_value() - retrieve value of a field in a kstat_named_t kstat.
- *
- * parameters
- * kstat_t *ksp - kstat containing the field
- * char *name - text string representing the field name
- *
- * returns
- * void * - pointer to data retrieved
- */
-void *
-kstat_value(kstat_t *ksp, char *name)
-{
- kstat_named_t *knm;
-
- if ((knm = kstat_data_lookup(ksp, name)) == NULL)
- return (NULL);
-
- switch (knm->data_type) {
- case KSTAT_DATA_CHAR :
- return (knm->value.c);
- case KSTAT_DATA_INT32 :
- return (&knm->value.i32);
- case KSTAT_DATA_UINT32 :
- return (&knm->value.ui32);
- case KSTAT_DATA_INT64 :
- return (&knm->value.i64);
- case KSTAT_DATA_UINT64 :
- return (&knm->value.ui64);
- case KSTAT_DATA_STRING :
- return (KSTAT_NAMED_STR_PTR(knm));
- }
-
- return (NULL);
-}
-
-/*
- * kstat_free() - deallocated memory associated with a kstat
- *
- * paramters
- * kstat_t ksp - kstat to be deallocated
- *
- * returns
- * void
- */
-void
-kstat_free(kstat_t *ksp)
-{
- if (ksp != NULL) {
- if (ksp->ks_data != NULL)
- free(ksp->ks_data);
- free(ksp);
- }
-}
-
-uint32_t
-kstat_delta(kstat_t *pksp, kstat_t *cksp, char *name)
-{
- uint32_t *pv, *cv;
-
- pv = kstat_value(pksp, name);
- cv = kstat_value(cksp, name);
-
- return (u32_delta(*pv, *cv));
-}
diff --git a/usr/src/cmd/avs/dsstat/common.h b/usr/src/cmd/avs/dsstat/common.h
deleted file mode 100644
index 79805f8569..0000000000
--- a/usr/src/cmd/avs/dsstat/common.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _COMMON_H
-#define _COMMON_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Prototypes */
-void *kstat_value(kstat_t *, char *);
-kstat_t *kstat_retrieve(kstat_ctl_t *, kstat_t *);
-void kstat_free(kstat_t *);
-uint32_t kstat_delta(kstat_t *, kstat_t *, char *);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _COMMON_H */
diff --git a/usr/src/cmd/avs/dsstat/dsstat.c b/usr/src/cmd/avs/dsstat/dsstat.c
deleted file mode 100644
index a10ffc0a35..0000000000
--- a/usr/src/cmd/avs/dsstat/dsstat.c
+++ /dev/null
@@ -1,546 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <locale.h>
-
-#include <kstat.h>
-
-#include "dsstat.h"
-#include "multi_stats.h"
-
-/* Globals */
-int mode = 0;
-int interval = 1;
-int iterations = 1;
-int zflag = 0;
-int linesout = 0;
-
-short hflags = HEADERS_EXL;
-short dflags = 0;
-short rflags = 0;
-vslist_t *vs_top = NULL;
-
-void
-errout(char *msg)
-{
-
- (void) fprintf(stderr, msg);
-}
-
-void
-usage()
-{
- errout(gettext(
- "\ndsstat [-m <mode>[,<mode>]] [-f | -F] [-z] [-s <sets>] "
- "[-r <flags>] \\\n[-d <flags>] [<interval> [<count>]]\n\n"));
-}
-
-void
-help()
-{
- usage();
-
- errout(gettext("\t"
- "-d <flags> Specifies the statistics to be displayed\n\n"));
- errout(gettext("\t"
- " For 'cache' mode\n"));
- errout(gettext("\t"
- " Valid <flags> are 'rwfsdc', default <flags> are 'sf'\n"));
- errout(gettext("\t"
- " r=read, w=write, f=flags, s=summary,\n"));
- errout(gettext("\t"
- " only available for cache mode, need to combine with '-m'\n"));
- errout(gettext("\t"
- " d=destaged, c=write cancellations\n\n"));
- errout(gettext("\t"
- " For 'ii' mode;\n"));
- errout(gettext("\t"
- " Valid <flags> are 'rwtfps', default <flags> are 'sf'\n"));
- errout(gettext("\t"
- " r=read, w=write, t=timing, f=flags, p=percentages,\n"));
- errout(gettext("\t"
- " s=summary\n\n"));
- errout(gettext("\t"
- " For 'sndr' mode;\n"));
- errout(gettext("\t"
- " Valid <flags> are'rwtfpsq', default <flags> are 'spf'\n"));
- errout(gettext("\t"
- " r=read, w=write, t=timing, f=flags, p=percentages,\n"));
- errout(gettext("\t"
- " s=summary\n"));
- errout(gettext("\t"
- " only available for sndr mode, need to combine with '-m'\n"));
- errout(gettext("\t"
- " q=queue\n\n"));
- errout(gettext("\t"
- "-f prints field headers once for each iteration\n\n"));
- errout(gettext("\t"
- "-F prints field headers once, at the start of reporting\n\n"));
- errout(gettext("\t"
- "-h prints detailed usage message\n\n"));
- errout(gettext("\t"
- "-m <mode>[,<mode>] where mode is, 'cache', 'ii', or 'sndr'\n\n"));
- errout(gettext("\t"
- " Multiple modes may be specified as a comma separated list,\n"));
- errout(gettext("\t"
- " or multiple -m switches may be used.\n\n"));
- errout(gettext("\t"
- "-r <flags> specifies components to be reported\n\n"));
- errout(gettext("\t"
- " For 'cache' mode, this option is not used.\n\n"));
- errout(gettext("\t"
- " For 'ii' mode;\n"));
- errout(gettext("\t"
- " Valid <flags> are 'msbo', default <flags> are 'msbo'\n"));
- errout(gettext("\t"
- " m=master, s=shadow, b=bitmap, o=overflow\n\n"));
- errout(gettext("\t"
- " For 'sndr' mode;\n"));
- errout(gettext("\t"
- " Valid <flags> are 'nb', default <flags> are 'nb'\n"));
- errout(gettext("\t"
- " n=network, b=bitmap\n\n"));
- errout(gettext("\t"
- "-s <sets> outputs specified sets\n"));
- errout(gettext("\t"
- " Where <sets> is a comma delimited list of set names\n\n"));
- errout(gettext("\t"
- "-z suppress reports with zero value (no activity)\n\n"));
- errout(gettext("\t"
- "<interval> is the number of seconds between reports\n\n"));
- errout(gettext("\t"
- "<count> is the number of reports to be generated\n\n"));
-}
-
-void
-fail(int err, char *msg)
-{
- errout(gettext("\ndsstat: "));
- errout(msg);
-
- usage();
-
- errout(gettext("For detailed usage run \"dsstat -h\"\n"));
-
- exit(err);
-}
-
-int
-set_mode(char *user_modes)
-{
- char *m;
- int local_mode = 0;
-
- for (m = strtok(user_modes, ","); m != NULL; m = strtok(NULL, ",")) {
- if (local_mode != 0) {
- local_mode |= MULTI;
- }
-
- if (strncasecmp("sndr", m, strlen(m)) == 0) {
- local_mode |= SNDR;
- continue;
- }
-
- if (strncasecmp("ii", m, strlen(m)) == 0) {
- local_mode |= IIMG;
- continue;
- }
-
- if (strncasecmp("cache", m, strlen(m)) == 0) {
- local_mode |= SDBC;
- continue;
- }
-
- fail(DSSTAT_EINVAL, gettext("Invalid mode specified"));
- }
-
- return (local_mode);
-}
-
-short
-set_dflags(char *flags)
-{
- int index;
- short user_dflags = 0;
-
- for (index = 0; index < strlen(flags); index++) {
- switch (flags[index]) {
- case 'r':
- user_dflags |= READ;
- break;
- case 'w':
- user_dflags |= WRITE;
- break;
- case 't':
- user_dflags |= TIMING;
- break;
- case 'f':
- user_dflags |= FLAGS;
- break;
- case 'p':
- user_dflags |= PCTS;
- break;
- case 's':
- user_dflags |= SUMMARY;
- break;
- case 'd':
- user_dflags |= DESTAGED;
- break;
- case 'c':
- user_dflags |= WRCANCEL;
- break;
- case 'h':
- user_dflags |= RATIO;
- break;
- case 'q':
- user_dflags |= ASYNC_QUEUE;
- break;
- default:
- fail(DSSTAT_EINVAL,
- gettext("Invalid display-flags set\n"));
- }
- }
-
- return (user_dflags);
-}
-
-short
-set_rflags(char *flags)
-{
- int index;
- short user_rflags = 0;
-
- for (index = 0; index < strlen(flags); index++) {
- switch (flags[index]) {
- case 'm':
- user_rflags |= IIMG_MST;
- break;
- case 's':
- user_rflags |= IIMG_SHD;
- break;
- case 'b':
- user_rflags |= IIMG_BMP;
- user_rflags |= SNDR_BMP;
- break;
- case 'o':
- user_rflags |= IIMG_OVR;
- break;
- case 'n':
- user_rflags |= SNDR_NET;
- break;
- default:
- fail(DSSTAT_EINVAL,
- gettext("Invalid report-flags set\n"));
- }
- }
-
- return (user_rflags);
-}
-
-void
-set_vol_list(char *list)
-{
- vslist_t *pre;
- vslist_t *newvol;
- vslist_t *vslist;
- char *volume;
-
- for (volume = strtok(list, ","); volume != NULL;
- volume = strtok(NULL, ",")) {
- int dup = 0;
- char *vh = NULL;
- char *vn = NULL;
-
- /* get user-specified set information */
- if ((vn = strchr(volume, ':')) == NULL) {
- vn = volume;
- } else {
- *vn = '\0';
- vn++;
- vh = volume;
- }
-
- /* check for duplicates */
- dup = 0;
-
- for (vslist = vs_top; vslist != NULL; vslist = vslist->next) {
- if (vslist->volhost && vh) {
- if (strcmp(vslist->volhost, vh) == 0 &&
- strcmp(vslist->volname, vn) == 0)
- dup = 1;
- } else {
- if (strcmp(vslist->volname, vn) == 0)
- dup = 1;
- }
-
- pre = vslist;
- }
-
- if (dup)
- continue;
-
- /* initialize new vslist record */
- newvol = (vslist_t *)calloc(1, sizeof (vslist_t));
-
- newvol->volname = (char *)calloc((strlen(vn) + 1),
- sizeof (char));
- (void) strcpy(newvol->volname, vn);
-
- if (vh == NULL)
- goto save;
-
- newvol->volhost = (char *)calloc((strlen(vh) + 1),
- sizeof (char));
- (void) strcpy(newvol->volhost, vh);
-
-save:
- /* save record */
- if (vs_top == NULL) {
- vslist = vs_top = newvol;
- vslist->next = NULL;
- continue;
- }
-
- if (vslist == NULL) {
- vslist = pre->next = newvol;
- vslist->next = NULL;
- continue;
- }
- }
-}
-
-int
-main(int argc, char **argv)
-{
- extern char *optarg;
- extern int optind;
-
- int c;
- int error;
- short user_dflags = 0;
- short user_rflags = 0;
-
- /* Parse command line */
- while ((c = getopt(argc, argv, "d:fFhm:r:s:z")) != EOF) {
- switch (c) {
- case 'd': /* what to display */
- user_dflags = set_dflags(optarg);
- break;
- case 'f':
- hflags = HEADERS_ATT;
- break;
- case 'F':
- hflags = HEADERS_BOR;
- break;
- case 'h': /* usage */
- help();
- exit(0);
- break;
- case 'm': /* Mode */
- mode |= set_mode(optarg);
- break;
- case 'r': /* what to report on */
- user_rflags = set_rflags(optarg);
- break;
- case 's':
- set_vol_list(optarg);
- break;
- case 'z':
- zflag = 1;
- break;
-
- default:
- fail(DSSTAT_EINVAL,
- "Invalid argument specified\n");
- }
- }
-
- /* Parse additional arguments */
- if (optind < argc) {
- if ((interval = atoi(argv[optind])) <= 0) {
- fail(DSSTAT_EINVAL,
- gettext("Invalid interval specified.\n"));
- } else {
- iterations = -1;
- }
-
- optind++;
-
- if (optind < argc) {
- if ((iterations = atoi(argv[optind])) <= 0) {
- fail(DSSTAT_EINVAL,
- gettext("Invalid count specified.\n"));
- }
- }
-
- optind++;
- }
-
- if (optind < argc) {
- fail(DSSTAT_EINVAL,
- gettext("Too many parameters specified.\n"));
- }
-
- if (mode == 0)
- mode |= MULTI | IIMG | SNDR | SDBC;
-
- /* Select statistics to gather */
- if (mode & SNDR) {
- if (! (mode & MULTI)) {
- if (user_rflags & IIMG_BMP)
- user_rflags ^= IIMG_BMP;
-
- if ((user_dflags | SNDR_DIS_MASK) != SNDR_DIS_MASK) {
- fail(DSSTAT_EINVAL, gettext("Invalid "
- "display-flags for RemoteMirror\n"));
- }
-
- if ((user_rflags | SNDR_REP_MASK) != SNDR_REP_MASK) {
- fail(DSSTAT_EINVAL,
- gettext("Invalid report-flags for "
- "Remote Mirror\n"));
- }
- }
-
- if ((mode & MULTI) && (user_dflags & ASYNC_QUEUE)) {
- fail(DSSTAT_EINVAL, gettext("Remote Mirror async. queue"
- "statistics can not be displayed with mutiple "
- "modes."));
- }
-
- if (user_dflags)
- dflags = user_dflags;
- else
- dflags |= (SUMMARY | PCTS | FLAGS | RATIO);
-
- if (user_rflags)
- rflags = user_rflags;
- else
- rflags |= (SNDR_NET | SNDR_BMP);
- }
-
- if (mode & IIMG) {
- if (! (mode & MULTI)) {
- if (user_rflags & SNDR_BMP)
- user_rflags ^= SNDR_BMP;
-
- if ((user_dflags | IIMG_DIS_MASK) != IIMG_DIS_MASK) {
- fail(DSSTAT_EINVAL,
- gettext("Invalid display-flags for "
- "Point-in-Time Copy\n"));
- }
-
- if ((user_rflags | IIMG_REP_MASK) != IIMG_REP_MASK) {
- fail(DSSTAT_EINVAL,
- gettext("Invalid report-flags for "
- "Point-in-Time Copy\n"));
- }
- }
-
- if (user_dflags)
- dflags = user_dflags;
- else
- dflags |= (SUMMARY | PCTS | FLAGS | RATIO);
-
- if (user_rflags)
- rflags = user_rflags;
- else
- rflags |= (IIMG_MST | IIMG_SHD | IIMG_BMP | IIMG_OVR);
- }
-
- if (mode & SDBC) {
- if (! (mode & MULTI)) {
- if ((user_dflags | CACHE_DIS_MASK) != CACHE_DIS_MASK) {
- fail(DSSTAT_EINVAL, gettext("Invalid "
- "display-flags for CACHE\n"));
- }
-
- if ((user_rflags | CACHE_REP_MASK) != CACHE_REP_MASK) {
- fail(DSSTAT_EINVAL, gettext("Invalid "
- "report-flags for CACHE\n"));
- }
- } else {
- if ((user_dflags & DESTAGED) || (user_dflags & WRCANCEL)) {
- if (user_dflags & DESTAGED)
- fail(DSSTAT_EINVAL, gettext("Cache, destaged "
- "statistics can not be displayed with mutiple "
- "modes."));
- else
- fail(DSSTAT_EINVAL, gettext("Cache, write "
- "cancellations "
- "statistics can not be displayed with mutiple "
- "modes."));
- }
- }
-
- if (user_dflags)
- dflags = user_dflags;
- else
- if (mode & MULTI)
- dflags |= (SUMMARY);
- else
- dflags |= (SUMMARY | FLAGS);
-
- if (user_rflags)
- rflags = user_rflags;
- else
- rflags |= user_rflags;
- }
-
- error = do_stats();
-
- if (error == EAGAIN) {
- fail(DSSTAT_NOSTAT, gettext("No statistics available for the "
- "specified mode(s).\n"));
- }
-
- if (error == EINVAL) {
- fail(DSSTAT_EINVAL,
- gettext("Invalid kstat format detected.\n"));
- }
-
- if (error == ENOMEM) {
- fail(DSSTAT_ENOMEM,
- gettext("Unable to open kstat device for reading.\n"));
- }
-
- if (error == -1) {
- if (execv("/usr/sbin/dsstat", argv) != 0) {
- fail(DSSTAT_EMAP, gettext("Kstat is invalid.\n"));
- }
- }
-
- if (error) {
- fail(DSSTAT_EUNKNWN, gettext("An unknown error occured.\n"));
- }
-
- return (0);
-}
diff --git a/usr/src/cmd/avs/dsstat/dsstat.h b/usr/src/cmd/avs/dsstat/dsstat.h
deleted file mode 100644
index eb73bcd48c..0000000000
--- a/usr/src/cmd/avs/dsstat/dsstat.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _DSSTAT_H
-#define _DSSTAT_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct vslist_s
-{
- char *volname;
- char *volhost;
- struct vslist_s *next;
-} vslist_t;
-
-extern int mode;
-extern int interval;
-extern int iterations;
-extern int zflag;
-extern int linesout;
-extern short hflags;
-extern short dflags;
-extern short rflags;
-extern vslist_t *vs_top;
-
-/* kstat named character limit */
-#define NAMED_LEN 15
-
-/* Mode */
-#define MULTI 0x01
-#define SNDR 0x02
-#define IIMG 0x04
-#define SDBC 0x08
-
-/* Error codes */
-#define DSSTAT_SUCCESS 0 /* Success */
-#define DSSTAT_NOSTAT 1 /* No Statistics Avaiable */
-#define DSSTAT_EINVAL 2 /* Invalid Argument */
-#define DSSTAT_ENOMEM 3 /* No Memory Available To Get Statistics */
-#define DSSTAT_EUNKNWN 4 /* Unknown Error */
-#define DSSTAT_EMAP 5 /* Mapped kstat memory is invalid */
-
-/* Report flags */
-#define IIMG_MST 0x01
-#define IIMG_SHD 0x02
-#define IIMG_BMP 0x04
-#define IIMG_OVR 0x08
-
-#define SNDR_PRI 0x10
-#define SNDR_NET 0x20
-#define SNDR_BMP 0x40
-
-/* Display flags */
-#define SUMMARY 0x01
-#define READ 0x02
-#define WRITE 0x04
-#define TIMING 0x08
-#define FLAGS 0x10
-#define PCTS 0x20
-#define DESTAGED 0x40
-#define WRCANCEL 0x80
-#define RATIO 0x100
-#define ASYNC_QUEUE 0x200
-
-/* Flag masks */
-#define SNDR_REP_MASK (SNDR_PRI | SNDR_NET | SNDR_BMP)
-#define SNDR_DIS_MASK (SUMMARY | READ | WRITE | TIMING | FLAGS | PCTS | \
- RATIO | ASYNC_QUEUE)
-
-#define IIMG_REP_MASK (IIMG_MST | IIMG_SHD | IIMG_BMP | IIMG_OVR)
-#define IIMG_DIS_MASK (SUMMARY | READ | WRITE | TIMING | FLAGS | PCTS | RATIO)
-
-#define CACHE_REP_MASK 0
-#define CACHE_DIS_MASK (SUMMARY | READ | WRITE | FLAGS | DESTAGED | WRCANCEL)
-
-/* Field header defines */
-#define DISPLAY_LINES 19
-#define HEADERS_OUT 0x01 /* flag to show headers output for cycle */
-#define HEADERS_BOR 0x02 /* field headers at beginning of run */
-#define HEADERS_ATT 0x04 /* field headers all the time */
-#define HEADERS_EXL 0x08 /* field headers every X lines */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _DSSTAT_H */
diff --git a/usr/src/cmd/avs/dsstat/ii_stats.c b/usr/src/cmd/avs/dsstat/ii_stats.c
deleted file mode 100644
index e37ea891cb..0000000000
--- a/usr/src/cmd/avs/dsstat/ii_stats.c
+++ /dev/null
@@ -1,811 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <sys/mutex.h>
-
-#include <kstat.h>
-
-#include <sys/unistat/spcs_s.h>
-#include <sys/nsctl/dsw.h>
-#include "../../../uts/common/avs/ns/dsw/dsw_dev.h"
-#include <sys/nsctl/dsw_dev.h>
-
-#include "sdbc_stats.h"
-#include "ii_stats.h"
-
-#include "dsstat.h"
-#include "common.h"
-#include "report.h"
-
-static iistat_t *ii_top = NULL;
-
-void ii_add_stat(iistat_t *);
-iistat_t *ii_del_stat(iistat_t *);
-
-int ii_value_check(iistat_t *iistat);
-int ii_validate(kstat_t *ksp);
-int ii_vol_selected(kstat_t *);
-
-/*
- * ii_discover() - looks for new statistics to be monitored.
- * Verifies that any statistics found are now already being
- * monitored.
- *
- */
-int
-ii_discover(kstat_ctl_t *kc)
-{
- static int validated = 0;
-
- kstat_t *ksp;
-
- /* Loop on all kstats */
- for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) {
- char *kname;
- iistat_t *cur;
- iistat_t *iistat = NULL;
- kstat_t *mst_ksp;
- kstat_t *shd_ksp;
- kstat_t *bmp_ksp;
- kstat_t *ovr_ksp;
-
- /* Search for II set */
- if (strcmp(ksp->ks_class, II_KSTAT_CLASS) != 0)
- continue;
-
- if (kstat_read(kc, ksp, NULL) == -1)
- continue;
-
- /*
- * Validate kstat structure
- */
- if (! validated) {
- if (ii_validate(ksp))
- return (EINVAL);
-
- validated++;
- }
-
- /*
- * Duplicate check
- */
- for (cur = ii_top; cur != NULL; cur = cur->next) {
- char *cur_vname, *tst_vname;
- uint32_t cur_inst, tst_inst;
-
- cur_vname = cur->pre_set->ks_name;
- cur_inst = cur->pre_set->ks_instance;
-
- tst_vname = ksp->ks_name;
- tst_inst = ksp->ks_instance;
-
- if (strcmp(cur_vname, tst_vname) == 0 &&
- cur_inst == tst_inst)
- goto next;
- }
-
- /*
- * Initialize new record
- */
- iistat = (iistat_t *)calloc(1, sizeof (iistat_t));
-
- /*
- * Set kstat
- */
- iistat->pre_set = kstat_retrieve(kc, ksp);
-
- if (iistat->pre_set == NULL)
- goto next;
-
- iistat->collected |= GOT_SETSTAT;
-
- /*
- * Master kstat
- */
- kname = kstat_value(iistat->pre_set, DSW_SKSTAT_MSTIO);
-
- mst_ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
- iistat->pre_mst = kstat_retrieve(kc, mst_ksp);
-
- if (iistat->pre_mst == NULL)
- goto next;
-
- iistat->collected |= GOT_MSTSTAT;
-
- /*
- * Shadow kstat
- */
- kname = kstat_value(iistat->pre_set, DSW_SKSTAT_SHDIO);
-
- shd_ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
- iistat->pre_shd = kstat_retrieve(kc, shd_ksp);
-
- if (iistat->pre_shd == NULL)
- goto next;
-
- iistat->collected |= GOT_SHDSTAT;
-
- /*
- * Bitmap kstat
- */
- kname = kstat_value(iistat->pre_set, DSW_SKSTAT_BMPIO);
-
- bmp_ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
- iistat->pre_bmp = kstat_retrieve(kc, bmp_ksp);
-
- if (iistat->pre_bmp == NULL)
- goto next;
-
- iistat->collected |= GOT_BMPSTAT;
-
- /*
- * Overflow kstat
- */
- kname = kstat_value(iistat->pre_set, DSW_SKSTAT_OVRIO);
-
- ovr_ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
- iistat->pre_ovr = kstat_retrieve(kc, ovr_ksp);
-
- if (iistat->pre_ovr == NULL)
- goto next;
-
- iistat->collected |= GOT_OVRSTAT;
-
-next:
- /*
- * Check if we got a complete set of stats
- */
- if (iistat == NULL)
- continue;
-
- if (IIMG_COMPLETE(iistat->collected)) {
- (void) ii_del_stat(iistat);
- continue;
- }
-
- /*
- * Add to linked list
- */
- ii_add_stat(iistat);
- }
-
- if (ii_top == NULL)
- return (EAGAIN);
-
- return (0);
-}
-
-/*
- * ii_update() - updates all of the statistics currently being monitored.
- *
- */
-int
-ii_update(kstat_ctl_t *kc)
-{
- iistat_t *cur;
-
- for (cur = ii_top; cur != NULL; cur = cur->next) {
- char volname[KSTAT_STRLEN + 1];
- char *kname;
-
- kstat_t *ksp = NULL;
-
- cur->collected = 0;
-
- /*
- * Age off old stats
- */
- if (cur->cur_set != NULL) {
- kstat_free(cur->pre_set);
- kstat_free(cur->pre_mst);
- kstat_free(cur->pre_shd);
- kstat_free(cur->pre_bmp);
-
- cur->pre_set = cur->cur_set;
- cur->pre_mst = cur->cur_mst;
- cur->pre_shd = cur->cur_shd;
- cur->pre_bmp = cur->cur_bmp;
-
- if (cur->cur_ovr != NULL) {
- kstat_free(cur->pre_ovr);
- cur->pre_ovr = cur->cur_ovr;
- }
- }
-
- /*
- * Set kstat
- */
- (void) strncpy(volname, cur->pre_set->ks_name, KSTAT_STRLEN);
- volname[KSTAT_STRLEN] = '\0';
-
- ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, volname);
-
- if ((cur->cur_set = kstat_retrieve(kc, ksp)) == NULL)
- continue;
-
- cur->collected |= GOT_SETSTAT;
-
- /*
- * Validate set
- */
- if (strcmp(cur->pre_set->ks_name, cur->cur_set->ks_name) != 0 ||
- cur->pre_set->ks_instance != cur->cur_set->ks_instance)
- continue;
-
- /*
- * Master kstat
- */
- kname = kstat_value(cur->cur_set, DSW_SKSTAT_MSTIO);
-
- ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
-
- if ((cur->cur_mst = kstat_retrieve(kc, ksp)) == NULL)
- continue;
-
- cur->collected |= GOT_MSTSTAT;
-
- /*
- * Shadow kstat
- */
- kname = kstat_value(cur->cur_set, DSW_SKSTAT_SHDIO);
-
- ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
-
- if ((cur->cur_shd = kstat_retrieve(kc, ksp)) == NULL)
- continue;
-
- cur->collected |= GOT_SHDSTAT;
-
- /*
- * Bitmap kstat
- */
- kname = kstat_value(cur->pre_set, DSW_SKSTAT_BMPIO);
-
- ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
-
- if ((cur->cur_bmp = kstat_retrieve(kc, ksp)) == NULL)
- continue;
-
- cur->collected |= GOT_BMPSTAT;
-
- /*
- * Overflow kstat
- */
- kname = kstat_value(cur->cur_set, DSW_SKSTAT_OVRIO);
-
- ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
-
- if (ksp == NULL) {
- if (cur->pre_ovr != NULL) {
- kstat_free(cur->pre_ovr);
- cur->pre_ovr = NULL;
- }
- if (cur->cur_ovr != NULL) {
- kstat_free(cur->cur_ovr);
- cur->cur_ovr = NULL;
- }
- continue;
- }
-
- if (cur->pre_ovr == NULL) {
- if ((cur->pre_ovr = kstat_retrieve(kc, ksp)) == NULL)
- continue;
- } else {
- if ((cur->cur_ovr = kstat_retrieve(kc, ksp)) == NULL)
- continue;
- }
-
- cur->collected |= GOT_OVRSTAT;
- }
-
- return (0);
-}
-
-/*
- * ii_report() - outputs statistics for the statistics currently being
- * monitored. Deletes statistics for volumes that have been disabled.
- *
- */
-int
-ii_report()
-{
- uint32_t *flags;
- int padsz = 0;
- char pad[20] = {0};
- iistat_t *cur, *pre = NULL;
-
- if (ii_top == NULL) {
- return (0);
- }
-
- /* Create padding string for secondary report lines */
- if (dflags & FLAGS) {
- padsz += STAT_HDR_SIZE;
- padsz += STAT_HDR_SIZE;
- }
-
- if (dflags & PCTS)
- padsz += PCT_HDR_SIZE;
-
- if (padsz) {
- char fmt[20];
- (void) sprintf(fmt, "%%%ds", padsz);
- (void) sprintf(pad, fmt, "");
- }
-
- for (cur = ii_top; cur; /* CSTYLED */) {
- int first = 1;
- char data[20] = {0};
-
- /* Check to see if this is this a complete */
- if (IIMG_COMPLETE(cur->collected)) {
- char *c;
- char vol[(NAMED_LEN * 4) + 1] = {0};
- int offset;
- iistat_t *next;
-
- /* notify user of set being disabled */
- c = kstat_value(cur->pre_set, DSW_SKSTAT_SETA);
- (void) strncpy(vol, c, NAMED_LEN);
- c = kstat_value(cur->pre_set, DSW_SKSTAT_SETB);
- (void) strncat(vol, c, NAMED_LEN);
- c = kstat_value(cur->pre_set, DSW_SKSTAT_SETC);
- (void) strncat(vol, c, NAMED_LEN);
- c = kstat_value(cur->pre_set, DSW_SKSTAT_SETD);
- (void) strncat(vol, c, NAMED_LEN);
-
- offset = strlen(vol) - NAMED_LEN;
-
- if (offset < 0)
- offset = 0;
-
- (void) printf(DATA_C16, vol + offset);
- (void) printf(" %s\n", II_DISABLED);
-
- /* free memory and remove stat from list */
- next = ii_del_stat(cur);
-
- if (! pre)
- cur = ii_top = next;
- else
- cur = pre->next = next;
-
- continue;
- }
-
- /* Check to see if the user specified this volume */
- if (! ii_vol_selected(cur->pre_set))
- goto next;
-
- /* Check to see if zflag applies */
- if (zflag && ii_value_check(cur) == 0)
- goto next;
-
- /* Calculate flags */
- flags = kstat_value(cur->cur_set, DSW_SKSTAT_FLAGS);
-
- if (dflags & FLAGS) {
-
- char c[STAT_HDR_SIZE];
- char vtype[STAT_HDR_SIZE];
- char vstat[STAT_HDR_SIZE];
-
- if (*flags & DSW_GOLDEN)
- (void) strcpy(c, II_INDEPENDENT);
- else
- (void) strcpy(c, II_DEPENDENT);
-
- (void) sprintf(vtype, DATA_C2, c);
- (void) strcat(data, vtype);
-
- if (*flags & DSW_COPYINGP)
- (void) strcpy(c, II_COPYING);
- else
- (void) strcpy(c, NO_INFO);
-
-
- (void) sprintf(vstat, DATA_C2, c);
- (void) strcat(data, vstat);
- }
-
- /* Calculate sync needed precentage */
- if (dflags & PCTS) {
- char snpct[10];
- uint32_t *chkbits;
- uint32_t *cpybits;
- uint32_t *shdbits;
- uint32_t *volsize;
- float pct;
-
- cpybits =
- kstat_value(cur->cur_set, DSW_SKSTAT_COPYBITS);
-
- shdbits =
- kstat_value(cur->cur_set, DSW_SKSTAT_SHDBITS);
-
- volsize =
- kstat_value(cur->cur_set, DSW_SKSTAT_SIZE);
-
- *volsize /= DSW_SIZE;
-
- chkbits = *cpybits >= *shdbits ? cpybits : shdbits;
-
- pct = ((float)*chkbits / *volsize) * 100.0;
-
- (void) sprintf(snpct, DATA_F62, pct);
-
- (void) strcat(data, snpct);
- }
-
- /* Master statistics */
- if (rflags & IIMG_MST) {
- char *c;
- char vol[(NAMED_LEN * 4) + 1] = {0};
- int offset;
-
- c = kstat_value(cur->cur_set, DSW_SKSTAT_MSTA);
- (void) strncat(vol, c, NAMED_LEN);
- c = kstat_value(cur->cur_set, DSW_SKSTAT_MSTB);
- (void) strncat(vol, c, NAMED_LEN);
- c = kstat_value(cur->cur_set, DSW_SKSTAT_MSTC);
- (void) strncat(vol, c, NAMED_LEN);
- c = kstat_value(cur->cur_set, DSW_SKSTAT_MSTD);
- (void) strncat(vol, c, NAMED_LEN);
-
- offset = strlen(vol) - NAMED_LEN;
-
- if (offset < 0)
- offset = 0;
-
- header();
- (void) printf(DATA_C16, vol + offset);
- (void) printf("%s", data);
- (void) printf(ROLE_INF_FMT, II_MASTER);
-
- if (*flags & DSW_MSTOFFLINE) {
- (void) printf(" <<offline>>");
- linesout++;
- } else {
- io_report(cur->cur_mst, cur->pre_mst,
- sdbc_getstat(vol + offset));
- }
-
- (void) printf("\n");
-
- if (first) {
- (void) strcpy(data, strlen(pad) > 0 ? pad : "");
- first = 0;
- }
- }
-
- /* Shadow statistics */
- if (rflags & IIMG_SHD) {
- char *c;
- char vol[(NAMED_LEN * 4) + 1] = {0};
- int offset;
-
- c = kstat_value(cur->cur_set, DSW_SKSTAT_SETA);
- (void) strncat(vol, c, NAMED_LEN);
- c = kstat_value(cur->cur_set, DSW_SKSTAT_SETB);
- (void) strncat(vol, c, NAMED_LEN);
- c = kstat_value(cur->cur_set, DSW_SKSTAT_SETC);
- (void) strncat(vol, c, NAMED_LEN);
- c = kstat_value(cur->cur_set, DSW_SKSTAT_SETD);
- (void) strncat(vol, c, NAMED_LEN);
-
- offset = strlen(vol) - NAMED_LEN;
-
- if (offset < 0)
- offset = 0;
-
- header();
- (void) printf(DATA_C16, vol + offset);
- (void) printf("%s", data);
- (void) printf(ROLE_INF_FMT, II_SHADOW);
-
- if (*flags & DSW_SHDOFFLINE) {
- (void) printf(" <<offline>>");
- linesout++;
- } else {
- io_report(cur->cur_shd, cur->pre_shd,
- sdbc_getstat(vol + offset));
- }
-
- (void) printf("\n");
-
- if (first) {
- (void) strcpy(data, strlen(pad) > 0 ? pad : "");
- first = 0;
- }
- }
-
- /* Bitmap statistics */
- if (rflags & IIMG_BMP) {
- char *c;
- char vol[(NAMED_LEN * 4) + 1] = {0};
- int offset;
-
- c = kstat_value(cur->cur_set, DSW_SKSTAT_BMPA);
- (void) strncat(vol, c, NAMED_LEN);
- c = kstat_value(cur->cur_set, DSW_SKSTAT_BMPB);
- (void) strncat(vol, c, NAMED_LEN);
- c = kstat_value(cur->cur_set, DSW_SKSTAT_BMPC);
- (void) strncat(vol, c, NAMED_LEN);
- c = kstat_value(cur->cur_set, DSW_SKSTAT_BMPD);
- (void) strncat(vol, c, NAMED_LEN);
-
- offset = strlen(vol) - NAMED_LEN;
-
- if (offset < 0)
- offset = 0;
-
- header();
- (void) printf(DATA_C16, vol + offset);
- (void) printf("%s", data);
- (void) printf(ROLE_INF_FMT, II_BITMAP);
-
- if (*flags & DSW_BMPOFFLINE) {
- (void) printf(" <<offline>>");
- linesout++;
- } else {
- io_report(cur->cur_bmp, cur->pre_bmp,
- sdbc_getstat(vol + offset));
- }
- (void) printf("\n");
-
- if (first) {
- (void) strcpy(data, strlen(pad) > 0 ? pad : "");
- first = 0;
- }
- }
-
- /* Overflow statistics */
- if (rflags & IIMG_OVR) {
- char *c;
- char msg[20] = {0};
- char vol[(NAMED_LEN * 4) + 1] = {0};
- int offset;
-
- if (cur->cur_ovr == NULL && cur->pre_ovr != NULL)
- (void) strcpy(msg, " <<attached>>");
-
- if (! (cur->collected & GOT_OVRSTAT))
- (void) strcpy(msg, " <<not attached>>");
-
- c = kstat_value(cur->cur_set, DSW_SKSTAT_OVRA);
- (void) strncpy(vol, c, NAMED_LEN);
- c = kstat_value(cur->cur_set, DSW_SKSTAT_OVRB);
- (void) strncat(vol, c, NAMED_LEN);
- c = kstat_value(cur->cur_set, DSW_SKSTAT_OVRC);
- (void) strncat(vol, c, NAMED_LEN);
- c = kstat_value(cur->cur_set, DSW_SKSTAT_OVRD);
- (void) strncat(vol, c, NAMED_LEN);
-
- offset = strlen(vol) - NAMED_LEN;
-
- if (offset < 0)
- offset = 0;
-
- header();
- (void) printf(DATA_C16, vol + offset);
- (void) printf("%s", data);
- (void) printf(ROLE_INF_FMT, II_OVERFLOW);
-
- if (strlen(msg)) {
- (void) printf("%s\n", msg);
- linesout++;
- goto next;
- }
-
- if (*flags & DSW_OVROFFLINE) {
- (void) printf(" <<offline>>");
- linesout++;
- } else {
- io_report(cur->cur_ovr, cur->pre_ovr,
- sdbc_getstat(vol + offset));
- }
-
- (void) printf("\n");
-
- if (first) {
- (void) strcpy(data, strlen(pad) > 0 ? pad : "");
- first = 0;
- }
- }
-
-
-next:
- pre = cur;
- cur = cur->next;
- }
-
- return (0);
-}
-
-/*
- * ii_add_stat() - adds a fully populated iistat_t structure
- * to the linked list of currently monitored kstats. The structure
- * will be added in alphabetical order, using the volume name of
- * the shadow volume as the key.
- *
- */
-void
-ii_add_stat(iistat_t *iistat)
-{
-
- iistat_t *cur;
-
- if (ii_top == NULL) {
- ii_top = iistat;
- return;
- }
-
- for (cur = ii_top; cur != NULL; cur = cur->next) {
- if (strcmp(cur->pre_set->ks_name,
- iistat->pre_set->ks_name) <= 0) {
- /*
- * If we get to the last item in the list, then just
- * add this one to the end
- */
- if (cur->next == NULL) {
- cur->next = iistat;
- return;
- }
-
- if (strcmp(cur->next->pre_set->ks_name,
- iistat->pre_set->ks_name) > 0) {
- iistat->next = cur->next;
- cur->next = iistat;
- return;
- }
- } else {
- if (cur == ii_top)
- ii_top = iistat;
-
- iistat->next = cur;
-
- return;
- }
- }
-}
-
-/*
- * ii_del_stat() - deallocate memory for the structure being
- * passed in.
- *
- * parameters
- * iistat_t *iistat - structure to be deallocated
- *
- * returns
- * iistat_t * - pointer to the "next" structures in the
- * linked list. May be NULL if we are removing the last
- * structure in the linked list.
- *
- */
-iistat_t *
-ii_del_stat(iistat_t *iistat)
-{
-
- iistat_t *next = iistat->next;
-
- kstat_free(iistat->pre_set);
- kstat_free(iistat->pre_mst);
- kstat_free(iistat->pre_shd);
- kstat_free(iistat->pre_bmp);
- kstat_free(iistat->pre_ovr);
- kstat_free(iistat->cur_set);
- kstat_free(iistat->cur_mst);
- kstat_free(iistat->cur_shd);
- kstat_free(iistat->cur_bmp);
- kstat_free(iistat->cur_ovr);
-
- free(iistat);
-
- return (next);
-}
-
-int
-ii_value_check(iistat_t *iistat)
-{
- if (IIMG_COMPLETE(iistat->collected))
- return (1);
-
- if (io_value_check(iistat->pre_mst->ks_data,
- iistat->cur_mst->ks_data)) {
- return (1);
- }
-
- if (io_value_check(iistat->pre_shd->ks_data,
- iistat->cur_shd->ks_data)) {
- return (1);
- }
-
- if (io_value_check(iistat->pre_bmp->ks_data,
- iistat->cur_bmp->ks_data)) {
- return (1);
- }
-
- if (iistat->pre_ovr && iistat->cur_ovr) {
- if (io_value_check(iistat->pre_ovr->ks_data,
- iistat->cur_ovr->ks_data)) {
- return (1);
- }
- }
-
- return (0);
-}
-
-int
-ii_validate(kstat_t *ksp)
-{
- if (! kstat_value(ksp, DSW_SKSTAT_MSTIO) ||
- ! kstat_value(ksp, DSW_SKSTAT_SHDIO) ||
- ! kstat_value(ksp, DSW_SKSTAT_BMPIO) ||
- ! kstat_value(ksp, DSW_SKSTAT_OVRIO) ||
- ! kstat_value(ksp, DSW_SKSTAT_FLAGS) ||
- ! kstat_value(ksp, DSW_SKSTAT_MSTA) ||
- ! kstat_value(ksp, DSW_SKSTAT_SETA) ||
- ! kstat_value(ksp, DSW_SKSTAT_BMPA) ||
- ! kstat_value(ksp, DSW_SKSTAT_OVRA) ||
- ! kstat_value(ksp, DSW_SKSTAT_SHDBITS) ||
- ! kstat_value(ksp, DSW_SKSTAT_COPYBITS) ||
- ! kstat_value(ksp, DSW_SKSTAT_SIZE))
- return (1);
-
- return (0);
-}
-
-int
-ii_vol_selected(kstat_t *ksp)
-{
- vslist_t *vslist = vs_top;
-
- for (vslist = vs_top; vslist != NULL; vslist = vslist->next) {
- char *vn;
- int off = 0;
-
- vn = ksp->ks_name;
-
- if ((off = strlen(vn) - NAMED_LEN) <= 0) {
- off = 0;
- }
-
- if (strcmp(vslist->volname, &vn[off]) == 0) {
- break;
- }
- }
-
- if (vs_top != NULL && vslist == NULL) {
- return (0);
- } else {
- return (1);
- }
-}
diff --git a/usr/src/cmd/avs/dsstat/ii_stats.h b/usr/src/cmd/avs/dsstat/ii_stats.h
deleted file mode 100644
index 35307b4b95..0000000000
--- a/usr/src/cmd/avs/dsstat/ii_stats.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _II_STATS_H
-#define _II_STATS_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define GOT_SETSTAT 0x01
-#define GOT_MSTSTAT 0x02
-#define GOT_SHDSTAT 0x04
-#define GOT_BMPSTAT 0x08
-#define GOT_OVRSTAT 0x10
-
-#define GOT_COMPLETE_IIMG (GOT_SETSTAT|GOT_MSTSTAT|GOT_SHDSTAT|GOT_BMPSTAT)
-
-#define IIMG_COMPLETE(x) (((x) & (GOT_COMPLETE_IIMG)) != (GOT_COMPLETE_IIMG))
-
-/* II strings */
-#define II_KSTAT_MODULE "ii"
-#define II_KSTAT_CLASS "iiset"
-
-#define II_DISABLED "<<set disabled>>"
-#define II_INDEPENDENT "I"
-#define II_DEPENDENT "D"
-#define II_COPYING "C"
-#define II_MASTER "mst"
-#define II_SHADOW "shd"
-#define II_BITMAP "bmp"
-#define II_OVERFLOW "ovr"
-
-
-typedef struct iistat_s
-{
- kstat_t *pre_set;
- kstat_t *pre_mst;
- kstat_t *pre_shd;
- kstat_t *pre_bmp;
- kstat_t *pre_ovr;
- kstat_t *cur_set;
- kstat_t *cur_mst;
- kstat_t *cur_shd;
- kstat_t *cur_bmp;
- kstat_t *cur_ovr;
- int collected;
- struct iistat_s *next;
-} iistat_t;
-
-/* Prototypes */
-int ii_discover(kstat_ctl_t *);
-int ii_update(kstat_ctl_t *);
-int ii_report();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _II_STATS_H */
diff --git a/usr/src/cmd/avs/dsstat/multi_stats.c b/usr/src/cmd/avs/dsstat/multi_stats.c
deleted file mode 100644
index cac76d4cd6..0000000000
--- a/usr/src/cmd/avs/dsstat/multi_stats.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <kstat.h>
-
-#include "ii_stats.h"
-#include "sdbc_stats.h"
-#include "sndr_stats.h"
-
-#include "multi_stats.h"
-
-#include "dsstat.h"
-#include "common.h"
-#include "report.h"
-
-/*
- * do_stats() - called by main() to start monitoring
- *
- */
-int
-do_stats()
-{
- int error;
- int pass;
-
- /* Collection/reporting loop */
- for (pass = 0; ; pass++) { /* CSTYLED */
- if (iterations != -1 && pass >= iterations)
- return (0);
-
- error = discover();
-
- if (error == ENOMEM || error == EINVAL)
- return (error);
-
- if (error == EAGAIN && pass == 0)
- return (error);
-
- (void) sleep(interval);
-
- if ((error = update()) != 0)
- return (error);
-
- if (report())
- break;
- }
-
- /* No stats on this system */
- return (EAGAIN);
-}
-
-int
-discover()
-{
- int err = 0;
-
- int sdbc_err = 0;
- int sndr_err = 0;
- int ii_err = 0;
-
- kstat_ctl_t *kc;
-
- if ((kc = kstat_open()) == NULL)
- return (ENOMEM);
-
- if (mode & SDBC) {
- sdbc_err = sdbc_discover(kc);
- err = sdbc_err;
- if (sdbc_err && !(mode & MULTI))
- goto fail;
- if (sdbc_err && (mode & MULTI) && sdbc_err != EAGAIN)
- goto fail;
- }
-
- if (mode & SNDR) {
- sndr_err = sndr_discover(kc);
- err = sndr_err;
- if (sndr_err && !(mode & MULTI))
- goto fail;
- if (sndr_err && (mode & MULTI) && sndr_err != EAGAIN)
- goto fail;
- }
-
- if (mode & IIMG) {
- ii_err = ii_discover(kc);
- err = ii_err;
- if (ii_err && !(mode & MULTI))
- goto fail;
- if (ii_err && ii_err != EAGAIN && (mode & MULTI))
- goto fail;
- }
-
- (void) kstat_close(kc);
- if (sdbc_err && sndr_err && ii_err)
- return (err);
- else
- return (0);
-
-fail:
- (void) kstat_close(kc);
- return (err);
-}
-
-int
-update()
-{
- int err = 0;
-
- int sdbc_err = 0;
- int sndr_err = 0;
- int ii_err = 0;
-
- kstat_ctl_t *kc;
-
- if ((kc = kstat_open()) == NULL)
- goto fail;
-
- if (mode & SDBC) {
- sdbc_err = sdbc_update(kc);
- err = sdbc_err;
- if (sdbc_err && !(mode & MULTI))
- goto fail;
- if (sdbc_err && (mode & MULTI) && sdbc_err != EAGAIN)
- goto fail;
- }
-
- if (mode & SNDR) {
- sndr_err = sndr_update(kc);
- err = sndr_err;
- if (sndr_err && !(mode & MULTI))
- goto fail;
- if (sndr_err && (mode & MULTI) && sndr_err != EAGAIN)
- goto fail;
- }
-
- if (mode & IIMG) {
- ii_err = ii_update(kc);
- err = ii_err;
- if (ii_err && !(mode & MULTI))
- goto fail;
- if (ii_err && (mode & MULTI) && ii_err != EAGAIN)
- goto fail;
- }
-
- (void) kstat_close(kc);
- if (sdbc_err && sndr_err && ii_err)
- return (err);
- else
- return (0);
-
-fail:
- (void) kstat_close(kc);
- return (err);
-}
-
-int
-report()
-{
- int err = 0;
-
- int sdbc_err = 0;
- int sndr_err = 0;
- int ii_err = 0;
-
- hflags &= (HEADERS_EXL | HEADERS_ATT | HEADERS_BOR);
-
- if (mode & SNDR)
- if (sndr_err = sndr_report())
- err = sndr_err;
-
- if (mode & IIMG)
- if (ii_err = ii_report())
- err = ii_err;
-
- if ((mode & SDBC) && !(mode & MULTI))
- if (sdbc_err = sdbc_report())
- err = sdbc_err;
-
- return (err);
-}
diff --git a/usr/src/cmd/avs/dsstat/multi_stats.h b/usr/src/cmd/avs/dsstat/multi_stats.h
deleted file mode 100644
index 2c092d4fab..0000000000
--- a/usr/src/cmd/avs/dsstat/multi_stats.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _MULTI_STATS_H
-#define _MULTI_STATS_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Prototypes */
-int do_stats();
-int discover();
-int update();
-int report();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _MULTI_STATS_H */
diff --git a/usr/src/cmd/avs/dsstat/report.c b/usr/src/cmd/avs/dsstat/report.c
deleted file mode 100644
index 4b91c255d5..0000000000
--- a/usr/src/cmd/avs/dsstat/report.c
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#include <kstat.h>
-#include <sys/inttypes.h>
-
-#include <nsctl.h>
-
-#include "dsstat.h"
-#include "common.h"
-
-#include "sdbc_stats.h"
-#include "report.h"
-
-extern short dflags;
-
-/*
- * Return the number of ticks delta between two hrtime_t
- * values. Attempt to cater for various kinds of overflow
- * in hrtime_t - no matter how improbable.
- */
-uint64_t
-hrtime_delta(hrtime_t old, hrtime_t new)
-{
-
- uint64_t del;
-
- if ((new >= old) && (old >= 0L)) {
- return (new - old);
- } else {
- /*
- * We've overflowed the positive portion of an
- * hrtime_t.
- */
- if (new < 0L) {
- /*
- * The new value is negative. Handle the
- * case where the old value is positive or
- * negative.
- */
- uint64_t n1;
- uint64_t o1;
-
- n1 = -new;
-
- if (old > 0L) {
- return (n1 - old);
- } else {
- o1 = -old;
- del = n1 - o1;
- return (del);
- }
- } else {
- /*
- * Either we've just gone from being negative
- * to positive *or* the last entry was positive
- * and the new entry is also positive but *less*
- * than the old entry. This implies we waited
- * quite a few days on a very fast system between
- * iostat displays.
- */
- if (old < 0L) {
- uint64_t o2;
-
- o2 = -old;
- del = UINT64_MAX - o2;
- } else {
- del = UINT64_MAX - old;
- }
-
- del += new;
-
- return (del);
- }
- }
-}
-
-/*
- * Take the difference of an unsigned 32
- * bit int attempting to cater for
- * overflow.
- */
-uint32_t
-u32_delta(uint32_t old, uint32_t new)
-{
-
- if (new >= old)
- return (new - old);
- else
- return ((UINT32_MAX - old) + new + 1);
-}
-
-/*
- * Take the difference of an unsigned 64
- * bit int attempting to cater for
- * overflow.
- */
-uint64_t
-u64_delta(uint64_t old, uint64_t new)
-{
-
- if (new >= old)
- return (new - old);
- else
- return ((UINT64_MAX - old) + new + 1);
-}
-
-/*
- * io_report() - diffs and reports data contained in
- * kstat_io_t structures.
- *
- * parameters
- * kstat_io_t *cur - pointer to current data
- *
- * kstat_io_t *pre - pointer to data as it was
- * at the beginning of an interval.
- */
-void
-io_report(kstat_t *cur_kstat, kstat_t *pre_kstat, sdbcstat_t *sdbcstat)
-{
- sdbcvals_t vals;
-
- double rd_cnt, wr_cnt;
- double rd_kb, wr_kb, hr_etime;
-
- double rtm, tps, avs, etime;
-
- kstat_io_t *cur = cur_kstat->ks_data;
- kstat_io_t *pre = pre_kstat->ks_data;
-
- if (sdbcstat &&
- sdbc_getvalues(sdbcstat, &vals, (SDBC_KBYTES | SDBC_INTAVG)))
- return;
-
- /* Time */
- hr_etime = hrtime_delta(pre_kstat->ks_snaptime, cur_kstat->ks_snaptime);
- etime = hr_etime / (double)NANOSEC;
-
- /* Read count */
- rd_cnt = (double)u32_delta(pre->reads, cur->reads);
- if (rd_cnt) rd_cnt /= etime;
-
- /* Bytes read */
- rd_kb = (double)u64_delta(pre->nread, cur->nread) / KILOBYTE;
- if (rd_kb) rd_kb /= etime;
-
- /* Write count */
- wr_cnt = (double)u32_delta(pre->writes, cur->writes);
- if (wr_cnt) wr_cnt /= etime;
-
- /* Bytes written */
- wr_kb = (double)u64_delta(pre->nwritten, cur->nwritten) / KILOBYTE;
- if (wr_kb) wr_kb /= etime;
-
- /* Calculate service times */
- avs = (double)hrtime_delta(pre->rlentime, cur->rlentime) / hr_etime;
- tps = (double)rd_cnt + wr_cnt;
-
- if (tps > 0)
- rtm = (1000 / tps) * avs;
- else
- rtm = 0.0;
-
- /* Output */
- if (dflags & SUMMARY) {
- if ((mode & MULTI) && (mode & SDBC)) {
- if (sdbcstat) {
- (void) printf(KPS_INF_FMT,
- (float)vals.total_cache);
- (void) printf(KPS_INF_FMT,
- (float)vals.total_disk);
- } else {
- (void) printf(DATA_C6, NO_INFO);
- (void) printf(KPS_INF_FMT, rd_kb + wr_kb);
- }
- } else
- (void) printf(KPS_INF_FMT, rd_kb + wr_kb);
-
- (void) printf(TPS_INF_FMT, (uint32_t)(rd_cnt + wr_cnt));
- (void) printf(SVT_INF_FMT, rtm);
-
- goto done;
- }
-
- if (dflags & READ) {
- if ((mode & MULTI) && (mode & SDBC)) {
- if (sdbcstat) {
- (void) printf(KPS_INF_FMT,
- (float)vals.cache_read);
- (void) printf(KPS_INF_FMT,
- (float)vals.disk_read);
- } else {
- (void) printf(DATA_C6, NO_INFO);
- (void) printf(KPS_INF_FMT, rd_kb);
- }
-
- } else
- (void) printf(KPS_INF_FMT, rd_kb);
-
- (void) printf(TPS_INF_FMT, (uint32_t)rd_cnt);
- }
-
- if (dflags & WRITE) {
- if ((mode & MULTI) && (mode & SDBC)) {
- if (sdbcstat) {
- (void) printf(KPS_INF_FMT,
- (float)vals.cache_write);
- (void) printf(KPS_INF_FMT,
- (float)vals.disk_write);
- } else {
- (void) printf(DATA_C6, NO_INFO);
- (void) printf(KPS_INF_FMT, wr_kb);
- }
-
- } else
- (void) printf(KPS_INF_FMT, wr_kb);
-
- (void) printf(TPS_INF_FMT, (uint32_t)wr_cnt);
- }
-
- if (dflags & TIMING) {
- (void) printf(SVT_INF_FMT, rtm);
- }
-
-done:
- linesout++;
-}
-
-int
-io_value_check(kstat_io_t *pre, kstat_io_t *cur)
-{
- if (u32_delta(pre->reads, cur->reads))
- return (1);
- if (u32_delta(pre->writes, cur->writes))
- return (1);
-
- return (0);
-}
-
-/*
- * cd_report() - reports cache desriptor related statistics
- * based on the dflags global variable
- *
- * parameters
- * sdbcstat_t *sdbcstat - pointer to the cache structure
- * to be reported on.
- */
-void
-cd_report(sdbcstat_t *sdbcstat)
-{
- sdbcvals_t vals;
-
- /* Extract statistics, average for time */
- if (sdbc_getvalues(sdbcstat, &vals, (SDBC_KBYTES | SDBC_INTAVG)))
- return;
-
- /* Output */
- if (rflags & MULTI) {
- (void) printf(VOL_HDR_FMT, "");
-
- if (dflags & FLAGS) {
- (void) printf(STAT_HDR_FMT, "");
- (void) printf(STAT_HDR_FMT, "");
- }
-
- if (dflags & PCTS)
- (void) printf(PCT_HDR_FMT, "");
-
- if (dflags & SUMMARY) {
- (void) printf(KPS_INF_FMT, (float)vals.total_cache);
- (void) printf(DATA_C4, NO_INFO);
- (void) printf(DATA_C4, NO_INFO);
- (void) printf("\n");
- linesout++;
- return;
- }
-
- if (dflags & READ) {
- (void) printf(KPS_INF_FMT, (float)vals.cache_read);
- (void) printf(DATA_C4, NO_INFO);
- }
-
- if (dflags & WRITE) {
- (void) printf(KPS_INF_FMT, (float)vals.cache_write);
- (void) printf(DATA_C4, NO_INFO);
- }
-
- if (dflags & TIMING) {
- (void) printf(DATA_C4, NO_INFO);
- }
-
- linesout++;
- (void) printf("\n");
- return;
- }
-
- if (dflags & SUMMARY) {
- (void) printf(DATA_I32, vals.total_cache);
- (void) printf(DATA_I32, vals.total_disk);
- (void) printf(HIT_INF_FMT, vals.cache_hit);
-
- linesout++;
- (void) printf("\n");
- return;
- }
-
- if (dflags & READ) {
- (void) printf(DATA_I32, vals.cache_read);
- (void) printf(DATA_I32, vals.disk_read);
- (void) printf(HIT_INF_FMT, vals.read_hit);
- }
-
- if (dflags & WRITE) {
- (void) printf(DATA_I32, vals.cache_write);
- (void) printf(DATA_I32, vals.disk_write);
- (void) printf(HIT_INF_FMT, vals.write_hit);
- }
-
- if (dflags & DESTAGED)
- (void) printf(DATA_I32, vals.destaged);
-
- if (dflags & WRCANCEL)
- (void) printf(DATA_I32, vals.write_cancellations);
-
- linesout++;
- (void) printf("\n");
-}
-
-/*
- * header() - outputs an appropriate header by referencing the
- * global variables dflsgs and rflags
- *
- */
-void
-header()
-{
- if (hflags & HEADERS_EXL)
- if ((linesout % DISPLAY_LINES) != 0)
- return;
-
- if (hflags & HEADERS_BOR)
- if (linesout != 0)
- return;
-
- if (hflags & HEADERS_ATT)
- if (hflags & HEADERS_OUT)
- return;
- else
- hflags |= HEADERS_OUT;
-
- if (linesout)
- (void) printf("\n");
-
- (void) printf(VOL_HDR_FMT, SET_HDR_TXT);
-
- if (dflags & FLAGS) {
- (void) printf(STAT_HDR_FMT, TYPE_HDR_TXT);
- (void) printf(STAT_HDR_FMT, STAT_HDR_TXT);
- }
-
- if (dflags & ASYNC_QUEUE)
- (void) printf(STAT_HDR_FMT, QUEUE_HDR_TXT);
-
- if (dflags & PCTS)
- (void) printf(PCT_HDR_FMT, PCT_HDR_TXT);
-
- (void) printf(ROLE_HDR_FMT, ROLE_HDR_TXT);
-
- if (dflags & ASYNC_QUEUE) {
- (void) printf(TPS_HDR_FMT, QUEUE_ITEMS_TXT);
- (void) printf(KPS_HDR_FMT, QUEUE_KBYTES_TXT);
- (void) printf(TPS_HDR_FMT, QUEUE_ITEMS_HW_TXT);
- (void) printf(KPS_HDR_FMT, QUEUE_KBYTES_HW_TXT);
- }
-
- if (dflags & SUMMARY) {
- if ((mode & MULTI) && (mode & SDBC)) {
- (void) printf(KPS_HDR_FMT, CKPS_HDR_TXT);
- (void) printf(KPS_HDR_FMT, DKPS_HDR_TXT);
- } else
- (void) printf(KPS_HDR_FMT, KPS_HDR_TXT);
- (void) printf(TPS_HDR_FMT, TPS_HDR_TXT);
- (void) printf(SVT_HDR_FMT, SVT_HDR_TXT);
-
- (void) printf("\n");
-
- return;
- }
-
- if (dflags & READ) {
- if ((mode & MULTI) && (mode & SDBC)) {
- (void) printf(KPS_HDR_FMT, CRKPS_HDR_TXT);
- (void) printf(KPS_HDR_FMT, DRKPS_HDR_TXT);
- } else
- (void) printf(KPS_HDR_FMT, RKPS_HDR_TXT);
-
- (void) printf(TPS_HDR_FMT, RTPS_HDR_TXT);
- }
-
- if (dflags & WRITE) {
- if ((mode & MULTI) && (mode & SDBC)) {
- (void) printf(KPS_HDR_FMT, CWKPS_HDR_TXT);
- (void) printf(KPS_HDR_FMT, DWKPS_HDR_TXT);
- } else
- (void) printf(KPS_HDR_FMT, WKPS_HDR_TXT);
-
- (void) printf(TPS_HDR_FMT, WTPS_HDR_TXT);
- }
-
- if (dflags & TIMING)
- (void) printf(SVT_HDR_FMT, SVT_HDR_TXT);
-
- (void) printf("\n");
-}
diff --git a/usr/src/cmd/avs/dsstat/report.h b/usr/src/cmd/avs/dsstat/report.h
deleted file mode 100644
index 56f7a21cb8..0000000000
--- a/usr/src/cmd/avs/dsstat/report.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _REPORT_H
-#define _REPORT_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Prototypes */
-uint64_t hrtime_delta(hrtime_t, hrtime_t);
-uint32_t u32_delta(uint32_t, uint32_t);
-uint64_t u64_delta(uint64_t, uint64_t);
-void io_report(kstat_t *, kstat_t *, sdbcstat_t *);
-int io_value_check(kstat_io_t *, kstat_io_t *);
-void cd_report(sdbcstat_t *);
-void header();
-
-/* BEGIN CSTYLED */
-/* END CSTYLED */
-
-#define VOL_HDR_FMT "%-16s"
-#define VOL_HDR_SIZE 17
-#define SET_HDR_TXT "name"
-
-#define STAT_HDR_FMT "%3s"
-#define STAT_HDR_SIZE 3
-#define STAT_HDR_TXT "s"
-#define TYPE_HDR_TXT "t"
-
-#define ROLE_HDR_FMT "%5s"
-#define ROLE_HDR_SIZE 5
-#define ROLE_INF_FMT " %4s"
-#define ROLE_HDR_TXT "role"
-
-#define PCT_HDR_FMT "%7s"
-#define PCT_HDR_SIZE 7
-#define PCT_INF_FMT " %6.2f"
-#define SN_HDR_TXT "sn"
-#define PCT_HDR_TXT "pct"
-
-#define KPS_HDR_FMT "%7s"
-#define KPS_HDR_SIZE 7
-#define KPS_INF_FMT " %6.0f"
-#define KPS_HDR_TXT "kps"
-#define RKPS_HDR_TXT "rkps"
-#define WKPS_HDR_TXT "wkps"
-#define CKPS_HDR_TXT "ckps"
-#define DKPS_HDR_TXT "dkps"
-#define CRKPS_HDR_TXT "crkps"
-#define CWKPS_HDR_TXT "cwkps"
-#define DRKPS_HDR_TXT "drkps"
-#define DWKPS_HDR_TXT "dwkps"
-
-#define TPS_HDR_FMT "%6s"
-#define TPS_HDR_SIZE 6
-#define TPS_INF_FMT " %5u"
-#define TPS_HDR_TXT "tps"
-#define RTPS_HDR_TXT "rtps"
-#define WTPS_HDR_TXT "wtps"
-
-#define SVT_HDR_FMT "%5s"
-#define SVT_HDR_SIZE 5
-#define SVT_INF_FMT " %4.0f"
-#define SVT_HDR_TXT "svt"
-
-#define HIT_HDR_FMT "%6s"
-#define HIT_HDR_SIZE 6
-#define HIT_INF_FMT " %5.1f"
-#define HIT_PAD_FMT " %5s"
-#define HIT_HDR_TXT "hit"
-#define RHIT_HDR_TXT "rhit"
-#define WHIT_HDR_TXT "whit"
-
-#define QUEUE_HDR_TXT "q"
-#define QUEUE_ITEMS_TXT "qi"
-#define QUEUE_KBYTES_TXT "qk"
-#define QUEUE_ITEMS_HW_TXT "qhwi"
-#define QUEUE_KBYTES_HW_TXT "qhwk"
-
-#define NO_INFO "-"
-
-#define DATA_C16 "%-16s"
-#define DATA_C2 " %2s"
-#define DATA_C4 " %4s"
-#define DATA_C5 " %5s"
-#define DATA_C6 " %6s"
-#define DATA_I32 " %6u"
-#define DATA_I64 " %6llu"
-#define DATA_F62 " %6.2f"
-#define DATA_F60 " %6.0f"
-#define DATA_F50 " %5.0f"
-#define DATA_F40 " %4.0f"
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _REPORT_H */
diff --git a/usr/src/cmd/avs/dsstat/sdbc_stats.c b/usr/src/cmd/avs/dsstat/sdbc_stats.c
deleted file mode 100644
index f1af1acdd0..0000000000
--- a/usr/src/cmd/avs/dsstat/sdbc_stats.c
+++ /dev/null
@@ -1,788 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <inttypes.h>
-
-#include <kstat.h>
-
-#include <sys/nsctl/nsctl.h>
-#include <sys/nsctl/sd_bcache.h>
-
-#include "sdbc_stats.h"
-
-#include "dsstat.h"
-#include "common.h"
-#include "report.h"
-
-static sdbcstat_t *sdbc_top;
-kstat_t *sdbc_global = NULL;
-
-void sdbc_header();
-int sdbc_value_check(sdbcstat_t *);
-int sdbc_validate(kstat_t *);
-uint32_t sdbc_getdelta(sdbcstat_t *, char *);
-
-void sdbc_addstat(sdbcstat_t *);
-sdbcstat_t *sdbc_delstat(sdbcstat_t *);
-void center(int, char *);
-
-/*
- * sdbc_discover() - looks for new statistics to be monitored.
- * Verifies that any statistics found are now already being
- * monitored.
- *
- */
-int
-sdbc_discover(kstat_ctl_t *kc)
-{
- static int validated = 0;
-
- kstat_t *ksp;
-
- for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) {
- int kinst;
- char kname[KSTAT_STRLEN + 1];
- sdbcstat_t *cur;
- sdbcstat_t *sdbcstat = NULL;
- kstat_t *io_ksp;
-
- if (strcmp(ksp->ks_module, SDBC_KSTAT_MODULE) != 0 ||
- strncmp(ksp->ks_name, SDBC_KSTAT_CDSTATS, 2) != 0)
- continue;
-
- if (kstat_read(kc, ksp, NULL) == -1)
- continue;
-
- /*
- * Validate kstat structure
- */
- if (! validated) {
- if (sdbc_validate(ksp))
- return (EINVAL);
-
- validated++;
- }
-
- /*
- * Duplicate check
- */
- for (cur = sdbc_top; cur; cur = cur->next) {
- char *cur_vname, *tst_vname;
-
- cur_vname = kstat_value(cur->pre_set,
- SDBC_CDKSTAT_VOL_NAME);
-
- tst_vname = kstat_value(ksp,
- SDBC_CDKSTAT_VOL_NAME);
-
- if (strncmp(cur_vname, tst_vname, NAMED_LEN) == 0)
- goto next;
- }
-
- /*
- * Initialize new record
- */
- sdbcstat = (sdbcstat_t *)calloc(1, sizeof (sdbcstat_t));
-
- kinst = ksp->ks_instance;
-
- /*
- * Set kstat
- */
- sdbcstat->pre_set = kstat_retrieve(kc, ksp);
-
- if (sdbcstat->pre_set == NULL)
- goto next;
-
- sdbcstat->collected |= GOT_SET_KSTAT;
-
- /*
- * I/O kstat
- */
- (void) sprintf(kname, "%s%d", SDBC_IOKSTAT_CDSTATS, kinst);
-
- io_ksp = kstat_lookup(kc, SDBC_KSTAT_MODULE, kinst, kname);
- sdbcstat->pre_io = kstat_retrieve(kc, io_ksp);
-
- if (sdbcstat->pre_io == NULL)
- goto next;
-
- sdbcstat->collected |= GOT_IO_KSTAT;
-
-next:
- /*
- * Check if we got a complete set of stats
- */
- if (sdbcstat == NULL)
- continue;
-
- if (SDBC_COMPLETE(sdbcstat->collected)) {
- (void) sdbc_delstat(sdbcstat);
- continue;
- }
-
- sdbc_addstat(sdbcstat);
- }
-
- if (sdbc_top == NULL)
- return (EAGAIN);
-
- return (0);
-}
-
-/*
- * sdbc_update() - updates all of the statistics currently being monitored.
- *
- */
-int
-sdbc_update(kstat_ctl_t *kc)
-{
- kstat_t *ksp;
- sdbcstat_t *cur;
-
- /* Update global kstat information */
- ksp = kstat_lookup(kc, SDBC_KSTAT_MODULE, -1, SDBC_KSTAT_GSTATS);
-
- if (ksp == NULL)
- return (EAGAIN);
-
- if (sdbc_global)
- kstat_free(sdbc_global);
-
- sdbc_global = kstat_retrieve(kc, ksp);
-
- for (cur = sdbc_top; cur != NULL; cur = cur->next) {
- int kinst;
- char *kname, *cname, *pname;
-
- kstat_t *set_ksp, *io_ksp;
-
- cur->collected = 0;
-
- /*
- * Age off old stats
- */
- if (cur->cur_set != NULL) {
- kstat_free(cur->pre_set);
- kstat_free(cur->pre_io);
-
- cur->pre_set = cur->cur_set;
- cur->pre_io = cur->cur_io;
- }
-
- /*
- * Update set kstat
- */
- kinst = cur->pre_set->ks_instance;
- kname = cur->pre_set->ks_name;
-
- set_ksp = kstat_lookup(kc, SDBC_KSTAT_MODULE, kinst, kname);
-
- if ((cur->cur_set = kstat_retrieve(kc, set_ksp)) == NULL)
- continue;
-
- cur->collected |= GOT_SET_KSTAT;
-
- /*
- * Validate set
- */
- pname = kstat_value(cur->pre_set, SDBC_CDKSTAT_VOL_NAME);
- cname = kstat_value(cur->cur_set, SDBC_CDKSTAT_VOL_NAME);
-
- if (strncmp(pname, cname, NAMED_LEN) != 0)
- continue;
-
- /*
- * Update I/O kstat
- */
- kinst = cur->pre_io->ks_instance;
- kname = cur->pre_io->ks_name;
-
- io_ksp = kstat_lookup(kc, SDBC_KSTAT_MODULE, kinst, kname);
-
- if ((cur->cur_io = kstat_retrieve(kc, io_ksp)) == NULL)
- continue;
-
- cur->collected |= GOT_IO_KSTAT;
- }
-
- return (0);
-}
-
-/*
- * sdbc_report() - outputs statistics for the statistics currently being
- * monitored. Deletes statistics for volumes that have been disabled.
- *
- */
-int
-sdbc_report()
-{
- vslist_t *vslist = vs_top;
- sdbcstat_t *cur, *pre = NULL;
-
- if (sdbc_top == NULL)
- return (0);
-
- for (cur = sdbc_top; cur != NULL; ) { /* CSTYLED */
- static uint32_t linesout = 0;
- uint32_t *offline;
-
- char volname[NAMED_LEN + 1];
- char rmode[STAT_HDR_SIZE];
- char wmode[STAT_HDR_SIZE];
-
- /* Parse volume name */
- (void) strncpy(volname, kstat_value(cur->pre_set,
- SDBC_CDKSTAT_VOL_NAME), NAMED_LEN);
- volname[NAMED_LEN] = '\0';
-
- /* Check to see if the user specified this volume */
- for (vslist = vs_top; vslist != NULL; vslist = vslist->next)
- if (strcmp(volname, vslist->volname) == 0)
- break;
-
- if (vs_top != NULL && vslist == NULL)
- goto next;
-
- /* Check if volume is offline and zflag applies */
- if (zflag && sdbc_value_check(cur) == 0)
- goto next;
-
- /* Output volume name */
- sdbc_header();
-
- (void) printf(DATA_C16, volname);
-
- if (SDBC_COMPLETE(cur->collected)) {
- sdbcstat_t *next = sdbc_delstat(cur);
-
- if (! pre)
- cur = sdbc_top = next;
- else
- cur = pre->next = next;
-
- (void) printf(" <<volume disabled>>\n");
- continue;
- }
-
- offline = kstat_value(cur->cur_set, SDBC_CDKSTAT_FAILED);
- if (*offline) {
- (void) printf(" <<volume offline>>\n");
- linesout++;
- goto next;
- }
-
- /* Type/status flags */
- if (dflags & FLAGS) {
-
- uint32_t *dhint, *nhint;
- uint32_t hints;
-
- dhint = kstat_value(cur->cur_set, SDBC_CDKSTAT_CDHINTS);
- nhint = kstat_value(sdbc_global, SDBC_GKSTAT_NODEHINTS);
-
- if (! nhint)
- return (EINVAL);
-
- hints = *nhint;
- hints &= (NSC_FORCED_WRTHRU | NSC_NO_FORCED_WRTHRU |
- NSC_NOCACHE);
- hints |= *dhint;
-
- if (hints & NSC_NOCACHE)
- (void) strcpy(rmode, "D");
- else
- (void) strcpy(rmode, "C");
-
- if ((hints & NSC_FORCED_WRTHRU) || (hints & NSC_WRTHRU))
- (void) strcpy(wmode, "D");
- else
- (void) strcpy(wmode, "C");
-
- (void) printf(DATA_C2, rmode);
- (void) printf(DATA_C2, wmode);
- }
-
- /* Output set information */
- cd_report(cur);
-
-next:
- pre = cur;
- cur = cur->next;
- }
-
- return (0);
-}
-
-/*
- * sdbc_header() - outputs an appropriate header by referencing the
- * global variables dflsgs
- *
- */
-void
-sdbc_header()
-{
- int rcount = 0;
-
- if (hflags == HEADERS_EXL)
- if ((linesout % DISPLAY_LINES) != 0)
- return;
-
- if (hflags == HEADERS_BOR)
- if (linesout != 0)
- return;
-
- if (hflags & HEADERS_ATT)
- if (hflags & HEADERS_OUT)
- return;
- else
- hflags |= HEADERS_OUT;
-
- if (linesout)
- (void) printf("\n");
-
- /* first line header */
- if (! (dflags & SUMMARY) && dflags != FLAGS) {
-
- (void) printf(VOL_HDR_FMT, " ");
-
- if (dflags & FLAGS) {
- (void) printf(STAT_HDR_FMT, " ");
- (void) printf(STAT_HDR_FMT, " ");
- }
-
- if (dflags & READ) {
- int size;
-
- size = KPS_HDR_SIZE * 2 + HIT_HDR_SIZE;
- center(size, "- read -");
- rcount++;
- }
-
- if (dflags & WRITE) {
- int size;
-
- size = KPS_HDR_SIZE * 2 + HIT_HDR_SIZE;
- center(size, "- write -");
- rcount++;
- }
-
- if (dflags != FLAGS)
- (void) printf("\n");
- }
-
- /* second line header */
- (void) printf(VOL_HDR_FMT, "volume");
-
- if (dflags & FLAGS) {
- (void) printf(STAT_HDR_FMT, "rd");
- (void) printf(STAT_HDR_FMT, "wr");
- }
-
- if (dflags & SUMMARY) {
- (void) printf(KPS_HDR_FMT, "ckps");
- (void) printf(KPS_HDR_FMT, "dkps");
- (void) printf(HIT_HDR_FMT, HIT_HDR_TXT);
-
- goto out;
- }
-
- if (dflags & READ) {
- (void) printf(KPS_HDR_FMT, "ckps");
- (void) printf(KPS_HDR_FMT, "dkps");
- (void) printf(HIT_HDR_FMT, RHIT_HDR_TXT);
- }
-
- if (dflags & WRITE) {
- (void) printf(KPS_HDR_FMT, "ckps");
- (void) printf(KPS_HDR_FMT, "dkps");
- (void) printf(HIT_HDR_FMT, WHIT_HDR_TXT);
- }
-
- if (dflags & DESTAGED)
- (void) printf(KPS_HDR_FMT, "dstg");
-
- if (dflags & WRCANCEL)
- (void) printf(KPS_HDR_FMT, "cwrl");
-
-out:
- (void) printf("\n");
-}
-
-/*
- * sdbc_getstat() - find cache stat by name matching
- *
- * paraemters
- * char *vn - the volume name to match against
- * returns
- * sdbcstat_t * - the matching strcture, NULL if not found
- */
-sdbcstat_t *
-sdbc_getstat(char *vn)
-{
- sdbcstat_t *cur, *pre = NULL;
-
- for (cur = sdbc_top; cur; ) { /* CSTYLED */
- char *volname =
- kstat_value(cur->pre_set, SDBC_CDKSTAT_VOL_NAME);
-
- if (SDBC_COMPLETE(cur->collected)) {
- sdbcstat_t *next = sdbc_delstat(cur);
-
- if (! pre)
- cur = sdbc_top = next;
- else
- cur = pre->next = next;
-
- continue;
- }
-
- if (strncmp(volname, vn, NAMED_LEN) == 0)
- return (cur);
-
- pre = cur;
- cur = cur->next;
- }
-
- return (NULL);
-}
-
-/*
- * sdbc_addstat() - adds a fully populated sdbcstat_t structure
- * to the linked list of currently monitored kstats. The structure
- * will be added in alphabetical order, using the volume name as the
- * key.
- *
- * parameters
- * sdbcstat_t *sdbcstat - to be added to the list.
- *
- */
-void
-sdbc_addstat(sdbcstat_t *sdbcstat)
-{
- sdbcstat_t *cur;
-
- if (sdbc_top == NULL) {
- sdbc_top = sdbcstat;
- return;
- }
-
- for (cur = sdbc_top; cur != NULL; cur = cur->next) {
- char *cur_vname, *nxt_vname, *tst_vname;
-
- cur_vname = kstat_value(cur->pre_set,
- SDBC_CDKSTAT_VOL_NAME);
- tst_vname = kstat_value(sdbcstat->pre_set,
- SDBC_CDKSTAT_VOL_NAME);
-
- if (strncmp(cur_vname, tst_vname, NAMED_LEN) > 0) {
- if (cur == sdbc_top)
- sdbc_top = sdbcstat;
-
- sdbcstat->next = cur;
-
- return;
- }
-
- /*
- * If we get to the last item in the list, then just
- * add this one to the end
- */
- if (cur->next == NULL) {
- cur->next = sdbcstat;
- return;
- }
-
- nxt_vname = kstat_value(cur->next->pre_set,
- SDBC_CDKSTAT_VOL_NAME);
-
- if (strncmp(nxt_vname, tst_vname, NAMED_LEN) > 0) {
- sdbcstat->next = cur->next;
- cur->next = sdbcstat;
- return;
- }
- }
-}
-
-/*
- * sdbc_delstat() - deallocate memory for the structure being
- * passed in.
- *
- * parameters
- * sdbcstat_t *sdbcstat - structure to be deallocated
- *
- * returns
- * sdbcstat_t * - pointer to the "next" structures in the
- * linked list. May be NULL if we are removing the last
- * structure in the linked list.
- */
-sdbcstat_t *
-sdbc_delstat(sdbcstat_t *sdbcstat)
-{
-
- sdbcstat_t *next = sdbcstat->next;
-
- kstat_free(sdbcstat->pre_set);
- kstat_free(sdbcstat->pre_io);
- kstat_free(sdbcstat->cur_set);
- kstat_free(sdbcstat->cur_io);
-
- free(sdbcstat);
- sdbcstat = NULL;
-
- return (next);
-}
-
-/*
- * sdbc_value_check() - Checks for activity, supports -z switch
- *
- * parameters
- * sdbcstat_t *sdbcstat - structure to be checked
- *
- * returns
- * 1 - activity
- * 0 - no activity
- */
-int
-sdbc_value_check(sdbcstat_t *sdbcstat)
-{
- if (SDBC_COMPLETE(sdbcstat->collected))
- return (1);
-
- if (sdbc_getdelta(sdbcstat, SDBC_CDKSTAT_CACHE_READ) != 0)
- return (1);
-
- if (sdbc_getdelta(sdbcstat, SDBC_CDKSTAT_DISK_READ) != 0)
- return (1);
-
- if (sdbc_getdelta(sdbcstat, SDBC_CDKSTAT_CACHE_WRITE) != 0)
- return (1);
-
- if (sdbc_getdelta(sdbcstat, SDBC_CDKSTAT_DISK_WRITE) != 0)
- return (1);
-
- if (sdbc_getdelta(sdbcstat, SDBC_CDKSTAT_WRCANCELNS) != 0)
- return (1);
-
- if (io_value_check(sdbcstat->pre_io->ks_data,
- sdbcstat->cur_io->ks_data) != 0)
- return (1);
-
- return (0);
-}
-
-/*
- * sdbc_validate() - validates the structure of the kstats by attempting to
- * lookup fields used by this module
- *
- * parameters
- * kstat_t *ksp - kstat to be examined
- *
- * returns
- * 1 - one or more fields missing
- * 0 - all fields present
- */
-int
-sdbc_validate(kstat_t *ksp)
-{
- if (! kstat_value(ksp, SDBC_CDKSTAT_VOL_NAME) ||
- ! kstat_value(ksp, SDBC_CDKSTAT_FAILED) ||
- ! kstat_value(ksp, SDBC_CDKSTAT_CDHINTS) ||
- ! kstat_value(ksp, SDBC_CDKSTAT_CACHE_READ) ||
- ! kstat_value(ksp, SDBC_CDKSTAT_DISK_READ) ||
- ! kstat_value(ksp, SDBC_CDKSTAT_CACHE_WRITE) ||
- ! kstat_value(ksp, SDBC_CDKSTAT_DISK_WRITE) ||
- ! kstat_value(ksp, SDBC_CDKSTAT_DESTAGED) ||
- ! kstat_value(ksp, SDBC_CDKSTAT_WRCANCELNS))
- return (1);
-
- return (0);
-}
-
-/*
- * sdbc_getvalues() - populates a values structure with data obtained from the
- * kstat
- *
- * parameters
- * sdbcstat_t *sdbcstat - pointer to the structure containing the kstats
- * sdbcvals_t *vals - pointer to the structure that will receive the values
- * int flags - flags that describe adjustments made to the values
- *
- * returns
- * 1 - failure
- * 0 - success
- */
-int
-sdbc_getvalues(sdbcstat_t *sdbcstat, sdbcvals_t *vals, int flags)
-{
- int divisor = 0;
- int factors;
- uint64_t hr_etime;
- double etime;
-
- kstat_io_t *cur;
- kstat_io_t *pre;
-
- if (sdbcstat == NULL)
- return (1);
-
- cur = sdbcstat->cur_io->ks_data;
- pre = sdbcstat->pre_io->ks_data;
-
- hr_etime = hrtime_delta(pre->rlastupdate, cur->rlastupdate);
- etime = hr_etime / (double)NANOSEC;
-
- /* read data */
- vals->cache_read =
- FBA_SIZE(sdbc_getdelta(sdbcstat, SDBC_CDKSTAT_CACHE_READ));
- vals->disk_read =
- FBA_SIZE(sdbc_getdelta(sdbcstat, SDBC_CDKSTAT_DISK_READ));
-
-
- vals->total_reads = vals->cache_read + vals->disk_read;
-
- if (vals->cache_read == 0)
- vals->read_hit = 0.0;
- else
- vals->read_hit =
- ((float)vals->cache_read / vals->total_reads) * 100.0;
-
- /* write data */
- vals->cache_write =
- FBA_SIZE(sdbc_getdelta(sdbcstat, SDBC_CDKSTAT_CACHE_WRITE));
- vals->disk_write =
- FBA_SIZE(sdbc_getdelta(sdbcstat, SDBC_CDKSTAT_DISK_WRITE));
-
- vals->total_writes = vals->cache_write + vals->disk_write;
-
- vals->destaged =
- FBA_SIZE(sdbc_getdelta(sdbcstat, SDBC_CDKSTAT_DESTAGED));
-
- if (vals->cache_write == 0)
- vals->write_hit = 0.0;
- else
- vals->write_hit = ((float)vals->cache_write /
- (vals->total_writes - vals->destaged)) * 100.0;
-
- /* miscellaneous */
- vals->write_cancellations =
- FBA_SIZE(sdbc_getdelta(sdbcstat, SDBC_CDKSTAT_WRCANCELNS));
-
- vals->total_cache = vals->cache_read + vals->cache_write;
- vals->total_disk = vals->disk_read + vals->disk_write;
-
- /* total cache hit calculation */
- vals->cache_hit = 0;
- factors = 0;
-
- if (vals->cache_read != 0) {
- vals->cache_hit += vals->read_hit;
- factors++;
- }
-
- if (vals->cache_write != 0) {
- vals->cache_hit += vals->write_hit;
- factors++;
- }
-
- if (vals->cache_hit)
- vals->cache_hit /= (float)factors;
-
- /* adjustments */
- divisor = 1;
-
- if (flags & SDBC_KBYTES)
- divisor *= KILOBYTE;
- if ((flags & SDBC_INTAVG) && (etime > 0))
- divisor *= etime;
-
- if (divisor != 1) {
- vals->cache_read /= divisor;
- vals->disk_read /= divisor;
- vals->total_reads /= divisor;
-
- vals->cache_write /= divisor;
- vals->disk_write /= divisor;
- vals->total_writes /= divisor;
-
- vals->total_cache /= divisor;
- vals->total_disk /= divisor;
-
- vals->destaged /= divisor;
- vals->write_cancellations /= divisor;
- }
-
- return (0);
-}
-
-/*
- * sdbc_getdelta() - calculates the difference between two kstat fields
- *
- * parameters
- * sdbcstat_t *sdbcstat - the SDBC stat strcture containing the two fields
- * char *name - the name of the fields
- * returns
- * uint32_t value of the differences adjusted for overflow of the data type
- */
-uint32_t
-sdbc_getdelta(sdbcstat_t *sdbcstat, char *name)
-{
- uint32_t *cur_val;
- uint32_t *pre_val;
-
- pre_val = kstat_value(sdbcstat->pre_set, name);
- cur_val = kstat_value(sdbcstat->cur_set, name);
-
- return (u32_delta(*pre_val, *cur_val));
-}
-
-void
-center(int size, char *hdr)
-{
- int lpad = 0;
- int rpad = 0;
- char fmt[10];
-
- if (size == 0)
- return;
-
- if (strlen(hdr) < size) {
- lpad = (size - strlen(hdr)) / 2;
-
- if (lpad * 2 < size)
- lpad++;
-
- rpad = size - (lpad + strlen(hdr));
- }
-
-output:
- (void) sprintf(fmt, "%%%ds%%s%%%ds", lpad, rpad);
- (void) printf(fmt, " ", hdr, " ");
-}
diff --git a/usr/src/cmd/avs/dsstat/sdbc_stats.h b/usr/src/cmd/avs/dsstat/sdbc_stats.h
deleted file mode 100644
index ed455a7099..0000000000
--- a/usr/src/cmd/avs/dsstat/sdbc_stats.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _SDBC_STATS_H
-#define _SDBC_STATS_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Internal flags to denote data collection status
- */
-#define GOT_SET_KSTAT 0x01
-#define GOT_IO_KSTAT 0x02
-#define GOT_COMPLETE_SDBC (GOT_SET_KSTAT | GOT_IO_KSTAT)
-
-#define SDBC_COMPLETE(x) (((x) & (GOT_COMPLETE_SDBC)) != \
- (GOT_COMPLETE_SDBC))
-
-#define SDBC_KBYTES 0x01
-#define SDBC_INTAVG 0x02
-
-#define KILOBYTE 1024
-
-typedef struct sdbcstat_s
-{
- kstat_t *pre_set;
- kstat_t *pre_io;
- kstat_t *cur_set;
- kstat_t *cur_io;
- int collected;
- struct sdbcstat_s *next;
-} sdbcstat_t;
-
-typedef struct sdbcvals_t
-{
- uint32_t cache_read;
- uint32_t cache_write;
- uint32_t total_cache;
-
- float cache_hit;
- float read_hit;
- float write_hit;
-
- uint32_t disk_read;
- uint32_t disk_write;
- uint32_t total_disk;
-
- uint32_t destaged;
- uint32_t write_cancellations;
-
- uint32_t total_reads;
- uint32_t total_writes;
-} sdbcvals_t;
-
-extern kstat_t *sdbc_global;
-
-/* Prototypes */
-int sdbc_discover(kstat_ctl_t *);
-int sdbc_update(kstat_ctl_t *);
-int sdbc_report();
-sdbcstat_t *sdbc_getstat(char *);
-int sdbc_getvalues(sdbcstat_t *, sdbcvals_t *, int);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _SDBC_STATS_H */
diff --git a/usr/src/cmd/avs/dsstat/sndr_stats.c b/usr/src/cmd/avs/dsstat/sndr_stats.c
deleted file mode 100644
index 2d65ee2036..0000000000
--- a/usr/src/cmd/avs/dsstat/sndr_stats.c
+++ /dev/null
@@ -1,852 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <signal.h>
-#include <setjmp.h>
-
-#include <kstat.h>
-
-#include <sys/nsctl/rdc.h>
-#include <sys/nsctl/rdc_io.h>
-#include <sys/nsctl/rdc_bitmap.h>
-
-#include "sdbc_stats.h"
-#include "sndr_stats.h"
-
-#include "dsstat.h"
-#include "common.h"
-#include "report.h"
-
-static sndrstat_t *sndr_top;
-
-void sndr_add_stat(sndrstat_t *);
-sndrstat_t *sndr_del_stat(sndrstat_t *);
-
-int sndr_value_check(sndrstat_t *);
-int sndr_validate(kstat_t *);
-int sndr_strcmp(char *, char *);
-int sndr_vol_selected(kstat_t *);
-
-void getType(kstat_t *, char *);
-void getStat(kstat_t *, char *);
-void getQueue(kstat_t *, char *);
-void printQueueStats(int, kstat_t *);
-float getSyncNeeded(kstat_t *);
-
-static void update_sighandler(int);
-static void discover_sighandler(int);
-
-static sigjmp_buf update_env, discover_env;
-static sig_atomic_t sig_raised = 0;
-/*
- * sndr_discover() - looks for new statistics to be monitored.
- * Verifies that any statistics found are now already being
- * monitored.
- *
- */
-int
-sndr_discover(kstat_ctl_t *kc)
-{
- static int validated = 0;
- struct sigaction segv_act;
- int rc = 0;
- kstat_t *ksp;
-
-
- (void) signal(SIGSEGV, discover_sighandler);
- (void) sigaction(SIGSEGV, NULL, &segv_act);
-
- /* Loop on all kstats */
- for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) {
- int kinst;
- char kname[KSTAT_STRLEN + 1];
- sndrstat_t *cur;
- sndrstat_t *sndrstat = NULL;
- kstat_t *bmp_ksp;
- kstat_t *sec_ksp;
-
- /* Serach for SNDR set */
- if (strcmp(ksp->ks_module, RDC_KSTAT_MODULE) != 0 ||
- strcmp(ksp->ks_name, RDC_KSTAT_INFO) != 0) {
- continue;
- }
-
- if (kstat_read(kc, ksp, NULL) == -1)
- continue;
-
- /*
- * Validate kstat structure
- */
- if (! validated) {
- if (sndr_validate(ksp))
- return (EINVAL);
-
- validated++;
- }
-
- /*
- * Duplicate check
- */
- for (cur = sndr_top; cur != NULL; cur = cur->next) {
- char *cur_vname, *tst_vname;
- uint32_t cur_inst, tst_inst;
-
- cur_vname = kstat_value(cur->pre_set, RDC_IKSTAT_FILE);
- cur_inst = cur->pre_set->ks_instance;
-
- tst_vname = kstat_value(ksp, RDC_IKSTAT_FILE);
- tst_inst = ksp->ks_instance;
-
- if (strcmp(cur_vname, tst_vname) == 0 &&
- cur_inst == tst_inst)
- goto next;
- }
-
- /*
- * Initialize new record
- */
- sndrstat = (sndrstat_t *)calloc(1, sizeof (sndrstat_t));
- kinst = ksp->ks_instance;
-
- /*
- * Set kstat
- */
- sndrstat->pre_set = kstat_retrieve(kc, ksp);
-
- if (sndrstat->pre_set == NULL)
- goto next;
-
- sndrstat->collected |= GOT_SET_KSTAT;
-
- /*
- * Bitmap kstat
- */
- (void) sprintf(kname, "%s%d", RDC_KSTAT_BMPNAME, kinst);
-
- bmp_ksp = kstat_lookup(kc, RDC_KSTAT_BMPNAME, kinst, kname);
- sndrstat->pre_bmp = kstat_retrieve(kc, bmp_ksp);
-
- if (sndrstat->pre_bmp == NULL)
- goto next;
-
- sndrstat->collected |= GOT_BMP_KSTAT;
-
- /*
- * Secondary kstat
- */
- (void) sprintf(kname, "%s%d", RDC_KSTAT_RDCNAME, kinst);
-
- sec_ksp = kstat_lookup(kc, RDC_KSTAT_MODULE, kinst, kname);
- sndrstat->pre_sec = kstat_retrieve(kc, sec_ksp);
-
- if (sndrstat->pre_sec == NULL)
- goto next;
-
- sndrstat->collected |= GOT_SEC_KSTAT;
-
-next:
- /*
- * Check if we got a complete set of stats
- */
- if (sndrstat == NULL)
- continue;
-
- if (SNDR_COMPLETE(sndrstat->collected)) {
- (void) sndr_del_stat(sndrstat);
- continue;
- }
-
- /*
- * Add to linked list
- */
- sndr_add_stat(sndrstat);
- }
-
- (void) sigsetjmp(discover_env, 0);
- if (sig_raised) {
- sig_raised = 0;
- rc = -1;
- }
- (void) sigaction(SIGSEGV, &segv_act, NULL);
-
- return (rc);
-}
-
-void
-discover_sighandler(int sig)
-{
- switch (sig) {
- case SIGSEGV:
- sig_raised = 1;
- siglongjmp(discover_env, sig);
- default:
- exit(sig);
- }
-}
-
-void
-update_sighandler(int sig)
-{
- switch (sig) {
- case SIGSEGV:
- sig_raised = 1;
- siglongjmp(update_env, sig);
- default:
- exit(sig);
- }
-}
-
-/*
- * sndr_update() - updates all of the statistics currently being monitored.
- *
- */
-int
-sndr_update(kstat_ctl_t *kc)
-{
- sndrstat_t *cur;
- struct sigaction segv_act;
- int rc = 0;
-
- (void) signal(SIGSEGV, update_sighandler);
- (void) sigaction(SIGSEGV, NULL, &segv_act);
-
- for (cur = sndr_top; cur != NULL; cur = cur->next) {
- int kinst;
- char kname[KSTAT_STRLEN + 1];
- kstat_t *ksp = NULL;
- char *cur_vname, *tst_vname;
-
- cur->collected = 0;
-
- /*
- * Age off old stats
- */
- if (cur->cur_set != NULL) {
- kstat_free(cur->pre_set);
- kstat_free(cur->pre_bmp);
- kstat_free(cur->pre_sec);
-
- cur->pre_set = cur->cur_set;
- cur->pre_bmp = cur->cur_bmp;
- cur->pre_sec = cur->cur_sec;
- }
-
- /*
- * Set kstat
- */
- (void) strncpy(kname, cur->pre_set->ks_name, KSTAT_STRLEN);
- kname[KSTAT_STRLEN] = '\0';
-
- kinst = cur->pre_set->ks_instance;
-
- ksp = kstat_lookup(kc, RDC_KSTAT_MODULE, kinst, kname);
-
- if ((cur->cur_set = kstat_retrieve(kc, ksp)) == NULL)
- continue;
-
- cur->collected |= GOT_SET_KSTAT;
-
- /*
- * Validate set
- */
- cur_vname = kstat_value(cur->pre_set, RDC_IKSTAT_FILE);
- tst_vname = kstat_value(cur->cur_set, RDC_IKSTAT_FILE);
-
- if (strcmp(cur_vname, tst_vname) != 0)
- continue;
-
- /*
- * Bitmap kstat
- */
- (void) sprintf(kname, "%s%d", RDC_KSTAT_BMPNAME, kinst);
-
- ksp = kstat_lookup(kc, RDC_KSTAT_BMPNAME, kinst, kname);
-
- if ((cur->cur_bmp = kstat_retrieve(kc, ksp)) == NULL)
- continue;
-
- cur->collected |= GOT_BMP_KSTAT;
-
- /*
- * Secondary kstat
- */
- (void) sprintf(kname, "%s%d", RDC_KSTAT_RDCNAME, kinst);
-
- ksp = kstat_lookup(kc, RDC_KSTAT_MODULE, kinst, kname);
-
- if ((cur->cur_sec = kstat_retrieve(kc, ksp)) == NULL)
- continue;
-
- cur->collected |= GOT_SEC_KSTAT;
-
- }
-
- (void) sigsetjmp(update_env, 0);
- if (sig_raised) {
- sig_raised = 0;
- rc = -1;
- }
- (void) sigaction(SIGSEGV, &segv_act, NULL);
-
- return (rc);
-}
-
-/*
- * sndr_report() - outputs statistics for the statistics currently being
- * monitored. Deletes statistics for volumes that have been disabled.
- *
- */
-int
-sndr_report()
-{
- int padsz;
- char pad[20] = "";
- sndrstat_t *cur, *pre = NULL;
-
- if (sndr_top == NULL)
- return (0);
-
- /* Create padding string for secondary report lines */
- padsz = 0;
- if (dflags & FLAGS) {
- padsz += STAT_HDR_SIZE;
- padsz += STAT_HDR_SIZE;
- }
-
- if (dflags & ASYNC_QUEUE)
- padsz += STAT_HDR_SIZE;
-
- if (dflags & PCTS)
- padsz += PCT_HDR_SIZE;
-
- if (padsz) {
- char fmt[20];
- (void) sprintf(fmt, "%%%ds", padsz);
- (void) sprintf(pad, fmt, " ");
- }
-
- for (cur = sndr_top; cur != NULL; ) { /*CSTYLED */
- int first = 1;
- char data[20] = "";
-
- /* Check to see if this is this a complete */
- if (SNDR_COMPLETE(cur->collected)) {
- char *c;
- char vn[NSC_MAXPATH + 1];
- sndrstat_t *next;
-
- /* notify user of set being disabled */
- c = kstat_value(cur->pre_set, RDC_IKSTAT_SECFILE);
- (void) strncpy(vn, c, NSC_MAXPATH);
- vn[NSC_MAXPATH] = '\0';
-
- (void) printf(DATA_C16, vn);
- (void) printf(" %s\n", RDC_DISABLED);
-
- next = sndr_del_stat(cur);
-
- /* free memory and remove stat from list */
- if (! pre)
- cur = sndr_top = next;
- else
- cur = pre->next = next;
-
- continue;
- }
-
- /* Check to see if the user specified this volume */
- if (! sndr_vol_selected(cur->pre_set))
- goto next;
-
- /* Check to see if zflag applies */
- if (zflag && sndr_value_check(cur) == 0)
- goto next;
-
- /* Calculate flags */
- if (dflags & FLAGS) {
- char c[STAT_HDR_SIZE];
- char vtype[STAT_HDR_SIZE];
- char vstat[STAT_HDR_SIZE];
-
- getType(cur->cur_set, &c[0]);
- (void) sprintf(vtype, DATA_C2, c);
- (void) strcat(data, vtype);
-
- getStat(cur->cur_set, &c[0]);
- (void) sprintf(vstat, DATA_C2, c);
- (void) strcat(data, vstat);
- }
-
- /* Async. queue statistics */
- if (dflags & ASYNC_QUEUE) {
- char c[STAT_HDR_SIZE];
- char qtype[STAT_HDR_SIZE];
-
- getQueue(cur->cur_set, &c[0]);
- (void) sprintf(qtype, DATA_C2, c);
- (void) strcat(data, qtype);
- }
-
- /* Calculate sync needed percentages */
- if (dflags & PCTS) {
- char snpct[10];
-
- (void) sprintf(snpct, DATA_F62,
- getSyncNeeded(cur->cur_set));
- (void) strcat(data, snpct);
- }
-
- /* Output */
- if (rflags & SNDR_NET) {
- char *c;
- char type[STAT_HDR_SIZE];
- char vn[NAMED_LEN + 1];
-
- getType(cur->cur_set, &type[0]);
-
- if (type[0] == 'S') {
- c = kstat_value(cur->pre_set,
- RDC_IKSTAT_FILE);
- } else {
- c = kstat_value(cur->pre_set,
- RDC_IKSTAT_SECFILE);
- }
-
- /* Only print last 15 characters */
- if (strlen(c) >= NAMED_LEN) {
- c += strlen(c) - NAMED_LEN;
- }
- (void) strncpy(vn, c, NAMED_LEN);
- vn[NAMED_LEN] = '\0';
-
- header();
- (void) printf(DATA_C16, vn);
- (void) printf("%s", data);
- (void) printf(ROLE_INF_FMT, RDC_SECONDARY);
-
- /* Async. queue statistics */
- if (dflags & ASYNC_QUEUE)
- printQueueStats(first, cur->cur_set);
-
- io_report(cur->cur_sec, cur->pre_sec,
- sdbc_getstat(vn));
- (void) printf("\n");
-
- if (first) {
- (void) strcpy(data, strlen(pad) > 0 ? pad : "");
- first = 0;
- }
- }
-
- if (rflags & SNDR_BMP) {
- char *c;
- char vn[16];
-
- c = kstat_value(cur->pre_set, RDC_IKSTAT_BITMAP);
-
- /* Only print last 15 characters */
- if (strlen(c) >= NAMED_LEN) {
- c += strlen(c) - NAMED_LEN;
- }
- (void) strncpy(vn, c, NAMED_LEN);
- vn[NAMED_LEN] = '\0';
-
- header();
- (void) printf(DATA_C16, vn);
- (void) printf("%s", data);
- (void) printf(ROLE_INF_FMT, RDC_BITMAP);
-
- /* Async. queue statistics */
- if (dflags & ASYNC_QUEUE)
- printQueueStats(first, cur->cur_set);
-
- io_report(cur->cur_bmp, cur->pre_bmp,
- sdbc_getstat(vn));
- (void) printf("\n");
-
- if (first) {
- (void) strcpy(data, strlen(pad) > 0 ? pad : "");
- first = 0;
- }
- }
-next:
- pre = cur;
- cur = cur->next;
- }
-
- return (0);
-}
-
-/*
- * sndr_add_stat() - adds a fully populated sndrstat_t structure
- * to the linked list of currently monitored kstats. The structure
- * will be added in alphabetical order, using the volume name as the
- * key.
- *
- * parameters
- * sndrstat_t *sndrstat - to be added to the list.
- *
- */
-void
-sndr_add_stat(sndrstat_t *sndrstat)
-{
-
- sndrstat_t *cur;
-
- if (sndr_top == NULL) {
- sndr_top = sndrstat;
- return;
- }
-
- for (cur = sndr_top; cur != NULL; cur = cur->next) {
- char *cur_vname, *nxt_vname, *tst_vname;
-
- cur_vname = kstat_value(cur->pre_set, RDC_IKSTAT_FILE);
- tst_vname = kstat_value(sndrstat->pre_set, RDC_IKSTAT_FILE);
-
- if (strcmp(cur_vname, tst_vname) <= 0) {
- /*
- * If we get to the last item in the list, then just
- * add this one to the end
- */
- if (cur->next == NULL) {
- cur->next = sndrstat;
- return;
- }
-
- nxt_vname = kstat_value(cur->next->pre_set,
- RDC_IKSTAT_FILE);
-
- if (strcmp(nxt_vname, tst_vname) > 0) {
- sndrstat->next = cur->next;
- cur->next = sndrstat;
- return;
- }
- } else {
- if (cur == sndr_top)
- sndr_top = sndrstat;
-
- sndrstat->next = cur;
-
- return;
- }
- }
-}
-
-/*
- * sndr_del_stat() - deallocate memory for the structure being
- * passed in.
- *
- * parameters
- * sndrstat_t *sndrstat - structure to be deallocated
- *
- * returns
- * sndrstat_t * - pointer to the "next" structures in the
- * linked list. May be NULL if we are removing the last
- * structure in the linked list.
- *
- */
-sndrstat_t *
-sndr_del_stat(sndrstat_t *sndrstat)
-{
-
- sndrstat_t *next = sndrstat->next;
-
- kstat_free(sndrstat->pre_set);
- kstat_free(sndrstat->pre_bmp);
- kstat_free(sndrstat->pre_sec);
- kstat_free(sndrstat->cur_set);
- kstat_free(sndrstat->cur_bmp);
- kstat_free(sndrstat->cur_sec);
-
- free(sndrstat);
-
- return (next);
-}
-
-/*
- * sndr_value_check() - check to determine if any activity was registered
- * on this volume by checking the previous stats vs. the current stats.
- *
- * parameters
- * sndrstat_t *sndrstat - structure to be checked
- *
- * returns
- * 0 - no activity
- * 1 - activity
- */
-int
-sndr_value_check(sndrstat_t *sndrstat)
-{
- if (SNDR_COMPLETE(sndrstat->collected))
- return (1);
-
- if (io_value_check(sndrstat->pre_bmp->ks_data,
- sndrstat->cur_bmp->ks_data)) {
- return (1);
- }
-
- if (io_value_check(sndrstat->pre_sec->ks_data,
- sndrstat->cur_sec->ks_data)) {
- return (1);
- }
-
- return (0);
-}
-
-/*
- * sndr_validate() - validates the fields required by dsstat exist in
- * the kstat_t structure passed in. This check keeps dsstat from
- * core dumping if the kstat_named_t structures change in any of the
- * services that dsstat monitors.
- *
- * paramaters
- * kstat_t *ksp - kstat_t structure to check. The ks_data field
- * should have been populated with a call to kstat_read()
- *
- * returns
- * 0 - all fields are contained in the kstat
- * 1 - a field required by dsstat is not in the kstat
- */
-int
-sndr_validate(kstat_t *ksp)
-{
- if (! kstat_value(ksp, RDC_IKSTAT_FILE) ||
- ! kstat_value(ksp, RDC_IKSTAT_FLAGS) ||
- ! kstat_value(ksp, RDC_IKSTAT_SYNCFLAGS) ||
- ! kstat_value(ksp, RDC_IKSTAT_BMPFLAGS) ||
- ! kstat_value(ksp, RDC_IKSTAT_VOLSIZE) ||
- ! kstat_value(ksp, RDC_IKSTAT_BITSSET) ||
- ! kstat_value(ksp, RDC_IKSTAT_QUEUE_TYPE) ||
- ! kstat_value(ksp, RDC_IKSTAT_ASYNC_ITEMS) ||
- ! kstat_value(ksp, RDC_IKSTAT_ASYNC_BLOCKS) ||
- ! kstat_value(ksp, RDC_IKSTAT_ASYNC_ITEM_HWM) ||
- ! kstat_value(ksp, RDC_IKSTAT_ASYNC_BLOCK_HWM))
- return (1);
-
- return (0);
-}
-
-void
-getType(kstat_t *ksp, char *vtype)
-{
- uint32_t *set_flags;
-
- set_flags = kstat_value(ksp, RDC_IKSTAT_FLAGS);
-
- if (*set_flags & RDC_PRIMARY)
- (void) strcpy(vtype, "P");
- else
- (void) strcpy(vtype, "S");
-}
-
-void
-getStat(kstat_t *ksp, char *vstat)
-{
- uint32_t *set_flags;
- uint32_t *syn_flags;
- uint32_t *bmp_flags;
-
- set_flags = kstat_value(ksp, RDC_IKSTAT_FLAGS);
- syn_flags = kstat_value(ksp, RDC_IKSTAT_SYNCFLAGS);
- bmp_flags = kstat_value(ksp, RDC_IKSTAT_BMPFLAGS);
-
- (void) strcpy(vstat, "R");
-
- if (*set_flags & RDC_SYNCING) {
- if (*set_flags & RDC_SLAVE)
- if (*set_flags & RDC_PRIMARY)
- (void) strcpy(vstat, "RS");
- else
- (void) strcpy(vstat, "SY");
- else
- if (*set_flags & RDC_PRIMARY)
- (void) strcpy(vstat, "SY");
- else
- (void) strcpy(vstat, "RS");
- }
-
- if (*set_flags & RDC_LOGGING) {
- (void) strcpy(vstat, "L");
-
- if (*set_flags & RDC_QUEUING)
- (void) strcpy(vstat, "Q");
-
- if (*set_flags & RDC_DISKQ_FAILED)
- (void) strcpy(vstat, "QF");
-
- if (*syn_flags & RDC_SYNC_NEEDED)
- (void) strcpy(vstat, "SN");
-
- if (*syn_flags & RDC_RSYNC_NEEDED)
- (void) strcpy(vstat, "RN");
- }
-
- if (*syn_flags & RDC_FCAL_FAILED)
- (void) strcpy(vstat, "FF");
-
- if (*bmp_flags & RDC_BMP_FAILED)
- (void) strcpy(vstat, "BF");
-
- if (*syn_flags & RDC_VOL_FAILED)
- (void) strcpy(vstat, "VF");
-}
-
-void
-getQueue(kstat_t *ksp, char *vqueue)
-{
- char *qtype;
-
- (void) strcpy(vqueue, "-");
-
- qtype = kstat_value(ksp, RDC_IKSTAT_QUEUE_TYPE);
-
- if (strcmp(qtype, "memory") == 0)
- (void) strcpy(vqueue, "M");
-
- if (strcmp(qtype, "disk") == 0)
- (void) strcpy(vqueue, "D");
-}
-
-float
-getSyncNeeded(kstat_t *ksp)
-{
- uint32_t *volsize, *bitsset;
- uint32_t bits, segs;
- float pct;
-
- volsize = kstat_value(ksp, RDC_IKSTAT_VOLSIZE);
- bitsset = kstat_value(ksp, RDC_IKSTAT_BITSSET);
-
- segs = FBA_TO_LOG_LEN(*volsize);
- bits = *bitsset > 0 ? *bitsset : 0;
-
- pct = segs ? ((float)bits/(float)segs) : 0.0;
- pct *= 100;
-
- return (pct);
-}
-
-/*
- * Special handling for compatibility.
- * "dsstat -s <set>" allows set name to be the last 15 chars,
- * due to 15 characters limit of old kstat information.
- *
- * return 0 if:
- * 1) full and partial are same
- * 2) partial is the last 15 chars of full
- */
-int
-sndr_strcmp(char *full, char *partial)
-{
- char *f = full;
- int rc;
-
- rc = strcmp(full, partial);
-
- if (rc != 0 &&
- (strlen(partial) == NAMED_LEN) &&
- (strlen(full) > NAMED_LEN)) {
- f += strlen(full) - NAMED_LEN;
- rc = strncmp(f, partial, NAMED_LEN);
- }
-
- return (rc);
-}
-
-int
-sndr_vol_selected(kstat_t *ksp)
-{
- vslist_t *vslist = vs_top;
-
- for (vslist = vs_top; vslist != NULL; vslist = vslist->next) {
- char *vn;
- char *vh;
-
- /* If no host specified, check local only */
- if (vslist->volhost == NULL) {
- vn = kstat_value(ksp, RDC_IKSTAT_FILE);
-
- if (sndr_strcmp(vn, vslist->volname))
- continue;
- else
- break;
- }
-
- /* Check primary */
- vn = kstat_value(ksp, RDC_IKSTAT_FILE);
- vh = kstat_value(ksp, RDC_IKSTAT_PRIMARY_HOST);
-
- if (sndr_strcmp(vn, vslist->volname) == 0 &&
- sndr_strcmp(vh, vslist->volhost) == 0)
- break;
-
- /* Check secondary */
- vn = kstat_value(ksp, RDC_IKSTAT_SECFILE);
- vh = kstat_value(ksp, RDC_IKSTAT_SECONDARY_HOST);
-
- if (sndr_strcmp(vn, vslist->volname) == 0 &&
- sndr_strcmp(vh, vslist->volhost) == 0)
- break;
- }
-
- if (vs_top != NULL && vslist == NULL)
- return (0);
-
- return (1);
-}
-
-void
-printQueueStats(int first, kstat_t *cur_set)
-{
- uint32_t *val;
-
- if (! first) {
- /* Filler for async. queue fields */
- (void) printf(TPS_HDR_FMT, NO_INFO);
- (void) printf(KPS_HDR_FMT, NO_INFO);
- (void) printf(TPS_HDR_FMT, NO_INFO);
- (void) printf(KPS_HDR_FMT, NO_INFO);
-
- return;
- }
-
- val = (uint32_t *)kstat_value(cur_set, RDC_IKSTAT_ASYNC_ITEMS);
- (void) printf(TPS_INF_FMT, *val);
-
- val = (uint32_t *)kstat_value(cur_set, RDC_IKSTAT_ASYNC_BLOCKS);
- (void) printf(KPS_INF_FMT, (float)(*val / 2));
-
- val = (uint32_t *)kstat_value(cur_set, RDC_IKSTAT_ASYNC_ITEM_HWM);
- (void) printf(TPS_INF_FMT, *val);
-
- val = (uint32_t *)kstat_value(cur_set, RDC_IKSTAT_ASYNC_BLOCK_HWM);
- (void) printf(KPS_INF_FMT, (float)(*val / 2));
-}
diff --git a/usr/src/cmd/avs/dsstat/sndr_stats.h b/usr/src/cmd/avs/dsstat/sndr_stats.h
deleted file mode 100644
index d5b730c96c..0000000000
--- a/usr/src/cmd/avs/dsstat/sndr_stats.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _SNDR_STATS_H
-#define _SNDR_STATS_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define GOT_SET_KSTAT 0x01
-#define GOT_BMP_KSTAT 0x02
-#define GOT_SEC_KSTAT 0x04
-
-#define GOT_COMPLETE_SNDR (GOT_SET_KSTAT|GOT_BMP_KSTAT|GOT_SEC_KSTAT)
-
-#define SNDR_COMPLETE(x) (((x) & (GOT_COMPLETE_SNDR)) != (GOT_COMPLETE_SNDR))
-
-/* SNDR strings */
-#define RDC_KSTAT_RDCNAME "sndr"
-#define RDC_KSTAT_BMPNAME "sndrbmp"
-
-#define RDC_DISABLED "<<set disabled>>"
-#define RDC_SECONDARY "net"
-#define RDC_BITMAP "bmp"
-
-typedef struct sndrstat_s
-{
- kstat_t *pre_set;
- kstat_t *pre_bmp;
- kstat_t *pre_sec;
- kstat_t *cur_set;
- kstat_t *cur_bmp;
- kstat_t *cur_sec;
- int collected;
- struct sndrstat_s *next;
-} sndrstat_t;
-
-/* Prototypes */
-int sndr_discover(kstat_ctl_t *);
-int sndr_update(kstat_ctl_t *);
-int sndr_report();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _SNDR_STATS_H */