Skip to content

Commit 6de4b1a

Browse files
author
Darrick J. Wong
committed
xfs: try to idiot-proof the allocators
In porting his development branch to 6.3-rc1, yours truly has repeatedly screwed up the args->pag being fed to the xfs_alloc_vextent* functions. Add some debugging assertions to test the preconditions required of the callers. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]>
1 parent 8ac5b99 commit 6de4b1a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

fs/xfs/libxfs/xfs_alloc.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3279,6 +3279,9 @@ xfs_alloc_vextent_this_ag(
32793279
xfs_agnumber_t minimum_agno;
32803280
int error;
32813281

3282+
ASSERT(args->pag != NULL);
3283+
ASSERT(args->pag->pag_agno == agno);
3284+
32823285
args->agno = agno;
32833286
args->agbno = 0;
32843287
error = xfs_alloc_vextent_check_args(args, XFS_AGB_TO_FSB(mp, agno, 0),
@@ -3394,6 +3397,8 @@ xfs_alloc_vextent_start_ag(
33943397
bool bump_rotor = false;
33953398
int error;
33963399

3400+
ASSERT(args->pag == NULL);
3401+
33973402
args->agno = NULLAGNUMBER;
33983403
args->agbno = NULLAGBLOCK;
33993404
error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
@@ -3442,6 +3447,8 @@ xfs_alloc_vextent_first_ag(
34423447
xfs_agnumber_t start_agno;
34433448
int error;
34443449

3450+
ASSERT(args->pag == NULL);
3451+
34453452
args->agno = NULLAGNUMBER;
34463453
args->agbno = NULLAGBLOCK;
34473454
error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
@@ -3470,6 +3477,9 @@ xfs_alloc_vextent_exact_bno(
34703477
xfs_agnumber_t minimum_agno;
34713478
int error;
34723479

3480+
ASSERT(args->pag != NULL);
3481+
ASSERT(args->pag->pag_agno == XFS_FSB_TO_AGNO(mp, target));
3482+
34733483
args->agno = XFS_FSB_TO_AGNO(mp, target);
34743484
args->agbno = XFS_FSB_TO_AGBNO(mp, target);
34753485
error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
@@ -3502,6 +3512,9 @@ xfs_alloc_vextent_near_bno(
35023512
bool needs_perag = args->pag == NULL;
35033513
int error;
35043514

3515+
if (!needs_perag)
3516+
ASSERT(args->pag->pag_agno == XFS_FSB_TO_AGNO(mp, target));
3517+
35053518
args->agno = XFS_FSB_TO_AGNO(mp, target);
35063519
args->agbno = XFS_FSB_TO_AGBNO(mp, target);
35073520
error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);

0 commit comments

Comments
 (0)