]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: t_firstblock is tracking AGs not blocks
authorDave Chinner <dchinner@redhat.com>
Fri, 17 Feb 2023 02:31:45 +0000 (18:31 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 6 Apr 2023 00:05:54 +0000 (17:05 -0700)
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 <dchinner@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
include/xfs_trans.h
libxfs/trans.c
libxfs/xfs_alloc.c
libxfs/xfs_bmap.c
libxfs/xfs_bmap_btree.c
libxfs/xfs_btree.c

index 690759ece3af79b2599636dc50be5bf4fd882c78..6627a83f31fc99c4e9d93ab00c428bd51ade5424 100644 (file)
@@ -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 */
index 50d9c23de3e22d370f0a2c0ef19a37c71fd5a18d..553f9471cd7f5cc2bfb17c63d9c84e187053bd7c 100644 (file)
@@ -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) {
index 27dfe768f6d6edc4a0f12f98df590bf974a01bb1..82449ba979b807a4715c17214cd3eadee44c21dc 100644 (file)
@@ -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:
index bb3a66dee3fa2276572d2ee248ceae2c7c52c11d..7ca1ff15b63d92e3a31fc65f23c419c3552a21de 100644 (file)
@@ -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),
index 1083cd814e12e7c91d65325e4121369cb7a586da..076c2066a568822ddff77e686e1c32af0b37f8df 100644 (file)
@@ -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);
 
index d6d4ca86394a35c788c5d0ded8c83ee9f033da39..87ddff58df0b7778d0a351517c01aba4e6d624d0 100644 (file)
@@ -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;