xfs
[Top] [All Lists]

Re: [patch] Use atomics for iclog reference counting

To: David Chinner <dgc@xxxxxxx>
Subject: Re: [patch] Use atomics for iclog reference counting
From: Timothy Shimmin <tes@xxxxxxx>
Date: Fri, 15 Feb 2008 16:05:06 +1100
Cc: xfs-dev <xfs-dev@xxxxxxx>, xfs-oss <xfs@xxxxxxxxxxx>
In-reply-to: <20080215042712.GY155259@xxxxxxx>
References: <20080121053021.GH155259@xxxxxxx> <4796CCF5.8010509@xxxxxxx> <20080214234758.GP155259@xxxxxxx> <20080215002429.GT155259@xxxxxxx> <47B5085D.30409@xxxxxxx> <20080215042712.GY155259@xxxxxxx>
Sender: xfs-bounce@xxxxxxxxxxx
User-agent: Thunderbird 2.0.0.9 (Macintosh/20071031)
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



<Prev in Thread] Current Thread [Next in Thread>