diff mbox series

[3/3] xfs: xfs_defer_capture should absorb remaining transaction reservation

Message ID 160031335967.3624461.12775342036527430147.stgit@magnolia (mailing list archive)
State Superseded
Headers show
Series xfs: fix how we deal with new intents during recovery | expand

Commit Message

Darrick J. Wong Sept. 17, 2020, 3:29 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

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.

This avoids a potential failure vector by ensuring that we never ask for
more log reservation space than we would have asked for had the system
not gone down.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_defer.c |    3 +++
 fs/xfs/libxfs/xfs_defer.h |    1 +
 fs/xfs/xfs_log_recover.c  |    4 ++--
 3 files changed, 6 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig Sept. 23, 2020, 7:49 a.m. UTC | #1
>  	list_for_each_entry_safe(dfc, next, dfops_freezers, dfc_list) {
> -		error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0,
> -				0, XFS_TRANS_RESERVE, &tp);
> +		error = xfs_trans_alloc(mp, &dfc->dfc_tres, 0, 0,
> +				XFS_TRANS_RESERVE, &tp);

... and this fixes the weird itruncate thing.  Nice!
Darrick J. Wong Sept. 23, 2020, 3:22 p.m. UTC | #2
On Wed, Sep 23, 2020 at 08:49:53AM +0100, Christoph Hellwig wrote:
> >  	list_for_each_entry_safe(dfc, next, dfops_freezers, dfc_list) {
> > -		error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0,
> > -				0, XFS_TRANS_RESERVE, &tp);
> > +		error = xfs_trans_alloc(mp, &dfc->dfc_tres, 0, 0,
> > +				XFS_TRANS_RESERVE, &tp);
> 
> ... and this fixes the weird itruncate thing.  Nice!

Yep, Dave was also complaining about how weird the itruncate thing was.

--D
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
index d1db97ccad51..edfb3b9856c8 100644
--- a/fs/xfs/libxfs/xfs_defer.c
+++ b/fs/xfs/libxfs/xfs_defer.c
@@ -590,6 +590,9 @@  xfs_defer_capture(
 		dfc->dfc_tpflags = tp->t_flags & XFS_TRANS_LOWMODE;
 		dfc->dfc_blkres = tp->t_blk_res - tp->t_blk_res_used;
 		tp->t_blk_res = tp->t_blk_res_used;
+		dfc->dfc_tres.tr_logres = tp->t_log_res;
+		dfc->dfc_tres.tr_logcount = tp->t_log_count;
+		dfc->dfc_tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
 		xfs_defer_reset(tp);
 	}
 
diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h
index fea610f5d3e1..a788855aef69 100644
--- a/fs/xfs/libxfs/xfs_defer.h
+++ b/fs/xfs/libxfs/xfs_defer.h
@@ -77,6 +77,7 @@  struct xfs_defer_capture {
 	struct list_head	dfc_dfops;
 	unsigned int		dfc_tpflags;
 	unsigned int		dfc_blkres;
+	struct xfs_trans_res	dfc_tres;
 };
 
 /*
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 5f664e52c542..f5748c8f5157 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2503,8 +2503,8 @@  xlog_finish_defer_ops(
 	int			error = 0;
 
 	list_for_each_entry_safe(dfc, next, dfops_freezers, dfc_list) {
-		error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0,
-				0, XFS_TRANS_RESERVE, &tp);
+		error = xfs_trans_alloc(mp, &dfc->dfc_tres, 0, 0,
+				XFS_TRANS_RESERVE, &tp);
 		if (error)
 			break;