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

xfs: factor out tree fixup logic into helper

Lift the btree fixup path into a helper function.
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 0e26d5ca
...@@ -890,6 +890,36 @@ xfs_alloc_cur_check( ...@@ -890,6 +890,36 @@ xfs_alloc_cur_check(
return 0; return 0;
} }
/*
* Complete an allocation of a candidate extent. Remove the extent from both
* trees and update the args structure.
*/
STATIC int
xfs_alloc_cur_finish(
struct xfs_alloc_arg *args,
struct xfs_alloc_cur *acur)
{
int error;
ASSERT(acur->cnt && acur->bnolt);
ASSERT(acur->bno >= acur->rec_bno);
ASSERT(acur->bno + acur->len <= acur->rec_bno + acur->rec_len);
ASSERT(acur->rec_bno + acur->rec_len <=
be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
error = xfs_alloc_fixup_trees(acur->cnt, acur->bnolt, acur->rec_bno,
acur->rec_len, acur->bno, acur->len, 0);
if (error)
return error;
args->agbno = acur->bno;
args->len = acur->len;
args->wasfromfl = 0;
trace_xfs_alloc_cur(args);
return 0;
}
/* /*
* Deal with the case where only small freespaces remain. Either return the * Deal with the case where only small freespaces remain. Either return the
* contents of the last freespace record, or allocate space from the freelist if * contents of the last freespace record, or allocate space from the freelist if
...@@ -1359,7 +1389,6 @@ xfs_alloc_ag_vextent_near( ...@@ -1359,7 +1389,6 @@ xfs_alloc_ag_vextent_near(
} else if (error) { } else if (error) {
goto out; goto out;
} }
args->wasfromfl = 0;
/* /*
* First algorithm. * First algorithm.
...@@ -1440,15 +1469,8 @@ xfs_alloc_ag_vextent_near( ...@@ -1440,15 +1469,8 @@ xfs_alloc_ag_vextent_near(
} }
alloc: alloc:
args->agbno = acur.bno; /* fix up btrees on a successful allocation */
args->len = acur.len; error = xfs_alloc_cur_finish(args, &acur);
ASSERT(acur.bno >= acur.rec_bno);
ASSERT(acur.bno + acur.len <= acur.rec_bno + acur.rec_len);
ASSERT(acur.rec_bno + acur.rec_len <=
be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
error = xfs_alloc_fixup_trees(acur.cnt, acur.bnolt, acur.rec_bno,
acur.rec_len, acur.bno, acur.len, 0);
out: out:
xfs_alloc_cur_close(&acur, error); xfs_alloc_cur_close(&acur, error);
......
...@@ -1577,6 +1577,7 @@ DEFINE_ALLOC_EVENT(xfs_alloc_exact_notfound); ...@@ -1577,6 +1577,7 @@ DEFINE_ALLOC_EVENT(xfs_alloc_exact_notfound);
DEFINE_ALLOC_EVENT(xfs_alloc_exact_error); DEFINE_ALLOC_EVENT(xfs_alloc_exact_error);
DEFINE_ALLOC_EVENT(xfs_alloc_near_nominleft); DEFINE_ALLOC_EVENT(xfs_alloc_near_nominleft);
DEFINE_ALLOC_EVENT(xfs_alloc_near_first); DEFINE_ALLOC_EVENT(xfs_alloc_near_first);
DEFINE_ALLOC_EVENT(xfs_alloc_cur);
DEFINE_ALLOC_EVENT(xfs_alloc_cur_right); DEFINE_ALLOC_EVENT(xfs_alloc_cur_right);
DEFINE_ALLOC_EVENT(xfs_alloc_cur_left); DEFINE_ALLOC_EVENT(xfs_alloc_cur_left);
DEFINE_ALLOC_EVENT(xfs_alloc_near_error); DEFINE_ALLOC_EVENT(xfs_alloc_near_error);
......
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