From owner-p4-projects@FreeBSD.ORG Thu Jul 5 14:31:35 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 972DC16A46B; Thu, 5 Jul 2007 14:31:35 +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 350BB16A468 for ; Thu, 5 Jul 2007 14:31:35 +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 2570113C43E for ; Thu, 5 Jul 2007 14:31:35 +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 l65EVZYC079678 for ; Thu, 5 Jul 2007 14:31:35 GMT (envelope-from lulf@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l65EVYUJ079675 for perforce@freebsd.org; Thu, 5 Jul 2007 14:31:34 GMT (envelope-from lulf@FreeBSD.org) Date: Thu, 5 Jul 2007 14:31:34 GMT Message-Id: <200707051431.l65EVYUJ079675@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 122955 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:31:35 -0000 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); }