]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: move xfs_rmap_update_defer_add to xfs_rmap_item.c
authorDarrick J. Wong <djwong@kernel.org>
Tue, 2 Jul 2024 18:23:04 +0000 (11:23 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 2 Jul 2024 18:37:05 +0000 (11:37 -0700)
Move the code that adds the incore xfs_rmap_update_item deferred work
data to a transaction to live with the RUI log item code.  This means
that the rmap code no longer has to know about the inner workings of the
RUI 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_rmap.c
fs/xfs/libxfs/xfs_rmap.h
fs/xfs/xfs_rmap_item.c
fs/xfs/xfs_rmap_item.h

index a5a0fa6a5b5dc33c3957c78cabf0e0aadbdaa34e..6ef4687b3aba8fcf6aef22adb0e46db405507e61 100644 (file)
@@ -24,6 +24,7 @@
 #include "xfs_inode.h"
 #include "xfs_ag.h"
 #include "xfs_health.h"
+#include "xfs_rmap_item.h"
 
 struct kmem_cache      *xfs_rmap_intent_cache;
 
@@ -2656,10 +2657,7 @@ __xfs_rmap_add(
        ri->ri_whichfork = whichfork;
        ri->ri_bmap = *bmap;
 
-       trace_xfs_rmap_defer(tp->t_mountp, ri);
-
-       xfs_rmap_update_get_group(tp->t_mountp, ri);
-       xfs_defer_add(tp, &ri->ri_list, &xfs_rmap_update_defer_type);
+       xfs_rmap_defer_add(tp, ri);
 }
 
 /* Map an extent into a file. */
index 9d85dd2a6553cc27e55088dd768c04c58fff3be4..b783dd4dd95d1abe73c4697f50fdd05efb11d518 100644 (file)
@@ -176,9 +176,6 @@ struct xfs_rmap_intent {
        struct xfs_perag                        *ri_pag;
 };
 
-void xfs_rmap_update_get_group(struct xfs_mount *mp,
-               struct xfs_rmap_intent *ri);
-
 /* functions for updating the rmapbt based on bmbt map/unmap operations */
 void xfs_rmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip,
                int whichfork, struct xfs_bmbt_irec *imap);
index 44a9b77c17639a69ebfbafcaffb48293353e02bf..88b5580e1e19f53821fa123d2965a2357fa11655 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_rui_cache;
 struct kmem_cache      *xfs_rud_cache;
@@ -342,21 +343,18 @@ xfs_rmap_update_create_done(
        return &rudp->rud_item;
 }
 
-/* Take a passive ref to the AG containing the space we're rmapping. */
+/* Add this deferred RUI to the transaction. */
 void
-xfs_rmap_update_get_group(
-       struct xfs_mount        *mp,
+xfs_rmap_defer_add(
+       struct xfs_trans        *tp,
        struct xfs_rmap_intent  *ri)
 {
-       ri->ri_pag = xfs_perag_intent_get(mp, ri->ri_bmap.br_startblock);
-}
+       struct xfs_mount        *mp = tp->t_mountp;
 
-/* Release a passive AG ref after finishing rmapping work. */
-static inline void
-xfs_rmap_update_put_group(
-       struct xfs_rmap_intent  *ri)
-{
-       xfs_perag_intent_put(ri->ri_pag);
+       trace_xfs_rmap_defer(mp, ri);
+
+       ri->ri_pag = xfs_perag_intent_get(mp, ri->ri_bmap.br_startblock);
+       xfs_defer_add(tp, &ri->ri_list, &xfs_rmap_update_defer_type);
 }
 
 /* Cancel a deferred rmap update. */
@@ -366,7 +364,7 @@ xfs_rmap_update_cancel_item(
 {
        struct xfs_rmap_intent          *ri = ri_entry(item);
 
-       xfs_rmap_update_put_group(ri);
+       xfs_perag_intent_put(ri->ri_pag);
        kmem_cache_free(xfs_rmap_intent_cache, ri);
 }
 
@@ -496,7 +494,7 @@ xfs_rui_recover_work(
        ri->ri_bmap.br_blockcount = map->me_len;
        ri->ri_bmap.br_state = (map->me_flags & XFS_RMAP_EXTENT_UNWRITTEN) ?
                        XFS_EXT_UNWRITTEN : XFS_EXT_NORM;
-       xfs_rmap_update_get_group(mp, ri);
+       ri->ri_pag = xfs_perag_intent_get(mp, map->me_startblock);
 
        xfs_defer_add_item(dfp, &ri->ri_list);
 }
index 802e5119eacaab640dc4b4d25e955cc02aadd695..40d331555675ba348c60fa117db990f02ca249c5 100644 (file)
@@ -71,4 +71,8 @@ struct xfs_rud_log_item {
 extern struct kmem_cache       *xfs_rui_cache;
 extern struct kmem_cache       *xfs_rud_cache;
 
+struct xfs_rmap_intent;
+
+void xfs_rmap_defer_add(struct xfs_trans *tp, struct xfs_rmap_intent *ri);
+
 #endif /* __XFS_RMAP_ITEM_H__ */