Rename g_call_me() to g_post_event(), and give it a flag

argument to determine if we can M_WAITOK in malloc.
This commit is contained in:
Poul-Henning Kamp 2003-04-23 20:46:12 +00:00
parent 7f10745771
commit 8cd1535a24
12 changed files with 35 additions and 34 deletions

View File

@ -208,9 +208,9 @@ void g_trace(int level, const char *, ...);
/* geom_event.c */
typedef void g_call_me_t(void *, int flag);
typedef void g_event_t(void *, int flag);
#define EV_CANCEL 1
int g_call_me(g_call_me_t *func, void *arg, ...);
int g_post_event(g_event_t *func, void *arg, int flag, ...);
void g_cancel_event(void *ref);
void g_orphan_provider(struct g_provider *pp, int error);
void g_waitidle(void);

View File

@ -345,7 +345,7 @@ g_bsd_try(struct g_geom *gp, struct g_slicer *gsp, struct g_consumer *cp, int se
/*
* Implement certain ioctls to modify disklabels with. This function
* is called by the event handler thread with topology locked as result
* of the g_call_me() in g_bsd_start(). It is not necessary to keep
* of the g_post_event() in g_bsd_start(). It is not necessary to keep
* topology locked all the time but make sure to return with topology
* locked as well.
*/
@ -592,7 +592,7 @@ g_bsd_start(struct bio *bp)
* some I/O requests. Ask the event-handler to schedule
* us in a less restricted environment.
*/
error = g_call_me(g_bsd_ioctl, bp, gp, NULL);
error = g_post_event(g_bsd_ioctl, bp, M_NOWAIT, gp, NULL);
if (error)
g_io_deliver(bp, error);
/*

View File

@ -333,7 +333,7 @@ disk_create(int unit, struct disk *dp, int flags, void *unused __unused, void *
dp->d_sectorsize, DEVSTAT_ALL_SUPPORTED,
DEVSTAT_TYPE_DIRECT, DEVSTAT_PRIORITY_MAX);
dp->d_geom = NULL;
g_call_me(g_disk_create, dp, dp, NULL);
g_post_event(g_disk_create, dp, M_WAITOK, dp, NULL);
}
/*
@ -386,12 +386,11 @@ sysctl_disks(SYSCTL_HANDLER_ARGS)
sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
sbuf_clear(sb);
error = g_call_me(g_kern_disks, sb, NULL);
while (!error && !sbuf_done(sb)) {
g_post_event(g_kern_disks, sb, M_WAITOK, NULL);
while (!sbuf_done(sb)) {
tsleep(sb, PZERO, "kern.disks", hz);
}
if (!error)
error = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1);
error = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1);
sbuf_delete(sb);
return error;
}

View File

@ -210,18 +210,20 @@ g_cancel_event(void *ref)
}
int
g_call_me(g_call_me_t *func, void *arg, ...)
g_post_event(g_event_t *func, void *arg, int flag, ...)
{
struct g_event *ep;
va_list ap;
void *p;
u_int n;
g_trace(G_T_TOPOLOGY, "g_call_me(%p, %p", func, arg);
ep = g_malloc(sizeof *ep, M_NOWAIT | M_ZERO);
g_trace(G_T_TOPOLOGY, "g_post_event(%p, %p, %d", func, arg, flag);
KASSERT(flag == M_NOWAIT || flag == M_WAITOK,
("Wrong flag to g_post_event"));
ep = g_malloc(sizeof *ep, flag | M_ZERO);
if (ep == NULL)
return (ENOMEM);
va_start(ap, arg);
va_start(ap, flag);
for (n = 0; n < G_N_EVENTREFS; n++) {
p = va_arg(ap, void *);
if (p == NULL)

View File

@ -58,7 +58,7 @@ extern int g_debugflags;
struct g_event {
TAILQ_ENTRY(g_event) events;
void *arg;
g_call_me_t *func;
g_event_t *func;
void *ref[G_N_EVENTREFS];
};

View File

@ -172,7 +172,7 @@ sysctl_kern_geom_conftxt(SYSCTL_HANDLER_ARGS)
sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
sbuf_clear(sb);
g_call_me(g_conftxt, sb, NULL);
g_post_event(g_conftxt, sb, M_WAITOK, NULL);
do {
tsleep(sb, PZERO, "g_conftxt", hz);
} while(!sbuf_done(sb));
@ -189,7 +189,7 @@ sysctl_kern_geom_confdot(SYSCTL_HANDLER_ARGS)
sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
sbuf_clear(sb);
g_call_me(g_confdot, sb, NULL);
g_post_event(g_confdot, sb, M_WAITOK, NULL);
do {
tsleep(sb, PZERO, "g_confdot", hz);
} while(!sbuf_done(sb));
@ -206,7 +206,7 @@ sysctl_kern_geom_confxml(SYSCTL_HANDLER_ARGS)
sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
sbuf_clear(sb);
g_call_me(g_confxml, sb, NULL);
g_post_event(g_confxml, sb, M_WAITOK, NULL);
do {
tsleep(sb, PZERO, "g_confxml", hz);
} while(!sbuf_done(sb));

View File

@ -226,7 +226,7 @@ g_mbr_start(struct bio *bp)
* some I/O requests. Ask the event-handler to schedule
* us in a less restricted environment.
*/
error = g_call_me(g_mbr_ioctl, bp, gp, NULL);
error = g_post_event(g_mbr_ioctl, bp, M_NOWAIT, gp, NULL);
if (error)
g_io_deliver(bp, error);
/*

View File

@ -233,7 +233,7 @@ g_pc98_start(struct bio *bp)
* some I/O requests. Ask the event-handler to schedule
* us in a less restricted environment.
*/
error = g_call_me(g_pc98_ioctl, bp, gp, NULL);
error = g_post_event(g_pc98_ioctl, bp, M_NOWAIT, gp, NULL);
if (error)
g_io_deliver(bp, error);
/*

View File

@ -210,7 +210,8 @@ g_slice_start(struct bio *bp)
g_io_deliver(bp, error);
return;
case G_SLICE_HOT_CALL:
error = g_call_me(gsp->hot, bp, gp, NULL);
error = g_post_event(gsp->hot, bp, M_NOWAIT,
gp, NULL);
if (error)
g_io_deliver(bp, error);
return;

View File

@ -65,7 +65,7 @@ struct g_slicer {
void *softc;
g_slice_start_t *start;
g_call_me_t *hot;
g_event_t *hot;
};
g_dumpconf_t g_slice_dumpconf;

View File

@ -105,7 +105,7 @@ g_add_class(struct g_class *mp)
LIST_INIT(&mp->geom);
LIST_INSERT_HEAD(&g_classes, mp, class);
if (g_nproviders > 0 && mp->taste != NULL)
g_call_me(g_new_class_event, mp, mp, NULL);
g_post_event(g_new_class_event, mp, M_WAITOK, mp, NULL);
g_topology_unlock();
}
@ -242,7 +242,7 @@ g_new_providerf(struct g_geom *gp, const char *fmt, ...)
DEVSTAT_TYPE_DIRECT, DEVSTAT_PRIORITY_MAX);
LIST_INSERT_HEAD(&gp->provider, pp, provider);
g_nproviders++;
g_call_me(g_new_provider_event, pp, pp, NULL);
g_post_event(g_new_provider_event, pp, M_WAITOK, pp, NULL);
return (pp);
}
@ -491,7 +491,8 @@ g_access_rel(struct g_consumer *cp, int dcr, int dcw, int dce)
g_spoil(pp, cp);
else if (pp->acw != 0 && pp->acw == -dcw &&
!(pp->geom->flags & G_GEOM_WITHER))
g_call_me(g_new_provider_event, pp, pp, NULL);
g_post_event(g_new_provider_event, pp, M_WAITOK,
pp, NULL);
pp->acr += dcr;
pp->acw += dcw;
@ -633,7 +634,7 @@ g_spoil(struct g_provider *pp, struct g_consumer *cp)
KASSERT(cp2->ace == 0, ("spoiling cp->ace = %d", cp2->ace));
cp2->spoiled++;
}
g_call_me(g_spoil_event, pp, pp, NULL);
g_post_event(g_spoil_event, pp, M_WAITOK, pp, NULL);
}
int

View File

@ -194,15 +194,13 @@ g_sunlabel_config(struct gctl_req *req, struct g_geom *gp, const char *verb)
error = g_access_rel(cp, 1, 1, 1);
if (error)
return (error);
error = g_call_me(g_sunlabel_callconfig, &h0h0, gp, NULL);
if (!error) {
g_topology_unlock();
do
tsleep(&h0h0, PRIBIO, "g_sunlabel_config", hz);
while (h0h0.error == -1);
g_topology_lock();
error = h0h0.error;
}
g_post_event(g_sunlabel_callconfig, &h0h0, M_WAITOK, gp, NULL);
g_topology_unlock();
do
tsleep(&h0h0, PRIBIO, "g_sunlabel_config", hz);
while (h0h0.error == -1);
g_topology_lock();
error = h0h0.error;
g_access_rel(cp, -1, -1, -1);
g_free(label);
} else if (!strcmp(verb, "write bootcode")) {