[RFC PATCH 1/3] xfs: Add is_rwsem_write_locked function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is going to be used to check if an rwsem is held for write.
Mimicking what current mrlock->mr_writer variable provides but using
the generic rwsem infrastructure. One might argue that redefining the
locked bit is a layering violation since RWSEM_WRITE_LOCKED is not
exposed, however I'd argue back that this is only used in a debugging
scenario and the physical layout of the rwsem is unlikely to change.

Signed-off-by: Nikolay Borisov <nborisov@xxxxxxxx>
---
 fs/xfs/xfs_inode.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index b7352bc4c815..499e63da935c 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -345,6 +345,13 @@ xfs_ilock_demote(
 }
 
 #if defined(DEBUG) || defined(XFS_WARN)
+static bool is_rwsem_write_locked(struct rw_semaphore *rwsem)
+{
+	/* Copy of RWSEM_WRITE_LOCKED from rwsem.c */
+#define LOCK_BIT (1UL << 0)
+	return atomic_long_read(&rwsem->count) & LOCK_BIT;
+}
+
 int
 xfs_isilocked(
 	xfs_inode_t		*ip,
-- 
2.25.1




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux