Date: Thu, 5 Jul 2007 14:31:34 GMT From: Ulf Lilleengen <lulf@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 122955 for review Message-ID: <200707051431.l65EVYUJ079675@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=122955 Change 122955 by lulf@lulf_carrot on 2007/07/05 14:31:21 - Implement raid5 command, which enables easy creation of raid5 volumes. - Remember to setup objects after we have run raid5/mirror/stripe/concat. Affected files ... .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.c#27 edit .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.h#20 edit .. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_create.c#3 edit Differences ... ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.c#27 (text+ko) ==== @@ -444,6 +444,9 @@ } else if (!strcmp(verb, "move")) { gv_move(gp, req); + } else if (!strcmp(verb, "raid5")) { + gv_raid5(gp, req); + } else if (!strcmp(verb, "rebuildparity") || !strcmp(verb, "checkparity")) { gv_parityop(sc, req); ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.h#20 (text+ko) ==== @@ -33,6 +33,7 @@ void gv_concat(struct g_geom *gp, struct gctl_req *); void gv_mirror(struct g_geom *gp, struct gctl_req *); void gv_stripe(struct g_geom *gp, struct gctl_req *); +void gv_raid5(struct g_geom *gp, struct gctl_req *); /* geom_vinum_drive.c */ void gv_save_config(struct gv_softc *); ==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_create.c#3 (text+ko) ==== @@ -100,6 +100,7 @@ s->size = -1; gv_post_event(sc, GV_EVENT_CREATE_SD, s, NULL, 0, 0); } + gv_post_event(sc, GV_EVENT_SETUP_OBJECTS, sc, NULL, 0, 0); gv_post_event(sc, GV_EVENT_SAVE_CONFIG, sc, NULL, 0, 0); } @@ -191,6 +192,83 @@ scount++; } } + gv_post_event(sc, GV_EVENT_SETUP_OBJECTS, sc, NULL, 0, 0); + gv_post_event(sc, GV_EVENT_SAVE_CONFIG, sc, NULL, 0, 0); +} + +void +gv_raid5(struct g_geom *gp, struct gctl_req *req) +{ + struct gv_softc *sc; + struct gv_drive *d; + struct gv_volume *v; + struct gv_plex *p; + struct gv_sd *s; + int *drives, *flags, dcount; + char *vol, *drive, buf[30]; + off_t *stripesize; + + dcount = 0; + sc = gp->softc; + + vol = gctl_get_param(req, "name", NULL); + if (vol == NULL) { + gctl_error(req, "volume's not given"); + return; + } + flags = gctl_get_paraml(req, "flags", sizeof(*flags)); + drives = gctl_get_paraml(req, "drives", sizeof(*drives)); + stripesize = gctl_get_paraml(req, "stripesize", sizeof(*stripesize)); + + if (stripesize == NULL) { + gctl_error(req, "no stripesize given"); + return; + } + + if (drives == NULL) { + gctl_error(req, "drives not given"); + return; + } + + /* We must have at least three drives. */ + if (*drives < 3) { + gctl_error(req, "must have at least three drives for this " + "plex organisation"); + return; + } + /* First we create the volume. */ + v = g_malloc(sizeof(*v), M_WAITOK | M_ZERO); + strlcpy(v->name, vol, GV_MAXVOLNAME); + v->state = GV_VOL_UP; + gv_post_event(sc, GV_EVENT_CREATE_VOLUME, v, NULL, 0, 0); + + /* Then we create the plex. */ + p = g_malloc(sizeof(*p), M_WAITOK | M_ZERO); + snprintf(p->name, sizeof(p->name), "%s.p%d", v->name, v->plexcount); + strlcpy(p->volume, v->name, GV_MAXVOLNAME); + p->org = GV_PLEX_RAID5; + p->stripesize = *stripesize; + gv_post_event(sc, GV_EVENT_CREATE_PLEX, p, NULL, 0, 0); + + /* Create subdisks on drives. */ + for (dcount = 0; dcount < *drives; dcount++) { + snprintf(buf, sizeof(buf), "drive%d", dcount); + drive = gctl_get_param(req, buf, NULL); + d = gv_find_drive(sc, drive); + if (d == NULL) { + gctl_error(req, "No such drive '%s'", drive); + continue; + } + s = g_malloc(sizeof(*s), M_WAITOK | M_ZERO); + snprintf(s->name, sizeof(s->name), "%s.s%d", p->name, dcount); + strlcpy(s->plex, p->name, GV_MAXPLEXNAME); + strlcpy(s->drive, drive, GV_MAXDRIVENAME); + s->plex_offset = -1; + s->drive_offset = -1; + s->size = -1; + gv_post_event(sc, GV_EVENT_CREATE_SD, s, NULL, 0, 0); + } + gv_post_event(sc, GV_EVENT_SETUP_OBJECTS, sc, NULL, 0, 0); gv_post_event(sc, GV_EVENT_SAVE_CONFIG, sc, NULL, 0, 0); } @@ -244,8 +322,7 @@ p->stripesize = 262144; gv_post_event(sc, GV_EVENT_CREATE_PLEX, p, NULL, 0, 0); - /* Drives are first (only right now) priority. We just gives each even - * drive to plex one, and each odd to plex two. */ + /* Create subdisks on drives. */ for (dcount = 0; dcount < *drives; dcount++) { snprintf(buf, sizeof(buf), "drive%d", dcount); drive = gctl_get_param(req, buf, NULL); @@ -263,5 +340,6 @@ s->size = -1; gv_post_event(sc, GV_EVENT_CREATE_SD, s, NULL, 0, 0); } + gv_post_event(sc, GV_EVENT_SETUP_OBJECTS, sc, NULL, 0, 0); gv_post_event(sc, GV_EVENT_SAVE_CONFIG, sc, NULL, 0, 0); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707051431.l65EVYUJ079675>