From the submitter:
- this causes POSIX locking to use the thread group leader (p->p_leader) as the locking thread for all advisory locks. In non-kernel-threaded code p->p_leader == p, so this will have no effect. This results in (more) correct POSIX threaded flock-ing semantics. It also prevents the leader from exiting before any of the children. (so that p->p_leader will never be stale) in exit1(). We have been running this patch for over a month now in our lab under load and at customer sites. Submitted by: John Plevyak <jplevyak@inktomi.com>
This commit is contained in:
parent
a26aa2519f
commit
79fc0bf4a0
@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94
|
||||
* $Id: kern_descrip.c,v 1.62 1999/05/30 16:52:54 phk Exp $
|
||||
* $Id: kern_descrip.c,v 1.63 1999/05/31 11:27:30 phk Exp $
|
||||
*/
|
||||
|
||||
#include "opt_compat.h"
|
||||
@ -304,16 +304,16 @@ fcntl(p, uap)
|
||||
if ((fp->f_flag & FREAD) == 0)
|
||||
return (EBADF);
|
||||
p->p_flag |= P_ADVLOCK;
|
||||
return (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg));
|
||||
return (VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_SETLK, &fl, flg));
|
||||
|
||||
case F_WRLCK:
|
||||
if ((fp->f_flag & FWRITE) == 0)
|
||||
return (EBADF);
|
||||
p->p_flag |= P_ADVLOCK;
|
||||
return (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg));
|
||||
return (VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_SETLK, &fl, flg));
|
||||
|
||||
case F_UNLCK:
|
||||
return (VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &fl,
|
||||
return (VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_UNLCK, &fl,
|
||||
F_POSIX));
|
||||
|
||||
default:
|
||||
@ -334,7 +334,7 @@ fcntl(p, uap)
|
||||
return (EINVAL);
|
||||
if (fl.l_whence == SEEK_CUR)
|
||||
fl.l_start += fp->f_offset;
|
||||
if ((error = VOP_ADVLOCK(vp,(caddr_t)p,F_GETLK,&fl,F_POSIX)))
|
||||
if ((error = VOP_ADVLOCK(vp,(caddr_t)p->p_leader,F_GETLK,&fl,F_POSIX)))
|
||||
return (error);
|
||||
return (copyout((caddr_t)&fl, (caddr_t)(intptr_t)uap->arg,
|
||||
sizeof(fl)));
|
||||
@ -1064,7 +1064,7 @@ closef(fp, p)
|
||||
lf.l_len = 0;
|
||||
lf.l_type = F_UNLCK;
|
||||
vp = (struct vnode *)fp->f_data;
|
||||
(void) VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &lf, F_POSIX);
|
||||
(void) VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_UNLCK, &lf, F_POSIX);
|
||||
}
|
||||
if (--fp->f_count > 0)
|
||||
return (0);
|
||||
|
@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)kern_exit.c 8.7 (Berkeley) 2/12/94
|
||||
* $Id: kern_exit.c,v 1.79 1999/04/28 01:04:26 luoqi Exp $
|
||||
* $Id: kern_exit.c,v 1.80 1999/04/28 11:36:52 phk Exp $
|
||||
*/
|
||||
|
||||
#include "opt_compat.h"
|
||||
@ -143,21 +143,10 @@ exit1(p, rv)
|
||||
kill(p, &killArgs);
|
||||
nq = q;
|
||||
q = q->p_peers;
|
||||
/*
|
||||
* orphan the threads so we don't mess up
|
||||
* when they call exit
|
||||
*/
|
||||
nq->p_peers = 0;
|
||||
nq->p_leader = nq;
|
||||
}
|
||||
|
||||
/* otherwise are we a peer? */
|
||||
} else if(p->p_peers) {
|
||||
q = p->p_leader;
|
||||
while(q->p_peers != p)
|
||||
q = q->p_peers;
|
||||
q->p_peers = p->p_peers;
|
||||
}
|
||||
while (p->p_peers)
|
||||
tsleep((caddr_t)p, PWAIT, "exit1", 0);
|
||||
}
|
||||
|
||||
#ifdef PGINPROF
|
||||
vmsizmon();
|
||||
@ -200,6 +189,14 @@ exit1(p, rv)
|
||||
*/
|
||||
fdfree(p);
|
||||
|
||||
if(p->p_leader->p_peers) {
|
||||
q = p->p_leader;
|
||||
while(q->p_peers != p)
|
||||
q = q->p_peers;
|
||||
q->p_peers = p->p_peers;
|
||||
wakeup((caddr_t)p->p_leader);
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX Shutdown SYSV semaphores
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user