diff options
author | Christoph Hellwig <hch@infradead.org> | 2011-12-06 16:58:22 -0500 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2011-12-15 15:37:32 -0500 |
commit | 78e55892d65ea69fbf252e086375d0d8f081b6c8 (patch) | |
tree | 7f115cdcd97b5dfa6826f8c27427d4061a97591f /fs/xfs | |
parent | ab680bb739ca0e969148951c2e127f6683dcb933 (diff) |
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: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_dquot.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_dquot.h | 10 | ||||
-rw-r--r-- | fs/xfs/xfs_qm.c | 48 |
3 files changed, 21 insertions, 39 deletions
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index f1d3ccb2980e..2ce562cb5c78 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c | |||
@@ -733,7 +733,7 @@ xfs_qm_dqlookup( | |||
733 | return -1; | 733 | return -1; |
734 | } | 734 | } |
735 | 735 | ||
736 | XFS_DQHOLD(dqp); | 736 | dqp->q_nrefs++; |
737 | 737 | ||
738 | /* | 738 | /* |
739 | * move the dquot to the front of the hashchain | 739 | * move the dquot to the front of the hashchain |
diff --git a/fs/xfs/xfs_dquot.h b/fs/xfs/xfs_dquot.h index 98488dfe442f..cc0149d217ba 100644 --- a/fs/xfs/xfs_dquot.h +++ b/fs/xfs/xfs_dquot.h | |||
@@ -80,8 +80,6 @@ enum { | |||
80 | XFS_QLOCK_NESTED, | 80 | XFS_QLOCK_NESTED, |
81 | }; | 81 | }; |
82 | 82 | ||
83 | #define XFS_DQHOLD(dqp) ((dqp)->q_nrefs++) | ||
84 | |||
85 | /* | 83 | /* |
86 | * Manage the q_flush completion queue embedded in the dquot. This completion | 84 | * Manage the q_flush completion queue embedded in the dquot. This completion |
87 | * queue synchronizes processes attempting to flush the in-core dquot back to | 85 | * 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 | extern void xfs_dqunlock(struct xfs_dquot *); | 145 | extern void xfs_dqunlock(struct xfs_dquot *); |
148 | extern void xfs_dqflock_pushbuf_wait(struct xfs_dquot *dqp); | 146 | extern void xfs_dqflock_pushbuf_wait(struct xfs_dquot *dqp); |
149 | 147 | ||
148 | static inline struct xfs_dquot *xfs_qm_dqhold(struct xfs_dquot *dqp) | ||
149 | { | ||
150 | xfs_dqlock(dqp); | ||
151 | dqp->q_nrefs++; | ||
152 | xfs_dqunlock(dqp); | ||
153 | return dqp; | ||
154 | } | ||
155 | |||
150 | #endif /* __XFS_DQUOT_H__ */ | 156 | #endif /* __XFS_DQUOT_H__ */ |
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 3c553454443c..cd7460ba4e69 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c | |||
@@ -605,12 +605,9 @@ xfs_qm_dqattach_one( | |||
605 | */ | 605 | */ |
606 | dqp = udqhint->q_gdquot; | 606 | dqp = udqhint->q_gdquot; |
607 | if (dqp && be32_to_cpu(dqp->q_core.d_id) == id) { | 607 | if (dqp && be32_to_cpu(dqp->q_core.d_id) == id) { |
608 | xfs_dqlock(dqp); | ||
609 | XFS_DQHOLD(dqp); | ||
610 | ASSERT(*IO_idqpp == NULL); | 608 | ASSERT(*IO_idqpp == NULL); |
611 | *IO_idqpp = dqp; | ||
612 | 609 | ||
613 | xfs_dqunlock(dqp); | 610 | *IO_idqpp = xfs_qm_dqhold(dqp); |
614 | xfs_dqunlock(udqhint); | 611 | xfs_dqunlock(udqhint); |
615 | return 0; | 612 | return 0; |
616 | } | 613 | } |
@@ -670,11 +667,7 @@ xfs_qm_dqattach_grouphint( | |||
670 | xfs_qm_dqrele(tmp); | 667 | xfs_qm_dqrele(tmp); |
671 | } | 668 | } |
672 | 669 | ||
673 | xfs_dqlock(gdq); | 670 | udq->q_gdquot = xfs_qm_dqhold(gdq); |
674 | XFS_DQHOLD(gdq); | ||
675 | xfs_dqunlock(gdq); | ||
676 | |||
677 | udq->q_gdquot = gdq; | ||
678 | done: | 671 | done: |
679 | xfs_dqunlock(udq); | 672 | xfs_dqunlock(udq); |
680 | } | 673 | } |
@@ -1941,10 +1934,7 @@ xfs_qm_vop_dqalloc( | |||
1941 | * this to caller | 1934 | * this to caller |
1942 | */ | 1935 | */ |
1943 | ASSERT(ip->i_udquot); | 1936 | ASSERT(ip->i_udquot); |
1944 | uq = ip->i_udquot; | 1937 | uq = xfs_qm_dqhold(ip->i_udquot); |
1945 | xfs_dqlock(uq); | ||
1946 | XFS_DQHOLD(uq); | ||
1947 | xfs_dqunlock(uq); | ||
1948 | } | 1938 | } |
1949 | } | 1939 | } |
1950 | if ((flags & XFS_QMOPT_GQUOTA) && XFS_IS_GQUOTA_ON(mp)) { | 1940 | if ((flags & XFS_QMOPT_GQUOTA) && XFS_IS_GQUOTA_ON(mp)) { |
@@ -1965,10 +1955,7 @@ xfs_qm_vop_dqalloc( | |||
1965 | xfs_ilock(ip, lockflags); | 1955 | xfs_ilock(ip, lockflags); |
1966 | } else { | 1956 | } else { |
1967 | ASSERT(ip->i_gdquot); | 1957 | ASSERT(ip->i_gdquot); |
1968 | gq = ip->i_gdquot; | 1958 | gq = xfs_qm_dqhold(ip->i_gdquot); |
1969 | xfs_dqlock(gq); | ||
1970 | XFS_DQHOLD(gq); | ||
1971 | xfs_dqunlock(gq); | ||
1972 | } | 1959 | } |
1973 | } else if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) { | 1960 | } else if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) { |
1974 | if (xfs_get_projid(ip) != prid) { | 1961 | if (xfs_get_projid(ip) != prid) { |
@@ -1988,10 +1975,7 @@ xfs_qm_vop_dqalloc( | |||
1988 | xfs_ilock(ip, lockflags); | 1975 | xfs_ilock(ip, lockflags); |
1989 | } else { | 1976 | } else { |
1990 | ASSERT(ip->i_gdquot); | 1977 | ASSERT(ip->i_gdquot); |
1991 | gq = ip->i_gdquot; | 1978 | gq = xfs_qm_dqhold(ip->i_gdquot); |
1992 | xfs_dqlock(gq); | ||
1993 | XFS_DQHOLD(gq); | ||
1994 | xfs_dqunlock(gq); | ||
1995 | } | 1979 | } |
1996 | } | 1980 | } |
1997 | if (uq) | 1981 | if (uq) |
@@ -2041,14 +2025,10 @@ xfs_qm_vop_chown( | |||
2041 | xfs_trans_mod_dquot(tp, newdq, XFS_TRANS_DQ_ICOUNT, 1); | 2025 | xfs_trans_mod_dquot(tp, newdq, XFS_TRANS_DQ_ICOUNT, 1); |
2042 | 2026 | ||
2043 | /* | 2027 | /* |
2044 | * Take an extra reference, because the inode | 2028 | * Take an extra reference, because the inode is going to keep |
2045 | * is going to keep this dquot pointer even | 2029 | * this dquot pointer even after the trans_commit. |
2046 | * after the trans_commit. | ||
2047 | */ | 2030 | */ |
2048 | xfs_dqlock(newdq); | 2031 | *IO_olddq = xfs_qm_dqhold(newdq); |
2049 | XFS_DQHOLD(newdq); | ||
2050 | xfs_dqunlock(newdq); | ||
2051 | *IO_olddq = newdq; | ||
2052 | 2032 | ||
2053 | return prevdq; | 2033 | return prevdq; |
2054 | } | 2034 | } |
@@ -2180,25 +2160,21 @@ xfs_qm_vop_create_dqattach( | |||
2180 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); | 2160 | ASSERT(XFS_IS_QUOTA_RUNNING(mp)); |
2181 | 2161 | ||
2182 | if (udqp) { | 2162 | if (udqp) { |
2183 | xfs_dqlock(udqp); | ||
2184 | XFS_DQHOLD(udqp); | ||
2185 | xfs_dqunlock(udqp); | ||
2186 | ASSERT(ip->i_udquot == NULL); | 2163 | ASSERT(ip->i_udquot == NULL); |
2187 | ip->i_udquot = udqp; | ||
2188 | ASSERT(XFS_IS_UQUOTA_ON(mp)); | 2164 | ASSERT(XFS_IS_UQUOTA_ON(mp)); |
2189 | ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id)); | 2165 | ASSERT(ip->i_d.di_uid == be32_to_cpu(udqp->q_core.d_id)); |
2166 | |||
2167 | ip->i_udquot = xfs_qm_dqhold(udqp); | ||
2190 | xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1); | 2168 | xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1); |
2191 | } | 2169 | } |
2192 | if (gdqp) { | 2170 | if (gdqp) { |
2193 | xfs_dqlock(gdqp); | ||
2194 | XFS_DQHOLD(gdqp); | ||
2195 | xfs_dqunlock(gdqp); | ||
2196 | ASSERT(ip->i_gdquot == NULL); | 2171 | ASSERT(ip->i_gdquot == NULL); |
2197 | ip->i_gdquot = gdqp; | ||
2198 | ASSERT(XFS_IS_OQUOTA_ON(mp)); | 2172 | ASSERT(XFS_IS_OQUOTA_ON(mp)); |
2199 | ASSERT((XFS_IS_GQUOTA_ON(mp) ? | 2173 | ASSERT((XFS_IS_GQUOTA_ON(mp) ? |
2200 | ip->i_d.di_gid : xfs_get_projid(ip)) == | 2174 | ip->i_d.di_gid : xfs_get_projid(ip)) == |
2201 | be32_to_cpu(gdqp->q_core.d_id)); | 2175 | be32_to_cpu(gdqp->q_core.d_id)); |
2176 | |||
2177 | ip->i_gdquot = xfs_qm_dqhold(gdqp); | ||
2202 | xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1); | 2178 | xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1); |
2203 | } | 2179 | } |
2204 | } | 2180 | } |