libxfs: add realtime extent reservation and usage tracking to transactions
PATCH 1/1 libxfs: add realtime extent reservation and usage tracking to transactions
From: Darrick J. Wong <[email protected]>
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.
---
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(+)
include/xfs_trans.h +2 -0
@@ -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 */
libxfs/trans.c +14 -0
@@ -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 :
Quoted 8 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
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.
Quoted 5 lines
Signed-off-by Darrick J. Wong <[email protected]>---
FWIW this should have been a prep patch ahead of "xfs:xfs_defer_captureshould absorb remaining block reservations" but I goofed. Sorry about that... :(
Looks good,