From: Darrick J. Wong <darrick.wong@xxxxxxxxxx> An upcoming patch will add to the deferred ops code the ability to capture the unfinished deferred ops and transaction reservation for later replay during log recovery. This requires transactions to have the ability to track rt extent reservations and usage, so add that missing piece now. Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> --- FWIW this should have been a prep patch ahead of "xfs: xfs_defer_capture should absorb remaining block reservations" but I goofed. Sorry about that... :( --- include/xfs_trans.h | 2 ++ libxfs/trans.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/xfs_trans.h b/include/xfs_trans.h index 9292a4a54237..f19914068030 100644 --- a/include/xfs_trans.h +++ b/include/xfs_trans.h @@ -64,9 +64,11 @@ 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 */ + unsigned int t_rtx_res; 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_used; unsigned int t_flags; /* misc flags */ long t_icount_delta; /* superblock icount change */ long t_ifree_delta; /* superblock ifree change */ diff --git a/libxfs/trans.c b/libxfs/trans.c index 6838b727350b..912e95b8d708 100644 --- a/libxfs/trans.c +++ b/libxfs/trans.c @@ -230,6 +230,7 @@ xfs_trans_reserve( error = -ENOSPC; goto undo_blocks; } + tp->t_rtx_res += rtextents; } return 0; @@ -765,6 +766,19 @@ _("Transaction block reservation exceeded! %u > %u\n"), tp->t_ifree_delta += delta; break; case XFS_TRANS_SB_FREXTENTS: + /* + * Track the number of rt extents allocated in the transaction. + * Make sure it does not exceed the number reserved. + */ + if (delta < 0) { + tp->t_rtx_res_used += (uint)-delta; + if (tp->t_rtx_res_used > tp->t_rtx_res) { + fprintf(stderr, +_("Transaction rt block reservation exceeded! %u > %u\n"), + tp->t_rtx_res_used, tp->t_rtx_res); + ASSERT(0); + } + } tp->t_frextents_delta += delta; break; default: