public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Bill O'Donnell <billodo@redhat.com>
To: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	Pavel Reichl <preichl@redhat.com>,
	linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/4] xfs: change xfs_isilocked() to always use lockdep()
Date: Thu, 30 Jan 2020 14:27:46 -0600	[thread overview]
Message-ID: <20200130202746.GB118904@redhat.com> (raw)
In-Reply-To: <20200130201447.GQ18610@dread.disaster.area>

On Fri, Jan 31, 2020 at 07:14:47AM +1100, Dave Chinner wrote:
> On Wed, Jan 29, 2020 at 11:44:24PM -0800, Christoph Hellwig wrote:
> > On Thu, Jan 30, 2020 at 09:18:19AM +1100, Dave Chinner wrote:
> > > This captures both read and write locks on the rwsem, and doesn't
> > > discriminate at all. Now we don't have explicit writer lock checking
> > > in CONFIG_XFS_DEBUG=y kernels, I think we need to at least check
> > > that the rwsem is locked in all cases to catch cases where we are
> > > calling a function without the lock held. That will ctach most
> > > programming mistakes, and then lockdep will provide the
> > > read-vs-write discrimination to catch the "hold the wrong lock type"
> > > mistakes.
> > > 
> > > Hence I think this code should end up looking like this:
> > > 
> > > 	if (lock_flags & (XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)) {
> > > 		bool locked = false;
> > > 
> > > 		if (!rwsem_is_locked(&ip->i_lock))
> > > 			return false;
> > > 		if (!debug_locks)
> > > 			return true;
> > > 		if (lock_flags & XFS_ILOCK_EXCL)
> > > 			locked = lockdep_is_held_type(&ip->i_lock, 0);
> > > 		if (lock_flags & XFS_ILOCK_SHARED)
> > > 			locked |= lockdep_is_held_type(&ip->i_lock, 1);
> > > 		return locked;
> > > 	}
> > > 
> > > Thoughts?
> > 
> > I like the idea, but I really think that this does not belong into XFS,
> > but into the core rwsem code.  That means replacing the lock_flags with
> > a bool exclusive, picking a good name for it (can't think of one right
> > now, except for re-using rwsem_is_locked), and adding a kerneldoc
> > comment explaining the semantics and use cases in detail.
> 
> I'd say that's the step after removing mrlocks in XFS. Get this
> patchset sorted, then lift the rwsem checking function to the core
> code as a separate patchset that can be handled indepedently to the
> changes we need to make to XFS...

I agree with this approach, with modification of rwsem checking code as
as separate follow-on patchset.
Thanks-
Bill

> 
> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.com
> 


  reply	other threads:[~2020-01-30 20:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-28 14:55 [PATCH 0/4] xfs: Remove wrappers for some semaphores Pavel Reichl
2020-01-28 14:55 ` [PATCH 1/4] xfs: change xfs_isilocked() to always use lockdep() Pavel Reichl
2020-01-28 16:42   ` Darrick J. Wong
2020-01-28 16:50     ` Pavel Reichl
2020-01-28 18:00     ` Eric Sandeen
2020-01-28 23:02     ` Dave Chinner
2020-01-29 22:18   ` Dave Chinner
2020-01-29 22:25     ` Darrick J. Wong
2020-01-29 23:20       ` Dave Chinner
2020-01-30  7:44     ` Christoph Hellwig
2020-01-30 20:14       ` Dave Chinner
2020-01-30 20:27         ` Bill O'Donnell [this message]
2020-01-28 14:55 ` [PATCH 2/4] xfs: Remove mr_writer field from mrlock_t Pavel Reichl
2020-01-28 14:55 ` [PATCH 3/4] xfs: Make i_lock and i_mmap native rwsems Pavel Reichl
2020-01-28 14:55 ` [PATCH 4/4] xfs: replace mr*() functions with native rwsem calls Pavel Reichl
2020-01-28 16:44   ` Darrick J. Wong
2020-01-30  7:45   ` Christoph Hellwig
2020-01-30  8:57     ` Pavel Reichl
2020-01-30 13:31       ` Christoph Hellwig
2020-01-30 13:43         ` Pavel Reichl

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=20200130202746.GB118904@redhat.com \
    --to=billodo@redhat.com \
    --cc=david@fromorbit.com \
    --cc=hch@infradead.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=preichl@redhat.com \
    /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