PERFORCE change 122956 for review
Ulf Lilleengen
lulf at FreeBSD.org
Thu Jul 5 14:33:38 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=122956
Change 122956 by lulf at 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"))
More information about the p4-projects
mailing list