xfs: make tr_growdata a permanent transaction
PATCH 1/1 xfs: make tr_growdata a permanent transaction
From: Brian Foster <[email protected]>
The growdata transaction is used by growfs operations to increase the data size of the filesystem. Part of this sequence involves extending the size of the last preexisting AG in the fs, if necessary. This is implemented by freeing the newly available physical range to the AG.
tr_growdata is not a permanent transaction, however, and block allocation transactions must be permanent to handle deferred frees of AGFL blocks. If the grow operation extends an existing AG that requires AGFL fixing, assert failures occur due to a populated dfops list on a non-permanent transaction and the AGFL free does not occur. This is reproduced (rarely) by xfs/104.
Change tr_growdata to a permanent transaction with a default log count. This increases initial transaction reservation size, but growfs is an infrequent and non-performance critical operation and so should have minimal impact. Also add an assert in the block allocation path to make this transaction requirement explicit and obvious to future callers.
--- fs/xfs/libxfs/xfs_trans_resv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/xfs/libxfs/xfs_trans_resv.c +5 -1
@@ -876,9 +876,13 @@ xfs_trans_resv_calc( resp->tr_sb.tr_logres =xfs_calc_sb_reservation (mp); resp->tr_sb.tr_logcount =XFS_DEFAULT_LOG_COUNT ; +/* growdata requires permanent res; it can free space to the last AG */ + resp->tr_growdata.tr_logres =xfs_calc_growdata_reservation (mp); + resp->tr_growdata.tr_logcount =XFS_DEFAULT_PERM_LOG_COUNT ; + resp->tr_growdata.tr_logflags |=XFS_TRANS_PERM_LOG_RES ; +/* The following transaction are logged in logical format */ resp->tr_ichange.tr_logres =xfs_calc_ichange_reservation (mp); - resp->tr_growdata.tr_logres =xfs_calc_growdata_reservation (mp); resp->tr_fsyncts.tr_logres =xfs_calc_swrite_reservation (mp); resp->tr_writeid.tr_logres =xfs_calc_writeid_reservation (mp); resp->tr_attrsetrt.tr_logres =xfs_calc_attrsetrt_reservation (mp);
Quoted 15 lines · Darrick J. Wong
From: Brian Foster <[email protected]>
The growdata transaction is used by growfs operations to increase the data size of the filesystem. Part of this sequence involves extending the size of the last preexisting AG in the fs, if necessary. This is implemented by freeing the newly available physical range to the AG.
tr_growdatais not a permanent transaction, however, and block allocation transactions must be permanent to handle deferred frees of AGFL blocks. If the grow operation extends an existing AG that requires AGFL fixing, assert failures occur due to a populated dfops list on a non-permanent transaction and the AGFL free does not occur. This is reproduced (rarely) by xfs/104.
Quoted 7 lines
Change
tr_growdatato a permanent transaction with a default log count. This increases initial transaction reservation size, but growfs is an infrequent and non-performance critical operation and so should have minimal impact. Also add an assert in the block allocation path to make this transaction requirement explicit and obvious to future callers.
We should drop the last sentence from this commit log too if we push the assert to its own patch.
Brian
Quoted 28 lines
Reported-by Darrick J. Wong <[email protected]>Signed-off-by Brian Foster <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>[darrick: add a comment to the assert]Signed-off-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_trans_resv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)fs/xfs/libxfs/xfs_trans_resv.c +5
-1@@ -876,9 +876,13 @@ xfs_trans_resv_calc( resp->tr_sb.tr_logres =xfs_calc_sb_reservation (mp); resp->tr_sb.tr_logcount =XFS_DEFAULT_LOG_COUNT ; +/* growdata requires permanent res; it can free space to the last AG */ + resp->tr_growdata.tr_logres =xfs_calc_growdata_reservation (mp); + resp->tr_growdata.tr_logcount =XFS_DEFAULT_PERM_LOG_COUNT ; + resp->tr_growdata.tr_logflags |=XFS_TRANS_PERM_LOG_RES ; +/* The following transaction are logged in logical format */ resp->tr_ichange.tr_logres =xfs_calc_ichange_reservation (mp); - resp->tr_growdata.tr_logres =xfs_calc_growdata_reservation (mp); resp->tr_fsyncts.tr_logres =xfs_calc_swrite_reservation (mp); resp->tr_writeid.tr_logres =xfs_calc_writeid_reservation (mp); resp->tr_attrsetrt.tr_logres =xfs_calc_attrsetrt_reservation (mp);
Quoted 24 lines · Brian Foster
Quoted 15 lines · Darrick J. Wong
From: Brian Foster <[email protected]>
The growdata transaction is used by growfs operations to increase the data size of the filesystem. Part of this sequence involves extending the size of the last preexisting AG in the fs, if necessary. This is implemented by freeing the newly available physical range to the AG.
tr_growdatais not a permanent transaction, however, and block allocation transactions must be permanent to handle deferred frees of AGFL blocks. If the grow operation extends an existing AG that requires AGFL fixing, assert failures occur due to a populated dfops list on a non-permanent transaction and the AGFL free does not occur. This is reproduced (rarely) by xfs/104.Quoted 7 lines
Change
tr_growdatato a permanent transaction with a default log count. This increases initial transaction reservation size, but growfs is an infrequent and non-performance critical operation and so should have minimal impact. Also add an assert in the block allocation path to make this transaction requirement explicit and obvious to future callers.
Quoted 2 lines
We should drop the last sentence from this commit log too if we push the assert to its own patch.
Ok, will do.
--D
Quoted 31 lines
Brian
Quoted 28 lines
Reported-by Darrick J. Wong <[email protected]>Signed-off-by Brian Foster <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>[darrick: add a comment to the assert]Signed-off-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_trans_resv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)fs/xfs/libxfs/xfs_trans_resv.c +5
-1@@ -876,9 +876,13 @@ xfs_trans_resv_calc( resp->tr_sb.tr_logres =xfs_calc_sb_reservation (mp); resp->tr_sb.tr_logcount =XFS_DEFAULT_LOG_COUNT ; +/* growdata requires permanent res; it can free space to the last AG */ + resp->tr_growdata.tr_logres =xfs_calc_growdata_reservation (mp); + resp->tr_growdata.tr_logcount =XFS_DEFAULT_PERM_LOG_COUNT ; + resp->tr_growdata.tr_logflags |=XFS_TRANS_PERM_LOG_RES ; +/* The following transaction are logged in logical format */ resp->tr_ichange.tr_logres =xfs_calc_ichange_reservation (mp); - resp->tr_growdata.tr_logres =xfs_calc_growdata_reservation (mp); resp->tr_fsyncts.tr_logres =xfs_calc_swrite_reservation (mp); resp->tr_writeid.tr_logres =xfs_calc_writeid_reservation (mp); resp->tr_attrsetrt.tr_logres =xfs_calc_attrsetrt_reservation (mp);
PATCH 1/1 xfs: assert that we don't enter agfl freeing with a non-permanent transaction
In reply to Darrick J. WongFrom: Brian Foster <[email protected]>
Block allocation requires a permanent transaction for deferred AGFL frees. Add an assert in the block allocation path to make explicit and obvious to future callers the requirement of a transaction with a permanent reservation.
--- fs/xfs/libxfs/xfs_alloc.c | 3 +++ 1 file changed, 3 insertions(+)
fs/xfs/libxfs/xfs_alloc.c +3 -0
@@ -2243,6 +2243,9 @@ xfs_alloc_fix_freelist(xfs_extlen_t need;/* total blocks needed in freelist */ int error =0 ; +/* deferred ops (AGFL block frees) require permanent transactions */ +ASSERT (tp->t_flags &XFS_TRANS_PERM_LOG_RES ); +if (!pag->pagf_init) { error =xfs_alloc_read_agf (mp, tp, args->agno, flags, &agbp);if (error)