[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230907174705.2976191-4-willy@infradead.org>
Date: Thu, 7 Sep 2023 18:47:03 +0100
From: "Matthew Wilcox (Oracle)" <willy@...radead.org>
To: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>,
Waiman Long <longman@...hat.com>
Cc: "Matthew Wilcox (Oracle)" <willy@...radead.org>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Chandan Babu R <chandan.babu@...cle.com>,
"Darrick J . Wong" <djwong@...nel.org>, linux-xfs@...r.kernel.org
Subject: [PATCH 3/5] xfs: Use rwsem_is_write_locked()
This avoids using the mr_writer field to check the XFS ILOCK is held
for write. It also improves the checking we do when lockdep is disabled.
Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
---
fs/xfs/xfs_inode.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 360fe83a334f..e58d84d23f49 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);
@@ -359,12 +362,10 @@ xfs_isilocked(
struct xfs_inode *ip,
uint lock_flags)
{
- if (lock_flags & (XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)) {
- if (!(lock_flags & XFS_ILOCK_SHARED))
- return !!ip->i_lock.mr_writer;
+ if (lock_flags & XFS_ILOCK_SHARED)
return rwsem_is_locked(&ip->i_lock.mr_lock);
- }
-
+ if (lock_flags & XFS_ILOCK_EXCL)
+ return rwsem_is_write_locked(&ip->i_lock.mr_lock);
if (lock_flags & (XFS_MMAPLOCK_EXCL|XFS_MMAPLOCK_SHARED)) {
return __xfs_rwsem_islocked(&VFS_I(ip)->i_mapping->invalidate_lock,
(lock_flags & XFS_MMAPLOCK_SHARED));
--
2.40.1
Powered by blists - more mailing lists