xfs
[Top] [All Lists]

[PATCH 05/14] xfs: cleanup xfs_qm_dqlookup

To: xfs@xxxxxxxxxxx
Subject: [PATCH 05/14] xfs: cleanup xfs_qm_dqlookup
From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Wed, 31 Aug 2011 16:36:52 -0400
References: <20110831203647.455809764@xxxxxxxxxxxxxxxxxxxxxx>
User-agent: quilt/0.48-1
Rearrange the code to avoid the conditional locking around the
flist_locked variable.  This means we lose a (rather pointless)
assert, and hold the freelist lock a bit longer for one corner
case.

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

Index: xfs/fs/xfs/xfs_dquot.c
===================================================================
--- xfs.orig/fs/xfs/xfs_dquot.c 2011-08-29 18:16:23.349023464 +0200
+++ xfs/fs/xfs/xfs_dquot.c      2011-08-29 18:23:23.256748629 +0200
@@ -707,12 +707,9 @@ xfs_qm_dqlookup(
        xfs_dquot_t             **O_dqpp)
 {
        xfs_dquot_t             *dqp;
-       uint                    flist_locked;
 
        ASSERT(mutex_is_locked(&qh->qh_lock));
 
-       flist_locked = B_FALSE;
-
        /*
         * Traverse the hashchain looking for a match
         */
@@ -747,31 +744,19 @@ xfs_qm_dqlookup(
                                        xfs_dqlock(dqp);
                                        dqp->dq_flags &= ~(XFS_DQ_WANT);
                                }
-                               flist_locked = B_TRUE;
-                       }
-
-                       /*
-                        * id couldn't have changed; we had the hashlock all
-                        * along
-                        */
-                       ASSERT(be32_to_cpu(dqp->q_core.d_id) == id);
 
-                       if (flist_locked) {
-                               if (dqp->q_nrefs != 0) {
-                                       
mutex_unlock(&xfs_Gqm->qm_dqfrlist_lock);
-                                       flist_locked = B_FALSE;
-                               } else {
+                               if (dqp->q_nrefs == 0) {
                                        /* take it off the freelist */
                                        trace_xfs_dqlookup_freelist(dqp);
                                        list_del_init(&dqp->q_freelist);
                                        xfs_Gqm->qm_dqfrlist_cnt--;
                                }
+                               XFS_DQHOLD(dqp);
+                               mutex_unlock(&xfs_Gqm->qm_dqfrlist_lock);
+                       } else {
+                               XFS_DQHOLD(dqp);
                        }
 
-                       XFS_DQHOLD(dqp);
-
-                       if (flist_locked)
-                               mutex_unlock(&xfs_Gqm->qm_dqfrlist_lock);
                        /*
                         * move the dquot to the front of the hashchain
                         */

<Prev in Thread] Current Thread [Next in Thread>