Skip to content

Commit

Permalink
xfs: remove a few macro indirections in the quota code
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Dave Chinner <[email protected]>
  • Loading branch information
Christoph Hellwig authored and Alex Elder committed May 19, 2010
1 parent 8a7b8a8 commit 191f848
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 31 deletions.
16 changes: 11 additions & 5 deletions fs/xfs/quota/xfs_dquot.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,23 +956,29 @@ xfs_qm_dqget(
*/
if (ip) {
xfs_ilock(ip, XFS_ILOCK_EXCL);
if (! XFS_IS_DQTYPE_ON(mp, type)) {
/* inode stays locked on return */
xfs_qm_dqdestroy(dqp);
return XFS_ERROR(ESRCH);
}

/*
* A dquot could be attached to this inode by now, since
* we had dropped the ilock.
*/
if (type == XFS_DQ_USER) {
if (!XFS_IS_UQUOTA_ON(mp)) {
/* inode stays locked on return */
xfs_qm_dqdestroy(dqp);
return XFS_ERROR(ESRCH);
}
if (ip->i_udquot) {
xfs_qm_dqdestroy(dqp);
dqp = ip->i_udquot;
xfs_dqlock(dqp);
goto dqret;
}
} else {
if (!XFS_IS_OQUOTA_ON(mp)) {
/* inode stays locked on return */
xfs_qm_dqdestroy(dqp);
return XFS_ERROR(ESRCH);
}
if (ip->i_gdquot) {
xfs_qm_dqdestroy(dqp);
dqp = ip->i_gdquot;
Expand Down
4 changes: 3 additions & 1 deletion fs/xfs/quota/xfs_qm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1591,8 +1591,10 @@ xfs_qm_quotacheck_dqadjust(

/*
* Set default limits, adjust timers (since we changed usages)
*
* There are no timers for the default values set in the root dquot.
*/
if (! XFS_IS_SUSER_DQUOT(dqp)) {
if (dqp->q_core.d_id) {
xfs_qm_adjust_dqlimits(dqp->q_mount, &dqp->q_core);
xfs_qm_adjust_dqtimers(dqp->q_mount, &dqp->q_core);
}
Expand Down
13 changes: 0 additions & 13 deletions fs/xfs/quota/xfs_quota_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
*/
#define XFS_DQITER_MAP_SIZE 10

#define XFS_DQ_IS_ADDEDTO_TRX(t, d) ((d)->q_transp == (t))

/*
* Hash into a bucket in the dquot hash table, based on <mp, id>.
*/
Expand All @@ -37,9 +35,6 @@
XFS_DQ_HASHVAL(mp, id)) : \
(xfs_Gqm->qm_grp_dqhtable + \
XFS_DQ_HASHVAL(mp, id)))
#define XFS_IS_DQTYPE_ON(mp, type) (type == XFS_DQ_USER ? \
XFS_IS_UQUOTA_ON(mp) : \
XFS_IS_OQUOTA_ON(mp))
#define XFS_IS_DQUOT_UNINITIALIZED(dqp) ( \
!dqp->q_core.d_blk_hardlimit && \
!dqp->q_core.d_blk_softlimit && \
Expand All @@ -51,14 +46,6 @@
!dqp->q_core.d_rtbcount && \
!dqp->q_core.d_icount)

#define XFS_DQ_IS_LOGITEM_INITD(dqp) ((dqp)->q_logitem.qli_dquot == (dqp))

#define XFS_QM_DQP_TO_DQACCT(tp, dqp) (XFS_QM_ISUDQ(dqp) ? \
(tp)->t_dqinfo->dqa_usrdquots : \
(tp)->t_dqinfo->dqa_grpdquots)
#define XFS_IS_SUSER_DQUOT(dqp) \
(!((dqp)->q_core.d_id))

#define DQFLAGTO_TYPESTR(d) (((d)->dq_flags & XFS_DQ_USER) ? "USR" : \
(((d)->dq_flags & XFS_DQ_GROUP) ? "GRP" : \
(((d)->dq_flags & XFS_DQ_PROJ) ? "PRJ":"???")))
Expand Down
23 changes: 11 additions & 12 deletions fs/xfs/quota/xfs_trans_dquot.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@ xfs_trans_dqjoin(
xfs_trans_t *tp,
xfs_dquot_t *dqp)
{
xfs_dq_logitem_t *lp;
xfs_dq_logitem_t *lp = &dqp->q_logitem;

ASSERT(! XFS_DQ_IS_ADDEDTO_TRX(tp, dqp));
ASSERT(dqp->q_transp != tp);
ASSERT(XFS_DQ_IS_LOCKED(dqp));
ASSERT(XFS_DQ_IS_LOGITEM_INITD(dqp));
lp = &dqp->q_logitem;
ASSERT(lp->qli_dquot == dqp);

/*
* Get a log_item_desc to point at the new item.
Expand Down Expand Up @@ -96,7 +95,7 @@ xfs_trans_log_dquot(
{
xfs_log_item_desc_t *lidp;

ASSERT(XFS_DQ_IS_ADDEDTO_TRX(tp, dqp));
ASSERT(dqp->q_transp == tp);
ASSERT(XFS_DQ_IS_LOCKED(dqp));

lidp = xfs_trans_find_item(tp, (xfs_log_item_t*)(&dqp->q_logitem));
Expand Down Expand Up @@ -198,16 +197,16 @@ xfs_trans_get_dqtrx(
int i;
xfs_dqtrx_t *qa;

for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) {
qa = XFS_QM_DQP_TO_DQACCT(tp, dqp);
qa = XFS_QM_ISUDQ(dqp) ?
tp->t_dqinfo->dqa_usrdquots : tp->t_dqinfo->dqa_grpdquots;

for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) {
if (qa[i].qt_dquot == NULL ||
qa[i].qt_dquot == dqp) {
return (&qa[i]);
}
qa[i].qt_dquot == dqp)
return &qa[i];
}

return (NULL);
return NULL;
}

/*
Expand Down Expand Up @@ -381,7 +380,7 @@ xfs_trans_apply_dquot_deltas(
break;

ASSERT(XFS_DQ_IS_LOCKED(dqp));
ASSERT(XFS_DQ_IS_ADDEDTO_TRX(tp, dqp));
ASSERT(dqp->q_transp == tp);

/*
* adjust the actual number of blocks used
Expand Down

0 comments on commit 191f848

Please sign in to comment.