xfs: try any AG when allocating the first btree block when reflinking
PATCH 1/1 xfs: try any AG when allocating the first btree block when reflinking
When a reflink operation causes the bmap code to allocate a btree block we're currently doing single-AG allocations due to having ->firstblock set and then try any higher AG due a little reflink quirk we've put in when adding the reflink code. But given that we do not have a minleft reservation of any kind in this AG we can still not have any space in the same or higher AG even if the file system has enough free space. To fix this use a XFS_ALLOCTYPE_FIRST_AG allocation in this fall back path instead.
[And yes, we need to redo this properly instead of piling hacks over
hacks. I'm working on that, but it's not going to be a small series. In the meantime this fixes the customer reported issue]
Also add a warning for failing allocations to make it easier to debug.
--- fs/xfs/libxfs/xfs_bmap.c | 9 +++++++-- fs/xfs/libxfs/xfs_bmap_btree.c | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +7 -2
@@ -763,8 +763,8 @@ xfs_bmap_extents_to_btree( args.type =XFS_ALLOCTYPE_START_BNO ; args.fsbno =XFS_INO_TO_FSB (mp, ip->i_ino); }else if (dfops->dop_low) { -try_another_ag: args.type =XFS_ALLOCTYPE_START_BNO ; +try_another_ag: args.fsbno = *firstblock; }else { args.type =XFS_ALLOCTYPE_NEAR_BNO ;
@@ -790,9 +790,14 @@ xfs_bmap_extents_to_btree(if (xfs_sb_version_hasreflink (&cur->bc_mp->m_sb) && args.fsbno ==NULLFSBLOCK && args.type ==XFS_ALLOCTYPE_NEAR_BNO ) { - dfops->dop_low = true; + args.type =XFS_ALLOCTYPE_FIRST_AG ; goto try_another_ag; } +if (WARN_ON_ONCE (args.fsbno ==NULLFSBLOCK )) { +xfs_iroot_realloc (ip,-1 , whichfork); +xfs_btree_del_cursor (cur,XFS_BTREE_ERROR ); +return -ENOMEM ; + }/* * Allocation can't fail, the space was reserved. */
fs/xfs/libxfs/xfs_bmap_btree.c +3 -3
@@ -447,8 +447,8 @@ xfs_bmbt_alloc_block(if (args.fsbno ==NULLFSBLOCK ) { args.fsbno =be64_to_cpu (start->l); -try_another_ag: args.type =XFS_ALLOCTYPE_START_BNO ; +try_another_ag:/* * Make sure there is sufficient room left in the AG to * complete a full tree split for an extent insert. If
@@ -488,8 +488,8 @@ xfs_bmbt_alloc_block(if (xfs_sb_version_hasreflink (&cur->bc_mp->m_sb) && args.fsbno ==NULLFSBLOCK && args.type ==XFS_ALLOCTYPE_NEAR_BNO ) { - cur->bc_private.b.dfops->dop_low = true; args.fsbno = cur->bc_private.b.firstblock; + args.type =XFS_ALLOCTYPE_FIRST_AG ; goto try_another_ag; }
@@ -506,7 +506,7 @@ xfs_bmbt_alloc_block( goto error0; cur->bc_private.b.dfops->dop_low = true; } -if (args.fsbno ==NULLFSBLOCK ) { +if (WARN_ON_ONCE (args.fsbno ==NULLFSBLOCK )) {XFS_BTREE_TRACE_CURSOR (cur,XBT_EXIT ); *stat =0 ;return 0 ;
Signature · 1 line
2.11.0
Quoted 37 lines · Christoph Hellwig
When a reflink operation causes the bmap code to allocate a btree block we're currently doing single-AG allocations due to having ->firstblock set and then try any higher AG due a little reflink quirk we've put in when adding the reflink code. But given that we do not have a minleft reservation of any kind in this AG we can still not have any space in the same or higher AG even if the file system has enough free space. To fix this use a
XFS_ALLOCTYPE_FIRST_AGallocation in this fall back path instead.[And yes, we need to redo this properly instead of piling hacks over
hacks. I'm working on that, but it's not going to be a small series. In the meantime this fixes the customer reported issue]Also add a warning for failing allocations to make it easier to debug.
Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/libxfs/xfs_bmap.c | 9 +++++++-- fs/xfs/libxfs/xfs_bmap_btree.c | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-)fs/xfs/libxfs/xfs_bmap.c +1
-1@@ -763,8 +763,8 @@ xfs_bmap_extents_to_btree( args.type =XFS_ALLOCTYPE_START_BNO ; args.fsbno =XFS_INO_TO_FSB (mp, ip->i_ino); }else if (dfops->dop_low) { -try_another_ag: args.type =XFS_ALLOCTYPE_START_BNO ; +try_another_ag: args.fsbno = *firstblock; }else { args.type =XFS_ALLOCTYPE_NEAR_BNO ;@@ -790,9 +790,14 @@ xfs_bmap_extents_to_btree( if (xfs_sb_version_hasreflink(&cur->bc_mp->m_sb) &&
fs/xfs/libxfs/xfs_bmap.c xfs_bmap_extents_to_btree( · line 799
Quoted 10 lines
fs/xfs/libxfs/xfs_bmap.c +5
-1args.fsbno == NULLFSBLOCK && args.type == XFS_ALLOCTYPE_NEAR_BNO) { - dfops->dop_low = true; + args.type =XFS_ALLOCTYPE_FIRST_AG ; goto try_another_ag; } +if (WARN_ON_ONCE (args.fsbno ==NULLFSBLOCK )) { +xfs_iroot_realloc (ip,-1 , whichfork); +xfs_btree_del_cursor (cur,XFS_BTREE_ERROR ); +return -ENOMEM ;
ENOSPC?
fs/xfs/libxfs/xfs_bmap.c xfs_bmap_extents_to_btree( · line 803
Quoted 4 lines
fs/xfs/libxfs/xfs_bmap.c +1
-0+ }/* * Allocation can't fail, the space was reserved. */
Can we get rid of the ASSERT(args.fsbno != NULLFSBLOCK); just below here now that we jump out above?
Conceptually I guess it's ok for now until we separate out the uses of *firstblock to stay ahead of locking rules vs. *firstblock to remap things. Hmm, I'll try to make a first stab at that today.
--D
Quoted 40 lines
fs/xfs/libxfs/xfs_bmap_btree.c +3
-3@@ -447,8 +447,8 @@ xfs_bmbt_alloc_block(if (args.fsbno ==NULLFSBLOCK ) { args.fsbno =be64_to_cpu (start->l); -try_another_ag: args.type =XFS_ALLOCTYPE_START_BNO ; +try_another_ag:/* * Make sure there is sufficient room left in the AG to * complete a full tree split for an extent insert. If @@ -488,8 +488,8 @@ xfs_bmbt_alloc_block(if (xfs_sb_version_hasreflink (&cur->bc_mp->m_sb) && args.fsbno ==NULLFSBLOCK && args.type ==XFS_ALLOCTYPE_NEAR_BNO ) { - cur->bc_private.b.dfops->dop_low = true; args.fsbno = cur->bc_private.b.firstblock; + args.type =XFS_ALLOCTYPE_FIRST_AG ; goto try_another_ag; }@@ -506,7 +506,7 @@ xfs_bmbt_alloc_block( goto error0; cur->bc_private.b.dfops->dop_low = true; } -if (args.fsbno ==NULLFSBLOCK ) { +if (WARN_ON_ONCE (args.fsbno ==NULLFSBLOCK )) {XFS_BTREE_TRACE_CURSOR (cur,XBT_EXIT ); *stat =0 ;return 0 ;Signature · 6 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Darrick J. Wong
fs/xfs/libxfs/xfs_bmap.c xfs_bmap_extents_to_btree( · line 799
Quoted 4 lines
fs/xfs/libxfs/xfs_bmap.c +4
-0+if (WARN_ON_ONCE (args.fsbno ==NULLFSBLOCK )) { +xfs_iroot_realloc (ip,-1 , whichfork); +xfs_btree_del_cursor (cur,XFS_BTREE_ERROR ); +return -ENOMEM ;ENOSPC?
Yeah.
Quoted 7 lines
fs/xfs/libxfs/xfs_bmap.c xfs_bmap_extents_to_btree( · line 803
Quoted 4 lines
fs/xfs/libxfs/xfs_bmap.c +1
-0+ }/* * Allocation can't fail, the space was reserved. */ Can we get rid of the ASSERT(args.fsbno != NULLFSBLOCK); just below here now that we jump out above?
Sure.
Quoted 4 lines
Conceptually I guess it's ok for now until we separate out the uses of *firstblock to stay ahead of locking rules vs. *firstblock to remap things. Hmm, I'll try to make a first stab at that today.
I've been working on that for a while - the problem is that it goes up a few layers, including xfs_bmapi_write and the da_args structures.
Give me a little more time and I should have a series for you.
Quoted 21 lines · Christoph Hellwig
Quoted 6 lines · Darrick J. Wong
fs/xfs/libxfs/xfs_bmap.c xfs_bmap_extents_to_btree( · line 799
Quoted 4 lines
fs/xfs/libxfs/xfs_bmap.c +4
-0+if (WARN_ON_ONCE (args.fsbno ==NULLFSBLOCK )) { +xfs_iroot_realloc (ip,-1 , whichfork); +xfs_btree_del_cursor (cur,XFS_BTREE_ERROR ); +return -ENOMEM ;ENOSPC?
Yeah.
Quoted 7 lines
fs/xfs/libxfs/xfs_bmap.c xfs_bmap_extents_to_btree( · line 803
Quoted 4 lines
fs/xfs/libxfs/xfs_bmap.c +1
-0+ }/* * Allocation can't fail, the space was reserved. */ Can we get rid of the ASSERT(args.fsbno != NULLFSBLOCK); just below here now that we jump out above?
Sure.
Quoted 1 line
Quoted 8 lines
Quoted 3 lines
Conceptually I guess it's ok for now until we separate out the uses of *firstblock to stay ahead of locking rules vs. *firstblock to remap things. Hmm, I'll try to make a first stab at that today.
I've been working on that for a while - the problem is that it goes up a few layers, including
xfs_bmapi_writeand theda_argsstructures.Give me a little more time and I should have a series for you.
Ok.
--D
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html