Sprinkle some hackish locks here and there, just enough to allow
libp2k & rump to run multithreaded.
This commit is contained in:
parent
94c0a71eb1
commit
40ffc8b91f
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dispatcher.c,v 1.18 2007/10/28 18:40:30 pooka Exp $ */
|
||||
/* $NetBSD: dispatcher.c,v 1.19 2007/10/29 15:52:44 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006, 2007 Antti Kantee. All Rights Reserved.
|
||||
@ -30,7 +30,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if !defined(lint)
|
||||
__RCSID("$NetBSD: dispatcher.c,v 1.18 2007/10/28 18:40:30 pooka Exp $");
|
||||
__RCSID("$NetBSD: dispatcher.c,v 1.19 2007/10/29 15:52:44 pooka Exp $");
|
||||
#endif /* !lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -183,17 +183,18 @@ puffs_dopreq(struct puffs_usermount *pu, struct puffs_req *preq,
|
||||
*/
|
||||
pex = malloc(sizeof(struct puffs_executor));
|
||||
pex->pex_preq = preq;
|
||||
/* mutex_enter */
|
||||
PU_LOCK();
|
||||
TAILQ_INSERT_TAIL(&pu->pu_exq, pex, pex_entries);
|
||||
TAILQ_FOREACH(pex, &pu->pu_exq, pex_entries) {
|
||||
if (pex->pex_preq->preq_pid == preq->preq_pid
|
||||
&& pex->pex_preq->preq_lid == preq->preq_lid) {
|
||||
if (pex->pex_preq != preq) {
|
||||
/* mutex_exit */
|
||||
PU_UNLOCK();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
PU_UNLOCK();
|
||||
|
||||
return dopreq2(pu, preq, ppr);
|
||||
}
|
||||
@ -207,7 +208,7 @@ puffs_docc(struct puffs_cc *pcc, struct puffs_putreq *ppr)
|
||||
struct puffs_usermount *pu = pcc->pcc_pu;
|
||||
struct puffs_req *preq;
|
||||
struct puffs_cc *pcc_iter;
|
||||
struct puffs_executor *pex;
|
||||
struct puffs_executor *pex, *pex_n;
|
||||
int found;
|
||||
|
||||
assert((pcc->pcc_flags & PCC_DONE) == 0);
|
||||
@ -221,8 +222,9 @@ puffs_docc(struct puffs_cc *pcc, struct puffs_putreq *ppr)
|
||||
/* check if we need to schedule FAFs which were stalled */
|
||||
found = 0;
|
||||
preq = pcc->pcc_preq;
|
||||
/* mutex_enter */
|
||||
TAILQ_FOREACH(pex, &pu->pu_exq, pex_entries) {
|
||||
PU_LOCK();
|
||||
for (pex = TAILQ_FIRST(&pu->pu_exq); pex; pex = pex_n) {
|
||||
pex_n = TAILQ_NEXT(pex, pex_entries);
|
||||
if (pex->pex_preq->preq_pid == preq->preq_pid
|
||||
&& pex->pex_preq->preq_lid == preq->preq_lid) {
|
||||
if (found == 0) {
|
||||
@ -238,13 +240,13 @@ puffs_docc(struct puffs_cc *pcc, struct puffs_putreq *ppr)
|
||||
}
|
||||
}
|
||||
}
|
||||
/* mutex_exit */
|
||||
|
||||
/* can't do this above due to PCC_BORROWED */
|
||||
while ((pcc_iter = LIST_FIRST(&pu->pu_ccnukelst)) != NULL) {
|
||||
LIST_REMOVE(pcc_iter, nlst_entries);
|
||||
puffs_cc_destroy(pcc_iter);
|
||||
}
|
||||
PU_UNLOCK();
|
||||
}
|
||||
|
||||
/* library private, but linked from callcontext.c */
|
||||
@ -728,9 +730,11 @@ puffs_calldispatcher(struct puffs_cc *pcc)
|
||||
pi.pi_old = &pcn_src.pcn_po_full;
|
||||
pi.pi_new = &pcn_targ.pcn_po_full;
|
||||
|
||||
PU_LOCK();
|
||||
if (puffs_pn_nodewalk(pu,
|
||||
puffs_path_prefixadj, &pi) != NULL)
|
||||
error = ENOMEM;
|
||||
PU_UNLOCK();
|
||||
pu->pu_pathfree(pu, &po_old);
|
||||
}
|
||||
}
|
||||
@ -1067,7 +1071,9 @@ processresult(struct puffs_cc *pcc, struct puffs_putreq *ppr, int how)
|
||||
puffs_req_putcc(ppr, pcc);
|
||||
break;
|
||||
case PUFFCALL_IGNORE:
|
||||
PU_LOCK();
|
||||
LIST_INSERT_HEAD(&pu->pu_ccnukelst, pcc, nlst_entries);
|
||||
PU_UNLOCK();
|
||||
break;
|
||||
case PUFFCALL_AGAIN:
|
||||
if ((pcc->pcc_flags & PCC_REALCC) == 0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: opdump.c,v 1.16 2007/10/26 17:24:45 pooka Exp $ */
|
||||
/* $NetBSD: opdump.c,v 1.17 2007/10/29 15:52:45 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if !defined(lint)
|
||||
__RCSID("$NetBSD: opdump.c,v 1.16 2007/10/26 17:24:45 pooka Exp $");
|
||||
__RCSID("$NetBSD: opdump.c,v 1.17 2007/10/29 15:52:45 pooka Exp $");
|
||||
#endif /* !lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -45,6 +45,8 @@ __RCSID("$NetBSD: opdump.c,v 1.16 2007/10/26 17:24:45 pooka Exp $");
|
||||
#include <puffsdump.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "puffs_priv.h"
|
||||
|
||||
/* XXX! */
|
||||
const char *vfsop_revmap[] = {
|
||||
"PUFFS_VFS_MOUNT",
|
||||
@ -174,10 +176,12 @@ puffsdump_req(struct puffs_req *preq)
|
||||
}
|
||||
}
|
||||
|
||||
PU_LOCK();
|
||||
gettimeofday(&tv_now, NULL);
|
||||
timersub(&tv_now, &tv_prev, &tv);
|
||||
printf("\t\tsince previous call: %ld.%06ld\n", tv.tv_sec, tv.tv_usec);
|
||||
gettimeofday(&tv_prev, NULL);
|
||||
PU_UNLOCK();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: puffs.c,v 1.71 2007/10/28 18:40:30 pooka Exp $ */
|
||||
/* $NetBSD: puffs.c,v 1.72 2007/10/29 15:52:45 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if !defined(lint)
|
||||
__RCSID("$NetBSD: puffs.c,v 1.71 2007/10/28 18:40:30 pooka Exp $");
|
||||
__RCSID("$NetBSD: puffs.c,v 1.72 2007/10/29 15:52:45 pooka Exp $");
|
||||
#endif /* !lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -59,6 +59,11 @@ const struct mntopt puffsmopts[] = {
|
||||
MOPT_NULL,
|
||||
};
|
||||
|
||||
#ifdef PUFFS_WITH_THREADS
|
||||
#include <pthread.h>
|
||||
pthread_mutex_t pu_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
#endif
|
||||
|
||||
#define FILLOP(lower, upper) \
|
||||
do { \
|
||||
if (pops->puffs_node_##lower) \
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: puffs_priv.h,v 1.29 2007/10/28 18:40:31 pooka Exp $ */
|
||||
/* $NetBSD: puffs_priv.h,v 1.30 2007/10/29 15:52:45 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
|
||||
@ -34,6 +34,17 @@
|
||||
#include <puffs.h>
|
||||
#include <ucontext.h>
|
||||
|
||||
#ifdef PUFFS_WITH_THREADS
|
||||
#include <pthread.h>
|
||||
|
||||
extern pthread_mutex_t pu_lock;
|
||||
#define PU_LOCK() pthread_mutex_lock(&pu_lock);
|
||||
#define PU_UNLOCK() pthread_mutex_unlock(&pu_lock);
|
||||
#else
|
||||
#define PU_LOCK()
|
||||
#define PU_UNLOCK()
|
||||
#endif
|
||||
|
||||
#define PU_CMAP(pu, c) (pu->pu_cmap ? pu->pu_cmap(c) : (struct puffs_node *)c)
|
||||
|
||||
struct puffs_framectrl {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: requests.c,v 1.13 2007/10/26 17:35:02 pooka Exp $ */
|
||||
/* $NetBSD: requests.c,v 1.14 2007/10/29 15:52:45 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
|
||||
@ -27,7 +27,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if !defined(lint)
|
||||
__RCSID("$NetBSD: requests.c,v 1.13 2007/10/26 17:35:02 pooka Exp $");
|
||||
__RCSID("$NetBSD: requests.c,v 1.14 2007/10/29 15:52:45 pooka Exp $");
|
||||
#endif /* !lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -162,7 +162,9 @@ puffs_req_putcc(struct puffs_putreq *ppr, struct puffs_cc *pcc)
|
||||
{
|
||||
|
||||
puffs_req_put(ppr, pcc->pcc_preq);
|
||||
PU_LOCK();
|
||||
TAILQ_INSERT_TAIL(&ppr->ppr_pccq, pcc, entries);
|
||||
PU_UNLOCK();
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
@ -178,10 +180,12 @@ puffs_req_resetput(struct puffs_putreq *ppr)
|
||||
{
|
||||
struct puffs_cc *pcc;
|
||||
|
||||
PU_LOCK();
|
||||
while ((pcc = TAILQ_FIRST(&ppr->ppr_pccq)) != NULL) {
|
||||
TAILQ_REMOVE(&ppr->ppr_pccq, pcc, entries);
|
||||
puffs_cc_destroy(pcc);
|
||||
}
|
||||
PU_UNLOCK();
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user