- tweak RUN_ONCE api to allow init_func returns an error.
- physio: handle failure of workqueue_create.
This commit is contained in:
parent
330b298a42
commit
dae53410a7
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_lkm.c,v 1.88 2005/12/11 12:24:29 christos Exp $ */
|
||||
/* $NetBSD: kern_lkm.c,v 1.89 2006/01/16 21:45:38 yamt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Christopher G. Demetriou
|
||||
@ -41,7 +41,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_lkm.c,v 1.88 2005/12/11 12:24:29 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_lkm.c,v 1.89 2006/01/16 21:45:38 yamt Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_malloclog.h"
|
||||
@ -132,7 +132,7 @@ const struct cdevsw lkm_cdevsw = {
|
||||
|
||||
static ONCE_DECL(lkm_init_once);
|
||||
|
||||
static void
|
||||
static int
|
||||
lkm_init(void)
|
||||
{
|
||||
/*
|
||||
@ -141,6 +141,8 @@ lkm_init(void)
|
||||
*/
|
||||
if (lkm_map == NULL)
|
||||
lkm_map = kernel_map;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_physio.c,v 1.71 2006/01/04 10:13:05 yamt Exp $ */
|
||||
/* $NetBSD: kern_physio.c,v 1.72 2006/01/16 21:45:38 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1990, 1993
|
||||
@ -71,7 +71,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_physio.c,v 1.71 2006/01/04 10:13:05 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_physio.c,v 1.72 2006/01/16 21:45:38 yamt Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -244,16 +244,17 @@ physio_wait(struct buf *bp, int n, const char *wchan)
|
||||
return error;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
physio_init(void)
|
||||
{
|
||||
int error;
|
||||
|
||||
KASSERT(physio_workqueue == NULL);
|
||||
|
||||
if (workqueue_create(&physio_workqueue, "physiod",
|
||||
physio_done, NULL, PRIBIO, 0/* IPL_BIO notyet */, 0)) {
|
||||
panic("physiod create");
|
||||
}
|
||||
error = workqueue_create(&physio_workqueue, "physiod",
|
||||
physio_done, NULL, PRIBIO, 0/* IPL_BIO notyet */, 0);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
#define PHYSIO_CONCURRENCY 16 /* XXX tune */
|
||||
@ -272,13 +273,16 @@ physio(void (*strategy)(struct buf *), struct buf *obp, dev_t dev, int flags,
|
||||
struct lwp *l = curlwp;
|
||||
struct proc *p = l->l_proc;
|
||||
int i, s;
|
||||
int error = 0;
|
||||
int error;
|
||||
int error2;
|
||||
struct buf *bp = NULL;
|
||||
struct buf *mbp;
|
||||
int concurrency = PHYSIO_CONCURRENCY - 1;
|
||||
|
||||
RUN_ONCE(&physio_initialized, physio_init);
|
||||
error = RUN_ONCE(&physio_initialized, physio_init);
|
||||
if (__predict_false(error != 0)) {
|
||||
return error;
|
||||
}
|
||||
|
||||
DPRINTF(("%s: called: off=%" PRIu64 ", resid=%zu\n",
|
||||
__func__, uio->uio_offset, uio->uio_resid));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: subr_once.c,v 1.2 2005/12/11 12:24:30 christos Exp $ */
|
||||
/* $NetBSD: subr_once.c,v 1.3 2006/01/16 21:45:38 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c)2005 YAMAMOTO Takashi,
|
||||
@ -27,16 +27,17 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_once.c,v 1.2 2005/12/11 12:24:30 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_once.c,v 1.3 2006/01/16 21:45:38 yamt Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/once.h>
|
||||
|
||||
void
|
||||
_run_once(once_t *o, void (*fn)(void))
|
||||
int
|
||||
_run_once(once_t *o, int (*fn)(void))
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
simple_lock(&o->o_lock);
|
||||
while ((o->o_flags & ONCE_RUNNING) != 0) {
|
||||
@ -48,11 +49,15 @@ _run_once(once_t *o, void (*fn)(void))
|
||||
o->o_flags |= ONCE_RUNNING;
|
||||
simple_unlock(&o->o_lock);
|
||||
|
||||
(*fn)();
|
||||
error = (*fn)();
|
||||
|
||||
simple_lock(&o->o_lock);
|
||||
o->o_flags = ONCE_DONE;
|
||||
if (error == 0) {
|
||||
o->o_flags = ONCE_DONE;
|
||||
}
|
||||
wakeup(o);
|
||||
done:
|
||||
simple_unlock(&o->o_lock);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tty_conf.c,v 1.49 2005/12/11 12:24:30 christos Exp $ */
|
||||
/* $NetBSD: tty_conf.c,v 1.50 2006/01/16 21:45:38 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2005 The NetBSD Foundation, Inc.
|
||||
@ -73,7 +73,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: tty_conf.c,v 1.49 2005/12/11 12:24:30 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: tty_conf.c,v 1.50 2006/01/16 21:45:38 yamt Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -179,7 +179,7 @@ ttyerrpoll(struct tty *tp, int events, struct lwp *l)
|
||||
|
||||
static ONCE_DECL(ttyldisc_init_once);
|
||||
|
||||
static void
|
||||
static int
|
||||
ttyldisc_init(void)
|
||||
{
|
||||
|
||||
@ -187,6 +187,8 @@ ttyldisc_init(void)
|
||||
panic("ttyldisc_init: termios_disc");
|
||||
if (ttyldisc_attach(&ntty_disc) != 0)
|
||||
panic("ttyldisc_init: ntty_disc");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct linesw *
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ieee80211_netbsd.c,v 1.11 2005/12/04 19:15:21 christos Exp $ */
|
||||
/* $NetBSD: ieee80211_netbsd.c,v 1.12 2006/01/16 21:45:38 yamt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
|
||||
* All rights reserved.
|
||||
@ -30,7 +30,7 @@
|
||||
#ifdef __FreeBSD__
|
||||
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_freebsd.c,v 1.8 2005/08/08 18:46:35 sam Exp $");
|
||||
#else
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.11 2005/12/04 19:15:21 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.12 2006/01/16 21:45:38 yamt Exp $");
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -76,7 +76,7 @@ typedef void (*ieee80211_setup_func)(void);
|
||||
|
||||
__link_set_decl(ieee80211_funcs, ieee80211_setup_func);
|
||||
|
||||
static void
|
||||
static int
|
||||
ieee80211_init0(void)
|
||||
{
|
||||
ieee80211_setup_func * const *ieee80211_setup, f;
|
||||
@ -85,6 +85,8 @@ ieee80211_init0(void)
|
||||
f = (void*)*ieee80211_setup;
|
||||
(*f)();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nfs_subs.c,v 1.156 2005/12/11 12:25:16 christos Exp $ */
|
||||
/* $NetBSD: nfs_subs.c,v 1.157 2006/01/16 21:45:38 yamt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
@ -70,7 +70,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.156 2005/12/11 12:25:16 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.157 2006/01/16 21:45:38 yamt Exp $");
|
||||
|
||||
#include "fs_nfs.h"
|
||||
#include "opt_nfs.h"
|
||||
@ -1550,7 +1550,7 @@ nfs_invaldircache(vp, flags)
|
||||
* Called once before VFS init to initialize shared and
|
||||
* server-specific data structures.
|
||||
*/
|
||||
static void
|
||||
static int
|
||||
nfs_init0(void)
|
||||
{
|
||||
nfsrtt.pos = 0;
|
||||
@ -1607,6 +1607,7 @@ nfs_init0(void)
|
||||
/* Initialize the iod structures */
|
||||
nfs_iodinit();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: crypto.c,v 1.11 2005/11/25 16:16:46 thorpej Exp $ */
|
||||
/* $NetBSD: crypto.c,v 1.12 2006/01/16 21:45:38 yamt Exp $ */
|
||||
/* $FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $ */
|
||||
/* $OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $ */
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.11 2005/11/25 16:16:46 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.12 2006/01/16 21:45:38 yamt Exp $");
|
||||
|
||||
/* XXX FIXME: should be defopt'ed */
|
||||
#define CRYPTO_TIMING /* enable cryptop timing stuff */
|
||||
@ -178,7 +178,7 @@ SYSCTL_STRUCT(_kern, OID_AUTO, crypto_stats, CTLFLAG_RW, &cryptostats,
|
||||
cryptostats, "Crypto system statistics");
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
static void
|
||||
static int
|
||||
crypto_init0(void)
|
||||
{
|
||||
#ifdef __FreeBSD__
|
||||
@ -197,7 +197,7 @@ crypto_init0(void)
|
||||
sizeof(struct cryptocap), M_CRYPTO_DATA, M_NOWAIT | M_ZERO);
|
||||
if (crypto_drivers == NULL) {
|
||||
printf("crypto_init: cannot malloc driver table\n");
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
crypto_drivers_num = CRYPTO_DRIVERS_INITIAL;
|
||||
|
||||
@ -214,6 +214,7 @@ crypto_init0(void)
|
||||
/* defer thread creation until after boot */
|
||||
kthread_create( deferred_crypto_thread, NULL);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: once.h,v 1.2 2005/12/03 17:10:46 christos Exp $ */
|
||||
/* $NetBSD: once.h,v 1.3 2006/01/16 21:45:38 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c)2005 YAMAMOTO Takashi,
|
||||
@ -38,7 +38,7 @@ typedef struct {
|
||||
#define ONCE_DONE 2
|
||||
} once_t;
|
||||
|
||||
void _run_once(once_t *, void (*)(void));
|
||||
int _run_once(once_t *, int (*)(void));
|
||||
|
||||
#define ONCE_DECL(o) \
|
||||
once_t (o) = { \
|
||||
@ -47,10 +47,6 @@ void _run_once(once_t *, void (*)(void));
|
||||
};
|
||||
|
||||
#define RUN_ONCE(o, fn) \
|
||||
do { \
|
||||
if (__predict_false(((o)->o_flags & ONCE_DONE) == 0)) { \
|
||||
_run_once((o), (fn)); \
|
||||
} \
|
||||
} while (0 /* CONSTCOND */)
|
||||
(__predict_true(((o)->o_flags & ONCE_DONE) != 0) ? 0 : _run_once((o), (fn)))
|
||||
|
||||
#endif /* _SYS_ONCE_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user