]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: add realtime extent reservation and usage tracking to transactions
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 4 Dec 2020 17:17:12 +0000 (12:17 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Fri, 4 Dec 2020 17:17:12 +0000 (12:17 -0500)
The libxfs resync added to the deferred ops code the ability to capture
the unfinished deferred ops and transaction reservation for later replay
during log recovery.  This nominally requires transactions to have the
ability to track rt extent reservations and usage, so port that missing
piece from the kernel now to avoid leaving logic bombs in case anyone
ever /does/ start messing with realtime.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/trans.c

index 83247582d61e7998a60a1f5331866599e01a02f4..bc4af26c09f603a7e75a58e4ed50f7d7348b5107 100644 (file)
@@ -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: