PERFORCE change 122415 for review
Ulf Lilleengen
lulf at FreeBSD.org
Wed Jun 27 17:22:23 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=122415
Change 122415 by lulf at lulf_carrot on 2007/06/27 17:22:20
- Modify gv_event structure to contain to intmax variables, and remove
one pointer. This way we won't have to allocate and deallocate memory
for passing integer values. intmax_t should be large enough i think.
- Modify all code that uses the event-structure and post_event to use
the structure correctly.
Affected files ...
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.c#20 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.h#16 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_events.c#5 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_init.c#12 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_plex.c#16 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_rm.c#7 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_state.c#14 edit
.. //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_var.h#17 edit
Differences ...
==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.c#20 (text+ko) ====
@@ -73,7 +73,7 @@
g_trace(G_T_TOPOLOGY, "gv_orphan(%s)", gp->name);
- gv_post_event(sc, GV_EVENT_DRIVE_LOST, d, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_DRIVE_LOST, d, NULL, 0, 0);
}
void
@@ -186,7 +186,7 @@
sc = gp->softc;
if (sc != NULL) {
- gv_post_event(sc, GV_EVENT_THREAD_EXIT, NULL, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_THREAD_EXIT, NULL, NULL, 0, 0);
gp->softc = NULL;
g_wither_geom(gp, ENXIO);
return (EAGAIN);
@@ -231,7 +231,7 @@
v = gv_find_vol(sc, parent);
p = gv_find_plex(sc, child);
/* XXX: Rename not supported yet. */
- gv_post_event(sc, GV_EVENT_ATTACH_PLEX, p, v, NULL);
+ gv_post_event(sc, GV_EVENT_ATTACH_PLEX, p, v, 0, 0);
break;
case GV_TYPE_SD:
if (type_parent != GV_TYPE_PLEX) {
@@ -241,7 +241,7 @@
p = gv_find_plex(sc, parent);
s = gv_find_sd(sc, child);
/* XXX: Rename not supported yet. */
- gv_post_event(sc, GV_EVENT_ATTACH_SD, s, p, NULL);
+ gv_post_event(sc, GV_EVENT_ATTACH_SD, s, p, 0, 0);
break;
default:
gctl_error(req, "invalid child type");
@@ -270,12 +270,12 @@
case GV_TYPE_PLEX:
/* XXX: Support flags. */
p = gv_find_plex(sc, object);
- gv_post_event(sc, GV_EVENT_DETACH_PLEX, p, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_DETACH_PLEX, p, NULL, 0, 0);
break;
case GV_TYPE_SD:
/* XXX: Support flags. */
s = gv_find_sd(sc, object);
- gv_post_event(sc, GV_EVENT_DETACH_SD, s, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_DETACH_SD, s, NULL, 0, 0);
break;
default:
gctl_error(req, "invalid object type");
@@ -328,7 +328,7 @@
d = g_malloc(sizeof(*d), M_WAITOK | M_ZERO);
bcopy(d2, d, sizeof(*d));
- gv_post_event(sc, GV_EVENT_CREATE_DRIVE, d, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_CREATE_DRIVE, d, NULL, 0, 0);
}
/* ... then volume definitions ... */
@@ -345,7 +345,7 @@
v = g_malloc(sizeof(*v), M_WAITOK | M_ZERO);
bcopy(v2, v, sizeof(*v));
- gv_post_event(sc, GV_EVENT_CREATE_VOLUME, v, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_CREATE_VOLUME, v, NULL, 0, 0);
}
/* ... then plex definitions ... */
@@ -362,7 +362,7 @@
p = g_malloc(sizeof(*p), M_WAITOK | M_ZERO);
bcopy(p2, p, sizeof(*p));
- gv_post_event(sc, GV_EVENT_CREATE_PLEX, p, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_CREATE_PLEX, p, NULL, 0, 0);
}
/* ... and, finally, subdisk definitions. */
@@ -379,10 +379,10 @@
s = g_malloc(sizeof(*s), M_WAITOK | M_ZERO);
bcopy(s2, s, sizeof(*s));
- gv_post_event(sc, GV_EVENT_CREATE_SD, s, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_CREATE_SD, s, NULL, 0, 0);
}
- gv_post_event(sc, GV_EVENT_SAVE_CONFIG, sc, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_SAVE_CONFIG, sc, NULL, 0, 0);
return (0);
}
@@ -411,7 +411,7 @@
/* Save our configuration back to disk. */
} else if (!strcmp(verb, "saveconfig")) {
- gv_post_event(sc, GV_EVENT_SAVE_CONFIG, sc, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_SAVE_CONFIG, sc, NULL, 0, 0);
/* Return configuration in string form. */
} else if (!strcmp(verb, "getconfig")) {
@@ -442,7 +442,7 @@
gv_rename(gp, req);
} else if (!strcmp(verb, "resetconfig")) {
- gv_post_event(sc, GV_EVENT_RESET_CONFIG, sc, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_RESET_CONFIG, sc, NULL, 0, 0);
} else if (!strcmp(verb, "start")) {
gv_start_obj(gp, req);
@@ -495,7 +495,8 @@
/* Check if what we've been given is a valid vinum drive. */
if (vhdr != NULL) {
if (vhdr->magic == GV_MAGIC)
- gv_post_event(sc, GV_EVENT_DRIVE_TASTED, pp, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_DRIVE_TASTED, pp, NULL, 0,
+ 0);
g_free(vhdr);
}
@@ -602,53 +603,45 @@
case GV_EVENT_SET_SD_STATE:
printf("VINUM: event 'setstate sd'\n");
s = ev->arg1;
- newstate = *(int *)ev->arg2;
- flags = *(int *)ev->arg3;
+ newstate = ev->arg3;
+ flags = ev->arg4;
err = gv_set_sd_state(s, newstate, flags);
if (err)
printf("VINUM: error setting subdisk "
"state: error code %d\n", err);
- g_free(ev->arg2);
- g_free(ev->arg3);
break;
case GV_EVENT_SET_DRIVE_STATE:
printf("VINUM: event 'setstate drive'\n");
d = ev->arg1;
- newstate = *(int *)ev->arg2;
- flags = *(int *)ev->arg3;
+ newstate = ev->arg3;
+ flags = ev->arg4;
err = gv_set_drive_state(d, newstate, flags);
if (err)
printf("VINUM: error setting drive "
"state: error code %d\n", err);
- 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;
+ newstate = ev->arg3;
+ flags = ev->arg4;
err = gv_set_vol_state(v, newstate, flags);
if (err)
printf("VINUM: error setting volume "
"state: error code %d\n", err);
- g_free(ev->arg2);
- g_free(ev->arg3);
break;
case GV_EVENT_SET_PLEX_STATE:
printf("VINUM: event 'setstate plex'\n");
p = ev->arg1;
- newstate = *(int *)ev->arg2;
- flags = *(int *)ev->arg3;
+ newstate = ev->arg3;
+ flags = ev->arg4;
err = gv_set_plex_state(p, newstate, flags);
if (err)
printf("VINUM: error setting plex "
"state: error code %d\n", err);
- g_free(ev->arg2);
- g_free(ev->arg3);
break;
case GV_EVENT_RESET_CONFIG:
==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum.h#16 (text+ko) ====
@@ -96,7 +96,8 @@
int gv_detach_sd(struct gv_sd *, int);
void gv_worker(void *);
-void gv_post_event(struct gv_softc *, int, void *, void *, void *);
+void gv_post_event(struct gv_softc *, int, void *, void *, intmax_t,
+ intmax_t);
void gv_drive_tasted(struct gv_softc *, struct g_provider *);
void gv_drive_lost(struct gv_softc *, struct gv_drive *);
void gv_setup_objects(struct gv_softc *);
==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_events.c#5 (text+ko) ====
@@ -43,7 +43,7 @@
void
gv_post_event(struct gv_softc *sc, int event, void *arg1, void *arg2,
- void *arg3)
+ intmax_t arg3, intmax_t arg4)
{
struct gv_event *ev;
@@ -52,6 +52,7 @@
ev->arg1 = arg1;
ev->arg2 = arg2;
ev->arg3 = arg3;
+ ev->arg4 = arg4;
mtx_lock(&sc->queue_mtx);
TAILQ_INSERT_TAIL(&sc->equeue, ev, events);
@@ -174,7 +175,7 @@
if (cp->nstart != cp->nend) {
printf("VINUM: dead drive '%s' has still active "
"requests, can't detach consumer\n", d->name);
- gv_post_event(sc, GV_EVENT_DRIVE_LOST, d, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_DRIVE_LOST, d, NULL, 0, 0);
return;
}
g_topology_lock();
==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_init.c#12 (text+ko) ====
@@ -74,14 +74,14 @@
v = gv_find_vol(sc, argv);
if (v != NULL)
gv_post_event(sc, GV_EVENT_START_VOLUME, v,
- NULL, NULL);
+ NULL, *initsize, 0);
break;
case GV_TYPE_PLEX:
p = gv_find_plex(sc, argv);
if (p != NULL)
gv_post_event(sc, GV_EVENT_START_PLEX, p, NULL,
- NULL);
+ *initsize, 0);
break;
case GV_TYPE_SD:
==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_plex.c#16 (text+ko) ====
@@ -800,7 +800,7 @@
/* XXX: The state of the plex might have changed when this event is
* picked up ... We should really check this afterwards. */
if (*rebuild)
- gv_post_event(sc, GV_EVENT_PARITY_REBUILD, p, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_PARITY_REBUILD, p, NULL, 0, 0);
else
- gv_post_event(sc, GV_EVENT_PARITY_CHECK, p, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_PARITY_CHECK, p, NULL, 0, 0);
}
==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_rm.c#7 (text+ko) ====
@@ -83,7 +83,7 @@
return;
}
- gv_post_event(sc, GV_EVENT_RM_VOLUME, v, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_RM_VOLUME, v, NULL, 0, 0);
break;
case GV_TYPE_PLEX:
@@ -108,7 +108,7 @@
return;
}
- gv_post_event(sc, GV_EVENT_RM_PLEX, p, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_RM_PLEX, p, NULL, 0, 0);
break;
case GV_TYPE_SD:
@@ -121,7 +121,7 @@
return;
}
- gv_post_event(sc, GV_EVENT_RM_SD, s, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_RM_SD, s, NULL, 0, 0);
break;
case GV_TYPE_DRIVE:
@@ -140,7 +140,7 @@
return;
}
- gv_post_event(sc, GV_EVENT_RM_DRIVE, d, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_RM_DRIVE, d, NULL, 0, 0);
break;
default:
@@ -149,7 +149,7 @@
}
}
- gv_post_event(sc, GV_EVENT_SAVE_CONFIG, sc, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_SAVE_CONFIG, sc, NULL, 0, 0);
}
/* Resets configuration */
@@ -177,7 +177,7 @@
LIST_FOREACH_SAFE(v, &sc->volumes, volume, v2)
gv_rm_vol(sc, v);
- gv_post_event(sc, GV_EVENT_SAVE_CONFIG, sc, NULL, NULL);
+ gv_post_event(sc, GV_EVENT_SAVE_CONFIG, sc, NULL, 0, 0);
return (0);
}
==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_state.c#14 (text+ko) ====
@@ -46,7 +46,7 @@
struct gv_volume *v;
struct gv_plex *p;
char *obj, *state;
- int f, *flags, *newstatep, *flagp, type;
+ int f, *flags, type;
f = 0;
obj = gctl_get_param(req, "object", NULL);
@@ -79,13 +79,8 @@
break;
}
v = gv_find_vol(sc, obj);
-
- /* XXX: Should try to avoid malloc. */
- newstatep = g_malloc(sizeof(int), M_WAITOK | M_ZERO);
- *newstatep = gv_volstatei(state);
- flagp = g_malloc(sizeof(int), M_WAITOK | M_ZERO);
- *flagp = f;
- gv_post_event(sc, GV_EVENT_SET_VOL_STATE, v, newstatep, flagp);
+ gv_post_event(sc, GV_EVENT_SET_VOL_STATE, v, NULL,
+ gv_volstatei(state), f);
break;
case GV_TYPE_PLEX:
@@ -94,13 +89,8 @@
break;
}
p = gv_find_plex(sc, obj);
-
- /* XXX: Should try to avoid malloc. */
- newstatep = g_malloc(sizeof(int), M_WAITOK | M_ZERO);
- *newstatep = gv_plexstatei(state);
- flagp = g_malloc(sizeof(int), M_WAITOK | M_ZERO);
- *flagp = f;
- gv_post_event(sc, GV_EVENT_SET_PLEX_STATE, p, newstatep, flagp);
+ gv_post_event(sc, GV_EVENT_SET_PLEX_STATE, p, NULL,
+ gv_plexstatei(state), f);
break;
case GV_TYPE_SD:
@@ -109,13 +99,8 @@
break;
}
s = gv_find_sd(sc, obj);
-
- /* XXX: Should try to avoid malloc. */
- newstatep = g_malloc(sizeof(int), M_WAITOK | M_ZERO);
- *newstatep = gv_sdstatei(state);
- flagp = g_malloc(sizeof(int), M_WAITOK | M_ZERO);
- *flagp = f;
- gv_post_event(sc, GV_EVENT_SET_SD_STATE, s, newstatep, flagp);
+ gv_post_event(sc, GV_EVENT_SET_SD_STATE, s, NULL,
+ gv_sdstatei(state), f);
break;
case GV_TYPE_DRIVE:
@@ -124,14 +109,8 @@
break;
}
d = gv_find_drive(sc, obj);
-
- /* XXX: Should try to avoid malloc. */
- newstatep = g_malloc(sizeof(int), M_WAITOK | M_ZERO);
- *newstatep = gv_drivestatei(state);
- flagp = g_malloc(sizeof(int), M_WAITOK | M_ZERO);
- *flagp = f;
- gv_post_event(sc, GV_EVENT_SET_DRIVE_STATE, d, newstatep,
- flagp);
+ gv_post_event(sc, GV_EVENT_SET_DRIVE_STATE, d, NULL,
+ gv_drivestatei(state), f);
break;
default:
==== //depot/projects/soc2007/lulf/gvinum_fixup/sys/geom/vinum/geom_vinum_var.h#17 (text+ko) ====
@@ -204,7 +204,8 @@
int type;
void *arg1;
void *arg2;
- void *arg3;
+ intmax_t arg3;
+ intmax_t arg4;
TAILQ_ENTRY(gv_event) events;
};
More information about the p4-projects
mailing list