Commit d6d3aff2 authored by Brian Foster's avatar Brian Foster Committed by Darrick J. Wong

xfs: track allocation busy state in allocation cursor

Extend the allocation cursor to track extent busy state for an
allocation attempt. No functional changes.
Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent f5e7dbea
...@@ -716,6 +716,8 @@ struct xfs_alloc_cur { ...@@ -716,6 +716,8 @@ struct xfs_alloc_cur {
struct xfs_btree_cur *cnt; /* btree cursors */ struct xfs_btree_cur *cnt; /* btree cursors */
struct xfs_btree_cur *bnolt; struct xfs_btree_cur *bnolt;
struct xfs_btree_cur *bnogt; struct xfs_btree_cur *bnogt;
unsigned int busy_gen;/* busy state */
bool busy;
}; };
/* /*
...@@ -733,6 +735,9 @@ xfs_alloc_cur_setup( ...@@ -733,6 +735,9 @@ xfs_alloc_cur_setup(
ASSERT(args->alignment == 1 || args->type != XFS_ALLOCTYPE_THIS_BNO); 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 * Perform an initial cntbt lookup to check for availability of maxlen
* extents. If this fails, we'll return -ENOSPC to signal the caller to * extents. If this fails, we'll return -ENOSPC to signal the caller to
...@@ -1185,8 +1190,6 @@ xfs_alloc_ag_vextent_near( ...@@ -1185,8 +1190,6 @@ xfs_alloc_ag_vextent_near(
xfs_extlen_t ltlena; /* aligned ... */ xfs_extlen_t ltlena; /* aligned ... */
xfs_agblock_t ltnew; /* useful start bno of left side */ xfs_agblock_t ltnew; /* useful start bno of left side */
xfs_extlen_t rlen; /* length of returned extent */ xfs_extlen_t rlen; /* length of returned extent */
bool busy;
unsigned busy_gen;
#ifdef DEBUG #ifdef DEBUG
/* /*
* Randomly don't execute the first algorithm. * Randomly don't execute the first algorithm.
...@@ -1211,7 +1214,6 @@ xfs_alloc_ag_vextent_near( ...@@ -1211,7 +1214,6 @@ xfs_alloc_ag_vextent_near(
ltlen = 0; ltlen = 0;
gtlena = 0; gtlena = 0;
ltlena = 0; ltlena = 0;
busy = false;
/* /*
* Set up cursors and see if there are any free extents as big as * Set up cursors and see if there are any free extents as big as
...@@ -1290,8 +1292,8 @@ xfs_alloc_ag_vextent_near( ...@@ -1290,8 +1292,8 @@ xfs_alloc_ag_vextent_near(
if (error) if (error)
goto out; goto out;
XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, out); XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, out);
busy = xfs_alloc_compute_aligned(args, ltbno, ltlen, acur.busy = xfs_alloc_compute_aligned(args, ltbno, ltlen,
&ltbnoa, &ltlena, &busy_gen); &ltbnoa, &ltlena, &acur.busy_gen);
if (ltlena < args->minlen) if (ltlena < args->minlen)
continue; continue;
if (ltbnoa < args->min_agbno || ltbnoa > args->max_agbno) if (ltbnoa < args->min_agbno || ltbnoa > args->max_agbno)
...@@ -1373,8 +1375,8 @@ xfs_alloc_ag_vextent_near( ...@@ -1373,8 +1375,8 @@ xfs_alloc_ag_vextent_near(
if (error) if (error)
goto out; goto out;
XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, out); XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, out);
busy |= xfs_alloc_compute_aligned(args, ltbno, ltlen, acur.busy |= xfs_alloc_compute_aligned(args, ltbno,
&ltbnoa, &ltlena, &busy_gen); ltlen, &ltbnoa, &ltlena, &acur.busy_gen);
if (ltlena >= args->minlen && ltbnoa >= args->min_agbno) if (ltlena >= args->minlen && ltbnoa >= args->min_agbno)
break; break;
error = xfs_btree_decrement(acur.bnolt, 0, &i); error = xfs_btree_decrement(acur.bnolt, 0, &i);
...@@ -1388,8 +1390,8 @@ xfs_alloc_ag_vextent_near( ...@@ -1388,8 +1390,8 @@ xfs_alloc_ag_vextent_near(
if (error) if (error)
goto out; goto out;
XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, out); XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, out);
busy |= xfs_alloc_compute_aligned(args, gtbno, gtlen, acur.busy |= xfs_alloc_compute_aligned(args, gtbno,
&gtbnoa, &gtlena, &busy_gen); gtlen, &gtbnoa, &gtlena, &acur.busy_gen);
if (gtlena >= args->minlen && gtbnoa <= args->max_agbno) if (gtlena >= args->minlen && gtbnoa <= args->max_agbno)
break; break;
error = xfs_btree_increment(acur.bnogt, 0, &i); error = xfs_btree_increment(acur.bnogt, 0, &i);
...@@ -1449,9 +1451,10 @@ xfs_alloc_ag_vextent_near( ...@@ -1449,9 +1451,10 @@ xfs_alloc_ag_vextent_near(
*/ */
if (!xfs_alloc_cur_active(acur.bnolt) && if (!xfs_alloc_cur_active(acur.bnolt) &&
!xfs_alloc_cur_active(acur.bnogt)) { !xfs_alloc_cur_active(acur.bnogt)) {
if (busy) { if (acur.busy) {
trace_xfs_alloc_near_busy(args); 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; goto restart;
} }
trace_xfs_alloc_size_neither(args); trace_xfs_alloc_size_neither(args);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment