diff options
author | kib <kib@FreeBSD.org> | 2010-06-03 10:24:53 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2010-06-03 10:24:53 +0000 |
commit | 881c9b1a5c2a6aadd5230cc3aa0a496454289511 (patch) | |
tree | e650546ee79f135a11ac7430cf855828d7ff08f6 | |
parent | 2ba33ab98eb607efe3f9a55b0cd863ca7a7fad43 (diff) | |
download | FreeBSD-src-881c9b1a5c2a6aadd5230cc3aa0a496454289511.zip FreeBSD-src-881c9b1a5c2a6aadd5230cc3aa0a496454289511.tar.gz |
Extend the scope of the lock on the quota file vnode in quotaon() to
cover the initial read by dqopen(). Assert that vnode is locked in
dqopen(). Remove VFS_LOCK_GIANT() from dqopen(), since quotaon() keeps
Giant locked if needed around the call.
-rw-r--r-- | sys/ufs/ufs/ufs_quota.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/ufs/ufs/ufs_quota.c b/sys/ufs/ufs/ufs_quota.c index c516189..a8909f9 100644 --- a/sys/ufs/ufs/ufs_quota.c +++ b/sys/ufs/ufs/ufs_quota.c @@ -522,8 +522,8 @@ quotaon(struct thread *td, struct mount *mp, int type, void *fname) vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); vp = nd.ni_vp; - VOP_UNLOCK(vp, 0); if (vp->v_type != VREG) { + VOP_UNLOCK(vp, 0); (void) vn_close(vp, FREAD|FWRITE, td->td_ucred, td); VFS_UNLOCK_GIANT(vfslocked); return (EACCES); @@ -532,6 +532,7 @@ quotaon(struct thread *td, struct mount *mp, int type, void *fname) UFS_LOCK(ump); if ((ump->um_qflags[type] & (QTF_OPENING|QTF_CLOSING)) != 0) { UFS_UNLOCK(ump); + VOP_UNLOCK(vp, 0); (void) vn_close(vp, FREAD|FWRITE, td->td_ucred, td); VFS_UNLOCK_GIANT(vfslocked); return (EALREADY); @@ -539,6 +540,7 @@ quotaon(struct thread *td, struct mount *mp, int type, void *fname) ump->um_qflags[type] |= QTF_OPENING|QTF_CLOSING; UFS_UNLOCK(ump); if ((error = dqopen(vp, ump, type)) != 0) { + VOP_UNLOCK(vp, 0); UFS_LOCK(ump); ump->um_qflags[type] &= ~(QTF_OPENING|QTF_CLOSING); UFS_UNLOCK(ump); @@ -546,6 +548,7 @@ quotaon(struct thread *td, struct mount *mp, int type, void *fname) VFS_UNLOCK_GIANT(vfslocked); return (error); } + VOP_UNLOCK(vp, 0); MNT_ILOCK(mp); mp->mnt_flag |= MNT_QUOTA; MNT_IUNLOCK(mp); @@ -1169,8 +1172,9 @@ dqopen(struct vnode *vp, struct ufsmount *ump, int type) struct dqhdr64 dqh; struct iovec aiov; struct uio auio; - int error, vfslocked; + int error; + ASSERT_VOP_LOCKED(vp, "dqopen"); auio.uio_iov = &aiov; auio.uio_iovcnt = 1; aiov.iov_base = &dqh; @@ -1180,9 +1184,7 @@ dqopen(struct vnode *vp, struct ufsmount *ump, int type) auio.uio_segflg = UIO_SYSSPACE; auio.uio_rw = UIO_READ; auio.uio_td = (struct thread *)0; - vfslocked = VFS_LOCK_GIANT(vp->v_mount); error = VOP_READ(vp, &auio, 0, ump->um_cred[type]); - VFS_UNLOCK_GIANT(vfslocked); if (error != 0) return (error); |