public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Dave Chinner <david@fromorbit.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 5/6] [XFS] Replace per-ag array with a radix tree
Date: Thu, 10 Dec 2009 18:45:47 -0500	[thread overview]
Message-ID: <20091210234547.GA28289@infradead.org> (raw)
In-Reply-To: <1259734299-20306-6-git-send-email-david@fromorbit.com>

On Wed, Dec 02, 2009 at 05:11:38PM +1100, Dave Chinner wrote:
> -		down_read(&mp->m_peraglock);
> +		pag = xfs_perag_get(mp, ag);
>  		while (blen < ap->alen) {
> -			pag = xfs_perag_get(mp, ag);
>  			if (!pag->pagf_init &&
>  			    (error = xfs_alloc_pagf_init(mp, args.tp,
>  				    ag, XFS_ALLOC_FLAG_TRYLOCK))) {
>  				xfs_perag_put(pag);
> -				up_read(&mp->m_peraglock);
>  				return error;
>  			}
>  			/*
> @@ -2801,7 +2799,6 @@ xfs_bmap_btalloc(
>  			} else
>  				notinit = 1;
>  
> -			xfs_perag_put(pag);

There's a lot of those xfs_perag_get/put moved around here.  Having
those merged into the patch that adds them would be a lot cleaner.

> +	/* allocate the new per-ag structures */
>  	if (nagcount > oagcount) {
> +		/* XXX: (dgc) We don't need the filestream flush anymore? */
>  		xfs_filestream_flush(mp);

What was the reason to have it in the first time?

> index 3727104..d6de63d 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -207,13 +207,17 @@ STATIC void
>  xfs_free_perag(
>  	xfs_mount_t	*mp)
>  {
> +	xfs_agnumber_t	agno;
> +	struct xfs_perag *pag;
> +
> +	for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) {
> +		spin_lock(&mp->m_perag_lock);
> +		pag = radix_tree_delete(&mp->m_perag_tree, agno);
> +		spin_unlock(&mp->m_perag_lock);
> +		if (!pag)
> +			continue;

Shouldn't this be a BUG_ON/ASSERT?

> +	/*
> +	 * Walk the current per-ag tree so we don't try to initialise AGs
> +	 * that already exist (growfs case). Allocate and insert all the
> +	 * AGs we don't find ready for initialisation.
> +	 */
> +	for (index = 0; index < agcount; index++) {
> +		pag = xfs_perag_get(mp, index);
> +		if (pag) {
> +			xfs_perag_put(pag);
> +			continue;
> +		}
> +		pag = kmem_zalloc(sizeof(*pag), KM_MAYFAIL);
> +		if (!pag)
> +			return -ENOMEM;
> +		if (radix_tree_preload(GFP_NOFS))
> +			return -ENOMEM;

Leaks the pag object on failure.

>  	mp->m_maxagi = xfs_initialize_perag(mp, sbp->sb_agcount);
> +	if ((int)mp->m_maxagi < 0) {
> +		cmn_err(CE_WARN, "XFS: Failed per-ag initialisation: %d",
> +				(int)mp->m_maxagi);
> +		error = mp->m_maxagi;
>
Just assign it to error first and then later to mp->m_maxagi to avoid
the cast?

>  static inline xfs_perag_t *
>  xfs_perag_get(struct xfs_mount *mp, xfs_agnumber_t agno)
>  {
> -	return &mp->m_perag[agno];
> +	struct xfs_perag	*pag;
> +
> +	spin_lock(&mp->m_perag_lock);
> +	pag = radix_tree_lookup(&mp->m_perag_tree, agno);
> +	spin_unlock(&mp->m_perag_lock);
> +	return pag;

Can't we do this as a lock-less (at least for lookups) radix tree?

And btw, I think we should still have a global sleeping lock to
serialize the whole growfs operation against other potentional growfs
callers.

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

  reply	other threads:[~2009-12-10 23:45 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-02  6:11 [PATCH 0/6] [XFS] Fix growfs deadlocks and per-AG use after free Dave Chinner
2009-12-02  6:11 ` [PATCH 1/6] [XFS] rename xfs_get_perag Dave Chinner
2009-12-10 23:15   ` Christoph Hellwig
2009-12-10 23:25     ` Dave Chinner
2009-12-02  6:11 ` [PATCH 2/6] [XFS] Don't directly reference m_perag in allocation code Dave Chinner
2009-12-10 23:18   ` Christoph Hellwig
2009-12-10 23:41     ` Dave Chinner
2009-12-02  6:11 ` [PATCH 3/6] [XFS] Convert filestreams code to use per-ag get/put routines Dave Chinner
2009-12-10 23:22   ` Christoph Hellwig
2009-12-02  6:11 ` [PATCH 4/6] [XFS] convert remaining direct references to m_perag Dave Chinner
2009-12-10 23:24   ` Christoph Hellwig
2009-12-02  6:11 ` [PATCH 5/6] [XFS] Replace per-ag array with a radix tree Dave Chinner
2009-12-10 23:45   ` Christoph Hellwig [this message]
2009-12-11  0:43     ` Dave Chinner
2009-12-11 11:43       ` Christoph Hellwig
2009-12-11 11:46       ` Christoph Hellwig
2009-12-14  4:16         ` Nick Piggin
2009-12-02  6:11 ` [PATCH 6/6] [XFS] Reference count per-ag structures Dave Chinner
2009-12-10 23:48   ` Christoph Hellwig
2009-12-11  0:50     ` Dave Chinner
  -- strict thread matches above, loose matches on Subject: below --
2009-12-14 23:11 [PATCH 0/6] XFS: Fix growfs deadlocks and per-AG use after free V2 Dave Chinner
2009-12-14 23:11 ` [PATCH 5/6] XFS: Replace per-ag array with a radix tree Dave Chinner
2009-12-15  6:11 [PATCH 0/6] XFS: Fix growfs deadlocks and per-AG use after free V3 Dave Chinner
2009-12-15  6:11 ` [PATCH 5/6] XFS: Replace per-ag array with a radix tree Dave Chinner
2009-12-23 16:02   ` Christoph Hellwig
2009-12-23 22:08   ` Alex Elder
2009-12-26  4:17     ` 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=20091210234547.GA28289@infradead.org \
    --to=hch@infradead.org \
    --cc=david@fromorbit.com \
    --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