public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Timothy Shimmin <tes@sgi.com>, Eric Sandeen <sandeen@sandeen.net>,
	markgw@sgi.com, xfs-oss <xfs@oss.sgi.com>
Subject: Re: deadlocked xfs
Date: Fri, 11 Jul 2008 00:17:36 -0400	[thread overview]
Message-ID: <20080711041736.GA29688@infradead.org> (raw)
In-Reply-To: <20080711040447.GC11558@disturbed>

On Fri, Jul 11, 2008 at 02:04:47PM +1000, Dave Chinner wrote:
>  		xlog_state_switch_iclogs(log, iclog, iclog->ic_size);
>  
> -		/* If I'm the only one writing to this iclog, sync it to disk */
> -		if (atomic_read(&iclog->ic_refcnt) == 1) {
> +		/*
> +		 * If I'm the only one writing to this iclog, sync it to disk.
> +		 * We need to do an atomic compare and decrement here to avoid
> +		 * racing with concurrent atomic_dec_and_lock() calls in
> +		 * xlog_state_release_iclog() when there is more than one
> +		 * reference to the iclog.
> +		 */
> +		if (atomic_add_unless(&iclog->ic_refcnt, -1, 1)) {
>  			spin_unlock(&log->l_icloglock);
> -			if ((error = xlog_state_release_iclog(log, iclog)))
> +			error = xlog_state_release_iclog(log, iclog);
> +			if (error)
>  				return error;
>  		} else {
> -			atomic_dec(&iclog->ic_refcnt);
>  			spin_unlock(&log->l_icloglock);
>  		}
>  		goto restart;

Independent ofwether it actually fixes the bug (which I think it will)
this looks good.  Doing anything with the return value from atomic_read
except for printing it is most likely bogus, and this one clearly is.

  parent reply	other threads:[~2008-07-11  4:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-11  2:33 deadlocked xfs Eric Sandeen
2008-07-11  2:48 ` Mark Goodwin
2008-07-11  2:56   ` Eric Sandeen
2008-07-11  3:21   ` Timothy Shimmin
2008-07-11  4:04     ` Dave Chinner
2008-07-11  4:10       ` Eric Sandeen
2008-07-11  4:13         ` Timothy Shimmin
2008-07-11  4:18           ` Eric Sandeen
2008-07-11  4:26             ` Eric Sandeen
2008-07-11  4:27             ` Dave Chinner
2008-07-11  4:17       ` Christoph Hellwig [this message]
2008-07-11  4:44       ` Timothy Shimmin
2008-07-11  3:22   ` Dave Chinner
2008-07-11  3:50     ` Mark Goodwin
2008-07-11  4:02       ` Eric Sandeen
2008-07-11  4:05       ` Dave Chinner
2008-07-11  4:08       ` Timothy Shimmin

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=20080711041736.GA29688@infradead.org \
    --to=hch@infradead.org \
    --cc=markgw@sgi.com \
    --cc=sandeen@sandeen.net \
    --cc=tes@sgi.com \
    --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