17836SJohn.Forte@Sun.COM /*
27836SJohn.Forte@Sun.COM * CDDL HEADER START
37836SJohn.Forte@Sun.COM *
47836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the
57836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License").
67836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License.
77836SJohn.Forte@Sun.COM *
87836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing.
107836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions
117836SJohn.Forte@Sun.COM * and limitations under the License.
127836SJohn.Forte@Sun.COM *
137836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
147836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
167836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
177836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
187836SJohn.Forte@Sun.COM *
197836SJohn.Forte@Sun.COM * CDDL HEADER END
207836SJohn.Forte@Sun.COM */
217836SJohn.Forte@Sun.COM /*
22*11576SSurya.Prakki@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
237836SJohn.Forte@Sun.COM * Use is subject to license terms.
247836SJohn.Forte@Sun.COM */
257836SJohn.Forte@Sun.COM
267836SJohn.Forte@Sun.COM #include <stdio.h>
277836SJohn.Forte@Sun.COM #include <stdlib.h>
287836SJohn.Forte@Sun.COM #include <string.h>
297836SJohn.Forte@Sun.COM #include <unistd.h>
307836SJohn.Forte@Sun.COM #include <errno.h>
317836SJohn.Forte@Sun.COM #include <signal.h>
327836SJohn.Forte@Sun.COM #include <setjmp.h>
337836SJohn.Forte@Sun.COM
347836SJohn.Forte@Sun.COM #include <kstat.h>
357836SJohn.Forte@Sun.COM
367836SJohn.Forte@Sun.COM #include <sys/nsctl/rdc.h>
377836SJohn.Forte@Sun.COM #include <sys/nsctl/rdc_io.h>
387836SJohn.Forte@Sun.COM #include <sys/nsctl/rdc_bitmap.h>
397836SJohn.Forte@Sun.COM
407836SJohn.Forte@Sun.COM #include "sdbc_stats.h"
417836SJohn.Forte@Sun.COM #include "sndr_stats.h"
427836SJohn.Forte@Sun.COM
437836SJohn.Forte@Sun.COM #include "dsstat.h"
447836SJohn.Forte@Sun.COM #include "common.h"
457836SJohn.Forte@Sun.COM #include "report.h"
467836SJohn.Forte@Sun.COM
477836SJohn.Forte@Sun.COM static sndrstat_t *sndr_top;
487836SJohn.Forte@Sun.COM
497836SJohn.Forte@Sun.COM void sndr_add_stat(sndrstat_t *);
507836SJohn.Forte@Sun.COM sndrstat_t *sndr_del_stat(sndrstat_t *);
517836SJohn.Forte@Sun.COM
527836SJohn.Forte@Sun.COM int sndr_value_check(sndrstat_t *);
537836SJohn.Forte@Sun.COM int sndr_validate(kstat_t *);
547836SJohn.Forte@Sun.COM int sndr_strcmp(char *, char *);
557836SJohn.Forte@Sun.COM int sndr_vol_selected(kstat_t *);
567836SJohn.Forte@Sun.COM
577836SJohn.Forte@Sun.COM void getType(kstat_t *, char *);
587836SJohn.Forte@Sun.COM void getStat(kstat_t *, char *);
597836SJohn.Forte@Sun.COM void getQueue(kstat_t *, char *);
607836SJohn.Forte@Sun.COM void printQueueStats(int, kstat_t *);
617836SJohn.Forte@Sun.COM float getSyncNeeded(kstat_t *);
627836SJohn.Forte@Sun.COM
637836SJohn.Forte@Sun.COM static void update_sighandler(int);
647836SJohn.Forte@Sun.COM static void discover_sighandler(int);
657836SJohn.Forte@Sun.COM
667836SJohn.Forte@Sun.COM static sigjmp_buf update_env, discover_env;
677836SJohn.Forte@Sun.COM static sig_atomic_t sig_raised = 0;
687836SJohn.Forte@Sun.COM /*
697836SJohn.Forte@Sun.COM * sndr_discover() - looks for new statistics to be monitored.
707836SJohn.Forte@Sun.COM * Verifies that any statistics found are now already being
717836SJohn.Forte@Sun.COM * monitored.
727836SJohn.Forte@Sun.COM *
737836SJohn.Forte@Sun.COM */
747836SJohn.Forte@Sun.COM int
sndr_discover(kstat_ctl_t * kc)757836SJohn.Forte@Sun.COM sndr_discover(kstat_ctl_t *kc)
767836SJohn.Forte@Sun.COM {
777836SJohn.Forte@Sun.COM static int validated = 0;
787836SJohn.Forte@Sun.COM struct sigaction segv_act;
797836SJohn.Forte@Sun.COM int rc = 0;
807836SJohn.Forte@Sun.COM kstat_t *ksp;
817836SJohn.Forte@Sun.COM
827836SJohn.Forte@Sun.COM
837836SJohn.Forte@Sun.COM (void) signal(SIGSEGV, discover_sighandler);
847836SJohn.Forte@Sun.COM (void) sigaction(SIGSEGV, NULL, &segv_act);
857836SJohn.Forte@Sun.COM
867836SJohn.Forte@Sun.COM /* Loop on all kstats */
877836SJohn.Forte@Sun.COM for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) {
887836SJohn.Forte@Sun.COM int kinst;
897836SJohn.Forte@Sun.COM char kname[KSTAT_STRLEN + 1];
907836SJohn.Forte@Sun.COM sndrstat_t *cur;
917836SJohn.Forte@Sun.COM sndrstat_t *sndrstat = NULL;
927836SJohn.Forte@Sun.COM kstat_t *bmp_ksp;
937836SJohn.Forte@Sun.COM kstat_t *sec_ksp;
947836SJohn.Forte@Sun.COM
957836SJohn.Forte@Sun.COM /* Serach for SNDR set */
967836SJohn.Forte@Sun.COM if (strcmp(ksp->ks_module, RDC_KSTAT_MODULE) != 0 ||
977836SJohn.Forte@Sun.COM strcmp(ksp->ks_name, RDC_KSTAT_INFO) != 0) {
987836SJohn.Forte@Sun.COM continue;
997836SJohn.Forte@Sun.COM }
1007836SJohn.Forte@Sun.COM
1017836SJohn.Forte@Sun.COM if (kstat_read(kc, ksp, NULL) == -1)
1027836SJohn.Forte@Sun.COM continue;
1037836SJohn.Forte@Sun.COM
1047836SJohn.Forte@Sun.COM /*
1057836SJohn.Forte@Sun.COM * Validate kstat structure
1067836SJohn.Forte@Sun.COM */
1077836SJohn.Forte@Sun.COM if (! validated) {
1087836SJohn.Forte@Sun.COM if (sndr_validate(ksp))
1097836SJohn.Forte@Sun.COM return (EINVAL);
1107836SJohn.Forte@Sun.COM
1117836SJohn.Forte@Sun.COM validated++;
1127836SJohn.Forte@Sun.COM }
1137836SJohn.Forte@Sun.COM
1147836SJohn.Forte@Sun.COM /*
1157836SJohn.Forte@Sun.COM * Duplicate check
1167836SJohn.Forte@Sun.COM */
1177836SJohn.Forte@Sun.COM for (cur = sndr_top; cur != NULL; cur = cur->next) {
1187836SJohn.Forte@Sun.COM char *cur_vname, *tst_vname;
1197836SJohn.Forte@Sun.COM uint32_t cur_inst, tst_inst;
1207836SJohn.Forte@Sun.COM
1217836SJohn.Forte@Sun.COM cur_vname = kstat_value(cur->pre_set, RDC_IKSTAT_FILE);
1227836SJohn.Forte@Sun.COM cur_inst = cur->pre_set->ks_instance;
1237836SJohn.Forte@Sun.COM
1247836SJohn.Forte@Sun.COM tst_vname = kstat_value(ksp, RDC_IKSTAT_FILE);
1257836SJohn.Forte@Sun.COM tst_inst = ksp->ks_instance;
1267836SJohn.Forte@Sun.COM
1277836SJohn.Forte@Sun.COM if (strcmp(cur_vname, tst_vname) == 0 &&
1287836SJohn.Forte@Sun.COM cur_inst == tst_inst)
1297836SJohn.Forte@Sun.COM goto next;
1307836SJohn.Forte@Sun.COM }
1317836SJohn.Forte@Sun.COM
1327836SJohn.Forte@Sun.COM /*
1337836SJohn.Forte@Sun.COM * Initialize new record
1347836SJohn.Forte@Sun.COM */
1357836SJohn.Forte@Sun.COM sndrstat = (sndrstat_t *)calloc(1, sizeof (sndrstat_t));
1367836SJohn.Forte@Sun.COM kinst = ksp->ks_instance;
1377836SJohn.Forte@Sun.COM
1387836SJohn.Forte@Sun.COM /*
1397836SJohn.Forte@Sun.COM * Set kstat
1407836SJohn.Forte@Sun.COM */
1417836SJohn.Forte@Sun.COM sndrstat->pre_set = kstat_retrieve(kc, ksp);
1427836SJohn.Forte@Sun.COM
1437836SJohn.Forte@Sun.COM if (sndrstat->pre_set == NULL)
1447836SJohn.Forte@Sun.COM goto next;
1457836SJohn.Forte@Sun.COM
1467836SJohn.Forte@Sun.COM sndrstat->collected |= GOT_SET_KSTAT;
1477836SJohn.Forte@Sun.COM
1487836SJohn.Forte@Sun.COM /*
1497836SJohn.Forte@Sun.COM * Bitmap kstat
1507836SJohn.Forte@Sun.COM */
1517836SJohn.Forte@Sun.COM (void) sprintf(kname, "%s%d", RDC_KSTAT_BMPNAME, kinst);
1527836SJohn.Forte@Sun.COM
1537836SJohn.Forte@Sun.COM bmp_ksp = kstat_lookup(kc, RDC_KSTAT_BMPNAME, kinst, kname);
1547836SJohn.Forte@Sun.COM sndrstat->pre_bmp = kstat_retrieve(kc, bmp_ksp);
1557836SJohn.Forte@Sun.COM
1567836SJohn.Forte@Sun.COM if (sndrstat->pre_bmp == NULL)
1577836SJohn.Forte@Sun.COM goto next;
1587836SJohn.Forte@Sun.COM
1597836SJohn.Forte@Sun.COM sndrstat->collected |= GOT_BMP_KSTAT;
1607836SJohn.Forte@Sun.COM
1617836SJohn.Forte@Sun.COM /*
1627836SJohn.Forte@Sun.COM * Secondary kstat
1637836SJohn.Forte@Sun.COM */
1647836SJohn.Forte@Sun.COM (void) sprintf(kname, "%s%d", RDC_KSTAT_RDCNAME, kinst);
1657836SJohn.Forte@Sun.COM
1667836SJohn.Forte@Sun.COM sec_ksp = kstat_lookup(kc, RDC_KSTAT_MODULE, kinst, kname);
1677836SJohn.Forte@Sun.COM sndrstat->pre_sec = kstat_retrieve(kc, sec_ksp);
1687836SJohn.Forte@Sun.COM
1697836SJohn.Forte@Sun.COM if (sndrstat->pre_sec == NULL)
1707836SJohn.Forte@Sun.COM goto next;
1717836SJohn.Forte@Sun.COM
1727836SJohn.Forte@Sun.COM sndrstat->collected |= GOT_SEC_KSTAT;
1737836SJohn.Forte@Sun.COM
1747836SJohn.Forte@Sun.COM next:
1757836SJohn.Forte@Sun.COM /*
1767836SJohn.Forte@Sun.COM * Check if we got a complete set of stats
1777836SJohn.Forte@Sun.COM */
1787836SJohn.Forte@Sun.COM if (sndrstat == NULL)
1797836SJohn.Forte@Sun.COM continue;
1807836SJohn.Forte@Sun.COM
1817836SJohn.Forte@Sun.COM if (SNDR_COMPLETE(sndrstat->collected)) {
1827836SJohn.Forte@Sun.COM (void) sndr_del_stat(sndrstat);
1837836SJohn.Forte@Sun.COM continue;
1847836SJohn.Forte@Sun.COM }
1857836SJohn.Forte@Sun.COM
1867836SJohn.Forte@Sun.COM /*
1877836SJohn.Forte@Sun.COM * Add to linked list
1887836SJohn.Forte@Sun.COM */
1897836SJohn.Forte@Sun.COM sndr_add_stat(sndrstat);
1907836SJohn.Forte@Sun.COM }
1917836SJohn.Forte@Sun.COM
1927836SJohn.Forte@Sun.COM (void) sigsetjmp(discover_env, 0);
1937836SJohn.Forte@Sun.COM if (sig_raised) {
1947836SJohn.Forte@Sun.COM sig_raised = 0;
1957836SJohn.Forte@Sun.COM rc = -1;
1967836SJohn.Forte@Sun.COM }
1977836SJohn.Forte@Sun.COM (void) sigaction(SIGSEGV, &segv_act, NULL);
1987836SJohn.Forte@Sun.COM
1997836SJohn.Forte@Sun.COM return (rc);
2007836SJohn.Forte@Sun.COM }
2017836SJohn.Forte@Sun.COM
2027836SJohn.Forte@Sun.COM void
discover_sighandler(int sig)2037836SJohn.Forte@Sun.COM discover_sighandler(int sig)
2047836SJohn.Forte@Sun.COM {
2057836SJohn.Forte@Sun.COM switch (sig) {
2067836SJohn.Forte@Sun.COM case SIGSEGV:
2077836SJohn.Forte@Sun.COM sig_raised = 1;
2087836SJohn.Forte@Sun.COM siglongjmp(discover_env, sig);
2097836SJohn.Forte@Sun.COM default:
2107836SJohn.Forte@Sun.COM exit(sig);
2117836SJohn.Forte@Sun.COM }
2127836SJohn.Forte@Sun.COM }
2137836SJohn.Forte@Sun.COM
2147836SJohn.Forte@Sun.COM void
update_sighandler(int sig)2157836SJohn.Forte@Sun.COM update_sighandler(int sig)
2167836SJohn.Forte@Sun.COM {
2177836SJohn.Forte@Sun.COM switch (sig) {
2187836SJohn.Forte@Sun.COM case SIGSEGV:
2197836SJohn.Forte@Sun.COM sig_raised = 1;
2207836SJohn.Forte@Sun.COM siglongjmp(update_env, sig);
2217836SJohn.Forte@Sun.COM default:
2227836SJohn.Forte@Sun.COM exit(sig);
2237836SJohn.Forte@Sun.COM }
2247836SJohn.Forte@Sun.COM }
2257836SJohn.Forte@Sun.COM
2267836SJohn.Forte@Sun.COM /*
2277836SJohn.Forte@Sun.COM * sndr_update() - updates all of the statistics currently being monitored.
2287836SJohn.Forte@Sun.COM *
2297836SJohn.Forte@Sun.COM */
2307836SJohn.Forte@Sun.COM int
sndr_update(kstat_ctl_t * kc)2317836SJohn.Forte@Sun.COM sndr_update(kstat_ctl_t *kc)
2327836SJohn.Forte@Sun.COM {
2337836SJohn.Forte@Sun.COM sndrstat_t *cur;
2347836SJohn.Forte@Sun.COM struct sigaction segv_act;
2357836SJohn.Forte@Sun.COM int rc = 0;
2367836SJohn.Forte@Sun.COM
2377836SJohn.Forte@Sun.COM (void) signal(SIGSEGV, update_sighandler);
2387836SJohn.Forte@Sun.COM (void) sigaction(SIGSEGV, NULL, &segv_act);
2397836SJohn.Forte@Sun.COM
2407836SJohn.Forte@Sun.COM for (cur = sndr_top; cur != NULL; cur = cur->next) {
2417836SJohn.Forte@Sun.COM int kinst;
2427836SJohn.Forte@Sun.COM char kname[KSTAT_STRLEN + 1];
2437836SJohn.Forte@Sun.COM kstat_t *ksp = NULL;
2447836SJohn.Forte@Sun.COM char *cur_vname, *tst_vname;
2457836SJohn.Forte@Sun.COM
2467836SJohn.Forte@Sun.COM cur->collected = 0;
2477836SJohn.Forte@Sun.COM
2487836SJohn.Forte@Sun.COM /*
2497836SJohn.Forte@Sun.COM * Age off old stats
2507836SJohn.Forte@Sun.COM */
2517836SJohn.Forte@Sun.COM if (cur->cur_set != NULL) {
2527836SJohn.Forte@Sun.COM kstat_free(cur->pre_set);
2537836SJohn.Forte@Sun.COM kstat_free(cur->pre_bmp);
2547836SJohn.Forte@Sun.COM kstat_free(cur->pre_sec);
2557836SJohn.Forte@Sun.COM
2567836SJohn.Forte@Sun.COM cur->pre_set = cur->cur_set;
2577836SJohn.Forte@Sun.COM cur->pre_bmp = cur->cur_bmp;
2587836SJohn.Forte@Sun.COM cur->pre_sec = cur->cur_sec;
2597836SJohn.Forte@Sun.COM }
2607836SJohn.Forte@Sun.COM
2617836SJohn.Forte@Sun.COM /*
2627836SJohn.Forte@Sun.COM * Set kstat
2637836SJohn.Forte@Sun.COM */
264*11576SSurya.Prakki@Sun.COM (void) strncpy(kname, cur->pre_set->ks_name, KSTAT_STRLEN);
2657836SJohn.Forte@Sun.COM kname[KSTAT_STRLEN] = '\0';
2667836SJohn.Forte@Sun.COM
2677836SJohn.Forte@Sun.COM kinst = cur->pre_set->ks_instance;
2687836SJohn.Forte@Sun.COM
2697836SJohn.Forte@Sun.COM ksp = kstat_lookup(kc, RDC_KSTAT_MODULE, kinst, kname);
2707836SJohn.Forte@Sun.COM
2717836SJohn.Forte@Sun.COM if ((cur->cur_set = kstat_retrieve(kc, ksp)) == NULL)
2727836SJohn.Forte@Sun.COM continue;
2737836SJohn.Forte@Sun.COM
2747836SJohn.Forte@Sun.COM cur->collected |= GOT_SET_KSTAT;
2757836SJohn.Forte@Sun.COM
2767836SJohn.Forte@Sun.COM /*
2777836SJohn.Forte@Sun.COM * Validate set
2787836SJohn.Forte@Sun.COM */
2797836SJohn.Forte@Sun.COM cur_vname = kstat_value(cur->pre_set, RDC_IKSTAT_FILE);
2807836SJohn.Forte@Sun.COM tst_vname = kstat_value(cur->cur_set, RDC_IKSTAT_FILE);
2817836SJohn.Forte@Sun.COM
2827836SJohn.Forte@Sun.COM if (strcmp(cur_vname, tst_vname) != 0)
2837836SJohn.Forte@Sun.COM continue;
2847836SJohn.Forte@Sun.COM
2857836SJohn.Forte@Sun.COM /*
2867836SJohn.Forte@Sun.COM * Bitmap kstat
2877836SJohn.Forte@Sun.COM */
2887836SJohn.Forte@Sun.COM (void) sprintf(kname, "%s%d", RDC_KSTAT_BMPNAME, kinst);
2897836SJohn.Forte@Sun.COM
2907836SJohn.Forte@Sun.COM ksp = kstat_lookup(kc, RDC_KSTAT_BMPNAME, kinst, kname);
2917836SJohn.Forte@Sun.COM
2927836SJohn.Forte@Sun.COM if ((cur->cur_bmp = kstat_retrieve(kc, ksp)) == NULL)
2937836SJohn.Forte@Sun.COM continue;
2947836SJohn.Forte@Sun.COM
2957836SJohn.Forte@Sun.COM cur->collected |= GOT_BMP_KSTAT;
2967836SJohn.Forte@Sun.COM
2977836SJohn.Forte@Sun.COM /*
2987836SJohn.Forte@Sun.COM * Secondary kstat
2997836SJohn.Forte@Sun.COM */
3007836SJohn.Forte@Sun.COM (void) sprintf(kname, "%s%d", RDC_KSTAT_RDCNAME, kinst);
3017836SJohn.Forte@Sun.COM
3027836SJohn.Forte@Sun.COM ksp = kstat_lookup(kc, RDC_KSTAT_MODULE, kinst, kname);
3037836SJohn.Forte@Sun.COM
3047836SJohn.Forte@Sun.COM if ((cur->cur_sec = kstat_retrieve(kc, ksp)) == NULL)
3057836SJohn.Forte@Sun.COM continue;
3067836SJohn.Forte@Sun.COM
3077836SJohn.Forte@Sun.COM cur->collected |= GOT_SEC_KSTAT;
3087836SJohn.Forte@Sun.COM
3097836SJohn.Forte@Sun.COM }
3107836SJohn.Forte@Sun.COM
3117836SJohn.Forte@Sun.COM (void) sigsetjmp(update_env, 0);
3127836SJohn.Forte@Sun.COM if (sig_raised) {
3137836SJohn.Forte@Sun.COM sig_raised = 0;
3147836SJohn.Forte@Sun.COM rc = -1;
3157836SJohn.Forte@Sun.COM }
3167836SJohn.Forte@Sun.COM (void) sigaction(SIGSEGV, &segv_act, NULL);
3177836SJohn.Forte@Sun.COM
3187836SJohn.Forte@Sun.COM return (rc);
3197836SJohn.Forte@Sun.COM }
3207836SJohn.Forte@Sun.COM
3217836SJohn.Forte@Sun.COM /*
3227836SJohn.Forte@Sun.COM * sndr_report() - outputs statistics for the statistics currently being
3237836SJohn.Forte@Sun.COM * monitored. Deletes statistics for volumes that have been disabled.
3247836SJohn.Forte@Sun.COM *
3257836SJohn.Forte@Sun.COM */
3267836SJohn.Forte@Sun.COM int
sndr_report()3277836SJohn.Forte@Sun.COM sndr_report()
3287836SJohn.Forte@Sun.COM {
3297836SJohn.Forte@Sun.COM int padsz;
3307836SJohn.Forte@Sun.COM char pad[20] = "";
3317836SJohn.Forte@Sun.COM sndrstat_t *cur, *pre = NULL;
3327836SJohn.Forte@Sun.COM
3337836SJohn.Forte@Sun.COM if (sndr_top == NULL)
3347836SJohn.Forte@Sun.COM return (0);
3357836SJohn.Forte@Sun.COM
3367836SJohn.Forte@Sun.COM /* Create padding string for secondary report lines */
3377836SJohn.Forte@Sun.COM padsz = 0;
3387836SJohn.Forte@Sun.COM if (dflags & FLAGS) {
3397836SJohn.Forte@Sun.COM padsz += STAT_HDR_SIZE;
3407836SJohn.Forte@Sun.COM padsz += STAT_HDR_SIZE;
3417836SJohn.Forte@Sun.COM }
3427836SJohn.Forte@Sun.COM
3437836SJohn.Forte@Sun.COM if (dflags & ASYNC_QUEUE)
3447836SJohn.Forte@Sun.COM padsz += STAT_HDR_SIZE;
3457836SJohn.Forte@Sun.COM
3467836SJohn.Forte@Sun.COM if (dflags & PCTS)
3477836SJohn.Forte@Sun.COM padsz += PCT_HDR_SIZE;
3487836SJohn.Forte@Sun.COM
3497836SJohn.Forte@Sun.COM if (padsz) {
3507836SJohn.Forte@Sun.COM char fmt[20];
351*11576SSurya.Prakki@Sun.COM (void) sprintf(fmt, "%%%ds", padsz);
352*11576SSurya.Prakki@Sun.COM (void) sprintf(pad, fmt, " ");
3537836SJohn.Forte@Sun.COM }
3547836SJohn.Forte@Sun.COM
3557836SJohn.Forte@Sun.COM for (cur = sndr_top; cur != NULL; ) { /*CSTYLED */
3567836SJohn.Forte@Sun.COM int first = 1;
3577836SJohn.Forte@Sun.COM char data[20] = "";
3587836SJohn.Forte@Sun.COM
3597836SJohn.Forte@Sun.COM /* Check to see if this is this a complete */
3607836SJohn.Forte@Sun.COM if (SNDR_COMPLETE(cur->collected)) {
3617836SJohn.Forte@Sun.COM char *c;
3627836SJohn.Forte@Sun.COM char vn[NSC_MAXPATH + 1];
3637836SJohn.Forte@Sun.COM sndrstat_t *next;
3647836SJohn.Forte@Sun.COM
3657836SJohn.Forte@Sun.COM /* notify user of set being disabled */
3667836SJohn.Forte@Sun.COM c = kstat_value(cur->pre_set, RDC_IKSTAT_SECFILE);
367*11576SSurya.Prakki@Sun.COM (void) strncpy(vn, c, NSC_MAXPATH);
3687836SJohn.Forte@Sun.COM vn[NSC_MAXPATH] = '\0';
3697836SJohn.Forte@Sun.COM
370*11576SSurya.Prakki@Sun.COM (void) printf(DATA_C16, vn);
371*11576SSurya.Prakki@Sun.COM (void) printf(" %s\n", RDC_DISABLED);
3727836SJohn.Forte@Sun.COM
3737836SJohn.Forte@Sun.COM next = sndr_del_stat(cur);
3747836SJohn.Forte@Sun.COM
3757836SJohn.Forte@Sun.COM /* free memory and remove stat from list */
3767836SJohn.Forte@Sun.COM if (! pre)
3777836SJohn.Forte@Sun.COM cur = sndr_top = next;
3787836SJohn.Forte@Sun.COM else
3797836SJohn.Forte@Sun.COM cur = pre->next = next;
3807836SJohn.Forte@Sun.COM
3817836SJohn.Forte@Sun.COM continue;
3827836SJohn.Forte@Sun.COM }
3837836SJohn.Forte@Sun.COM
3847836SJohn.Forte@Sun.COM /* Check to see if the user specified this volume */
3857836SJohn.Forte@Sun.COM if (! sndr_vol_selected(cur->pre_set))
3867836SJohn.Forte@Sun.COM goto next;
3877836SJohn.Forte@Sun.COM
3887836SJohn.Forte@Sun.COM /* Check to see if zflag applies */
3897836SJohn.Forte@Sun.COM if (zflag && sndr_value_check(cur) == 0)
3907836SJohn.Forte@Sun.COM goto next;
3917836SJohn.Forte@Sun.COM
3927836SJohn.Forte@Sun.COM /* Calculate flags */
3937836SJohn.Forte@Sun.COM if (dflags & FLAGS) {
3947836SJohn.Forte@Sun.COM char c[STAT_HDR_SIZE];
3957836SJohn.Forte@Sun.COM char vtype[STAT_HDR_SIZE];
3967836SJohn.Forte@Sun.COM char vstat[STAT_HDR_SIZE];
3977836SJohn.Forte@Sun.COM
3987836SJohn.Forte@Sun.COM getType(cur->cur_set, &c[0]);
399*11576SSurya.Prakki@Sun.COM (void) sprintf(vtype, DATA_C2, c);
400*11576SSurya.Prakki@Sun.COM (void) strcat(data, vtype);
4017836SJohn.Forte@Sun.COM
4027836SJohn.Forte@Sun.COM getStat(cur->cur_set, &c[0]);
403*11576SSurya.Prakki@Sun.COM (void) sprintf(vstat, DATA_C2, c);
404*11576SSurya.Prakki@Sun.COM (void) strcat(data, vstat);
4057836SJohn.Forte@Sun.COM }
4067836SJohn.Forte@Sun.COM
4077836SJohn.Forte@Sun.COM /* Async. queue statistics */
4087836SJohn.Forte@Sun.COM if (dflags & ASYNC_QUEUE) {
4097836SJohn.Forte@Sun.COM char c[STAT_HDR_SIZE];
4107836SJohn.Forte@Sun.COM char qtype[STAT_HDR_SIZE];
4117836SJohn.Forte@Sun.COM
4127836SJohn.Forte@Sun.COM getQueue(cur->cur_set, &c[0]);
413*11576SSurya.Prakki@Sun.COM (void) sprintf(qtype, DATA_C2, c);
414*11576SSurya.Prakki@Sun.COM (void) strcat(data, qtype);
4157836SJohn.Forte@Sun.COM }
4167836SJohn.Forte@Sun.COM
4177836SJohn.Forte@Sun.COM /* Calculate sync needed percentages */
4187836SJohn.Forte@Sun.COM if (dflags & PCTS) {
4197836SJohn.Forte@Sun.COM char snpct[10];
4207836SJohn.Forte@Sun.COM
421*11576SSurya.Prakki@Sun.COM (void) sprintf(snpct, DATA_F62,
422*11576SSurya.Prakki@Sun.COM getSyncNeeded(cur->cur_set));
423*11576SSurya.Prakki@Sun.COM (void) strcat(data, snpct);
4247836SJohn.Forte@Sun.COM }
4257836SJohn.Forte@Sun.COM
4267836SJohn.Forte@Sun.COM /* Output */
4277836SJohn.Forte@Sun.COM if (rflags & SNDR_NET) {
4287836SJohn.Forte@Sun.COM char *c;
4297836SJohn.Forte@Sun.COM char type[STAT_HDR_SIZE];
4307836SJohn.Forte@Sun.COM char vn[NAMED_LEN + 1];
4317836SJohn.Forte@Sun.COM
4327836SJohn.Forte@Sun.COM getType(cur->cur_set, &type[0]);
4337836SJohn.Forte@Sun.COM
4347836SJohn.Forte@Sun.COM if (type[0] == 'S') {
4357836SJohn.Forte@Sun.COM c = kstat_value(cur->pre_set,
4367836SJohn.Forte@Sun.COM RDC_IKSTAT_FILE);
4377836SJohn.Forte@Sun.COM } else {
4387836SJohn.Forte@Sun.COM c = kstat_value(cur->pre_set,
4397836SJohn.Forte@Sun.COM RDC_IKSTAT_SECFILE);
4407836SJohn.Forte@Sun.COM }
4417836SJohn.Forte@Sun.COM
4427836SJohn.Forte@Sun.COM /* Only print last 15 characters */
4437836SJohn.Forte@Sun.COM if (strlen(c) >= NAMED_LEN) {
4447836SJohn.Forte@Sun.COM c += strlen(c) - NAMED_LEN;
4457836SJohn.Forte@Sun.COM }
446*11576SSurya.Prakki@Sun.COM (void) strncpy(vn, c, NAMED_LEN);
4477836SJohn.Forte@Sun.COM vn[NAMED_LEN] = '\0';
4487836SJohn.Forte@Sun.COM
4497836SJohn.Forte@Sun.COM header();
450*11576SSurya.Prakki@Sun.COM (void) printf(DATA_C16, vn);
451*11576SSurya.Prakki@Sun.COM (void) printf("%s", data);
452*11576SSurya.Prakki@Sun.COM (void) printf(ROLE_INF_FMT, RDC_SECONDARY);
4537836SJohn.Forte@Sun.COM
4547836SJohn.Forte@Sun.COM /* Async. queue statistics */
4557836SJohn.Forte@Sun.COM if (dflags & ASYNC_QUEUE)
4567836SJohn.Forte@Sun.COM printQueueStats(first, cur->cur_set);
4577836SJohn.Forte@Sun.COM
45810714SThomas.Atkins@Sun.COM io_report(cur->cur_sec, cur->pre_sec,
4597836SJohn.Forte@Sun.COM sdbc_getstat(vn));
460*11576SSurya.Prakki@Sun.COM (void) printf("\n");
4617836SJohn.Forte@Sun.COM
4627836SJohn.Forte@Sun.COM if (first) {
463*11576SSurya.Prakki@Sun.COM (void) strcpy(data, strlen(pad) > 0 ? pad : "");
4647836SJohn.Forte@Sun.COM first = 0;
4657836SJohn.Forte@Sun.COM }
4667836SJohn.Forte@Sun.COM }
4677836SJohn.Forte@Sun.COM
4687836SJohn.Forte@Sun.COM if (rflags & SNDR_BMP) {
4697836SJohn.Forte@Sun.COM char *c;
4707836SJohn.Forte@Sun.COM char vn[16];
4717836SJohn.Forte@Sun.COM
4727836SJohn.Forte@Sun.COM c = kstat_value(cur->pre_set, RDC_IKSTAT_BITMAP);
4737836SJohn.Forte@Sun.COM
4747836SJohn.Forte@Sun.COM /* Only print last 15 characters */
4757836SJohn.Forte@Sun.COM if (strlen(c) >= NAMED_LEN) {
4767836SJohn.Forte@Sun.COM c += strlen(c) - NAMED_LEN;
4777836SJohn.Forte@Sun.COM }
478*11576SSurya.Prakki@Sun.COM (void) strncpy(vn, c, NAMED_LEN);
4797836SJohn.Forte@Sun.COM vn[NAMED_LEN] = '\0';
4807836SJohn.Forte@Sun.COM
4817836SJohn.Forte@Sun.COM header();
482*11576SSurya.Prakki@Sun.COM (void) printf(DATA_C16, vn);
483*11576SSurya.Prakki@Sun.COM (void) printf("%s", data);
484*11576SSurya.Prakki@Sun.COM (void) printf(ROLE_INF_FMT, RDC_BITMAP);
4857836SJohn.Forte@Sun.COM
4867836SJohn.Forte@Sun.COM /* Async. queue statistics */
4877836SJohn.Forte@Sun.COM if (dflags & ASYNC_QUEUE)
4887836SJohn.Forte@Sun.COM printQueueStats(first, cur->cur_set);
4897836SJohn.Forte@Sun.COM
49010714SThomas.Atkins@Sun.COM io_report(cur->cur_bmp, cur->pre_bmp,
4917836SJohn.Forte@Sun.COM sdbc_getstat(vn));
492*11576SSurya.Prakki@Sun.COM (void) printf("\n");
4937836SJohn.Forte@Sun.COM
4947836SJohn.Forte@Sun.COM if (first) {
495*11576SSurya.Prakki@Sun.COM (void) strcpy(data, strlen(pad) > 0 ? pad : "");
4967836SJohn.Forte@Sun.COM first = 0;
4977836SJohn.Forte@Sun.COM }
4987836SJohn.Forte@Sun.COM }
4997836SJohn.Forte@Sun.COM next:
5007836SJohn.Forte@Sun.COM pre = cur;
5017836SJohn.Forte@Sun.COM cur = cur->next;
5027836SJohn.Forte@Sun.COM }
5037836SJohn.Forte@Sun.COM
5047836SJohn.Forte@Sun.COM return (0);
5057836SJohn.Forte@Sun.COM }
5067836SJohn.Forte@Sun.COM
5077836SJohn.Forte@Sun.COM /*
5087836SJohn.Forte@Sun.COM * sndr_add_stat() - adds a fully populated sndrstat_t structure
5097836SJohn.Forte@Sun.COM * to the linked list of currently monitored kstats. The structure
5107836SJohn.Forte@Sun.COM * will be added in alphabetical order, using the volume name as the
5117836SJohn.Forte@Sun.COM * key.
5127836SJohn.Forte@Sun.COM *
5137836SJohn.Forte@Sun.COM * parameters
5147836SJohn.Forte@Sun.COM * sndrstat_t *sndrstat - to be added to the list.
5157836SJohn.Forte@Sun.COM *
5167836SJohn.Forte@Sun.COM */
5177836SJohn.Forte@Sun.COM void
sndr_add_stat(sndrstat_t * sndrstat)5187836SJohn.Forte@Sun.COM sndr_add_stat(sndrstat_t *sndrstat)
5197836SJohn.Forte@Sun.COM {
5207836SJohn.Forte@Sun.COM
5217836SJohn.Forte@Sun.COM sndrstat_t *cur;
5227836SJohn.Forte@Sun.COM
5237836SJohn.Forte@Sun.COM if (sndr_top == NULL) {
5247836SJohn.Forte@Sun.COM sndr_top = sndrstat;
5257836SJohn.Forte@Sun.COM return;
5267836SJohn.Forte@Sun.COM }
5277836SJohn.Forte@Sun.COM
5287836SJohn.Forte@Sun.COM for (cur = sndr_top; cur != NULL; cur = cur->next) {
5297836SJohn.Forte@Sun.COM char *cur_vname, *nxt_vname, *tst_vname;
5307836SJohn.Forte@Sun.COM
5317836SJohn.Forte@Sun.COM cur_vname = kstat_value(cur->pre_set, RDC_IKSTAT_FILE);
5327836SJohn.Forte@Sun.COM tst_vname = kstat_value(sndrstat->pre_set, RDC_IKSTAT_FILE);
5337836SJohn.Forte@Sun.COM
5347836SJohn.Forte@Sun.COM if (strcmp(cur_vname, tst_vname) <= 0) {
5357836SJohn.Forte@Sun.COM /*
5367836SJohn.Forte@Sun.COM * If we get to the last item in the list, then just
5377836SJohn.Forte@Sun.COM * add this one to the end
5387836SJohn.Forte@Sun.COM */
5397836SJohn.Forte@Sun.COM if (cur->next == NULL) {
5407836SJohn.Forte@Sun.COM cur->next = sndrstat;
5417836SJohn.Forte@Sun.COM return;
5427836SJohn.Forte@Sun.COM }
5437836SJohn.Forte@Sun.COM
5447836SJohn.Forte@Sun.COM nxt_vname = kstat_value(cur->next->pre_set,
5457836SJohn.Forte@Sun.COM RDC_IKSTAT_FILE);
5467836SJohn.Forte@Sun.COM
5477836SJohn.Forte@Sun.COM if (strcmp(nxt_vname, tst_vname) > 0) {
5487836SJohn.Forte@Sun.COM sndrstat->next = cur->next;
5497836SJohn.Forte@Sun.COM cur->next = sndrstat;
5507836SJohn.Forte@Sun.COM return;
5517836SJohn.Forte@Sun.COM }
5527836SJohn.Forte@Sun.COM } else {
5537836SJohn.Forte@Sun.COM if (cur == sndr_top)
5547836SJohn.Forte@Sun.COM sndr_top = sndrstat;
5557836SJohn.Forte@Sun.COM
5567836SJohn.Forte@Sun.COM sndrstat->next = cur;
5577836SJohn.Forte@Sun.COM
5587836SJohn.Forte@Sun.COM return;
5597836SJohn.Forte@Sun.COM }
5607836SJohn.Forte@Sun.COM }
5617836SJohn.Forte@Sun.COM }
5627836SJohn.Forte@Sun.COM
5637836SJohn.Forte@Sun.COM /*
5647836SJohn.Forte@Sun.COM * sndr_del_stat() - deallocate memory for the structure being
5657836SJohn.Forte@Sun.COM * passed in.
5667836SJohn.Forte@Sun.COM *
5677836SJohn.Forte@Sun.COM * parameters
5687836SJohn.Forte@Sun.COM * sndrstat_t *sndrstat - structure to be deallocated
5697836SJohn.Forte@Sun.COM *
5707836SJohn.Forte@Sun.COM * returns
5717836SJohn.Forte@Sun.COM * sndrstat_t * - pointer to the "next" structures in the
5727836SJohn.Forte@Sun.COM * linked list. May be NULL if we are removing the last
5737836SJohn.Forte@Sun.COM * structure in the linked list.
5747836SJohn.Forte@Sun.COM *
5757836SJohn.Forte@Sun.COM */
5767836SJohn.Forte@Sun.COM sndrstat_t *
sndr_del_stat(sndrstat_t * sndrstat)5777836SJohn.Forte@Sun.COM sndr_del_stat(sndrstat_t *sndrstat)
5787836SJohn.Forte@Sun.COM {
5797836SJohn.Forte@Sun.COM
5807836SJohn.Forte@Sun.COM sndrstat_t *next = sndrstat->next;
5817836SJohn.Forte@Sun.COM
5827836SJohn.Forte@Sun.COM kstat_free(sndrstat->pre_set);
5837836SJohn.Forte@Sun.COM kstat_free(sndrstat->pre_bmp);
5847836SJohn.Forte@Sun.COM kstat_free(sndrstat->pre_sec);
5857836SJohn.Forte@Sun.COM kstat_free(sndrstat->cur_set);
5867836SJohn.Forte@Sun.COM kstat_free(sndrstat->cur_bmp);
5877836SJohn.Forte@Sun.COM kstat_free(sndrstat->cur_sec);
5887836SJohn.Forte@Sun.COM
5897836SJohn.Forte@Sun.COM free(sndrstat);
5907836SJohn.Forte@Sun.COM
5917836SJohn.Forte@Sun.COM return (next);
5927836SJohn.Forte@Sun.COM }
5937836SJohn.Forte@Sun.COM
5947836SJohn.Forte@Sun.COM /*
5957836SJohn.Forte@Sun.COM * sndr_value_check() - check to determine if any activity was registered
5967836SJohn.Forte@Sun.COM * on this volume by checking the previous stats vs. the current stats.
5977836SJohn.Forte@Sun.COM *
5987836SJohn.Forte@Sun.COM * parameters
5997836SJohn.Forte@Sun.COM * sndrstat_t *sndrstat - structure to be checked
6007836SJohn.Forte@Sun.COM *
6017836SJohn.Forte@Sun.COM * returns
6027836SJohn.Forte@Sun.COM * 0 - no activity
6037836SJohn.Forte@Sun.COM * 1 - activity
6047836SJohn.Forte@Sun.COM */
6057836SJohn.Forte@Sun.COM int
sndr_value_check(sndrstat_t * sndrstat)6067836SJohn.Forte@Sun.COM sndr_value_check(sndrstat_t *sndrstat)
6077836SJohn.Forte@Sun.COM {
6087836SJohn.Forte@Sun.COM if (SNDR_COMPLETE(sndrstat->collected))
6097836SJohn.Forte@Sun.COM return (1);
6107836SJohn.Forte@Sun.COM
6117836SJohn.Forte@Sun.COM if (io_value_check(sndrstat->pre_bmp->ks_data,
6127836SJohn.Forte@Sun.COM sndrstat->cur_bmp->ks_data)) {
6137836SJohn.Forte@Sun.COM return (1);
6147836SJohn.Forte@Sun.COM }
6157836SJohn.Forte@Sun.COM
6167836SJohn.Forte@Sun.COM if (io_value_check(sndrstat->pre_sec->ks_data,
6177836SJohn.Forte@Sun.COM sndrstat->cur_sec->ks_data)) {
6187836SJohn.Forte@Sun.COM return (1);
6197836SJohn.Forte@Sun.COM }
6207836SJohn.Forte@Sun.COM
6217836SJohn.Forte@Sun.COM return (0);
6227836SJohn.Forte@Sun.COM }
6237836SJohn.Forte@Sun.COM
6247836SJohn.Forte@Sun.COM /*
6257836SJohn.Forte@Sun.COM * sndr_validate() - validates the fields required by dsstat exist in
6267836SJohn.Forte@Sun.COM * the kstat_t structure passed in. This check keeps dsstat from
6277836SJohn.Forte@Sun.COM * core dumping if the kstat_named_t structures change in any of the
6287836SJohn.Forte@Sun.COM * services that dsstat monitors.
6297836SJohn.Forte@Sun.COM *
6307836SJohn.Forte@Sun.COM * paramaters
6317836SJohn.Forte@Sun.COM * kstat_t *ksp - kstat_t structure to check. The ks_data field
6327836SJohn.Forte@Sun.COM * should have been populated with a call to kstat_read()
6337836SJohn.Forte@Sun.COM *
6347836SJohn.Forte@Sun.COM * returns
6357836SJohn.Forte@Sun.COM * 0 - all fields are contained in the kstat
6367836SJohn.Forte@Sun.COM * 1 - a field required by dsstat is not in the kstat
6377836SJohn.Forte@Sun.COM */
6387836SJohn.Forte@Sun.COM int
sndr_validate(kstat_t * ksp)6397836SJohn.Forte@Sun.COM sndr_validate(kstat_t *ksp)
6407836SJohn.Forte@Sun.COM {
6417836SJohn.Forte@Sun.COM if (! kstat_value(ksp, RDC_IKSTAT_FILE) ||
6427836SJohn.Forte@Sun.COM ! kstat_value(ksp, RDC_IKSTAT_FLAGS) ||
6437836SJohn.Forte@Sun.COM ! kstat_value(ksp, RDC_IKSTAT_SYNCFLAGS) ||
6447836SJohn.Forte@Sun.COM ! kstat_value(ksp, RDC_IKSTAT_BMPFLAGS) ||
6457836SJohn.Forte@Sun.COM ! kstat_value(ksp, RDC_IKSTAT_VOLSIZE) ||
6467836SJohn.Forte@Sun.COM ! kstat_value(ksp, RDC_IKSTAT_BITSSET) ||
6477836SJohn.Forte@Sun.COM ! kstat_value(ksp, RDC_IKSTAT_QUEUE_TYPE) ||
6487836SJohn.Forte@Sun.COM ! kstat_value(ksp, RDC_IKSTAT_ASYNC_ITEMS) ||
6497836SJohn.Forte@Sun.COM ! kstat_value(ksp, RDC_IKSTAT_ASYNC_BLOCKS) ||
6507836SJohn.Forte@Sun.COM ! kstat_value(ksp, RDC_IKSTAT_ASYNC_ITEM_HWM) ||
6517836SJohn.Forte@Sun.COM ! kstat_value(ksp, RDC_IKSTAT_ASYNC_BLOCK_HWM))
6527836SJohn.Forte@Sun.COM return (1);
6537836SJohn.Forte@Sun.COM
6547836SJohn.Forte@Sun.COM return (0);
6557836SJohn.Forte@Sun.COM }
6567836SJohn.Forte@Sun.COM
6577836SJohn.Forte@Sun.COM void
getType(kstat_t * ksp,char * vtype)6587836SJohn.Forte@Sun.COM getType(kstat_t *ksp, char *vtype)
6597836SJohn.Forte@Sun.COM {
6607836SJohn.Forte@Sun.COM uint32_t *set_flags;
6617836SJohn.Forte@Sun.COM
6627836SJohn.Forte@Sun.COM set_flags = kstat_value(ksp, RDC_IKSTAT_FLAGS);
6637836SJohn.Forte@Sun.COM
6647836SJohn.Forte@Sun.COM if (*set_flags & RDC_PRIMARY)
6657836SJohn.Forte@Sun.COM (void) strcpy(vtype, "P");
6667836SJohn.Forte@Sun.COM else
6677836SJohn.Forte@Sun.COM (void) strcpy(vtype, "S");
6687836SJohn.Forte@Sun.COM }
6697836SJohn.Forte@Sun.COM
6707836SJohn.Forte@Sun.COM void
getStat(kstat_t * ksp,char * vstat)6717836SJohn.Forte@Sun.COM getStat(kstat_t *ksp, char *vstat)
6727836SJohn.Forte@Sun.COM {
6737836SJohn.Forte@Sun.COM uint32_t *set_flags;
6747836SJohn.Forte@Sun.COM uint32_t *syn_flags;
6757836SJohn.Forte@Sun.COM uint32_t *bmp_flags;
6767836SJohn.Forte@Sun.COM
6777836SJohn.Forte@Sun.COM set_flags = kstat_value(ksp, RDC_IKSTAT_FLAGS);
6787836SJohn.Forte@Sun.COM syn_flags = kstat_value(ksp, RDC_IKSTAT_SYNCFLAGS);
6797836SJohn.Forte@Sun.COM bmp_flags = kstat_value(ksp, RDC_IKSTAT_BMPFLAGS);
6807836SJohn.Forte@Sun.COM
6817836SJohn.Forte@Sun.COM (void) strcpy(vstat, "R");
6827836SJohn.Forte@Sun.COM
6837836SJohn.Forte@Sun.COM if (*set_flags & RDC_SYNCING) {
6847836SJohn.Forte@Sun.COM if (*set_flags & RDC_SLAVE)
6857836SJohn.Forte@Sun.COM if (*set_flags & RDC_PRIMARY)
6867836SJohn.Forte@Sun.COM (void) strcpy(vstat, "RS");
6877836SJohn.Forte@Sun.COM else
6887836SJohn.Forte@Sun.COM (void) strcpy(vstat, "SY");
6897836SJohn.Forte@Sun.COM else
6907836SJohn.Forte@Sun.COM if (*set_flags & RDC_PRIMARY)
6917836SJohn.Forte@Sun.COM (void) strcpy(vstat, "SY");
6927836SJohn.Forte@Sun.COM else
6937836SJohn.Forte@Sun.COM (void) strcpy(vstat, "RS");
6947836SJohn.Forte@Sun.COM }
6957836SJohn.Forte@Sun.COM
6967836SJohn.Forte@Sun.COM if (*set_flags & RDC_LOGGING) {
6977836SJohn.Forte@Sun.COM (void) strcpy(vstat, "L");
6987836SJohn.Forte@Sun.COM
6997836SJohn.Forte@Sun.COM if (*set_flags & RDC_QUEUING)
7007836SJohn.Forte@Sun.COM (void) strcpy(vstat, "Q");
7017836SJohn.Forte@Sun.COM
7027836SJohn.Forte@Sun.COM if (*set_flags & RDC_DISKQ_FAILED)
7037836SJohn.Forte@Sun.COM (void) strcpy(vstat, "QF");
7047836SJohn.Forte@Sun.COM
7057836SJohn.Forte@Sun.COM if (*syn_flags & RDC_SYNC_NEEDED)
7067836SJohn.Forte@Sun.COM (void) strcpy(vstat, "SN");
7077836SJohn.Forte@Sun.COM
7087836SJohn.Forte@Sun.COM if (*syn_flags & RDC_RSYNC_NEEDED)
7097836SJohn.Forte@Sun.COM (void) strcpy(vstat, "RN");
7107836SJohn.Forte@Sun.COM }
7117836SJohn.Forte@Sun.COM
7127836SJohn.Forte@Sun.COM if (*syn_flags & RDC_FCAL_FAILED)
7137836SJohn.Forte@Sun.COM (void) strcpy(vstat, "FF");
7147836SJohn.Forte@Sun.COM
7157836SJohn.Forte@Sun.COM if (*bmp_flags & RDC_BMP_FAILED)
7167836SJohn.Forte@Sun.COM (void) strcpy(vstat, "BF");
7177836SJohn.Forte@Sun.COM
7187836SJohn.Forte@Sun.COM if (*syn_flags & RDC_VOL_FAILED)
7197836SJohn.Forte@Sun.COM (void) strcpy(vstat, "VF");
7207836SJohn.Forte@Sun.COM }
7217836SJohn.Forte@Sun.COM
7227836SJohn.Forte@Sun.COM void
getQueue(kstat_t * ksp,char * vqueue)7237836SJohn.Forte@Sun.COM getQueue(kstat_t *ksp, char *vqueue)
7247836SJohn.Forte@Sun.COM {
7257836SJohn.Forte@Sun.COM char *qtype;
7267836SJohn.Forte@Sun.COM
7277836SJohn.Forte@Sun.COM (void) strcpy(vqueue, "-");
7287836SJohn.Forte@Sun.COM
7297836SJohn.Forte@Sun.COM qtype = kstat_value(ksp, RDC_IKSTAT_QUEUE_TYPE);
7307836SJohn.Forte@Sun.COM
7317836SJohn.Forte@Sun.COM if (strcmp(qtype, "memory") == 0)
7327836SJohn.Forte@Sun.COM (void) strcpy(vqueue, "M");
7337836SJohn.Forte@Sun.COM
7347836SJohn.Forte@Sun.COM if (strcmp(qtype, "disk") == 0)
7357836SJohn.Forte@Sun.COM (void) strcpy(vqueue, "D");
7367836SJohn.Forte@Sun.COM }
7377836SJohn.Forte@Sun.COM
7387836SJohn.Forte@Sun.COM float
getSyncNeeded(kstat_t * ksp)7397836SJohn.Forte@Sun.COM getSyncNeeded(kstat_t *ksp)
7407836SJohn.Forte@Sun.COM {
7417836SJohn.Forte@Sun.COM uint32_t *volsize, *bitsset;
7427836SJohn.Forte@Sun.COM uint32_t bits, segs;
7437836SJohn.Forte@Sun.COM float pct;
7447836SJohn.Forte@Sun.COM
7457836SJohn.Forte@Sun.COM volsize = kstat_value(ksp, RDC_IKSTAT_VOLSIZE);
7467836SJohn.Forte@Sun.COM bitsset = kstat_value(ksp, RDC_IKSTAT_BITSSET);
7477836SJohn.Forte@Sun.COM
7487836SJohn.Forte@Sun.COM segs = FBA_TO_LOG_LEN(*volsize);
7497836SJohn.Forte@Sun.COM bits = *bitsset > 0 ? *bitsset : 0;
7507836SJohn.Forte@Sun.COM
7517836SJohn.Forte@Sun.COM pct = segs ? ((float)bits/(float)segs) : 0.0;
7527836SJohn.Forte@Sun.COM pct *= 100;
7537836SJohn.Forte@Sun.COM
7547836SJohn.Forte@Sun.COM return (pct);
7557836SJohn.Forte@Sun.COM }
7567836SJohn.Forte@Sun.COM
7577836SJohn.Forte@Sun.COM /*
7587836SJohn.Forte@Sun.COM * Special handling for compatibility.
7597836SJohn.Forte@Sun.COM * "dsstat -s <set>" allows set name to be the last 15 chars,
7607836SJohn.Forte@Sun.COM * due to 15 characters limit of old kstat information.
7617836SJohn.Forte@Sun.COM *
7627836SJohn.Forte@Sun.COM * return 0 if:
7637836SJohn.Forte@Sun.COM * 1) full and partial are same
7647836SJohn.Forte@Sun.COM * 2) partial is the last 15 chars of full
7657836SJohn.Forte@Sun.COM */
7667836SJohn.Forte@Sun.COM int
sndr_strcmp(char * full,char * partial)7677836SJohn.Forte@Sun.COM sndr_strcmp(char *full, char *partial)
7687836SJohn.Forte@Sun.COM {
7697836SJohn.Forte@Sun.COM char *f = full;
7707836SJohn.Forte@Sun.COM int rc;
7717836SJohn.Forte@Sun.COM
7727836SJohn.Forte@Sun.COM rc = strcmp(full, partial);
7737836SJohn.Forte@Sun.COM
7747836SJohn.Forte@Sun.COM if (rc != 0 &&
7757836SJohn.Forte@Sun.COM (strlen(partial) == NAMED_LEN) &&
7767836SJohn.Forte@Sun.COM (strlen(full) > NAMED_LEN)) {
7777836SJohn.Forte@Sun.COM f += strlen(full) - NAMED_LEN;
7787836SJohn.Forte@Sun.COM rc = strncmp(f, partial, NAMED_LEN);
7797836SJohn.Forte@Sun.COM }
7807836SJohn.Forte@Sun.COM
7817836SJohn.Forte@Sun.COM return (rc);
7827836SJohn.Forte@Sun.COM }
7837836SJohn.Forte@Sun.COM
7847836SJohn.Forte@Sun.COM int
sndr_vol_selected(kstat_t * ksp)7857836SJohn.Forte@Sun.COM sndr_vol_selected(kstat_t *ksp)
7867836SJohn.Forte@Sun.COM {
7877836SJohn.Forte@Sun.COM vslist_t *vslist = vs_top;
7887836SJohn.Forte@Sun.COM
7897836SJohn.Forte@Sun.COM for (vslist = vs_top; vslist != NULL; vslist = vslist->next) {
7907836SJohn.Forte@Sun.COM char *vn;
7917836SJohn.Forte@Sun.COM char *vh;
7927836SJohn.Forte@Sun.COM
7937836SJohn.Forte@Sun.COM /* If no host specified, check local only */
7947836SJohn.Forte@Sun.COM if (vslist->volhost == NULL) {
7957836SJohn.Forte@Sun.COM vn = kstat_value(ksp, RDC_IKSTAT_FILE);
7967836SJohn.Forte@Sun.COM
7977836SJohn.Forte@Sun.COM if (sndr_strcmp(vn, vslist->volname))
7987836SJohn.Forte@Sun.COM continue;
7997836SJohn.Forte@Sun.COM else
8007836SJohn.Forte@Sun.COM break;
8017836SJohn.Forte@Sun.COM }
8027836SJohn.Forte@Sun.COM
8037836SJohn.Forte@Sun.COM /* Check primary */
8047836SJohn.Forte@Sun.COM vn = kstat_value(ksp, RDC_IKSTAT_FILE);
8057836SJohn.Forte@Sun.COM vh = kstat_value(ksp, RDC_IKSTAT_PRIMARY_HOST);
8067836SJohn.Forte@Sun.COM
8077836SJohn.Forte@Sun.COM if (sndr_strcmp(vn, vslist->volname) == 0 &&
8087836SJohn.Forte@Sun.COM sndr_strcmp(vh, vslist->volhost) == 0)
8097836SJohn.Forte@Sun.COM break;
8107836SJohn.Forte@Sun.COM
8117836SJohn.Forte@Sun.COM /* Check secondary */
8127836SJohn.Forte@Sun.COM vn = kstat_value(ksp, RDC_IKSTAT_SECFILE);
8137836SJohn.Forte@Sun.COM vh = kstat_value(ksp, RDC_IKSTAT_SECONDARY_HOST);
8147836SJohn.Forte@Sun.COM
8157836SJohn.Forte@Sun.COM if (sndr_strcmp(vn, vslist->volname) == 0 &&
8167836SJohn.Forte@Sun.COM sndr_strcmp(vh, vslist->volhost) == 0)
8177836SJohn.Forte@Sun.COM break;
8187836SJohn.Forte@Sun.COM }
8197836SJohn.Forte@Sun.COM
8207836SJohn.Forte@Sun.COM if (vs_top != NULL && vslist == NULL)
8217836SJohn.Forte@Sun.COM return (0);
8227836SJohn.Forte@Sun.COM
8237836SJohn.Forte@Sun.COM return (1);
8247836SJohn.Forte@Sun.COM }
8257836SJohn.Forte@Sun.COM
8267836SJohn.Forte@Sun.COM void
printQueueStats(int first,kstat_t * cur_set)8277836SJohn.Forte@Sun.COM printQueueStats(int first, kstat_t *cur_set)
8287836SJohn.Forte@Sun.COM {
8297836SJohn.Forte@Sun.COM uint32_t *val;
8307836SJohn.Forte@Sun.COM
8317836SJohn.Forte@Sun.COM if (! first) {
8327836SJohn.Forte@Sun.COM /* Filler for async. queue fields */
833*11576SSurya.Prakki@Sun.COM (void) printf(TPS_HDR_FMT, NO_INFO);
834*11576SSurya.Prakki@Sun.COM (void) printf(KPS_HDR_FMT, NO_INFO);
835*11576SSurya.Prakki@Sun.COM (void) printf(TPS_HDR_FMT, NO_INFO);
836*11576SSurya.Prakki@Sun.COM (void) printf(KPS_HDR_FMT, NO_INFO);
8377836SJohn.Forte@Sun.COM
8387836SJohn.Forte@Sun.COM return;
8397836SJohn.Forte@Sun.COM }
8407836SJohn.Forte@Sun.COM
8417836SJohn.Forte@Sun.COM val = (uint32_t *)kstat_value(cur_set, RDC_IKSTAT_ASYNC_ITEMS);
842*11576SSurya.Prakki@Sun.COM (void) printf(TPS_INF_FMT, *val);
8437836SJohn.Forte@Sun.COM
8447836SJohn.Forte@Sun.COM val = (uint32_t *)kstat_value(cur_set, RDC_IKSTAT_ASYNC_BLOCKS);
845*11576SSurya.Prakki@Sun.COM (void) printf(KPS_INF_FMT, (float)(*val / 2));
8467836SJohn.Forte@Sun.COM
8477836SJohn.Forte@Sun.COM val = (uint32_t *)kstat_value(cur_set, RDC_IKSTAT_ASYNC_ITEM_HWM);
848*11576SSurya.Prakki@Sun.COM (void) printf(TPS_INF_FMT, *val);
8497836SJohn.Forte@Sun.COM
8507836SJohn.Forte@Sun.COM val = (uint32_t *)kstat_value(cur_set, RDC_IKSTAT_ASYNC_BLOCK_HWM);
851*11576SSurya.Prakki@Sun.COM (void) printf(KPS_INF_FMT, (float)(*val / 2));
8527836SJohn.Forte@Sun.COM }
853