summaryrefslogtreecommitdiffstats
path: root/sys/fs
diff options
context:
space:
mode:
authortanimura <tanimura@FreeBSD.org>2002-02-23 11:12:57 +0000
committertanimura <tanimura@FreeBSD.org>2002-02-23 11:12:57 +0000
commita09da298590e8c11ebafa37f79e0046814665237 (patch)
tree2289c653c0f7aa23498f82b603c33107952652ec /sys/fs
parent33e8ee5265ca2838260ab581a9cebdedb1e1e29b (diff)
downloadFreeBSD-src-a09da298590e8c11ebafa37f79e0046814665237.zip
FreeBSD-src-a09da298590e8c11ebafa37f79e0046814665237.tar.gz
Lock struct pgrp, session and sigio.
New locks are: - pgrpsess_lock which locks the whole pgrps and sessions, - pg_mtx which protects the pgrp members, and - s_mtx which protects the session members. Please refer to sys/proc.h for the coverage of these locks. Changes on the pgrp/session interface: - pgfind() needs the pgrpsess_lock held. - The caller of enterpgrp() is responsible to allocate a new pgrp and session. - Call enterthispgrp() in order to enter an existing pgrp. - pgsignal() requires a pgrp lock held. Reviewed by: jhb, alfred Tested on: cvsup.jp.FreeBSD.org (which is a quad-CPU machine running -current)
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/coda/coda_venus.c6
-rw-r--r--sys/fs/procfs/procfs_ctl.c4
-rw-r--r--sys/fs/procfs/procfs_status.c6
-rw-r--r--sys/fs/specfs/spec_vnops.c13
4 files changed, 21 insertions, 8 deletions
diff --git a/sys/fs/coda/coda_venus.c b/sys/fs/coda/coda_venus.c
index 022009e..e223617 100644
--- a/sys/fs/coda/coda_venus.c
+++ b/sys/fs/coda/coda_venus.c
@@ -94,13 +94,11 @@
#define INIT_IN(in, op, ident, p) \
(in)->opcode = (op); \
- if (p) \
- PROC_LOCK(p); \
+ PGRPSESS_SLOCK(); \
(in)->pid = p ? p->p_pid : -1; \
(in)->pgid = p ? p->p_pgid : -1; \
(in)->sid = (p && p->p_session && p->p_session->s_leader) ? (p->p_session->s_leader->p_pid) : -1; \
- if (p) \
- PROC_UNLOCK(p); \
+ PGRPSESS_SUNLOCK(); \
if (ident != NOCRED) { \
(in)->cred.cr_uid = ident->cr_uid; \
(in)->cred.cr_groupid = ident->cr_gid; \
diff --git a/sys/fs/procfs/procfs_ctl.c b/sys/fs/procfs/procfs_ctl.c
index 154eaa6..3a73980 100644
--- a/sys/fs/procfs/procfs_ctl.c
+++ b/sys/fs/procfs/procfs_ctl.c
@@ -230,8 +230,10 @@ out:
pp = pfind(p->p_oppid);
PROC_LOCK(p);
- if (pp)
+ if (pp) {
+ PROC_UNLOCK(pp);
proc_reparent(p, pp);
+ }
} else
PROC_LOCK(p);
p->p_oppid = 0;
diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c
index 0f8e343..9238dfe 100644
--- a/sys/fs/procfs/procfs_status.c
+++ b/sys/fs/procfs/procfs_status.c
@@ -48,6 +48,8 @@
#include <sys/mutex.h>
#include <sys/jail.h>
#include <sys/malloc.h>
+#include <sys/mutex.h>
+#include <sys/sx.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/sbuf.h>
@@ -75,9 +77,9 @@ procfs_doprocstatus(PFS_FILL_ARGS)
pid = p->p_pid;
PROC_LOCK(p);
ppid = p->p_pptr ? p->p_pptr->p_pid : 0;
- PROC_UNLOCK(p);
pgid = p->p_pgrp->pg_id;
sess = p->p_pgrp->pg_session;
+ SESS_LOCK(sess);
sid = sess->s_leader ? sess->s_leader->p_pid : 0;
/* comm pid ppid pgid sid maj,min ctty,sldr start ut st wmsg
@@ -106,6 +108,8 @@ procfs_doprocstatus(PFS_FILL_ARGS)
sbuf_printf(sb, "%ssldr", sep);
sep = ",";
}
+ SESS_UNLOCK(sess);
+ PROC_UNLOCK(p);
if (*sep != ',') {
sbuf_printf(sb, "noflags");
}
diff --git a/sys/fs/specfs/spec_vnops.c b/sys/fs/specfs/spec_vnops.c
index 9de659c..7887ddb 100644
--- a/sys/fs/specfs/spec_vnops.c
+++ b/sys/fs/specfs/spec_vnops.c
@@ -35,6 +35,8 @@
*/
#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/sx.h>
#include <sys/proc.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@@ -568,7 +570,7 @@ spec_close(ap)
struct thread *a_td;
} */ *ap;
{
- struct vnode *vp = ap->a_vp;
+ struct vnode *vp = ap->a_vp, *oldvp;
struct thread *td = ap->a_td;
dev_t dev = vp->v_rdev;
@@ -581,11 +583,18 @@ spec_close(ap)
* if the reference count is 2 (this last descriptor
* plus the session), release the reference from the session.
*/
+ oldvp = NULL;
+ PGRPSESS_XLOCK();
if (vcount(vp) == 2 && td && (vp->v_flag & VXLOCK) == 0 &&
vp == td->td_proc->p_session->s_ttyvp) {
- vrele(vp);
+ SESS_LOCK(td->td_proc->p_session);
td->td_proc->p_session->s_ttyvp = NULL;
+ SESS_UNLOCK(td->td_proc->p_session);
+ oldvp = vp;
}
+ PGRPSESS_XUNLOCK();
+ if (oldvp != NULL)
+ vrele(oldvp);
/*
* We do not want to really close the device if it
* is still in use unless we are trying to close it
OpenPOWER on IntegriCloud