Skip to content

Commit

Permalink
xfs: convert the per-mount dquot list to use list heads
Browse files Browse the repository at this point in the history
Convert the dquot list on the filesytesm 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>
  • Loading branch information
Dave Chinner authored and Alex Elder committed May 19, 2010
1 parent 9abbc53 commit 3a25404
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 112 deletions.
21 changes: 12 additions & 9 deletions fs/xfs/quota/xfs_dquot.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ xfs_qm_dqinit(
*/
dqp->q_nrefs = 0;
dqp->q_blkno = 0;
dqp->MPL_NEXT = dqp->HL_NEXT = NULL;
dqp->HL_PREVP = dqp->MPL_PREVP = NULL;
INIT_LIST_HEAD(&dqp->q_mplist);
dqp->HL_NEXT = NULL;
dqp->HL_PREVP = NULL;
dqp->q_bufoffset = 0;
dqp->q_fileoffset = 0;
dqp->q_transp = NULL;
Expand Down Expand Up @@ -772,7 +773,7 @@ xfs_qm_dqlookup(
/*
* All in core dquots must be on the dqlist of mp
*/
ASSERT(dqp->MPL_PREVP != NULL);
ASSERT(!list_empty(&dqp->q_mplist));

xfs_dqlock(dqp);
if (dqp->q_nrefs == 0) {
Expand Down Expand Up @@ -1039,17 +1040,17 @@ xfs_qm_dqget(
* Attach this dquot to this filesystem's list of all dquots,
* kept inside the mount structure in m_quotainfo field
*/
xfs_qm_mplist_lock(mp);
mutex_lock(&mp->m_quotainfo->qi_dqlist_lock);

/*
* We return a locked dquot to the caller, with a reference taken
*/
xfs_dqlock(dqp);
dqp->q_nrefs = 1;

XQM_MPLIST_INSERT(&(XFS_QI_MPL_LIST(mp)), dqp);

xfs_qm_mplist_unlock(mp);
list_add(&dqp->q_mplist, &mp->m_quotainfo->qi_dqlist);
mp->m_quotainfo->qi_dquots++;
mutex_unlock(&mp->m_quotainfo->qi_dqlist_lock);
mutex_unlock(&h->qh_lock);
dqret:
ASSERT((ip == NULL) || xfs_isilocked(ip, XFS_ILOCK_EXCL));
Expand Down Expand Up @@ -1389,7 +1390,7 @@ xfs_qm_dqpurge(
xfs_dqhash_t *thishash;
xfs_mount_t *mp = dqp->q_mount;

ASSERT(XFS_QM_IS_MPLIST_LOCKED(mp));
ASSERT(mutex_is_locked(&mp->m_quotainfo->qi_dqlist_lock));
ASSERT(mutex_is_locked(&dqp->q_hash->qh_lock));

xfs_dqlock(dqp);
Expand Down Expand Up @@ -1454,7 +1455,9 @@ xfs_qm_dqpurge(

thishash = dqp->q_hash;
XQM_HASHLIST_REMOVE(thishash, dqp);
XQM_MPLIST_REMOVE(&(XFS_QI_MPL_LIST(mp)), dqp);
list_del_init(&dqp->q_mplist);
mp->m_quotainfo->qi_dqreclaims++;
mp->m_quotainfo->qi_dquots--;
/*
* XXX Move this to the front of the freelist, if we can get the
* freelist lock.
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/quota/xfs_dquot.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ struct xfs_trans;
typedef struct xfs_dqmarker {
struct xfs_dquot*dqm_flnext; /* link to freelist: must be first */
struct xfs_dquot*dqm_flprev;
xfs_dqlink_t dqm_mplist; /* link to mount's list of dquots */
xfs_dqlink_t dqm_hashlist; /* link to the hash chain */
uint dqm_flags; /* various flags (XFS_DQ_*) */
} xfs_dqmarker_t;
Expand All @@ -67,6 +66,7 @@ typedef struct xfs_dqmarker {
*/
typedef struct xfs_dquot {
xfs_dqmarker_t q_lists; /* list ptrs, q_flags (marker) */
struct list_head q_mplist; /* mount's list of dquots */
xfs_dqhash_t *q_hash; /* the hashchain header */
struct xfs_mount*q_mount; /* filesystem this relates to */
struct xfs_trans*q_transp; /* trans this belongs to currently */
Expand Down
Loading

0 comments on commit 3a25404

Please sign in to comment.