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?