All of lore.kernel.org
 help / color / mirror / Atom feed
From: Timothy Shimmin <tes@sgi.com>
To: David Chinner <dgc@sgi.com>
Cc: xfs-dev <xfs-dev@sgi.com>, xfs-oss <xfs@oss.sgi.com>
Subject: Re: [patch] Use atomics for iclog reference counting
Date: Fri, 15 Feb 2008 16:05:06 +1100	[thread overview]
Message-ID: <47B51D82.1060509@sgi.com> (raw)
In-Reply-To: <20080215042712.GY155259@sgi.com>

David Chinner wrote:
> On Fri, Feb 15, 2008 at 02:34:53PM +1100, Timothy Shimmin wrote:
>> In the 1st 2 cases of the patch:
>>> @@ -675,7 +675,7 @@ xfs_log_unmount_write(xfs_mount_t *mp)
>>>
>>>  		spin_lock(&log->l_icloglock);
>>>  		iclog = log->l_iclog;
>>> -		iclog->ic_refcnt++;
>>> +		atomic_inc(&iclog->ic_refcnt);
>>>  		spin_unlock(&log->l_icloglock);
>>>  		xlog_state_want_sync(log, iclog);
>>>  		(void) xlog_state_release_iclog(log, iclog);
>>> @@ -713,7 +713,7 @@ xfs_log_unmount_write(xfs_mount_t *mp)
>>>  		 */
>>>  		spin_lock(&log->l_icloglock);
>>>  		iclog = log->l_iclog;
>>> -		iclog->ic_refcnt++;
>>> +		atomic_inc(&iclog->ic_refcnt);
>>>  		spin_unlock(&log->l_icloglock);
>> Do we still really need to take the lock etc?
> 
> log->iclog is protected by the l_icloglock as well, 

Ah, yep :)

> so the lock
> needs to be retained to prevent races when reading and taking a
> reference to it. IOWs, the l_icloglock still synchronises increments
> and the final decrement on an iclog; we only need the atomic counter
> to enable unlocked refcount decrements when the refcount is > 1.
>  
Yep.

--Tim

      reply	other threads:[~2008-02-15  5:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-21  5:30 [patch] Use atomics for iclog reference counting David Chinner
2008-01-23  5:13 ` Timothy Shimmin
2008-02-14 23:47   ` David Chinner
2008-02-15  0:24     ` David Chinner
2008-02-15  3:34       ` Timothy Shimmin
2008-02-15  4:27         ` David Chinner
2008-02-15  5:05           ` Timothy Shimmin [this message]

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=47B51D82.1060509@sgi.com \
    --to=tes@sgi.com \
    --cc=dgc@sgi.com \
    --cc=xfs-dev@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 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.