/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <strings.h>
#include <stdlib.h>
#include <curses.h>
static int rdc_maxsets;
static int rdc_enabled_sets;
#ifdef m88k
extern unsigned *usec_ptr;
#endif
static int bright = 0;
extern int sdbc_max_devices;
extern _sd_stats_t *cs_cur;
extern _sd_stats_t *cs_prev;
extern _sd_stats_t *cs_persec;
extern int *on_off;
extern int *dual_on_off;
extern int *updates_prev;
extern double *rate_prev;
extern int *samples;
int range_num = 0;
int screen = 0;
int dual_screen = 0;
static int rnum = 0;
typedef struct {
} range_t;
extern int range_first();
extern int range_next(int);
extern int range_last();
static int dual_initted = 0;
#ifdef m88k
#else /* !m88k */
static int Usec_started = 0;
void total_display(void);
void disp_stats(void);
void do_calc(void);
void init_dual(void);
void calc_time(void);
void calc_completion(int, int, int);
void disp_total_stats(void);
void display_cache(void);
static void
USEC_START(void)
{
if (!Usec_started) {
Usec_started = 1;
}
}
static unsigned int
{
if (!Usec_started)
USEC_START();
}
#endif /* m88k */
/*
* refresh curses window to file
*/
void
{
int x, y;
if (c != ' ')
*cp++ = c;
}
if (blank)
*cp++ = '\n';
}
if (empty)
/* cp is eliminated by short _maxy and _maxx, it won't overflow */
/* LINTED, cp - buf won't be > INT32_MAX */
}
int
{
int i;
return (i);
}
return (0);
}
int
is_dirty()
{
int i, dirty = 0;
&ustats) == SPCS_S_ERROR) {
perror("Could not get stats from kernel");
if (ustats) {
}
return (-errno);
}
if (cs_cur->st_cachesize == 0)
return (0);
}
return (dirty != 0);
}
void
display_cache(void)
{
SPCS_S_ERROR) {
perror("sd_stats");
if (ustats) {
}
}
do_calc();
if (first) {
first = 0;
} else
disp_stats();
}
void
total_display(void)
{
SPCS_S_ERROR) {
if (ustats) {
}
perror("sd_stats");
}
}
int
{
rnum = 0;
}
int
{
return (cd + 1);
rnum++;
else
return (cd + 1);
}
int
range_last() {
}
void
{
i = range_next(i)) {
ct++;
break;
}
}
if (((i >= rdc_enabled_sets) ||
(i > range_last())) && (dual_screen > 0)) {
dual_screen--;
} else {
for (j = i; j < rdc_enabled_sets && j <= range_last();
j = range_next(j)) {
newct++;
dual_on_off[j] = 1;
} else
break;
}
}
}
}
void
{
ct++;
break;
}
}
if ((i > range_last()) && (screen > 0)) {
screen--;
set_on_off();
} else {
for (j = i; j <= range_last(); j = range_next(j)) {
newct++;
on_off[j] = 1;
else
break;
}
}
}
}
void
disp_stats(void)
{
int len;
if (delta_time != 0) {
} else
if (rtotal != 0)
else
readp = 0.0;
if (wtotal != 0) {
} else
writep = 0.0;
set_on_off();
if (cs_cur->st_cachesize == 0)
else
(void) attron(A_UNDERLINE);
" dirty todisk failed");
(void) attroff(A_UNDERLINE);
if (i >= sdbc_max_devices)
break;
if (!down)
status_bit = '*';
} else
status_bit = ' ';
> 15) {
len - 12);
} else
if (on_off[i]) {
"%3d %-15s%c %6d %6d %6d %6d %6d %6d %6d",
fn,
j++;
}
}
}
(int)rthroughput, (int)throughput,
(void) attron(A_UNDERLINE);
" ");
(void) attroff(A_UNDERLINE);
if (down)
}
void
do_calc(void)
{
int i, j;
if (i >= sdbc_max_devices)
break;
j++;
}
}
}
void
init_dual(void)
{
#define IND_ENABLED 0
dual_initted = 1;
}
int
rdc_get_maxsets(void)
{
int rc;
rdc_status.nset = 0;
ustatus = spcs_s_ucreate();
if (rc == SPCS_S_ERROR)
return (-1);
return (rdc_status.maxsets);
}
int
{
int rdcindex;
float pct;
char *phost;
char *shost;
char *pfile;
char *sfile;
if (rdc_maxsets <= 0)
if (rdc_maxsets < 0)
goto no_stats;
if (!rdc_status) {
if (!rdc_status) {
(void) mvprintw(0, 20,
"****** Dual Copy Not Available ******");
return (-1);
}
}
ustats = spcs_s_ucreate();
if (size == SPCS_S_ERROR) {
if (ustats) {
}
return (-1);
}
if (!dual_initted)
init_dual();
calc_time();
(void) attron(A_UNDERLINE);
(void) attroff(A_UNDERLINE);
continue;
else
ind = IND_LOGGING;
else
ind = IND_RESYNC;
ind = IND_RESYNC;
else
} else
ind = IND_ENABLED;
} else
} else
if (ind == IND_RESYNC_REVERSE) {
} else if (ind == IND_RESYNC) {
} else if (ind == IND_LOGGING)
else if (ind == IND_ENABLED)
} else
} else
k++;
}
k += 5;
(void) attron(A_UNDERLINE);
for (i = 0; i < 80; i++)
(void) mvprintw(k, i, " ");
k += 2;
(void) mvprintw(k, 0, "partition");
(void) attroff(A_UNDERLINE);
k += 2;
continue;
continue;
}
continue;
}
if (len > 15) {
} else
while (stars > 0) {
stars--;
}
else
pct = 0.0;
while (stars > 0) {
stars--;
}
k++;
}
return (0);
}
/*
* Calculate a time interval in milliseconds using the
* micosecond counter
*/
void
calc_time(void)
{
unsigned int cur;
dc_delta_time /= 1000;
dc_prev_time = cur;
}
/*
* Calculate estimated time of completion of resync
*/
void
{
int delta_done;
double rate;
long time_left;
long hours;
long minutes;
static int initted = 0;
if (!initted) {
initted = 1;
return;
}
/*
* Caclulate updates since last check
*/
/*
* If no updates, don't bother estimating completion time
*/
if (delta_done <= 0) {
return;
}
/*
* Calculate rate of updates as a weighted average
* of previous and current rate
*/
/*
* Get enough samples before making estimate
*/
return;
if (time_left < 0)
return;
(void) mvprintw(l, 67,
}
void
disp_total_stats(void)
{
int len;
if (rtotal != 0)
else
readp = 0.0;
if (wtotal != 0)
else
writep = 0.0;
set_on_off();
(void) mvprintw(0, 14,
"****** Storage Cache (Cumulative) ******");
(void) attron(A_UNDERLINE);
" cd cached_partition reads writes reads writes");
(void) attroff(A_UNDERLINE);
if (i >= sdbc_max_devices)
break;
if (!down)
status_bit = '*';
else
status_bit = ' ';
if ((len =
len - 12);
} else
if (on_off[i]) {
"%3d %-15s%c %10u %10u %10u %10u",
fn,
j++;
}
}
}
"---------- ---------- ---------- ----------");
(int)rthroughput, (int)throughput,
(void) attron(A_UNDERLINE);
" ");
(void) attroff(A_UNDERLINE);
(void) mvprintw(10 + j, 0,
(void) attron(A_UNDERLINE);
(void) attroff(A_UNDERLINE);
cs_cur->st_blksize);
(void) attron(A_UNDERLINE);
(void) attroff(A_UNDERLINE);
(void) attron(A_UNDERLINE);
(void) attroff(A_UNDERLINE);
if (down)
}