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.
This commit is contained in:
Konstantin Belousov 2010-06-03 10:24:53 +00:00
parent 882da14c3d
commit db875cbd74
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=208774

View File

@ -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);