xfs
[Top] [All Lists]

Re: [PATCH 10/14] xfs: convert grant head manipulations to lockless algo

To: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Subject: Re: [PATCH 10/14] xfs: convert grant head manipulations to lockless algorithm
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Thu, 2 Dec 2010 13:11:30 +1100
Cc: xfs@xxxxxxxxxxx
In-reply-to: <20101201131513.GB22455@xxxxxxxxxxxxx>
References: <1290994712-21376-1-git-send-email-david@xxxxxxxxxxxxx> <1290994712-21376-11-git-send-email-david@xxxxxxxxxxxxx> <20101201131513.GB22455@xxxxxxxxxxxxx>
User-agent: Mutt/1.5.20 (2009-06-14)
On Wed, Dec 01, 2010 at 08:15:13AM -0500, Christoph Hellwig wrote:
> On Mon, Nov 29, 2010 at 12:38:28PM +1100, Dave Chinner wrote:
> > From: Dave Chinner <dchinner@xxxxxxxxxx>
> > 
> > The only thing that the grant lock remains to protect is the grant head
> > manipulations when adding or removing space from the log. These calculations
> > are already based on atomic variables, so we can already update them safely
> > without locks. However, the grant head manpulations require atomic 
> > multi-step
> > calculations to be executed, which the algorithms currently don't allow.
> > 
> > To make these multi-step calculations atomic, convert the algorithms to
> > compare-and-exchange loops on the atomic variables. That is, we sample the 
> > old
> > value, perform the calculation and use atomic64_cmpxchg() to attempt to 
> > update
> > the head with the new value. If the head has not changed since we sampled 
> > it,
> > it will succeed and we are done. Otherwise, we rerun the calculation again 
> > from
> > a new sample of the head.
> > 
> > This allows us to remove the grant lock from around all the grant head space
> > manipulations, and that effectively removes the grant lock from the log
> > completely.
> > 
> > Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
....
> > @@ -3478,11 +3485,18 @@ xlog_verify_dest_ptr(
> >             xlog_panic("xlog_verify_dest_ptr: invalid ptr");
> >  }
> >  
> > +/*
> > + * XXX: because we cannot atomically sample both the reserve and write 
> > heads,
> > + * we cannot verify them reliably as they may be sampled in the middle of
> > + * racing modifications. Hence just taking snapshots of the heads can give 
> > an
> > + * incorrect view of the state of log. Hence just disable this check for 
> > now.
> > + */
> >  STATIC void
> >  xlog_verify_grant_head(
> 
> I can't see any way to keep this check with the atomic reserve/write
> heads, so we might as well remove it entirely.

Ok, will do.

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

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