diff options
author | Christoph Hellwig <hch@lst.de> | 2009-02-09 02:47:22 -0500 |
---|---|---|
committer | Christoph Hellwig <hch@brick.lst.de> | 2009-02-09 02:47:22 -0500 |
commit | c9a192dcf906a33f59c555924e7796a4b9454217 (patch) | |
tree | fda65cd2f97b75d21762fcfa229c2c1e4920e9cf /fs/xfs/quota/xfs_qm.c | |
parent | 7201813bf55cc06e6a7405831f63df96ee7842e7 (diff) |
xfs: sanitize qh_lock wrappers
Get rid of various obsfucating wrappers for accessing the quota hash lock,
we only keep the accessors for accessing the mplist and freelist locks as
they encode a multi-level datastructure walk. But make sure all of them
are defined in the same way as simple macros.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/quota/xfs_qm.c')
-rw-r--r-- | fs/xfs/quota/xfs_qm.c | 49 |
1 files changed, 8 insertions, 41 deletions
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c index 246790ad9589..11d0a4f89a0e 100644 --- a/fs/xfs/quota/xfs_qm.c +++ b/fs/xfs/quota/xfs_qm.c | |||
@@ -69,8 +69,6 @@ STATIC void xfs_qm_list_destroy(xfs_dqlist_t *); | |||
69 | 69 | ||
70 | STATIC void xfs_qm_freelist_init(xfs_frlist_t *); | 70 | STATIC void xfs_qm_freelist_init(xfs_frlist_t *); |
71 | STATIC void xfs_qm_freelist_destroy(xfs_frlist_t *); | 71 | STATIC void xfs_qm_freelist_destroy(xfs_frlist_t *); |
72 | STATIC int xfs_qm_mplist_nowait(xfs_mount_t *); | ||
73 | STATIC int xfs_qm_dqhashlock_nowait(xfs_dquot_t *); | ||
74 | 72 | ||
75 | STATIC int xfs_qm_init_quotainos(xfs_mount_t *); | 73 | STATIC int xfs_qm_init_quotainos(xfs_mount_t *); |
76 | STATIC int xfs_qm_init_quotainfo(xfs_mount_t *); | 74 | STATIC int xfs_qm_init_quotainfo(xfs_mount_t *); |
@@ -576,10 +574,10 @@ xfs_qm_dqpurge_int( | |||
576 | continue; | 574 | continue; |
577 | } | 575 | } |
578 | 576 | ||
579 | if (! xfs_qm_dqhashlock_nowait(dqp)) { | 577 | if (!mutex_trylock(&dqp->q_hash->qh_lock)) { |
580 | nrecl = XFS_QI_MPLRECLAIMS(mp); | 578 | nrecl = XFS_QI_MPLRECLAIMS(mp); |
581 | xfs_qm_mplist_unlock(mp); | 579 | xfs_qm_mplist_unlock(mp); |
582 | XFS_DQ_HASH_LOCK(dqp->q_hash); | 580 | mutex_lock(&dqp->q_hash->qh_lock); |
583 | xfs_qm_mplist_lock(mp); | 581 | xfs_qm_mplist_lock(mp); |
584 | 582 | ||
585 | /* | 583 | /* |
@@ -589,7 +587,7 @@ xfs_qm_dqpurge_int( | |||
589 | * this point, but somebody might be taking things off. | 587 | * this point, but somebody might be taking things off. |
590 | */ | 588 | */ |
591 | if (nrecl != XFS_QI_MPLRECLAIMS(mp)) { | 589 | if (nrecl != XFS_QI_MPLRECLAIMS(mp)) { |
592 | XFS_DQ_HASH_UNLOCK(dqp->q_hash); | 590 | mutex_unlock(&dqp->q_hash->qh_lock); |
593 | goto again; | 591 | goto again; |
594 | } | 592 | } |
595 | } | 593 | } |
@@ -2027,7 +2025,7 @@ xfs_qm_shake_freelist( | |||
2027 | * a dqlookup process that holds the hashlock that is | 2025 | * a dqlookup process that holds the hashlock that is |
2028 | * waiting for the freelist lock. | 2026 | * waiting for the freelist lock. |
2029 | */ | 2027 | */ |
2030 | if (! xfs_qm_dqhashlock_nowait(dqp)) { | 2028 | if (!mutex_trylock(&dqp->q_hash->qh_lock)) { |
2031 | xfs_dqfunlock(dqp); | 2029 | xfs_dqfunlock(dqp); |
2032 | xfs_dqunlock(dqp); | 2030 | xfs_dqunlock(dqp); |
2033 | dqp = dqp->dq_flnext; | 2031 | dqp = dqp->dq_flnext; |
@@ -2044,7 +2042,7 @@ xfs_qm_shake_freelist( | |||
2044 | /* XXX put a sentinel so that we can come back here */ | 2042 | /* XXX put a sentinel so that we can come back here */ |
2045 | xfs_dqfunlock(dqp); | 2043 | xfs_dqfunlock(dqp); |
2046 | xfs_dqunlock(dqp); | 2044 | xfs_dqunlock(dqp); |
2047 | XFS_DQ_HASH_UNLOCK(hash); | 2045 | mutex_unlock(&hash->qh_lock); |
2048 | xfs_qm_freelist_unlock(xfs_Gqm); | 2046 | xfs_qm_freelist_unlock(xfs_Gqm); |
2049 | if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS) | 2047 | if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS) |
2050 | return nreclaimed; | 2048 | return nreclaimed; |
@@ -2061,7 +2059,7 @@ xfs_qm_shake_freelist( | |||
2061 | XQM_HASHLIST_REMOVE(hash, dqp); | 2059 | XQM_HASHLIST_REMOVE(hash, dqp); |
2062 | xfs_dqfunlock(dqp); | 2060 | xfs_dqfunlock(dqp); |
2063 | xfs_qm_mplist_unlock(dqp->q_mount); | 2061 | xfs_qm_mplist_unlock(dqp->q_mount); |
2064 | XFS_DQ_HASH_UNLOCK(hash); | 2062 | mutex_unlock(&hash->qh_lock); |
2065 | 2063 | ||
2066 | off_freelist: | 2064 | off_freelist: |
2067 | XQM_FREELIST_REMOVE(dqp); | 2065 | XQM_FREELIST_REMOVE(dqp); |
@@ -2203,7 +2201,7 @@ xfs_qm_dqreclaim_one(void) | |||
2203 | continue; | 2201 | continue; |
2204 | } | 2202 | } |
2205 | 2203 | ||
2206 | if (! xfs_qm_dqhashlock_nowait(dqp)) | 2204 | if (!mutex_trylock(&dqp->q_hash->qh_lock)) |
2207 | goto mplistunlock; | 2205 | goto mplistunlock; |
2208 | 2206 | ||
2209 | ASSERT(dqp->q_nrefs == 0); | 2207 | ASSERT(dqp->q_nrefs == 0); |
@@ -2212,7 +2210,7 @@ xfs_qm_dqreclaim_one(void) | |||
2212 | XQM_HASHLIST_REMOVE(dqp->q_hash, dqp); | 2210 | XQM_HASHLIST_REMOVE(dqp->q_hash, dqp); |
2213 | XQM_FREELIST_REMOVE(dqp); | 2211 | XQM_FREELIST_REMOVE(dqp); |
2214 | dqpout = dqp; | 2212 | dqpout = dqp; |
2215 | XFS_DQ_HASH_UNLOCK(dqp->q_hash); | 2213 | mutex_unlock(&dqp->q_hash->qh_lock); |
2216 | mplistunlock: | 2214 | mplistunlock: |
2217 | xfs_qm_mplist_unlock(dqp->q_mount); | 2215 | xfs_qm_mplist_unlock(dqp->q_mount); |
2218 | xfs_dqfunlock(dqp); | 2216 | xfs_dqfunlock(dqp); |
@@ -2715,34 +2713,3 @@ xfs_qm_freelist_append(xfs_frlist_t *ql, xfs_dquot_t *dq) | |||
2715 | { | 2713 | { |
2716 | xfs_qm_freelist_insert((xfs_frlist_t *)ql->qh_prev, dq); | 2714 | xfs_qm_freelist_insert((xfs_frlist_t *)ql->qh_prev, dq); |
2717 | } | 2715 | } |
2718 | |||
2719 | STATIC int | ||
2720 | xfs_qm_dqhashlock_nowait( | ||
2721 | xfs_dquot_t *dqp) | ||
2722 | { | ||
2723 | int locked; | ||
2724 | |||
2725 | locked = mutex_trylock(&((dqp)->q_hash->qh_lock)); | ||
2726 | return locked; | ||
2727 | } | ||
2728 | |||
2729 | int | ||
2730 | xfs_qm_freelist_lock_nowait( | ||
2731 | xfs_qm_t *xqm) | ||
2732 | { | ||
2733 | int locked; | ||
2734 | |||
2735 | locked = mutex_trylock(&(xqm->qm_dqfreelist.qh_lock)); | ||
2736 | return locked; | ||
2737 | } | ||
2738 | |||
2739 | STATIC int | ||
2740 | xfs_qm_mplist_nowait( | ||
2741 | xfs_mount_t *mp) | ||
2742 | { | ||
2743 | int locked; | ||
2744 | |||
2745 | ASSERT(mp->m_quotainfo); | ||
2746 | locked = mutex_trylock(&(XFS_QI_MPLLOCK(mp))); | ||
2747 | return locked; | ||
2748 | } | ||