Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F148314387
D19887.id56151.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D19887.id56151.diff
View Options
Index: sys/fs/nfs/nfsport.h
===================================================================
--- sys/fs/nfs/nfsport.h
+++ sys/fs/nfs/nfsport.h
@@ -692,8 +692,6 @@
#define NFSUNLOCKMNT(m) mtx_unlock(&((m)->nm_mtx))
#define NFSLOCKREQUEST(r) mtx_lock(&((r)->r_mtx))
#define NFSUNLOCKREQUEST(r) mtx_unlock(&((r)->r_mtx))
-#define NFSPROCLISTLOCK() sx_slock(&allproc_lock)
-#define NFSPROCLISTUNLOCK() sx_sunlock(&allproc_lock)
#define NFSLOCKSOCKREQ(r) mtx_lock(&((r)->nr_mtx))
#define NFSUNLOCKSOCKREQ(r) mtx_unlock(&((r)->nr_mtx))
#define NFSLOCKDS(d) mtx_lock(&((d)->nfsclds_mtx))
Index: sys/fs/nfsclient/nfs_clport.c
===================================================================
--- sys/fs/nfsclient/nfs_clport.c
+++ sys/fs/nfsclient/nfs_clport.c
@@ -1157,7 +1157,7 @@
tl.cval[2] = *own++;
tl.cval[3] = *own++;
pid = tl.lval;
- p = pfind(pid);
+ p = pfind_locked(pid);
if (p == NULL)
return (1);
if (p->p_stats == NULL) {
Index: sys/fs/nfsclient/nfs_clstate.c
===================================================================
--- sys/fs/nfsclient/nfs_clstate.c
+++ sys/fs/nfsclient/nfs_clstate.c
@@ -1788,8 +1788,16 @@
struct nfsclopen *op;
struct nfscllockowner *lp, *nlp;
struct nfscldeleg *dp;
+ int i;
- NFSPROCLISTLOCK();
+ /*
+ * All the pidhash locks must be acquired, since they are sx locks
+ * and must be acquired before the mutexes. The pid(s) that will
+ * be used aren't known yet, so all the locks need to be acquired.
+ * Fortunately, this function is only performed once/sec.
+ */
+ for (i = 0; i < pidhashlock + 1; i++)
+ sx_slock(&pidhashtbl_lock[i]);
NFSLOCKCLSTATE();
LIST_FOREACH_SAFE(owp, &clp->nfsc_owner, nfsow_list, nowp) {
LIST_FOREACH(op, &owp->nfsow_open, nfso_list) {
@@ -1816,7 +1824,8 @@
}
}
NFSUNLOCKCLSTATE();
- NFSPROCLISTUNLOCK();
+ for (i = 0; i < pidhashlock + 1; i++)
+ sx_sunlock(&pidhashtbl_lock[i]);
}
/*
Index: sys/kern/kern_proc.c
===================================================================
--- sys/kern/kern_proc.c
+++ sys/kern/kern_proc.c
@@ -178,6 +178,7 @@
procinit(void)
{
u_long i;
+ char buf[16];
sx_init(&allproc_lock, "allproc");
sx_init(&zombproc_lock, "zombproc");
@@ -192,8 +193,10 @@
pidhashlock--;
pidhashtbl_lock = malloc(sizeof(*pidhashtbl_lock) * (pidhashlock + 1),
M_PROC, M_WAITOK | M_ZERO);
- for (i = 0; i < pidhashlock + 1; i++)
- sx_init(&pidhashtbl_lock[i], "pidhash");
+ for (i = 0; i < pidhashlock + 1; i++) {
+ snprintf(buf, sizeof(buf), "pidhash%ju", (uintmax_t)i);
+ sx_init(&pidhashtbl_lock[i], buf);
+ }
pgrphashtbl = hashinit(maxproc / 4, M_PROC, &pgrphash);
proc_zone = uma_zcreate("PROC", sched_sizeof_proc(),
proc_ctor, proc_dtor, proc_init, proc_fini,
@@ -365,6 +368,25 @@
return (0);
}
return (1);
+}
+
+struct proc *
+pfind_locked(pid_t pid)
+{
+ struct proc *p;
+
+ sx_assert(PIDHASHLOCK(pid), SX_LOCKED);
+ LIST_FOREACH(p, PIDHASH(pid), p_hash) {
+ if (p->p_pid == pid) {
+ PROC_LOCK(p);
+ if (p->p_state == PRS_NEW) {
+ PROC_UNLOCK(p);
+ p = NULL;
+ }
+ break;
+ }
+ }
+ return (p);
}
/*
Index: sys/sys/proc.h
===================================================================
--- sys/sys/proc.h
+++ sys/sys/proc.h
@@ -989,6 +989,7 @@
struct proc *pfind(pid_t); /* Find process by id. */
struct proc *pfind_any(pid_t); /* Find (zombie) process by id. */
+struct proc *pfind_locked(pid_t pid); /* Find process by id, locked. */
struct pgrp *pgfind(pid_t); /* Find process group by id. */
struct proc *zpfind(pid_t); /* Find zombie process by id. */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 18, 3:21 AM (14 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29874135
Default Alt Text
D19887.id56151.diff (3 KB)
Attached To
Mode
D19887: fix the NFSv4 client so that it doesn't call pfind() with a mutex held
Attached
Detach File
Event Timeline
Log In to Comment