From: Dave Chinner Date: Tue, 9 May 2023 09:29:40 +0000 (+0200) Subject: xfs: t_firstblock is tracking AGs not blocks X-Git-Tag: v6.3.0~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9cdecd7e7ab388c811073946795a48ed329f2312;p=thirdparty%2Fxfsprogs-dev.git xfs: t_firstblock is tracking AGs not blocks Source kernel commit: 692b6cddeb65a5170c1e63d25b1ffb7822e80f7d 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: Dave Chinner Reviewed-by: Allison Henderson Reviewed-by: Darrick J. Wong Signed-off-by: Carlos Maiolino --- diff --git a/include/xfs_trans.h b/include/xfs_trans.h index 690759ece..6627a83f3 100644 --- a/include/xfs_trans.h +++ b/include/xfs_trans.h @@ -66,7 +66,7 @@ typedef struct xfs_trans { unsigned int t_rtx_res; /* # of rt extents resvd */ unsigned int t_rtx_res_used; /* # of resvd rt extents used */ unsigned int t_flags; /* misc flags */ - xfs_fsblock_t t_firstblock; /* first block allocated */ + xfs_agnumber_t t_highest_agno; /* highest AGF locked */ struct xfs_mount *t_mountp; /* ptr to fs mount struct */ struct xfs_dquot_acct *t_dqinfo; /* acctg info for dquots */ long t_icount_delta; /* superblock icount change */ diff --git a/libxfs/trans.c b/libxfs/trans.c index 50d9c23de..553f9471c 100644 --- a/libxfs/trans.c +++ b/libxfs/trans.c @@ -149,7 +149,7 @@ xfs_trans_dup( ntp->t_mountp = tp->t_mountp; INIT_LIST_HEAD(&ntp->t_items); INIT_LIST_HEAD(&ntp->t_dfops); - ntp->t_firstblock = NULLFSBLOCK; + ntp->t_highest_agno = NULLAGNUMBER; ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); @@ -263,7 +263,7 @@ libxfs_trans_alloc( tp->t_mountp = mp; INIT_LIST_HEAD(&tp->t_items); INIT_LIST_HEAD(&tp->t_dfops); - tp->t_firstblock = NULLFSBLOCK; + tp->t_highest_agno = NULLAGNUMBER; error = xfs_trans_reserve(tp, resp, blocks, rtextents); if (error) { diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index 27dfe768f..82449ba97 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -3165,8 +3165,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 @@ -3371,11 +3371,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: diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index bb3a66dee..7ca1ff15b 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -4185,7 +4185,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; @@ -6072,7 +6072,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), diff --git a/libxfs/xfs_bmap_btree.c b/libxfs/xfs_bmap_btree.c index 1083cd814..076c2066a 100644 --- a/libxfs/xfs_bmap_btree.c +++ b/libxfs/xfs_bmap_btree.c @@ -182,11 +182,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; } @@ -216,7 +216,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); diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index d6d4ca863..87ddff58d 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -2940,7 +2940,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;