diff options
author | Dave Chinner <dchinner@redhat.com> | 2023-02-12 23:14:53 +0100 |
---|---|---|
committer | Dave Chinner <dchinner@redhat.com> | 2023-02-12 23:14:53 +0100 |
commit | 319c9e874ac8721acdb6583e3459ef595e5ed0a6 (patch) | |
tree | 20e015829d34c39a52f7cb3618249ce040fa180e /fs/xfs/libxfs/xfs_alloc.c | |
parent | xfs: factor xfs_bmap_btalloc() (diff) | |
download | linux-319c9e874ac8721acdb6583e3459ef595e5ed0a6.tar.xz linux-319c9e874ac8721acdb6583e3459ef595e5ed0a6.zip |
xfs: use xfs_alloc_vextent_first_ag() where appropriate
Change obvious callers of single AG allocation to use
xfs_alloc_vextent_first_ag(). This gets rid of
XFS_ALLOCTYPE_FIRST_AG as the type used within
xfs_alloc_vextent_first_ag() during iteration is _THIS_AG. Hence we
can remove the setting of args->type from all the callers of
_first_ag() and remove the alloctype.
While doing this, pass the allocation target fsb as a parameter
rather than encoding it in args->fsbno. This starts the process
of making args->fsbno an output only variable rather than
input/output.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/xfs/libxfs/xfs_alloc.c')
-rw-r--r-- | fs/xfs/libxfs/xfs_alloc.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index 7e4452c11421..bd77e645398b 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -3183,7 +3183,8 @@ xfs_alloc_read_agf( */ static int xfs_alloc_vextent_check_args( - struct xfs_alloc_arg *args) + struct xfs_alloc_arg *args, + xfs_fsblock_t target) { struct xfs_mount *mp = args->mp; xfs_agblock_t agsize; @@ -3201,13 +3202,13 @@ xfs_alloc_vextent_check_args( args->maxlen = agsize; if (args->alignment == 0) args->alignment = 1; - ASSERT(XFS_FSB_TO_AGNO(mp, args->fsbno) < mp->m_sb.sb_agcount); - ASSERT(XFS_FSB_TO_AGBNO(mp, args->fsbno) < agsize); + ASSERT(XFS_FSB_TO_AGNO(mp, target) < mp->m_sb.sb_agcount); + ASSERT(XFS_FSB_TO_AGBNO(mp, target) < agsize); ASSERT(args->minlen <= args->maxlen); ASSERT(args->minlen <= agsize); ASSERT(args->mod < args->prod); - if (XFS_FSB_TO_AGNO(mp, args->fsbno) >= mp->m_sb.sb_agcount || - XFS_FSB_TO_AGBNO(mp, args->fsbno) >= agsize || + if (XFS_FSB_TO_AGNO(mp, target) >= mp->m_sb.sb_agcount || + XFS_FSB_TO_AGBNO(mp, target) >= agsize || args->minlen > args->maxlen || args->minlen > agsize || args->mod >= args->prod) { args->fsbno = NULLFSBLOCK; @@ -3281,7 +3282,7 @@ xfs_alloc_vextent_this_ag( if (args->tp->t_highest_agno != NULLAGNUMBER) minimum_agno = args->tp->t_highest_agno; - error = xfs_alloc_vextent_check_args(args); + error = xfs_alloc_vextent_check_args(args, args->fsbno); if (error) { if (error == -ENOSPC) return 0; @@ -3406,7 +3407,7 @@ xfs_alloc_vextent_start_ag( bool bump_rotor = false; int error; - error = xfs_alloc_vextent_check_args(args); + error = xfs_alloc_vextent_check_args(args, args->fsbno); if (error) { if (error == -ENOSPC) return 0; @@ -3444,25 +3445,29 @@ xfs_alloc_vextent_start_ag( * filesystem attempting blocking allocation. This does not wrap or try a second * pass, so will not recurse into AGs lower than indicated by fsbno. */ -static int +int xfs_alloc_vextent_first_ag( struct xfs_alloc_arg *args, - xfs_agnumber_t minimum_agno) -{ + xfs_fsblock_t target) + { struct xfs_mount *mp = args->mp; + xfs_agnumber_t minimum_agno = 0; xfs_agnumber_t start_agno; int error; - error = xfs_alloc_vextent_check_args(args); + if (args->tp->t_highest_agno != NULLAGNUMBER) + minimum_agno = args->tp->t_highest_agno; + + error = xfs_alloc_vextent_check_args(args, target); if (error) { if (error == -ENOSPC) return 0; return error; } - start_agno = max(minimum_agno, XFS_FSB_TO_AGNO(mp, args->fsbno)); - + start_agno = max(minimum_agno, XFS_FSB_TO_AGNO(mp, target)); args->type = XFS_ALLOCTYPE_THIS_AG; + args->fsbno = target; error = xfs_alloc_vextent_iterate_ags(args, minimum_agno, start_agno, 0); xfs_alloc_vextent_set_fsbno(args, minimum_agno); @@ -3495,8 +3500,6 @@ xfs_alloc_vextent( break; case XFS_ALLOCTYPE_START_BNO: return xfs_alloc_vextent_start_ag(args, minimum_agno); - case XFS_ALLOCTYPE_FIRST_AG: - return xfs_alloc_vextent_first_ag(args, minimum_agno); default: error = -EFSCORRUPTED; ASSERT(0); |