xref: /titanic_44/usr/src/cmd/avs/dsstat/ii_stats.c (revision 570de38f63910201fdd77246630b7aa8f9dc5661)
1fcf3ce44SJohn Forte /*
2fcf3ce44SJohn Forte  * CDDL HEADER START
3fcf3ce44SJohn Forte  *
4fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7fcf3ce44SJohn Forte  *
8fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11fcf3ce44SJohn Forte  * and limitations under the License.
12fcf3ce44SJohn Forte  *
13fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce44SJohn Forte  *
19fcf3ce44SJohn Forte  * CDDL HEADER END
20fcf3ce44SJohn Forte  */
21fcf3ce44SJohn Forte /*
22*570de38fSSurya Prakki  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
23fcf3ce44SJohn Forte  * Use is subject to license terms.
24fcf3ce44SJohn Forte  */
25fcf3ce44SJohn Forte 
26fcf3ce44SJohn Forte #include <stdio.h>
27fcf3ce44SJohn Forte #include <stdlib.h>
28fcf3ce44SJohn Forte #include <string.h>
29fcf3ce44SJohn Forte #include <unistd.h>
30fcf3ce44SJohn Forte #include <errno.h>
31fcf3ce44SJohn Forte 
32fcf3ce44SJohn Forte #include <sys/mutex.h>
33fcf3ce44SJohn Forte 
34fcf3ce44SJohn Forte #include <kstat.h>
35fcf3ce44SJohn Forte 
36fcf3ce44SJohn Forte #include <sys/unistat/spcs_s.h>
37fcf3ce44SJohn Forte #include <sys/nsctl/dsw.h>
38fcf3ce44SJohn Forte #include "../../../uts/common/avs/ns/dsw/dsw_dev.h"
39fcf3ce44SJohn Forte #include <sys/nsctl/dsw_dev.h>
40fcf3ce44SJohn Forte 
41fcf3ce44SJohn Forte #include "sdbc_stats.h"
42fcf3ce44SJohn Forte #include "ii_stats.h"
43fcf3ce44SJohn Forte 
44fcf3ce44SJohn Forte #include "dsstat.h"
45fcf3ce44SJohn Forte #include "common.h"
46fcf3ce44SJohn Forte #include "report.h"
47fcf3ce44SJohn Forte 
48fcf3ce44SJohn Forte static iistat_t *ii_top = NULL;
49fcf3ce44SJohn Forte 
50fcf3ce44SJohn Forte void ii_add_stat(iistat_t *);
51fcf3ce44SJohn Forte iistat_t *ii_del_stat(iistat_t *);
52fcf3ce44SJohn Forte 
53fcf3ce44SJohn Forte int ii_value_check(iistat_t *iistat);
54fcf3ce44SJohn Forte int ii_validate(kstat_t *ksp);
55fcf3ce44SJohn Forte int ii_vol_selected(kstat_t *);
56fcf3ce44SJohn Forte 
57fcf3ce44SJohn Forte /*
58fcf3ce44SJohn Forte  * ii_discover() - looks for new statistics to be monitored.
59fcf3ce44SJohn Forte  * Verifies that any statistics found are now already being
60fcf3ce44SJohn Forte  * monitored.
61fcf3ce44SJohn Forte  *
62fcf3ce44SJohn Forte  */
63fcf3ce44SJohn Forte int
ii_discover(kstat_ctl_t * kc)64fcf3ce44SJohn Forte ii_discover(kstat_ctl_t *kc)
65fcf3ce44SJohn Forte {
66fcf3ce44SJohn Forte 	static int validated = 0;
67fcf3ce44SJohn Forte 
68fcf3ce44SJohn Forte 	kstat_t *ksp;
69fcf3ce44SJohn Forte 
70fcf3ce44SJohn Forte 	/* Loop on all kstats */
71fcf3ce44SJohn Forte 	for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) {
72fcf3ce44SJohn Forte 		char *kname;
73fcf3ce44SJohn Forte 		iistat_t *cur;
74fcf3ce44SJohn Forte 		iistat_t *iistat = NULL;
75fcf3ce44SJohn Forte 		kstat_t *mst_ksp;
76fcf3ce44SJohn Forte 		kstat_t *shd_ksp;
77fcf3ce44SJohn Forte 		kstat_t *bmp_ksp;
78fcf3ce44SJohn Forte 		kstat_t *ovr_ksp;
79fcf3ce44SJohn Forte 
80fcf3ce44SJohn Forte 		/* Search for II set */
81fcf3ce44SJohn Forte 		if (strcmp(ksp->ks_class, II_KSTAT_CLASS) != 0)
82fcf3ce44SJohn Forte 			continue;
83fcf3ce44SJohn Forte 
84fcf3ce44SJohn Forte 		if (kstat_read(kc, ksp, NULL) == -1)
85fcf3ce44SJohn Forte 			continue;
86fcf3ce44SJohn Forte 
87fcf3ce44SJohn Forte 		/*
88fcf3ce44SJohn Forte 		 * Validate kstat structure
89fcf3ce44SJohn Forte 		 */
90fcf3ce44SJohn Forte 		if (! validated) {
91fcf3ce44SJohn Forte 			if (ii_validate(ksp))
92fcf3ce44SJohn Forte 				return (EINVAL);
93fcf3ce44SJohn Forte 
94fcf3ce44SJohn Forte 			validated++;
95fcf3ce44SJohn Forte 		}
96fcf3ce44SJohn Forte 
97fcf3ce44SJohn Forte 		/*
98fcf3ce44SJohn Forte 		 * Duplicate check
99fcf3ce44SJohn Forte 		 */
100fcf3ce44SJohn Forte 		for (cur = ii_top; cur != NULL; cur = cur->next) {
101fcf3ce44SJohn Forte 			char *cur_vname, *tst_vname;
102fcf3ce44SJohn Forte 			uint32_t cur_inst, tst_inst;
103fcf3ce44SJohn Forte 
104fcf3ce44SJohn Forte 			cur_vname = cur->pre_set->ks_name;
105fcf3ce44SJohn Forte 			cur_inst = cur->pre_set->ks_instance;
106fcf3ce44SJohn Forte 
107fcf3ce44SJohn Forte 			tst_vname = ksp->ks_name;
108fcf3ce44SJohn Forte 			tst_inst = ksp->ks_instance;
109fcf3ce44SJohn Forte 
110fcf3ce44SJohn Forte 			if (strcmp(cur_vname, tst_vname) == 0 &&
111fcf3ce44SJohn Forte 			    cur_inst == tst_inst)
112fcf3ce44SJohn Forte 				goto next;
113fcf3ce44SJohn Forte 		}
114fcf3ce44SJohn Forte 
115fcf3ce44SJohn Forte 		/*
116fcf3ce44SJohn Forte 		 * Initialize new record
117fcf3ce44SJohn Forte 		 */
118fcf3ce44SJohn Forte 		iistat = (iistat_t *)calloc(1, sizeof (iistat_t));
119fcf3ce44SJohn Forte 
120fcf3ce44SJohn Forte 		/*
121fcf3ce44SJohn Forte 		 * Set kstat
122fcf3ce44SJohn Forte 		 */
123fcf3ce44SJohn Forte 		iistat->pre_set = kstat_retrieve(kc, ksp);
124fcf3ce44SJohn Forte 
125fcf3ce44SJohn Forte 		if (iistat->pre_set == NULL)
126fcf3ce44SJohn Forte 			goto next;
127fcf3ce44SJohn Forte 
128fcf3ce44SJohn Forte 		iistat->collected |= GOT_SETSTAT;
129fcf3ce44SJohn Forte 
130fcf3ce44SJohn Forte 		/*
131fcf3ce44SJohn Forte 		 * Master kstat
132fcf3ce44SJohn Forte 		 */
133fcf3ce44SJohn Forte 		kname = kstat_value(iistat->pre_set, DSW_SKSTAT_MSTIO);
134fcf3ce44SJohn Forte 
135fcf3ce44SJohn Forte 		mst_ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
136fcf3ce44SJohn Forte 		iistat->pre_mst = kstat_retrieve(kc, mst_ksp);
137fcf3ce44SJohn Forte 
138fcf3ce44SJohn Forte 		if (iistat->pre_mst == NULL)
139fcf3ce44SJohn Forte 			goto next;
140fcf3ce44SJohn Forte 
141fcf3ce44SJohn Forte 		iistat->collected |= GOT_MSTSTAT;
142fcf3ce44SJohn Forte 
143fcf3ce44SJohn Forte 		/*
144fcf3ce44SJohn Forte 		 * Shadow kstat
145fcf3ce44SJohn Forte 		 */
146fcf3ce44SJohn Forte 		kname = kstat_value(iistat->pre_set, DSW_SKSTAT_SHDIO);
147fcf3ce44SJohn Forte 
148fcf3ce44SJohn Forte 		shd_ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
149fcf3ce44SJohn Forte 		iistat->pre_shd = kstat_retrieve(kc, shd_ksp);
150fcf3ce44SJohn Forte 
151fcf3ce44SJohn Forte 		if (iistat->pre_shd == NULL)
152fcf3ce44SJohn Forte 			goto next;
153fcf3ce44SJohn Forte 
154fcf3ce44SJohn Forte 		iistat->collected |= GOT_SHDSTAT;
155fcf3ce44SJohn Forte 
156fcf3ce44SJohn Forte 		/*
157fcf3ce44SJohn Forte 		 * Bitmap kstat
158fcf3ce44SJohn Forte 		 */
159fcf3ce44SJohn Forte 		kname = kstat_value(iistat->pre_set, DSW_SKSTAT_BMPIO);
160fcf3ce44SJohn Forte 
161fcf3ce44SJohn Forte 		bmp_ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
162fcf3ce44SJohn Forte 		iistat->pre_bmp = kstat_retrieve(kc, bmp_ksp);
163fcf3ce44SJohn Forte 
164fcf3ce44SJohn Forte 		if (iistat->pre_bmp == NULL)
165fcf3ce44SJohn Forte 			goto next;
166fcf3ce44SJohn Forte 
167fcf3ce44SJohn Forte 		iistat->collected |= GOT_BMPSTAT;
168fcf3ce44SJohn Forte 
169fcf3ce44SJohn Forte 		/*
170fcf3ce44SJohn Forte 		 * Overflow kstat
171fcf3ce44SJohn Forte 		 */
172fcf3ce44SJohn Forte 		kname = kstat_value(iistat->pre_set, DSW_SKSTAT_OVRIO);
173fcf3ce44SJohn Forte 
174fcf3ce44SJohn Forte 		ovr_ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
175fcf3ce44SJohn Forte 		iistat->pre_ovr = kstat_retrieve(kc, ovr_ksp);
176fcf3ce44SJohn Forte 
177fcf3ce44SJohn Forte 		if (iistat->pre_ovr == NULL)
178fcf3ce44SJohn Forte 			goto next;
179fcf3ce44SJohn Forte 
180fcf3ce44SJohn Forte 		iistat->collected |= GOT_OVRSTAT;
181fcf3ce44SJohn Forte 
182fcf3ce44SJohn Forte next:
183fcf3ce44SJohn Forte 		/*
184fcf3ce44SJohn Forte 		 * Check if we got a complete set of stats
185fcf3ce44SJohn Forte 		 */
186fcf3ce44SJohn Forte 		if (iistat == NULL)
187fcf3ce44SJohn Forte 			continue;
188fcf3ce44SJohn Forte 
189fcf3ce44SJohn Forte 		if (IIMG_COMPLETE(iistat->collected)) {
190fcf3ce44SJohn Forte 			(void) ii_del_stat(iistat);
191fcf3ce44SJohn Forte 			continue;
192fcf3ce44SJohn Forte 		}
193fcf3ce44SJohn Forte 
194fcf3ce44SJohn Forte 		/*
195fcf3ce44SJohn Forte 		 * Add to linked list
196fcf3ce44SJohn Forte 		 */
197fcf3ce44SJohn Forte 		ii_add_stat(iistat);
198fcf3ce44SJohn Forte 	}
199fcf3ce44SJohn Forte 
200fcf3ce44SJohn Forte 	if (ii_top == NULL)
201fcf3ce44SJohn Forte 		return (EAGAIN);
202fcf3ce44SJohn Forte 
203fcf3ce44SJohn Forte 	return (0);
204fcf3ce44SJohn Forte }
205fcf3ce44SJohn Forte 
206fcf3ce44SJohn Forte /*
207fcf3ce44SJohn Forte  * ii_update() - updates all of the statistics currently being monitored.
208fcf3ce44SJohn Forte  *
209fcf3ce44SJohn Forte  */
210fcf3ce44SJohn Forte int
ii_update(kstat_ctl_t * kc)211fcf3ce44SJohn Forte ii_update(kstat_ctl_t *kc)
212fcf3ce44SJohn Forte {
213fcf3ce44SJohn Forte 	iistat_t *cur;
214fcf3ce44SJohn Forte 
215fcf3ce44SJohn Forte 	for (cur = ii_top; cur != NULL; cur = cur->next) {
216fcf3ce44SJohn Forte 		char volname[KSTAT_STRLEN + 1];
217fcf3ce44SJohn Forte 		char *kname;
218fcf3ce44SJohn Forte 
219fcf3ce44SJohn Forte 		kstat_t *ksp = NULL;
220fcf3ce44SJohn Forte 
221fcf3ce44SJohn Forte 		cur->collected = 0;
222fcf3ce44SJohn Forte 
223fcf3ce44SJohn Forte 		/*
224fcf3ce44SJohn Forte 		 * Age off old stats
225fcf3ce44SJohn Forte 		 */
226fcf3ce44SJohn Forte 		if (cur->cur_set != NULL) {
227fcf3ce44SJohn Forte 			kstat_free(cur->pre_set);
228fcf3ce44SJohn Forte 			kstat_free(cur->pre_mst);
229fcf3ce44SJohn Forte 			kstat_free(cur->pre_shd);
230fcf3ce44SJohn Forte 			kstat_free(cur->pre_bmp);
231fcf3ce44SJohn Forte 
232fcf3ce44SJohn Forte 			cur->pre_set = cur->cur_set;
233fcf3ce44SJohn Forte 			cur->pre_mst = cur->cur_mst;
234fcf3ce44SJohn Forte 			cur->pre_shd = cur->cur_shd;
235fcf3ce44SJohn Forte 			cur->pre_bmp = cur->cur_bmp;
236fcf3ce44SJohn Forte 
237fcf3ce44SJohn Forte 			if (cur->cur_ovr != NULL) {
238fcf3ce44SJohn Forte 				kstat_free(cur->pre_ovr);
239fcf3ce44SJohn Forte 				cur->pre_ovr = cur->cur_ovr;
240fcf3ce44SJohn Forte 			}
241fcf3ce44SJohn Forte 		}
242fcf3ce44SJohn Forte 
243fcf3ce44SJohn Forte 		/*
244fcf3ce44SJohn Forte 		 * Set kstat
245fcf3ce44SJohn Forte 		 */
246*570de38fSSurya Prakki 		(void) strncpy(volname, cur->pre_set->ks_name, KSTAT_STRLEN);
247fcf3ce44SJohn Forte 		volname[KSTAT_STRLEN] = '\0';
248fcf3ce44SJohn Forte 
249fcf3ce44SJohn Forte 		ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, volname);
250fcf3ce44SJohn Forte 
251fcf3ce44SJohn Forte 		if ((cur->cur_set = kstat_retrieve(kc, ksp)) == NULL)
252fcf3ce44SJohn Forte 			continue;
253fcf3ce44SJohn Forte 
254fcf3ce44SJohn Forte 		cur->collected |= GOT_SETSTAT;
255fcf3ce44SJohn Forte 
256fcf3ce44SJohn Forte 		/*
257fcf3ce44SJohn Forte 		 * Validate set
258fcf3ce44SJohn Forte 		 */
259fcf3ce44SJohn Forte 		if (strcmp(cur->pre_set->ks_name, cur->cur_set->ks_name) != 0 ||
260fcf3ce44SJohn Forte 		    cur->pre_set->ks_instance != cur->cur_set->ks_instance)
261fcf3ce44SJohn Forte 			continue;
262fcf3ce44SJohn Forte 
263fcf3ce44SJohn Forte 		/*
264fcf3ce44SJohn Forte 		 * Master kstat
265fcf3ce44SJohn Forte 		 */
266fcf3ce44SJohn Forte 		kname = kstat_value(cur->cur_set, DSW_SKSTAT_MSTIO);
267fcf3ce44SJohn Forte 
268fcf3ce44SJohn Forte 		ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
269fcf3ce44SJohn Forte 
270fcf3ce44SJohn Forte 		if ((cur->cur_mst = kstat_retrieve(kc, ksp)) == NULL)
271fcf3ce44SJohn Forte 			continue;
272fcf3ce44SJohn Forte 
273fcf3ce44SJohn Forte 		cur->collected |= GOT_MSTSTAT;
274fcf3ce44SJohn Forte 
275fcf3ce44SJohn Forte 		/*
276fcf3ce44SJohn Forte 		 * Shadow kstat
277fcf3ce44SJohn Forte 		 */
278fcf3ce44SJohn Forte 		kname = kstat_value(cur->cur_set, DSW_SKSTAT_SHDIO);
279fcf3ce44SJohn Forte 
280fcf3ce44SJohn Forte 		ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
281fcf3ce44SJohn Forte 
282fcf3ce44SJohn Forte 		if ((cur->cur_shd = kstat_retrieve(kc, ksp)) == NULL)
283fcf3ce44SJohn Forte 			continue;
284fcf3ce44SJohn Forte 
285fcf3ce44SJohn Forte 		cur->collected |= GOT_SHDSTAT;
286fcf3ce44SJohn Forte 
287fcf3ce44SJohn Forte 		/*
288fcf3ce44SJohn Forte 		 * Bitmap kstat
289fcf3ce44SJohn Forte 		 */
290fcf3ce44SJohn Forte 		kname = kstat_value(cur->pre_set, DSW_SKSTAT_BMPIO);
291fcf3ce44SJohn Forte 
292fcf3ce44SJohn Forte 		ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
293fcf3ce44SJohn Forte 
294fcf3ce44SJohn Forte 		if ((cur->cur_bmp = kstat_retrieve(kc, ksp)) == NULL)
295fcf3ce44SJohn Forte 			continue;
296fcf3ce44SJohn Forte 
297fcf3ce44SJohn Forte 		cur->collected |= GOT_BMPSTAT;
298fcf3ce44SJohn Forte 
299fcf3ce44SJohn Forte 		/*
300fcf3ce44SJohn Forte 		 * Overflow kstat
301fcf3ce44SJohn Forte 		 */
302fcf3ce44SJohn Forte 		kname = kstat_value(cur->cur_set, DSW_SKSTAT_OVRIO);
303fcf3ce44SJohn Forte 
304fcf3ce44SJohn Forte 		ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
305fcf3ce44SJohn Forte 
306fcf3ce44SJohn Forte 		if (ksp == NULL) {
307fcf3ce44SJohn Forte 			if (cur->pre_ovr != NULL) {
308fcf3ce44SJohn Forte 				kstat_free(cur->pre_ovr);
309fcf3ce44SJohn Forte 				cur->pre_ovr = NULL;
310fcf3ce44SJohn Forte 			}
311fcf3ce44SJohn Forte 			if (cur->cur_ovr != NULL) {
312fcf3ce44SJohn Forte 				kstat_free(cur->cur_ovr);
313fcf3ce44SJohn Forte 				cur->cur_ovr = NULL;
314fcf3ce44SJohn Forte 			}
315fcf3ce44SJohn Forte 			continue;
316fcf3ce44SJohn Forte 		}
317fcf3ce44SJohn Forte 
318fcf3ce44SJohn Forte 		if (cur->pre_ovr == NULL) {
319fcf3ce44SJohn Forte 			if ((cur->pre_ovr = kstat_retrieve(kc, ksp)) == NULL)
320fcf3ce44SJohn Forte 				continue;
321fcf3ce44SJohn Forte 		} else {
322fcf3ce44SJohn Forte 			if ((cur->cur_ovr = kstat_retrieve(kc, ksp)) == NULL)
323fcf3ce44SJohn Forte 				continue;
324fcf3ce44SJohn Forte 		}
325fcf3ce44SJohn Forte 
326fcf3ce44SJohn Forte 		cur->collected |= GOT_OVRSTAT;
327fcf3ce44SJohn Forte 	}
328fcf3ce44SJohn Forte 
329fcf3ce44SJohn Forte 	return (0);
330fcf3ce44SJohn Forte }
331fcf3ce44SJohn Forte 
332fcf3ce44SJohn Forte /*
333fcf3ce44SJohn Forte  * ii_report() - outputs statistics for the statistics currently being
334fcf3ce44SJohn Forte  * monitored.  Deletes statistics for volumes that have been disabled.
335fcf3ce44SJohn Forte  *
336fcf3ce44SJohn Forte  */
337fcf3ce44SJohn Forte int
ii_report()338fcf3ce44SJohn Forte ii_report()
339fcf3ce44SJohn Forte {
340fcf3ce44SJohn Forte 	uint32_t *flags;
341fcf3ce44SJohn Forte 	int padsz = 0;
342fcf3ce44SJohn Forte 	char pad[20] = {0};
343fcf3ce44SJohn Forte 	iistat_t *cur, *pre = NULL;
344fcf3ce44SJohn Forte 
345fcf3ce44SJohn Forte 	if (ii_top == NULL) {
346fcf3ce44SJohn Forte 		return (0);
347fcf3ce44SJohn Forte 	}
348fcf3ce44SJohn Forte 
349fcf3ce44SJohn Forte 	/* Create padding string for secondary report lines */
350fcf3ce44SJohn Forte 	if (dflags & FLAGS) {
351fcf3ce44SJohn Forte 		padsz += STAT_HDR_SIZE;
352fcf3ce44SJohn Forte 		padsz += STAT_HDR_SIZE;
353fcf3ce44SJohn Forte 	}
354fcf3ce44SJohn Forte 
355fcf3ce44SJohn Forte 	if (dflags & PCTS)
356fcf3ce44SJohn Forte 		padsz += PCT_HDR_SIZE;
357fcf3ce44SJohn Forte 
358fcf3ce44SJohn Forte 	if (padsz) {
359fcf3ce44SJohn Forte 		char fmt[20];
360*570de38fSSurya Prakki 		(void) sprintf(fmt, "%%%ds", padsz);
361*570de38fSSurya Prakki 		(void) sprintf(pad, fmt, "");
362fcf3ce44SJohn Forte 	}
363fcf3ce44SJohn Forte 
364fcf3ce44SJohn Forte 	for (cur = ii_top; cur; /* CSTYLED */) {
365fcf3ce44SJohn Forte 		int first = 1;
366fcf3ce44SJohn Forte 		char data[20] = {0};
367fcf3ce44SJohn Forte 
368fcf3ce44SJohn Forte 		/* Check to see if this is this a complete */
369fcf3ce44SJohn Forte 		if (IIMG_COMPLETE(cur->collected)) {
370fcf3ce44SJohn Forte 			char *c;
371fcf3ce44SJohn Forte 			char vol[(NAMED_LEN * 4) + 1] = {0};
372fcf3ce44SJohn Forte 			int offset;
373fcf3ce44SJohn Forte 			iistat_t *next;
374fcf3ce44SJohn Forte 
375fcf3ce44SJohn Forte 			/* notify user of set being disabled */
376fcf3ce44SJohn Forte 			c = kstat_value(cur->pre_set, DSW_SKSTAT_SETA);
377*570de38fSSurya Prakki 			(void) strncpy(vol, c, NAMED_LEN);
378fcf3ce44SJohn Forte 			c = kstat_value(cur->pre_set, DSW_SKSTAT_SETB);
379*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
380fcf3ce44SJohn Forte 			c = kstat_value(cur->pre_set, DSW_SKSTAT_SETC);
381*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
382fcf3ce44SJohn Forte 			c = kstat_value(cur->pre_set, DSW_SKSTAT_SETD);
383*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
384fcf3ce44SJohn Forte 
385fcf3ce44SJohn Forte 			offset = strlen(vol) - NAMED_LEN;
386fcf3ce44SJohn Forte 
387fcf3ce44SJohn Forte 			if (offset < 0)
388fcf3ce44SJohn Forte 				offset = 0;
389fcf3ce44SJohn Forte 
390*570de38fSSurya Prakki 			(void) printf(DATA_C16, vol + offset);
391*570de38fSSurya Prakki 			(void) printf(" %s\n", II_DISABLED);
392fcf3ce44SJohn Forte 
393fcf3ce44SJohn Forte 			/* free memory and remove stat from list */
394fcf3ce44SJohn Forte 			next = ii_del_stat(cur);
395fcf3ce44SJohn Forte 
396fcf3ce44SJohn Forte 			if (! pre)
397fcf3ce44SJohn Forte 				cur = ii_top = next;
398fcf3ce44SJohn Forte 			else
399fcf3ce44SJohn Forte 				cur = pre->next = next;
400fcf3ce44SJohn Forte 
401fcf3ce44SJohn Forte 			continue;
402fcf3ce44SJohn Forte 		}
403fcf3ce44SJohn Forte 
404fcf3ce44SJohn Forte 		/* Check to see if the user specified this volume */
405fcf3ce44SJohn Forte 		if (! ii_vol_selected(cur->pre_set))
406fcf3ce44SJohn Forte 			goto next;
407fcf3ce44SJohn Forte 
408fcf3ce44SJohn Forte 		/* Check to see if zflag applies */
409fcf3ce44SJohn Forte 		if (zflag && ii_value_check(cur) == 0)
410fcf3ce44SJohn Forte 			goto next;
411fcf3ce44SJohn Forte 
412fcf3ce44SJohn Forte 		/* Calculate flags */
413fcf3ce44SJohn Forte 		flags = kstat_value(cur->cur_set, DSW_SKSTAT_FLAGS);
414fcf3ce44SJohn Forte 
415fcf3ce44SJohn Forte 		if (dflags & FLAGS) {
416fcf3ce44SJohn Forte 
417fcf3ce44SJohn Forte 			char c[STAT_HDR_SIZE];
418fcf3ce44SJohn Forte 			char vtype[STAT_HDR_SIZE];
419fcf3ce44SJohn Forte 			char vstat[STAT_HDR_SIZE];
420fcf3ce44SJohn Forte 
421fcf3ce44SJohn Forte 			if (*flags & DSW_GOLDEN)
422*570de38fSSurya Prakki 				(void) strcpy(c, II_INDEPENDENT);
423fcf3ce44SJohn Forte 			else
424*570de38fSSurya Prakki 				(void) strcpy(c, II_DEPENDENT);
425fcf3ce44SJohn Forte 
426*570de38fSSurya Prakki 			(void) sprintf(vtype, DATA_C2, c);
427*570de38fSSurya Prakki 			(void) strcat(data, vtype);
428fcf3ce44SJohn Forte 
429fcf3ce44SJohn Forte 			if (*flags & DSW_COPYINGP)
430*570de38fSSurya Prakki 				(void) strcpy(c, II_COPYING);
431fcf3ce44SJohn Forte 			else
432*570de38fSSurya Prakki 				(void) strcpy(c, NO_INFO);
433fcf3ce44SJohn Forte 
434fcf3ce44SJohn Forte 
435*570de38fSSurya Prakki 			(void) sprintf(vstat, DATA_C2, c);
436*570de38fSSurya Prakki 			(void) strcat(data, vstat);
437fcf3ce44SJohn Forte 		}
438fcf3ce44SJohn Forte 
439fcf3ce44SJohn Forte 		/* Calculate sync needed precentage */
440fcf3ce44SJohn Forte 		if (dflags & PCTS) {
441fcf3ce44SJohn Forte 			char snpct[10];
442fcf3ce44SJohn Forte 			uint32_t *chkbits;
443fcf3ce44SJohn Forte 			uint32_t *cpybits;
444fcf3ce44SJohn Forte 			uint32_t *shdbits;
445fcf3ce44SJohn Forte 			uint32_t *volsize;
446fcf3ce44SJohn Forte 			float pct;
447fcf3ce44SJohn Forte 
448fcf3ce44SJohn Forte 			cpybits =
449fcf3ce44SJohn Forte 			    kstat_value(cur->cur_set, DSW_SKSTAT_COPYBITS);
450fcf3ce44SJohn Forte 
451fcf3ce44SJohn Forte 			shdbits =
452fcf3ce44SJohn Forte 			    kstat_value(cur->cur_set, DSW_SKSTAT_SHDBITS);
453fcf3ce44SJohn Forte 
454fcf3ce44SJohn Forte 			volsize =
455fcf3ce44SJohn Forte 			    kstat_value(cur->cur_set, DSW_SKSTAT_SIZE);
456fcf3ce44SJohn Forte 
457fcf3ce44SJohn Forte 			*volsize /= DSW_SIZE;
458fcf3ce44SJohn Forte 
459fcf3ce44SJohn Forte 			chkbits = *cpybits >= *shdbits ? cpybits : shdbits;
460fcf3ce44SJohn Forte 
461fcf3ce44SJohn Forte 			pct = ((float)*chkbits / *volsize) * 100.0;
462fcf3ce44SJohn Forte 
463*570de38fSSurya Prakki 			(void) sprintf(snpct, DATA_F62, pct);
464fcf3ce44SJohn Forte 
465*570de38fSSurya Prakki 			(void) strcat(data, snpct);
466fcf3ce44SJohn Forte 		}
467fcf3ce44SJohn Forte 
468fcf3ce44SJohn Forte 		/* Master statistics */
469fcf3ce44SJohn Forte 		if (rflags & IIMG_MST) {
470fcf3ce44SJohn Forte 			char *c;
471fcf3ce44SJohn Forte 			char vol[(NAMED_LEN * 4) + 1] = {0};
472fcf3ce44SJohn Forte 			int offset;
473fcf3ce44SJohn Forte 
474fcf3ce44SJohn Forte 			c = kstat_value(cur->cur_set, DSW_SKSTAT_MSTA);
475*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
476fcf3ce44SJohn Forte 			c = kstat_value(cur->cur_set, DSW_SKSTAT_MSTB);
477*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
478fcf3ce44SJohn Forte 			c = kstat_value(cur->cur_set, DSW_SKSTAT_MSTC);
479*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
480fcf3ce44SJohn Forte 			c = kstat_value(cur->cur_set, DSW_SKSTAT_MSTD);
481*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
482fcf3ce44SJohn Forte 
483fcf3ce44SJohn Forte 			offset = strlen(vol) - NAMED_LEN;
484fcf3ce44SJohn Forte 
485fcf3ce44SJohn Forte 			if (offset < 0)
486fcf3ce44SJohn Forte 				offset = 0;
487fcf3ce44SJohn Forte 
488fcf3ce44SJohn Forte 			header();
489*570de38fSSurya Prakki 			(void) printf(DATA_C16, vol + offset);
490*570de38fSSurya Prakki 			(void) printf("%s", data);
491*570de38fSSurya Prakki 			(void) printf(ROLE_INF_FMT, II_MASTER);
492fcf3ce44SJohn Forte 
493fcf3ce44SJohn Forte 			if (*flags & DSW_MSTOFFLINE) {
494*570de38fSSurya Prakki 				(void) printf(" <<offline>>");
495fcf3ce44SJohn Forte 				linesout++;
496fcf3ce44SJohn Forte 			} else {
497e31df310SThomas Atkins 				io_report(cur->cur_mst, cur->pre_mst,
498fcf3ce44SJohn Forte 				    sdbc_getstat(vol + offset));
499fcf3ce44SJohn Forte 			}
500fcf3ce44SJohn Forte 
501*570de38fSSurya Prakki 			(void) printf("\n");
502fcf3ce44SJohn Forte 
503fcf3ce44SJohn Forte 			if (first) {
504*570de38fSSurya Prakki 				(void) strcpy(data, strlen(pad) > 0 ? pad : "");
505fcf3ce44SJohn Forte 				first = 0;
506fcf3ce44SJohn Forte 			}
507fcf3ce44SJohn Forte 		}
508fcf3ce44SJohn Forte 
509fcf3ce44SJohn Forte 		/* Shadow statistics */
510fcf3ce44SJohn Forte 		if (rflags & IIMG_SHD) {
511fcf3ce44SJohn Forte 			char *c;
512fcf3ce44SJohn Forte 			char vol[(NAMED_LEN * 4) + 1] = {0};
513fcf3ce44SJohn Forte 			int offset;
514fcf3ce44SJohn Forte 
515fcf3ce44SJohn Forte 			c = kstat_value(cur->cur_set, DSW_SKSTAT_SETA);
516*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
517fcf3ce44SJohn Forte 			c = kstat_value(cur->cur_set, DSW_SKSTAT_SETB);
518*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
519fcf3ce44SJohn Forte 			c = kstat_value(cur->cur_set, DSW_SKSTAT_SETC);
520*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
521fcf3ce44SJohn Forte 			c = kstat_value(cur->cur_set, DSW_SKSTAT_SETD);
522*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
523fcf3ce44SJohn Forte 
524fcf3ce44SJohn Forte 			offset = strlen(vol) - NAMED_LEN;
525fcf3ce44SJohn Forte 
526fcf3ce44SJohn Forte 			if (offset < 0)
527fcf3ce44SJohn Forte 				offset = 0;
528fcf3ce44SJohn Forte 
529fcf3ce44SJohn Forte 			header();
530*570de38fSSurya Prakki 			(void) printf(DATA_C16, vol + offset);
531*570de38fSSurya Prakki 			(void) printf("%s", data);
532*570de38fSSurya Prakki 			(void) printf(ROLE_INF_FMT, II_SHADOW);
533fcf3ce44SJohn Forte 
534fcf3ce44SJohn Forte 			if (*flags & DSW_SHDOFFLINE) {
535*570de38fSSurya Prakki 				(void) printf(" <<offline>>");
536fcf3ce44SJohn Forte 				linesout++;
537fcf3ce44SJohn Forte 			} else {
538e31df310SThomas Atkins 				io_report(cur->cur_shd, cur->pre_shd,
539fcf3ce44SJohn Forte 				    sdbc_getstat(vol + offset));
540fcf3ce44SJohn Forte 			}
541fcf3ce44SJohn Forte 
542*570de38fSSurya Prakki 			(void) printf("\n");
543fcf3ce44SJohn Forte 
544fcf3ce44SJohn Forte 			if (first) {
545*570de38fSSurya Prakki 				(void) strcpy(data, strlen(pad) > 0 ? pad : "");
546fcf3ce44SJohn Forte 				first = 0;
547fcf3ce44SJohn Forte 			}
548fcf3ce44SJohn Forte 		}
549fcf3ce44SJohn Forte 
550fcf3ce44SJohn Forte 		/* Bitmap statistics */
551fcf3ce44SJohn Forte 		if (rflags & IIMG_BMP) {
552fcf3ce44SJohn Forte 			char *c;
553fcf3ce44SJohn Forte 			char vol[(NAMED_LEN * 4) + 1] = {0};
554fcf3ce44SJohn Forte 			int offset;
555fcf3ce44SJohn Forte 
556fcf3ce44SJohn Forte 			c = kstat_value(cur->cur_set, DSW_SKSTAT_BMPA);
557*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
558fcf3ce44SJohn Forte 			c = kstat_value(cur->cur_set, DSW_SKSTAT_BMPB);
559*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
560fcf3ce44SJohn Forte 			c = kstat_value(cur->cur_set, DSW_SKSTAT_BMPC);
561*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
562fcf3ce44SJohn Forte 			c = kstat_value(cur->cur_set, DSW_SKSTAT_BMPD);
563*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
564fcf3ce44SJohn Forte 
565fcf3ce44SJohn Forte 			offset = strlen(vol) - NAMED_LEN;
566fcf3ce44SJohn Forte 
567fcf3ce44SJohn Forte 			if (offset < 0)
568fcf3ce44SJohn Forte 				offset = 0;
569fcf3ce44SJohn Forte 
570fcf3ce44SJohn Forte 			header();
571*570de38fSSurya Prakki 			(void) printf(DATA_C16, vol + offset);
572*570de38fSSurya Prakki 			(void) printf("%s", data);
573*570de38fSSurya Prakki 			(void) printf(ROLE_INF_FMT, II_BITMAP);
574fcf3ce44SJohn Forte 
575fcf3ce44SJohn Forte 			if (*flags & DSW_BMPOFFLINE) {
576*570de38fSSurya Prakki 				(void) printf(" <<offline>>");
577fcf3ce44SJohn Forte 				linesout++;
578fcf3ce44SJohn Forte 			} else {
579e31df310SThomas Atkins 				io_report(cur->cur_bmp, cur->pre_bmp,
580fcf3ce44SJohn Forte 				    sdbc_getstat(vol + offset));
581fcf3ce44SJohn Forte 			}
582*570de38fSSurya Prakki 			(void) printf("\n");
583fcf3ce44SJohn Forte 
584fcf3ce44SJohn Forte 			if (first) {
585*570de38fSSurya Prakki 				(void) strcpy(data, strlen(pad) > 0 ? pad : "");
586fcf3ce44SJohn Forte 				first = 0;
587fcf3ce44SJohn Forte 			}
588fcf3ce44SJohn Forte 		}
589fcf3ce44SJohn Forte 
590fcf3ce44SJohn Forte 		/* Overflow statistics */
591fcf3ce44SJohn Forte 		if (rflags & IIMG_OVR) {
592fcf3ce44SJohn Forte 			char *c;
593fcf3ce44SJohn Forte 			char msg[20] = {0};
594fcf3ce44SJohn Forte 			char vol[(NAMED_LEN * 4) + 1] = {0};
595fcf3ce44SJohn Forte 			int offset;
596fcf3ce44SJohn Forte 
597fcf3ce44SJohn Forte 			if (cur->cur_ovr == NULL && cur->pre_ovr != NULL)
598*570de38fSSurya Prakki 				(void) strcpy(msg, " <<attached>>");
599fcf3ce44SJohn Forte 
600fcf3ce44SJohn Forte 			if (! (cur->collected & GOT_OVRSTAT))
601*570de38fSSurya Prakki 				(void) strcpy(msg, " <<not attached>>");
602fcf3ce44SJohn Forte 
603fcf3ce44SJohn Forte 			c = kstat_value(cur->cur_set, DSW_SKSTAT_OVRA);
604*570de38fSSurya Prakki 			(void) strncpy(vol, c, NAMED_LEN);
605fcf3ce44SJohn Forte 			c = kstat_value(cur->cur_set, DSW_SKSTAT_OVRB);
606*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
607fcf3ce44SJohn Forte 			c = kstat_value(cur->cur_set, DSW_SKSTAT_OVRC);
608*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
609fcf3ce44SJohn Forte 			c = kstat_value(cur->cur_set, DSW_SKSTAT_OVRD);
610*570de38fSSurya Prakki 			(void) strncat(vol, c, NAMED_LEN);
611fcf3ce44SJohn Forte 
612fcf3ce44SJohn Forte 			offset = strlen(vol) - NAMED_LEN;
613fcf3ce44SJohn Forte 
614fcf3ce44SJohn Forte 			if (offset < 0)
615fcf3ce44SJohn Forte 				offset = 0;
616fcf3ce44SJohn Forte 
617fcf3ce44SJohn Forte 			header();
618*570de38fSSurya Prakki 			(void) printf(DATA_C16, vol + offset);
619*570de38fSSurya Prakki 			(void) printf("%s", data);
620*570de38fSSurya Prakki 			(void) printf(ROLE_INF_FMT, II_OVERFLOW);
621fcf3ce44SJohn Forte 
622fcf3ce44SJohn Forte 			if (strlen(msg)) {
623*570de38fSSurya Prakki 				(void) printf("%s\n", msg);
624fcf3ce44SJohn Forte 				linesout++;
625fcf3ce44SJohn Forte 				goto next;
626fcf3ce44SJohn Forte 			}
627fcf3ce44SJohn Forte 
628fcf3ce44SJohn Forte 			if (*flags & DSW_OVROFFLINE) {
629*570de38fSSurya Prakki 				(void) printf(" <<offline>>");
630fcf3ce44SJohn Forte 				linesout++;
631fcf3ce44SJohn Forte 			} else {
632e31df310SThomas Atkins 				io_report(cur->cur_ovr, cur->pre_ovr,
633fcf3ce44SJohn Forte 				    sdbc_getstat(vol + offset));
634fcf3ce44SJohn Forte 			}
635fcf3ce44SJohn Forte 
636*570de38fSSurya Prakki 			(void) printf("\n");
637fcf3ce44SJohn Forte 
638fcf3ce44SJohn Forte 			if (first) {
639*570de38fSSurya Prakki 				(void) strcpy(data, strlen(pad) > 0 ? pad : "");
640fcf3ce44SJohn Forte 				first = 0;
641fcf3ce44SJohn Forte 			}
642fcf3ce44SJohn Forte 		}
643fcf3ce44SJohn Forte 
644fcf3ce44SJohn Forte 
645fcf3ce44SJohn Forte next:
646fcf3ce44SJohn Forte 		pre = cur;
647fcf3ce44SJohn Forte 		cur = cur->next;
648fcf3ce44SJohn Forte 	}
649fcf3ce44SJohn Forte 
650fcf3ce44SJohn Forte 	return (0);
651fcf3ce44SJohn Forte }
652fcf3ce44SJohn Forte 
653fcf3ce44SJohn Forte /*
654fcf3ce44SJohn Forte  * ii_add_stat() - adds a fully populated iistat_t structure
655fcf3ce44SJohn Forte  * to the linked list of currently monitored kstats.  The structure
656fcf3ce44SJohn Forte  * will be added in alphabetical order, using the volume name of
657fcf3ce44SJohn Forte  * the shadow volume as the key.
658fcf3ce44SJohn Forte  *
659fcf3ce44SJohn Forte  */
660fcf3ce44SJohn Forte void
ii_add_stat(iistat_t * iistat)661fcf3ce44SJohn Forte ii_add_stat(iistat_t *iistat)
662fcf3ce44SJohn Forte {
663fcf3ce44SJohn Forte 
664fcf3ce44SJohn Forte 	iistat_t *cur;
665fcf3ce44SJohn Forte 
666fcf3ce44SJohn Forte 	if (ii_top == NULL) {
667fcf3ce44SJohn Forte 		ii_top = iistat;
668fcf3ce44SJohn Forte 		return;
669fcf3ce44SJohn Forte 	}
670fcf3ce44SJohn Forte 
671fcf3ce44SJohn Forte 	for (cur = ii_top; cur != NULL; cur = cur->next) {
672fcf3ce44SJohn Forte 		if (strcmp(cur->pre_set->ks_name,
673fcf3ce44SJohn Forte 		    iistat->pre_set->ks_name) <= 0) {
674fcf3ce44SJohn Forte 			/*
675fcf3ce44SJohn Forte 			 * If we get to the last item in the list, then just
676fcf3ce44SJohn Forte 			 * add this one to the end
677fcf3ce44SJohn Forte 			 */
678fcf3ce44SJohn Forte 			if (cur->next == NULL) {
679fcf3ce44SJohn Forte 				cur->next = iistat;
680fcf3ce44SJohn Forte 				return;
681fcf3ce44SJohn Forte 			}
682fcf3ce44SJohn Forte 
683fcf3ce44SJohn Forte 			if (strcmp(cur->next->pre_set->ks_name,
684fcf3ce44SJohn Forte 			    iistat->pre_set->ks_name) > 0) {
685fcf3ce44SJohn Forte 				iistat->next = cur->next;
686fcf3ce44SJohn Forte 				cur->next = iistat;
687fcf3ce44SJohn Forte 				return;
688fcf3ce44SJohn Forte 			}
689fcf3ce44SJohn Forte 		} else {
690fcf3ce44SJohn Forte 			if (cur == ii_top)
691fcf3ce44SJohn Forte 				ii_top = iistat;
692fcf3ce44SJohn Forte 
693fcf3ce44SJohn Forte 			iistat->next = cur;
694fcf3ce44SJohn Forte 
695fcf3ce44SJohn Forte 			return;
696fcf3ce44SJohn Forte 		}
697fcf3ce44SJohn Forte 	}
698fcf3ce44SJohn Forte }
699fcf3ce44SJohn Forte 
700fcf3ce44SJohn Forte /*
701fcf3ce44SJohn Forte  * ii_del_stat() - deallocate memory for the structure being
702fcf3ce44SJohn Forte  * passed in.
703fcf3ce44SJohn Forte  *
704fcf3ce44SJohn Forte  * parameters
705fcf3ce44SJohn Forte  * 	iistat_t *iistat - structure to be deallocated
706fcf3ce44SJohn Forte  *
707fcf3ce44SJohn Forte  * returns
708fcf3ce44SJohn Forte  * 	iistat_t * - pointer to the "next" structures in the
709fcf3ce44SJohn Forte  * 	linked list. May be NULL if we are removing the last
710fcf3ce44SJohn Forte  * 	structure in the linked list.
711fcf3ce44SJohn Forte  *
712fcf3ce44SJohn Forte  */
713fcf3ce44SJohn Forte iistat_t *
ii_del_stat(iistat_t * iistat)714fcf3ce44SJohn Forte ii_del_stat(iistat_t *iistat)
715fcf3ce44SJohn Forte {
716fcf3ce44SJohn Forte 
717fcf3ce44SJohn Forte 	iistat_t *next = iistat->next;
718fcf3ce44SJohn Forte 
719fcf3ce44SJohn Forte 	kstat_free(iistat->pre_set);
720fcf3ce44SJohn Forte 	kstat_free(iistat->pre_mst);
721fcf3ce44SJohn Forte 	kstat_free(iistat->pre_shd);
722fcf3ce44SJohn Forte 	kstat_free(iistat->pre_bmp);
723fcf3ce44SJohn Forte 	kstat_free(iistat->pre_ovr);
724fcf3ce44SJohn Forte 	kstat_free(iistat->cur_set);
725fcf3ce44SJohn Forte 	kstat_free(iistat->cur_mst);
726fcf3ce44SJohn Forte 	kstat_free(iistat->cur_shd);
727fcf3ce44SJohn Forte 	kstat_free(iistat->cur_bmp);
728fcf3ce44SJohn Forte 	kstat_free(iistat->cur_ovr);
729fcf3ce44SJohn Forte 
730fcf3ce44SJohn Forte 	free(iistat);
731fcf3ce44SJohn Forte 
732fcf3ce44SJohn Forte 	return (next);
733fcf3ce44SJohn Forte }
734fcf3ce44SJohn Forte 
735fcf3ce44SJohn Forte int
ii_value_check(iistat_t * iistat)736fcf3ce44SJohn Forte ii_value_check(iistat_t *iistat)
737fcf3ce44SJohn Forte {
738fcf3ce44SJohn Forte 	if (IIMG_COMPLETE(iistat->collected))
739fcf3ce44SJohn Forte 		return (1);
740fcf3ce44SJohn Forte 
741fcf3ce44SJohn Forte 	if (io_value_check(iistat->pre_mst->ks_data,
742fcf3ce44SJohn Forte 	    iistat->cur_mst->ks_data)) {
743fcf3ce44SJohn Forte 		return (1);
744fcf3ce44SJohn Forte 	}
745fcf3ce44SJohn Forte 
746fcf3ce44SJohn Forte 	if (io_value_check(iistat->pre_shd->ks_data,
747fcf3ce44SJohn Forte 	    iistat->cur_shd->ks_data)) {
748fcf3ce44SJohn Forte 		return (1);
749fcf3ce44SJohn Forte 	}
750fcf3ce44SJohn Forte 
751fcf3ce44SJohn Forte 	if (io_value_check(iistat->pre_bmp->ks_data,
752fcf3ce44SJohn Forte 	    iistat->cur_bmp->ks_data)) {
753fcf3ce44SJohn Forte 		return (1);
754fcf3ce44SJohn Forte 	}
755fcf3ce44SJohn Forte 
756fcf3ce44SJohn Forte 	if (iistat->pre_ovr && iistat->cur_ovr) {
757fcf3ce44SJohn Forte 		if (io_value_check(iistat->pre_ovr->ks_data,
758fcf3ce44SJohn Forte 		    iistat->cur_ovr->ks_data)) {
759fcf3ce44SJohn Forte 			return (1);
760fcf3ce44SJohn Forte 		}
761fcf3ce44SJohn Forte 	}
762fcf3ce44SJohn Forte 
763fcf3ce44SJohn Forte 	return (0);
764fcf3ce44SJohn Forte }
765fcf3ce44SJohn Forte 
766fcf3ce44SJohn Forte int
ii_validate(kstat_t * ksp)767fcf3ce44SJohn Forte ii_validate(kstat_t *ksp)
768fcf3ce44SJohn Forte {
769fcf3ce44SJohn Forte 	if (! kstat_value(ksp, DSW_SKSTAT_MSTIO) ||
770fcf3ce44SJohn Forte 	    ! kstat_value(ksp, DSW_SKSTAT_SHDIO) ||
771fcf3ce44SJohn Forte 	    ! kstat_value(ksp, DSW_SKSTAT_BMPIO) ||
772fcf3ce44SJohn Forte 	    ! kstat_value(ksp, DSW_SKSTAT_OVRIO) ||
773fcf3ce44SJohn Forte 	    ! kstat_value(ksp, DSW_SKSTAT_FLAGS) ||
774fcf3ce44SJohn Forte 	    ! kstat_value(ksp, DSW_SKSTAT_MSTA) ||
775fcf3ce44SJohn Forte 	    ! kstat_value(ksp, DSW_SKSTAT_SETA) ||
776fcf3ce44SJohn Forte 	    ! kstat_value(ksp, DSW_SKSTAT_BMPA) ||
777fcf3ce44SJohn Forte 	    ! kstat_value(ksp, DSW_SKSTAT_OVRA) ||
778fcf3ce44SJohn Forte 	    ! kstat_value(ksp, DSW_SKSTAT_SHDBITS) ||
779fcf3ce44SJohn Forte 	    ! kstat_value(ksp, DSW_SKSTAT_COPYBITS) ||
780fcf3ce44SJohn Forte 	    ! kstat_value(ksp, DSW_SKSTAT_SIZE))
781fcf3ce44SJohn Forte 		return (1);
782fcf3ce44SJohn Forte 
783fcf3ce44SJohn Forte 	return (0);
784fcf3ce44SJohn Forte }
785fcf3ce44SJohn Forte 
786fcf3ce44SJohn Forte int
ii_vol_selected(kstat_t * ksp)787fcf3ce44SJohn Forte ii_vol_selected(kstat_t *ksp)
788fcf3ce44SJohn Forte {
789fcf3ce44SJohn Forte 	vslist_t *vslist = vs_top;
790fcf3ce44SJohn Forte 
791fcf3ce44SJohn Forte 	for (vslist = vs_top; vslist != NULL; vslist = vslist->next) {
792fcf3ce44SJohn Forte 		char *vn;
793fcf3ce44SJohn Forte 		int off = 0;
794fcf3ce44SJohn Forte 
795fcf3ce44SJohn Forte 		vn = ksp->ks_name;
796fcf3ce44SJohn Forte 
797fcf3ce44SJohn Forte 		if ((off = strlen(vn) - NAMED_LEN) <= 0) {
798fcf3ce44SJohn Forte 			off = 0;
799fcf3ce44SJohn Forte 		}
800fcf3ce44SJohn Forte 
801fcf3ce44SJohn Forte 		if (strcmp(vslist->volname, &vn[off]) == 0) {
802fcf3ce44SJohn Forte 			break;
803fcf3ce44SJohn Forte 		}
804fcf3ce44SJohn Forte 	}
805fcf3ce44SJohn Forte 
806fcf3ce44SJohn Forte 	if (vs_top != NULL && vslist == NULL) {
807fcf3ce44SJohn Forte 		return (0);
808fcf3ce44SJohn Forte 	} else {
809fcf3ce44SJohn Forte 		return (1);
810fcf3ce44SJohn Forte 	}
811fcf3ce44SJohn Forte }
812