fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
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 * CDDL HEADER END
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "../../../uts/common/avs/ns/dsw/dsw_dev.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ii_discover() - looks for new statistics to be monitored.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Verifies that any statistics found are now already being
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * monitored.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Loop on all kstats */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Search for II set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Validate kstat structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Duplicate check
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cur = ii_top; cur != NULL; cur = cur->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initialize new record
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iistat = (iistat_t *)calloc(1, sizeof (iistat_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Master kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kname = kstat_value(iistat->pre_set, DSW_SKSTAT_MSTIO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mst_ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Shadow kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kname = kstat_value(iistat->pre_set, DSW_SKSTAT_SHDIO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte shd_ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Bitmap kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kname = kstat_value(iistat->pre_set, DSW_SKSTAT_BMPIO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp_ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Overflow kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kname = kstat_value(iistat->pre_set, DSW_SKSTAT_OVRIO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ovr_ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check if we got a complete set of stats
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add to linked list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ii_update() - updates all of the statistics currently being monitored.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cur = ii_top; cur != NULL; cur = cur->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Age off old stats
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(volname, cur->pre_set->ks_name, KSTAT_STRLEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, volname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cur->cur_set = kstat_retrieve(kc, ksp)) == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Validate set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(cur->pre_set->ks_name, cur->cur_set->ks_name) != 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur->pre_set->ks_instance != cur->cur_set->ks_instance)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Master kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kname = kstat_value(cur->cur_set, DSW_SKSTAT_MSTIO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cur->cur_mst = kstat_retrieve(kc, ksp)) == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Shadow kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kname = kstat_value(cur->cur_set, DSW_SKSTAT_SHDIO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cur->cur_shd = kstat_retrieve(kc, ksp)) == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Bitmap kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kname = kstat_value(cur->pre_set, DSW_SKSTAT_BMPIO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cur->cur_bmp = kstat_retrieve(kc, ksp)) == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Overflow kstat
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kname = kstat_value(cur->cur_set, DSW_SKSTAT_OVRIO);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cur->pre_ovr = kstat_retrieve(kc, ksp)) == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cur->cur_ovr = kstat_retrieve(kc, ksp)) == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ii_report() - outputs statistics for the statistics currently being
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * monitored. Deletes statistics for volumes that have been disabled.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Create padding string for secondary report lines */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check to see if this is this a complete */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* notify user of set being disabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* free memory and remove stat from list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check to see if the user specified this volume */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check to see if zflag applies */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Calculate flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flags = kstat_value(cur->cur_set, DSW_SKSTAT_FLAGS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Calculate sync needed precentage */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chkbits = *cpybits >= *shdbits ? cpybits : shdbits;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Master statistics */
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(data, strlen(pad) > 0 ? pad : "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Shadow statistics */
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(data, strlen(pad) > 0 ? pad : "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Bitmap statistics */
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(data, strlen(pad) > 0 ? pad : "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Overflow statistics */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cur->cur_ovr == NULL && cur->pre_ovr != NULL)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(data, strlen(pad) > 0 ? pad : "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ii_add_stat() - adds a fully populated iistat_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 of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the shadow volume as the key.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cur = ii_top; cur != NULL; cur = cur->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we get to the last item in the list, then just
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add this one to the end
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ii_del_stat() - deallocate memory for the structure being
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * passed in.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parameters
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iistat_t *iistat - structure to be deallocated
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iistat_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 for (vslist = vs_top; vslist != NULL; vslist = vslist->next) {