@@ -71,6 +71,7 @@ typedef struct xfs_trans {
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_flags; /* misc flags */
long t_icount_delta; /* superblock icount change */
long t_ifree_delta; /* superblock ifree change */
@@ -158,6 +158,9 @@ xfs_trans_dup(
/* We gave our writer reference to the new transaction */
tp->t_flags |= XFS_TRANS_NO_WRITECOUNT;
+ ntp->t_blk_res = tp->t_blk_res - tp->t_blk_res_used;
+ tp->t_blk_res = tp->t_blk_res_used;
+
/* move deferred ops over to the new tp */
xfs_defer_move(ntp, tp);
@@ -790,6 +793,15 @@ libxfs_trans_mod_sb(
case XFS_TRANS_SB_RES_FDBLOCKS:
return;
case XFS_TRANS_SB_FDBLOCKS:
+ if (delta < 0) {
+ tp->t_blk_res_used += (uint)-delta;
+ if (tp->t_blk_res_used > tp->t_blk_res) {
+ fprintf(stderr,
+_("Transaction block reservation exceeded! %u > %u\n"),
+ tp->t_blk_res_used, tp->t_blk_res);
+ ASSERT(0);
+ }
+ }
tp->t_fdblocks_delta += delta;
break;
case XFS_TRANS_SB_ICOUNT: