aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2023-05-09 11:29:52 +0200
committerCarlos Maiolino <cem@kernel.org>2023-05-10 13:47:57 +0200
commit649442d074a95ba076936c7e60de645ebda656af (patch)
tree1363e445d4cf9938ccfff52cf21252d5daf5aefb
parent0ac70e08c2e4d67da616ef1d30297e5cc675bfe9 (diff)
downloadxfsprogs-dev-649442d074a95ba076936c7e60de645ebda656af.tar.gz
xfs: factor xfs_alloc_vextent_this_ag() for _iterate_ags()
Source kernel commit: 2edf06a50f5bbe664283f3c55c480fc013221d70 The core of the per-ag iteration is effectively doing a "this ag" allocation on one AG at a time. Use the same code to implement the core "this ag" allocation in both xfs_alloc_vextent_this_ag() and xfs_alloc_vextent_iterate_ags(). This means we only call xfs_alloc_ag_vextent() from one place so we can easily collapse the call stack in future patches. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
-rw-r--r--libxfs/xfs_alloc.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c
index 490d392308..2a3b20ff7e 100644
--- a/libxfs/xfs_alloc.c
+++ b/libxfs/xfs_alloc.c
@@ -3241,6 +3241,28 @@ xfs_alloc_vextent_set_fsbno(
* Allocate within a single AG only.
*/
static int
+__xfs_alloc_vextent_this_ag(
+ struct xfs_alloc_arg *args)
+{
+ struct xfs_mount *mp = args->mp;
+ int error;
+
+ error = xfs_alloc_fix_freelist(args, 0);
+ if (error) {
+ trace_xfs_alloc_vextent_nofix(args);
+ return error;
+ }
+ if (!args->agbp) {
+ /* cannot allocate in this AG at all */
+ trace_xfs_alloc_vextent_noagbp(args);
+ args->agbno = NULLAGBLOCK;
+ return 0;
+ }
+ args->agbno = XFS_FSB_TO_AGBNO(mp, args->fsbno);
+ return xfs_alloc_ag_vextent(args);
+}
+
+static int
xfs_alloc_vextent_this_ag(
struct xfs_alloc_arg *args,
xfs_agnumber_t minimum_agno)
@@ -3263,21 +3285,9 @@ xfs_alloc_vextent_this_ag(
}
args->pag = xfs_perag_get(mp, args->agno);
- error = xfs_alloc_fix_freelist(args, 0);
- if (error) {
- trace_xfs_alloc_vextent_nofix(args);
- goto out_error;
- }
- if (!args->agbp) {
- trace_xfs_alloc_vextent_noagbp(args);
- args->fsbno = NULLFSBLOCK;
- goto out_error;
- }
- args->agbno = XFS_FSB_TO_AGBNO(mp, args->fsbno);
- error = xfs_alloc_ag_vextent(args);
+ error = __xfs_alloc_vextent_this_ag(args);
xfs_alloc_vextent_set_fsbno(args, minimum_agno);
-out_error:
xfs_perag_put(args->pag);
return error;
}
@@ -3315,24 +3325,16 @@ xfs_alloc_vextent_iterate_ags(
args->agno = start_agno;
for (;;) {
args->pag = xfs_perag_get(mp, args->agno);
- error = xfs_alloc_fix_freelist(args, flags);
+ error = __xfs_alloc_vextent_this_ag(args);
if (error) {
- trace_xfs_alloc_vextent_nofix(args);
+ args->agbno = NULLAGBLOCK;
break;
}
- /*
- * If we get a buffer back then the allocation will fly.
- */
- if (args->agbp) {
- error = xfs_alloc_ag_vextent(args);
+ if (args->agbp)
break;
- }
trace_xfs_alloc_vextent_loopfailed(args);
- /*
- * Didn't work, figure out the next iteration.
- */
if (args->agno == start_agno &&
args->otype == XFS_ALLOCTYPE_START_BNO)
args->type = XFS_ALLOCTYPE_THIS_AG;