Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Aug 2005 10:21:43 GMT
From:      soc-cjones <soc-cjones@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 82440 for review
Message-ID:  <200508231021.j7NALhHQ023234@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=82440

Change 82440 by soc-cjones@soc-cjones_ishtar on 2005/08/23 10:21:38

	Yeeeeeehaw!  We've now got moves working, kernel-panic-less, with one exception: the new sd's consumer is set to 0.  Which is, well, wrong.  But this is easily fixable, after I get some sleep.

Affected files ...

.. //depot/projects/soc2005/gvinum/src/sys/geom/vinum/geom_vinum_move.c#11 edit

Differences ...

==== //depot/projects/soc2005/gvinum/src/sys/geom/vinum/geom_vinum_move.c#11 (text+ko) ====

@@ -170,6 +170,7 @@
 	struct gv_sd *newsd, *s, *s2;
 	struct gv_plex *p;
 	struct gv_volume *v;
+	struct g_consumer *cp;
 	char errstr[ERRBUFSIZ];
 
 	printf("gv_move_sd: entering\n");
@@ -235,6 +236,9 @@
 	}
 
 	/* Replace the old sd by the new one. */
+	cp = cursd->consumer;
+	g_detach(cp);
+        printf("gv_move_sd: detached consumer\n");
 	LIST_FOREACH_SAFE(s, &p->subdisks, in_plex, s2) {
 	    printf("gv_move_sd: traversing in_plex list (s: %p, s->name: '%s', s2: %p)\n", s, s->name, s2);
 	    printf("gv_move_sd: for sd '%s', consumer = %p\n", s->name, s->consumer);
@@ -242,7 +246,7 @@
 		    printf("\thit!\n");
 			p->sdcount--;
 			err = gv_rm_sd(sc, req, s, 0);
-			printf("gv_move_sd: removed subdisk\n");
+			printf("gv_move_sd: removed old subdisk\n");
 			if (err) {
 				printf("gv_move_sd: gv_rm_sd = %d\n", err);
 				return err;
@@ -252,24 +256,34 @@
 	}
 	printf("gv_move_sd: completed traversing in_plex\n");
 	gv_sd_to_plex(p, newsd, 1);
-	newsd->flags |= GV_SD_NEWBORN;
+	/* newsd->flags |= GV_SD_NEWBORN; */
 	printf("gv_move_sd: gave sd to plex, set flags\n");
-	gv_drive_modify(d);
+	gv_drive_modify(d); /* Creates the new providers.... */
 	printf("gv_move_sd: gv_drive_modify(d)\n");
-	/* XXX - how to get the consumer set?	s->consumer = g_new_consumer(p->geom); */
-	printf("gv_move_sd: set s->consumer to %p\n", s->consumer);
+	printf("cp=%p, newsd=%p, newsd->provider=%p\n", cp, newsd, newsd->provider);
+	/* And reconnect the consumer ... */
+	err = g_attach(cp, newsd->provider);
+	printf("gv_move_sd: called g_attach(%p, %p) => %d; new consumer %p\n", cp, newsd->provider, err, newsd->consumer);
+	if (err) {
+	    g_destroy_consumer(cp);
+	    gctl_error(req, "proposed move would create a loop in GEOM config");
+	    return err;
+	} else {
+		printf("gv_move_sd: set newsd->consumer to %p\n", newsd->consumer);
+	}
+	printf("gv_move_sd: before LIST_INSERT_HEAD\n");
 	LIST_INSERT_HEAD(&sc->subdisks, newsd, sd);
-	printf("gv_move_sd: inserted sd into subdisks list\n");
+	printf("gv_move_sd: inserted newsd into subdisks list\n");
 
-	LIST_FOREACH(s, &sc->subdisks, sd)
+	/*	LIST_FOREACH(s, &sc->subdisks, sd)
 		gv_update_sd_state(s);
-	printf("gv_move_sd: updated subdisk states\n");
-	LIST_FOREACH(p, &sc->plexes, plex)
+		printf("gv_move_sd: updated subdisk states\n");
+		LIST_FOREACH(p, &sc->plexes, plex)
 		gv_update_plex_config(p);
-	printf("gv_move_sd: updated plex configs\n");
-	LIST_FOREACH(v, &sc->volumes, volume)
+		printf("gv_move_sd: updated plex configs\n");
+		LIST_FOREACH(v, &sc->volumes, volume)
 		gv_update_vol_state(v);
-	printf("gv_move_sd: updated volume states\n");
+		printf("gv_move_sd: updated volume states\n"); */
 
 	gv_save_config_all(sc);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508231021.j7NALhHQ023234>