From: Matthew Wilcox (Oracle) Date: Wed, 6 Sep 2023 18:44:49 +0000 (-0400) Subject: xfs: Use rwsem_is_write_locked() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=754fb6a68dae3649398722ba0f1a38b3870f72a5;p=users%2Fwilly%2Fpagecache.git 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) --- 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)) {