Commit f9369729 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dave Chinner

xfs: improve xfs_isilocked

Use rwsem_is_locked to make the assertations for shared locks work.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent 070ecdca
...@@ -741,30 +741,24 @@ xfs_ilock_demote( ...@@ -741,30 +741,24 @@ xfs_ilock_demote(
} }
#ifdef DEBUG #ifdef DEBUG
/*
* Debug-only routine, without additional rw_semaphore APIs, we can
* now only answer requests regarding whether we hold the lock for write
* (reader state is outside our visibility, we only track writer state).
*
* Note: this means !xfs_isilocked would give false positives, so don't do that.
*/
int int
xfs_isilocked( xfs_isilocked(
xfs_inode_t *ip, xfs_inode_t *ip,
uint lock_flags) uint lock_flags)
{ {
if ((lock_flags & (XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)) == if (lock_flags & (XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)) {
XFS_ILOCK_EXCL) { if (!(lock_flags & XFS_ILOCK_SHARED))
if (!ip->i_lock.mr_writer) return !!ip->i_lock.mr_writer;
return 0; return rwsem_is_locked(&ip->i_lock.mr_lock);
} }
if ((lock_flags & (XFS_IOLOCK_EXCL|XFS_IOLOCK_SHARED)) == if (lock_flags & (XFS_IOLOCK_EXCL|XFS_IOLOCK_SHARED)) {
XFS_IOLOCK_EXCL) { if (!(lock_flags & XFS_IOLOCK_SHARED))
if (!ip->i_iolock.mr_writer) return !!ip->i_iolock.mr_writer;
return 0; return rwsem_is_locked(&ip->i_iolock.mr_lock);
} }
return 1; ASSERT(0);
return 0;
} }
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment