Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Jun 2007 11:29:27 GMT
From:      Ulf Lilleengen <lulf@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 121907 for review
Message-ID:  <200706181129.l5IBTRPB044118@repoman.freebsd.org>

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

Change 121907 by lulf@lulf_carrot on 2007/06/18 11:28:48

	- Enable gv_start_volume and hook it up into the build.
	- Remove old init/rebuild/sync threads.

Affected files ...

.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.c#17 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_init.c#9 edit

Differences ...

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

@@ -699,7 +699,7 @@
 			case GV_EVENT_START_VOLUME:
 				printf("VINUM: event 'start'\n");
 				v = ev->arg1;
-				/*gv_start_volume(v);*/
+				gv_start_volume(v);
 				break;
 
 			case GV_EVENT_ATTACH_PLEX:

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

@@ -26,7 +26,6 @@
 
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/sys/geom/vinum/geom_vinum_init.c,v 1.11 2005/08/28 18:16:31 le Exp $");
-
 #include <sys/param.h>
 #include <sys/bio.h>
 #include <sys/kernel.h>
@@ -45,13 +44,6 @@
 static int	gv_rebuild_plex(struct gv_plex *);
 static int	gv_init_plex(struct gv_plex *);
 
-struct gv_sync_args {
-	struct gv_volume *v;
-	struct gv_plex *from;
-	struct gv_plex *to;
-	off_t syncsize;
-};
-
 void
 gv_start_obj(struct g_geom *gp, struct gctl_req *req)
 {
@@ -280,279 +272,3 @@
 	}
 	return (0);
 }
-
-#if 0
-/* This thread is responsible for rebuilding a degraded RAID5 plex. */
-void
-gv_rebuild_td(void *arg)
-{
-	struct bio *bp;
-	struct gv_plex *p;
-	struct g_consumer *cp;
-	struct gv_sync_args *sync;
-	u_char *buf;
-	off_t i;
-	int error;
-
-	buf = NULL;
-	bp = NULL;
-
-	sync = arg;
-	p = sync->to;
-	p->synced = 0;
-	cp = p->consumer;
-
-	g_topology_lock();
-	error = g_access(cp, 1, 1, 0);
-	if (error) {
-		g_topology_unlock();
-		printf("GEOM_VINUM: rebuild of %s failed to access consumer: "
-		    "%d\n", p->name, error);
-		kthread_exit(error);
-	}
-	g_topology_unlock();
-
-	buf = g_malloc(sync->syncsize, M_WAITOK);
-
-	printf("GEOM_VINUM: rebuild of %s started\n", p->name);
-	i = 0;
-	for (i = 0; i < p->size; i += (p->stripesize * (p->sdcount - 1))) {
-/*
-		if (i + sync->syncsize > p->size)
-			sync->syncsize = p->size - i;
-*/
-		bp = g_new_bio();
-		if (bp == NULL) {
-			printf("GEOM_VINUM: rebuild of %s failed creating bio: "
-			    "out of memory\n", p->name);
-			break;
-		}
-		bp->bio_cmd = BIO_WRITE;
-		bp->bio_done = NULL;
-		bp->bio_data = buf;
-		bp->bio_cflags |= GV_BIO_REBUILD;
-		bp->bio_offset = i;
-		bp->bio_length = p->stripesize;
-
-		/* Schedule it down ... */
-		g_io_request(bp, cp);
-
-		/* ... and wait for the result. */
-		error = biowait(bp, "gwrite");
-		if (error) {
-			printf("GEOM_VINUM: rebuild of %s failed at offset %jd "
-			    "errno: %d\n", p->name, i, error);
-			break;
-		}
-		g_destroy_bio(bp);
-		bp = NULL;
-	}
-
-	if (bp != NULL)
-		g_destroy_bio(bp);
-	if (buf != NULL)
-		g_free(buf);
-
-	g_topology_lock();
-	g_access(cp, -1, -1, 0);
-	gv_save_config_all(p->vinumconf);
-	g_topology_unlock();
-
-	p->flags &= ~GV_PLEX_SYNCING;
-	p->synced = 0;
-
-	/* Successful initialization. */
-	if (!error)
-		printf("GEOM_VINUM: rebuild of %s finished\n", p->name);
-
-	g_free(sync);
-	kthread_exit(error);
-}
-
-void
-gv_sync_td(void *arg)
-{
-	struct bio *bp;
-	struct gv_plex *p;
-	struct g_consumer *from, *to;
-	struct gv_sync_args *sync;
-	u_char *buf;
-	off_t i;
-	int error;
-
-	sync = arg;
-
-	from = sync->from->consumer;
-	to = sync->to->consumer;
-
-	p = sync->to;
-	p->synced = 0;
-
-	error = 0;
-
-	g_topology_lock();
-	error = g_access(from, 1, 0, 0);
-	if (error) {
-		g_topology_unlock();
-		printf("GEOM_VINUM: sync from '%s' failed to access "
-		    "consumer: %d\n", sync->from->name, error);
-		g_free(sync);
-		kthread_exit(error);
-	}
-	error = g_access(to, 0, 1, 0);
-	if (error) {
-		g_access(from, -1, 0, 0);
-		g_topology_unlock();
-		printf("GEOM_VINUM: sync to '%s' failed to access "
-		    "consumer: %d\n", p->name, error);
-		g_free(sync);
-		kthread_exit(error);
-	}
-	g_topology_unlock();
-
-	printf("GEOM_VINUM: plex sync %s -> %s started\n", sync->from->name,
-	    sync->to->name);
-	for (i = 0; i < p->size; i+= sync->syncsize) {
-		/* Read some bits from the good plex. */
-		buf = g_read_data(from, i, sync->syncsize, &error);
-		if (buf == NULL) {
-			printf("GEOM_VINUM: sync read from '%s' failed at "
-			    "offset %jd; errno: %d\n", sync->from->name, i,
-			    error);
-			break;
-		}
-
-		/*
-		 * Create a bio and schedule it down on the 'bad' plex.  We
-		 * cannot simply use g_write_data() because we have to let the
-		 * lower parts know that we are an initialization process and
-		 * not a 'normal' request.
-		 */
-		bp = g_new_bio();
-		if (bp == NULL) {
-			printf("GEOM_VINUM: sync write to '%s' failed at "
-			    "offset %jd; out of memory\n", p->name, i);
-			g_free(buf);
-			break;
-		}
-		bp->bio_cmd = BIO_WRITE;
-		bp->bio_offset = i;
-		bp->bio_length = sync->syncsize;
-		bp->bio_data = buf;
-		bp->bio_done = NULL;
-
-		/*
-		 * This hack declare this bio as part of an initialization
-		 * process, so that the lower levels allow it to get through.
-		 */
-		bp->bio_cflags |= GV_BIO_SYNCREQ;
-
-		/* Schedule it down ... */
-		g_io_request(bp, to);
-
-		/* ... and wait for the result. */
-		error = biowait(bp, "gwrite");
-		g_destroy_bio(bp);
-		g_free(buf);
-		if (error) {
-			printf("GEOM_VINUM: sync write to '%s' failed at "
-			    "offset %jd; errno: %d\n", p->name, i, error);
-			break;
-		}
-
-		/* Note that we have synced a little bit more. */
-		p->synced += sync->syncsize;
-	}
-
-	g_topology_lock();
-	g_access(from, -1, 0, 0);
-	g_access(to, 0, -1, 0);
-	gv_save_config_all(p->vinumconf);
-	g_topology_unlock();
-
-	/* Successful initialization. */
-	if (!error)
-		printf("GEOM_VINUM: plex sync %s -> %s finished\n",
-		    sync->from->name, sync->to->name);
-
-	p->flags &= ~GV_PLEX_SYNCING;
-	p->synced = 0;
-
-	g_free(sync);
-	kthread_exit(error);
-}
-
-void
-gv_init_td(void *arg)
-{
-	struct gv_sd *s;
-	struct gv_drive *d;
-	struct g_geom *gp;
-	struct g_consumer *cp;
-	int error;
-	off_t i, init_size, start, offset, length;
-	u_char *buf;
-
-	s = arg;
-	KASSERT(s != NULL, ("gv_init_td: NULL s"));
-	d = s->drive_sc;
-	KASSERT(d != NULL, ("gv_init_td: NULL d"));
-	gp = d->geom;
-	KASSERT(gp != NULL, ("gv_init_td: NULL gp"));
-
-	cp = LIST_FIRST(&gp->consumer);
-	KASSERT(cp != NULL, ("gv_init_td: NULL cp"));
-
-	s->init_error = 0;
-	init_size = s->init_size;
-	start = s->drive_offset + s->initialized;
-	offset = s->drive_offset;
-	length = s->size;
-
-	buf = g_malloc(s->init_size, M_WAITOK | M_ZERO);
-
-	g_topology_lock();
-	error = g_access(cp, 0, 1, 0);
-	if (error) {
-		s->init_error = error;
-		g_topology_unlock();
-		printf("GEOM_VINUM: subdisk '%s' init: failed to access "
-		    "consumer; error: %d\n", s->name, error);
-		kthread_exit(error);
-	}
-	g_topology_unlock();
-
-	for (i = start; i < offset + length; i += init_size) {
-		error = g_write_data(cp, i, buf, init_size);
-		if (error) {
-			printf("GEOM_VINUM: subdisk '%s' init: write failed"
-			    " at offset %jd (drive offset %jd); error %d\n",
-			    s->name, (intmax_t)s->initialized, (intmax_t)i,
-			    error);
-			break;
-		}
-		s->initialized += init_size;
-	}
-
-	g_free(buf);
-
-	g_topology_lock();
-	g_access(cp, 0, -1, 0);
-	g_topology_unlock();
-	if (error) {
-		s->init_error = error;
-		g_topology_lock();
-		gv_set_sd_state(s, GV_SD_STALE,
-		    GV_SETSTATE_FORCE | GV_SETSTATE_CONFIG);
-		g_topology_unlock();
-	} else {
-		g_topology_lock();
-		gv_set_sd_state(s, GV_SD_UP, GV_SETSTATE_CONFIG);
-		g_topology_unlock();
-		s->initialized = 0;
-		printf("GEOM_VINUM: subdisk '%s' init: finished successfully\n",
-		    s->name);
-	}
-	kthread_exit(error);
-}
-#endif



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