From 754fb6a68dae3649398722ba0f1a38b3870f72a5 Mon Sep 17 00:00:00 2001 From: "Matthew Wilcox (Oracle)" Date: Wed, 6 Sep 2023 14:44:49 -0400 Subject: [PATCH] xfs: Use rwsem_is_write_locked() This gives slightly better runtime checking when lockdep is disabled. It also lets us avoid using the mr_writer field to check the XFS ILOCK. Signed-off-by: Matthew Wilcox (Oracle) --- fs/xfs/xfs_inode.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 9e62cc5001401..3f1aa367f45af 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -339,8 +339,11 @@ __xfs_rwsem_islocked( struct rw_semaphore *rwsem, bool shared) { - if (!debug_locks) + if (!debug_locks) { + if (!shared) + return rwsem_is_write_locked(rwsem); return rwsem_is_locked(rwsem); + } if (!shared) return lockdep_is_held_type(rwsem, 0); @@ -360,9 +363,8 @@ xfs_isilocked( uint lock_flags) { if (lock_flags & (XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)) { - if (!(lock_flags & XFS_ILOCK_SHARED)) - return !!ip->i_lock.mr_writer; - return rwsem_is_locked(&ip->i_lock.mr_lock); + return __xfs_rwsem_islocked(&ip->i_lock.mr_lock, + (lock_flags & XFS_ILOCK_SHARED)); } if (lock_flags & (XFS_MMAPLOCK_EXCL|XFS_MMAPLOCK_SHARED)) { -- 2.49.0