diff options
author | grog <grog@FreeBSD.org> | 2000-03-01 07:19:33 +0000 |
---|---|---|
committer | grog <grog@FreeBSD.org> | 2000-03-01 07:19:33 +0000 |
commit | 9301681b2f2fd2daa5e6580a249cc9a524581db2 (patch) | |
tree | 18d95bc8783ce3a72f6b0eb52bc8431beb5d43a9 /sbin/vinum | |
parent | bcb4b1ee2b428810438ee842e3270dee34c8b56c (diff) | |
download | FreeBSD-src-9301681b2f2fd2daa5e6580a249cc9a524581db2.zip FreeBSD-src-9301681b2f2fd2daa5e6580a249cc9a524581db2.tar.gz |
Implement vinum_rebuildparity, which had got forgotten. In the
process, move the body of vinum_rebuildparity and vinum_checkparity to
a new function, parityops.
Implicitly-sanctioned-by: jkh
Diffstat (limited to 'sbin/vinum')
-rw-r--r-- | sbin/vinum/commands.c | 93 |
1 files changed, 58 insertions, 35 deletions
diff --git a/sbin/vinum/commands.c b/sbin/vinum/commands.c index 6c85063..dce2ad7 100644 --- a/sbin/vinum/commands.c +++ b/sbin/vinum/commands.c @@ -2396,58 +2396,81 @@ vinum_setstate(int argc, char *argv[], char *argv0[]) void vinum_checkparity(int argc, char *argv[], char *argv0[]) { + if (argc == 0) /* no parameters? */ + fprintf(stderr, "Usage: checkparity object [object...]\n"); + else + parityops(argc, argv, checkparity); +} + +void +vinum_rebuildparity(int argc, char *argv[], char *argv0[]) +{ + if (argc == 0) /* no parameters? */ + fprintf(stderr, "Usage: rebuildparity object [object...]\n"); + else + parityops(argc, argv, rebuildparity); +} + +void +parityops(int argc, char *argv[], enum parityop op) +{ int object; struct plex plex; struct _ioctl_reply reply; struct vinum_ioctl_msg *message = (struct vinum_ioctl_msg *) &reply; int index; enum objecttype type; + char *msg; - - if (argc == 0) /* no parameters? */ - fprintf(stderr, "Usage: checkparity object [object...]\n"); - else { - for (index = 0; index < argc; index++) { - object = find_object(argv[index], &type); /* look for it */ - if (type != plex_object) - fprintf(stderr, "There is no plex %s\n", argv[index]); + if (op == checkparity) + msg = "Checking"; + else + msg = "Rebuilding"; + for (index = 0; index < argc; index++) { + object = find_object(argv[index], &type); /* look for it */ + if (type != plex_object) + fprintf(stderr, "%s is not a plex\n", argv[index]); + else { + get_plex_info(&plex, object); + if (!isparity((&plex))) + fprintf(stderr, "%s is not a RAID-4 or RAID-5 plex\n", argv[index]); else { - get_plex_info(&plex, object); - if (!isparity((&plex))) - fprintf(stderr, "%s is not a RAID-4 or RAID-5 plex\n", argv[index]); - else { - do { - message->index = object; /* pass object number */ - message->type = type; /* and type of object */ + do { + message->index = object; /* pass object number */ + message->type = type; /* and type of object */ + if (op == checkparity) ioctl(superdev, VINUM_CHECKPARITY, message); - if (vflag) { - get_plex_info(&plex, object); - if (plex.checkblock != 0) - printf("\rChecking at %s ", roughlength(plex.checkblock << DEV_BSHIFT, 1)); - fflush(stdout); - } + else + ioctl(superdev, VINUM_REBUILDPARITY, message); + if (vflag) { + get_plex_info(&plex, object); + if (plex.checkblock != 0) + printf("\r%s at %s ", + msg, + roughlength(plex.checkblock << DEV_BSHIFT, 1)); + fflush(stdout); } - while (reply.error == EAGAIN); - if (reply.error != 0) { - if (reply.msg[0]) - fputs(reply.msg, stderr); - else - fprintf(stderr, - "checkparity failed: %s\n", - strerror(reply.error)); - } else if (vflag) + } + while (reply.error == EAGAIN); + if (reply.error != 0) { + if (reply.msg[0]) + fputs(reply.msg, stderr); + else + fprintf(stderr, + "%s failed: %s\n", + msg, + strerror(reply.error)); + } else if (vflag) { + if (op == checkparity) fprintf(stderr, "%s has correct parity\n", argv[index]); + else + fprintf(stderr, "Rebuilt parity on %s\n", argv[index]); } } } } } -void -vinum_rebuildparity(int argc, char *argv[], char *argv0[]) -{ -} - /* Local Variables: */ /* fill-column: 50 */ /* End: */ |