From owner-p4-projects@FreeBSD.ORG Tue Aug 9 06:01:21 2005 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 51E3316A421; Tue, 9 Aug 2005 06:01:21 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D328916A41F for ; Tue, 9 Aug 2005 06:01:20 +0000 (GMT) (envelope-from soc-cjones@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9824843D53 for ; Tue, 9 Aug 2005 06:01:20 +0000 (GMT) (envelope-from soc-cjones@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j7961Khh089473 for ; Tue, 9 Aug 2005 06:01:20 GMT (envelope-from soc-cjones@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j7961KO7089470 for perforce@freebsd.org; Tue, 9 Aug 2005 06:01:20 GMT (envelope-from soc-cjones@freebsd.org) Date: Tue, 9 Aug 2005 06:01:20 GMT Message-Id: <200508090601.j7961KO7089470@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to soc-cjones@freebsd.org using -f From: soc-cjones To: Perforce Change Reviews Cc: Subject: PERFORCE change 81706 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: Tue, 09 Aug 2005 06:01:22 -0000 http://perforce.freebsd.org/chv.cgi?CH=81706 Change 81706 by soc-cjones@soc-cjones_ishtar on 2005/08/09 06:00:25 First cut at moving subdisks. Let's see whether it works.... Affected files ... .. //depot/projects/soc2005/gvinum/src/sys/geom/vinum/geom_vinum_move.c#4 edit Differences ... ==== //depot/projects/soc2005/gvinum/src/sys/geom/vinum/geom_vinum_move.c#4 (text+ko) ==== @@ -70,6 +70,10 @@ gctl_error(req, "no destination given"); return; } + if (GV_TYPE_DRIVE != gv_object_type(sc, destination)) { + gctl_error(req, "destination is not a drive"); + return; + } for (i = 0; i < *argc; i++) { snprintf(buf, sizeof(buf), "argv%d", i); @@ -84,6 +88,8 @@ gctl_error(req, "unknown volume '%s'", object); return; } + gctl_error(req, "no touching volumes!"); + return 1; err = gv_move_vol(sc, req, v, destination, *flags); if (err) return; @@ -94,6 +100,8 @@ gctl_error(req, "unknown plex '%s'", object); return; } + gctl_error(req, "no touching plexes!"); + return 1; err = gv_move_plex(sc, req, p, destination, *flags); if (err) return; @@ -114,6 +122,8 @@ gctl_error(req, "unknown drive '%s'", object); return; } + gctl_err(req, "no touching drives!"); + return 1; err = gv_move_drive(sc, req, d, destination, *flags); if (err) return; @@ -131,10 +141,11 @@ static int gv_move_vol(struct gv_softc *sc, struct gctl_req *req, struct gv_volume *v, char *destination, int flags) { - int err; - g_topology_assert(); - KASSERT(d != NULL, ("gv_move_vol: NULL v")); + KASSERT(v != NULL, ("gv_move_vol: NULL v")); + + gctl_error(req, "moving a volume makes no sense"); + return 99; } /* Move a plex. */ @@ -144,7 +155,9 @@ int err; g_topology_assert(); - KASSERT(d != NULL, ("gv_move_plex: NULL p")); + KASSERT(p != NULL, ("gv_move_plex: NULL p")); + + /* TODO identify all sds for the plex, then move 'em. */ return (0); } @@ -154,9 +167,65 @@ gv_move_sd(struct gv_softc *sc, struct gctl_req *req, struct gv_sd *s, char *destination, int flags) { int err; - + struct gv_drive *d; + struct gv_sd *s2; + char errstr[ERRBUFSIZ]; + g_topology_assert(); - KASSERT(d != NULL, ("gv_move_sd: NULL s")); + KASSERT(s != NULL, ("gv_move_sd: NULL s")); + + if (!(flags && GV_FLAG_F)) { + gctl_error(req, "-f flag not passed; move would be destructive"); + return 98; + } + + d = gv_find_drive(sc, destination); + if (NULL == d) { + gctl_error(req, "destination drive '%s' not found", destination); + return 97; + } + + if (!strncmp(s->drive, d->name, GV_MAXDRIVENAME)) { + gctl_error(req, "subdisk '%s' already on drive '%s'", s->name, destination); + return 96; + } + + /* Create new sd, set vital stats, and try allocating space + on the new drive. Unfortunately, we can't use gv_new_sd, + since we don't really want to deal with tokenizing stuff. + Oh well. */ + s2 = g_malloc(sizeof(*s2), M_WAITOK | M_ZERO); + printf("A\n"); + snprintf(s2->name, GV_MAXSDNAME, "temp.s0"); /* TODO Come up with temp name. */ + printf("B (s2->name = %s)\n", s2->name); + s2->size = s->size; + printf("C\n"); + s2->drive_sc = d; + s2->drive_offset = -1; + s2->plex_offset = -1; + printf("D\n"); + s2->plex_sc = (struct gv_plex *) NULL; + s2->state = GV_SD_DOWN; + s2->vinumconf = sc; + printf("E\n"); + err = gv_sd_to_drive(sc, d, s2, errstr, sizeof(errstr)); + if (err) { + printf("F errstr = %s\n", errstr); + gctl_error(req, errstr); + g_free(s2); + return err; + } + printf("G\n"); + s2->flags |= GV_SD_NEWBORN; + printf("H\n"); + LIST_INSERT_HEAD(&sc->subdisks, s2, sd); + printf("I\n"); + gv_update_sd_state(s); + printf("J\n"); + gv_save_config_all(sc); + + /* TODO -- move data from old sd to new sd. */ + /* TODO -- delete old sd. */ return (0); } @@ -170,6 +239,8 @@ g_topology_assert(); KASSERT(d != NULL, ("gv_move_drive: NULL d")); + /* TODO find all sds on drive, then move them. */ + return (0); }