提交 78e55892 编写于 作者: C Christoph Hellwig 提交者: Ben Myers

xfs: add a xfs_dqhold helper

Factor the common pattern of:

	xfs_dqlock(dqp);
	XFS_DQHOLD(dqp);
	xfs_dqunlock(dqp);

into a new helper, and remove XFS_DQHOLD now that only one other caller
is left.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NDave Chinner <dchinner@redhat.com>
Signed-off-by: NBen Myers <bpm@sgi.com>
上级 ab680bb7
...@@ -733,7 +733,7 @@ xfs_qm_dqlookup( ...@@ -733,7 +733,7 @@ xfs_qm_dqlookup(
return -1; return -1;
} }
XFS_DQHOLD(dqp); dqp->q_nrefs++;
/* /*
* move the dquot to the front of the hashchain * move the dquot to the front of the hashchain
......
...@@ -80,8 +80,6 @@ enum { ...@@ -80,8 +80,6 @@ enum {
XFS_QLOCK_NESTED, XFS_QLOCK_NESTED,
}; };
#define XFS_DQHOLD(dqp) ((dqp)->q_nrefs++)
/* /*
* Manage the q_flush completion queue embedded in the dquot. This completion * Manage the q_flush completion queue embedded in the dquot. This completion
* queue synchronizes processes attempting to flush the in-core dquot back to * queue synchronizes processes attempting to flush the in-core dquot back to
...@@ -147,4 +145,12 @@ extern void xfs_dqlock2(struct xfs_dquot *, struct xfs_dquot *); ...@@ -147,4 +145,12 @@ extern void xfs_dqlock2(struct xfs_dquot *, struct xfs_dquot *);
extern void xfs_dqunlock(struct xfs_dquot *); extern void xfs_dqunlock(struct xfs_dquot *);
extern void xfs_dqflock_pushbuf_wait(struct xfs_dquot *dqp); extern void xfs_dqflock_pushbuf_wait(struct xfs_dquot *dqp);
static inline struct xfs_dquot *xfs_qm_dqhold(struct xfs_dquot *dqp)
{
xfs_dqlock(dqp);
dqp->q_nrefs++;
xfs_dqunlock(dqp);
return dqp;
}
#endif /* __XFS_DQUOT_H__ */ #endif /* __XFS_DQUOT_H__ */
...@@ -605,12 +605,9 @@ xfs_qm_dqattach_one( ...@@ -605,12 +605,9 @@ xfs_qm_dqattach_one(
*/ */
dqp = udqhint->q_gdquot; dqp = udqhint->q_gdquot;
if (dqp && be32_to_cpu(dqp->q_core.d_id) == id) { if (dqp && be32_to_cpu(dqp->q_core.d_id) == id) {
xfs_dqlock(dqp);
XFS_DQHOLD(dqp);
ASSERT(*IO_idqpp == NULL); ASSERT(*IO_idqpp == NULL);
*IO_idqpp = dqp;
xfs_dqunlock(dqp); *IO_idqpp = xfs_qm_dqhold(dqp);
xfs_dqunlock(udqhint); xfs_dqunlock(udqhint);
return 0; return 0;
} }
...@@ -670,11 +667,7 @@ xfs_qm_dqattach_grouphint( ...@@ -670,11 +667,7 @@ xfs_qm_dqattach_grouphint(
xfs_qm_dqrele(tmp); xfs_qm_dqrele(tmp);
} }
xfs_dqlock(gdq); udq->q_gdquot = xfs_qm_dqhold(gdq);
XFS_DQHOLD(gdq);
xfs_dqunlock(gdq);
udq->q_gdquot = gdq;
done: done:
xfs_dqunlock(udq); xfs_dqunlock(udq);
} }
...@@ -1941,10 +1934,7 @@ xfs_qm_vop_dqalloc( ...@@ -1941,10 +1934,7 @@ xfs_qm_vop_dqalloc(
* this to caller * this to caller
*/ */
ASSERT(ip->i_udquot); ASSERT(ip->i_udquot);
uq = ip->i_udquot; uq = xfs_qm_dqhold(ip->i_udquot);
xfs_dqlock(uq);
XFS_DQHOLD(uq);
xfs_dqunlock(uq);
} }
} }
if ((flags & XFS_QMOPT_GQUOTA) && XFS_IS_GQUOTA_ON(mp)) { if ((flags & XFS_QMOPT_GQUOTA) && XFS_IS_GQUOTA_ON(mp)) {
...@@ -1965,10 +1955,7 @@ xfs_qm_vop_dqalloc( ...@@ -1965,10 +1955,7 @@ xfs_qm_vop_dqalloc(
xfs_ilock(ip, lockflags); xfs_ilock(ip, lockflags);
} else { } else {
ASSERT(ip->i_gdquot); ASSERT(ip->i_gdquot);
gq = ip->i_gdquot; gq = xfs_qm_dqhold(ip->i_gdquot);
xfs_dqlock(gq);
XFS_DQHOLD(gq);
xfs_dqunlock(gq);
} }
} else if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) { } else if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) {
if (xfs_get_projid(ip) != prid) { if (xfs_get_projid(ip) != prid) {
...@@ -1988,10 +1975,7 @@ xfs_qm_vop_dqalloc( ...@@ -1988,10 +1975,7 @@ xfs_qm_vop_dqalloc(
xfs_ilock(ip, lockflags); xfs_ilock(ip, lockflags);
} else { } else {
ASSERT(ip->i_gdquot); ASSERT(ip->i_gdquot);
gq = ip->i_gdquot; gq = xfs_qm_dqhold(ip->i_gdquot);
xfs_dqlock(gq);
XFS_DQHOLD(gq);
xfs_dqunlock(gq);
} }
} }
if (uq) if (uq)
...@@ -2041,14 +2025,10 @@ xfs_qm_vop_chown( ...@@ -2041,14 +2025,10 @@ xfs_qm_vop_chown(
xfs_trans_mod_dquot(tp, newdq, XFS_TRANS_DQ_ICOUNT, 1); xfs_trans_mod_dquot(tp, newdq, XFS_TRANS_DQ_ICOUNT, 1);
/* /*
* Take an extra reference, because the inode * Take an extra reference, because the inode is going to keep
* is going to keep this dquot pointer even * this dquot pointer even after the trans_commit.
* after the trans_commit.
*/ */
xfs_dqlock(newdq); *IO_olddq = xfs_qm_dqhold(newdq);
XFS_DQHOLD(newdq);
xfs_dqunlock(newdq);
*IO_olddq = newdq;
return prevdq; return prevdq;
} }
...@@ -2180,25 +2160,21 @@ xfs_qm_vop_create_dqattach( ...@@ -2180,25 +2160,21 @@ xfs_qm_vop_create_dqattach(
ASSERT(XFS_IS_QUOTA_RUNNING(mp)); ASSERT(XFS_IS_QUOTA_RUNNING(mp));
if (udqp) { if (udqp) {
xfs_dqlock(udqp);
XFS_DQHOLD(udqp);
xfs_dqunlock(udqp);
ASSERT(ip->i_udquot == NULL); ASSERT(ip->i_udquot == NULL);
ip->i_udquot = udqp;
ASSERT(XFS_IS_UQUOTA_ON(mp)); ASSERT(XFS_IS_UQUOTA_ON(mp));
ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id)); ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id));
ip->i_udquot = xfs_qm_dqhold(udqp);
xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1); xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1);
} }
if (gdqp) { if (gdqp) {
xfs_dqlock(gdqp);
XFS_DQHOLD(gdqp);
xfs_dqunlock(gdqp);
ASSERT(ip->i_gdquot == NULL); ASSERT(ip->i_gdquot == NULL);
ip->i_gdquot = gdqp;
ASSERT(XFS_IS_OQUOTA_ON(mp)); ASSERT(XFS_IS_OQUOTA_ON(mp));
ASSERT((XFS_IS_GQUOTA_ON(mp) ? ASSERT((XFS_IS_GQUOTA_ON(mp) ?
ip->i_d.di_gid : xfs_get_projid(ip)) == ip->i_d.di_gid : xfs_get_projid(ip)) ==
be32_to_cpu(gdqp->q_core.d_id)); be32_to_cpu(gdqp->q_core.d_id));
ip->i_gdquot = xfs_qm_dqhold(gdqp);
xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1); xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册