public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: Dave Chinner <david@fromorbit.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 04/20] xfs: clean up XFS_MIN_FREELIST macros
Date: Mon, 15 Jun 2015 10:58:19 -0400	[thread overview]
Message-ID: <20150615145819.GD36091@bfoster.bfoster> (raw)
In-Reply-To: <1433311497-10245-5-git-send-email-david@fromorbit.com>

On Wed, Jun 03, 2015 at 04:04:41PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> We no longer calculate the minimum freelist size from the on-disk
> AGF, so we don't need the macros used for this. That means the
> nested macros can be cleaned up, and turn this into an actual
> function so the logic is clear and concise. This will make it much
> easier to add support for the rmap btree when the time comes.
> 
> This also gets rid of the XFS_AG_MAXLEVELS macro used by these
> freelist macros as it is simply a wrapper around a single variable.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/libxfs/xfs_alloc.c       | 22 +++++++++++++++++++---
>  fs/xfs/libxfs/xfs_alloc.h       |  2 ++
>  fs/xfs/libxfs/xfs_bmap.c        |  2 +-
>  fs/xfs/libxfs/xfs_format.h      | 13 -------------
>  fs/xfs/libxfs/xfs_trans_resv.h  |  4 ++--
>  fs/xfs/libxfs/xfs_trans_space.h |  2 +-
>  fs/xfs/xfs_filestream.c         |  2 +-
>  7 files changed, 26 insertions(+), 21 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
> index 352db46..d4aa844 100644
> --- a/fs/xfs/libxfs/xfs_alloc.c
> +++ b/fs/xfs/libxfs/xfs_alloc.c
> @@ -1870,6 +1870,23 @@ xfs_alloc_longest_free_extent(
>  	return pag->pagf_flcount > 0 || pag->pagf_longest > 0;
>  }
>  
> +unsigned int
> +xfs_alloc_min_freelist(
> +	struct xfs_mount	*mp,
> +	struct xfs_perag	*pag)
> +{
> +	unsigned int		min_free;
> +
> +	/* space needed by-bno freespace btree */
> +	min_free = min_t(unsigned int, pag->pagf_levels[XFS_BTNUM_BNOi] + 1,
> +				       mp->m_ag_maxlevels);
> +	/* space needed by-size freespace btree */
> +	min_free += min_t(unsigned int, pag->pagf_levels[XFS_BTNUM_CNTi] + 1,
> +				       mp->m_ag_maxlevels);
> +
> +	return min_free;
> +}
> +
>  /*
>   * Check if the operation we are fixing up the freelist for should go ahead or
>   * not. If we are freeing blocks, we always allow it, otherwise the allocation
> @@ -1944,7 +1961,7 @@ xfs_alloc_fix_freelist(
>  		goto out_agbp_relse;
>  	}
>  
> -	need = XFS_MIN_FREELIST_PAG(pag, mp);
> +	need = xfs_alloc_min_freelist(mp, pag);
>  	if (!xfs_alloc_space_available(args, need, flags))
>  		goto out_agbp_relse;
>  
> @@ -1963,9 +1980,8 @@ xfs_alloc_fix_freelist(
>  		}
>  	}
>  
> -
>  	/* If there isn't enough total space or single-extent, reject it. */
> -	need = XFS_MIN_FREELIST_PAG(pag, mp);
> +	need = xfs_alloc_min_freelist(mp, pag);
>  	if (!xfs_alloc_space_available(args, need, flags))
>  		goto out_agbp_relse;
>  
> diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h
> index a4d3b9a..ca1c816 100644
> --- a/fs/xfs/libxfs/xfs_alloc.h
> +++ b/fs/xfs/libxfs/xfs_alloc.h
> @@ -132,6 +132,8 @@ typedef struct xfs_alloc_arg {
>  
>  xfs_extlen_t xfs_alloc_longest_free_extent(struct xfs_mount *mp,
>  		struct xfs_perag *pag, xfs_extlen_t need);
> +unsigned int xfs_alloc_min_freelist(struct xfs_mount *mp,
> +		struct xfs_perag *pag);
>  
>  /*
>   * Compute and fill in value of m_ag_maxlevels.
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 7382cce..983a5d0 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -3522,7 +3522,7 @@ xfs_bmap_longest_free_extent(
>  	}
>  
>  	longest = xfs_alloc_longest_free_extent(mp, pag,
> -						XFS_MIN_FREELIST_PAG(pag, mp));
> +					xfs_alloc_min_freelist(mp, pag));
>  	if (*blen < longest)
>  		*blen = longest;
>  
> diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
> index 815f61b..a0ae572 100644
> --- a/fs/xfs/libxfs/xfs_format.h
> +++ b/fs/xfs/libxfs/xfs_format.h
> @@ -766,19 +766,6 @@ typedef struct xfs_agfl {
>  
>  #define XFS_AGFL_CRC_OFF	offsetof(struct xfs_agfl, agfl_crc)
>  
> -
> -#define	XFS_AG_MAXLEVELS(mp)		((mp)->m_ag_maxlevels)
> -#define	XFS_MIN_FREELIST_RAW(bl,cl,mp)	\
> -	(MIN(bl + 1, XFS_AG_MAXLEVELS(mp)) + MIN(cl + 1, XFS_AG_MAXLEVELS(mp)))
> -#define	XFS_MIN_FREELIST(a,mp)		\
> -	(XFS_MIN_FREELIST_RAW(		\
> -		be32_to_cpu((a)->agf_levels[XFS_BTNUM_BNOi]), \
> -		be32_to_cpu((a)->agf_levels[XFS_BTNUM_CNTi]), mp))
> -#define	XFS_MIN_FREELIST_PAG(pag,mp)	\
> -	(XFS_MIN_FREELIST_RAW(		\
> -		(unsigned int)(pag)->pagf_levels[XFS_BTNUM_BNOi], \
> -		(unsigned int)(pag)->pagf_levels[XFS_BTNUM_CNTi], mp))
> -
>  #define XFS_AGB_TO_FSB(mp,agno,agbno)	\
>  	(((xfs_fsblock_t)(agno) << (mp)->m_sb.sb_agblklog) | (agbno))
>  #define	XFS_FSB_TO_AGNO(mp,fsbno)	\
> diff --git a/fs/xfs/libxfs/xfs_trans_resv.h b/fs/xfs/libxfs/xfs_trans_resv.h
> index 2d5bdfc..7978150 100644
> --- a/fs/xfs/libxfs/xfs_trans_resv.h
> +++ b/fs/xfs/libxfs/xfs_trans_resv.h
> @@ -73,9 +73,9 @@ struct xfs_trans_resv {
>   * 2 trees * (2 blocks/level * max depth - 1) * block size
>   */
>  #define	XFS_ALLOCFREE_LOG_RES(mp,nx) \
> -	((nx) * (2 * XFS_FSB_TO_B((mp), 2 * XFS_AG_MAXLEVELS(mp) - 1)))
> +	((nx) * (2 * XFS_FSB_TO_B((mp), 2 * (mp)->m_ag_maxlevels - 1)))
>  #define	XFS_ALLOCFREE_LOG_COUNT(mp,nx) \
> -	((nx) * (2 * (2 * XFS_AG_MAXLEVELS(mp) - 1)))
> +	((nx) * (2 * (2 * (mp)->m_ag_maxlevels - 1)))
>  
>  /*
>   * Per-directory log reservation for any directory change.
> diff --git a/fs/xfs/libxfs/xfs_trans_space.h b/fs/xfs/libxfs/xfs_trans_space.h
> index bf9c457..41e0428 100644
> --- a/fs/xfs/libxfs/xfs_trans_space.h
> +++ b/fs/xfs/libxfs/xfs_trans_space.h
> @@ -67,7 +67,7 @@
>  #define	XFS_DIOSTRAT_SPACE_RES(mp, v)	\
>  	(XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK) + (v))
>  #define	XFS_GROWFS_SPACE_RES(mp)	\
> -	(2 * XFS_AG_MAXLEVELS(mp))
> +	(2 * (mp)->m_ag_maxlevels)
>  #define	XFS_GROWFSRT_SPACE_RES(mp,b)	\
>  	((b) + XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK))
>  #define	XFS_LINK_SPACE_RES(mp,nl)	\
> diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c
> index 9ac5eaa..c4c130f 100644
> --- a/fs/xfs/xfs_filestream.c
> +++ b/fs/xfs/xfs_filestream.c
> @@ -197,7 +197,7 @@ xfs_filestream_pick_ag(
>  		}
>  
>  		longest = xfs_alloc_longest_free_extent(mp, pag,
> -						XFS_MIN_FREELIST_PAG(pag, mp));
> +					xfs_alloc_min_freelist(mp, pag));
>  		if (((minlen && longest >= minlen) ||
>  		     (!minlen && pag->pagf_freeblks >= minfree)) &&
>  		    (!pag->pagf_metadata || !(flags & XFS_PICK_USERDATA) ||
> -- 
> 2.0.0
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

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

  reply	other threads:[~2015-06-15 14:58 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-03  6:04 [RFC PATCH 00/20] xfs: reverse mapping btree support Dave Chinner
2015-06-03  6:04 ` [PATCH 01/20] xfs: xfs_alloc_fix_freelist() can use incore perag structures Dave Chinner
2015-06-15 14:57   ` Brian Foster
2015-06-03  6:04 ` [PATCH 02/20] xfs: factor out free space extent length check Dave Chinner
2015-06-15 14:58   ` Brian Foster
2015-06-03  6:04 ` [PATCH 03/20] xfs: sanitise error handling in xfs_alloc_fix_freelist Dave Chinner
2015-06-15 14:58   ` Brian Foster
2015-06-15 21:51     ` Dave Chinner
2015-06-16 11:27       ` Brian Foster
2015-06-22  0:10         ` Dave Chinner
2015-06-03  6:04 ` [PATCH 04/20] xfs: clean up XFS_MIN_FREELIST macros Dave Chinner
2015-06-15 14:58   ` Brian Foster [this message]
2015-06-03  6:04 ` [PATCH 05/20] xfs: introduce rmap btree definitions Dave Chinner
2015-06-03  6:30   ` Darrick J. Wong
2015-06-03  6:34     ` Darrick J. Wong
2015-06-03  6:04 ` [PATCH 06/20] xfs: add rmap btree stats infrastructure Dave Chinner
2015-06-03  6:04 ` [PATCH 07/20] xfs: rmap btree add more reserved blocks Dave Chinner
2015-06-03  6:04 ` [PATCH 08/20] xfs: add owner field to extent allocation and freeing Dave Chinner
2015-06-24 19:09   ` Brian Foster
2015-06-24 21:13     ` Dave Chinner
2015-06-25 13:03       ` Brian Foster
2015-06-03  6:04 ` [PATCH 09/20] xfs: introduce rmap extent operation stubs Dave Chinner
2015-06-03  6:04 ` [PATCH 10/20] xfs: define the on-disk rmap btree format Dave Chinner
2015-06-03  6:04 ` [PATCH 11/20] xfs: add rmap btree growfs support Dave Chinner
2015-06-03  6:04 ` [PATCH 12/20] xfs: rmap btree transaction reservations Dave Chinner
2015-06-03  6:04 ` [PATCH 13/20] xfs: rmap btree requires more reserved free space Dave Chinner
2015-06-25 16:41   ` Brian Foster
2015-07-10  0:37     ` Dave Chinner
2015-06-03  6:04 ` [PATCH 14/20] xfs: add rmap btree operations Dave Chinner
2015-06-03  6:04 ` [PATCH 15/20] xfs: add an extent to the rmap btree Dave Chinner
2015-06-25 16:41   ` Brian Foster
2015-07-10  0:39     ` Dave Chinner
2015-06-03  6:04 ` [PATCH 16/20] xfs: remove an extent from " Dave Chinner
2015-06-03  6:04 ` [PATCH 17/20] xfs: add rmap btree geometry feature flag Dave Chinner
2015-06-03  6:04 ` [PATCH 18/20] xfs: add rmap btree block detection to log recovery Dave Chinner
2015-06-03  6:04 ` [PATCH 19/20] xfs: disable XFS_IOC_SWAPEXT when rmap btree is enabled Dave Chinner
2015-06-03  6:04 ` [PATCH 20/20] xfs: enable the rmap btree functionality 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=20150615145819.GD36091@bfoster.bfoster \
    --to=bfoster@redhat.com \
    --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