aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/quota/xfs_dquot.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2010-04-13 01:06:51 -0400
committerAlex Elder <aelder@sgi.com>2010-05-19 10:58:11 -0400
commite6a81f13aa9aa20ef03174210aed24791865b05e (patch)
tree727202721a225004e2522f32278de294c3748e70 /fs/xfs/quota/xfs_dquot.c
parent368e136174344c417bad6ff0380b7b3f574bf120 (diff)
xfs: convert the dquot hash list to use list heads
Convert the dquot hash 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.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/quota/xfs_dquot.c
index 838289b92bb9..ad64ab62d9c5 100644
--- a/fs/xfs/quota/xfs_dquot.c
+++ b/fs/xfs/quota/xfs_dquot.c
@@ -122,8 +122,7 @@ xfs_qm_dqinit(
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 dqp->HL_NEXT = NULL; 125 INIT_LIST_HEAD(&dqp->q_hashlist);
126 dqp->HL_PREVP = NULL;
127 dqp->q_bufoffset = 0; 126 dqp->q_bufoffset = 0;
128 dqp->q_fileoffset = 0; 127 dqp->q_fileoffset = 0;
129 dqp->q_transp = NULL; 128 dqp->q_transp = NULL;
@@ -752,7 +751,6 @@ xfs_qm_dqlookup(
752{ 751{
753 xfs_dquot_t *dqp; 752 xfs_dquot_t *dqp;
754 uint flist_locked; 753 uint flist_locked;
755 xfs_dquot_t *d;
756 754
757 ASSERT(mutex_is_locked(&qh->qh_lock)); 755 ASSERT(mutex_is_locked(&qh->qh_lock));
758 756
@@ -761,7 +759,7 @@ xfs_qm_dqlookup(
761 /* 759 /*
762 * Traverse the hashchain looking for a match 760 * Traverse the hashchain looking for a match
763 */ 761 */
764 for (dqp = qh->qh_next; dqp != NULL; dqp = dqp->HL_NEXT) { 762 list_for_each_entry(dqp, &qh->qh_list, q_hashlist) {
765 /* 763 /*
766 * We already have the hashlock. We don't need the 764 * We already have the hashlock. We don't need the
767 * dqlock to look at the id field of the dquot, since the 765 * dqlock to look at the id field of the dquot, since the
@@ -828,21 +826,10 @@ xfs_qm_dqlookup(
828 * move the dquot to the front of the hashchain 826 * move the dquot to the front of the hashchain
829 */ 827 */
830 ASSERT(mutex_is_locked(&qh->qh_lock)); 828 ASSERT(mutex_is_locked(&qh->qh_lock));
831 if (dqp->HL_PREVP != &qh->qh_next) { 829 list_move(&dqp->q_hashlist, &qh->qh_list);
832 trace_xfs_dqlookup_move(dqp);
833 if ((d = dqp->HL_NEXT))
834 d->HL_PREVP = dqp->HL_PREVP;
835 *(dqp->HL_PREVP) = d;
836 d = qh->qh_next;
837 d->HL_PREVP = &dqp->HL_NEXT;
838 dqp->HL_NEXT = d;
839 dqp->HL_PREVP = &qh->qh_next;
840 qh->qh_next = dqp;
841 }
842 trace_xfs_dqlookup_done(dqp); 830 trace_xfs_dqlookup_done(dqp);
843 *O_dqpp = dqp; 831 *O_dqpp = dqp;
844 ASSERT(mutex_is_locked(&qh->qh_lock)); 832 return 0;
845 return (0);
846 } 833 }
847 } 834 }
848 835
@@ -1034,7 +1021,8 @@ xfs_qm_dqget(
1034 */ 1021 */
1035 ASSERT(mutex_is_locked(&h->qh_lock)); 1022 ASSERT(mutex_is_locked(&h->qh_lock));
1036 dqp->q_hash = h; 1023 dqp->q_hash = h;
1037 XQM_HASHLIST_INSERT(h, dqp); 1024 list_add(&dqp->q_hashlist, &h->qh_list);
1025 h->qh_version++;
1038 1026
1039 /* 1027 /*
1040 * Attach this dquot to this filesystem's list of all dquots, 1028 * Attach this dquot to this filesystem's list of all dquots,
@@ -1387,7 +1375,7 @@ int
1387xfs_qm_dqpurge( 1375xfs_qm_dqpurge(
1388 xfs_dquot_t *dqp) 1376 xfs_dquot_t *dqp)
1389{ 1377{
1390 xfs_dqhash_t *thishash; 1378 xfs_dqhash_t *qh = dqp->q_hash;
1391 xfs_mount_t *mp = dqp->q_mount; 1379 xfs_mount_t *mp = dqp->q_mount;
1392 1380
1393 ASSERT(mutex_is_locked(&mp->m_quotainfo->qi_dqlist_lock)); 1381 ASSERT(mutex_is_locked(&mp->m_quotainfo->qi_dqlist_lock));
@@ -1453,8 +1441,8 @@ xfs_qm_dqpurge(
1453 ASSERT(XFS_FORCED_SHUTDOWN(mp) || 1441 ASSERT(XFS_FORCED_SHUTDOWN(mp) ||
1454 !(dqp->q_logitem.qli_item.li_flags & XFS_LI_IN_AIL)); 1442 !(dqp->q_logitem.qli_item.li_flags & XFS_LI_IN_AIL));
1455 1443
1456 thishash = dqp->q_hash; 1444 list_del_init(&dqp->q_hashlist);
1457 XQM_HASHLIST_REMOVE(thishash, dqp); 1445 qh->qh_version++;
1458 list_del_init(&dqp->q_mplist); 1446 list_del_init(&dqp->q_mplist);
1459 mp->m_quotainfo->qi_dqreclaims++; 1447 mp->m_quotainfo->qi_dqreclaims++;
1460 mp->m_quotainfo->qi_dquots--; 1448 mp->m_quotainfo->qi_dquots--;
@@ -1470,7 +1458,7 @@ xfs_qm_dqpurge(
1470 memset(&dqp->q_core, 0, sizeof(dqp->q_core)); 1458 memset(&dqp->q_core, 0, sizeof(dqp->q_core));
1471 xfs_dqfunlock(dqp); 1459 xfs_dqfunlock(dqp);
1472 xfs_dqunlock(dqp); 1460 xfs_dqunlock(dqp);
1473 mutex_unlock(&thishash->qh_lock); 1461 mutex_unlock(&qh->qh_lock);
1474 return (0); 1462 return (0);
1475} 1463}
1476 1464