svn commit: r190392 - projects/gvinum/sys/geom/vinum

Ulf Lilleengen lulf at FreeBSD.org
Tue Mar 24 13:46:03 PDT 2009


Author: lulf
Date: Tue Mar 24 20:46:02 2009
New Revision: 190392
URL: http://svn.freebsd.org/changeset/base/190392

Log:
  - Cleanup code before import.
  - Fix comments that had not yet been addressed.

Modified:
  projects/gvinum/sys/geom/vinum/geom_vinum.c
  projects/gvinum/sys/geom/vinum/geom_vinum.h
  projects/gvinum/sys/geom/vinum/geom_vinum_create.c
  projects/gvinum/sys/geom/vinum/geom_vinum_events.c
  projects/gvinum/sys/geom/vinum/geom_vinum_init.c
  projects/gvinum/sys/geom/vinum/geom_vinum_plex.c
  projects/gvinum/sys/geom/vinum/geom_vinum_raid5.c
  projects/gvinum/sys/geom/vinum/geom_vinum_raid5.h
  projects/gvinum/sys/geom/vinum/geom_vinum_rm.c
  projects/gvinum/sys/geom/vinum/geom_vinum_subr.c
  projects/gvinum/sys/geom/vinum/geom_vinum_volume.c

Modified: projects/gvinum/sys/geom/vinum/geom_vinum.c
==============================================================================
--- projects/gvinum/sys/geom/vinum/geom_vinum.c	Tue Mar 24 20:39:08 2009	(r190391)
+++ projects/gvinum/sys/geom/vinum/geom_vinum.c	Tue Mar 24 20:46:02 2009	(r190392)
@@ -1,6 +1,6 @@
 /*-
  *  Copyright (c) 2004, 2007 Lukas Ertl
- *  Copyright (c) 2007 Ulf Lilleengen
+ *  Copyright (c) 2007, 2009 Ulf Lilleengen
  *  All rights reserved.
  * 
  * Redistribution and use in source and binary forms, with or without
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include <geom/geom.h>
 #include <geom/vinum/geom_vinum_var.h>
 #include <geom/vinum/geom_vinum.h>
+#include <geom/vinum/geom_vinum_raid5.h>
 
 SYSCTL_DECL(_kern_geom);
 SYSCTL_NODE(_kern_geom, OID_AUTO, vinum, CTLFLAG_RW, 0, "GEOM_VINUM stuff");
@@ -259,10 +260,6 @@ gv_attach(struct gv_softc *sc, struct gc
 			return;
 		}
 		p = gv_find_plex(sc, parent);
-/*		if (p->org == GV_PLEX_CONCAT) {
-			gctl_error(req, "attach on concat plex not allowed");
-			break;
-		}*/
 		s = gv_find_sd(sc, child);
 		gv_post_event(sc, GV_EVENT_ATTACH_SD, s, p, *offset, *rename);
 		break;

Modified: projects/gvinum/sys/geom/vinum/geom_vinum.h
==============================================================================
--- projects/gvinum/sys/geom/vinum/geom_vinum.h	Tue Mar 24 20:39:08 2009	(r190391)
+++ projects/gvinum/sys/geom/vinum/geom_vinum.h	Tue Mar 24 20:46:02 2009	(r190392)
@@ -34,6 +34,10 @@ void	gv_concat(struct g_geom *gp, struct
 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 *);
+int	gv_create_drive(struct gv_softc *, struct gv_drive *);
+int	gv_create_volume(struct gv_softc *, struct gv_volume *);
+int	gv_create_plex(struct gv_softc *, struct gv_plex *);
+int	gv_create_sd(struct gv_softc *, struct gv_sd *);
 
 /* geom_vinum_drive.c */
 void	gv_save_config(struct gv_softc *);
@@ -84,58 +88,37 @@ void	gv_update_plex_state(struct gv_plex
 void	gv_update_vol_state(struct gv_volume *);
 
 /* geom_vinum_subr.c */
-void	gv_adjust_freespace(struct gv_sd *, off_t);
-void	gv_free_sd(struct gv_sd *);
-struct gv_drive	*gv_find_drive(struct gv_softc *, char *);
-struct gv_drive	*gv_find_drive_device(struct gv_softc *, char *);
-struct gv_plex	*gv_find_plex(struct gv_softc *, char *);
-struct gv_sd	*gv_find_sd(struct gv_softc *, char *);
-struct gv_volume *gv_find_vol(struct gv_softc *, char *);
-void	gv_format_config(struct gv_softc *, struct sbuf *, int, char *);
-int	gv_is_striped(struct gv_plex *);
-int	gv_consumer_is_open(struct g_consumer *);
-int	gv_provider_is_open(struct g_provider *);
-int	gv_object_type(struct gv_softc *, char *);
-void	gv_parse_config(struct gv_softc *, char *, struct gv_drive *);
-int	gv_sd_to_drive(struct gv_sd *, struct gv_drive *);
-int	gv_sd_to_plex(struct gv_sd *, struct gv_plex *);
-int	gv_sdcount(struct gv_plex *, int);
-void	gv_update_plex_config(struct gv_plex *);
-void	gv_update_vol_size(struct gv_volume *, off_t);
-off_t	gv_vol_size(struct gv_volume *);
-off_t	gv_plex_size(struct gv_plex *);
-int	gv_plexdown(struct gv_volume *);
-int	gv_attach_plex(struct gv_plex *, struct gv_volume *, int);
-int	gv_attach_sd(struct gv_sd *, struct gv_plex *, off_t, int);
-int	gv_detach_plex(struct gv_plex *, int);
-int	gv_detach_sd(struct gv_sd *, int);
-
-extern	u_int	g_vinum_debug;
-
-#define	G_VINUM_DEBUG(lvl, ...)	do {					\
-	if (g_vinum_debug >= (lvl)) {					\
-		printf("GEOM_VINUM");					\
-		if (g_vinum_debug > 0)					\
-			printf("[%u]", lvl);				\
-		printf(": ");						\
-		printf(__VA_ARGS__);					\
-		printf("\n");						\
-	}								\
-} while (0)
-
-#define	G_VINUM_LOGREQ(lvl, bp, ...)	do {				\
-	if (g_vinum_debug >= (lvl)) {					\
-		printf("GEOM_VINUM");					\
-		if (g_vinum_debug > 0)					\
-			printf("[%u]", lvl);				\
-		printf(": ");						\
-		printf(__VA_ARGS__);					\
-		printf(" ");						\
-		g_print_bio(bp);					\
-		printf("\n");						\
-	}								\
-} while (0)
+void		 	 gv_adjust_freespace(struct gv_sd *, off_t);
+void		 	 gv_free_sd(struct gv_sd *);
+struct gv_drive		*gv_find_drive(struct gv_softc *, char *);
+struct gv_drive		*gv_find_drive_device(struct gv_softc *, char *);
+struct gv_plex		*gv_find_plex(struct gv_softc *, char *);
+struct gv_sd		*gv_find_sd(struct gv_softc *, char *);
+struct gv_volume	*gv_find_vol(struct gv_softc *, char *);
+void			 gv_format_config(struct gv_softc *, struct sbuf *, int,
+			     char *);
+int			 gv_is_striped(struct gv_plex *);
+int			 gv_consumer_is_open(struct g_consumer *);
+int			 gv_provider_is_open(struct g_provider *);
+int			 gv_object_type(struct gv_softc *, char *);
+void			 gv_parse_config(struct gv_softc *, char *,
+			     struct gv_drive *);
+int			 gv_sd_to_drive(struct gv_sd *, struct gv_drive *);
+int			 gv_sd_to_plex(struct gv_sd *, struct gv_plex *);
+int			 gv_sdcount(struct gv_plex *, int);
+void			 gv_update_plex_config(struct gv_plex *);
+void			 gv_update_vol_size(struct gv_volume *, off_t);
+off_t			 gv_vol_size(struct gv_volume *);
+off_t			 gv_plex_size(struct gv_plex *);
+int			 gv_plexdown(struct gv_volume *);
+int			 gv_attach_plex(struct gv_plex *, struct gv_volume *,
+			     int);
+int			 gv_attach_sd(struct gv_sd *, struct gv_plex *, off_t,
+			     int);
+int			 gv_detach_plex(struct gv_plex *, int);
+int			 gv_detach_sd(struct gv_sd *, int);
 
