lwkt_tokref_t ref;
lwkt_token_t tok;
- if (td->td_toks == NULL)
+ if (TD_TOKS_NOT_HELD(td))
return;
db_printf(" TOKENS:");
- for (ref = td->td_toks; ref; ref = ref->tr_next) {
+ for (ref = &td->td_toks_base; ref < td->td_toks_stop; ++ref) {
tok = ref->tr_tok;
db_printf(" %p[tok=%p", ref, ref->tr_tok);
struct pfsnode *pfs;
struct vnode *vp;
struct pfsnode **pp;
- lwkt_tokref ilock;
int error;
- lwkt_gettoken(&ilock, &pfs_token);
+ lwkt_gettoken(&pfs_token);
loop:
for (pfs = pfshead[pid & PFSHMASK]; pfs; pfs = pfs->pfs_next) {
vp = PFSTOV(pfs);
if (vget(vp, LK_EXCLUSIVE|LK_SLEEPFAIL))
goto loop;
*vpp = vp;
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&pfs_token);
return (0);
}
}
pfsvplock &= ~PROCFS_WANT;
wakeup((caddr_t) &pfsvplock);
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&pfs_token);
return (error);
}
{
struct pfsnode **pfspp;
struct pfsnode *pfs = VTOPFS(vp);
- lwkt_tokref ilock;
- lwkt_gettoken(&ilock, &pfs_token);
+ lwkt_gettoken(&pfs_token);
pfspp = &pfshead[pfs->pfs_pid & PFSHMASK];
while (*pfspp != pfs) {
KKASSERT(*pfspp != NULL);
pfspp = &(*pfspp)->pfs_next;
}
*pfspp = pfs->pfs_next;
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&pfs_token);
FREE(vp->v_data, M_TEMP);
vp->v_data = NULL;
return (0);
void
linprocfs_init(void)
{
- lwkt_token_init(&pfs_token);
+ lwkt_token_init(&pfs_token, 1);
}
void
linprocfs_exit(struct thread *td)
{
- lwkt_tokref ilock;
struct pfsnode *pfs;
struct vnode *vp;
pid_t pid;
/*
* Remove all the procfs vnodes associated with an exiting process.
*/
- lwkt_gettoken(&ilock, &pfs_token);
+ lwkt_gettoken(&pfs_token);
restart:
for (pfs = pfshead[pid & PFSHMASK]; pfs; pfs = pfs->pfs_next) {
if (pfs->pfs_pid == pid) {
goto restart;
}
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&pfs_token);
lwkt_token_uninit(&pfs_token);
}
{
struct ndis_req *r = NULL, *die = NULL;
struct ndisproc *p;
- struct lwkt_tokref tokref;
p = arg;
/* Look for any jobs on the work queue. */
- lwkt_gettoken(&tokref, &ndis_thr_token);
+ lwkt_gettoken(&ndis_thr_token);
p->np_state = NDIS_PSTATE_RUNNING;
while(STAILQ_FIRST(p->np_q) != NULL) {
r = STAILQ_FIRST(p->np_q);
STAILQ_REMOVE_HEAD(p->np_q, link);
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ndis_thr_token);
/* Do the work. */
if (r->nr_func != NULL)
(*r->nr_func)(r->nr_arg);
- lwkt_gettoken(&tokref, &ndis_thr_token);
+ lwkt_gettoken(&ndis_thr_token);
STAILQ_INSERT_HEAD(&ndis_free, r, link);
/* Check for a shutdown request */
die = r;
}
p->np_state = NDIS_PSTATE_SLEEPING;
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ndis_thr_token);
/* Bail if we were told to shut down. */
struct ndis_req *r;
int i, error = 0;
- lwkt_token_init(&ndis_thr_token);
+ lwkt_token_init(&ndis_thr_token, 1);
STAILQ_INIT(&ndis_ttodo);
STAILQ_INIT(&ndis_itodo);
struct ndis_req *r;
struct ndisqhead *q;
thread_t td;
- struct lwkt_tokref tokref;
if (t == NDIS_TASKQUEUE) {
q = &ndis_ttodo;
/* Create and post a special 'exit' job. */
- lwkt_gettoken(&tokref, &ndis_thr_token);
+ lwkt_gettoken(&ndis_thr_token);
r = STAILQ_FIRST(&ndis_free);
STAILQ_REMOVE_HEAD(&ndis_free, link);
r->nr_func = NULL;
r->nr_arg = NULL;
r->nr_exit = TRUE;
STAILQ_INSERT_TAIL(q, r, link);
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ndis_thr_token);
ndis_thresume(td);
/* Now empty the job list. */
- lwkt_gettoken(&tokref, &ndis_thr_token);
+ lwkt_gettoken(&ndis_thr_token);
while ((r = STAILQ_FIRST(q)) != NULL) {
STAILQ_REMOVE_HEAD(q, link);
STAILQ_INSERT_HEAD(&ndis_free, r, link);
}
- lwkt_reltoken(&tokref);
-
- return;
+ lwkt_reltoken(&ndis_thr_token);
}
static int
{
struct ndis_req *r;
int i;
- struct lwkt_tokref tokref;
for (i = 0; i < cnt; i++) {
r = kmalloc(sizeof(struct ndis_req), M_DEVBUF, M_WAITOK);
- lwkt_gettoken(&tokref, &ndis_thr_token);
+ lwkt_gettoken(&ndis_thr_token);
STAILQ_INSERT_HEAD(&ndis_free, r, link);
ndis_jobs++;
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ndis_thr_token);
}
return(0);
{
struct ndis_req *r;
int i;
- struct lwkt_tokref tokref;
for (i = 0; i < cnt; i++) {
- lwkt_gettoken(&tokref, &ndis_thr_token);
+ lwkt_gettoken(&ndis_thr_token);
r = STAILQ_FIRST(&ndis_free);
if (r == NULL) {
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ndis_thr_token);
return(ENOMEM);
}
STAILQ_REMOVE_HEAD(&ndis_free, link);
ndis_jobs--;
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ndis_thr_token);
kfree(r, M_DEVBUF);
}
struct ndis_req *r;
struct ndisqhead *q;
thread_t td;
- struct lwkt_tokref tokref;
if (t == NDIS_TASKQUEUE) {
q = &ndis_ttodo;
td = ndis_iproc.np_td;
}
- lwkt_gettoken(&tokref, &ndis_thr_token);
+ lwkt_gettoken(&ndis_thr_token);
STAILQ_FOREACH(r, q, link) {
if (r->nr_func == func && r->nr_arg == arg) {
STAILQ_REMOVE(q, r, ndis_req, link);
STAILQ_INSERT_HEAD(&ndis_free, r, link);
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ndis_thr_token);
return(0);
}
}
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ndis_thr_token);
return(ENOENT);
}
struct ndisqhead *q;
thread_t td;
int s;
- struct lwkt_tokref tokref;
if (t == NDIS_TASKQUEUE) {
q = &ndis_ttodo;
td = ndis_iproc.np_td;
}
- lwkt_gettoken(&tokref, &ndis_thr_token);
+ lwkt_gettoken(&ndis_thr_token);
/*
* Check to see if an instance of this job is already
* pending. If so, don't bother queuing it again.
*/
STAILQ_FOREACH(r, q, link) {
if (r->nr_func == func && r->nr_arg == arg) {
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ndis_thr_token);
return(0);
}
}
r = STAILQ_FIRST(&ndis_free);
if (r == NULL) {
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ndis_thr_token);
return(EAGAIN);
}
STAILQ_REMOVE_HEAD(&ndis_free, link);
s = ndis_tproc.np_state;
else
s = ndis_iproc.np_state;
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ndis_thr_token);
/*
* Post the job, but only if the thread is actually blocked
int
ntoskrnl_libinit(void)
{
- lwkt_token_init(&ntoskrnl_dispatchtoken);
+ lwkt_token_init(&ntoskrnl_dispatchtoken, 1);
ntoskrnl_init_lock(&ntoskrnl_global);
TAILQ_INIT(&ntoskrnl_reflist);
return(0);
wait_block *w;
list_entry *e;
struct thread *td;
- struct lwkt_tokref tokref;
obj = arg;
- lwkt_gettoken(&tokref, &ntoskrnl_dispatchtoken);
+ lwkt_gettoken(&ntoskrnl_dispatchtoken);
obj->dh_sigstate = TRUE;
e = obj->dh_waitlisthead.nle_flink;
while (e != &obj->dh_waitlisthead) {
break;
e = e->nle_flink;
}
- lwkt_reltoken(&tokref);
-
- return;
+ lwkt_reltoken(&ntoskrnl_dispatchtoken);
}
static void
int error = 0;
int ticks;
uint64_t curtime;
- struct lwkt_tokref tokref;
if (obj == NULL)
return(STATUS_INVALID_PARAMETER);
- lwkt_gettoken(&tokref, &ntoskrnl_dispatchtoken);
+ lwkt_gettoken(&ntoskrnl_dispatchtoken);
/*
* See if the object is a mutex. If so, and we already own
obj->dh_sigstate = FALSE;
km->km_acquirecnt++;
km->km_ownerthread = curthread->td_proc;
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ntoskrnl_dispatchtoken);
return (STATUS_SUCCESS);
}
} else if (obj->dh_sigstate == TRUE) {
if (obj->dh_type == EVENT_TYPE_SYNC)
obj->dh_sigstate = FALSE;
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ntoskrnl_dispatchtoken);
return (STATUS_SUCCESS);
}
}
}
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ntoskrnl_dispatchtoken);
ticks = 1 + tv.tv_sec * hz + tv.tv_usec * hz / 1000000;
error = ndis_thsuspend(td, duetime == NULL ? 0 : ticks);
if (error == EWOULDBLOCK) {
REMOVE_LIST_ENTRY((&w.wb_waitlist));
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ntoskrnl_dispatchtoken);
return(STATUS_TIMEOUT);
}
obj->dh_sigstate = FALSE;
REMOVE_LIST_ENTRY((&w.wb_waitlist));
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ntoskrnl_dispatchtoken);
return(STATUS_SUCCESS);
}
int i, wcnt = 0, widx = 0, error = 0;
uint64_t curtime;
struct timespec t1, t2;
- struct lwkt_tokref tokref;
if (cnt > MAX_WAIT_OBJECTS)
return(STATUS_INVALID_PARAMETER);
if (cnt > THREAD_WAIT_OBJECTS && wb_array == NULL)
return(STATUS_INVALID_PARAMETER);
- lwkt_gettoken(&tokref, &ntoskrnl_dispatchtoken);
+ lwkt_gettoken(&ntoskrnl_dispatchtoken);
if (wb_array == NULL)
w = &_wb_array[0];
km->km_acquirecnt++;
km->km_ownerthread = curthread->td_proc;
if (wtype == WAITTYPE_ANY) {
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ntoskrnl_dispatchtoken);
return (STATUS_WAIT_0 + i);
}
}
if (obj[i]->dh_type == EVENT_TYPE_SYNC)
obj[i]->dh_sigstate = FALSE;
if (wtype == WAITTYPE_ANY) {
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ntoskrnl_dispatchtoken);
return (STATUS_WAIT_0 + i);
}
}
while (wcnt) {
nanotime(&t1);
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ntoskrnl_dispatchtoken);
if (duetime) {
ticks = 1 + tv.tv_sec * hz + tv.tv_usec * hz / 1000000;
error = ndis_thsuspend(td, 0);
}
- lwkt_gettoken(&tokref, &ntoskrnl_dispatchtoken);
+ lwkt_gettoken(&ntoskrnl_dispatchtoken);
nanotime(&t2);
for (i = 0; i < cnt; i++) {
}
if (error == EWOULDBLOCK) {
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ntoskrnl_dispatchtoken);
return(STATUS_TIMEOUT);
}
if (wtype == WAITTYPE_ANY && wcnt) {
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ntoskrnl_dispatchtoken);
return(STATUS_WAIT_0 + widx);
}
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ntoskrnl_dispatchtoken);
return(STATUS_SUCCESS);
}
__stdcall static uint32_t
ntoskrnl_release_mutex(kmutant *kmutex, uint8_t kwait)
{
- struct lwkt_tokref tokref;
-
- lwkt_gettoken(&tokref, &ntoskrnl_dispatchtoken);
+ lwkt_gettoken(&ntoskrnl_dispatchtoken);
if (kmutex->km_ownerthread != curthread->td_proc) {
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ntoskrnl_dispatchtoken);
return(STATUS_MUTANT_NOT_OWNED);
}
kmutex->km_acquirecnt--;
if (kmutex->km_acquirecnt == 0) {
kmutex->km_ownerthread = NULL;
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ntoskrnl_dispatchtoken);
ntoskrnl_wakeup(&kmutex->km_header);
- } else
- lwkt_reltoken(&tokref);
+ } else {
+ lwkt_reltoken(&ntoskrnl_dispatchtoken);
+ }
return(kmutex->km_acquirecnt);
}
ntoskrnl_reset_event(nt_kevent *kevent)
{
uint32_t prevstate;
- struct lwkt_tokref tokref;
- lwkt_gettoken(&tokref, &ntoskrnl_dispatchtoken);
+ lwkt_gettoken(&ntoskrnl_dispatchtoken);
prevstate = kevent->k_header.dh_sigstate;
kevent->k_header.dh_sigstate = FALSE;
- lwkt_reltoken(&tokref);
+ lwkt_reltoken(&ntoskrnl_dispatchtoken);
return(prevstate);
}
struct proc *owner;
off_t start, end;
int type, flags, error;
- lwkt_tokref ilock;
+ lwkt_token_t token;
/*
* Convert the flock structure into a start and end.
/*
* Do the requested operation.
*/
- lwkt_getpooltoken(&ilock, lock);
+ token = lwkt_getpooltoken(lock);
if (lock->init_done == 0) {
TAILQ_INIT(&lock->lf_range);
error = EINVAL;
break;
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(token);
return(error);
}
/*
- * Copyright (c) 2003,2004 The DragonFly Project. All rights reserved.
+ * Copyright (c) 2003-2010 The DragonFly Project. All rights reserved.
*
* This code is derived from software contributed to The DragonFly Project
* by Matthew Dillon <dillon@backplane.com>
td->td_flags = flags;
td->td_gd = gd;
td->td_pri = TDPRI_KERN_DAEMON + TDPRI_CRIT;
+ td->td_toks_stop = &td->td_toks_base;
#ifdef SMP
if ((flags & TDF_MPSAFE) == 0)
td->td_mpcount = 1;
td->td_release(td);
crit_enter_gd(gd);
- if (td->td_toks)
+ if (TD_TOKS_HELD(td))
lwkt_relalltokens(td);
/*
* cause the core MP lock to be released.
*/
if ((ntd->td_mpcount && mpheld == 0 && !cpu_try_mplock()) ||
- (ntd->td_toks && lwkt_getalltokens(ntd) == 0)
+ (TD_TOKS_HELD(ntd) && lwkt_getalltokens(ntd) == 0)
) {
u_int32_t rqmask = gd->gd_runqmask;
* failure, but the variable is only needed for
* the loop.
*/
- if (ntd->td_toks && !lwkt_getalltokens(ntd)) {
+ if (TD_TOKS_HELD(ntd) && !lwkt_getalltokens(ntd)) {
/* spinning due to token contention */
#ifdef INVARIANTS
++token_contention_count;
need_lwkt_resched();
return;
}
- if (ntd->td_toks) {
+ if (TD_TOKS_HELD(ntd)) {
++preempt_miss;
need_lwkt_resched();
return;
#include <sys/thread2.h>
#include <sys/spinlock2.h>
+#include <sys/mplock2.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
return(&pool_tokens[i & LWKT_MASK_POOL_TOKENS]);
}
+/*
+ * Initialize a tokref_t prior to making it visible in the thread's
+ * token array.
+ */
+static __inline
+void
+_lwkt_tokref_init(lwkt_tokref_t ref, lwkt_token_t tok, thread_t td)
+{
+ ref->tr_tok = tok;
+ ref->tr_owner = td;
+ ref->tr_flags = tok->t_flags;
+}
/*
* Obtain all the tokens required by the specified thread on the current
* lwkt_getalltokens is called by the LWKT scheduler to acquire all
* tokens that the thread had acquired prior to going to sleep.
*
+ * The scheduler is responsible for maintaining the MP lock count, so
+ * we don't need to deal with tr_flags here.
+ *
* Called from a critical section.
*/
int
lwkt_getalltokens(thread_t td)
{
- lwkt_tokref_t scan1;
- lwkt_tokref_t scan2;
+ lwkt_tokref_t scan;
lwkt_tokref_t ref;
lwkt_token_t tok;
- for (scan1 = td->td_toks; scan1; scan1 = scan1->tr_next) {
- tok = scan1->tr_tok;
+ /*
+ * Acquire tokens in forward order, assign or validate tok->t_ref.
+ */
+ for (scan = &td->td_toks_base; scan < td->td_toks_stop; ++scan) {
+ tok = scan->tr_tok;
for (;;) {
/*
* Try to acquire the token if we do not already have
* lost a cpu race.
*/
ref = tok->t_ref;
- if (ref == scan1)
- break;
if (ref == NULL) {
- if (atomic_cmpset_ptr(&tok->t_ref, NULL, scan1))
+ if (atomic_cmpset_ptr(&tok->t_ref, NULL, scan))
break;
continue;
}
/*
- * If acquisition fails the token might be held
- * recursively by another ref owned by the same
- * thread.
- *
- * NOTE! We cannot just dereference 'ref' to test
- * the tr_owner as its storage will be
- * unstable if it belongs to another thread.
- *
- * NOTE! Since tokens are inserted at the head
- * of the list we must migrate such tokens
- * so the actual lock is not cleared until
- * the last release.
+ * Test if ref is already recursively held by this
+ * thread. We cannot safely dereference tok->t_ref
+ * (it might belong to another thread and is thus
+ * unstable), but we don't have to. We can simply
+ * range-check it.
*/
- scan2 = td->td_toks;
- for (;;) {
- if (scan2 == scan1) {
- lwkt_relalltokens(td);
- return(FALSE);
- }
- if (scan2 == ref) {
- tok->t_ref = scan1;
- break;
- }
- scan2 = scan2->tr_next;
- }
- break;
+ if (ref >= &td->td_toks_base && ref < td->td_toks_stop)
+ break;
+
+ /*
+ * Otherwise we failed to acquire all the tokens.
+ * Undo and return.
+ */
+ lwkt_relalltokens(td);
+ return(FALSE);
}
}
return (TRUE);
* This code is really simple. Even in cases where we own all the tokens
* note that t_ref may not match the scan for recursively held tokens,
* or for the case where a lwkt_getalltokens() failed.
+ *
+ * The scheduler is responsible for maintaining the MP lock count, so
+ * we don't need to deal with tr_flags here.
*
* Called from a critical section.
*/
void
lwkt_relalltokens(thread_t td)
{
- lwkt_tokref_t scan1;
+ lwkt_tokref_t scan;
lwkt_token_t tok;
- for (scan1 = td->td_toks; scan1; scan1 = scan1->tr_next) {
- tok = scan1->tr_tok;
- if (tok->t_ref == scan1)
+ for (scan = &td->td_toks_base; scan < td->td_toks_stop; ++scan) {
+ tok = scan->tr_tok;
+ if (tok->t_ref == scan)
tok->t_ref = NULL;
}
}
/*
- * Token acquisition helper function. Note that get/trytokenref do not
- * reset t_lastowner if the token is already held. Only lwkt_token_is_stale()
- * is allowed to do that.
+ * Token acquisition helper function. The caller must have already
+ * made nref visible by adjusting td_toks_stop and will be responsible
+ * for the disposition of nref on either success or failure.
*
- * NOTE: On failure, this function doesn't remove the token from the
- * thread's token list, so that you have to perform that yourself:
- *
- * td->td_toks = ref->tr_next;
+ * When acquiring tokens recursively we want tok->t_ref to point to
+ * the outer (first) acquisition so it gets cleared only on the last
+ * release.
*/
static __inline
int
_lwkt_trytokref2(lwkt_tokref_t nref, thread_t td)
{
- lwkt_tokref_t ref;
- lwkt_tokref_t scan2;
lwkt_token_t tok;
+ lwkt_tokref_t ref;
KKASSERT(td->td_gd->gd_intr_nesting_level == 0);
/*
- * Link the tokref into curthread's list. Make sure the
- * cpu does not reorder these instructions!
+ * Make sure the compiler does not reorder prior instructions
+ * beyond this demark.
*/
- nref->tr_next = td->td_toks;
- cpu_ccfence();
- td->td_toks = nref;
cpu_ccfence();
/*
* it.
*/
ref = tok->t_ref;
- if (ref == nref)
- return (TRUE);
if (ref == NULL) {
/*
* NOTE: If atomic_cmpset_ptr() fails we have to
}
/*
- * If acquisition fails the token might be held
- * recursively by another ref owned by the same
- * thread.
- *
- * NOTE! We cannot just dereference 'ref' to test
- * the tr_owner as its storage will be
- * unstable if it belongs to another thread.
- *
- * NOTE! We do not migrate t_ref to nref here as we
- * want the recursion unwinding in reverse order
- * to NOT release the token until last the
- * recursive ref is released.
+ * Test if ref is already recursively held by this
+ * thread. We cannot safely dereference tok->t_ref
+ * (it might belong to another thread and is thus
+ * unstable), but we don't have to. We can simply
+ * range-check it.
+ */
+ if (ref >= &td->td_toks_base && ref < td->td_toks_stop)
+ return(TRUE);
+
+ /*
+ * Otherwise we failed.
*/
- for (scan2 = nref->tr_next; scan2; scan2 = scan2->tr_next) {
- if (scan2 == ref)
- return(TRUE);
- }
return(FALSE);
}
}
int
_lwkt_trytokref(lwkt_tokref_t ref, thread_t td)
{
+ if ((ref->tr_flags & LWKT_TOKEN_MPSAFE) == 0) {
+ if (try_mplock() == 0)
+ return (FALSE);
+ }
if (_lwkt_trytokref2(ref, td) == FALSE) {
/*
- * Cleanup. Remove the token from the thread's list.
+ * Cleanup, deactivate the failed token.
*/
- td->td_toks = ref->tr_next;
+ --td->td_toks_stop;
+ if ((ref->tr_flags & LWKT_TOKEN_MPSAFE) == 0)
+ rel_mplock();
return (FALSE);
}
return (TRUE);
void
_lwkt_gettokref(lwkt_tokref_t ref, thread_t td)
{
+ if ((ref->tr_flags & LWKT_TOKEN_MPSAFE) == 0)
+ get_mplock();
if (_lwkt_trytokref2(ref, td) == FALSE) {
/*
* Give up running if we can't acquire the token right now.
- * But as we have linked in the tokref to the thread's list
- * (_lwkt_trytokref2), the scheduler now takes care to acquire
- * the token (by calling lwkt_getalltokens) before resuming
- * execution. As such, when we return from lwkt_yield(),
- * the token is acquired.
*
- * Since we failed this is not a recursive token so upon
+ * Since the tokref is already active the scheduler now
+ * takes care of acquisition, so we need only call
+ * lwkt_yield().
+ *
+ * Since we failed this was not a recursive token so upon
* return tr_tok->t_ref should be assigned to this specific
* ref.
*/
logtoken(fail, ref);
lwkt_yield();
logtoken(succ, ref);
-#if 0
- if (ref->tr_tok->t_ref != ref) {
- lwkt_tokref_t scan;
- kprintf("gettokref %p failed, held by tok %p ref %p\n",
- ref, ref->tr_tok, ref->tr_tok->t_ref);
- for (scan = td->td_toks; scan; scan = scan->tr_next) {
- kprintf(" %p\n", scan);
- }
- }
-#endif
KKASSERT(ref->tr_tok->t_ref == ref);
}
}
void
-lwkt_gettoken(lwkt_tokref_t ref, lwkt_token_t tok)
+lwkt_gettoken(lwkt_token_t tok)
{
thread_t td = curthread;
+ lwkt_tokref_t ref;
- lwkt_tokref_init(ref, tok, td);
+ ref = td->td_toks_stop;
+ KKASSERT(ref < &td->td_toks_end);
+ _lwkt_tokref_init(ref, tok, td);
+ ++td->td_toks_stop;
_lwkt_gettokref(ref, td);
}
-void
-lwkt_getpooltoken(lwkt_tokref_t ref, void *ptr)
+lwkt_token_t
+lwkt_getpooltoken(void *ptr)
{
thread_t td = curthread;
+ lwkt_token_t tok;
+ lwkt_tokref_t ref;
- lwkt_tokref_init(ref, _lwkt_token_pool_lookup(ptr), td);
+ ref = td->td_toks_stop;
+ KKASSERT(ref < &td->td_toks_end);
+ tok = _lwkt_token_pool_lookup(ptr);
+ _lwkt_tokref_init(ref, tok, td);
+ ++td->td_toks_stop;
_lwkt_gettokref(ref, td);
-}
-
-void
-lwkt_gettokref(lwkt_tokref_t ref)
-{
- _lwkt_gettokref(ref, ref->tr_owner);
+ return(tok);
}
int
-lwkt_trytoken(lwkt_tokref_t ref, lwkt_token_t tok)
+lwkt_trytoken(lwkt_token_t tok)
{
thread_t td = curthread;
+ lwkt_tokref_t ref;
- lwkt_tokref_init(ref, tok, td);
+ ref = td->td_toks_stop;
+ KKASSERT(ref < &td->td_toks_end);
+ _lwkt_tokref_init(ref, tok, td);
+ ++td->td_toks_stop;
return(_lwkt_trytokref(ref, td));
}
-int
-lwkt_trytokref(lwkt_tokref_t ref)
-{
- return(_lwkt_trytokref(ref, ref->tr_owner));
-}
-
/*
* Release a serializing token.
*
- * WARNING! Any recursive tokens must be released in reverse order.
+ * WARNING! All tokens must be released in reverse order. This will be
+ * asserted.
*/
void
-lwkt_reltoken(lwkt_tokref_t ref)
+lwkt_reltoken(lwkt_token_t tok)
{
- struct lwkt_tokref **scanp;
- lwkt_token_t tok;
- thread_t td;
+ thread_t td = curthread;
+ lwkt_tokref_t ref;
- tok = ref->tr_tok;
+ /*
+ * Remove ref from thread token list and assert that it matches
+ * the token passed in. Tokens must be released in reverse order.
+ */
+ ref = td->td_toks_stop - 1;
+ KKASSERT(ref >= &td->td_toks_base && ref->tr_tok == tok);
+ td->td_toks_stop = ref;
+
+ /*
+ * If the token was not MPSAFE release the MP lock.
+ */
+ if ((ref->tr_flags & LWKT_TOKEN_MPSAFE) == 0)
+ rel_mplock();
/*
- * Remove the ref from the thread's token list.
- *
- * NOTE: td == curthread
+ * Make sure the compiler does not reorder the clearing of
+ * tok->t_ref.
*/
- td = ref->tr_owner;
- for (scanp = &td->td_toks; *scanp != ref; scanp = &((*scanp)->tr_next))
- ;
- *scanp = ref->tr_next;
cpu_ccfence();
/*
int i;
for (i = 0; i < LWKT_NUM_POOL_TOKENS; ++i)
- lwkt_token_init(&pool_tokens[i]);
+ lwkt_token_init(&pool_tokens[i], 1);
}
lwkt_token_t
* and reset the generation count.
*/
void
-lwkt_token_init(lwkt_token_t tok)
+lwkt_token_init(lwkt_token_t tok, int mpsafe)
{
tok->t_ref = NULL;
+ tok->t_flags = mpsafe ? LWKT_TOKEN_MPSAFE : 0;
}
void
{
struct disk *dp;
struct diskslice *sp;
- lwkt_tokref ilock;
disk_msg_t msg;
int run;
dp->d_cdev->si_name);
devfs_destroy_subnames(dp->d_cdev->si_name);
devfs_destroy_dev(dp->d_cdev);
- lwkt_gettoken(&ilock, &disklist_token);
+ lwkt_gettoken(&disklist_token);
LIST_REMOVE(dp, d_list);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&disklist_token);
if (dp->d_info.d_serialno) {
kfree(dp->d_info.d_serialno, M_TEMP);
dp->d_info.d_serialno = NULL;
cdev_t
disk_create(int unit, struct disk *dp, struct dev_ops *raw_ops)
{
- lwkt_tokref ilock;
cdev_t rawdev;
disk_debug(1,
dsched_disk_create_callback(dp, raw_ops->head.name, unit);
- lwkt_gettoken(&ilock, &disklist_token);
+ lwkt_gettoken(&disklist_token);
LIST_INSERT_HEAD(&disklist, dp, d_list);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&disklist_token);
- disk_debug(1,
- "disk_create (end): %s%d\n",
- raw_ops->head.name, unit);
+ disk_debug(1, "disk_create (end): %s%d\n", raw_ops->head.name, unit);
return (dp->d_rawdev);
}
disk_enumerate(struct disk *disk)
{
struct disk *dp;
- lwkt_tokref ilock;
- lwkt_gettoken(&ilock, &disklist_token);
+ lwkt_gettoken(&disklist_token);
if (!disk)
dp = (LIST_FIRST(&disklist));
else
dp = (LIST_NEXT(disk, d_list));
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&disklist_token);
return dp;
}
objcache_malloc_free,
&disk_msg_malloc_args);
- lwkt_token_init(&disklist_token);
+ lwkt_token_init(&disklist_token, 1);
/*
* Initialize the reply-only port which acts as a message drain
static void
kobj_init_token(void *arg)
{
- lwkt_token_init(&kobj_token);
+ lwkt_token_init(&kobj_token, 1);
}
SYSINIT(kobj, SI_BOOT1_LOCK, SI_ORDER_ANY, kobj_init_token, NULL);
void
kobj_class_instantiate(kobj_class_t cls)
{
- lwkt_tokref ilock;
-
- lwkt_gettoken(&ilock, &kobj_token);
+ lwkt_gettoken(&kobj_token);
crit_enter();
if (!cls->ops)
cls->refs++;
crit_exit();
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&kobj_token);
}
void
kobj_class_uninstantiate(kobj_class_t cls)
{
- lwkt_tokref ilock;
-
- lwkt_gettoken(&ilock, &kobj_token);
+ lwkt_gettoken(&kobj_token);
crit_enter();
cls->refs--;
kobj_class_free(cls);
crit_exit();
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&kobj_token);
}
kobj_t
rman_init(struct rman *rm)
{
static int once;
- lwkt_tokref ilock;
if (once == 0) {
once = 1;
TAILQ_INIT(&rman_head);
- lwkt_token_init(&rman_tok);
+ lwkt_token_init(&rman_tok, 1);
}
if (rm->rm_type == RMAN_UNINIT)
rm->rm_slock = kmalloc(sizeof *rm->rm_slock, M_RMAN, M_NOWAIT);
if (rm->rm_slock == NULL)
return ENOMEM;
- lwkt_token_init(rm->rm_slock);
+ lwkt_token_init(rm->rm_slock, 1);
- lwkt_gettoken(&ilock, &rman_tok);
+ lwkt_gettoken(&rman_tok);
TAILQ_INSERT_TAIL(&rman_head, rm, rm_link);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&rman_tok);
return 0;
}
rman_manage_region(struct rman *rm, u_long start, u_long end)
{
struct resource *r, *s;
- lwkt_tokref ilock;
DPRINTF(("rman_manage_region: <%s> request: start %#lx, end %#lx\n",
rm->rm_descr, start, end));
r->r_dev = 0;
r->r_rm = rm;
- lwkt_gettoken(&ilock, rm->rm_slock);
+ lwkt_gettoken(rm->rm_slock);
for (s = TAILQ_FIRST(&rm->rm_list);
s && s->r_end < r->r_start;
s = TAILQ_NEXT(s, r_link))
else
TAILQ_INSERT_BEFORE(s, r, r_link);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(rm->rm_slock);
return 0;
}
rman_fini(struct rman *rm)
{
struct resource *r;
- lwkt_tokref ilock;
- lwkt_gettoken(&ilock, rm->rm_slock);
+ lwkt_gettoken(rm->rm_slock);
TAILQ_FOREACH(r, &rm->rm_list, r_link) {
if (r->r_flags & RF_ALLOCATED) {
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(rm->rm_slock);
return EBUSY;
}
}
TAILQ_REMOVE(&rm->rm_list, r, r_link);
kfree(r, M_RMAN);
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(rm->rm_slock);
+
/* XXX what's the point of this if we are going to free the struct? */
- lwkt_gettoken(&ilock, &rman_tok);
+ lwkt_gettoken(&rman_tok);
TAILQ_REMOVE(&rman_head, rm, rm_link);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&rman_tok);
kfree(rm->rm_slock, M_RMAN);
return 0;
u_int want_activate;
struct resource *r, *s, *rv;
u_long rstart, rend;
- lwkt_tokref ilock;
rv = 0;
want_activate = (flags & RF_ACTIVE);
flags &= ~RF_ACTIVE;
- lwkt_gettoken(&ilock, rm->rm_slock);
+ lwkt_gettoken(rm->rm_slock);
for (r = TAILQ_FIRST(&rm->rm_list);
r && r->r_end < start;
rv = 0;
}
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(rm->rm_slock);
return (rv);
}
{
int rv;
struct resource *whohas;
- lwkt_tokref ilock;
struct rman *rm;
rm = r->r_rm;
- lwkt_gettoken(&ilock, rm->rm_slock);
+ lwkt_gettoken(rm->rm_slock);
rv = int_rman_activate_resource(rm, r, &whohas);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(rm->rm_slock);
return rv;
}
/* XXX */
int
-rman_await_resource(struct resource *r, lwkt_tokref_t ilock, int slpflags, int timo)
+rman_await_resource(struct resource *r, int slpflags, int timo)
{
int rv;
struct resource *whohas;
rm = r->r_rm;
for (;;) {
- lwkt_gettoken(ilock, rm->rm_slock);
+ lwkt_gettoken(rm->rm_slock);
rv = int_rman_activate_resource(rm, r, &whohas);
if (rv != EBUSY)
return (rv); /* returns with ilock held */
whohas->r_flags |= RF_WANTED;
rv = tsleep(r->r_sharehead, slpflags, "rmwait", timo);
if (rv) {
- lwkt_reltoken(ilock);
+ lwkt_reltoken(rm->rm_slock);
crit_exit();
return rv;
}
int
rman_deactivate_resource(struct resource *r)
{
- lwkt_tokref ilock;
struct rman *rm;
rm = r->r_rm;
- lwkt_gettoken(&ilock, rm->rm_slock);
+ lwkt_gettoken(rm->rm_slock);
int_rman_deactivate_resource(r);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(rm->rm_slock);
return 0;
}
rman_release_resource(struct resource *r)
{
struct rman *rm = r->r_rm;
- lwkt_tokref ilock;
int rv;
- lwkt_gettoken(&ilock, rm->rm_slock);
+ lwkt_gettoken(rm->rm_slock);
rv = int_rman_release_resource(rm, r);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(rm->rm_slock);
return (rv);
}
vfs_timestamp(&cpipe->pipe_ctime);
cpipe->pipe_atime = cpipe->pipe_ctime;
cpipe->pipe_mtime = cpipe->pipe_ctime;
- lwkt_token_init(&cpipe->pipe_rlock);
- lwkt_token_init(&cpipe->pipe_wlock);
+ lwkt_token_init(&cpipe->pipe_rlock, 1);
+ lwkt_token_init(&cpipe->pipe_wlock, 1);
return (0);
}
u_int nsize; /* total bytes to read */
u_int rindex; /* contiguous bytes available */
int notify_writer;
- lwkt_tokref rlock;
- lwkt_tokref wlock;
int mpsave;
int bigread;
int bigcount;
*/
pipe_get_mplock(&mpsave);
rpipe = (struct pipe *)fp->f_data;
- lwkt_gettoken(&rlock, &rpipe->pipe_rlock);
+ lwkt_gettoken(&rpipe->pipe_rlock);
if (fflags & O_FBLOCKING)
nbio = 0;
error = pipe_start_uio(rpipe, &rpipe->pipe_rip);
if (error) {
pipe_rel_mplock(&mpsave);
- lwkt_reltoken(&rlock);
+ lwkt_reltoken(&rpipe->pipe_rlock);
return (error);
}
notify_writer = 0;
* wlock are held.
*/
if (rpipe->pipe_state & PIPE_WANTW) {
- lwkt_gettoken(&wlock, &rpipe->pipe_wlock);
+ lwkt_gettoken(&rpipe->pipe_wlock);
if (rpipe->pipe_state & PIPE_WANTW) {
notify_writer = 0;
rpipe->pipe_state &= ~PIPE_WANTW;
- lwkt_reltoken(&wlock);
+ lwkt_reltoken(&rpipe->pipe_wlock);
wakeup(rpipe);
} else {
- lwkt_reltoken(&wlock);
+ lwkt_reltoken(&rpipe->pipe_wlock);
}
}
/*
* Last chance, interlock with WANTR.
*/
- lwkt_gettoken(&wlock, &rpipe->pipe_wlock);
+ lwkt_gettoken(&rpipe->pipe_wlock);
size = rpipe->pipe_buffer.windex - rpipe->pipe_buffer.rindex;
if (size) {
- lwkt_reltoken(&wlock);
+ lwkt_reltoken(&rpipe->pipe_wlock);
continue;
}
* tokens already held.
*/
if (rpipe->pipe_state & PIPE_REOF) {
- lwkt_reltoken(&wlock);
+ lwkt_reltoken(&rpipe->pipe_wlock);
break;
}
*/
rpipe->pipe_state |= PIPE_WANTR;
tsleep_interlock(rpipe, PCATCH);
- lwkt_reltoken(&wlock);
+ lwkt_reltoken(&rpipe->pipe_wlock);
error = tsleep(rpipe, PCATCH | PINTERLOCKED, "piperd", 0);
++pipe_rblocked_count;
if (error)
*/
if (notify_writer) {
if (rpipe->pipe_state & PIPE_WANTW) {
- lwkt_gettoken(&wlock, &rpipe->pipe_wlock);
+ lwkt_gettoken(&rpipe->pipe_wlock);
if (rpipe->pipe_state & PIPE_WANTW) {
rpipe->pipe_state &= ~PIPE_WANTW;
- lwkt_reltoken(&wlock);
+ lwkt_reltoken(&rpipe->pipe_wlock);
wakeup(rpipe);
} else {
- lwkt_reltoken(&wlock);
+ lwkt_reltoken(&rpipe->pipe_wlock);
}
}
if (pipeseltest(rpipe)) {
- lwkt_gettoken(&wlock, &rpipe->pipe_wlock);
+ lwkt_gettoken(&rpipe->pipe_wlock);
pipeselwakeup(rpipe);
- lwkt_reltoken(&wlock);
+ lwkt_reltoken(&rpipe->pipe_wlock);
}
}
/*size = rpipe->pipe_buffer.windex - rpipe->pipe_buffer.rindex;*/
- lwkt_reltoken(&rlock);
+ lwkt_reltoken(&rpipe->pipe_rlock);
pipe_rel_mplock(&mpsave);
return (error);
int orig_resid;
int nbio;
struct pipe *wpipe, *rpipe;
- lwkt_tokref rlock;
- lwkt_tokref wlock;
u_int windex;
u_int space;
u_int wcount;
*/
rpipe = (struct pipe *) fp->f_data;
wpipe = rpipe->pipe_peer;
- lwkt_gettoken(&wlock, &wpipe->pipe_wlock);
+ lwkt_gettoken(&wpipe->pipe_wlock);
if (wpipe->pipe_state & PIPE_WEOF) {
pipe_rel_mplock(&mpsave);
- lwkt_reltoken(&wlock);
+ lwkt_reltoken(&wpipe->pipe_wlock);
return (EPIPE);
}
*/
if (uio->uio_resid == 0) {
pipe_rel_mplock(&mpsave);
- lwkt_reltoken(&wlock);
+ lwkt_reltoken(&wpipe->pipe_wlock);
return(0);
}
error = pipe_start_uio(wpipe, &wpipe->pipe_wip);
if (error) {
pipe_rel_mplock(&mpsave);
- lwkt_reltoken(&wlock);
+ lwkt_reltoken(&wpipe->pipe_wlock);
return (error);
}
/*
* Recheck after lock.
*/
- lwkt_gettoken(&rlock, &wpipe->pipe_rlock);
+ lwkt_gettoken(&wpipe->pipe_rlock);
if ((wpipe->pipe_buffer.size <= PIPE_SIZE) &&
(pipe_nbig < pipe_maxbig) &&
(wpipe->pipe_buffer.rindex == wpipe->pipe_buffer.windex)) {
else
atomic_subtract_int(&pipe_nbig, 1);
}
- lwkt_reltoken(&rlock);
+ lwkt_reltoken(&wpipe->pipe_rlock);
}
orig_resid = uio->uio_resid;
* These are token locks so we do not have to worry about
* deadlocks.
*/
- lwkt_gettoken(&rlock, &wpipe->pipe_rlock);
+ lwkt_gettoken(&wpipe->pipe_rlock);
/*
* If the "read-side" has been blocked, wake it up now
* don't block on non-blocking I/O
*/
if (nbio) {
- lwkt_reltoken(&rlock);
+ lwkt_reltoken(&wpipe->pipe_rlock);
error = EAGAIN;
break;
}
* tokens already held.
*/
if (wpipe->pipe_state & PIPE_WEOF) {
- lwkt_reltoken(&rlock);
+ lwkt_reltoken(&wpipe->pipe_rlock);
error = EPIPE;
break;
}
error = tsleep(wpipe, PCATCH, "pipewr", 0);
++pipe_wblocked_count;
}
- lwkt_reltoken(&rlock);
+ lwkt_reltoken(&wpipe->pipe_rlock);
/*
* Break out if we errored or the read side wants us to go
*/
if (wpipe->pipe_buffer.windex != wpipe->pipe_buffer.rindex) {
if (wpipe->pipe_state & PIPE_WANTR) {
- lwkt_gettoken(&rlock, &wpipe->pipe_rlock);
+ lwkt_gettoken(&wpipe->pipe_rlock);
if (wpipe->pipe_state & PIPE_WANTR) {
wpipe->pipe_state &= ~PIPE_WANTR;
- lwkt_reltoken(&rlock);
+ lwkt_reltoken(&wpipe->pipe_rlock);
wakeup(wpipe);
} else {
- lwkt_reltoken(&rlock);
+ lwkt_reltoken(&wpipe->pipe_rlock);
}
}
if (pipeseltest(wpipe)) {
- lwkt_gettoken(&rlock, &wpipe->pipe_rlock);
+ lwkt_gettoken(&wpipe->pipe_rlock);
pipeselwakeup(wpipe);
- lwkt_reltoken(&rlock);
+ lwkt_reltoken(&wpipe->pipe_rlock);
}
}
* wake up select/poll.
*/
/*space = wpipe->pipe_buffer.windex - wpipe->pipe_buffer.rindex;*/
- lwkt_reltoken(&wlock);
+ lwkt_reltoken(&wpipe->pipe_wlock);
pipe_rel_mplock(&mpsave);
return (error);
}
struct ucred *cred, struct sysmsg *msg)
{
struct pipe *mpipe;
- lwkt_tokref rlock;
- lwkt_tokref wlock;
int error;
int mpsave;
pipe_get_mplock(&mpsave);
mpipe = (struct pipe *)fp->f_data;
- lwkt_gettoken(&rlock, &mpipe->pipe_rlock);
- lwkt_gettoken(&wlock, &mpipe->pipe_wlock);
+ lwkt_gettoken(&mpipe->pipe_rlock);
+ lwkt_gettoken(&mpipe->pipe_wlock);
switch (cmd) {
case FIOASYNC:
error = ENOTTY;
break;
}
- lwkt_reltoken(&rlock);
- lwkt_reltoken(&wlock);
+ lwkt_reltoken(&mpipe->pipe_wlock);
+ lwkt_reltoken(&mpipe->pipe_rlock);
pipe_rel_mplock(&mpsave);
return (error);
int
pipe_poll(struct file *fp, int events, struct ucred *cred)
{
- lwkt_tokref rpipe_rlock;
- lwkt_tokref rpipe_wlock;
- lwkt_tokref wpipe_rlock;
- lwkt_tokref wpipe_wlock;
struct pipe *rpipe;
struct pipe *wpipe;
int revents = 0;
revents = pipe_poll_events(rpipe, wpipe, events);
if (revents == 0) {
if (events & (POLLIN | POLLRDNORM)) {
- lwkt_gettoken(&rpipe_rlock, &rpipe->pipe_rlock);
- lwkt_gettoken(&rpipe_wlock, &rpipe->pipe_wlock);
+ lwkt_gettoken(&rpipe->pipe_rlock);
+ lwkt_gettoken(&rpipe->pipe_wlock);
}
if (events & (POLLOUT | POLLWRNORM)) {
- lwkt_gettoken(&wpipe_rlock, &wpipe->pipe_rlock);
- lwkt_gettoken(&wpipe_wlock, &wpipe->pipe_wlock);
+ lwkt_gettoken(&wpipe->pipe_rlock);
+ lwkt_gettoken(&wpipe->pipe_wlock);
}
revents = pipe_poll_events(rpipe, wpipe, events);
if (revents == 0) {
wpipe->pipe_state |= PIPE_SEL;
}
}
- if (events & (POLLIN | POLLRDNORM)) {
- lwkt_reltoken(&rpipe_rlock);
- lwkt_reltoken(&rpipe_wlock);
- }
if (events & (POLLOUT | POLLWRNORM)) {
- lwkt_reltoken(&wpipe_rlock);
- lwkt_reltoken(&wpipe_wlock);
+ lwkt_reltoken(&wpipe->pipe_wlock);
+ lwkt_reltoken(&wpipe->pipe_rlock);
+ }
+ if (events & (POLLIN | POLLRDNORM)) {
+ lwkt_reltoken(&rpipe->pipe_wlock);
+ lwkt_reltoken(&rpipe->pipe_rlock);
}
}
pipe_rel_mplock(&mpsave);
struct pipe *rpipe;
struct pipe *wpipe;
int error = EPIPE;
- lwkt_tokref rpipe_rlock;
- lwkt_tokref rpipe_wlock;
- lwkt_tokref wpipe_rlock;
- lwkt_tokref wpipe_wlock;
int mpsave;
pipe_get_mplock(&mpsave);
* We modify pipe_state on both pipes, which means we need
* all four tokens!
*/
- lwkt_gettoken(&rpipe_rlock, &rpipe->pipe_rlock);
- lwkt_gettoken(&rpipe_wlock, &rpipe->pipe_wlock);
- lwkt_gettoken(&wpipe_rlock, &wpipe->pipe_rlock);
- lwkt_gettoken(&wpipe_wlock, &wpipe->pipe_wlock);
+ lwkt_gettoken(&rpipe->pipe_rlock);
+ lwkt_gettoken(&rpipe->pipe_wlock);
+ lwkt_gettoken(&wpipe->pipe_rlock);
+ lwkt_gettoken(&wpipe->pipe_wlock);
switch(how) {
case SHUT_RDWR:
pipeselwakeup(rpipe);
pipeselwakeup(wpipe);
- lwkt_reltoken(&rpipe_rlock);
- lwkt_reltoken(&rpipe_wlock);
- lwkt_reltoken(&wpipe_rlock);
- lwkt_reltoken(&wpipe_wlock);
+ lwkt_reltoken(&wpipe->pipe_wlock);
+ lwkt_reltoken(&wpipe->pipe_rlock);
+ lwkt_reltoken(&rpipe->pipe_wlock);
+ lwkt_reltoken(&rpipe->pipe_rlock);
pipe_rel_mplock(&mpsave);
return (error);
{
globaldata_t gd;
struct pipe *ppipe;
- lwkt_tokref cpipe_rlock;
- lwkt_tokref cpipe_wlock;
- lwkt_tokref ppipe_rlock;
- lwkt_tokref ppipe_wlock;
if (cpipe == NULL)
return;
*/
if (cpipe->pipe_slock)
lockmgr(cpipe->pipe_slock, LK_EXCLUSIVE);
- lwkt_gettoken(&cpipe_rlock, &cpipe->pipe_rlock);
- lwkt_gettoken(&cpipe_wlock, &cpipe->pipe_wlock);
+ lwkt_gettoken(&cpipe->pipe_rlock);
+ lwkt_gettoken(&cpipe->pipe_wlock);
/*
* Set our state, wakeup anyone waiting in select, and
* Disconnect from peer.
*/
if ((ppipe = cpipe->pipe_peer) != NULL) {
- lwkt_gettoken(&ppipe_rlock, &ppipe->pipe_rlock);
- lwkt_gettoken(&ppipe_wlock, &ppipe->pipe_wlock);
+ lwkt_gettoken(&ppipe->pipe_rlock);
+ lwkt_gettoken(&ppipe->pipe_wlock);
ppipe->pipe_state |= PIPE_REOF | PIPE_WEOF;
pipeselwakeup(ppipe);
if (ppipe->pipe_state & (PIPE_WANTR | PIPE_WANTW)) {
KNOTE(&ppipe->pipe_sel.si_note, 0);
rel_mplock();
}
- lwkt_reltoken(&ppipe_rlock);
- lwkt_reltoken(&ppipe_wlock);
+ lwkt_reltoken(&ppipe->pipe_wlock);
+ lwkt_reltoken(&ppipe->pipe_rlock);
}
/*
ppipe = NULL;
}
- lwkt_reltoken(&cpipe_rlock);
- lwkt_reltoken(&cpipe_wlock);
+ lwkt_reltoken(&cpipe->pipe_wlock);
+ lwkt_reltoken(&cpipe->pipe_rlock);
if (cpipe->pipe_slock)
lockmgr(cpipe->pipe_slock, LK_RELEASE);
struct buf *
findblk(struct vnode *vp, off_t loffset, int flags)
{
- lwkt_tokref vlock;
struct buf *bp;
int lkflags;
lkflags |= LK_NOWAIT;
for (;;) {
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
bp = buf_rb_hash_RB_LOOKUP(&vp->v_rbhash_tree, loffset);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
if (bp == NULL || (flags & FINDBLK_TEST))
break;
if (BUF_LOCK(bp, lkflags)) {
{
struct vnode *vp = obj;
- lwkt_token_init(&vp->v_token);
+ lwkt_token_init(&vp->v_token, 1);
lockinit(&vp->v_lock, "vnode", 0, 0);
ccms_dataspace_init(&vp->v_ccms);
TAILQ_INIT(&vp->v_namecache);
void
vfs_mount_init(void)
{
- lwkt_token_init(&mountlist_token);
- lwkt_token_init(&mntvnode_token);
- lwkt_token_init(&mntid_token);
+ lwkt_token_init(&mountlist_token, 1);
+ lwkt_token_init(&mntvnode_token, 1);
+ lwkt_token_init(&mntid_token, 1);
TAILQ_INIT(&mountscan_list);
TAILQ_INIT(&mntvnodescan_list);
mount_init(&dummymount);
mount_init(struct mount *mp)
{
lockinit(&mp->mnt_lock, "vfslock", 0, 0);
- lwkt_token_init(&mp->mnt_token);
+ lwkt_token_init(&mp->mnt_token, 1);
TAILQ_INIT(&mp->mnt_nvnodelist);
TAILQ_INIT(&mp->mnt_reservedvnlist);
vfs_getvfs(fsid_t *fsid)
{
struct mount *mp;
- lwkt_tokref ilock;
- lwkt_gettoken(&ilock, &mountlist_token);
+ lwkt_gettoken(&mountlist_token);
TAILQ_FOREACH(mp, &mountlist, mnt_list) {
if (mp->mnt_stat.f_fsid.val[0] == fsid->val[0] &&
mp->mnt_stat.f_fsid.val[1] == fsid->val[1]) {
break;
}
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&mountlist_token);
return (mp);
}
vfs_getnewfsid(struct mount *mp)
{
static u_int16_t mntid_base;
- lwkt_tokref ilock;
fsid_t tfsid;
int mtype;
- lwkt_gettoken(&ilock, &mntid_token);
+ lwkt_gettoken(&mntid_token);
mtype = mp->mnt_vfc->vfc_typenum;
tfsid.val[1] = mtype;
mtype = (mtype & 0xFF) << 24;
}
mp->mnt_stat.f_fsid.val[0] = tfsid.val[0];
mp->mnt_stat.f_fsid.val[1] = tfsid.val[1];
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&mntid_token);
}
/*
{
struct vnlru_info *info = data;
struct vnode *vp;
- lwkt_tokref ilock;
int done;
int trigger;
int usevnodes;
trigger = vmstats.v_page_count * (trigger_mult + 2) / usevnodes;
done = 0;
- lwkt_gettoken(&ilock, &mntvnode_token);
+ lwkt_gettoken(&mntvnode_token);
count = mp->mnt_nvnodelistsize / 10 + 1;
while (count && mp->mnt_syncer) {
++done;
--count;
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&mntvnode_token);
return (done);
}
void
mountlist_insert(struct mount *mp, int how)
{
- lwkt_tokref ilock;
-
- lwkt_gettoken(&ilock, &mountlist_token);
+ lwkt_gettoken(&mountlist_token);
if (how == MNTINS_FIRST)
TAILQ_INSERT_HEAD(&mountlist, mp, mnt_list);
else
TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&mountlist_token);
}
/*
int
mountlist_interlock(int (*callback)(struct mount *), struct mount *mp)
{
- lwkt_tokref ilock;
int error;
- lwkt_gettoken(&ilock, &mountlist_token);
+ lwkt_gettoken(&mountlist_token);
error = callback(mp);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&mountlist_token);
return (error);
}
mountlist_remove(struct mount *mp)
{
struct mountscan_info *msi;
- lwkt_tokref ilock;
- lwkt_gettoken(&ilock, &mountlist_token);
+ lwkt_gettoken(&mountlist_token);
TAILQ_FOREACH(msi, &mountscan_list, msi_entry) {
if (msi->msi_node == mp) {
if (msi->msi_how & MNTSCAN_FORWARD)
}
}
TAILQ_REMOVE(&mountlist, mp, mnt_list);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&mountlist_token);
}
/*
mountlist_scan(int (*callback)(struct mount *, void *), void *data, int how)
{
struct mountscan_info info;
- lwkt_tokref ilock;
struct mount *mp;
thread_t td;
int count;
int res;
- lwkt_gettoken(&ilock, &mountlist_token);
+ lwkt_gettoken(&mountlist_token);
info.msi_how = how;
info.msi_node = NULL; /* paranoia */
}
}
TAILQ_REMOVE(&mountscan_list, &info, msi_entry);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&mountlist_token);
return(res);
}
void
insmntque(struct vnode *vp, struct mount *mp)
{
- lwkt_tokref ilock;
-
- lwkt_gettoken(&ilock, &mntvnode_token);
+ lwkt_gettoken(&mntvnode_token);
/*
* Delete from old mount point vnode list, if on one.
*/
* The 'end' of the LRU list is the vnode prior to mp->mnt_syncer.
*/
if ((vp->v_mount = mp) == NULL) {
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&mntvnode_token);
return;
}
if (mp->mnt_syncer) {
TAILQ_INSERT_TAIL(&mp->mnt_nvnodelist, vp, v_nmntvnodes);
}
mp->mnt_nvnodelistsize++;
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&mntvnode_token);
}
void *data
) {
struct vmntvnodescan_info info;
- lwkt_tokref ilock;
struct vnode *vp;
int r = 0;
int maxcount = 1000000;
int stopcount = 0;
int count = 0;
- lwkt_gettoken(&ilock, &mntvnode_token);
+ lwkt_gettoken(&mntvnode_token);
/*
* If asked to do one pass stop after iterating available vnodes.
info.vp = TAILQ_NEXT(vp, v_nmntvnodes);
}
TAILQ_REMOVE(&mntvnodescan_list, &info, entry);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&mntvnode_token);
return(r);
}
mount_get_by_nc(struct namecache *ncp)
{
struct mount *mp = NULL;
- lwkt_tokref ilock;
- lwkt_gettoken(&ilock, &mountlist_token);
+ lwkt_gettoken(&mountlist_token);
TAILQ_FOREACH(mp, &mountlist, mnt_list) {
if (ncp == mp->mnt_ncmountpt.ncp)
break;
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&mountlist_token);
return (mp);
}
KvaSize / factor2);
desiredvnodes = imax(desiredvnodes, maxproc * 8);
- lwkt_token_init(&spechash_token);
+ lwkt_token_init(&spechash_token, 1);
}
/*
{
struct vinvalbuf_bp_info info;
vm_object_t object;
- lwkt_tokref vlock;
int error;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
/*
* If we are being asked to save, call fsync to ensure that the inode
panic("vinvalbuf: flush failed, buffers still present");
error = 0;
done:
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (error);
}
{
off_t truncloffset;
const char *filename;
- lwkt_tokref vlock;
int count;
/*
else
truncloffset = length;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
do {
count = RB_SCAN(buf_rb_tree, &vp->v_rbclean_tree,
vtruncbuf_bp_trunc_cmp,
}
} while(count);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (0);
}
int (*waitoutput)(struct vnode *, struct thread *))
{
struct vfsync_info info;
- lwkt_tokref vlock;
int error;
bzero(&info, sizeof(info));
if ((info.checkdef = checkdef) == NULL)
info.syncdeps = 1;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
switch(waitfor) {
case MNT_LAZY:
}
break;
}
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return(error);
}
int
bgetvp(struct vnode *vp, struct buf *bp)
{
- lwkt_tokref vlock;
-
KASSERT(bp->b_vp == NULL, ("bgetvp: not free"));
KKASSERT((bp->b_flags & (B_HASHED|B_DELWRI|B_VNCLEAN|B_VNDIRTY)) == 0);
/*
* Insert onto list for new vnode.
*/
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
if (buf_rb_hash_RB_INSERT(&vp->v_rbhash_tree, bp)) {
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (EEXIST);
}
bp->b_vp = vp;
if (buf_rb_tree_RB_INSERT(&vp->v_rbclean_tree, bp))
panic("reassignbuf: dup lblk/clean vp %p bp %p", vp, bp);
vhold(vp);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return(0);
}
brelvp(struct buf *bp)
{
struct vnode *vp;
- lwkt_tokref vlock;
KASSERT(bp->b_vp != NULL, ("brelvp: NULL"));
* Delete from old vnode list, if on one.
*/
vp = bp->b_vp;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
if (bp->b_flags & (B_VNDIRTY | B_VNCLEAN)) {
if (bp->b_flags & B_VNDIRTY)
buf_rb_tree_RB_REMOVE(&vp->v_rbdirty_tree, bp);
LIST_REMOVE(vp, v_synclist);
}
bp->b_vp = NULL;
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
vdrop(vp);
}
reassignbuf(struct buf *bp)
{
struct vnode *vp = bp->b_vp;
- lwkt_tokref vlock;
int delay;
KKASSERT(vp != NULL);
if (bp->b_flags & B_PAGING)
panic("cannot reassign paging buffer");
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
if (bp->b_flags & B_DELWRI) {
/*
* Move to the dirty list, add the vnode to the worklist
LIST_REMOVE(vp, v_synclist);
}
}
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
}
/*
int
v_associate_rdev(struct vnode *vp, cdev_t dev)
{
- lwkt_tokref ilock;
-
if (dev == NULL)
return(ENXIO);
if (dev_is_good(dev) == 0)
return(ENXIO);
KKASSERT(vp->v_rdev == NULL);
vp->v_rdev = reference_dev(dev);
- lwkt_gettoken(&ilock, &spechash_token);
+ lwkt_gettoken(&spechash_token);
SLIST_INSERT_HEAD(&dev->si_hlist, vp, v_cdevnext);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&spechash_token);
return(0);
}
void
v_release_rdev(struct vnode *vp)
{
- lwkt_tokref ilock;
cdev_t dev;
if ((dev = vp->v_rdev) != NULL) {
- lwkt_gettoken(&ilock, &spechash_token);
+ lwkt_gettoken(&spechash_token);
SLIST_REMOVE(&dev->si_hlist, vp, vnode, v_cdevnext);
vp->v_rdev = NULL;
release_dev(dev);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&spechash_token);
}
}
{
struct vnode *vq;
struct vnode *vqn;
- lwkt_tokref ilock;
cdev_t dev;
int error;
return(0);
}
reference_dev(dev);
- lwkt_gettoken(&ilock, &spechash_token);
+ lwkt_gettoken(&spechash_token);
vqn = SLIST_FIRST(&dev->si_hlist);
if (vqn)
/*v_release_rdev(vq);*/
vrele(vq);
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&spechash_token);
dev_drevoke(dev);
release_dev(dev);
return (0);
int
vfinddev(cdev_t dev, enum vtype type, struct vnode **vpp)
{
- lwkt_tokref ilock;
struct vnode *vp;
- lwkt_gettoken(&ilock, &spechash_token);
+ lwkt_gettoken(&spechash_token);
SLIST_FOREACH(vp, &dev->si_hlist, v_cdevnext) {
if (type == vp->v_type) {
*vpp = vp;
vref(vp);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&spechash_token);
return (1);
}
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&spechash_token);
return (0);
}
int
count_dev(cdev_t dev)
{
- lwkt_tokref ilock;
struct vnode *vp;
int count = 0;
if (SLIST_FIRST(&dev->si_hlist)) {
- lwkt_gettoken(&ilock, &spechash_token);
+ lwkt_gettoken(&spechash_token);
SLIST_FOREACH(vp, &dev->si_hlist, v_cdevnext) {
count += vp->v_opencount;
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&spechash_token);
}
return(count);
}
int
vn_pollrecord(struct vnode *vp, int events)
{
- lwkt_tokref vlock;
-
KKASSERT(curthread->td_proc != NULL);
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
if (vp->v_pollinfo.vpi_revents & events) {
/*
* This leaves events we are not interested
events &= vp->v_pollinfo.vpi_revents;
vp->v_pollinfo.vpi_revents &= ~events;
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return events;
}
vp->v_pollinfo.vpi_events |= events;
selrecord(curthread, &vp->v_pollinfo.vpi_selinfo);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return 0;
}
void
vn_pollevent(struct vnode *vp, int events)
{
- lwkt_tokref vlock;
-
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
if (vp->v_pollinfo.vpi_events & events) {
/*
* We clear vpi_events so that we don't
vp->v_pollinfo.vpi_revents |= events;
selwakeup(&vp->v_pollinfo.vpi_selinfo);
}
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
}
/*
void
vn_pollgone(struct vnode *vp)
{
- lwkt_tokref vlock;
-
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
if (vp->v_pollinfo.vpi_events) {
vp->v_pollinfo.vpi_events = 0;
selwakeup(&vp->v_pollinfo.vpi_selinfo);
}
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
}
/*
syncer_workitem_pending = hashinit(syncer_maxdelay, M_DEVBUF,
&syncer_mask);
syncer_maxdelay = syncer_mask + 1;
- lwkt_token_init(&syncer_token);
+ lwkt_token_init(&syncer_token, 1);
}
/*
void
vn_syncer_add_to_worklist(struct vnode *vp, int delay)
{
- lwkt_tokref ilock;
int slot;
- lwkt_gettoken(&ilock, &syncer_token);
+ lwkt_gettoken(&syncer_token);
if (vp->v_flag & VONWORKLST)
LIST_REMOVE(vp, v_synclist);
LIST_INSERT_HEAD(&syncer_workitem_pending[slot], vp, v_synclist);
vsetflags(vp, VONWORKLST);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&syncer_token);
}
struct thread *updatethread;
struct thread *td = curthread;
struct synclist *slp;
struct vnode *vp;
- lwkt_tokref ilock;
- lwkt_tokref vlock;
long starttime;
EVENTHANDLER_REGISTER(shutdown_pre_sync, shutdown_kproc, td,
kproc_suspend_loop();
starttime = time_second;
- lwkt_gettoken(&ilock, &syncer_token);
+ lwkt_gettoken(&syncer_token);
/*
* Push files whose dirty time has expired. Be careful
* here.
*/
if (LIST_FIRST(slp) == vp) {
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
if (LIST_FIRST(slp) == vp) {
if (RB_EMPTY(&vp->v_rbdirty_tree) &&
!vn_isdisk(vp, NULL)) {
}
vn_syncer_add_to_worklist(vp, syncdelay);
}
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
}
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&syncer_token);
/*
* Do sync processing for each mount.
sync_reclaim(struct vop_reclaim_args *ap)
{
struct vnode *vp = ap->a_vp;
- lwkt_tokref ilock;
- lwkt_gettoken(&ilock, &syncer_token);
+ lwkt_gettoken(&syncer_token);
KKASSERT(vp->v_mount->mnt_syncer != vp);
if (vp->v_flag & VONWORKLST) {
LIST_REMOVE(vp, v_synclist);
vclrflags(vp, VONWORKLST);
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&syncer_token);
return (0);
}
off_t truncloffset;
off_t truncboffset;
const char *filename;
- lwkt_tokref vlock;
struct buf *bp;
int count;
int error;
else
truncloffset = length;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
do {
count = RB_SCAN(buf_rb_tree, &vp->v_rbclean_tree,
nvtruncbuf_bp_trunc_cmp,
}
} while(count);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (error);
}
vop_inactive(struct vop_ops *ops, struct vnode *vp)
{
struct vop_inactive_args ap;
+ struct mount *mp;
VFS_MPLOCK_DECLARE;
int error;
ap.a_head.a_ops = ops;
ap.a_vp = vp;
- VFS_MPLOCK_FLAG(vp->v_mount, MNTK_IN_MPSAFE);
+ /*
+ * WARNING! Deactivation of the vnode can cause it to be recycled,
+ * clearing vp->v_mount.
+ */
+ mp = vp->v_mount;
+ VFS_MPLOCK_FLAG(mp, MNTK_IN_MPSAFE);
DO_OPS(ops, error, &ap, vop_inactive);
- VFS_MPUNLOCK(vp->v_mount);
+ VFS_MPUNLOCK(mp);
return(error);
}
vop_reclaim(struct vop_ops *ops, struct vnode *vp)
{
struct vop_reclaim_args ap;
+ struct mount *mp;
VFS_MPLOCK_DECLARE;
int error;
ap.a_head.a_ops = ops;
ap.a_vp = vp;
- VFS_MPLOCK1(vp->v_mount);
+ /*
+ * WARNING! Reclamation of the vnode will clear vp->v_mount.
+ */
+ mp = vp->v_mount;
+ VFS_MPLOCK1(mp);
DO_OPS(ops, error, &ap, vop_reclaim);
- VFS_MPUNLOCK(vp->v_mount);
+ VFS_MPUNLOCK(mp);
return(error);
}
struct mbchain;
struct proc;
struct thread;
-struct lwkt_tokref;
struct smb_vc;
struct smb_rq;
#endif
static struct lwkt_token bounce_zone_tok =
- LWKT_TOKEN_INITIALIZER(bounce_zone_tok);
+ LWKT_TOKEN_MP_INITIALIZER(bounce_zone_tok);
static int busdma_zonecount;
static STAILQ_HEAD(, bounce_zone) bounce_zone_list =
STAILQ_HEAD_INITIALIZER(bounce_zone_list);
alloc_bounce_zone(bus_dma_tag_t dmat)
{
struct bounce_zone *bz, *new_bz;
- lwkt_tokref ref;
KASSERT(dmat->bounce_zone == NULL,
("bounce zone was already assigned\n"));
new_bz = kmalloc(sizeof(*new_bz), M_DEVBUF, M_INTWAIT | M_ZERO);
- lwkt_gettoken(&ref, &bounce_zone_tok);
+ lwkt_gettoken(&bounce_zone_tok);
/* Check to see if we already have a suitable zone */
STAILQ_FOREACH(bz, &bounce_zone_list, links) {
if (dmat->alignment <= bz->alignment &&
dmat->lowaddr >= bz->lowaddr) {
- lwkt_reltoken(&ref);
+ lwkt_reltoken(&bounce_zone_tok);
dmat->bounce_zone = bz;
kfree(new_bz, M_DEVBUF);
ksnprintf(bz->lowaddrid, 18, "%#jx", (uintmax_t)bz->lowaddr);
STAILQ_INSERT_TAIL(&bounce_zone_list, bz, links);
- lwkt_reltoken(&ref);
+ lwkt_reltoken(&bounce_zone_tok);
dmat->bounce_zone = bz;
#endif
static struct lwkt_token bounce_zone_tok =
- LWKT_TOKEN_INITIALIZER(bounce_zone_tok);
+ LWKT_TOKEN_MP_INITIALIZER(bounce_zone_tok);
static int busdma_zonecount;
static STAILQ_HEAD(, bounce_zone) bounce_zone_list =
STAILQ_HEAD_INITIALIZER(bounce_zone_list);
alloc_bounce_zone(bus_dma_tag_t dmat)
{
struct bounce_zone *bz, *new_bz;
- lwkt_tokref ref;
KASSERT(dmat->bounce_zone == NULL,
("bounce zone was already assigned\n"));
new_bz = kmalloc(sizeof(*new_bz), M_DEVBUF, M_INTWAIT | M_ZERO);
- lwkt_gettoken(&ref, &bounce_zone_tok);
+ lwkt_gettoken(&bounce_zone_tok);
/* Check to see if we already have a suitable zone */
STAILQ_FOREACH(bz, &bounce_zone_list, links) {
if (dmat->alignment <= bz->alignment &&
dmat->lowaddr >= bz->lowaddr) {
- lwkt_reltoken(&ref);
+ lwkt_reltoken(&bounce_zone_tok);
dmat->bounce_zone = bz;
kfree(new_bz, M_DEVBUF);
ksnprintf(bz->lowaddrid, 18, "%#jx", (uintmax_t)bz->lowaddr);
STAILQ_INSERT_TAIL(&bounce_zone_list, bz, links);
- lwkt_reltoken(&ref);
+ lwkt_reltoken(&bounce_zone_tok);
dmat->bounce_zone = bz;
#endif
static struct lwkt_token bounce_zone_tok =
- LWKT_TOKEN_INITIALIZER(bounce_zone_tok);
+ LWKT_TOKEN_MP_INITIALIZER(bounce_zone_tok);
static int busdma_zonecount;
static STAILQ_HEAD(, bounce_zone) bounce_zone_list =
STAILQ_HEAD_INITIALIZER(bounce_zone_list);
alloc_bounce_zone(bus_dma_tag_t dmat)
{
struct bounce_zone *bz, *new_bz;
- lwkt_tokref ref;
KASSERT(dmat->bounce_zone == NULL,
("bounce zone was already assigned\n"));
new_bz = kmalloc(sizeof(*new_bz), M_DEVBUF, M_INTWAIT | M_ZERO);
- lwkt_gettoken(&ref, &bounce_zone_tok);
+ lwkt_gettoken(&bounce_zone_tok);
/* Check to see if we already have a suitable zone */
STAILQ_FOREACH(bz, &bounce_zone_list, links) {
if (dmat->alignment <= bz->alignment &&
dmat->lowaddr >= bz->lowaddr) {
- lwkt_reltoken(&ref);
+ lwkt_reltoken(&bounce_zone_tok);
dmat->bounce_zone = bz;
kfree(new_bz, M_DEVBUF);
ksnprintf(bz->lowaddrid, 18, "%#jx", (uintmax_t)bz->lowaddr);
STAILQ_INSERT_TAIL(&bounce_zone_list, bz, links);
- lwkt_reltoken(&ref);
+ lwkt_reltoken(&bounce_zone_tok);
dmat->bounce_zone = bz;
#endif
static struct lwkt_token bounce_zone_tok =
- LWKT_TOKEN_INITIALIZER(bounce_zone_tok);
+ LWKT_TOKEN_MP_INITIALIZER(bounce_zone_tok);
static int busdma_zonecount;
static STAILQ_HEAD(, bounce_zone) bounce_zone_list =
STAILQ_HEAD_INITIALIZER(bounce_zone_list);
alloc_bounce_zone(bus_dma_tag_t dmat)
{
struct bounce_zone *bz, *new_bz;
- lwkt_tokref ref;
KASSERT(dmat->bounce_zone == NULL,
("bounce zone was already assigned\n"));
new_bz = kmalloc(sizeof(*new_bz), M_DEVBUF, M_INTWAIT | M_ZERO);
- lwkt_gettoken(&ref, &bounce_zone_tok);
+ lwkt_gettoken(&bounce_zone_tok);
/* Check to see if we already have a suitable zone */
STAILQ_FOREACH(bz, &bounce_zone_list, links) {
if (dmat->alignment <= bz->alignment &&
dmat->lowaddr >= bz->lowaddr) {
- lwkt_reltoken(&ref);
+ lwkt_reltoken(&bounce_zone_tok);
dmat->bounce_zone = bz;
kfree(new_bz, M_DEVBUF);
ksnprintf(bz->lowaddrid, 18, "%#jx", (uintmax_t)bz->lowaddr);
STAILQ_INSERT_TAIL(&bounce_zone_list, bz, links);
- lwkt_reltoken(&ref);
+ lwkt_reltoken(&bounce_zone_tok);
dmat->bounce_zone = bz;
/*
* VFS MPLOCK helper.
*/
-#define VFS_MPLOCK_DECLARE struct lwkt_tokref xlock; int xlock_mpsafe
+#define VFS_MPLOCK_DECLARE int xlock_mpsafe
#define VFS_MPLOCK1(mp) VFS_MPLOCK_FLAG(mp, MNTK_MPSAFE)
do { \
if (xlock_mpsafe) { \
get_mplock(); /* TEMPORARY */ \
- lwkt_gettoken(&xlock, &mp->mnt_token); \
+ lwkt_gettoken(&mp->mnt_token); \
xlock_mpsafe = 0; \
} \
} while(0)
xlock_mpsafe = 1; \
} else { \
get_mplock(); /* TEMPORARY */ \
- lwkt_gettoken(&xlock, &mp->mnt_token); \
+ lwkt_gettoken(&mp->mnt_token); \
xlock_mpsafe = 0; \
} \
} while(0)
#define VFS_MPUNLOCK(mp) \
do { \
if (xlock_mpsafe == 0) { \
- lwkt_reltoken(&xlock); \
+ lwkt_reltoken(&mp->mnt_token); \
rel_mplock(); /* TEMPORARY */ \
} \
} while(0)
};
struct lwkt_token;
-struct lwkt_tokref;
struct rman {
struct resource_head rm_list;
TAILQ_HEAD(rman_head, rman);
int rman_activate_resource(struct resource *r);
-int rman_await_resource(struct resource *r, struct lwkt_tokref *ilock, int slpflags, int timo);
+#if 0
+int rman_await_resource(struct resource *r, int slpflags, int timo);
+#endif
int rman_deactivate_resource(struct resource *r);
int rman_fini(struct rman *rm);
int rman_init(struct rman *rm);
typedef struct lwkt_token {
struct lwkt_tokref *t_ref; /* Owning ref or NULL */
+ intptr_t t_flags; /* MP lock required */
} lwkt_token;
-#define LWKT_TOKEN_INITIALIZER(head) \
+#define LWKT_TOKEN_MPSAFE 0x0001
+
+/*
+ * Static initialization for a lwkt_token.
+ * UP - Not MPSAFE (full MP lock will also be acquired)
+ * MP - Is MPSAFE (only the token will be acquired)
+ */
+#define LWKT_TOKEN_UP_INITIALIZER(head) \
{ \
- .t_ref = NULL \
+ .t_ref = NULL, \
+ .t_flags = 0 \
+}
+
+#define LWKT_TOKEN_MP_INITIALIZER(head) \
+{ \
+ .t_ref = NULL, \
+ .t_flags = LWKT_TOKEN_MPSAFE \
}
#define ASSERT_LWKT_TOKEN_HELD(tok) \
KKASSERT((tok)->t_ref->tr_owner == curthread)
-typedef struct lwkt_tokref {
+struct lwkt_tokref {
lwkt_token_t tr_tok; /* token in question */
struct thread *tr_owner; /* me */
- lwkt_tokref_t tr_next; /* linked list */
-} lwkt_tokref;
+ intptr_t tr_flags; /* copy of t_flags */
+};
#define MAXCPUFIFO 16 /* power of 2 */
#define MAXCPUFIFO_MASK (MAXCPUFIFO - 1)
-#define LWKT_MAXTOKENS 16 /* max tokens beneficially held by thread */
+#define LWKT_MAXTOKENS 32 /* max tokens beneficially held by thread */
/*
* Always cast to ipifunc_t when registering an ipi. The actual ipi function
struct thread *td_preempted; /* we preempted this thread */
struct ucred *td_ucred; /* synchronized from p_ucred */
struct caps_kinfo *td_caps; /* list of client and server registrations */
- lwkt_tokref_t td_toks; /* tokens beneficially held */
+ lwkt_tokref_t td_toks_stop;
+ struct lwkt_tokref td_toks_array[LWKT_MAXTOKENS];
#ifdef DEBUG_CRIT_SECTIONS
#define CRIT_DEBUG_ARRAY_SIZE 32
#define CRIT_DEBUG_ARRAY_MASK (CRIT_DEBUG_ARRAY_SIZE - 1)
struct md_thread td_mach;
};
+#define td_toks_base td_toks_array[0]
+#define td_toks_end td_toks_array[LWKT_MAXTOKENS]
+
+#define TD_TOKS_HELD(td) ((td)->td_toks_stop != &(td)->td_toks_base)
+#define TD_TOKS_NOT_HELD(td) ((td)->td_toks_stop == &(td)->td_toks_base)
+
/*
* Thread flags. Note that TDF_RUNNING is cleared on the old thread after
* we switch to the new one, which is necessary because LWKTs don't need
extern void lwkt_rele(thread_t);
extern void lwkt_passive_release(thread_t);
-extern void lwkt_gettoken(lwkt_tokref_t, lwkt_token_t);
-extern int lwkt_trytoken(lwkt_tokref_t, lwkt_token_t);
-extern void lwkt_gettokref(lwkt_tokref_t);
-extern int lwkt_trytokref(lwkt_tokref_t);
-extern void lwkt_reltoken(lwkt_tokref_t);
+extern void lwkt_gettoken(lwkt_token_t);
+extern int lwkt_trytoken(lwkt_token_t);
+extern void lwkt_reltoken(lwkt_token_t);
extern int lwkt_getalltokens(thread_t);
extern void lwkt_relalltokens(thread_t);
extern void lwkt_drain_token_requests(void);
-extern void lwkt_token_init(lwkt_token_t);
+extern void lwkt_token_init(lwkt_token_t, int);
extern void lwkt_token_uninit(lwkt_token_t);
extern void lwkt_token_pool_init(void);
extern lwkt_token_t lwkt_token_pool_lookup(void *);
-extern void lwkt_getpooltoken(lwkt_tokref_t, void *);
+extern lwkt_token_t lwkt_getpooltoken(void *);
extern void lwkt_setpri(thread_t, int);
extern void lwkt_setpri_initial(thread_t, int);
}
/*
- * Initialize a tokref_t. We only need to initialize the token pointer
- * and the magic number. We do not have to initialize tr_next, tr_gdreqnext,
- * or tr_reqgd.
- */
-static __inline void
-lwkt_tokref_init(lwkt_tokref_t ref, lwkt_token_t tok, thread_t td)
-{
- ref->tr_tok = tok;
- ref->tr_owner = td;
-}
-
-/*
* Return whether any threads are runnable, whether they meet mp_lock
* requirements or not.
*/
struct vnode *vp = ap->a_vp;
struct fifoinfo *fip;
struct socket *rso, *wso;
- lwkt_tokref vlock;
int error;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
if ((fip = vp->v_fifoinfo) == NULL) {
MALLOC(fip, struct fifoinfo *, sizeof(*fip), M_FIFOINFO, M_WAITOK);
vp->v_fifoinfo = fip;
}
vsetflags(vp, VNOTSEEKABLE);
error = vop_stdopen(ap);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (error);
bad:
vop_stdopen(ap); /* bump opencount/writecount as appropriate */
VOP_CLOSE(vp, ap->a_mode);
done:
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (error);
}
fifo_read(struct vop_read_args *ap)
{
struct uio *uio = ap->a_uio;
- struct socket *rso = ap->a_vp->v_fifoinfo->fi_readsock;
+ struct vnode *vp = ap->a_vp;
+ struct socket *rso = vp->v_fifoinfo->fi_readsock;
int error, startresid;
- lwkt_tokref vlock;
int flags;
#ifdef DIAGNOSTIC
else
flags = 0;
startresid = uio->uio_resid;
- vn_unlock(ap->a_vp);
- lwkt_gettoken(&vlock, &ap->a_vp->v_token);
+ vn_unlock(vp);
+ lwkt_gettoken(&vp->v_token);
error = soreceive(rso, NULL, uio, NULL, NULL, &flags);
- lwkt_reltoken(&vlock);
- vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY);
+ lwkt_reltoken(&vp->v_token);
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
return (error);
}
static int
fifo_write(struct vop_write_args *ap)
{
- struct socket *wso = ap->a_vp->v_fifoinfo->fi_writesock;
struct thread *td = ap->a_uio->uio_td;
- lwkt_tokref vlock;
+ struct vnode *vp = ap->a_vp;
+ struct socket *wso = vp->v_fifoinfo->fi_writesock;
int error;
int flags;
flags = MSG_FNONBLOCKING;
else
flags = 0;
- vn_unlock(ap->a_vp);
- lwkt_gettoken(&vlock, &ap->a_vp->v_token);
+ vn_unlock(vp);
+ lwkt_gettoken(&vp->v_token);
error = sosend(wso, NULL, ap->a_uio, 0, NULL, flags, td);
- lwkt_reltoken(&vlock);
- vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY);
+ lwkt_reltoken(&vp->v_token);
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
return (error);
}
fifo_ioctl(struct vop_ioctl_args *ap)
{
struct file filetmp; /* Local */
- lwkt_tokref vlock;
+ struct vnode *vp = ap->a_vp;
int error;
if (ap->a_fflag & FREAD) {
- filetmp.f_data = ap->a_vp->v_fifoinfo->fi_readsock;
- lwkt_gettoken(&vlock, &ap->a_vp->v_token);
+ filetmp.f_data = vp->v_fifoinfo->fi_readsock;
+ lwkt_gettoken(&vp->v_token);
error = soo_ioctl(&filetmp, ap->a_command, ap->a_data,
ap->a_cred, ap->a_sysmsg);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
if (error)
return (error);
}
if (ap->a_fflag & FWRITE) {
- filetmp.f_data = ap->a_vp->v_fifoinfo->fi_writesock;
- lwkt_gettoken(&vlock, &ap->a_vp->v_token);
+ filetmp.f_data = vp->v_fifoinfo->fi_writesock;
+ lwkt_gettoken(&vp->v_token);
error = soo_ioctl(&filetmp, ap->a_command, ap->a_data,
ap->a_cred, ap->a_sysmsg);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
if (error)
return (error);
}
struct fifoinfo *fi = vp->v_fifoinfo;
struct socket *so;
struct signalsockbuf *ssb;
- lwkt_tokref vlock;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
switch (ap->a_kn->kn_filter) {
case EVFILT_READ:
ssb = &so->so_snd;
break;
default:
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (1);
}
ap->a_kn->kn_hook = (caddr_t)vp;
ssb_insert_knote(ssb, ap->a_kn);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (0);
}
{
struct vnode *vp = (void *)kn->kn_hook;
struct socket *so = vp->v_fifoinfo->fi_readsock;
- lwkt_tokref vlock;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
ssb_remove_knote(&so->so_rcv, kn);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
}
static int
{
struct vnode *vp = (void *)kn->kn_hook;
struct socket *so = vp->v_fifoinfo->fi_readsock;
- lwkt_tokref vlock;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
kn->kn_data = so->so_rcv.ssb_cc;
if (so->so_state & SS_CANTRCVMORE) {
kn->kn_flags |= EV_EOF;
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (1);
}
kn->kn_flags &= ~EV_EOF;
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (kn->kn_data > 0);
}
{
struct vnode *vp = (void *)kn->kn_hook;
struct socket *so = vp->v_fifoinfo->fi_writesock;
- lwkt_tokref vlock;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
ssb_remove_knote(&so->so_snd, kn);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
}
static int
{
struct vnode *vp = (void *)kn->kn_hook;
struct socket *so = vp->v_fifoinfo->fi_writesock;
- lwkt_tokref vlock;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
kn->kn_data = ssb_space(&so->so_snd);
if (so->so_state & SS_CANTSENDMORE) {
kn->kn_flags |= EV_EOF;
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (1);
}
kn->kn_flags &= ~EV_EOF;
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (kn->kn_data >= so->so_snd.ssb_lowat);
}
static int
fifo_poll(struct vop_poll_args *ap)
{
+ struct vnode *vp = ap->a_vp;
struct file filetmp;
int events, revents = 0;
- lwkt_tokref vlock;
- lwkt_gettoken(&vlock, &ap->a_vp->v_token);
+ lwkt_gettoken(&vp->v_token);
events = ap->a_events &
(POLLIN | POLLINIGNEOF | POLLPRI | POLLRDNORM | POLLRDBAND);
if (events) {
events |= POLLINIGNEOF;
}
- filetmp.f_data = ap->a_vp->v_fifoinfo->fi_readsock;
+ filetmp.f_data = vp->v_fifoinfo->fi_readsock;
if (filetmp.f_data)
revents |= soo_poll(&filetmp, events, ap->a_cred);
}
events = ap->a_events & (POLLOUT | POLLWRNORM | POLLWRBAND);
if (events) {
- filetmp.f_data = ap->a_vp->v_fifoinfo->fi_writesock;
+ filetmp.f_data = vp->v_fifoinfo->fi_writesock;
if (filetmp.f_data)
revents |= soo_poll(&filetmp, events, ap->a_cred);
}
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (revents);
}
struct vnode *vp = ap->a_vp;
struct fifoinfo *fip;
int error1, error2;
- lwkt_tokref vlock;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
fip = vp->v_fifoinfo;
if (ap->a_fflag & FREAD) {
fip->fi_readers--;
}
if (vp->v_sysref.refcnt > 1) {
vop_stdclose(ap);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (0);
}
error1 = soclose(fip->fi_readsock, FNONBLOCK);
} else {
vop_stdclose(ap);
}
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (error2);
}
ext2_ihash <<= 1;
ext2_ihashtbl = kmalloc(sizeof(void *) * ext2_ihash, M_EXT2IHASH, M_WAITOK|M_ZERO);
--ext2_ihash;
- lwkt_token_init(&ext2_ihash_token);
+ lwkt_token_init(&ext2_ihash_token, 1);
}
int
ext2_uninit(struct vfsconf *vfc)
{
- lwkt_tokref ilock;
-
- lwkt_gettoken(&ilock, &ext2_ihash_token);
+ lwkt_gettoken(&ext2_ihash_token);
if (ext2_ihashtbl)
kfree(ext2_ihashtbl, M_EXT2IHASH);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ext2_ihash_token);
return (0);
}
ext2_ihashlookup(cdev_t dev, ino_t inum)
{
struct inode *ip;
- lwkt_tokref ilock;
- lwkt_gettoken(&ilock, &ext2_ihash_token);
+ lwkt_gettoken(&ext2_ihash_token);
for (ip = *INOHASH(dev, inum); ip; ip = ip->i_next) {
if (inum == ip->i_number && dev == ip->i_dev)
break;
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ext2_ihash_token);
if (ip)
return (ITOV(ip));
return (NULLVP);
struct vnode *
ext2_ihashget(cdev_t dev, ino_t inum)
{
- lwkt_tokref ilock;
struct inode *ip;
struct vnode *vp;
- lwkt_gettoken(&ilock, &ext2_ihash_token);
+ lwkt_gettoken(&ext2_ihash_token);
loop:
for (ip = *INOHASH(dev, inum); ip; ip = ip->i_next) {
if (inum != ip->i_number || dev != ip->i_dev)
vput(vp);
goto loop;
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ext2_ihash_token);
return (vp);
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ext2_ihash_token);
return (NULL);
}
int
ext2_ihashcheck(cdev_t dev, ino_t inum)
{
- lwkt_tokref ilock;
struct inode *ip;
- lwkt_gettoken(&ilock, &ext2_ihash_token);
+ lwkt_gettoken(&ext2_ihash_token);
for (ip = *INOHASH(dev, inum); ip; ip = ip->i_next) {
if (inum == ip->i_number && dev == ip->i_dev)
break;
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ext2_ihash_token);
return(ip ? 1 : 0);
}
{
struct inode **ipp;
struct inode *iq;
- lwkt_tokref ilock;
KKASSERT((ip->i_flag & IN_HASHED) == 0);
- lwkt_gettoken(&ilock, &ext2_ihash_token);
+ lwkt_gettoken(&ext2_ihash_token);
ipp = INOHASH(ip->i_dev, ip->i_number);
while ((iq = *ipp) != NULL) {
if (ip->i_dev == iq->i_dev && ip->i_number == iq->i_number) {
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ext2_ihash_token);
return(EBUSY);
}
ipp = &iq->i_next;
ip->i_next = NULL;
*ipp = ip;
ip->i_flag |= IN_HASHED;
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ext2_ihash_token);
return(0);
}
void
ext2_ihashrem(struct inode *ip)
{
- lwkt_tokref ilock;
struct inode **ipp;
struct inode *iq;
- lwkt_gettoken(&ilock, &ext2_ihash_token);
+ lwkt_gettoken(&ext2_ihash_token);
if (ip->i_flag & IN_HASHED) {
ipp = INOHASH(ip->i_dev, ip->i_number);
while ((iq = *ipp) != NULL) {
ip->i_next = NULL;
ip->i_flag &= ~IN_HASHED;
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ext2_ihash_token);
}
{
struct ext2_fsync_bp_info info;
struct vnode *vp = ap->a_vp;
- lwkt_tokref vlock;
int count;
/*
*/
ext2_discard_prealloc(VTOI(vp));
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
info.vp = vp;
loop:
info.waitfor = ap->a_waitfor;
}
#endif
}
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (EXT2_UPDATE(ap->a_vp, ap->a_waitfor == MNT_WAIT));
}
{
struct vnode *vp = ap->a_vp;
struct knote *kn = ap->a_kn;
- lwkt_tokref vlock;
switch (kn->kn_filter) {
case EVFILT_READ:
kn->kn_hook = (caddr_t)vp;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
SLIST_INSERT_HEAD(&vp->v_pollinfo.vpi_selinfo.si_note, kn, kn_selnext);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (0);
}
filt_ext2detach(struct knote *kn)
{
struct vnode *vp = (struct vnode *)kn->kn_hook;
- lwkt_tokref vlock;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
SLIST_REMOVE(&vp->v_pollinfo.vpi_selinfo.si_note,
kn, knote, kn_selnext);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
}
/*ARGSUSED*/
{
struct vnode *vp = ap->a_vp;
struct knote *kn = ap->a_kn;
- lwkt_tokref vlock;
switch (kn->kn_filter) {
case EVFILT_READ:
kn->kn_hook = (caddr_t)vp;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
SLIST_INSERT_HEAD(&vp->v_pollinfo.vpi_selinfo.si_note, kn, kn_selnext);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return(0);
}
filt_hammerdetach(struct knote *kn)
{
struct vnode *vp = (void *)kn->kn_hook;
- lwkt_tokref vlock;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
SLIST_REMOVE(&vp->v_pollinfo.vpi_selinfo.si_note,
kn, knote, kn_selnext);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
}
static int
lockinit (&hpfs_hphash_lock, "hpfs_hphashlock", 0, 0);
hpfs_hphashtbl = HASHINIT(desiredvnodes, M_HPFSHASH, M_WAITOK,
&hpfs_hphash);
- lwkt_token_init(&hpfs_hphash_token);
+ lwkt_token_init(&hpfs_hphash_token, 1);
}
/*
int
hpfs_hphash_uninit(struct vfsconf *vfc)
{
- lwkt_tokref ilock;
-
- lwkt_gettoken(&ilock, &hpfs_hphash_token);
+ lwkt_gettoken(&hpfs_hphash_token);
if (hpfs_hphashtbl)
kfree(hpfs_hphashtbl, M_HPFSHASH);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&hpfs_hphash_token);
return 0;
}
hpfs_hphashlookup(cdev_t dev, lsn_t ino)
{
struct hpfsnode *hp;
- lwkt_tokref ilock;
- lwkt_gettoken(&ilock, &hpfs_hphash_token);
+ lwkt_gettoken(&hpfs_hphash_token);
for (hp = HPNOHASH(dev, ino)->lh_first; hp; hp = hp->h_hash.le_next) {
if (ino == hp->h_no && dev == hp->h_dev)
break;
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&hpfs_hphash_token);
return (hp);
}
hpfs_hphashvget(cdev_t dev, lsn_t ino)
{
struct hpfsnode *hp;
- lwkt_tokref ilock;
struct vnode *vp;
- lwkt_gettoken(&ilock, &hpfs_hphash_token);
+ lwkt_gettoken(&hpfs_hphash_token);
loop:
for (hp = HPNOHASH(dev, ino)->lh_first; hp; hp = hp->h_hash.le_next) {
if (ino != hp->h_no || dev != hp->h_dev)
/*
* Or if the vget fails (due to a race)
*/
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&hpfs_hphash_token);
return (vp);
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&hpfs_hphash_token);
return (NULLVP);
}
hpfs_hphashins(struct hpfsnode *hp)
{
struct hphashhead *hpp;
- lwkt_tokref ilock;
- lwkt_gettoken(&ilock, &hpfs_hphash_token);
+ lwkt_gettoken(&hpfs_hphash_token);
hpp = HPNOHASH(hp->h_dev, hp->h_no);
hp->h_flag |= H_HASHED;
LIST_INSERT_HEAD(hpp, hp, h_hash);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&hpfs_hphash_token);
}
/*
void
hpfs_hphashrem(struct hpfsnode *hp)
{
- lwkt_tokref ilock;
-
- lwkt_gettoken(&ilock, &hpfs_hphash_token);
+ lwkt_gettoken(&hpfs_hphash_token);
if (hp->h_flag & H_HASHED) {
hp->h_flag &= ~H_HASHED;
LIST_REMOVE(hp, h_hash);
hp->h_hash.le_prev = NULL;
#endif
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&hpfs_hphash_token);
}
if (ino == (ino_t)hpmp->hpm_su.su_rootfno)
vsetflags(vp, VROOT);
- lwkt_token_init(&hp->h_interlock);
+ lwkt_token_init(&hp->h_interlock, 1);
hp->h_flag = H_INVAL;
hp->h_vp = vp;
isohashtbl = kmalloc(sizeof(void *) * isohash,
M_ISOFSMNT, M_WAITOK|M_ZERO);
--isohash;
- lwkt_token_init(&cd9660_ihash_token);
+ lwkt_token_init(&cd9660_ihash_token, 1);
return (0);
}
cd9660_ihashget(cdev_t dev, ino_t inum)
{
struct iso_node *ip;
- lwkt_tokref ilock;
struct vnode *vp;
- lwkt_gettoken(&ilock, &cd9660_ihash_token);
+ lwkt_gettoken(&cd9660_ihash_token);
loop:
for (ip = isohashtbl[INOHASH(dev, inum)]; ip; ip = ip->i_next) {
if (inum != ip->i_number || dev != ip->i_dev)
if (ip == NULL || ITOV(ip) != vp) {
goto loop;
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&cd9660_ihash_token);
return (vp);
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&cd9660_ihash_token);
return (NULL);
}
cd9660_ihashins(struct iso_node *ip)
{
struct iso_node **ipp, *iq;
- lwkt_tokref ilock;
- lwkt_gettoken(&ilock, &cd9660_ihash_token);
+ lwkt_gettoken(&cd9660_ihash_token);
ipp = &isohashtbl[INOHASH(ip->i_dev, ip->i_number)];
while ((iq = *ipp) != NULL) {
if (iq->i_dev == ip->i_dev && iq->i_number == ip->i_number) {
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&cd9660_ihash_token);
return(EBUSY);
}
ipp = &iq->i_next;
}
ip->i_next = NULL;
*ipp = ip;
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&cd9660_ihash_token);
return(0);
}
cd9660_ihashrem(struct iso_node *ip)
{
struct iso_node **ipp, *iq;
- lwkt_tokref ilock;
- lwkt_gettoken(&ilock, &cd9660_ihash_token);
+ lwkt_gettoken(&cd9660_ihash_token);
ipp = &isohashtbl[INOHASH(ip->i_dev, ip->i_number)];
while ((iq = *ipp) != NULL) {
if (ip == iq)
KKASSERT(ip == iq);
*ipp = ip->i_next;
ip->i_next = NULL;
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&cd9660_ihash_token);
}
/*
dehashtbl = kmalloc(sizeof(void *) * dehash, M_MSDOSFSMNT,
M_WAITOK|M_ZERO);
--dehash;
- lwkt_token_init(&dehash_token);
+ lwkt_token_init(&dehash_token, 1);
return (0);
}
msdosfs_hashget(cdev_t dev, u_long dirclust, u_long diroff)
{
struct denode *dep;
- lwkt_tokref ilock;
struct vnode *vp;
- lwkt_gettoken(&ilock, &dehash_token);
+ lwkt_gettoken(&dehash_token);
loop:
for (dep = DEHASH(dev, dirclust, diroff); dep; dep = dep->de_next) {
if (dirclust != dep->de_dirclust
vput(vp);
goto loop;
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&dehash_token);
return (dep);
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&dehash_token);
return (NULL);
}
msdosfs_hashins(struct denode *dep)
{
struct denode **depp, *deq;
- lwkt_tokref ilock;
- lwkt_gettoken(&ilock, &dehash_token);
+ lwkt_gettoken(&dehash_token);
depp = &DEHASH(dep->de_dev, dep->de_dirclust, dep->de_diroffset);
while ((deq = *depp) != NULL) {
if (deq->de_dev == dep->de_dev &&
deq->de_dirclust == dep->de_dirclust &&
deq->de_diroffset == dep->de_diroffset &&
deq->de_refcnt > 0) {
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&dehash_token);
return(EBUSY);
}
depp = &deq->de_next;
}
dep->de_next = NULL;
*depp = dep;
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&dehash_token);
return(0);
}
msdosfs_hashrem(struct denode *dep)
{
struct denode **depp, *deq;
- lwkt_tokref ilock;
- lwkt_gettoken(&ilock, &dehash_token);
+ lwkt_gettoken(&dehash_token);
depp = &DEHASH(dep->de_dev, dep->de_dirclust, dep->de_diroffset);
while ((deq = *depp) != NULL) {
if (dep == deq)
KKASSERT(dep == deq);
*depp = dep->de_next;
dep->de_next = NULL;
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&dehash_token);
}
void
msdosfs_reinsert(struct denode *ip, u_long new_dirclust, u_long new_diroffset)
{
- lwkt_tokref ilock;
int error;
- lwkt_gettoken(&ilock, &dehash_token);
+ lwkt_gettoken(&dehash_token);
msdosfs_hashrem(ip);
ip->de_dirclust = new_dirclust;
ip->de_diroffset = new_diroffset;
error = msdosfs_hashins(ip);
KASSERT(!error, ("msdosfs_reinsert: insertion failed %d", error));
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&dehash_token);
}
/*
nfs_clearcommit_callback(struct mount *mp, struct vnode *vp,
void *data __unused)
{
- lwkt_tokref vlock;
-
vhold(vp);
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
RB_SCAN(buf_rb_tree, &vp->v_rbdirty_tree, NULL,
nfs_clearcommit_bp, NULL);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
vdrop(vp);
return(0);
}
struct nfsnode *np = VTONFS(vp);
struct nfsmount *nmp = VFSTONFS(vp->v_mount);
struct nfs_flush_info info;
- lwkt_tokref vlock;
int error;
bzero(&info, sizeof(info));
info.waitfor = waitfor;
info.slpflag = (nmp->nm_flag & NFSMNT_INT) ? PCATCH : 0;
info.loops = 0;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
do {
/*
error = np->n_error;
np->n_flag &= ~NWRITEERR;
}
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (error);
}
lockinit(&ntfs_hashlock, "ntfs_nthashlock", 0, 0);
ntfs_nthashtbl = HASHINIT(desiredvnodes, M_NTFSNTHASH, M_WAITOK,
&ntfs_nthash);
- lwkt_token_init(&ntfs_nthash_slock);
+ lwkt_token_init(&ntfs_nthash_slock, 1);
}
/*
int
ntfs_nthash_uninit(struct vfsconf *vfc)
{
- lwkt_tokref ilock;
-
- lwkt_gettoken(&ilock, &ntfs_nthash_slock);
+ lwkt_gettoken(&ntfs_nthash_slock);
if (ntfs_nthashtbl)
kfree(ntfs_nthashtbl, M_NTFSNTHASH);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ntfs_nthash_slock);
return 0;
}
ntfs_nthashlookup(cdev_t dev, ino_t inum)
{
struct ntnode *ip;
- lwkt_tokref ilock;
- lwkt_gettoken(&ilock, &ntfs_nthash_slock);
+ lwkt_gettoken(&ntfs_nthash_slock);
for (ip = NTNOHASH(dev, inum)->lh_first; ip; ip = ip->i_hash.le_next) {
if (inum == ip->i_number && dev == ip->i_dev)
break;
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ntfs_nthash_slock);
return (ip);
}
ntfs_nthashins(struct ntnode *ip)
{
struct nthashhead *ipp;
- lwkt_tokref ilock;
- lwkt_gettoken(&ilock, &ntfs_nthash_slock);
+ lwkt_gettoken(&ntfs_nthash_slock);
ipp = NTNOHASH(ip->i_dev, ip->i_number);
LIST_INSERT_HEAD(ipp, ip, i_hash);
ip->i_flag |= IN_HASHED;
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ntfs_nthash_slock);
}
/*
void
ntfs_nthashrem(struct ntnode *ip)
{
- lwkt_tokref ilock;
-
- lwkt_gettoken(&ilock, &ntfs_nthash_slock);
+ lwkt_gettoken(&ntfs_nthash_slock);
if (ip->i_flag & IN_HASHED) {
ip->i_flag &= ~IN_HASHED;
LIST_REMOVE(ip, i_hash);
ip->i_hash.le_prev = NULL;
#endif
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ntfs_nthash_slock);
}
struct vnode *rootvp;
struct thread *td = curthread; /* XXX */
struct ntfs_args args;
- lwkt_tokref ilock;
int error;
if (root_device->dv_class != DV_DISK)
brelse(bp);
bp = NULL;
- lwkt_token_init(&udfmp->hash_token);
+ lwkt_token_init(&udfmp->hash_token, 1);
udfmp->hashtbl = phashinit(UDF_HASHTBLSIZE, M_UDFMOUNT, &udfmp->hashsz);
return(0);
struct udf_node *node;
struct udf_hash_lh *lh;
struct vnode *vp;
- lwkt_tokref hashlock;
*vpp = NULL;
- lwkt_gettoken(&hashlock, &udfmp->hash_token);
+ lwkt_gettoken(&udfmp->hash_token);
loop:
lh = &udfmp->hashtbl[id % udfmp->hashsz];
if (lh == NULL) {
- lwkt_reltoken(&hashlock);
+ lwkt_reltoken(&udfmp->hash_token);
return(ENOENT);
}
LIST_FOREACH(node, lh, le) {
vput(vp);
goto loop;
}
- lwkt_reltoken(&hashlock);
+ lwkt_reltoken(&udfmp->hash_token);
*vpp = vp;
return(0);
}
- lwkt_reltoken(&hashlock);
+ lwkt_reltoken(&udfmp->hash_token);
return(0);
}
{
struct udf_mnt *udfmp;
struct udf_hash_lh *lh;
- lwkt_tokref hashlock;
udfmp = node->udfmp;
- lwkt_gettoken(&hashlock, &udfmp->hash_token);
+ lwkt_gettoken(&udfmp->hash_token);
lh = &udfmp->hashtbl[node->hash_id % udfmp->hashsz];
LIST_INSERT_HEAD(lh, node, le);
- lwkt_reltoken(&hashlock);
+ lwkt_reltoken(&udfmp->hash_token);
return(0);
}
{
struct udf_mnt *udfmp;
struct udf_hash_lh *lh;
- lwkt_tokref hashlock;
udfmp = node->udfmp;
- lwkt_gettoken(&hashlock, &udfmp->hash_token);
+ lwkt_gettoken(&udfmp->hash_token);
lh = &udfmp->hashtbl[node->hash_id % udfmp->hashsz];
if (lh == NULL)
panic("hash entry is NULL, node->hash_id= %"PRId64"\n", node->hash_id);
LIST_REMOVE(node, le);
- lwkt_reltoken(&hashlock);
+ lwkt_reltoken(&udfmp->hash_token);
return(0);
}
{
int error;
int upgraded;
- lwkt_tokref vlock;
/*
* Check for dirty mmap, pending writes and dirty buffers
*/
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
if (bio_track_active(&vp->v_track_write) ||
!RB_EMPTY(&vp->v_rbdirty_tree) ||
(vp->v_flag & VOBJDIRTY) != 0) {
error = 0;
}
done:
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return error;
}
struct freeblks *freeblks;
struct inodedep *inodedep;
struct allocdirect *adp;
- lwkt_tokref vlock;
struct vnode *vp;
struct buf *bp;
struct fs *fs;
info.fs = fs;
info.ip = ip;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
do {
count = RB_SCAN(buf_rb_tree, &vp->v_rbdirty_tree, NULL,
softdep_setup_freeblocks_bp, &info);
} while (count != 0);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
if (inodedep_lookup(fs, ip->i_number, 0, &inodedep) != 0)
(void)free_inodedep(inodedep);
void
softdep_fsync_mountdev(struct vnode *vp)
{
- lwkt_tokref vlock;
-
if (!vn_isdisk(vp, NULL))
panic("softdep_fsync_mountdev: vnode not a disk");
ACQUIRE_LOCK(&lk);
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
RB_SCAN(buf_rb_tree, &vp->v_rbdirty_tree, NULL,
softdep_fsync_mountdev_bp, vp);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
drain_output(vp, 1);
FREE_LOCK(&lk);
}
softdep_sync_metadata(struct vnode *vp, struct thread *td)
{
struct softdep_sync_metadata_info info;
- lwkt_tokref vlock;
int error, waitfor;
/*
info.vp = vp;
info.waitfor = waitfor;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
error = RB_SCAN(buf_rb_tree, &vp->v_rbdirty_tree, NULL,
softdep_sync_metadata_bp, &info);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
if (error < 0) {
FREE_LOCK(&lk);
return(-error); /* error code */
ihash <<= 1;
ihashtbl = kmalloc(sizeof(void *) * ihash, M_UFSIHASH, M_WAITOK|M_ZERO);
--ihash;
- lwkt_token_init(&ufs_ihash_token);
+ lwkt_token_init(&ufs_ihash_token, 1);
}
int
ufs_uninit(struct vfsconf *vfc)
{
- lwkt_tokref ilock;
-
- lwkt_gettoken(&ilock, &ufs_ihash_token);
+ lwkt_gettoken(&ufs_ihash_token);
if (ihashtbl)
kfree(ihashtbl, M_UFSIHASH);
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ufs_ihash_token);
return (0);
}
ufs_ihashlookup(cdev_t dev, ino_t inum)
{
struct inode *ip;
- lwkt_tokref ilock;
- lwkt_gettoken(&ilock, &ufs_ihash_token);
+ lwkt_gettoken(&ufs_ihash_token);
for (ip = *INOHASH(dev, inum); ip; ip = ip->i_next) {
if (inum == ip->i_number && dev == ip->i_dev)
break;
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ufs_ihash_token);
if (ip)
return (ITOV(ip));
return (NULLVP);
struct vnode *
ufs_ihashget(cdev_t dev, ino_t inum)
{
- lwkt_tokref ilock;
struct inode *ip;
struct vnode *vp;
- lwkt_gettoken(&ilock, &ufs_ihash_token);
+ lwkt_gettoken(&ufs_ihash_token);
loop:
for (ip = *INOHASH(dev, inum); ip; ip = ip->i_next) {
if (inum != ip->i_number || dev != ip->i_dev)
vput(vp);
goto loop;
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ufs_ihash_token);
return (vp);
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ufs_ihash_token);
return (NULL);
}
int
ufs_ihashcheck(cdev_t dev, ino_t inum)
{
- lwkt_tokref ilock;
struct inode *ip;
- lwkt_gettoken(&ilock, &ufs_ihash_token);
+ lwkt_gettoken(&ufs_ihash_token);
for (ip = *INOHASH(dev, inum); ip; ip = ip->i_next) {
if (inum == ip->i_number && dev == ip->i_dev)
break;
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ufs_ihash_token);
return(ip ? 1 : 0);
}
{
struct inode **ipp;
struct inode *iq;
- lwkt_tokref ilock;
KKASSERT((ip->i_flag & IN_HASHED) == 0);
- lwkt_gettoken(&ilock, &ufs_ihash_token);
+ lwkt_gettoken(&ufs_ihash_token);
ipp = INOHASH(ip->i_dev, ip->i_number);
while ((iq = *ipp) != NULL) {
if (ip->i_dev == iq->i_dev && ip->i_number == iq->i_number) {
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ufs_ihash_token);
return(EBUSY);
}
ipp = &iq->i_next;
ip->i_next = NULL;
*ipp = ip;
ip->i_flag |= IN_HASHED;
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ufs_ihash_token);
return(0);
}
void
ufs_ihashrem(struct inode *ip)
{
- lwkt_tokref ilock;
struct inode **ipp;
struct inode *iq;
- lwkt_gettoken(&ilock, &ufs_ihash_token);
+ lwkt_gettoken(&ufs_ihash_token);
if (ip->i_flag & IN_HASHED) {
ipp = INOHASH(ip->i_dev, ip->i_number);
while ((iq = *ipp) != NULL) {
ip->i_next = NULL;
ip->i_flag &= ~IN_HASHED;
}
- lwkt_reltoken(&ilock);
+ lwkt_reltoken(&ufs_ihash_token);
}
{
struct vnode *vp = ap->a_vp;
struct knote *kn = ap->a_kn;
- lwkt_tokref vlock;
switch (kn->kn_filter) {
case EVFILT_READ:
kn->kn_hook = (caddr_t)vp;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
SLIST_INSERT_HEAD(&vp->v_pollinfo.vpi_selinfo.si_note, kn, kn_selnext);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
return (0);
}
filt_ufsdetach(struct knote *kn)
{
struct vnode *vp = (struct vnode *)kn->kn_hook;
- lwkt_tokref vlock;
- lwkt_gettoken(&vlock, &vp->v_token);
+ lwkt_gettoken(&vp->v_token);
SLIST_REMOVE(&vp->v_pollinfo.vpi_selinfo.si_note,
kn, knote, kn_selnext);
- lwkt_reltoken(&vlock);
+ lwkt_reltoken(&vp->v_token);
}
/*ARGSUSED*/