diff options
author | rwatson <rwatson@FreeBSD.org> | 2003-10-25 16:14:09 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2003-10-25 16:14:09 +0000 |
commit | e4935eb9ae5e1423e2efddfa52176de132ced5a8 (patch) | |
tree | 77638b02a496de64e94d441af6e17bc4e6bd21ec /sys | |
parent | 723804b2614efedcd5f10e95ad05af6ddba47258 (diff) | |
download | FreeBSD-src-e4935eb9ae5e1423e2efddfa52176de132ced5a8.zip FreeBSD-src-e4935eb9ae5e1423e2efddfa52176de132ced5a8.tar.gz |
When generate a core dump, use advisory locking in an advisory way:
if we do acquire an advisory lock, great! We'll release it later.
However, if we fail to acquire a lock, we perform the coredump
anyway. This problem became particularly visible with NFS after
the introduction of rpc.lockd: if the lock manager isn't running,
then locking calls will fail, aborting the core dump (resulting in
a zero-byte dump file).
Reported by: Yogeshwar Shenoy <ynshenoy@alumni.cs.ucsb.edu>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_sig.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index e83ad6c..0b14a4d 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -2521,7 +2521,7 @@ coredump(struct thread *td) struct flock lf; struct nameidata nd; struct vattr vattr; - int error, error1, flags; + int error, error1, flags, locked; struct mount *mp; char *name; /* name of corefile */ off_t limit; @@ -2575,9 +2575,7 @@ restart: lf.l_start = 0; lf.l_len = 0; lf.l_type = F_WRLCK; - error = VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &lf, F_FLOCK); - if (error) - goto out2; + locked = (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &lf, F_FLOCK) == 0); if (vn_start_write(vp, &mp, V_NOWAIT) != 0) { lf.l_type = F_UNLCK; @@ -2603,8 +2601,10 @@ restart: p->p_sysent->sv_coredump(td, vp, limit) : ENOSYS; - lf.l_type = F_UNLCK; - VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &lf, F_FLOCK); + if (locked) { + lf.l_type = F_UNLCK; + VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &lf, F_FLOCK); + } vn_finished_write(mp); out2: error1 = vn_close(vp, FWRITE, cred, td); |