+/* geom_vinum.c */
 void	gv_worker(void *);
 void	gv_post_event(struct gv_softc *, int, void *, void *, intmax_t,
 	    intmax_t);
@@ -144,18 +127,13 @@ void	gv_drive_lost(struct gv_softc *, st
 void	gv_setup_objects(struct gv_softc *);
 void	gv_start(struct bio *);
 int	gv_access(struct g_provider *, int, int, int);
+void	gv_cleanup(struct gv_softc *);
 
+/* geom_vinum_volume.c */
 void	gv_done(struct bio *);
 void	gv_volume_start(struct gv_softc *, struct bio *);
-
+void	gv_volume_flush(struct gv_volume *);
 void	gv_bio_done(struct gv_softc *, struct bio *);
-void	gv_cleanup(struct gv_softc *);
-int	gv_create_drive(struct gv_softc *, struct gv_drive *);
-int	gv_create_volume(struct gv_softc *, struct gv_volume *);
-int	gv_create_plex(struct gv_softc *, struct gv_plex *);
-int	gv_create_sd(struct gv_softc *, struct gv_sd *);
-
-int	gv_stripe_active(struct gv_plex *, struct bio *);
 
 /* geom_vinum_plex.c */
 void	gv_plex_start(struct gv_plex *, struct bio *);
@@ -172,4 +150,30 @@ int	gv_sync_request(struct gv_plex *, st
 	    caddr_t);
 int	gv_sync_complete(struct gv_plex *, struct bio *);
 
+extern	u_int	g_vinum_debug;
+
+#define	G_VINUM_DEBUG(lvl, ...)	do {					\
+	if (g_vinum_debug >= (lvl)) {					\
+		printf("GEOM_VINUM");					\
+		if (g_vinum_debug > 0)					\
+			printf("[%u]", lvl);				\
+		printf(": ");						\
+		printf(__VA_ARGS__);					\
+		printf("\n");						\
+	}								\
+} while (0)
+
+#define	G_VINUM_LOGREQ(lvl, bp, ...)	do {				\
+	if (g_vinum_debug >= (lvl)) {					\
+		printf("GEOM_VINUM");					\
+		if (g_vinum_debug > 0)					\
+			printf("[%u]", lvl);				\
+		printf(": ");						\
+		printf(__VA_ARGS__);					\
+		printf(" ");						\
+		g_print_bio(bp);					\
+		printf("\n");						\
+	}								\
+} while (0)
+
 #endif /* !_GEOM_VINUM_H_ */

Modified: projects/gvinum/sys/geom/vinum/geom_vinum_create.c
==============================================================================
--- projects/gvinum/sys/geom/vinum/geom_vinum_create.c	Tue Mar 24 20:39:08 2009	(r190391)
+++ projects/gvinum/sys/geom/vinum/geom_vinum_create.c	Tue Mar 24 20:46:02 2009	(r190392)
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2007 Lukas Ertl
- * Copyright (c) 2007 Ulf Lilleengen
+ * Copyright (c) 2007, 2009 Ulf Lilleengen
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -40,6 +40,8 @@
 #include <geom/vinum/geom_vinum_var.h>
 #include <geom/vinum/geom_vinum.h>
 
