PERFORCE change 119204 for review
Ulf Lilleengen
lulf at FreeBSD.org
Thu May 3 20:21:31 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=119204
Change 119204 by lulf at lulf_vimes on 2007/05/03 20:21:17
- Change gv_is_open to gv_consumer_is_open and add a similar function
for checking if a provider is open.
- Fix compilation issues from last commit. The setstate of subdisk, plex
and drive should work properly and seems to work after some tests.
Affected files ...
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.c#5 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.h#4 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_init.c#2 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_rm.c#3 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_state.c#6 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_subr.c#2 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_var.h#3 edit
Differences ...
==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.c#5 (text+ko) ====
@@ -529,7 +529,20 @@
* ERROR CODES.*/
if (err)
printf("VINUM: error setting drive "
- "state");
+ "state\n");
+ g_free(ev->arg2);
+ g_free(ev->arg3);
+ break;
+
+ case GV_EVENT_SET_VOL_STATE:
+ printf("VINUM: event 'setstate volume'\n");
+ v = ev->arg1;
+ newstate = *(int *)ev->arg2;
+ flags = *(int *)ev->arg3;
+ err = gv_set_vol_state(v, newstate, flags);
+ if (err)
+ printf("VINUM: error setting volume "
+ "state\n");
g_free(ev->arg2);
g_free(ev->arg3);
break;
==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.h#4 (text+ko) ====
@@ -63,6 +63,7 @@
void gv_setstate(struct g_geom *, struct gctl_req *);
int gv_set_drive_state(struct gv_drive *, int, int);
int gv_set_sd_state(struct gv_sd *, int, int);
+int gv_set_vol_state(struct gv_volume *, int, int);
void gv_update_sd_state(struct gv_sd *);
void gv_update_plex_state(struct gv_plex *);
void gv_update_vol_state(struct gv_volume *);
@@ -76,7 +77,8 @@
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_is_open(struct g_consumer *);
+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 *, u_char *);
int gv_sd_to_drive(struct gv_sd *, struct gv_drive *);
==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_init.c#2 (text+ko) ====
@@ -361,7 +361,7 @@
{
struct gv_sync_args *sync;
- if (gv_is_open(p->geom))
+ if (gv_consumer_is_open(p->geom))
return (EBUSY);
if (p->flags & GV_PLEX_SYNCING)
==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_rm.c#3 (text+ko) ====
@@ -127,7 +127,7 @@
case GV_TYPE_DRIVE:
d = gv_find_drive(sc, argv);
/* We don't allow to remove open drives. */
- if (gv_is_open(d->consumer)) {
+ if (gv_consumer_is_open(d->consumer)) {
gctl_error(req, "drive '%s' is open", d->name);
return;
}
@@ -163,7 +163,7 @@
/* First make sure nothing is open. */
LIST_FOREACH_SAFE(d, &sc->drives, drive, d2) {
- if (gv_is_open(d->consumer)) {
+ if (gv_consumer_is_open(d->consumer)) {
gctl_error(req, "drive '%s' is busy", d->name);
return (-1);
}
==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_state.c#6 (text+ko) ====
@@ -43,6 +43,7 @@
struct gv_softc *sc;
struct gv_sd *s;
struct gv_drive *d;
+ struct gv_volume *v;
char *obj, *state;
int f, *flags, *newstatep, *flagp, type;
@@ -142,7 +143,7 @@
return (0);
/* We allow to take down an open drive only with force. */
- if ((newstate == GV_DRIVE_DOWN) && gv_is_open(d->consumer) &&
+ if ((newstate == GV_DRIVE_DOWN) && gv_consumer_is_open(d->consumer) &&
(!(flags & GV_SETSTATE_FORCE)))
return (-1);
@@ -155,7 +156,7 @@
/* Save the config back to disk. */
if (flags & GV_SETSTATE_CONFIG)
- gv_post_event(sc, GV_EVENT_SAVE_CONFIG, v->vinumconf, NULL, NULL);
+ gv_save_config(d->vinumconf);
return (0);
}
@@ -270,7 +271,7 @@
/* Save the config back to disk. */
if (flags & GV_SETSTATE_CONFIG)
- gv_post_event(sc, GV_EVENT_SAVE_CONFIG, v->vinumconf, NULL, NULL);
+ gv_save_config(s->vinumconf);
return (status);
}
@@ -291,15 +292,16 @@
case GV_VOL_UP:
/* Let update handle if the volume can come up. */
gv_update_vol_state(v);
- if (v->state != GV_VOL_UP && flags & GV_SETSTATE_FORCE)
- v->state = newstate;
+ if (v->state != GV_VOL_UP && !(flags & GV_SETSTATE_FORCE))
+ return (-1); /* XXX: ERROR CODES. */
+ v->state = newstate;
break;
case GV_VOL_DOWN:
/*
* Set state to GV_VOL_DOWN only if noone is using the volume,
* or if the state should be forced.
*/
- if ((gv_is_open(v->geom) != 0) &&
+ if (!gv_provider_is_open(v->provider) &&
!(flags & GV_SETSTATE_FORCE))
return (-1); /* XXX: ERROR CODES. */
v->state = newstate;
@@ -307,7 +309,8 @@
}
/* Save config */
if (flags & GV_SETSTATE_CONFIG)
- gv_post_event(sc, GV_EVENT_SAVE_CONFIG, v->vinumconf, NULL, NULL);
+ gv_save_config(v->vinumconf);
+ return (0);
}
/* Update the state of a subdisk based on its environment. */
==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_subr.c#2 (text+ko) ====
@@ -853,7 +853,7 @@
/* Check if any consumer of the given geom is open. */
int
-gv_is_open(struct g_consumer *cp)
+gv_consumer_is_open(struct g_consumer *cp)
{
if (cp == NULL)
return (0);
@@ -864,6 +864,17 @@
return (0);
}
+int
+gv_provider_is_open(struct g_provider *pp) {
+ if (pp == NULL)
+ return (0);
+
+ if (pp->acr || pp->acw || pp->ace)
+ return (1);
+
+ return (0);
+}
+
/*
* Compare the modification dates of the drives.
* Return 1 if a > b, 0 otherwise.
==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_var.h#3 (text+ko) ====
@@ -174,6 +174,7 @@
#define GV_EVENT_RM_DRIVE 12
#define GV_EVENT_SET_SD_STATE 13
#define GV_EVENT_SET_DRIVE_STATE 14
+#define GV_EVENT_SET_VOL_STATE 15
struct gv_event {
int type;
More information about the p4-projects
mailing list