All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: linux-xfs@vger.kernel.org
Cc: david@fromorbit.com, Nikolay Borisov <nborisov@suse.com>
Subject: [RFC PATCH 1/3] xfs: Add is_rwsem_write_locked function
Date: Wed, 13 Jan 2021 13:17:04 +0200	[thread overview]
Message-ID: <20210113111707.756662-2-nborisov@suse.com> (raw)
In-Reply-To: <20210113111707.756662-1-nborisov@suse.com>

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@suse.com>
---
 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


  reply	other threads:[~2021-01-13 11:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-13 11:17 [RFC PATCH 0/3] Remove mrlock Nikolay Borisov
2021-01-13 11:17 ` Nikolay Borisov [this message]
2021-01-13 11:17 ` [RFC PATCH 2/3] xfs: Convert i_lock/i_mmaplock to rw_semaphore Nikolay Borisov
2021-01-13 11:17 ` [RFC PATCH 3/3] xfs: Remove mrlock Nikolay Borisov
2021-01-13 11:17 ` Nikolay Borisov
2021-01-13 11:27 ` [RFC PATCH 0/3] " Christoph Hellwig
2021-01-13 11:41   ` Nikolay Borisov
2021-01-13 12:09     ` Christoph Hellwig
2021-01-13 12:17       ` Nikolay Borisov
2021-01-20 20:14         ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210113111707.756662-2-nborisov@suse.com \
    --to=nborisov@suse.com \
    --cc=david@fromorbit.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.