]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: track allocation busy state in allocation cursor
authorBrian Foster <bfoster@redhat.com>
Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)
committerEric Sandeen <sandeen@redhat.com>
Thu, 16 Jan 2020 22:13:32 +0000 (17:13 -0500)
Source kernel commit: d6d3aff20377fcb38913152d53c54e0010462ccb

Extend the allocation cursor to track extent busy state for an
allocation attempt. No functional changes.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_alloc.c

index fb5f09341b2f12c865a19404344b0c9a5bddcf38..0da57063e9dbc4308cd08ebfe9d475ef6b3ce12d 100644 (file)
@@ -711,6 +711,8 @@ struct xfs_alloc_cur {
        struct xfs_btree_cur            *cnt;   /* btree cursors */
        struct xfs_btree_cur            *bnolt;
        struct xfs_btree_cur            *bnogt;
+       unsigned int                    busy_gen;/* busy state */
+       bool                            busy;
 };
 
 /*
@@ -728,6 +730,9 @@ xfs_alloc_cur_setup(
 
        ASSERT(args->alignment == 1 || args->type != XFS_ALLOCTYPE_THIS_BNO);
 
+       acur->busy = false;
+       acur->busy_gen = 0;
+
        /*
         * Perform an initial cntbt lookup to check for availability of maxlen
         * extents. If this fails, we'll return -ENOSPC to signal the caller to
@@ -1180,8 +1185,6 @@ xfs_alloc_ag_vextent_near(
        xfs_extlen_t    ltlena;         /* aligned ... */
        xfs_agblock_t   ltnew;          /* useful start bno of left side */
        xfs_extlen_t    rlen;           /* length of returned extent */
-       bool            busy;
-       unsigned        busy_gen;
 #ifdef DEBUG
        /*
         * Randomly don't execute the first algorithm.
@@ -1206,7 +1209,6 @@ restart:
        ltlen = 0;
        gtlena = 0;
        ltlena = 0;
-       busy = false;
 
        /*
         * Set up cursors and see if there are any free extents as big as
@@ -1285,8 +1287,8 @@ restart:
                        if (error)
                                goto out;
                        XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, out);
-                       busy = xfs_alloc_compute_aligned(args, ltbno, ltlen,
-                                       &ltbnoa, &ltlena, &busy_gen);
+                       acur.busy = xfs_alloc_compute_aligned(args, ltbno, ltlen,
+                                       &ltbnoa, &ltlena, &acur.busy_gen);
                        if (ltlena < args->minlen)
                                continue;
                        if (ltbnoa < args->min_agbno || ltbnoa > args->max_agbno)
@@ -1368,8 +1370,8 @@ restart:
                        if (error)
                                goto out;
                        XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, out);
-                       busy |= xfs_alloc_compute_aligned(args, ltbno, ltlen,
-                                       &ltbnoa, &ltlena, &busy_gen);
+                       acur.busy |= xfs_alloc_compute_aligned(args, ltbno,
+                                       ltlen, &ltbnoa, &ltlena, &acur.busy_gen);
                        if (ltlena >= args->minlen && ltbnoa >= args->min_agbno)
                                break;
                        error = xfs_btree_decrement(acur.bnolt, 0, &i);
@@ -1383,8 +1385,8 @@ restart:
                        if (error)
                                goto out;
                        XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, out);
-                       busy |= xfs_alloc_compute_aligned(args, gtbno, gtlen,
-                                       &gtbnoa, &gtlena, &busy_gen);
+                       acur.busy |= xfs_alloc_compute_aligned(args, gtbno,
+                                       gtlen, &gtbnoa, &gtlena, &acur.busy_gen);
                        if (gtlena >= args->minlen && gtbnoa <= args->max_agbno)
                                break;
                        error = xfs_btree_increment(acur.bnogt, 0, &i);
@@ -1444,9 +1446,10 @@ restart:
         */
        if (!xfs_alloc_cur_active(acur.bnolt) &&
            !xfs_alloc_cur_active(acur.bnogt)) {
-               if (busy) {
+               if (acur.busy) {
                        trace_xfs_alloc_near_busy(args);
-                       xfs_extent_busy_flush(args->mp, args->pag, busy_gen);
+                       xfs_extent_busy_flush(args->mp, args->pag,
+                                             acur.busy_gen);
                        goto restart;
                }
                trace_xfs_alloc_size_neither(args);