Commit 3a25404b authored by Dave Chinner's avatar Dave Chinner Committed by Alex Elder

xfs: convert the per-mount dquot list to use list heads

Convert the dquot list on the filesytesm to use listhead
infrastructure rather than the roll-your-own in the quota code.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 9abbc539
...@@ -121,8 +121,9 @@ xfs_qm_dqinit( ...@@ -121,8 +121,9 @@ xfs_qm_dqinit(
*/ */
dqp->q_nrefs = 0; dqp->q_nrefs = 0;
dqp->q_blkno = 0; dqp->q_blkno = 0;
dqp->MPL_NEXT = dqp->HL_NEXT = NULL; INIT_LIST_HEAD(&dqp->q_mplist);
dqp->HL_PREVP = dqp->MPL_PREVP = NULL; dqp->HL_NEXT = NULL;
dqp->HL_PREVP = NULL;
dqp->q_bufoffset = 0; dqp->q_bufoffset = 0;
dqp->q_fileoffset = 0; dqp->q_fileoffset = 0;
dqp->q_transp = NULL; dqp->q_transp = NULL;
...@@ -772,7 +773,7 @@ xfs_qm_dqlookup( ...@@ -772,7 +773,7 @@ xfs_qm_dqlookup(
/* /*
* All in core dquots must be on the dqlist of mp * 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); xfs_dqlock(dqp);
if (dqp->q_nrefs == 0) { if (dqp->q_nrefs == 0) {
...@@ -1039,7 +1040,7 @@ xfs_qm_dqget( ...@@ -1039,7 +1040,7 @@ xfs_qm_dqget(
* Attach this dquot to this filesystem's list of all dquots, * Attach this dquot to this filesystem's list of all dquots,
* kept inside the mount structure in m_quotainfo field * 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 * We return a locked dquot to the caller, with a reference taken
...@@ -1047,9 +1048,9 @@ xfs_qm_dqget( ...@@ -1047,9 +1048,9 @@ xfs_qm_dqget(
xfs_dqlock(dqp); xfs_dqlock(dqp);
dqp->q_nrefs = 1; dqp->q_nrefs = 1;
XQM_MPLIST_INSERT(&(XFS_QI_MPL_LIST(mp)), dqp); list_add(&dqp->q_mplist, &mp->m_quotainfo->qi_dqlist);
mp->m_quotainfo->qi_dquots++;
xfs_qm_mplist_unlock(mp); mutex_unlock(&mp->m_quotainfo->qi_dqlist_lock);
mutex_unlock(&h->qh_lock); mutex_unlock(&h->qh_lock);
dqret: dqret:
ASSERT((ip == NULL) || xfs_isilocked(ip, XFS_ILOCK_EXCL)); ASSERT((ip == NULL) || xfs_isilocked(ip, XFS_ILOCK_EXCL));
...@@ -1389,7 +1390,7 @@ xfs_qm_dqpurge( ...@@ -1389,7 +1390,7 @@ xfs_qm_dqpurge(
xfs_dqhash_t *thishash; xfs_dqhash_t *thishash;
xfs_mount_t *mp = dqp->q_mount; 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)); ASSERT(mutex_is_locked(&dqp->q_hash->qh_lock));
xfs_dqlock(dqp); xfs_dqlock(dqp);
...@@ -1454,7 +1455,9 @@ xfs_qm_dqpurge( ...@@ -1454,7 +1455,9 @@ xfs_qm_dqpurge(
thishash = dqp->q_hash; thishash = dqp->q_hash;
XQM_HASHLIST_REMOVE(thishash, dqp); 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 * XXX Move this to the front of the freelist, if we can get the
* freelist lock. * freelist lock.
......
...@@ -57,7 +57,6 @@ struct xfs_trans; ...@@ -57,7 +57,6 @@ struct xfs_trans;
typedef struct xfs_dqmarker { typedef struct xfs_dqmarker {
struct xfs_dquot*dqm_flnext; /* link to freelist: must be first */ struct xfs_dquot*dqm_flnext; /* link to freelist: must be first */
struct xfs_dquot*dqm_flprev; 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 */ xfs_dqlink_t dqm_hashlist; /* link to the hash chain */
uint dqm_flags; /* various flags (XFS_DQ_*) */ uint dqm_flags; /* various flags (XFS_DQ_*) */
} xfs_dqmarker_t; } xfs_dqmarker_t;
...@@ -67,6 +66,7 @@ typedef struct xfs_dqmarker { ...@@ -67,6 +66,7 @@ typedef struct xfs_dqmarker {
*/ */
typedef struct xfs_dquot { typedef struct xfs_dquot {
xfs_dqmarker_t q_lists; /* list ptrs, q_flags (marker) */ 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 */ xfs_dqhash_t *q_hash; /* the hashchain header */
struct xfs_mount*q_mount; /* filesystem this relates to */ struct xfs_mount*q_mount; /* filesystem this relates to */
struct xfs_trans*q_transp; /* trans this belongs to currently */ struct xfs_trans*q_transp; /* trans this belongs to currently */
......
This diff is collapsed.
...@@ -106,7 +106,9 @@ typedef struct xfs_qm { ...@@ -106,7 +106,9 @@ typedef struct xfs_qm {
typedef struct xfs_quotainfo { typedef struct xfs_quotainfo {
xfs_inode_t *qi_uquotaip; /* user quota inode */ xfs_inode_t *qi_uquotaip; /* user quota inode */
xfs_inode_t *qi_gquotaip; /* group quota inode */ xfs_inode_t *qi_gquotaip; /* group quota inode */
xfs_dqlist_t qi_dqlist; /* all dquots in filesys */ struct list_head qi_dqlist; /* all dquots in filesys */
struct mutex qi_dqlist_lock;
int qi_dquots;
int qi_dqreclaims; /* a change here indicates int qi_dqreclaims; /* a change here indicates
a removal in the dqlist */ a removal in the dqlist */
time_t qi_btimelimit; /* limit for blks timer */ time_t qi_btimelimit; /* limit for blks timer */
......
...@@ -442,7 +442,7 @@ xfs_qm_scall_getqstat( ...@@ -442,7 +442,7 @@ xfs_qm_scall_getqstat(
IRELE(gip); IRELE(gip);
} }
if (mp->m_quotainfo) { if (mp->m_quotainfo) {
out->qs_incoredqs = XFS_QI_MPLNDQUOTS(mp); out->qs_incoredqs = mp->m_quotainfo->qi_dquots;
out->qs_btimelimit = XFS_QI_BTIMELIMIT(mp); out->qs_btimelimit = XFS_QI_BTIMELIMIT(mp);
out->qs_itimelimit = XFS_QI_ITIMELIMIT(mp); out->qs_itimelimit = XFS_QI_ITIMELIMIT(mp);
out->qs_rtbtimelimit = XFS_QI_RTBTIMELIMIT(mp); out->qs_rtbtimelimit = XFS_QI_RTBTIMELIMIT(mp);
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#define XFS_DQ_IS_ADDEDTO_TRX(t, d) ((d)->q_transp == (t)) #define XFS_DQ_IS_ADDEDTO_TRX(t, d) ((d)->q_transp == (t))
#define XFS_QI_MPLRECLAIMS(mp) ((mp)->m_quotainfo->qi_dqreclaims)
#define XFS_QI_UQIP(mp) ((mp)->m_quotainfo->qi_uquotaip) #define XFS_QI_UQIP(mp) ((mp)->m_quotainfo->qi_uquotaip)
#define XFS_QI_GQIP(mp) ((mp)->m_quotainfo->qi_gquotaip) #define XFS_QI_GQIP(mp) ((mp)->m_quotainfo->qi_gquotaip)
#define XFS_QI_DQCHUNKLEN(mp) ((mp)->m_quotainfo->qi_dqchunklen) #define XFS_QI_DQCHUNKLEN(mp) ((mp)->m_quotainfo->qi_dqchunklen)
...@@ -41,19 +40,6 @@ ...@@ -41,19 +40,6 @@
#define XFS_QI_IWARNLIMIT(mp) ((mp)->m_quotainfo->qi_iwarnlimit) #define XFS_QI_IWARNLIMIT(mp) ((mp)->m_quotainfo->qi_iwarnlimit)
#define XFS_QI_QOFFLOCK(mp) ((mp)->m_quotainfo->qi_quotaofflock) #define XFS_QI_QOFFLOCK(mp) ((mp)->m_quotainfo->qi_quotaofflock)
#define XFS_QI_MPL_LIST(mp) ((mp)->m_quotainfo->qi_dqlist)
#define XFS_QI_MPLNEXT(mp) ((mp)->m_quotainfo->qi_dqlist.qh_next)
#define XFS_QI_MPLNDQUOTS(mp) ((mp)->m_quotainfo->qi_dqlist.qh_nelems)
#define xfs_qm_mplist_lock(mp) \
mutex_lock(&(XFS_QI_MPL_LIST(mp).qh_lock))
#define xfs_qm_mplist_nowait(mp) \
mutex_trylock(&(XFS_QI_MPL_LIST(mp).qh_lock))
#define xfs_qm_mplist_unlock(mp) \
mutex_unlock(&(XFS_QI_MPL_LIST(mp).qh_lock))
#define XFS_QM_IS_MPLIST_LOCKED(mp) \
mutex_is_locked(&(XFS_QI_MPL_LIST(mp).qh_lock))
#define xfs_qm_freelist_lock(qm) \ #define xfs_qm_freelist_lock(qm) \
mutex_lock(&((qm)->qm_dqfreelist.qh_lock)) mutex_lock(&((qm)->qm_dqfreelist.qh_lock))
#define xfs_qm_freelist_lock_nowait(qm) \ #define xfs_qm_freelist_lock_nowait(qm) \
...@@ -88,8 +74,6 @@ ...@@ -88,8 +74,6 @@
#define HL_PREVP dq_hashlist.ql_prevp #define HL_PREVP dq_hashlist.ql_prevp
#define HL_NEXT dq_hashlist.ql_next #define HL_NEXT dq_hashlist.ql_next
#define MPL_PREVP dq_mplist.ql_prevp
#define MPL_NEXT dq_mplist.ql_next
#define _LIST_REMOVE(h, dqp, PVP, NXT) \ #define _LIST_REMOVE(h, dqp, PVP, NXT) \
...@@ -116,9 +100,6 @@ ...@@ -116,9 +100,6 @@
(h)->qh_nelems++; \ (h)->qh_nelems++; \
} }
#define FOREACH_DQUOT_IN_MP(dqp, mp) \
for ((dqp) = XFS_QI_MPLNEXT(mp); (dqp) != NULL; (dqp) = (dqp)->MPL_NEXT)
#define FOREACH_DQUOT_IN_FREELIST(dqp, qlist) \ #define FOREACH_DQUOT_IN_FREELIST(dqp, qlist) \
for ((dqp) = (qlist)->qh_next; (dqp) != (xfs_dquot_t *)(qlist); \ for ((dqp) = (qlist)->qh_next; (dqp) != (xfs_dquot_t *)(qlist); \
(dqp) = (dqp)->dq_flnext) (dqp) = (dqp)->dq_flnext)
...@@ -129,16 +110,10 @@ for ((dqp) = (qlist)->qh_next; (dqp) != (xfs_dquot_t *)(qlist); \ ...@@ -129,16 +110,10 @@ for ((dqp) = (qlist)->qh_next; (dqp) != (xfs_dquot_t *)(qlist); \
#define XQM_FREELIST_INSERT(h, dqp) \ #define XQM_FREELIST_INSERT(h, dqp) \
xfs_qm_freelist_append(h, dqp) xfs_qm_freelist_append(h, dqp)
#define XQM_MPLIST_INSERT(h, dqp) \
_LIST_INSERT(h, dqp, MPL_PREVP, MPL_NEXT)
#define XQM_HASHLIST_REMOVE(h, dqp) \ #define XQM_HASHLIST_REMOVE(h, dqp) \
_LIST_REMOVE(h, dqp, HL_PREVP, HL_NEXT) _LIST_REMOVE(h, dqp, HL_PREVP, HL_NEXT)
#define XQM_FREELIST_REMOVE(dqp) \ #define XQM_FREELIST_REMOVE(dqp) \
xfs_qm_freelist_unlink(dqp) xfs_qm_freelist_unlink(dqp)
#define XQM_MPLIST_REMOVE(h, dqp) \
{ _LIST_REMOVE(h, dqp, MPL_PREVP, MPL_NEXT); \
XFS_QI_MPLRECLAIMS((dqp)->q_mount)++; }
#define XFS_DQ_IS_LOGITEM_INITD(dqp) ((dqp)->q_logitem.qli_dquot == (dqp)) #define XFS_DQ_IS_LOGITEM_INITD(dqp) ((dqp)->q_logitem.qli_dquot == (dqp))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment