Skip to content

Commit a03f1a6

Browse files
djwongdchinner
authored andcommitted
xfs: remove OWN_AG rmap when allocating a block from the AGFL
When we're really tight on space, xfs_alloc_ag_vextent_small() can allocate a block from the AGFL and give it to the caller. Since the caller is never the AGFL-fixing method, we must remove the OWN_AG reverse mapping because it will clash with whatever rmap the caller wants to set up. This bug was discovered by running generic/299 repeatedly. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
1 parent f32866f commit a03f1a6

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
@@ -1582,6 +1582,7 @@ xfs_alloc_ag_vextent_small(
15821582
xfs_extlen_t *flenp, /* result length */
15831583
int *stat) /* status: 0-freelist, 1-normal/none */
15841584
{
1585+
struct xfs_owner_info oinfo;
15851586
int error;
15861587
xfs_agblock_t fbno;
15871588
xfs_extlen_t flen;
@@ -1624,6 +1625,18 @@ xfs_alloc_ag_vextent_small(
16241625
error0);
16251626
args->wasfromfl = 1;
16261627
trace_xfs_alloc_small_freelist(args);
1628+
1629+
/*
1630+
* If we're feeding an AGFL block to something that
1631+
* doesn't live in the free space, we need to clear
1632+
* out the OWN_AG rmap.
1633+
*/
1634+
xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_AG);
1635+
error = xfs_rmap_free(args->tp, args->agbp, args->agno,
1636+
fbno, 1, &oinfo);
1637+
if (error)
1638+
goto error0;
1639+
16271640
*stat = 0;
16281641
return 0;
16291642
}

0 commit comments

Comments
 (0)