svn commit: r208774 - head/sys/ufs/ufs

Konstantin Belousov kib at FreeBSD.org
Thu Jun 3 10:24:53 UTC 2010


Author: kib
Date: Thu Jun  3 10:24:53 2010
New Revision: 208774
URL: http://svn.freebsd.org/changeset/base/208774

Log:
  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.

Modified:
  head/sys/ufs/ufs/ufs_quota.c

Modified: head/sys/ufs/ufs/ufs_quota.c
==============================================================================
--- head/sys/ufs/ufs/ufs_quota.c	Thu Jun  3 10:20:08 2010	(r208773)
+++ head/sys/ufs/ufs/ufs_quota.c	Thu Jun  3 10:24:53 2010	(r208774)
@@ -522,8 +522,8 @@ quotaon(struct thread *td, struct mount 
 	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 
 	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 
 	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 
 		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
 	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
 	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);


More information about the svn-src-all mailing list