From: Darrick J. Wong Date: Thu, 12 Nov 2020 22:21:10 +0000 (-0500) Subject: xfs: xfs_defer_capture should absorb remaining block reservations X-Git-Tag: v5.10.0-rc0~10 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=75d8bf7e082a7fd55d46eb3c90b3a570ee9f6714;p=thirdparty%2Fxfsprogs-dev.git xfs: xfs_defer_capture should absorb remaining block reservations Source kernel commit: 4f9a60c48078c0efa3459678fa8d6e050e8ada5d When xfs_defer_capture extracts the deferred ops and transaction state from a transaction, it should record the remaining block reservations so that when we continue the dfops chain, we can reserve the same number of blocks to use. We capture the reservations for both data and realtime volumes. This adds the requirement that every log intent item recovery function must be careful to reserve enough blocks to handle both itself and all defer ops that it can queue. On the other hand, this enables us to do away with the handwaving block estimation nonsense that was going on in xlog_finish_defer_ops. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Brian Foster Signed-off-by: Eric Sandeen --- diff --git a/include/xfs_trans.h b/include/xfs_trans.h index 9292a4a54..6daf35cfc 100644 --- a/include/xfs_trans.h +++ b/include/xfs_trans.h @@ -64,10 +64,12 @@ typedef struct xfs_trans { unsigned int t_log_res; /* amt of log space resvd */ unsigned int t_log_count; /* count for perm log res */ unsigned int t_blk_res; /* # of blocks resvd */ - xfs_fsblock_t t_firstblock; /* first block allocated */ - struct xfs_mount *t_mountp; /* ptr to fs mount struct */ unsigned int t_blk_res_used; /* # of resvd blocks used */ + unsigned int t_rtx_res; /* # of rt extents resvd */ + unsigned int t_rtx_res_used; /* # of resvd rt extents used */ unsigned int t_flags; /* misc flags */ + xfs_fsblock_t t_firstblock; /* first block allocated */ + struct xfs_mount *t_mountp; /* ptr to fs mount struct */ long t_icount_delta; /* superblock icount change */ long t_ifree_delta; /* superblock ifree change */ long t_fdblocks_delta; /* superblock fdblocks chg */ diff --git a/libxfs/xfs_defer.c b/libxfs/xfs_defer.c index 90dc9ce92..fc5c860e5 100644 --- a/libxfs/xfs_defer.c +++ b/libxfs/xfs_defer.c @@ -573,6 +573,10 @@ xfs_defer_ops_capture( dfc->dfc_tpflags = tp->t_flags & XFS_TRANS_LOWMODE; tp->t_flags &= ~XFS_TRANS_LOWMODE; + /* Capture the remaining block reservations along with the dfops. */ + dfc->dfc_blkres = tp->t_blk_res - tp->t_blk_res_used; + dfc->dfc_rtxres = tp->t_rtx_res - tp->t_rtx_res_used; + return dfc; } diff --git a/libxfs/xfs_defer.h b/libxfs/xfs_defer.h index 3af82ebc1..5c0e59b69 100644 --- a/libxfs/xfs_defer.h +++ b/libxfs/xfs_defer.h @@ -75,6 +75,10 @@ struct xfs_defer_capture { /* Deferred ops state saved from the transaction. */ struct list_head dfc_dfops; unsigned int dfc_tpflags; + + /* Block reservations for the data and rt devices. */ + unsigned int dfc_blkres; + unsigned int dfc_rtxres; }; /*