This is a note to let you know that I've just added the patch titled xfs: xfs_defer_capture should absorb remaining transaction reservation to the 5.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: xfs-xfs_defer_capture-should-absorb-remaining-transaction-reservation.patch and it can be found in the queue-5.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From chandan.babu@xxxxxxxxxx Thu Feb 16 06:22:08 2023 From: Chandan Babu R <chandan.babu@xxxxxxxxxx> Date: Thu, 16 Feb 2023 10:50:07 +0530 Subject: xfs: xfs_defer_capture should absorb remaining transaction reservation To: gregkh@xxxxxxxxxxxxxxxxxxx Cc: sashal@xxxxxxxxxx, mcgrof@xxxxxxxxxx, linux-xfs@xxxxxxxxxxxxxxx, stable@xxxxxxxxxxxxxxx, djwong@xxxxxxxxxx, chandan.babu@xxxxxxxxxx, amir73il@xxxxxxxxx, leah.rumancik@xxxxxxxxx Message-ID: <20230216052019.368896-14-chandan.babu@xxxxxxxxxx> From: "Darrick J. Wong" <darrick.wong@xxxxxxxxxx> commit 929b92f64048d90d23e40a59c47adf59f5026903 upstream. When xfs_defer_capture extracts the deferred ops and transaction state from a transaction, it should record the transaction reservation type from the old transaction so that when we continue the dfops chain, we still use the same reservation parameters. Doing this means that the log item recovery functions get to determine the transaction reservation instead of abusing tr_itruncate in yet another part of xfs. Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Reviewed-by: Brian Foster <bfoster@xxxxxxxxxx> Reviewed-by: Christoph Hellwig <hch@xxxxxx> Signed-off-by: Chandan Babu R <chandan.babu@xxxxxxxxxx> Acked-by: Darrick J. Wong <djwong@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/xfs/libxfs/xfs_defer.c | 3 +++ fs/xfs/libxfs/xfs_defer.h | 3 +++ fs/xfs/xfs_log_recover.c | 17 ++++++++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -593,6 +593,9 @@ xfs_defer_ops_capture( dfc->dfc_blkres = tp->t_blk_res - tp->t_blk_res_used; dfc->dfc_rtxres = tp->t_rtx_res - tp->t_rtx_res_used; + /* Preserve the log reservation size. */ + dfc->dfc_logres = tp->t_log_res; + return dfc; } --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -77,6 +77,9 @@ struct xfs_defer_capture { /* Block reservations for the data and rt devices. */ unsigned int dfc_blkres; unsigned int dfc_rtxres; + + /* Log reservation saved from the transaction. */ + unsigned int dfc_logres; }; /* --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -4769,9 +4769,20 @@ xlog_finish_defer_ops( int error = 0; list_for_each_entry_safe(dfc, next, capture_list, dfc_list) { - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, - dfc->dfc_blkres, dfc->dfc_rtxres, - XFS_TRANS_RESERVE, &tp); + struct xfs_trans_res resv; + + /* + * Create a new transaction reservation from the captured + * information. Set logcount to 1 to force the new transaction + * to regrant every roll so that we can make forward progress + * in recovery no matter how full the log might be. + */ + resv.tr_logres = dfc->dfc_logres; + resv.tr_logcount = 1; + resv.tr_logflags = XFS_TRANS_PERM_LOG_RES; + + error = xfs_trans_alloc(mp, &resv, dfc->dfc_blkres, + dfc->dfc_rtxres, XFS_TRANS_RESERVE, &tp); if (error) return error; Patches currently in stable-queue which might be from chandan.babu@xxxxxxxxxx are queue-5.4/xfs-remove-the-xfs_efd_log_item_t-typedef.patch queue-5.4/xfs-change-the-order-in-which-child-and-parent-defer-ops-are-finished.patch queue-5.4/xfs-refactor-xfs_defer_finish_noroll.patch queue-5.4/xfs-sync-lazy-sb-accounting-on-quiesce-of-read-only-mounts.patch queue-5.4/xfs-clean-up-xfs_bui_item_recover-iget-trans_alloc-ilock-ordering.patch queue-5.4/xfs-xfs_defer_capture-should-absorb-remaining-block-reservations.patch queue-5.4/xfs-factor-out-a-xfs_defer_create_intent-helper.patch queue-5.4/xfs-turn-dfp_intent-into-a-xfs_log_item.patch queue-5.4/xfs-fix-finobt-btree-block-recovery-ordering.patch queue-5.4/xfs-xfs_defer_capture-should-absorb-remaining-transaction-reservation.patch queue-5.4/xfs-merge-the-diff_items-defer-op-into-create_intent.patch queue-5.4/xfs-prevent-uaf-in-xfs_log_item_in_current_chkpt.patch queue-5.4/xfs-fix-missing-cow-blocks-writeback-conversion-retry.patch queue-5.4/xfs-remove-the-xfs_efi_log_item_t-typedef.patch queue-5.4/xfs-only-relog-deferred-intent-items-if-free-space-in-the-log-gets-low.patch queue-5.4/xfs-proper-replay-of-deferred-ops-queued-during-log-recovery.patch queue-5.4/xfs-clean-up-bmap-intent-item-recovery-checking.patch queue-5.4/xfs-fix-the-forward-progress-assertion-in-xfs_iwalk_run_callbacks.patch queue-5.4/xfs-log-new-intent-items-created-as-part-of-finishing-recovered-intent-items.patch queue-5.4/xfs-ensure-inobt-record-walks-always-make-forward-progress.patch queue-5.4/xfs-remove-the-xfs_inode_log_item_t-typedef.patch queue-5.4/xfs-fix-an-incore-inode-uaf-in-xfs_bui_recover.patch queue-5.4/xfs-expose-the-log-push-threshold.patch queue-5.4/xfs-periodically-relog-deferred-intent-items.patch queue-5.4/xfs-merge-the-log_item-defer-op-into-create_intent.patch