diff options
author | Matthew Dempsky <matthew@cvs.openbsd.org> | 2011-07-06 09:14:27 +0000 |
---|---|---|
committer | Matthew Dempsky <matthew@cvs.openbsd.org> | 2011-07-06 09:14:27 +0000 |
commit | 02909a2dc2ffdde76a1229b482e840081b7466c3 (patch) | |
tree | 2daf97a05d30a189980ce772c5fd076e2f56e4d4 /sys | |
parent | d9a232e316f9bd3fe56f809415ac202599f232b8 (diff) |
Minor turd polishing: hold the vnode lock in vn_rdwr() only while
necessary.
"ok ... wait wait WAIT!! ... oh, yeah, it's fine, ok" guenther@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/vfs_vnops.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index c5f7d4c4dc8..001dca5bbe5 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_vnops.c,v 1.66 2011/07/04 20:35:35 deraadt Exp $ */ +/* $OpenBSD: vfs_vnops.c,v 1.67 2011/07/06 09:14:26 matthew Exp $ */ /* $NetBSD: vfs_vnops.c,v 1.20 1996/02/04 02:18:41 christos Exp $ */ /* @@ -255,8 +255,6 @@ vn_rdwr(enum uio_rw rw, struct vnode *vp, caddr_t base, int len, off_t offset, struct iovec aiov; int error; - if ((ioflg & IO_NODELOCKED) == 0) - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); auio.uio_iov = &aiov; auio.uio_iovcnt = 1; aiov.iov_base = base; @@ -266,18 +264,22 @@ vn_rdwr(enum uio_rw rw, struct vnode *vp, caddr_t base, int len, off_t offset, auio.uio_segflg = segflg; auio.uio_rw = rw; auio.uio_procp = p; + + if ((ioflg & IO_NODELOCKED) == 0) + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); if (rw == UIO_READ) { error = VOP_READ(vp, &auio, ioflg, cred); } else { error = VOP_WRITE(vp, &auio, ioflg, cred); } + if ((ioflg & IO_NODELOCKED) == 0) + VOP_UNLOCK(vp, 0, p); + if (aresid) *aresid = auio.uio_resid; else if (auio.uio_resid && error == 0) error = EIO; - if ((ioflg & IO_NODELOCKED) == 0) - VOP_UNLOCK(vp, 0, p); return (error); } |