[Top] [All Lists]

Re: [PATCH 08/12] xfs: convert l_tail_lsn to an atomic variable.

To: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Subject: Re: [PATCH 08/12] xfs: convert l_tail_lsn to an atomic variable.
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Tue, 21 Dec 2010 12:27:17 +1100
Cc: xfs@xxxxxxxxxxx
In-reply-to: <20101220120634.GA3582@xxxxxxxxxxxxx>
References: <1292215483-18224-1-git-send-email-david@xxxxxxxxxxxxx> <1292215483-18224-9-git-send-email-david@xxxxxxxxxxxxx> <20101220120634.GA3582@xxxxxxxxxxxxx>
User-agent: Mutt/1.5.20 (2009-06-14)
On Mon, Dec 20, 2010 at 07:06:34AM -0500, Christoph Hellwig wrote:
> On Mon, Dec 13, 2010 at 03:44:39PM +1100, Dave Chinner wrote:
> > From: Dave Chinner <dchinner@xxxxxxxxxx>
> > 
> > log->l_tail_lsn is currently protected by the log grant lock. The
> > lock is only needed for serialising readers against writers, so we
> > don't really need the lock if we make the l_tail_lsn variable an
> > atomic. Converting the l_tail_lsn variable to an atomic64_t means we
> > can start to peel back the grant lock from various operations.
> > 
> > Also, provide functions to safely crack an atomic LSN variable into
> > it's component pieces and to recombined the components into an
> > atomic variable. Use them where appropriate.
> > 
> > This also removes the need for explicitly holding a spinlock to read
> > the l_tail_lsn on 32 bit platforms.
> I know I suggested this, but I think the atomic read of l_tail_lsn
> in xlog_space_left might be problemetic for the call from
> xlog_grant_push_ail, where we read it twice now.  Maybe split
> xlog_space_left into a __xlog_space_left that gets the already cracked
> values, and xlog_space_left as a wrapper around it?

I'd convinced myself that it wouldn't be a problem. That is,
once we have a value for the tail_lsn in xlog_grant_push_ail(), the
threshold that we will push to is effectively fixed. The only thing
that will change is the amount of log space currently available,
which can only increase if the tail moves.

Hence we'll either get:

        a) not enough log space and have to push, in which case the
           value of the tail lsn seen in xlog_space_left() is
           irrelevant to the threshold lsn we calculate, or

        b) we'll have enough log space and not need to push in which
           case we don't need to use the tail_lsn at all because we
           don't need to push.

So it seems to me that the double sample of the tail_lsn doesn't
matter at all for this code. Is there a hole in my logic here?


Dave Chinner

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