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 1/4] xfs: kill XBF_FS_MANAGED buffers
Date: Fri, 10 Sep 2010 13:10:04 +1000	[thread overview]
Message-ID: <20100910031004.GB24409@dastard> (raw)
In-Reply-To: <20100909013312.GB29825@infradead.org>

On Wed, Sep 08, 2010 at 09:33:13PM -0400, Christoph Hellwig wrote:
> Looks good, but a few comments below:
> 
> > +	bp = xfs_buf_get_noaddr(sector_size, mp->m_ddev_targp);
> > +
> >  	if (!bp || XFS_BUF_ISERROR(bp)) {
> 
> xfs_buf_get_noaddr will never return a buffer with an error set.

OK, will fix.

> > -	ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);
> > +
> > +	/* set up the buffer for a read IO */
> > +	xfs_buf_lock(bp);
> > +	XFS_BUF_SET_ADDR(bp, XFS_SB_DADDR);
> > +        XFS_BUF_READ(bp);
> > +        XFS_BUF_BUSY(bp);
> 
> Various indentation problems.

I'll fix all these by putting the uncached read function factoring
into an initial patch.

> > +	/* grab a reference for caching the buffer */
> > +        XFS_BUF_HOLD(bp);
> >  	mp->m_sb_bp = bp;
> > +
> >  	xfs_buf_relse(bp);
> 
> Grabbing the reference just to drop it three lines later is rather
> pointless, just remove both.

Except that xfs_buf_relse(bp) also unlocks bp. maybe I coul djust
make it do an explicit unlock....

> >  	ASSERT(XFS_BUF_VALUSEMA(bp) > 0);
> 
> Given that we took the lock a few lines above this one also feels rather
> poinless.

That's checking the buffer is unlocked, which could be removed if
there is an explicit unlock call. I'll do that.

> 
> > +fail:
> > +	if (bp)
> >  		xfs_buf_relse(bp);
> > -	}
> >  	return error;
> 
> I'd rather see this split into a fail_buf_relese label that puts the
> buffer, and a fail label that just returns the error.
> 
> >  	 * when we call xfs_buf_relse().
> >  	 */
> >  	bp = xfs_getsb(mp, 0);
> > -	XFS_BUF_UNMANAGE(bp);
> > -	xfs_buf_relse(bp);
> >  	mp->m_sb_bp = NULL;
> > +
> > +	/*
> > +	 * need to release the buffer twice to free it because we hold an extra
> > +	 * reference count on it.
> > +	 */
> > +	xfs_buf_relse(bp);
> > +	xfs_buf_relse(bp);
> 
> I'd rather rewrite xfs_freesb to not use xfs_getsb and thus avoid taking
> the superflous reference:
> 
> void
> xfs_freesb(
> 	struct xfs_mount	*mp);
> 
> 	struct xfs_buf		*bp = mp->m_sb_bp;
> 
> 	mp->m_sb_bp = NULL;
> 	if (xfs_buf_cond_lock(bp)
> 		BUG();
> 	xfs_buf_relse(bp);
> }

Yeah, that's better. I'll do that.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-08 15:12 [RFC] [PATCH 0/4] Replace buffer cache hash with rbtrees Dave Chinner
2010-09-08 15:12 ` [PATCH 1/4] xfs: kill XBF_FS_MANAGED buffers Dave Chinner
2010-09-09  1:33   ` Christoph Hellwig
2010-09-10  3:10     ` Dave Chinner [this message]
2010-09-10 21:17   ` Alex Elder
2010-09-08 15:12 ` [PATCH 2/4] xfs: use unhashed buffers for size checks Dave Chinner
2010-09-09  1:38   ` Christoph Hellwig
2010-09-10  3:14     ` Dave Chinner
2010-09-10 21:33   ` Alex Elder
2010-09-08 15:12 ` [PATCH 3/4] xfs: remove buftarg hash for external devices Dave Chinner
2010-09-09  1:39   ` Christoph Hellwig
2010-09-08 15:12 ` [PATCH 4/4] xfs: convert buffer cache hash to rbtree Dave Chinner
2010-09-09  1:51   ` Christoph Hellwig
2010-09-10  3:22     ` Dave Chinner
2010-09-13 16:59     ` Alex Elder
2010-09-13 16:53   ` Alex Elder
2010-09-14  7:13     ` 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=20100910031004.GB24409@dastard \
    --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