Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 May 2007 17:59:23 GMT
From:      Ulf Lilleengen <lulf@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 119581 for review
Message-ID:  <200705091759.l49HxNK5026739@repoman.freebsd.org>

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

Change 119581 by lulf@lulf_vimes on 2007/05/09 17:58:32

	- Define error codes and use them.

Affected files ...

.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.c#7 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_rm.c#4 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_state.c#8 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_subr.c#4 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_var.h#5 edit

Differences ...

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


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

@@ -165,7 +165,7 @@
         LIST_FOREACH_SAFE(d, &sc->drives, drive, d2) {
 		if (gv_consumer_is_open(d->consumer)) {
 			gctl_error(req, "drive '%s' is busy", d->name);
-			return (-1);
+			return (GV_ERR_ISOPEN);
 		}
 	}
 	/* Then if not, we remove everything. */

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

@@ -141,7 +141,7 @@
 	return;
 }
 
-/* Update drive state; return 0 if the state changes, otherwise -1. */
+/* Update drive state; return 0 if the state changes, otherwise error. */
 int
 gv_set_drive_state(struct gv_drive *d, int newstate, int flags)
 {
@@ -158,7 +158,7 @@
 	/* We allow to take down an open drive only with force. */
 	if ((newstate == GV_DRIVE_DOWN) && gv_consumer_is_open(d->consumer) &&
 	    (!(flags & GV_SETSTATE_FORCE)))
-		return (-1);
+		return (GV_ERR_ISOPEN);
 
 	d->state = newstate;
 
@@ -198,14 +198,14 @@
 		 * force.
 		 */
 		if ((s->plex_sc != NULL) && !(flags & GV_SETSTATE_FORCE))
-			return (-1);
+			return (GV_ERR_ISATTACHED);
 		break;
 
 	case GV_SD_UP:
 		/* We can't bring the subdisk up if our drive is dead. */
 		d = s->drive_sc;
 		if ((d == NULL) || (d->state != GV_DRIVE_UP))
-			return (-1);
+			return (GV_ERR_SETSTATE);
 
 		/* Check from where we want to be brought up. */
 		switch (s->state) {
@@ -242,7 +242,7 @@
 			else
 				s->state = GV_SD_STALE;
 
-			status = -1;
+			status = GV_ERR_SETSTATE;
 			break;
 
 		case GV_SD_STALE:
@@ -261,17 +261,17 @@
 			    (p->vol_sc->plexcount == 1))
 				break;
 			else
-				return (-1);
+				return (GV_ERR_SETSTATE);
 
 		default:
-			return (-1);
+			return (GV_ERR_INVSTATE);
 		}
 		break;
 
 	/* Other state transitions are only possible with force. */
 	default:
 		if (!(flags & GV_SETSTATE_FORCE))
-			return (-1);
+			return (GV_ERR_SETSTATE);
 	}
 
 	/* We can change the state and do it. */
@@ -309,7 +309,7 @@
 		/* Let update_plex handle if the plex can come up */
 		gv_update_plex_state(p);
 		if (p->state != GV_PLEX_UP && !(flags & GV_SETSTATE_FORCE))
-			return (-1); /* XXX: ERROR CODES. */
+			return (GV_ERR_SETSTATE);
 		p->state = newstate;
 		break;
 	case GV_PLEX_DOWN:
@@ -323,7 +323,7 @@
 			if ((v->plexcount == 1 ||
 			    (v->plexcount - plexdown == 1)) &&
 			    ((flags & GV_SETSTATE_FORCE) == 0))
-				return (-1); /* XXX: ERROR CODES. */
+				return (GV_ERR_SETSTATE);
 		}
 		p->state = newstate;
 		break;
@@ -356,7 +356,7 @@
 		/* Let update handle if the volume can come up. */
 		gv_update_vol_state(v);
 		if (v->state != GV_VOL_UP && !(flags & GV_SETSTATE_FORCE))
-			return (-1); /* XXX: ERROR CODES. */
+			return (GV_ERR_SETSTATE);
 		v->state = newstate;
 		break;
 	case GV_VOL_DOWN:
@@ -366,7 +366,7 @@
 		 */
 		if (!gv_provider_is_open(v->provider) &&
 		    !(flags & GV_SETSTATE_FORCE))
-			return (-1); /* XXX: ERROR CODES. */
+			return (GV_ERR_ISOPEN);
 		v->state = newstate;
 		break;
 	}

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

@@ -278,7 +278,7 @@
 		printf("VINUM: need equal sized subdisks for this plex "
 		    "organisation - %s (%jd) <-> %s (%jd)\n",
 		    s2->name, s2->size, s->name, s->size);
-		return (-1);
+		return (GV_ERR_BADSIZE);
 	}
 
 	/* Find the correct plex offset for this subdisk, if needed. */
@@ -525,7 +525,7 @@
 			printf("VINUM: can't give sd '%s' to '%s' "
 			    "(already on '%s')\n", s->name, d->name,
 			    s->drive_sc->name);
-			return (-1);
+			return (GV_ERR_ISATTACHED);
 		}
 	}
 
@@ -533,7 +533,7 @@
 	if ((s->size > d->avail) || (d->freelist_entries == 0)) {
 		printf("VINUM: not enough space on '%s' for '%s'", d->name,
 		    s->name);
-		return (-1);
+		return (GV_ERR_NOSPACE);
 	}
 
 	/* If no size was given for this subdisk, try to auto-size it... */
@@ -551,7 +551,7 @@
 		if (s->size == -1) {
 			printf("VINUM: couldn't autosize '%s' on '%s'",
 			    s->name, d->name);
-			return (-1);
+			return (GV_ERR_BADSIZE);
 		}
 
 	/*
@@ -575,7 +575,7 @@
 		if (i == 0) {
 			printf("VINUM: free slots to small for '%s' on '%s'",
 			    s->name, d->name);
-			return (-1);
+			return (GV_ERR_NOSPACE);
 		}
 	}
 
@@ -612,7 +612,7 @@
 		if (i == 0) {
 			printf("VINUM: given drive_offset for '%s' won't fit "
 			    "on '%s'", s->name, d->name);
-			return (-1);
+			return (GV_ERR_NOSPACE);
 		}
 	}
 
@@ -953,7 +953,7 @@
 			return (GV_TYPE_DRIVE);
 	}
 
-	return (-1);
+	return (GV_ERR_INVTYPE);
 }
 
 void

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

@@ -118,6 +118,19 @@
 #define	GV_BIO_PARITY	0x80
 #define GV_BIO_RETRY	0x100
 
+/* Error codes to be used within gvinum. */
+#define GV_ERR_SETSTATE		(-1)	/* Error setting state. */
+#define GV_ERR_BADSIZE		(-2)	/* Subdisk/plex/volume has wrong size. */
+#define GV_ERR_INVTYPE		(-3)    /* Invalid object type. */
+#define GV_ERR_CREATE		(-4)	/* Error creating gvinum object. */
+#define	GV_ERR_ISOPEN		(-5)	/* Object is busy. */
+#define GV_ERR_ISATTACHED	(-6)	/* Object is attached to another. */
+#define GV_ERR_INVFLAG		(-7)	/* Invalid flag passed. */
+#define GV_ERR_INVSTATE		(-8)	/* Invalid state. */
+#define GV_ERR_NOTFOUND		(-9)	/* Object not found. */
+#define GV_ERR_NAMETAKEN	(-10)	/* Object name is taken. */
+#define GV_ERR_NOSPACE		(-11)	/* No space left on drive/subdisk. */
+
 /*
  * hostname is 256 bytes long, but we don't need to shlep multiple copies in
  * vinum.  We use the host name just to identify this system, and 32 bytes



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