summaryrefslogtreecommitdiff
path: root/fs/xfs/libxfs/xfs_alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/libxfs/xfs_alloc.c')
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c33
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);