+#define DEFAULT_STRIPESIZE	262144
+
 /*
  * Create a new drive object, either by user request, during taste of the drive
  * itself, or because it was referenced by a subdisk during taste.
@@ -269,13 +271,6 @@ gv_create_sd(struct gv_softc *sc, struct
 		return (GV_ERR_CREATE);
 	}
 
-/*	if (p->org == GV_PLEX_RAID5 && p->state == GV_PLEX_DEGRADED) {
-		printf("VINUM: can't add subdisk to %s, rebuild plex before "
-		    " adding subdisks\n", p->name);
-		g_free(s);
-		return (0);
-	}*/
-
 	/*
 	 * First we give the subdisk to the drive, to handle autosized
 	 * values ...
@@ -290,7 +285,7 @@ gv_create_sd(struct gv_softc *sc, struct
 	 * given values are correct and maybe adjust them.
 	 */
 	if (gv_sd_to_plex(s, p) != 0) {
-		G_VINUM_DEBUG(0, "couldn't give sd '%s' to plex '%s'",
+		G_VINUM_DEBUG(0, "unable to give sd '%s' to plex '%s'",
 		    s->name, p->name);
 		if (s->drive_sc && !(s->drive_sc->flags & GV_DRIVE_REFERENCED))
 			LIST_REMOVE(s, from_drive);
@@ -331,7 +326,7 @@ gv_concat(struct g_geom *gp, struct gctl
 	dcount = 0;
 	vol = gctl_get_param(req, "name", NULL);
 	if (vol == NULL) {
-		gctl_error(req, "volume's not given");	
+		gctl_error(req, "volume names not given");	
 		return;
 	}
 
@@ -339,7 +334,7 @@ gv_concat(struct g_geom *gp, struct gctl
 	drives = gctl_get_paraml(req, "drives", sizeof(*drives));
 
 	if (drives == NULL) { 
-		gctl_error(req, "drives not given");
+		gctl_error(req, "drive names not given");
 		return;
 	}
 
@@ -413,7 +408,8 @@ gv_mirror(struct g_geom *gp, struct gctl
 
 	/* We must have an even number of drives. */
 	if (*drives % 2 != 0) {
-		gctl_error(req, "must have an even number of drives");
+		gctl_error(req, "mirror organization must have an even number "
+		    "of drives");
 		return;
 	}
 	if (*flags & GV_FLAG_S && *drives < 4) {
@@ -435,25 +431,27 @@ gv_mirror(struct g_geom *gp, struct gctl
 		strlcpy(p->volume, v->name, sizeof(p->volume));
 		if (*flags & GV_FLAG_S) {
 			p->org = GV_PLEX_STRIPED;
-			p->stripesize = 262144; /*XXX: DFLT_STRIPESIZE? */
+			p->stripesize = DEFAULT_STRIPESIZE;
 		} else {
 			p->org = GV_PLEX_CONCAT;
 			p->stripesize = -1;
 		}
 		gv_post_event(sc, GV_EVENT_CREATE_PLEX, p, NULL, 0, 0);
 
-		/* We just gives each even drive to plex one, and each odd to
-		 * plex two. */
+		/*
+		 * We just gives each even drive to plex one, and each odd to
+		 * plex two.
+		 */
 		scount = 0;
 		for (dcount = pcount; dcount < *drives; dcount += 2) {
 			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);
-				/* XXX: Should we fail instead? */
+				gctl_error(req, "No such drive '%s', aborting",
+				    drive);
 				scount++;
-				continue;
+				break;
 			}
 			s = g_malloc(sizeof(*s), M_WAITOK | M_ZERO);
 			snprintf(s->name, sizeof(s->name), "%s.s%d", p->name,

Modified: projects/gvinum/sys/geom/vinum/geom_vinum_events.c
==============================================================================
--- projects/gvinum/sys/geom/vinum/geom_vinum_events.c	Tue Mar 24 20:39:08 2009	(r190391)
+++ projects/gvinum/sys/geom/vinum/geom_vinum_events.c	Tue Mar 24 20:46:02 2009	(r190392)
@@ -136,8 +136,6 @@ gv_drive_tasted(struct gv_softc *sc, str
 	gv_setup_objects(sc);
 	gv_set_drive_state(d, GV_DRIVE_UP, 0);
 
-	/* XXX continue here! */
-
 	return;
 
 failed:

Modified: projects/gvinum/sys/geom/vinum/geom_vinum_init.c
==============================================================================
--- projects/gvinum/sys/geom/vinum/geom_vinum_init.c	Tue Mar 24 20:39:08 2009	(r190391)
+++ projects/gvinum/sys/geom/vinum/geom_vinum_init.c	Tue Mar 24 20:46:02 2009	(r190392)
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2004, 2007 Lukas Ertl
- * Copyright (c) 2007 Ulf Lilleengen
+ * Copyright (c) 2007, 2009 Ulf Lilleengen
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -86,7 +86,7 @@ gv_start_obj(struct g_geom *gp, struct g
 
 		case GV_TYPE_SD:
 		case GV_TYPE_DRIVE:
-			/* XXX not yet */
+			/* XXX Not implemented, but what is the use? */
 			gctl_error(req, "cannot start '%s' - not yet supported",
 			    argv);
 			return;
@@ -196,8 +196,9 @@ gv_sync_plex(struct gv_plex *p, struct g
 	KASSERT(up != NULL, ("%s: NULL up", __func__));
 	if ((p == up) || (p->state == GV_PLEX_UP))
 		return (0);
-	/* XXX: Should we check if rebuilding too? */
-	if (p->flags & GV_PLEX_SYNCING) {
+	if (p->flags & GV_PLEX_SYNCING ||
+	    p->flags & GV_PLEX_REBUILDING ||
+	    p->flags & GV_PLEX_GROWING) {
 		return (EINPROGRESS);
 	}
 	p->synced = 0;
@@ -270,10 +271,6 @@ gv_rebuild_plex(struct gv_plex *p)
 	struct gv_sd *s;
 	int error;
 
-/* XXX: Is this safe? (Allows for mounted rebuild)*/
-/*	if (gv_provider_is_open(p->vol_sc->provider))
-		return (EBUSY);*/
-
 	if (p->flags & GV_PLEX_SYNCING ||
 	    p->flags & GV_PLEX_REBUILDING ||
 	    p->flags & GV_PLEX_GROWING)
@@ -327,7 +324,7 @@ gv_grow_plex(struct gv_plex *p)
 	g_topology_unlock();
 	if (error) {
 		G_VINUM_DEBUG(0, "unable to access provider");
-		return (GV_ERR_ISBUSY); /*XXX: wrong errorcode */
+		return (error);
 	}
 
 	/* XXX: This routine with finding origsize is used two other places as
@@ -374,7 +371,7 @@ gv_init_plex(struct gv_plex *p)
 			G_VINUM_DEBUG(0, "subdisk %s has no drive yet", s->name);
 			break;
 		}
-		/* 
+		/*
 		 * Take the lock here since we need to avoid a race in
 		 * gv_init_request if the BIO is completed before the lock is
 		 * released.

Modified: projects/gvinum/sys/geom/vinum/geom_vinum_plex.c
==============================================================================
--- projects/gvinum/sys/geom/vinum/geom_vinum_plex.c	Tue Mar 24 20:39:08 2009	(r190391)
+++ projects/gvinum/sys/geom/vinum/geom_vinum_plex.c	Tue Mar 24 20:46:02 2009	(r190392)
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2004, 2007 Lukas Ertl
- * Copyright (c) 2007 Ulf Lilleengen
+ * Copyright (c) 2007, 2009 Ulf Lilleengen
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -144,7 +144,6 @@ gv_plex_offset(struct gv_plex *p, off_t 
 			}
 			i++;
 		}
-		/* Subdisk not found. */
 		if (s == NULL || s->drive_sc == NULL)
 			return (GV_ERR_NOTFOUND);
 
@@ -163,29 +162,19 @@ gv_plex_offset(struct gv_plex *p, off_t 
 		/* Take growing subdisks into account when calculating. */
 		sdcount = gv_sdcount(p, (boff >= p->synced));
 
-		/* Only take p->synced into calculation if we're growing. */
 		if (!(boff + bcount <= p->synced) &&
 		    (p->flags & GV_PLEX_GROWING) &&
 		    !growing)
 			return (GV_ERR_ISBUSY);
-		/* The number of the subdisk where the stripe resides. */
 		*sdno = stripeno % sdcount;
 
 		KASSERT(sdno >= 0, ("gv_plex_offset: sdno < 0"));
-
-		/* The offset of the stripe from the start of the subdisk. */ 
 		stripestart = (stripeno / sdcount) *
 		    p->stripesize;
 		KASSERT(stripestart >= 0, ("gv_plex_offset: stripestart < 0"));
-
-		/* The offset at the end of the stripe. */
 		stripeend = stripestart + p->stripesize;
-
-		/* The offset of the request on this subdisk. */
 		*real_off = boff - (stripeno * p->stripesize) +
 		    stripestart;
-
-		/* The length left in this stripe. */
 		len_left = stripeend - *real_off;
 		KASSERT(len_left >= 0, ("gv_plex_offset: len_left < 0"));
 
@@ -297,10 +286,8 @@ bad:
 		if (bp->bio_cflags & GV_BIO_MALLOC)
 			g_free(bp->bio_data);
 		g_destroy_bio(bp);
-		/* Reset flags. */
-		p->flags &= ~GV_PLEX_SYNCING;
-		p->flags &= ~GV_PLEX_REBUILDING;
-		p->flags &= ~GV_PLEX_GROWING;
+		p->flags &= ~(GV_PLEX_SYNCING | GV_PLEX_REBUILDING |
+		    GV_PLEX_GROWING);
 		return (-1);
 	}
 	g_io_deliver(bp, err);
@@ -548,6 +535,7 @@ gv_normal_parity(struct gv_plex *p, stru
 	return (finished);
 }
 
+/* Flush the queue with delayed requests. */
 static void
 gv_plex_flush(struct gv_plex *p)
 {
@@ -671,13 +659,7 @@ gv_sync_complete(struct gv_plex *to, str
 	gv_access(v->provider, -1, -1, 0);
 	g_topology_unlock();
 	G_VINUM_DEBUG(1, "plex sync completed");
-
-	/* Issue all delayed requests. */
-	bp = bioq_takefirst(v->wqueue);
-	while (bp != NULL) {
-		gv_volume_start(sc, bp);
-		bp = bioq_takefirst(v->wqueue);
-	}
+	gv_volume_flush(v);
 	return (0);
 }
 

Modified: projects/gvinum/sys/geom/vinum/geom_vinum_raid5.c
==============================================================================
--- projects/gvinum/sys/geom/vinum/geom_vinum_raid5.c	Tue Mar 24 20:39:08 2009	(r190391)
+++ projects/gvinum/sys/geom/vinum/geom_vinum_raid5.c	Tue Mar 24 20:46:02 2009	(r190392)
@@ -125,9 +125,8 @@ gv_raid5_start(struct gv_plex *p, struct
 				g_free(cbp->bio_data);
 			g_destroy_bio(bp);
 			/* Reset flags. */
-			p->flags &= ~GV_PLEX_SYNCING;
-			p->flags &= ~GV_PLEX_REBUILDING;
-			p->flags &= ~GV_PLEX_GROWING;
+			p->flags &= ~(GV_PLEX_SYNCING | GV_PLEX_REBUILDING |
+			    GV_PLEX_GROWING);
 			return (NULL);
 		}
 		g_io_deliver(bp, err);

Modified: projects/gvinum/sys/geom/vinum/geom_vinum_raid5.h
==============================================================================
--- projects/gvinum/sys/geom/vinum/geom_vinum_raid5.h	Tue Mar 24 20:39:08 2009	(r190391)
+++ projects/gvinum/sys/geom/vinum/geom_vinum_raid5.h	Tue Mar 24 20:46:02 2009	(r190392)
@@ -50,5 +50,6 @@ struct gv_raid5_packet {
 
 struct gv_raid5_packet * gv_raid5_start(struct gv_plex *, struct bio *,
 		caddr_t, off_t, off_t);
+int	gv_stripe_active(struct gv_plex *, struct bio *);
 
 #endif /* !_GEOM_VINUM_RAID5_H_ */

Modified: projects/gvinum/sys/geom/vinum/geom_vinum_rm.c
==============================================================================
--- projects/gvinum/sys/geom/vinum/geom_vinum_rm.c	Tue Mar 24 20:39:08 2009	(r190391)
+++ projects/gvinum/sys/geom/vinum/geom_vinum_rm.c	Tue Mar 24 20:46:02 2009	(r190392)
@@ -195,17 +195,15 @@ gv_rm_vol(struct gv_softc *sc, struct gv
 	struct gv_plex *p, *p2;
 
 	KASSERT(v != NULL, ("gv_rm_vol: NULL v"));
-
-	/* XXX gp = v->geom; */
 	pp = v->provider;
+	KASSERT(pp != NULL, ("gv_rm_vol: NULL pp"));
 
 	/* Check if any of our consumers is open. */
-/* XXX
-	if (gp != NULL && gv_is_open(gp)) {
-		gctl_error(req, "volume '%s' is busy", v->name);
-		return (-1);
+	if (gv_provider_is_open(pp)) {
+		G_VINUM_DEBUG(0, "Unable to remove %s: volume still in use",
+		    v->name);
+		return;
 	}
-*/
 
 	/* Remove the plexes our volume has. */
 	LIST_FOREACH_SAFE(p, &v->plexes, in_volume, p2)
@@ -232,16 +230,14 @@ gv_rm_plex(struct gv_softc *sc, struct g
 	struct gv_sd *s, *s2;
 
 	KASSERT(p != NULL, ("gv_rm_plex: NULL p"));
-
-	/* XXX gp = p->geom; */
+	v = p->vol_sc;
 
 	/* Check if any of our consumers is open. */
-/* XXX
-	if (gp != NULL && gv_is_open(gp)) {
-		gctl_error(req, "plex '%s' is busy", p->name);
-		return (-1);
+	if (v != NULL && gv_provider_is_open(v->provider) && v->plexcount < 2) {
+		G_VINUM_DEBUG(0, "Unable to remove %s: volume still in use",
+		    p->name);
+		return;
 	}
-*/
 
 	/* Remove the subdisks our plex has. */
 	LIST_FOREACH_SAFE(s, &p->subdisks, in_plex, s2)

Modified: projects/gvinum/sys/geom/vinum/geom_vinum_subr.c
==============================================================================
--- projects/gvinum/sys/geom/vinum/geom_vinum_subr.c	Tue Mar 24 20:39:08 2009	(r190391)
+++ projects/gvinum/sys/geom/vinum/geom_vinum_subr.c	Tue Mar 24 20:46:02 2009	(r190392)
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2004, 2007 Lukas Ertl
- * Copyright (c) 2007 Ulf Lilleengen
+ * Copyright (c) 2007, 2009 Ulf Lilleengen
  * Copyright (c) 1997, 1998, 1999
  *      Nan Yang Computer Services Limited.  All rights reserved.
  *
@@ -574,7 +574,6 @@ gv_sd_to_drive(struct gv_sd *s, struct g
 	fl2 = NULL;
 
 	/* Shortcut for "referenced" drives. */
-	/* XXX - insert into d->subdisks? */
 	if (d->flags & GV_DRIVE_REFERENCED) {
 		s->drive_sc = d;
 		return (0);

Modified: projects/gvinum/sys/geom/vinum/geom_vinum_volume.c
==============================================================================
--- projects/gvinum/sys/geom/vinum/geom_vinum_volume.c	Tue Mar 24 20:39:08 2009	(r190391)
+++ projects/gvinum/sys/geom/vinum/geom_vinum_volume.c	Tue Mar 24 20:46:02 2009	(r190392)
@@ -38,6 +38,23 @@ __FBSDID("$FreeBSD$");
 #include <geom/vinum/geom_vinum.h>
 
 void
+gv_volume_flush(struct gv_volume *v)
+{
+	struct gv_softc *sc;
+	struct bio *bp;
+
+	KASSERT(v != NULL, ("NULL v"));
+	sc = v->vinumconf;
+	KASSERT(sc != NULL, ("NULL sc"));
+
+	bp = bioq_takefirst(v->wqueue);
+	while (bp != NULL) {
+		gv_volume_start(sc, bp);
+		bp = bioq_takefirst(v->wqueue);
+	}
+}
+
+void
 gv_volume_start(struct gv_softc *sc, struct bio *bp)
 {
 	struct g_geom *gp;


More information about the svn-src-projects mailing list