Commit be9fb17d authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner
Browse files

xfs: add a perag to the btree cursor



Which will eventually completely replace the agno in it.

Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent 58d43a7e
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -776,7 +776,8 @@ xfs_alloc_cur_setup(
	 */
	if (!acur->cnt)
		acur->cnt = xfs_allocbt_init_cursor(args->mp, args->tp,
					args->agbp, args->agno, XFS_BTNUM_CNT);
						args->agbp, args->agno,
						args->pag, XFS_BTNUM_CNT);
	error = xfs_alloc_lookup_ge(acur->cnt, 0, args->maxlen, &i);
	if (error)
		return error;
@@ -786,10 +787,12 @@ xfs_alloc_cur_setup(
	 */
	if (!acur->bnolt)
		acur->bnolt = xfs_allocbt_init_cursor(args->mp, args->tp,
					args->agbp, args->agno, XFS_BTNUM_BNO);
						args->agbp, args->agno,
						args->pag, XFS_BTNUM_BNO);
	if (!acur->bnogt)
		acur->bnogt = xfs_allocbt_init_cursor(args->mp, args->tp,
					args->agbp, args->agno, XFS_BTNUM_BNO);
						args->agbp, args->agno,
						args->pag, XFS_BTNUM_BNO);
	return i == 1 ? 0 : -ENOSPC;
}

@@ -1217,7 +1220,7 @@ xfs_alloc_ag_vextent_exact(
	 * Allocate/initialize a cursor for the by-number freespace btree.
	 */
	bno_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp,
					  args->agno, XFS_BTNUM_BNO);
					  args->agno, args->pag, XFS_BTNUM_BNO);

	/*
	 * Lookup bno and minlen in the btree (minlen is irrelevant, really).
@@ -1277,7 +1280,7 @@ xfs_alloc_ag_vextent_exact(
	 * Allocate/initialize a cursor for the by-size btree.
	 */
	cnt_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp,
		args->agno, XFS_BTNUM_CNT);
					args->agno, args->pag, XFS_BTNUM_CNT);
	ASSERT(args->agbno + args->len <= be32_to_cpu(agf->agf_length));
	error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen, args->agbno,
				      args->len, XFSA_FIXUP_BNO_OK);
@@ -1674,7 +1677,7 @@ xfs_alloc_ag_vextent_size(
	 * Allocate and initialize a cursor for the by-size btree.
	 */
	cnt_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp,
		args->agno, XFS_BTNUM_CNT);
					args->agno, args->pag, XFS_BTNUM_CNT);
	bno_cur = NULL;
	busy = false;

@@ -1837,7 +1840,7 @@ xfs_alloc_ag_vextent_size(
	 * Allocate and initialize a cursor for the by-block tree.
	 */
	bno_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp,
		args->agno, XFS_BTNUM_BNO);
					args->agno, args->pag, XFS_BTNUM_BNO);
	if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen,
			rbno, rlen, XFSA_FIXUP_CNT_OK)))
		goto error0;
@@ -1909,7 +1912,8 @@ xfs_free_ag_extent(
	/*
	 * Allocate and initialize a cursor for the by-block btree.
	 */
	bno_cur = xfs_allocbt_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_BNO);
	bno_cur = xfs_allocbt_init_cursor(mp, tp, agbp, agno,
					NULL, XFS_BTNUM_BNO);
	/*
	 * Look for a neighboring block on the left (lower block numbers)
	 * that is contiguous with this space.
@@ -1979,7 +1983,8 @@ xfs_free_ag_extent(
	/*
	 * Now allocate and initialize a cursor for the by-size tree.
	 */
	cnt_cur = xfs_allocbt_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_CNT);
	cnt_cur = xfs_allocbt_init_cursor(mp, tp, agbp, agno,
					NULL, XFS_BTNUM_CNT);
	/*
	 * Have both left and right contiguous neighbors.
	 * Merge all three into a single free block.
@@ -2490,7 +2495,7 @@ xfs_exact_minlen_extent_available(
	int			error = 0;

	cnt_cur = xfs_allocbt_init_cursor(args->mp, args->tp, agbp,
			args->agno, XFS_BTNUM_CNT);
					args->agno, args->pag, XFS_BTNUM_CNT);
	error = xfs_alloc_lookup_ge(cnt_cur, 0, args->minlen, stat);
	if (error)
		goto out;
+10 −3
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ xfs_allocbt_dup_cursor(
{
	return xfs_allocbt_init_cursor(cur->bc_mp, cur->bc_tp,
			cur->bc_ag.agbp, cur->bc_ag.agno,
			cur->bc_btnum);
			cur->bc_ag.pag, cur->bc_btnum);
}

STATIC void
@@ -473,6 +473,7 @@ xfs_allocbt_init_common(
	struct xfs_mount	*mp,
	struct xfs_trans	*tp,
	xfs_agnumber_t		agno,
	struct xfs_perag	*pag,
	xfs_btnum_t		btnum)
{
	struct xfs_btree_cur	*cur;
@@ -497,6 +498,11 @@ xfs_allocbt_init_common(

	cur->bc_ag.agno = agno;
	cur->bc_ag.abt.active = false;
	if (pag) {
		/* take a reference for the cursor */
		atomic_inc(&pag->pag_ref);
	}
	cur->bc_ag.pag = pag;

	if (xfs_sb_version_hascrc(&mp->m_sb))
		cur->bc_flags |= XFS_BTREE_CRC_BLOCKS;
@@ -513,12 +519,13 @@ xfs_allocbt_init_cursor(
	struct xfs_trans	*tp,		/* transaction pointer */
	struct xfs_buf		*agbp,		/* buffer for agf structure */
	xfs_agnumber_t		agno,		/* allocation group number */
	struct xfs_perag	*pag,
	xfs_btnum_t		btnum)		/* btree identifier */
{
	struct xfs_agf		*agf = agbp->b_addr;
	struct xfs_btree_cur	*cur;

	cur = xfs_allocbt_init_common(mp, tp, agno, btnum);
	cur = xfs_allocbt_init_common(mp, tp, agno, pag, btnum);
	if (btnum == XFS_BTNUM_CNT)
		cur->bc_nlevels = be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]);
	else
@@ -539,7 +546,7 @@ xfs_allocbt_stage_cursor(
{
	struct xfs_btree_cur	*cur;

	cur = xfs_allocbt_init_common(mp, NULL, agno, btnum);
	cur = xfs_allocbt_init_common(mp, NULL, agno, NULL, btnum);
	xfs_btree_stage_afakeroot(cur, afake);
	return cur;
}
+2 −1
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
struct xfs_buf;
struct xfs_btree_cur;
struct xfs_mount;
struct xfs_perag;
struct xbtree_afakeroot;

/*
@@ -48,7 +49,7 @@ struct xbtree_afakeroot;

extern struct xfs_btree_cur *xfs_allocbt_init_cursor(struct xfs_mount *,
		struct xfs_trans *, struct xfs_buf *,
		xfs_agnumber_t, xfs_btnum_t);
		xfs_agnumber_t, struct xfs_perag *pag, xfs_btnum_t);
struct xfs_btree_cur *xfs_allocbt_stage_cursor(struct xfs_mount *mp,
		struct xbtree_afakeroot *afake, xfs_agnumber_t agno,
		xfs_btnum_t btnum);
+2 −0
Original line number Diff line number Diff line
@@ -377,6 +377,8 @@ xfs_btree_del_cursor(
	       XFS_FORCED_SHUTDOWN(cur->bc_mp));
	if (unlikely(cur->bc_flags & XFS_BTREE_STAGING))
		kmem_free(cur->bc_ops);
	if (!(cur->bc_flags & XFS_BTREE_LONG_PTRS) && cur->bc_ag.pag)
		xfs_perag_put(cur->bc_ag.pag);
	kmem_cache_free(xfs_btree_cur_zone, cur);
}

+10 −1
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ struct xfs_inode;
struct xfs_mount;
struct xfs_trans;
struct xfs_ifork;
struct xfs_perag;

extern kmem_zone_t	*xfs_btree_cur_zone;

@@ -180,11 +181,12 @@ union xfs_btree_irec {

/* Per-AG btree information. */
struct xfs_btree_cur_ag {
	xfs_agnumber_t		agno;
	struct xfs_perag	*pag;
	union {
		struct xfs_buf		*agbp;
		struct xbtree_afakeroot	*afake;	/* for staging cursor */
	};
	xfs_agnumber_t		agno;
	union {
		struct {
			unsigned long nr_ops;	/* # record updates */
@@ -231,6 +233,13 @@ typedef struct xfs_btree_cur
	uint8_t		bc_blocklog;	/* log2(blocksize) of btree blocks */
	xfs_btnum_t	bc_btnum;	/* identifies which btree type */
	int		bc_statoff;	/* offset of btre stats array */

	/*
	 * Short btree pointers need an agno to be able to turn the pointers
	 * into physical addresses for IO, so the btree cursor switches between
	 * bc_ino and bc_ag based on whether XFS_BTREE_LONG_PTRS is set for the
	 * cursor.
	 */
	union {
		struct xfs_btree_cur_ag	bc_ag;
		struct xfs_btree_cur_ino bc_ino;
Loading