public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 2/8] XFS: Use a cursor for AIL traversal.
Date: Wed, 24 Sep 2008 13:11:38 +1000	[thread overview]
Message-ID: <20080924031137.GF5448@disturbed> (raw)
In-Reply-To: <20080919092444.GB11443@infradead.org>

On Fri, Sep 19, 2008 at 05:24:44AM -0400, Christoph Hellwig wrote:
> On Sun, Sep 14, 2008 at 12:57:51AM +1000, Dave Chinner wrote:
> > -	int			orig_gen = gen;
> > -
> >  	do {
> >  		ASSERT(lip->li_type != XFS_LI_EFI);
> > -		lip = xfs_trans_next_ail(mp, lip, &gen, NULL);
> > -		/*
> > -		 * The check will be bogus if we restart from the
> > -		 * beginning of the AIL, so ASSERT that we don't.
> > -		 * We never should since we're holding the AIL lock
> > -		 * the entire time.
> > -		 */
> > -		ASSERT(gen == orig_gen);
> > +		lip = xfs_trans_next_ail(mp, cur);
> >  	} while (lip != NULL);
> 
> 	for (tmp = lip ; tmp = xfs_rans_next_ail(mp, tmp, &gen, NULL); tmp)
> 		ASSERT(tmp->li_type != XFS_LI_EFI);
> 
> ?

Doesn't really matter. I'd prefer to avoid needing another temporary
variable, so it can become:

	for (; lip; lip = xfs_trans_next_ail(mp, cur))
		ASSERT(lip->li_type != XFS_LI_EFI);

And at that point, I can probably kill the debug wrapper function
altogether. Hmmm - will the compiler optimise out the empty loop?
(i.e. do i need #ifdef DEBUG around it?)

> > +void
> > +xfs_trans_ail_cursor_init(
> 
> A little comment describing the function would be nice.

Sure.

> > +	struct xfs_ail		*ailp,
> > +	struct xfs_ail_cursor	*cur)
> > +{
> > +	cur->item = NULL;
> > +	if (cur == &ailp->xa_cursors)
> > +		return;
> 
> What is this check for?  It mans we'll do nothing if the cursor is the
> one embedded into the ail.  But we should never do this anyway, should
> we?

It means that we don't link the embedded push cursor into the list.
That is, initialisation of the push cursor simply clears the "next
item".

> > +/*
> > + * Set the cursor to the next item, because when we look
> > + * up the cursor the current item may have been freed.
> > + */
> > +STATIC void
> > +xfs_trans_ail_cursor_set(
> > +	struct xfs_ail		*ailp,
> > +	struct xfs_ail_cursor	*cur,
> > +	struct xfs_log_item	*lip)
> > +{
> > +	if (lip)
> > +		cur->item = xfs_ail_next(ailp, lip);
> > +}
> 
> Does it make sense to have the NULL check here and not in the caller?

Doesn't really matter - this saves having to check in every place
we call the function....

> 
> > +STATIC struct xfs_log_item *
> > +xfs_trans_ail_cursor_next(
> > +	struct xfs_ail		*ailp,
> > +	struct xfs_ail_cursor	*cur)
> > +{
> > +	struct xfs_log_item	*lip = cur->item;
> > +
> > +	xfs_trans_ail_cursor_set(ailp, cur, lip);
> > +	return lip;
> > +}
> 
> I'd say kill this wrapper, it's only used once anyway.

Ah - should be at least twice - I note that the push code uses
the xfs_mount version rather than the xfs_ail version.

Also, I realised that I forgot to add the traversal restart code
into this function, so it's definitely necessary....

> > +void
> > +xfs_trans_ail_cursor_done(
> > +	struct xfs_ail		*ailp,
> > +	struct xfs_ail_cursor	*done)
> 
> A little comment describing it, please.

Done.

> > +	if (done == &ailp->xa_cursors)
> > +		return;
> > +	prev = &ailp->xa_cursors;
> > +	for (cur = prev->next; cur; prev = cur, cur = prev->next) {
> > +		if (cur == done) {
> > +			prev->next = cur->next;
> > +			break;
> > +		}
> > +	}
> > +}
> 
> Add an assert somewhere that the cursor actually is on the list?

Done.

I'll repost the entire patch series with the fixes in a while

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2008-09-24  3:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-13 14:57 [PATCH 0/8] XFS: AIL cleanup and bug fixes Dave Chinner
2008-09-13 14:57 ` [PATCH 1/8] XFS: Allocate the struct xfs_ail Dave Chinner
2008-09-19  9:15   ` Christoph Hellwig
2008-09-13 14:57 ` [PATCH 2/8] XFS: Use a cursor for AIL traversal Dave Chinner
2008-09-19  9:24   ` Christoph Hellwig
2008-09-24  3:11     ` Dave Chinner [this message]
2008-09-13 14:57 ` [PATCH 3/8] XFS: move the AIl traversal over to a consistent interface Dave Chinner
2008-09-19  9:26   ` Christoph Hellwig
2008-09-13 14:57 ` [PATCH 4/8] XFS: Allow 64 bit machines to avoid the AIL lock during flushes Dave Chinner
2008-09-19  9:26   ` Christoph Hellwig
2008-09-13 14:57 ` [PATCH 5/8] XFS: Move the AIL lock into the struct xfs_ail Dave Chinner
2008-09-19  9:26   ` Christoph Hellwig
2008-09-13 14:57 ` [PATCH 6/8] XFS: Given the log a pointer to the AIL Dave Chinner
2008-09-19  9:27   ` Christoph Hellwig
2008-09-20  6:50     ` Dave Chinner
2008-09-13 14:57 ` [PATCH 7/8] XFS: Add ail pointer into log items Dave Chinner
2008-09-19  9:28   ` Christoph Hellwig
2008-09-20  6:34     ` Dave Chinner
2008-09-13 14:57 ` [PATCH 8/8] XFS: Finish removing the mount pointer from the AIL API Dave Chinner
2008-09-19  9:28   ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2008-10-07 22:13 [PATCH 0/8] XFS: AIL cleanup and bug fixes Dave Chinner
2008-10-07 22:13 ` [PATCH 2/8] XFS: Use a cursor for AIL traversal Dave Chinner

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=20080924031137.GF5448@disturbed \
    --to=david@fromorbit.com \
    --cc=hch@infradead.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox