PERFORCE change 122861 for review

Ulf Lilleengen lulf at FreeBSD.org
Wed Jul 4 16:45:36 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=122861

Change 122861 by lulf at lulf_carrot on 2007/07/04 16:45:22

	- Use the setstate routines to correctly set the state and give the user
	  notification on what's happening.
	- Remove GV_PLEX_NEWBORN flag when we have configured our plex.
	- Use a GV_EVENT_SETUP_OBJECTS event that is posted after object
	  creation. This might have to be used other places as well, but it
	  seems to be good enough after initial testing.

Affected files ...

.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.c#25 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_events.c#7 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_state.c#16 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_subr.c#16 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_var.h#21 edit

Differences ...

==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.c#25 (text+ko) ====

@@ -389,6 +389,7 @@
 		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);
 
 	return (0);
@@ -559,28 +560,24 @@
 				printf("VINUM: event 'create drive'\n");
 				d = ev->arg1;
 				gv_create_drive(sc, d);
-				gv_setup_objects(sc);
 				break;
 
 			case GV_EVENT_CREATE_VOLUME:
 				printf("VINUM: event 'create volume'\n");
 				v = ev->arg1;
 				gv_create_volume(sc, v);
-				gv_setup_objects(sc);
 				break;
 
 			case GV_EVENT_CREATE_PLEX:
 				printf("VINUM: event 'create plex'\n");
 				p = ev->arg1;
 				gv_create_plex(sc, p);
-				gv_setup_objects(sc);
 				break;
 
 			case GV_EVENT_CREATE_SD:
 				printf("VINUM: event 'create sd'\n");
 				s = ev->arg1;
 				gv_create_sd(sc, s);
-				gv_setup_objects(sc);
 				break;
 
 			case GV_EVENT_RM_DRIVE:
@@ -660,6 +657,11 @@
 					    "state: error code %d\n", err);
 				break;
 
+			case GV_EVENT_SETUP_OBJECTS:
+				printf("VINUM: event 'setup objects'\n");
+				gv_setup_objects(sc);
+				break;
+
 			case GV_EVENT_RESET_CONFIG:
 				printf("VINUM: event 'resetconfig'\n");
 				err = gv_resetconfig(sc);

==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_events.c#7 (text+ko) ====

@@ -348,6 +348,7 @@
 	KASSERT(v != NULL, ("gv_create_volume: NULL v"));
 
 	v->vinumconf = sc;
+	v->flags |= GV_VOL_NEWBORN;
 	LIST_INIT(&v->plexes);
 	LIST_INSERT_HEAD(&sc->volumes, v, volume);
 	v->wqueue = g_malloc(sizeof(struct bio_queue_head), M_WAITOK | M_ZERO);
@@ -369,7 +370,7 @@
 		g_free(p);
 		return;
 	}
-	if (v->plexcount)
+	if (!(v->flags & GV_VOL_NEWBORN))
 		p->flags |= GV_PLEX_ADDED;
 	p->vol_sc = v;
 	v->plexcount++;

==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_state.c#16 (text+ko) ====

@@ -263,8 +263,11 @@
 	}
 
 	/* We can change the state and do it. */
-	if (status == 0)
+	if (status == 0) {
+		printf("Changing state from %s to %s\n", gv_sdstate(s->state),
+		    gv_sdstate(newstate));
 		s->state = newstate;
+	}
 
 	/* Update our plex, if we're attached to one. */
 	if (s->plex_sc != NULL)

==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_subr.c#16 (text+ko) ====

@@ -417,7 +417,7 @@
 
 	/* The plex was added to an already running volume. */
 	if (p->flags & GV_PLEX_ADDED)
-		state = GV_PLEX_DOWN;
+		gv_set_plex_state(p, GV_PLEX_DOWN, GV_SETSTATE_FORCE);
 
 	switch (p->org) {
 	case GV_PLEX_STRIPED:
@@ -434,7 +434,7 @@
 
 	if (required_sds) {
 		if (p->sdcount < required_sds) {
-			state = GV_PLEX_DOWN;
+			gv_set_plex_state(p, GV_PLEX_DOWN, GV_SETSTATE_FORCE);
 		}
 
 		/*
@@ -446,7 +446,8 @@
 				printf("geom_vinum: subdisk size mismatch "
 				    "%s (%jd) <> %s (%jd)\n", s->name, s->size,
 				    s2->name, s2->size);
-				state = GV_PLEX_DOWN;
+				gv_set_plex_state(p, GV_PLEX_DOWN,
+				    GV_SETSTATE_FORCE);
 			}
 		}
 
@@ -465,14 +466,16 @@
 
 	p->size = gv_plex_size(p);
 	if (p->sdcount == 0)
-		state = GV_PLEX_DOWN;
+		gv_set_plex_state(p, GV_PLEX_DOWN, GV_SETSTATE_FORCE);
 	else if ((p->flags & GV_PLEX_ADDED) ||
 	    ((p->org == GV_PLEX_RAID5) && (p->flags & GV_PLEX_NEWBORN))) {
 		LIST_FOREACH(s, &p->subdisks, in_plex)
-			s->state = GV_SD_STALE;
+			gv_set_sd_state(s, GV_SD_STALE, GV_SETSTATE_FORCE);
 		p->flags &= ~GV_PLEX_ADDED;
-		p->state = GV_PLEX_DOWN;
+		gv_set_plex_state(p, GV_PLEX_DOWN, GV_SETSTATE_FORCE);
 	}
+	/* Our plex is grown up now. */
+	p->flags &= ~GV_PLEX_NEWBORN;
 }
 
 /*
@@ -985,6 +988,7 @@
 			v->provider->mediasize = v->size;
 			g_topology_unlock();
 		}
+		v->flags &= ~GV_VOL_NEWBORN;
 		gv_update_vol_state(v);
 	}
 }

==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_var.h#21 (text+ko) ====

@@ -205,6 +205,7 @@
 #define GV_EVENT_RENAME_SD		28
 #define GV_EVENT_RENAME_DRIVE		29
 #define GV_EVENT_MOVE_SD		30
+#define GV_EVENT_SETUP_OBJECTS		31
 
 #ifdef _KERNEL
 struct gv_event {
@@ -366,6 +367,7 @@
 #define	GV_VOL_THREAD_ACTIVE	0x01	/* Volume has an active thread. */
 #define	GV_VOL_THREAD_DIE	0x02	/* Signal the thread to die. */
 #define	GV_VOL_THREAD_DEAD	0x04	/* The thread has died. */
+#define GV_VOL_NEWBORN		0x08	/* The volume was just created. */
 
 	LIST_HEAD(,gv_plex)	plexes;		/* List of attached plexes. */
 	LIST_ENTRY(gv_volume)	volume;		/* Entry in vinum config. */


More information about the p4-projects mailing list