Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/raidctl - add '-v' (Verbose) option, which, most notabl...
details: https://anonhg.NetBSD.org/src/rev/ce6dd08a09d0
branches: trunk
changeset: 480135:ce6dd08a09d0
user: oster <oster%NetBSD.org@localhost>
date: Wed Jan 05 03:02:41 2000 +0000
description:
- add '-v' (Verbose) option, which, most notably, provides
a spiffy lukemftp-inspired progress bar for parity re-writing,
reconstructs, copybacks, et al.
- make 'raidctl -P' wait until the parity has been updated before exiting
(it waited previously, but only because the parity re-write ioctl wouldn't
exit until the parity was successfully re-written)
diffstat:
sbin/raidctl/raidctl.8 | 21 ++-
sbin/raidctl/raidctl.c | 361 +++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 339 insertions(+), 43 deletions(-)
diffs (truncated from 544 to 300 lines):
diff -r de3650142bda -r ce6dd08a09d0 sbin/raidctl/raidctl.8
--- a/sbin/raidctl/raidctl.8 Wed Jan 05 02:57:28 2000 +0000
+++ b/sbin/raidctl/raidctl.8 Wed Jan 05 03:02:41 2000 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: raidctl.8,v 1.10 1999/11/19 22:48:02 kristerw Exp $
+.\" $NetBSD: raidctl.8,v 1.11 2000/01/05 03:02:41 oster Exp $
.\"
.\" Copyright (c) 1998 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -68,36 +68,52 @@
.Nd configuration utility for the RAIDframe disk driver
.Sh SYNOPSIS
.Nm ""
+.Op Fl v
.Fl a Ar component Ar dev
.Nm ""
+.Op Fl v
.Fl B Ar dev
.Nm ""
+.Op Fl v
.Fl c Ar config_file Ar dev
.Nm ""
+.Op Fl v
.Fl C Ar config_file Ar dev
.Nm ""
+.Op Fl v
.Fl f Ar component Ar dev
.Nm ""
+.Op Fl v
.Fl F Ar component Ar dev
.Nm ""
+.Op Fl v
.Fl g Ar component Ar dev
.Nm ""
+.Op Fl v
.Fl i Ar dev
.Nm ""
+.Op Fl v
.Fl I Ar serial_number Ar dev
.Nm ""
+.Op Fl v
.Fl p Ar dev
.Nm ""
+.Op Fl v
.Fl P Ar dev
.Nm ""
+.Op Fl v
.Fl r Ar component Ar dev
.Nm ""
+.Op Fl v
.Fl R Ar component Ar dev
.Nm ""
+.Op Fl v
.Fl s Ar dev
.Nm ""
+.Op Fl v
.Fl S Ar dev
.Nm ""
+.Op Fl v
.Fl u Ar dev
.Sh DESCRIPTION
.Nm ""
@@ -191,6 +207,9 @@
the amount of progress achieved in reconstructing a failed component.
.It Fl u Ar dev
Unconfigure the RAIDframe device.
+.It Fl v
+Be more verbose. For operations such as reconstructions, parity
+re-writing, and copybacks, provide a progress indicator.
.El
.Pp
The device used by
diff -r de3650142bda -r ce6dd08a09d0 sbin/raidctl/raidctl.c
--- a/sbin/raidctl/raidctl.c Wed Jan 05 02:57:28 2000 +0000
+++ b/sbin/raidctl/raidctl.c Wed Jan 05 03:02:41 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: raidctl.c,v 1.9 1999/08/15 03:18:19 oster Exp $ */
+/* $NetBSD: raidctl.c,v 1.10 2000/01/05 03:02:41 oster Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -66,7 +66,7 @@
extern char *__progname;
int main __P((int, char *[]));
-static void do_ioctl __P((int, unsigned long, void *, char *));
+void do_ioctl __P((int, unsigned long, void *, char *));
static void rf_configure __P((int, char*, int));
static char *device_status __P((RF_DiskStatus_t));
static void rf_get_device_status __P((int));
@@ -79,6 +79,13 @@
static void add_hot_spare __P((int, char *));
static void remove_hot_spare __P((int, char *));
static void rebuild_in_place __P((int, char *));
+static void check_status __P((int));
+static void check_parity __P((int,int,char *));
+static void do_meter __P((int, int));
+static void get_bar __P((char *, double, int));
+static void get_time_string __P((char *, int));
+
+int verbose = 0;
int
main(argc,argv)
@@ -99,7 +106,6 @@
int is_clean;
int raidID;
int rawpart;
- int recon_percent_done;
int serial_number;
struct stat st;
int fd;
@@ -112,7 +118,7 @@
is_clean = 0;
force = 0;
- while ((ch = getopt(argc, argv, "a:Bc:C:f:F:g:iI:l:r:R:sSpPu")) != -1)
+ while ((ch = getopt(argc, argv, "a:Bc:C:f:F:g:iI:l:r:R:sSpPuv")) != -1)
switch(ch) {
case 'a':
action = RAIDFRAME_ADD_HOT_SPARE;
@@ -181,7 +187,7 @@
num_options++;
break;
case 'S':
- action = RAIDFRAME_CHECKRECON;
+ action = RAIDFRAME_CHECK_RECON_STATUS;
num_options++;
break;
case 'p':
@@ -197,6 +203,12 @@
action = RAIDFRAME_SHUTDOWN;
num_options++;
break;
+ case 'v':
+ verbose = 1;
+ /* Don't bump num_options, as '-v' is not
+ an option like the others */
+ /* num_options++; */
+ break;
default:
usage();
}
@@ -254,6 +266,11 @@
case RAIDFRAME_COPYBACK:
printf("Copyback.\n");
do_ioctl(fd, RAIDFRAME_COPYBACK, NULL, "RAIDFRAME_COPYBACK");
+ if (verbose) {
+ sleep(3); /* XXX give the copyback a chance to start */
+ printf("Copyback status:\n");
+ do_meter(fd,RAIDFRAME_CHECK_COPYBACK_STATUS);
+ }
break;
case RAIDFRAME_FAIL_DISK:
rf_fail_disk(fd,component,do_recon);
@@ -271,12 +288,14 @@
printf("Initiating re-write of parity\n");
do_ioctl(fd, RAIDFRAME_REWRITEPARITY, NULL,
"RAIDFRAME_REWRITEPARITY");
+ if (verbose) {
+ sleep(3); /* XXX give it time to get started */
+ printf("Parity Re-write status:\n");
+ do_meter(fd,RAIDFRAME_CHECK_PARITYREWRITE_STATUS);
+ }
break;
- case RAIDFRAME_CHECKRECON:
- do_ioctl(fd, RAIDFRAME_CHECKRECON, &recon_percent_done,
- "RAIDFRAME_CHECKRECON");
- printf("Reconstruction is %d%% complete.\n",
- recon_percent_done);
+ case RAIDFRAME_CHECK_RECON_STATUS:
+ check_status(fd);
break;
case RAIDFRAME_GET_INFO:
rf_get_device_status(fd);
@@ -285,23 +304,7 @@
rebuild_in_place(fd,component);
break;
case RAIDFRAME_CHECK_PARITY:
- do_ioctl(fd, RAIDFRAME_CHECK_PARITY, &is_clean,
- "RAIDFRAME_CHECK_PARITY");
- if (is_clean) {
- printf("%s: Parity status: clean\n",dev_name);
- } else {
- printf("%s: Parity status: DIRTY\n",dev_name);
- if (do_rewrite) {
- printf("%s: Initiating re-write of parity\n",
- dev_name);
- do_ioctl(fd, RAIDFRAME_REWRITEPARITY, NULL,
- "RAIDFRAME_REWRITEPARITY");
- } else {
- /* parity is wrong, and is not being fixed.
- Exit w/ an error. */
- exit(1);
- }
- }
+ check_parity(fd,do_rewrite,dev_name);
break;
case RAIDFRAME_SHUTDOWN:
do_ioctl(fd, RAIDFRAME_SHUTDOWN, NULL, "RAIDFRAME_SHUTDOWN");
@@ -314,7 +317,7 @@
exit(0);
}
-static void
+void
do_ioctl(fd, command, arg, ioctl_name)
int fd;
unsigned long command;
@@ -323,6 +326,7 @@
{
if (ioctl(fd, command, arg) < 0) {
warn("ioctl (%s) failed", ioctl_name);
+ printf("ioctl (%s) failed", ioctl_name);
exit(1);
}
}
@@ -427,6 +431,7 @@
} else {
printf("Parity status: DIRTY\n");
}
+ check_status(fd);
}
static void
@@ -486,6 +491,11 @@
}
do_ioctl(fd, RAIDFRAME_FAIL_DISK, &recon_request,
"RAIDFRAME_FAIL_DISK");
+ if (do_recon && verbose) {
+ printf("Reconstruction status:\n");
+ sleep(3); /* XXX give reconstruction a chance to start */
+ do_meter(fd,RAIDFRAME_CHECK_RECON_STATUS);
+ }
}
static void
@@ -623,25 +633,292 @@
do_ioctl( fd, RAIDFRAME_REBUILD_IN_PLACE, &comp,
"RAIDFRAME_REBUILD_IN_PLACE");
+
+ if (verbose) {
+ printf("Reconstruction status:\n");
+ sleep(3); /* XXX give reconstruction a chance to start */
+ do_meter(fd,RAIDFRAME_CHECK_RECON_STATUS);
+ }
+
+}
+
+static void
+check_parity( fd, do_rewrite, dev_name )
+ int fd;
+ int do_rewrite;
+ char *dev_name;
+{
+ int is_clean;
+ int percent_done;
+
+ is_clean = 0;
+ percent_done = 0;
+ do_ioctl(fd, RAIDFRAME_CHECK_PARITY, &is_clean,
+ "RAIDFRAME_CHECK_PARITY");
+ if (is_clean) {
+ printf("%s: Parity status: clean\n",dev_name);
+ } else {
+ printf("%s: Parity status: DIRTY\n",dev_name);
+ if (do_rewrite) {
+ printf("%s: Initiating re-write of parity\n",
+ dev_name);
+ do_ioctl(fd, RAIDFRAME_REWRITEPARITY, NULL,
+ "RAIDFRAME_REWRITEPARITY");
+ sleep(3); /* XXX give it time to
+ get started. */
+ if (verbose) {
+ printf("Parity Re-write status:\n");
+ do_meter(fd,
+ RAIDFRAME_CHECK_PARITYREWRITE_STATUS);
+ } else {
+ do_ioctl(fd,
+ RAIDFRAME_CHECK_PARITYREWRITE_STATUS,
+ &percent_done,
+ "RAIDFRAME_CHECK_PARITYREWRITE_STATUS"
+ );
+ while( percent_done < 100 ) {
+ do_ioctl(fd, RAIDFRAME_CHECK_PARITYREWRITE_STATUS,
+ &percent_done, "RAIDFRAME_CHECK_PARITYREWRITE_STATUS");
+ }
+
+ }
+ printf("%s: Parity Re-write complete\n",
+ dev_name);
+ } else {
+ /* parity is wrong, and is not being fixed.
+ Exit w/ an error. */
+ exit(1);
+ }
+ }
+}
+
Home |
Main Index |
Thread Index |
Old Index