[PATCH 5/3] xfs: return unlocked dquots from xfs_qm_dqqet

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We generally don't need the dquot structure locked for the fast path
operations, and we don't need the lock during lookup either.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>

diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index f17350d..7da4097 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -689,8 +689,9 @@ error0:
 }
 
 /*
- * Given the file system, inode OR id, and type (UDQUOT/GDQUOT), return a
- * a locked dquot, doing an allocation (if requested) as needed.
+ * Given the file system, id, type and optionally inode, return a an unlocked
+ * dquot, doing an allocation if requested and needed.
+ *
  * When both an inode and an id are given, the inode's id takes precedence.
  * That is, if the id changes while we don't hold the ilock inside this
  * function, the new dquot is returned, not necessarily the one requested
@@ -739,9 +740,7 @@ restart:
 	mutex_lock(&qi->qi_tree_lock);
 	dqp = radix_tree_lookup(tree, id);
 	if (dqp) {
-		xfs_dqlock(dqp);
 		if (dqp->dq_flags & XFS_DQ_FREEING) {
-			xfs_dqunlock(dqp);
 			mutex_unlock(&qi->qi_tree_lock);
 			trace_xfs_dqget_freeing(dqp);
 			delay(1);
@@ -824,7 +823,6 @@ restart:
 	/*
 	 * We return a locked, referenced dquot to the caller.
 	 */
-	xfs_dqlock(dqp);
 	qi->qi_dquots++;
 	mutex_unlock(&qi->qi_tree_lock);
 
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 843ab07..985b583 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -395,7 +395,6 @@ xfs_qm_dqattach_one(
 	 * that the dquot returned is the one that should go in the inode.
 	 */
 	*IO_idqpp = dqp;
-	xfs_dqunlock(dqp);
 	return 0;
 }
 
@@ -1142,6 +1141,8 @@ xfs_qm_quotacheck_dqadjust(
 
 	trace_xfs_dqadjust(dqp);
 
+	xfs_dqlock(dqp);
+
 	/*
 	 * Adjust the inode count and the block count to reflect this inode's
 	 * resource usage.
@@ -1679,10 +1680,6 @@ xfs_qm_vop_dqalloc(
 				ASSERT(error != ENOENT);
 				return error;
 			}
-			/*
-			 * Get the ilock in the right order.
-			 */
-			xfs_dqunlock(uq);
 			lockflags = XFS_ILOCK_SHARED;
 			xfs_ilock(ip, lockflags);
 		} else {
@@ -1706,7 +1703,6 @@ xfs_qm_vop_dqalloc(
 				ASSERT(error != ENOENT);
 				goto error_rele;
 			}
-			xfs_dqunlock(gq);
 			lockflags = XFS_ILOCK_SHARED;
 			xfs_ilock(ip, lockflags);
 		} else {
@@ -1726,7 +1722,6 @@ xfs_qm_vop_dqalloc(
 				ASSERT(error != ENOENT);
 				goto error_rele;
 			}
-			xfs_dqunlock(pq);
 			lockflags = XFS_ILOCK_SHARED;
 			xfs_ilock(ip, lockflags);
 		} else {
diff --git a/fs/xfs/xfs_qm_bhv.c b/fs/xfs/xfs_qm_bhv.c
index e9be63a..c8fda48 100644
--- a/fs/xfs/xfs_qm_bhv.c
+++ b/fs/xfs/xfs_qm_bhv.c
@@ -75,6 +75,7 @@ xfs_qm_statvfs(
 	xfs_dquot_t		*dqp;
 
 	if (!xfs_qm_dqget(mp, NULL, xfs_get_projid(ip), XFS_DQ_PROJ, 0, &dqp)) {
+		xfs_dqlock(dqp);
 		xfs_fill_statvfs_from_dquot(statp, dqp);
 		xfs_qm_dqput(dqp);
 	}
diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
index 1e61cd4..94dadbe 100644
--- a/fs/xfs/xfs_qm_syscalls.c
+++ b/fs/xfs/xfs_qm_syscalls.c
@@ -617,7 +617,6 @@ xfs_qm_scall_setqlim(
 		ASSERT(error != ENOENT);
 		goto out_unlock;
 	}
-	xfs_dqunlock(dqp);
 
 	tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SETQLIM);
 	error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_setqlim, 0, 0);
@@ -844,6 +843,8 @@ xfs_qm_scall_getquota(
 	if (error)
 		return error;
 
+	xfs_dqlock(dqp);
+
 	/*
 	 * If everything's NULL, this dquot doesn't quite exist as far as
 	 * our utility programs are concerned.

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs




[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux