From owner-p4-projects@FreeBSD.ORG Thu Jul 5 14:33:38 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 969E616A468; Thu, 5 Jul 2007 14:33:38 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6B6EA16A400 for ; Thu, 5 Jul 2007 14:33:38 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 5B3A513C4C3 for ; Thu, 5 Jul 2007 14:33:38 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l65EXcQL079809 for ; Thu, 5 Jul 2007 14:33:38 GMT (envelope-from lulf@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l65EXb2S079806 for perforce@freebsd.org; Thu, 5 Jul 2007 14:33:37 GMT (envelope-from lulf@FreeBSD.org) Date: Thu, 5 Jul 2007 14:33:37 GMT Message-Id: <200707051433.l65EXb2S079806@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to lulf@FreeBSD.org using -f From: Ulf Lilleengen To: Perforce Change Reviews Cc: Subject: PERFORCE change 122956 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jul 2007 14:33:38 -0000 http://perforce.freebsd.org/chv.cgi?CH=122956 Change 122956 by lulf@lulf_carrot on 2007/07/05 14:32:43 - Implement userland part of the raid5 command. Affected files ... .. //depot/projects/soc2007/lulf/gvinum_fixup/sbin/gvinum/gvinum.c#12 edit Differences ... ==== //depot/projects/soc2007/lulf/gvinum_fixup/sbin/gvinum/gvinum.c#12 (text+ko) ==== @@ -65,6 +65,7 @@ void gvinum_mirror(int, char **); void gvinum_parityop(int, char **, int); void gvinum_printconfig(int, char **); +void gvinum_raid5(int, char **); void gvinum_rename(int, char **); void gvinum_resetconfig(void); void gvinum_rm(int, char **); @@ -427,8 +428,8 @@ } /* - * General routine for creating a volume. Mainly for use by concat, mirror and - * stripe commands. + * General routine for creating a volume. Mainly for use by concat, mirror, + * raid5 and stripe commands. */ void create_volume(int argc, char **argv, char *verb) @@ -437,10 +438,13 @@ const char *errstr; char buf[BUFSIZ], *drivename, *volname; int drives, flags, i; + off_t stripesize; flags = 0; drives = 0; volname = NULL; + stripesize = 262144; + /* XXX: Should we check for argument length? */ req = gctl_get_handle(); @@ -455,6 +459,8 @@ flags |= GV_FLAG_V; } else if (!strcmp(argv[i], "-s")) { flags |= GV_FLAG_S; + if (!strcmp(verb, "raid5")) + stripesize = gv_sizespec(argv[++i]); } else { /* Assume it's a drive. */ snprintf(buf, sizeof(buf), "drive%d", drives++); @@ -468,6 +474,8 @@ } } + gctl_ro_param(req, "stripesize", sizeof(off_t), &stripesize); + /* Find a free volume name. */ if (volname == NULL) volname = find_name("gvinumvolume", GV_TYPE_VOL, GV_MAXVOLNAME); @@ -646,6 +654,8 @@ "quit Exit the vinum program when running in interactive mode." " Nor-\n" " mally this would be done by entering the EOF character.\n" + "raid5 [-fv] [-s stripesize] [-n name] drives\n" + " Create a RAID-5 volume from the specified drives.\n" "rename [-r] [drive | subdisk | plex | volume] newname\n" " Change the name of the specified object.\n" "rebuildparity plex [-f]\n" @@ -917,7 +927,20 @@ gctl_free(req); } +/* Create a RAID-5 volume. */ void +gvinum_raid5(int argc, char **argv) +{ + + if (argc < 2) { + warnx("usage:\traid5 [-fv] [-s stripesize] [-n name] drives\n"); + return; + } + create_volume(argc, argv, "raid5"); +} + + +void gvinum_rename(int argc, char **argv) { struct gctl_req *req; @@ -1199,6 +1222,8 @@ gvinum_move(argc, argv); else if (!strcmp(argv[0], "printconfig")) gvinum_printconfig(argc, argv); + else if (!strcmp(argv[0], "raid5")) + gvinum_raid5(argc, argv); else if (!strcmp(argv[0], "rename")) gvinum_rename(argc, argv); else if (!strcmp(argv[0], "resetconfig"))