From: Dave Chinner <david@fromorbit.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Waiman Long <longman@redhat.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Chandan Babu R <chandan.babu@oracle.com>,
"Darrick J . Wong" <djwong@kernel.org>,
linux-xfs@vger.kernel.org, Mateusz Guzik <mjguzik@gmail.com>
Subject: Re: [PATCH v2 3/5] xfs: Replace xfs_isilocked with xfs_assert_locked
Date: Mon, 9 Oct 2023 08:59:30 +1100 [thread overview]
Message-ID: <ZSMmQm/DbJQ0/oH9@dread.disaster.area> (raw)
In-Reply-To: <20231007203543.1377452-4-willy@infradead.org>
On Sat, Oct 07, 2023 at 09:35:41PM +0100, Matthew Wilcox (Oracle) wrote:
> To use the new rwsem_assert_held()/rwsem_assert_held_write(), we can't
> use the existing ASSERT macro.
>
> xfs_assert_ilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL) checks both the
> IOLOCK and the ILOCK are held for write. xfs_isilocked() only checked
> that the ILOCK was held for write.
>
> xfs_assert_ilocked() is always on, even if DEBUG or XFS_WARN aren't
> defined. It's a cheap check, so I don't think it's worth defining
> it away.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---
......
> -bool
> -xfs_isilocked(
> +void
> +xfs_assert_ilocked(
> 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;
> - return rwsem_is_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));
> - }
> -
> - if (lock_flags & (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED)) {
> - return __xfs_rwsem_islocked(&VFS_I(ip)->i_rwsem,
> - (lock_flags & XFS_IOLOCK_SHARED));
> - }
> -
> - ASSERT(0);
> - return false;
> + if (lock_flags & XFS_ILOCK_SHARED)
> + rwsem_assert_held(&ip->i_lock.mr_lock);
> + else if (lock_flags & XFS_ILOCK_EXCL)
> + BUG_ON(!ip->i_lock.mr_writer);
ASSERT(!ip->i_lock.mr_writer);
Otherwise OK.
-Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2023-10-08 21:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-07 20:35 [PATCH v2 0/5] Remove the XFS mrlock Matthew Wilcox (Oracle)
2023-10-07 20:35 ` [PATCH v2 1/5] locking: Add rwsem_assert_held() and rwsem_assert_held_write() Matthew Wilcox (Oracle)
2023-10-08 21:54 ` Dave Chinner
2023-10-07 20:35 ` [PATCH v2 2/5] mm: Use rwsem assertion macros for mmap_lock Matthew Wilcox (Oracle)
2023-10-07 20:35 ` [PATCH v2 3/5] xfs: Replace xfs_isilocked with xfs_assert_locked Matthew Wilcox (Oracle)
2023-10-08 21:59 ` Dave Chinner [this message]
2023-10-09 18:27 ` Darrick J. Wong
2023-10-07 20:35 ` [PATCH v2 4/5] xfs: Remove mrlock wrapper Matthew Wilcox (Oracle)
2023-10-08 22:17 ` Dave Chinner
2023-10-07 20:35 ` [PATCH v2 5/5] fs: Add inode_assert_locked() and inode_assert_locked_excl() Matthew Wilcox (Oracle)
2023-10-08 20:26 ` Mateusz Guzik
2023-10-08 21:05 ` Matthew Wilcox
2023-10-08 21:21 ` Mateusz Guzik
2023-10-08 20:31 ` [PATCH v2 0/5] Remove the XFS mrlock Mateusz Guzik
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=ZSMmQm/DbJQ0/oH9@dread.disaster.area \
--to=david@fromorbit.com \
--cc=chandan.babu@oracle.com \
--cc=djwong@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=mjguzik@gmail.com \
--cc=peterz@infradead.org \
--cc=will@kernel.org \
--cc=willy@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox