aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2010-06-03 02:22:29 -0400
committerDave Chinner <david@fromorbit.com>2010-06-03 02:22:29 -0400
commitf9369729496a0f4c607a4cc1ea4dfeddbbfc505a (patch)
tree05d463cd3c40514f09c01553cfd40ea3ea784f37
parent070ecdca54dde9577d2697088e74e45568f48efb (diff)
xfs: improve xfs_isilocked
Use rwsem_is_locked to make the assertations for shared locks work. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com>
-rw-r--r--fs/xfs/xfs_iget.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index f44a367907a8..75df75f43d48 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -741,30 +741,24 @@ xfs_ilock_demote(
741} 741}
742 742
743#ifdef DEBUG 743#ifdef DEBUG
744/*
745 * Debug-only routine, without additional rw_semaphore APIs, we can
746 * now only answer requests regarding whether we hold the lock for write
747 * (reader state is outside our visibility, we only track writer state).
748 *
749 * Note: this means !xfs_isilocked would give false positives, so don't do that.
750 */
751int 744int
752xfs_isilocked( 745xfs_isilocked(
753 xfs_inode_t *ip, 746 xfs_inode_t *ip,
754 uint lock_flags) 747 uint lock_flags)
755{ 748{
756 if ((lock_flags & (XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)) == 749 if (lock_flags & (XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)) {
757 XFS_ILOCK_EXCL) { 750 if (!(lock_flags & XFS_ILOCK_SHARED))
758 if (!ip->i_lock.mr_writer) 751 return !!ip->i_lock.mr_writer;
759 return 0; 752 return rwsem_is_locked(&ip->i_lock.mr_lock);
760 } 753 }
761 754
762 if ((lock_flags & (XFS_IOLOCK_EXCL|XFS_IOLOCK_SHARED)) == 755 if (lock_flags & (XFS_IOLOCK_EXCL|XFS_IOLOCK_SHARED)) {
763 XFS_IOLOCK_EXCL) { 756 if (!(lock_flags & XFS_IOLOCK_SHARED))
764 if (!ip->i_iolock.mr_writer) 757 return !!ip->i_iolock.mr_writer;
765 return 0; 758 return rwsem_is_locked(&ip->i_iolock.mr_lock);
766 } 759 }
767 760
768 return 1; 761 ASSERT(0);
762 return 0;
769} 763}
770#endif 764#endif