]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: move xfs_refcount_update_defer_add to xfs_refcount_item.c
authorDarrick J. Wong <djwong@kernel.org>
Tue, 2 Jul 2024 18:23:12 +0000 (11:23 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 2 Jul 2024 18:37:07 +0000 (11:37 -0700)
Move the code that adds the incore xfs_refcount_update_item deferred
work data to a transaction live with the CUI log item code.  This means
that the refcount code no longer has to know about the inner workings of
the CUI log items.

As a consequence, we can get rid of the _{get,put}_group helpers.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/libxfs/xfs_refcount.c
fs/xfs/libxfs/xfs_refcount.h
fs/xfs/xfs_refcount_item.c
fs/xfs/xfs_refcount_item.h

index 4137a8d1ac13d0a44c2806a18daea6e511a90d15..198b84117df138a6b4a75274ac241198aa5cfac7 100644 (file)
@@ -24,6 +24,7 @@
 #include "xfs_rmap.h"
 #include "xfs_ag.h"
 #include "xfs_health.h"
+#include "xfs_refcount_item.h"
 
 struct kmem_cache      *xfs_refcount_intent_cache;
 
@@ -1435,10 +1436,7 @@ __xfs_refcount_add(
        ri->ri_startblock = startblock;
        ri->ri_blockcount = blockcount;
 
-       trace_xfs_refcount_defer(tp->t_mountp, ri);
-
-       xfs_refcount_update_get_group(tp->t_mountp, ri);
-       xfs_defer_add(tp, &ri->ri_list, &xfs_refcount_update_defer_type);
+       xfs_refcount_defer_add(tp, ri);
 }
 
 /*
index c94b8f71d407b9a54fbd538cfb3164ca88095578..68acb0b1b4a8781598d4bbb8643a7a70f84e19fd 100644 (file)
@@ -74,9 +74,6 @@ xfs_refcount_check_domain(
        return true;
 }
 
-void xfs_refcount_update_get_group(struct xfs_mount *mp,
-               struct xfs_refcount_intent *ri);
-
 void xfs_refcount_increase_extent(struct xfs_trans *tp,
                struct xfs_bmbt_irec *irec);
 void xfs_refcount_decrease_extent(struct xfs_trans *tp,
index 4e06cadb924d36c327f3235b387bbda43e29b2f5..27398512b179b27a83f5e2b11e28a2b767f751a9 100644 (file)
@@ -22,6 +22,7 @@
 #include "xfs_log_recover.h"
 #include "xfs_ag.h"
 #include "xfs_btree.h"
+#include "xfs_trace.h"
 
 struct kmem_cache      *xfs_cui_cache;
 struct kmem_cache      *xfs_cud_cache;
@@ -319,21 +320,18 @@ xfs_refcount_update_create_done(
        return &cudp->cud_item;
 }
 
-/* Take a passive ref to the AG containing the space we're refcounting. */
+/* Add this deferred CUI to the transaction. */
 void
-xfs_refcount_update_get_group(
-       struct xfs_mount                *mp,
+xfs_refcount_defer_add(
+       struct xfs_trans                *tp,
        struct xfs_refcount_intent      *ri)
 {
-       ri->ri_pag = xfs_perag_intent_get(mp, ri->ri_startblock);
-}
+       struct xfs_mount                *mp = tp->t_mountp;
 
-/* Release a passive AG ref after finishing refcounting work. */
-static inline void
-xfs_refcount_update_put_group(
-       struct xfs_refcount_intent      *ri)
-{
-       xfs_perag_intent_put(ri->ri_pag);
+       trace_xfs_refcount_defer(mp, ri);
+
+       ri->ri_pag = xfs_perag_intent_get(mp, ri->ri_startblock);
+       xfs_defer_add(tp, &ri->ri_list, &xfs_refcount_update_defer_type);
 }
 
 /* Cancel a deferred refcount update. */
@@ -343,7 +341,7 @@ xfs_refcount_update_cancel_item(
 {
        struct xfs_refcount_intent      *ri = ci_entry(item);
 
-       xfs_refcount_update_put_group(ri);
+       xfs_perag_intent_put(ri->ri_pag);
        kmem_cache_free(xfs_refcount_intent_cache, ri);
 }
 
@@ -433,7 +431,7 @@ xfs_cui_recover_work(
        ri->ri_type = pmap->pe_flags & XFS_REFCOUNT_EXTENT_TYPE_MASK;
        ri->ri_startblock = pmap->pe_startblock;
        ri->ri_blockcount = pmap->pe_len;
-       xfs_refcount_update_get_group(mp, ri);
+       ri->ri_pag = xfs_perag_intent_get(mp, pmap->pe_startblock);
 
        xfs_defer_add_item(dfp, &ri->ri_list);
 }
index eb0ab13682d0b4702f5c7bd3696087709b79ed45..bfee8f30c63ce9ceaec935b969d7f42ed2e3efaf 100644 (file)
@@ -71,4 +71,9 @@ struct xfs_cud_log_item {
 extern struct kmem_cache       *xfs_cui_cache;
 extern struct kmem_cache       *xfs_cud_cache;
 
+struct xfs_refcount_intent;
+
+void xfs_refcount_defer_add(struct xfs_trans *tp,
+               struct xfs_refcount_intent *ri);
+
 #endif /* __XFS_REFCOUNT_ITEM_H__ */