fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <string.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <signal.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <setjmp.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <kstat.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/rdc.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/rdc_io.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/rdc_bitmap.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "sdbc_stats.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "sndr_stats.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "dsstat.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "common.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "report.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic sndrstat_t *sndr_top;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid sndr_add_stat(sndrstat_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesndrstat_t *sndr_del_stat(sndrstat_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint sndr_value_check(sndrstat_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint sndr_validate(kstat_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint sndr_strcmp(char *, char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint sndr_vol_selected(kstat_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid getType(kstat_t *, char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid getStat(kstat_t *, char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid getQueue(kstat_t *, char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid printQueueStats(int, kstat_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefloat getSyncNeeded(kstat_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void update_sighandler(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void discover_sighandler(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic sigjmp_buf update_env, discover_env;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic sig_atomic_t sig_raised = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sndr_discover() - looks for new statistics to be monitored.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Verifies that any statistics found are now already being
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * monitored.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesndr_discover(kstat_ctl_t *kc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static int validated = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct sigaction segv_act;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_t *ksp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) signal(SIGSEGV, discover_sighandler);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sigaction(SIGSEGV, NULL, &segv_act);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop on all kstats */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int kinst;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char kname[KSTAT_STRLEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat_t *cur;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat_t *sndrstat = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_t *bmp_ksp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_t *sec_ksp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Serach for SNDR set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(ksp->ks_module, RDC_KSTAT_MODULE) != 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcmp(ksp->ks_name, RDC_KSTAT_INFO) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (kstat_read(kc, ksp, NULL) == -1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Validate kstat structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (! validated) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sndr_validate(ksp))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (EINVAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte validated++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Duplicate check
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cur = sndr_top; cur != NULL; cur = cur->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *cur_vname, *tst_vname;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t cur_inst, tst_inst;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur_vname = kstat_value(cur->pre_set, RDC_IKSTAT_FILE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur_inst = cur->pre_set->ks_instance;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tst_vname = kstat_value(ksp, RDC_IKSTAT_FILE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tst_inst = ksp->ks_instance;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(cur_vname, tst_vname) == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur_inst == tst_inst)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initialize new record
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat = (sndrstat_t *)calloc(1, sizeof (sndrstat_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kinst = ksp->ks_instance;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat->pre_set = kstat_retrieve(kc, ksp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sndrstat->pre_set == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat->collected |= GOT_SET_KSTAT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Bitmap kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(kname, "%s%d", RDC_KSTAT_BMPNAME, kinst);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_ksp = kstat_lookup(kc, RDC_KSTAT_BMPNAME, kinst, kname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat->pre_bmp = kstat_retrieve(kc, bmp_ksp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sndrstat->pre_bmp == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat->collected |= GOT_BMP_KSTAT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Secondary kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(kname, "%s%d", RDC_KSTAT_RDCNAME, kinst);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sec_ksp = kstat_lookup(kc, RDC_KSTAT_MODULE, kinst, kname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat->pre_sec = kstat_retrieve(kc, sec_ksp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sndrstat->pre_sec == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat->collected |= GOT_SEC_KSTAT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortenext:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check if we got a complete set of stats
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sndrstat == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SNDR_COMPLETE(sndrstat->collected)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sndr_del_stat(sndrstat);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add to linked list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndr_add_stat(sndrstat);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sigsetjmp(discover_env, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sig_raised) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sig_raised = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sigaction(SIGSEGV, &segv_act, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortediscover_sighandler(int sig)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (sig) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SIGSEGV:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sig_raised = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte siglongjmp(discover_env, sig);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(sig);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_sighandler(int sig)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (sig) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case SIGSEGV:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sig_raised = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte siglongjmp(update_env, sig);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(sig);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sndr_update() - updates all of the statistics currently being monitored.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesndr_update(kstat_ctl_t *kc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat_t *cur;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct sigaction segv_act;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) signal(SIGSEGV, update_sighandler);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sigaction(SIGSEGV, NULL, &segv_act);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cur = sndr_top; cur != NULL; cur = cur->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int kinst;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char kname[KSTAT_STRLEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_t *ksp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *cur_vname, *tst_vname;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur->collected = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Age off old stats
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cur->cur_set != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_free(cur->pre_set);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_free(cur->pre_bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_free(cur->pre_sec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur->pre_set = cur->cur_set;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur->pre_bmp = cur->cur_bmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur->pre_sec = cur->cur_sec;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(kname, cur->pre_set->ks_name, KSTAT_STRLEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kname[KSTAT_STRLEN] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kinst = cur->pre_set->ks_instance;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ksp = kstat_lookup(kc, RDC_KSTAT_MODULE, kinst, kname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cur->cur_set = kstat_retrieve(kc, ksp)) == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur->collected |= GOT_SET_KSTAT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Validate set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur_vname = kstat_value(cur->pre_set, RDC_IKSTAT_FILE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tst_vname = kstat_value(cur->cur_set, RDC_IKSTAT_FILE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(cur_vname, tst_vname) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Bitmap kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(kname, "%s%d", RDC_KSTAT_BMPNAME, kinst);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ksp = kstat_lookup(kc, RDC_KSTAT_BMPNAME, kinst, kname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cur->cur_bmp = kstat_retrieve(kc, ksp)) == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur->collected |= GOT_BMP_KSTAT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Secondary kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(kname, "%s%d", RDC_KSTAT_RDCNAME, kinst);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ksp = kstat_lookup(kc, RDC_KSTAT_MODULE, kinst, kname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cur->cur_sec = kstat_retrieve(kc, ksp)) == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur->collected |= GOT_SEC_KSTAT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sigsetjmp(update_env, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sig_raised) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sig_raised = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sigaction(SIGSEGV, &segv_act, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sndr_report() - outputs statistics for the statistics currently being
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * monitored. Deletes statistics for volumes that have been disabled.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesndr_report()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int padsz;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char pad[20] = "";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat_t *cur, *pre = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sndr_top == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Create padding string for secondary report lines */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte padsz = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & FLAGS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte padsz += STAT_HDR_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte padsz += STAT_HDR_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & ASYNC_QUEUE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte padsz += STAT_HDR_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & PCTS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte padsz += PCT_HDR_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (padsz) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fmt[20];
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) sprintf(fmt, "%%%ds", padsz);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) sprintf(pad, fmt, " ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cur = sndr_top; cur != NULL; ) { /*CSTYLED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int first = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char data[20] = "";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check to see if this is this a complete */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SNDR_COMPLETE(cur->collected)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char vn[NSC_MAXPATH + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat_t *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* notify user of set being disabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c = kstat_value(cur->pre_set, RDC_IKSTAT_SECFILE);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(vn, c, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vn[NSC_MAXPATH] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(DATA_C16, vn);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(" %s\n", RDC_DISABLED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte next = sndr_del_stat(cur);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* free memory and remove stat from list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (! pre)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur = sndr_top = next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur = pre->next = next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check to see if the user specified this volume */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (! sndr_vol_selected(cur->pre_set))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check to see if zflag applies */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (zflag && sndr_value_check(cur) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Calculate flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & FLAGS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char c[STAT_HDR_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char vtype[STAT_HDR_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char vstat[STAT_HDR_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte getType(cur->cur_set, &c[0]);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) sprintf(vtype, DATA_C2, c);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcat(data, vtype);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte getStat(cur->cur_set, &c[0]);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) sprintf(vstat, DATA_C2, c);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcat(data, vstat);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Async. queue statistics */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & ASYNC_QUEUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char c[STAT_HDR_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char qtype[STAT_HDR_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte getQueue(cur->cur_set, &c[0]);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) sprintf(qtype, DATA_C2, c);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcat(data, qtype);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Calculate sync needed percentages */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & PCTS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char snpct[10];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) sprintf(snpct, DATA_F62,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki getSyncNeeded(cur->cur_set));
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcat(data, snpct);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Output */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rflags & SNDR_NET) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char type[STAT_HDR_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char vn[NAMED_LEN + 1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte getType(cur->cur_set, &type[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (type[0] == 'S') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c = kstat_value(cur->pre_set,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_IKSTAT_FILE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c = kstat_value(cur->pre_set,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_IKSTAT_SECFILE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Only print last 15 characters */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(c) >= NAMED_LEN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c += strlen(c) - NAMED_LEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(vn, c, NAMED_LEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vn[NAMED_LEN] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte header();
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(DATA_C16, vn);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf("%s", data);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(ROLE_INF_FMT, RDC_SECONDARY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Async. queue statistics */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & ASYNC_QUEUE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printQueueStats(first, cur->cur_set);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
e31df31051ab05e561eab5b23bb1c00627a10d64Thomas Atkins io_report(cur->cur_sec, cur->pre_sec,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_getstat(vn));
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (first) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(data, strlen(pad) > 0 ? pad : "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte first = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rflags & SNDR_BMP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char vn[16];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c = kstat_value(cur->pre_set, RDC_IKSTAT_BITMAP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Only print last 15 characters */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(c) >= NAMED_LEN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte c += strlen(c) - NAMED_LEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(vn, c, NAMED_LEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vn[NAMED_LEN] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte header();
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(DATA_C16, vn);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf("%s", data);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(ROLE_INF_FMT, RDC_BITMAP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Async. queue statistics */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (dflags & ASYNC_QUEUE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printQueueStats(first, cur->cur_set);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
e31df31051ab05e561eab5b23bb1c00627a10d64Thomas Atkins io_report(cur->cur_bmp, cur->pre_bmp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_getstat(vn));
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (first) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(data, strlen(pad) > 0 ? pad : "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte first = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortenext:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pre = cur;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur = cur->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sndr_add_stat() - adds a fully populated sndrstat_t structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the linked list of currently monitored kstats. The structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will be added in alphabetical order, using the volume name as the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * key.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sndrstat_t *sndrstat - to be added to the list.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesndr_add_stat(sndrstat_t *sndrstat)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat_t *cur;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sndr_top == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndr_top = sndrstat;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cur = sndr_top; cur != NULL; cur = cur->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *cur_vname, *nxt_vname, *tst_vname;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur_vname = kstat_value(cur->pre_set, RDC_IKSTAT_FILE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tst_vname = kstat_value(sndrstat->pre_set, RDC_IKSTAT_FILE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(cur_vname, tst_vname) <= 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we get to the last item in the list, then just
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add this one to the end
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cur->next == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur->next = sndrstat;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nxt_vname = kstat_value(cur->next->pre_set,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_IKSTAT_FILE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(nxt_vname, tst_vname) > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat->next = cur->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur->next = sndrstat;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cur == sndr_top)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndr_top = sndrstat;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat->next = cur;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sndr_del_stat() - deallocate memory for the structure being
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * passed in.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sndrstat_t *sndrstat - structure to be deallocated
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * returns
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sndrstat_t * - pointer to the "next" structures in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * linked list. May be NULL if we are removing the last
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * structure in the linked list.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesndrstat_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesndr_del_stat(sndrstat_t *sndrstat)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat_t *next = sndrstat->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_free(sndrstat->pre_set);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_free(sndrstat->pre_bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_free(sndrstat->pre_sec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_free(sndrstat->cur_set);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_free(sndrstat->cur_bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_free(sndrstat->cur_sec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(sndrstat);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sndr_value_check() - check to determine if any activity was registered
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on this volume by checking the previous stats vs. the current stats.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sndrstat_t *sndrstat - structure to be checked
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * returns
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 - no activity
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1 - activity
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesndr_value_check(sndrstat_t *sndrstat)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SNDR_COMPLETE(sndrstat->collected))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (io_value_check(sndrstat->pre_bmp->ks_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat->cur_bmp->ks_data)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (io_value_check(sndrstat->pre_sec->ks_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndrstat->cur_sec->ks_data)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sndr_validate() - validates the fields required by dsstat exist in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the kstat_t structure passed in. This check keeps dsstat from
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * core dumping if the kstat_named_t structures change in any of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * services that dsstat monitors.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * paramaters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * kstat_t *ksp - kstat_t structure to check. The ks_data field
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * should have been populated with a call to kstat_read()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * returns
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 - all fields are contained in the kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1 - a field required by dsstat is not in the kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesndr_validate(kstat_t *ksp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (! kstat_value(ksp, RDC_IKSTAT_FILE) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ! kstat_value(ksp, RDC_IKSTAT_FLAGS) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ! kstat_value(ksp, RDC_IKSTAT_SYNCFLAGS) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ! kstat_value(ksp, RDC_IKSTAT_BMPFLAGS) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ! kstat_value(ksp, RDC_IKSTAT_VOLSIZE) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ! kstat_value(ksp, RDC_IKSTAT_BITSSET) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ! kstat_value(ksp, RDC_IKSTAT_QUEUE_TYPE) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ! kstat_value(ksp, RDC_IKSTAT_ASYNC_ITEMS) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ! kstat_value(ksp, RDC_IKSTAT_ASYNC_BLOCKS) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ! kstat_value(ksp, RDC_IKSTAT_ASYNC_ITEM_HWM) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ! kstat_value(ksp, RDC_IKSTAT_ASYNC_BLOCK_HWM))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetType(kstat_t *ksp, char *vtype)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *set_flags;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte set_flags = kstat_value(ksp, RDC_IKSTAT_FLAGS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*set_flags & RDC_PRIMARY)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vtype, "P");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vtype, "S");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetStat(kstat_t *ksp, char *vstat)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *set_flags;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *syn_flags;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *bmp_flags;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte set_flags = kstat_value(ksp, RDC_IKSTAT_FLAGS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syn_flags = kstat_value(ksp, RDC_IKSTAT_SYNCFLAGS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_flags = kstat_value(ksp, RDC_IKSTAT_BMPFLAGS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vstat, "R");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*set_flags & RDC_SYNCING) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*set_flags & RDC_SLAVE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*set_flags & RDC_PRIMARY)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vstat, "RS");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vstat, "SY");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*set_flags & RDC_PRIMARY)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vstat, "SY");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vstat, "RS");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*set_flags & RDC_LOGGING) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vstat, "L");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*set_flags & RDC_QUEUING)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vstat, "Q");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*set_flags & RDC_DISKQ_FAILED)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vstat, "QF");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*syn_flags & RDC_SYNC_NEEDED)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vstat, "SN");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*syn_flags & RDC_RSYNC_NEEDED)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vstat, "RN");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*syn_flags & RDC_FCAL_FAILED)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vstat, "FF");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*bmp_flags & RDC_BMP_FAILED)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vstat, "BF");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*syn_flags & RDC_VOL_FAILED)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vstat, "VF");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetQueue(kstat_t *ksp, char *vqueue)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *qtype;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vqueue, "-");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qtype = kstat_value(ksp, RDC_IKSTAT_QUEUE_TYPE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(qtype, "memory") == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vqueue, "M");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(qtype, "disk") == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(vqueue, "D");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefloat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortegetSyncNeeded(kstat_t *ksp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *volsize, *bitsset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t bits, segs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte float pct;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volsize = kstat_value(ksp, RDC_IKSTAT_VOLSIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bitsset = kstat_value(ksp, RDC_IKSTAT_BITSSET);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte segs = FBA_TO_LOG_LEN(*volsize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bits = *bitsset > 0 ? *bitsset : 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pct = segs ? ((float)bits/(float)segs) : 0.0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pct *= 100;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (pct);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Special handling for compatibility.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "dsstat -s <set>" allows set name to be the last 15 chars,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * due to 15 characters limit of old kstat information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return 0 if:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1) full and partial are same
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 2) partial is the last 15 chars of full
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesndr_strcmp(char *full, char *partial)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *f = full;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = strcmp(full, partial);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc != 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strlen(partial) == NAMED_LEN) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strlen(full) > NAMED_LEN)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte f += strlen(full) - NAMED_LEN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = strncmp(f, partial, NAMED_LEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesndr_vol_selected(kstat_t *ksp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vslist_t *vslist = vs_top;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (vslist = vs_top; vslist != NULL; vslist = vslist->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *vn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *vh;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If no host specified, check local only */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vslist->volhost == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vn = kstat_value(ksp, RDC_IKSTAT_FILE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sndr_strcmp(vn, vslist->volname))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check primary */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vn = kstat_value(ksp, RDC_IKSTAT_FILE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vh = kstat_value(ksp, RDC_IKSTAT_PRIMARY_HOST);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sndr_strcmp(vn, vslist->volname) == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndr_strcmp(vh, vslist->volhost) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check secondary */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vn = kstat_value(ksp, RDC_IKSTAT_SECFILE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vh = kstat_value(ksp, RDC_IKSTAT_SECONDARY_HOST);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sndr_strcmp(vn, vslist->volname) == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sndr_strcmp(vh, vslist->volhost) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vs_top != NULL && vslist == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteprintQueueStats(int first, kstat_t *cur_set)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t *val;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (! first) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Filler for async. queue fields */
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(TPS_HDR_FMT, NO_INFO);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_HDR_FMT, NO_INFO);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(TPS_HDR_FMT, NO_INFO);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_HDR_FMT, NO_INFO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val = (uint32_t *)kstat_value(cur_set, RDC_IKSTAT_ASYNC_ITEMS);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(TPS_INF_FMT, *val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val = (uint32_t *)kstat_value(cur_set, RDC_IKSTAT_ASYNC_BLOCKS);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_INF_FMT, (float)(*val / 2));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val = (uint32_t *)kstat_value(cur_set, RDC_IKSTAT_ASYNC_ITEM_HWM);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(TPS_INF_FMT, *val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val = (uint32_t *)kstat_value(cur_set, RDC_IKSTAT_ASYNC_BLOCK_HWM);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) printf(KPS_INF_FMT, (float)(*val / 2));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}