Commit 6de4b1ab authored by Darrick J. Wong's avatar Darrick J. Wong

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: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent 8ac5b996
...@@ -3279,6 +3279,9 @@ xfs_alloc_vextent_this_ag( ...@@ -3279,6 +3279,9 @@ xfs_alloc_vextent_this_ag(
xfs_agnumber_t minimum_agno; xfs_agnumber_t minimum_agno;
int error; int error;
ASSERT(args->pag != NULL);
ASSERT(args->pag->pag_agno == agno);
args->agno = agno; args->agno = agno;
args->agbno = 0; args->agbno = 0;
error = xfs_alloc_vextent_check_args(args, XFS_AGB_TO_FSB(mp, agno, 0), error = xfs_alloc_vextent_check_args(args, XFS_AGB_TO_FSB(mp, agno, 0),
...@@ -3394,6 +3397,8 @@ xfs_alloc_vextent_start_ag( ...@@ -3394,6 +3397,8 @@ xfs_alloc_vextent_start_ag(
bool bump_rotor = false; bool bump_rotor = false;
int error; int error;
ASSERT(args->pag == NULL);
args->agno = NULLAGNUMBER; args->agno = NULLAGNUMBER;
args->agbno = NULLAGBLOCK; args->agbno = NULLAGBLOCK;
error = xfs_alloc_vextent_check_args(args, target, &minimum_agno); error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
...@@ -3442,6 +3447,8 @@ xfs_alloc_vextent_first_ag( ...@@ -3442,6 +3447,8 @@ xfs_alloc_vextent_first_ag(
xfs_agnumber_t start_agno; xfs_agnumber_t start_agno;
int error; int error;
ASSERT(args->pag == NULL);
args->agno = NULLAGNUMBER; args->agno = NULLAGNUMBER;
args->agbno = NULLAGBLOCK; args->agbno = NULLAGBLOCK;
error = xfs_alloc_vextent_check_args(args, target, &minimum_agno); error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
...@@ -3470,6 +3477,9 @@ xfs_alloc_vextent_exact_bno( ...@@ -3470,6 +3477,9 @@ xfs_alloc_vextent_exact_bno(
xfs_agnumber_t minimum_agno; xfs_agnumber_t minimum_agno;
int error; int error;
ASSERT(args->pag != NULL);
ASSERT(args->pag->pag_agno == XFS_FSB_TO_AGNO(mp, target));
args->agno = XFS_FSB_TO_AGNO(mp, target); args->agno = XFS_FSB_TO_AGNO(mp, target);
args->agbno = XFS_FSB_TO_AGBNO(mp, target); args->agbno = XFS_FSB_TO_AGBNO(mp, target);
error = xfs_alloc_vextent_check_args(args, target, &minimum_agno); error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
...@@ -3502,6 +3512,9 @@ xfs_alloc_vextent_near_bno( ...@@ -3502,6 +3512,9 @@ xfs_alloc_vextent_near_bno(
bool needs_perag = args->pag == NULL; bool needs_perag = args->pag == NULL;
int error; int error;
if (!needs_perag)
ASSERT(args->pag->pag_agno == XFS_FSB_TO_AGNO(mp, target));
args->agno = XFS_FSB_TO_AGNO(mp, target); args->agno = XFS_FSB_TO_AGNO(mp, target);
args->agbno = XFS_FSB_TO_AGBNO(mp, target); args->agbno = XFS_FSB_TO_AGBNO(mp, target);
error = xfs_alloc_vextent_check_args(args, target, &minimum_agno); error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
......
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