]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: add a realtime flag to the refcount update log redo items
authorDarrick J. Wong <djwong@kernel.org>
Mon, 24 Feb 2025 18:22:03 +0000 (10:22 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 25 Feb 2025 17:16:01 +0000 (09:16 -0800)
Extend the refcount update (CUI) log items with a new realtime flag that
indicates that the updates apply against the realtime refcountbt.  We'll
wire up the actual refcount code later.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
libxfs/defer_item.c

index 1ca9ce15ecfe3d5834c61e5f9fe23711bb427d19..6beefa6a439980bac9583f8a2717481dbf2c7e66 100644 (file)
@@ -442,9 +442,18 @@ xfs_refcount_defer_add(
 
        trace_xfs_refcount_defer(mp, ri);
 
+       /*
+        * Deferred refcount updates for the realtime and data sections must
+        * use separate transactions to finish deferred work because updates to
+        * realtime metadata files can lock AGFs to allocate btree blocks and
+        * we don't want that mixing with the AGF locks taken to finish data
+        * section updates.
+        */
        ri->ri_group = xfs_group_intent_get(mp, ri->ri_startblock,
-                       XG_TYPE_AG);
-       xfs_defer_add(tp, &ri->ri_list, &xfs_refcount_update_defer_type);
+                       ri->ri_realtime ? XG_TYPE_RTG : XG_TYPE_AG);
+       xfs_defer_add(tp, &ri->ri_list, ri->ri_realtime ?
+                       &xfs_rtrefcount_update_defer_type :
+                       &xfs_refcount_update_defer_type);
 }
 
 /* Cancel a deferred refcount update. */
@@ -516,6 +525,27 @@ const struct xfs_defer_op_type xfs_refcount_update_defer_type = {
        .cancel_item    = xfs_refcount_update_cancel_item,
 };
 
+/* Clean up after calling xfs_rtrefcount_finish_one. */
+STATIC void
+xfs_rtrefcount_finish_one_cleanup(
+       struct xfs_trans        *tp,
+       struct xfs_btree_cur    *rcur,
+       int                     error)
+{
+       if (rcur)
+               xfs_btree_del_cursor(rcur, error);
+}
+
+const struct xfs_defer_op_type xfs_rtrefcount_update_defer_type = {
+       .name           = "rtrefcount",
+       .create_intent  = xfs_refcount_update_create_intent,
+       .abort_intent   = xfs_refcount_update_abort_intent,
+       .create_done    = xfs_refcount_update_create_done,
+       .finish_item    = xfs_refcount_update_finish_item,
+       .finish_cleanup = xfs_rtrefcount_finish_one_cleanup,
+       .cancel_item    = xfs_refcount_update_cancel_item,
+};
+
 /* Inode Block Mapping */
 
 static inline struct xfs_bmap_intent *bi_entry(const struct list_head *e)