Skip to content

Commit 929b92f

Browse files
committed
xfs: xfs_defer_capture should absorb remaining transaction reservation
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 <[email protected]> Reviewed-by: Brian Foster <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent 4f9a60c commit 929b92f

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

fs/xfs/libxfs/xfs_defer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,9 @@ xfs_defer_ops_capture(
579579
dfc->dfc_blkres = tp->t_blk_res - tp->t_blk_res_used;
580580
dfc->dfc_rtxres = tp->t_rtx_res - tp->t_rtx_res_used;
581581

582+
/* Preserve the log reservation size. */
583+
dfc->dfc_logres = tp->t_log_res;
584+
582585
return dfc;
583586
}
584587

fs/xfs/libxfs/xfs_defer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ struct xfs_defer_capture {
7979
/* Block reservations for the data and rt devices. */
8080
unsigned int dfc_blkres;
8181
unsigned int dfc_rtxres;
82+
83+
/* Log reservation saved from the transaction. */
84+
unsigned int dfc_logres;
8285
};
8386

8487
/*

fs/xfs/xfs_log_recover.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,9 +2442,20 @@ xlog_finish_defer_ops(
24422442
int error = 0;
24432443

24442444
list_for_each_entry_safe(dfc, next, capture_list, dfc_list) {
2445-
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate,
2446-
dfc->dfc_blkres, dfc->dfc_rtxres,
2447-
XFS_TRANS_RESERVE, &tp);
2445+
struct xfs_trans_res resv;
2446+
2447+
/*
2448+
* Create a new transaction reservation from the captured
2449+
* information. Set logcount to 1 to force the new transaction
2450+
* to regrant every roll so that we can make forward progress
2451+
* in recovery no matter how full the log might be.
2452+
*/
2453+
resv.tr_logres = dfc->dfc_logres;
2454+
resv.tr_logcount = 1;
2455+
resv.tr_logflags = XFS_TRANS_PERM_LOG_RES;
2456+
2457+
error = xfs_trans_alloc(mp, &resv, dfc->dfc_blkres,
2458+
dfc->dfc_rtxres, XFS_TRANS_RESERVE, &tp);
24482459
if (error)
24492460
return error;
24502461

0 commit comments

Comments
 (0)