public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <aelder@sgi.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH] xfs: improve xfs_isilocked
Date: Fri, 28 May 2010 14:40:53 -0500	[thread overview]
Message-ID: <1275075653.2302.38.camel@doink> (raw)
In-Reply-To: <20100527190533.GB16102@infradead.org>

On Thu, 2010-05-27 at 15:05 -0400, Christoph Hellwig wrote:
> Use rwsem_is_locked to make the assertations for shared locks work.

So you're changing it so it answers "yes it's locked"
even it it's only a read lock now, right?

Previously it was basically (once each for ilock and
iolock):  "If the exclusive flag is set, but there is no
writer, then it is not locked; otherwise it is."

Now it's "If the exclusive flag is set, but no writer,
it's not locked.  Otherwise if the shared flag is
set it's locked if rwsem_is_locked() says we are.
Otherwise (ASSERT(0) and) it is not locked."

That last part is wrong I think.  It should be OK to
call xfs_isilocked() with neither flag set, in which
case the result should be 0.  And if the exclusive
flag is set, and there *is* a writer, it *is* locked,
so it should return 1.

					-Alex

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Index: xfs/fs/xfs/xfs_iget.c
> ===================================================================
> --- xfs.orig/fs/xfs/xfs_iget.c	2010-05-25 11:40:59.216005587 +0200
> +++ xfs/fs/xfs/xfs_iget.c	2010-05-27 20:59:09.244004330 +0200
> @@ -740,30 +738,24 @@ xfs_ilock_demote(
>  }
>  
>  #ifdef DEBUG
> -/*
> - * Debug-only routine, without additional rw_semaphore APIs, we can
> - * now only answer requests regarding whether we hold the lock for write
> - * (reader state is outside our visibility, we only track writer state).
> - *
> - * Note: this means !xfs_isilocked would give false positives, so don't do that.
> - */
>  int
>  xfs_isilocked(
>  	xfs_inode_t		*ip,
>  	uint			lock_flags)
>  {
> -	if ((lock_flags & (XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)) ==
> -			XFS_ILOCK_EXCL) {
> -		if (!ip->i_lock.mr_writer)
> -			return 0;
> +	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_IOLOCK_EXCL|XFS_IOLOCK_SHARED)) ==
> -			XFS_IOLOCK_EXCL) {
> -		if (!ip->i_iolock.mr_writer)
> -			return 0;
> +	if (lock_flags & (XFS_IOLOCK_EXCL|XFS_IOLOCK_SHARED)) {
> +		if (!(lock_flags & XFS_IOLOCK_SHARED))
> +			return !!ip->i_iolock.mr_writer;
> +		return rwsem_is_locked(&ip->i_iolock.mr_lock);
>  	}
>  
> -	return 1;
> +	ASSERT(0);
> +	return 0;
>  }
>  #endif
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs



_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2010-05-28 19:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-27 19:05 [PATCH] xfs: improve xfs_isilocked Christoph Hellwig
2010-05-28 19:40 ` Alex Elder [this message]
2010-05-29  9:50   ` Christoph Hellwig
2010-06-03 16:19     ` Alex Elder

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=1275075653.2302.38.camel@doink \
    --to=aelder@sgi.com \
    --cc=hch@infradead.org \
    --cc=xfs@oss.sgi.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