aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/quota/xfs_dquot.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2010-04-13 01:06:52 -0400
committerAlex Elder <aelder@sgi.com>2010-05-19 10:58:11 -0400
commit3a8406f6d6916e8211936edb9e1193123df2daab (patch)
tree53f490a433ef3bd2f430ef19cdfbbe5dc514e89d /fs/xfs/quota/xfs_dquot.c
parente6a81f13aa9aa20ef03174210aed24791865b05e (diff)
xfs: convert the dquot free list to use list heads
Convert the dquot free list on the filesystem to use listhead infrastructure rather than the roll-your-own in the quota code. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/xfs/quota/xfs_dquot.c')
-rw-r--r--fs/xfs/quota/xfs_dquot.c75
1 files changed, 31 insertions, 44 deletions
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/quota/xfs_dquot.c
index ad64ab62d9c5..02dac0a5f1ec 100644
--- a/fs/xfs/quota/xfs_dquot.c
+++ b/fs/xfs/quota/xfs_dquot.c
@@ -101,7 +101,7 @@ xfs_qm_dqinit(
101 * No need to re-initialize these if this is a reclaimed dquot. 101 * No need to re-initialize these if this is a reclaimed dquot.
102 */ 102 */
103 if (brandnewdquot) { 103 if (brandnewdquot) {
104 dqp->dq_flnext = dqp->dq_flprev = dqp; 104 INIT_LIST_HEAD(&dqp->q_freelist);
105 mutex_init(&dqp->q_qlock); 105 mutex_init(&dqp->q_qlock);
106 init_waitqueue_head(&dqp->q_pinwait); 106 init_waitqueue_head(&dqp->q_pinwait);
107 107
@@ -119,20 +119,20 @@ xfs_qm_dqinit(
119 * Only the q_core portion was zeroed in dqreclaim_one(). 119 * Only the q_core portion was zeroed in dqreclaim_one().
120 * So, we need to reset others. 120 * So, we need to reset others.
121 */ 121 */
122 dqp->q_nrefs = 0; 122 dqp->q_nrefs = 0;
123 dqp->q_blkno = 0; 123 dqp->q_blkno = 0;
124 INIT_LIST_HEAD(&dqp->q_mplist); 124 INIT_LIST_HEAD(&dqp->q_mplist);
125 INIT_LIST_HEAD(&dqp->q_hashlist); 125 INIT_LIST_HEAD(&dqp->q_hashlist);
126 dqp->q_bufoffset = 0; 126 dqp->q_bufoffset = 0;
127 dqp->q_fileoffset = 0; 127 dqp->q_fileoffset = 0;
128 dqp->q_transp = NULL; 128 dqp->q_transp = NULL;
129 dqp->q_gdquot = NULL; 129 dqp->q_gdquot = NULL;
130 dqp->q_res_bcount = 0; 130 dqp->q_res_bcount = 0;
131 dqp->q_res_icount = 0; 131 dqp->q_res_icount = 0;
132 dqp->q_res_rtbcount = 0; 132 dqp->q_res_rtbcount = 0;
133 atomic_set(&dqp->q_pincount, 0); 133 atomic_set(&dqp->q_pincount, 0);
134 dqp->q_hash = NULL; 134 dqp->q_hash = NULL;
135 ASSERT(dqp->dq_flnext == dqp->dq_flprev); 135 ASSERT(list_empty(&dqp->q_freelist));
136 136
137 trace_xfs_dqreuse(dqp); 137 trace_xfs_dqreuse(dqp);
138 } 138 }
@@ -158,7 +158,7 @@ void
158xfs_qm_dqdestroy( 158xfs_qm_dqdestroy(
159 xfs_dquot_t *dqp) 159 xfs_dquot_t *dqp)
160{ 160{
161 ASSERT(! XFS_DQ_IS_ON_FREELIST(dqp)); 161 ASSERT(list_empty(&dqp->q_freelist));
162 162
163 mutex_destroy(&dqp->q_qlock); 163 mutex_destroy(&dqp->q_qlock);
164 sv_destroy(&dqp->q_pinwait); 164 sv_destroy(&dqp->q_pinwait);
@@ -775,8 +775,8 @@ xfs_qm_dqlookup(
775 775
776 xfs_dqlock(dqp); 776 xfs_dqlock(dqp);
777 if (dqp->q_nrefs == 0) { 777 if (dqp->q_nrefs == 0) {
778 ASSERT (XFS_DQ_IS_ON_FREELIST(dqp)); 778 ASSERT(!list_empty(&dqp->q_freelist));
779 if (! xfs_qm_freelist_lock_nowait(xfs_Gqm)) { 779 if (!mutex_trylock(&xfs_Gqm->qm_dqfrlist_lock)) {
780 trace_xfs_dqlookup_want(dqp); 780 trace_xfs_dqlookup_want(dqp);
781 781
782 /* 782 /*
@@ -786,7 +786,7 @@ xfs_qm_dqlookup(
786 */ 786 */
787 dqp->dq_flags |= XFS_DQ_WANT; 787 dqp->dq_flags |= XFS_DQ_WANT;
788 xfs_dqunlock(dqp); 788 xfs_dqunlock(dqp);
789 xfs_qm_freelist_lock(xfs_Gqm); 789 mutex_lock(&xfs_Gqm->qm_dqfrlist_lock);
790 xfs_dqlock(dqp); 790 xfs_dqlock(dqp);
791 dqp->dq_flags &= ~(XFS_DQ_WANT); 791 dqp->dq_flags &= ~(XFS_DQ_WANT);
792 } 792 }
@@ -801,27 +801,20 @@ xfs_qm_dqlookup(
801 801
802 if (flist_locked) { 802 if (flist_locked) {
803 if (dqp->q_nrefs != 0) { 803 if (dqp->q_nrefs != 0) {
804 xfs_qm_freelist_unlock(xfs_Gqm); 804 mutex_unlock(&xfs_Gqm->qm_dqfrlist_lock);
805 flist_locked = B_FALSE; 805 flist_locked = B_FALSE;
806 } else { 806 } else {
807 /* 807 /* take it off the freelist */
808 * take it off the freelist
809 */
810 trace_xfs_dqlookup_freelist(dqp); 808 trace_xfs_dqlookup_freelist(dqp);
811 XQM_FREELIST_REMOVE(dqp); 809 list_del_init(&dqp->q_freelist);
812 /* xfs_qm_freelist_print(&(xfs_Gqm-> 810 xfs_Gqm->qm_dqfrlist_cnt--;
813 qm_dqfreelist),
814 "after removal"); */
815 } 811 }
816 } 812 }
817 813
818 /*
819 * grab a reference
820 */
821 XFS_DQHOLD(dqp); 814 XFS_DQHOLD(dqp);
822 815
823 if (flist_locked) 816 if (flist_locked)
824 xfs_qm_freelist_unlock(xfs_Gqm); 817 mutex_unlock(&xfs_Gqm->qm_dqfrlist_lock);
825 /* 818 /*
826 * move the dquot to the front of the hashchain 819 * move the dquot to the front of the hashchain
827 */ 820 */
@@ -1075,10 +1068,10 @@ xfs_qm_dqput(
1075 * drop the dqlock and acquire the freelist and dqlock 1068 * drop the dqlock and acquire the freelist and dqlock
1076 * in the right order; but try to get it out-of-order first 1069 * in the right order; but try to get it out-of-order first
1077 */ 1070 */
1078 if (! xfs_qm_freelist_lock_nowait(xfs_Gqm)) { 1071 if (!mutex_trylock(&xfs_Gqm->qm_dqfrlist_lock)) {
1079 trace_xfs_dqput_wait(dqp); 1072 trace_xfs_dqput_wait(dqp);
1080 xfs_dqunlock(dqp); 1073 xfs_dqunlock(dqp);
1081 xfs_qm_freelist_lock(xfs_Gqm); 1074 mutex_lock(&xfs_Gqm->qm_dqfrlist_lock);
1082 xfs_dqlock(dqp); 1075 xfs_dqlock(dqp);
1083 } 1076 }
1084 1077
@@ -1089,10 +1082,8 @@ xfs_qm_dqput(
1089 if (--dqp->q_nrefs == 0) { 1082 if (--dqp->q_nrefs == 0) {
1090 trace_xfs_dqput_free(dqp); 1083 trace_xfs_dqput_free(dqp);
1091 1084
1092 /* 1085 list_add_tail(&dqp->q_freelist, &xfs_Gqm->qm_dqfrlist);
1093 * insert at end of the freelist. 1086 xfs_Gqm->qm_dqfrlist_cnt++;
1094 */
1095 XQM_FREELIST_INSERT(&(xfs_Gqm->qm_dqfreelist), dqp);
1096 1087
1097 /* 1088 /*
1098 * If we just added a udquot to the freelist, then 1089 * If we just added a udquot to the freelist, then
@@ -1107,10 +1098,6 @@ xfs_qm_dqput(
1107 xfs_dqlock(gdqp); 1098 xfs_dqlock(gdqp);
1108 dqp->q_gdquot = NULL; 1099 dqp->q_gdquot = NULL;
1109 } 1100 }
1110
1111 /* xfs_qm_freelist_print(&(xfs_Gqm->qm_dqfreelist),
1112 "@@@@@++ Free list (after append) @@@@@+");
1113 */
1114 } 1101 }
1115 xfs_dqunlock(dqp); 1102 xfs_dqunlock(dqp);
1116 1103
@@ -1122,7 +1109,7 @@ xfs_qm_dqput(
1122 break; 1109 break;
1123 dqp = gdqp; 1110 dqp = gdqp;
1124 } 1111 }
1125 xfs_qm_freelist_unlock(xfs_Gqm); 1112 mutex_unlock(&xfs_Gqm->qm_dqfrlist_lock);
1126} 1113}
1127 1114
1128/* 1115/*
@@ -1396,7 +1383,7 @@ xfs_qm_dqpurge(
1396 return (1); 1383 return (1);
1397 } 1384 }
1398 1385
1399 ASSERT(XFS_DQ_IS_ON_FREELIST(dqp)); 1386 ASSERT(!list_empty(&dqp->q_freelist));
1400 1387
1401 /* 1388 /*
1402 * If we're turning off quotas, we have to make sure that, for 1389 * If we're turning off quotas, we have to make sure that, for
@@ -1450,7 +1437,7 @@ xfs_qm_dqpurge(
1450 * XXX Move this to the front of the freelist, if we can get the 1437 * XXX Move this to the front of the freelist, if we can get the
1451 * freelist lock. 1438 * freelist lock.
1452 */ 1439 */
1453 ASSERT(XFS_DQ_IS_ON_FREELIST(dqp)); 1440 ASSERT(!list_empty(&dqp->q_freelist));
1454 1441
1455 dqp->q_mount = NULL; 1442 dqp->q_mount = NULL;
1456 dqp->q_hash = NULL; 1443 dqp->q_hash = NULL;