Date: Tue, 21 Mar 2006 18:50:03 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 93724 for review Message-ID: <200603211850.k2LIo3pg073182@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=93724 Change 93724 by jhb@jhb_slimer on 2006/03/21 18:49:19 Use VFS locking for Giant in coredump(). Actually avoids a Giant leak for coredumps to a non-MPSAFE filesystem. Affected files ... .. //depot/projects/smpng/sys/kern/kern_sig.c#121 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_sig.c#121 (text+ko) ==== @@ -3065,6 +3065,7 @@ struct mount *mp; char *name; /* name of corefile */ off_t limit; + int vfslocked; PROC_LOCK_ASSERT(p, MA_OWNED); MPASS((p->p_flag & P_HADTHREADS) == 0 || p->p_singlethread == td); @@ -3088,21 +3089,17 @@ if (limit == 0) return (EFBIG); - mtx_lock(&Giant); restart: name = expand_name(p->p_comm, td->td_ucred->cr_uid, p->p_pid); - if (name == NULL) { - mtx_unlock(&Giant); + if (name == NULL) return (EINVAL); - } - NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, td); /* XXXKSE */ + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, td); flags = O_CREAT | FWRITE | O_NOFOLLOW; error = vn_open(&nd, &flags, S_IRUSR | S_IWUSR, -1); free(name, M_TEMP); - if (error) { - mtx_unlock(&Giant); + if (error) return (error); - } + vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); vp = nd.ni_vp; @@ -3111,7 +3108,7 @@ VOP_GETATTR(vp, &vattr, cred, td) || vattr.va_nlink != 1) { VOP_UNLOCK(vp, 0, td); error = EFAULT; - goto out; + goto close; } VOP_UNLOCK(vp, 0, td); @@ -3126,9 +3123,10 @@ if (locked) VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &lf, F_FLOCK); if ((error = vn_close(vp, FWRITE, cred, td)) != 0) - return (error); + goto out; if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0) - return (error); + goto out; + VFS_UNLOCK_GIANT(vfslocked); goto restart; } @@ -3153,11 +3151,12 @@ VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &lf, F_FLOCK); } vn_finished_write(mp); -out: +close: error1 = vn_close(vp, FWRITE, cred, td); - mtx_unlock(&Giant); if (error == 0) error = error1; +out: + VFS_UNLOCK_GIANT(vfslocked); return (error); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603211850.k2LIo3pg073182>