Commit 692b6cdd authored by Dave Chinner's avatar Dave Chinner
Browse files

xfs: t_firstblock is tracking AGs not blocks



The tp->t_firstblock field is now raelly tracking the highest AG we
have locked, not the block number of the highest allocation we've
made. It's purpose is to prevent AGF locking deadlocks, so rename it
to "highest AG" and simplify the implementation to just track the
agno rather than a fsbno.

Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarAllison Henderson <allison.henderson@oracle.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent 36b6ad2d
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -3169,8 +3169,8 @@ xfs_alloc_vextent(
	mp = args->mp;
	type = args->otype = args->type;
	args->agbno = NULLAGBLOCK;
	if (args->tp->t_firstblock != NULLFSBLOCK)
		minimum_agno = XFS_FSB_TO_AGNO(mp, args->tp->t_firstblock);
	if (args->tp->t_highest_agno != NULLAGNUMBER)
		minimum_agno = args->tp->t_highest_agno;
	/*
	 * Just fix this up, for the case where the last a.g. is shorter
	 * (or there's only one a.g.) and the caller couldn't easily figure
@@ -3375,11 +3375,9 @@ xfs_alloc_vextent(
	 * deadlocks.
	 */
	if (args->agbp &&
	    (args->tp->t_firstblock == NULLFSBLOCK ||
	     args->pag->pag_agno > minimum_agno)) {
		args->tp->t_firstblock = XFS_AGB_TO_FSB(mp,
					args->pag->pag_agno, 0);
	}
	    (args->tp->t_highest_agno == NULLAGNUMBER ||
	     args->pag->pag_agno > minimum_agno))
		args->tp->t_highest_agno = args->pag->pag_agno;
	xfs_perag_put(args->pag);
	return 0;
error0:
+2 −2
Original line number Diff line number Diff line
@@ -4192,7 +4192,7 @@ xfs_bmapi_minleft(
{
	struct xfs_ifork	*ifp = xfs_ifork_ptr(ip, fork);

	if (tp && tp->t_firstblock != NULLFSBLOCK)
	if (tp && tp->t_highest_agno != NULLAGNUMBER)
		return 0;
	if (ifp->if_format != XFS_DINODE_FMT_BTREE)
		return 1;
@@ -6079,7 +6079,7 @@ xfs_bmap_finish_one(
	struct xfs_bmbt_irec		*bmap = &bi->bi_bmap;
	int				error = 0;

	ASSERT(tp->t_firstblock == NULLFSBLOCK);
	ASSERT(tp->t_highest_agno == NULLAGNUMBER);

	trace_xfs_bmap_deferred(tp->t_mountp,
			XFS_FSB_TO_AGNO(tp->t_mountp, bmap->br_startblock),
+3 −3
Original line number Diff line number Diff line
@@ -184,11 +184,11 @@ xfs_bmbt_update_cursor(
	struct xfs_btree_cur	*src,
	struct xfs_btree_cur	*dst)
{
	ASSERT((dst->bc_tp->t_firstblock != NULLFSBLOCK) ||
	ASSERT((dst->bc_tp->t_highest_agno != NULLAGNUMBER) ||
	       (dst->bc_ino.ip->i_diflags & XFS_DIFLAG_REALTIME));

	dst->bc_ino.allocated += src->bc_ino.allocated;
	dst->bc_tp->t_firstblock = src->bc_tp->t_firstblock;
	dst->bc_tp->t_highest_agno = src->bc_tp->t_highest_agno;

	src->bc_ino.allocated = 0;
}
@@ -218,7 +218,7 @@ xfs_bmbt_alloc_block(
	 * we have to ensure that we attempt to locate the entire set of bmbt
	 * allocations in the same AG, as xfs_bmapi_write() would have reserved.
	 */
	if (cur->bc_tp->t_firstblock == NULLFSBLOCK)
	if (cur->bc_tp->t_highest_agno == NULLAGNUMBER)
		args.minleft = xfs_bmapi_minleft(cur->bc_tp, cur->bc_ino.ip,
					cur->bc_ino.whichfork);

+1 −1
Original line number Diff line number Diff line
@@ -2943,7 +2943,7 @@ xfs_btree_split(
	DECLARE_COMPLETION_ONSTACK(done);

	if (cur->bc_btnum != XFS_BTNUM_BMAP ||
	    cur->bc_tp->t_firstblock == NULLFSBLOCK)
	    cur->bc_tp->t_highest_agno == NULLAGNUMBER)
		return __xfs_btree_split(cur, level, ptrp, key, curp, stat);

	args.cur = cur;
+1 −1
Original line number Diff line number Diff line
@@ -1410,7 +1410,7 @@ xfs_swap_extent_rmap(

		/* Unmap the old blocks in the source file. */
		while (tirec.br_blockcount) {
			ASSERT(tp->t_firstblock == NULLFSBLOCK);
			ASSERT(tp->t_highest_agno == NULLAGNUMBER);
			trace_xfs_swap_extent_rmap_remap_piece(tip, &tirec);

			/* Read extent from the source file */
Loading