diff options
author | Christoph Hellwig <hch@lst.de> | 2011-07-08 08:36:19 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2011-07-08 08:36:19 -0400 |
commit | 0c842ad46a51891ac4420b7285613f4134a65ccd (patch) | |
tree | cf82cc7853821a21998114d20b1297b14061eade /fs/xfs/linux-2.6/xfs_buf.c | |
parent | bbb4197c73be356a052dac25cce5ed0c157c6c90 (diff) |
xfs: clean up buffer locking helpers
Rename xfs_buf_cond_lock and reverse it's return value to fit most other
trylock operations in the Kernel and XFS (with the exception of down_trylock,
after which xfs_buf_cond_lock was modelled), and replace xfs_buf_lock_val
with an xfs_buf_islocked for use in asserts, or and opencoded variant in
tracing. remove the XFS_BUF_* wrappers for all the locking helpers.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_buf.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_buf.c | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c index 5e68099db2a5..c77227615403 100644 --- a/fs/xfs/linux-2.6/xfs_buf.c +++ b/fs/xfs/linux-2.6/xfs_buf.c | |||
@@ -499,16 +499,14 @@ found: | |||
499 | spin_unlock(&pag->pag_buf_lock); | 499 | spin_unlock(&pag->pag_buf_lock); |
500 | xfs_perag_put(pag); | 500 | xfs_perag_put(pag); |
501 | 501 | ||
502 | if (xfs_buf_cond_lock(bp)) { | 502 | if (!xfs_buf_trylock(bp)) { |
503 | /* failed, so wait for the lock if requested. */ | 503 | if (flags & XBF_TRYLOCK) { |
504 | if (!(flags & XBF_TRYLOCK)) { | ||
505 | xfs_buf_lock(bp); | ||
506 | XFS_STATS_INC(xb_get_locked_waited); | ||
507 | } else { | ||
508 | xfs_buf_rele(bp); | 504 | xfs_buf_rele(bp); |
509 | XFS_STATS_INC(xb_busy_locked); | 505 | XFS_STATS_INC(xb_busy_locked); |
510 | return NULL; | 506 | return NULL; |
511 | } | 507 | } |
508 | xfs_buf_lock(bp); | ||
509 | XFS_STATS_INC(xb_get_locked_waited); | ||
512 | } | 510 | } |
513 | 511 | ||
514 | /* | 512 | /* |
@@ -896,8 +894,8 @@ xfs_buf_rele( | |||
896 | * to push on stale inode buffers. | 894 | * to push on stale inode buffers. |
897 | */ | 895 | */ |
898 | int | 896 | int |
899 | xfs_buf_cond_lock( | 897 | xfs_buf_trylock( |
900 | xfs_buf_t *bp) | 898 | struct xfs_buf *bp) |
901 | { | 899 | { |
902 | int locked; | 900 | int locked; |
903 | 901 | ||
@@ -907,15 +905,8 @@ xfs_buf_cond_lock( | |||
907 | else if (atomic_read(&bp->b_pin_count) && (bp->b_flags & XBF_STALE)) | 905 | else if (atomic_read(&bp->b_pin_count) && (bp->b_flags & XBF_STALE)) |
908 | xfs_log_force(bp->b_target->bt_mount, 0); | 906 | xfs_log_force(bp->b_target->bt_mount, 0); |
909 | 907 | ||
910 | trace_xfs_buf_cond_lock(bp, _RET_IP_); | 908 | trace_xfs_buf_trylock(bp, _RET_IP_); |
911 | return locked ? 0 : -EBUSY; | 909 | return locked; |
912 | } | ||
913 | |||
914 | int | ||
915 | xfs_buf_lock_value( | ||
916 | xfs_buf_t *bp) | ||
917 | { | ||
918 | return bp->b_sema.count; | ||
919 | } | 910 | } |
920 | 911 | ||
921 | /* | 912 | /* |
@@ -929,7 +920,7 @@ xfs_buf_lock_value( | |||
929 | */ | 920 | */ |
930 | void | 921 | void |
931 | xfs_buf_lock( | 922 | xfs_buf_lock( |
932 | xfs_buf_t *bp) | 923 | struct xfs_buf *bp) |
933 | { | 924 | { |
934 | trace_xfs_buf_lock(bp, _RET_IP_); | 925 | trace_xfs_buf_lock(bp, _RET_IP_); |
935 | 926 | ||
@@ -950,7 +941,7 @@ xfs_buf_lock( | |||
950 | */ | 941 | */ |
951 | void | 942 | void |
952 | xfs_buf_unlock( | 943 | xfs_buf_unlock( |
953 | xfs_buf_t *bp) | 944 | struct xfs_buf *bp) |
954 | { | 945 | { |
955 | if ((bp->b_flags & (XBF_DELWRI|_XBF_DELWRI_Q)) == XBF_DELWRI) { | 946 | if ((bp->b_flags & (XBF_DELWRI|_XBF_DELWRI_Q)) == XBF_DELWRI) { |
956 | atomic_inc(&bp->b_hold); | 947 | atomic_inc(&bp->b_hold); |
@@ -1694,7 +1685,7 @@ xfs_buf_delwri_split( | |||
1694 | list_for_each_entry_safe(bp, n, dwq, b_list) { | 1685 | list_for_each_entry_safe(bp, n, dwq, b_list) { |
1695 | ASSERT(bp->b_flags & XBF_DELWRI); | 1686 | ASSERT(bp->b_flags & XBF_DELWRI); |
1696 | 1687 | ||
1697 | if (!XFS_BUF_ISPINNED(bp) && !xfs_buf_cond_lock(bp)) { | 1688 | if (!XFS_BUF_ISPINNED(bp) && xfs_buf_trylock(bp)) { |
1698 | if (!force && | 1689 | if (!force && |
1699 | time_before(jiffies, bp->b_queuetime + age)) { | 1690 | time_before(jiffies, bp->b_queuetime + age)) { |
1700 | xfs_buf_unlock(bp); | 1691 | xfs_buf_unlock(bp); |