xfs: move xfs_bmap_defer_add to xfs_bmap_item.c
authorDarrick J. Wong <djwong@kernel.org>
Thu, 22 Feb 2024 20:44:21 +0000 (12:44 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 22 Feb 2024 20:44:21 +0000 (12:44 -0800)
Move the code that adds the incore xfs_bmap_item deferred work data to a
transaction live with the BUI log item code.  This means that the file
mapping code no longer has to know about the inner workings of the BUI
log items.

As a consequence, we can hide the _get_group helper.

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

index b90a903052165c183c117ee4fbe8b9ef084b0d25..fb99b75f02e23977bc37f851b128acc788c1b534 100644 (file)
@@ -37,6 +37,7 @@
 #include "xfs_icache.h"
 #include "xfs_iomap.h"
 #include "xfs_health.h"
+#include "xfs_bmap_item.h"
 
 struct kmem_cache              *xfs_bmap_intent_cache;
 
@@ -6198,10 +6199,7 @@ __xfs_bmap_add(
        bi->bi_whichfork = whichfork;
        bi->bi_bmap = *bmap;
 
-       trace_xfs_bmap_defer(bi);
-
-       xfs_bmap_update_get_group(tp->t_mountp, bi);
-       xfs_defer_add(tp, &bi->bi_list, &xfs_bmap_update_defer_type);
+       xfs_bmap_defer_add(tp, bi);
        return 0;
 }
 
index 0a2fd9304d1c50617d3049887cb205ac5e19de86..325cc232a4153df49d8a83e6df0f0cad5529be92 100644 (file)
@@ -245,9 +245,6 @@ struct xfs_bmap_intent {
        struct xfs_bmbt_irec                    bi_bmap;
 };
 
-void xfs_bmap_update_get_group(struct xfs_mount *mp,
-               struct xfs_bmap_intent *bi);
-
 int    xfs_bmap_finish_one(struct xfs_trans *tp, struct xfs_bmap_intent *bi);
 void   xfs_bmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip,
                struct xfs_bmbt_irec *imap);
index 8df5e370c0bb4a68e78cba9e09ff3f8bae91d734..a47cbce36482d780efedb25a352325e0ed8bb9da 100644 (file)
@@ -25,6 +25,7 @@
 #include "xfs_log_priv.h"
 #include "xfs_log_recover.h"
 #include "xfs_ag.h"
+#include "xfs_trace.h"
 
 struct kmem_cache      *xfs_bui_cache;
 struct kmem_cache      *xfs_bud_cache;
@@ -316,7 +317,7 @@ xfs_bmap_update_create_done(
 }
 
 /* Take a passive ref to the AG containing the space we're mapping. */
-void
+static inline void
 xfs_bmap_update_get_group(
        struct xfs_mount        *mp,
        struct xfs_bmap_intent  *bi)
@@ -335,6 +336,18 @@ xfs_bmap_update_get_group(
        bi->bi_pag = xfs_perag_intent_get(mp, agno);
 }
 
+/* Add this deferred BUI to the transaction. */
+void
+xfs_bmap_defer_add(
+       struct xfs_trans        *tp,
+       struct xfs_bmap_intent  *bi)
+{
+       trace_xfs_bmap_defer(bi);
+
+       xfs_bmap_update_get_group(tp->t_mountp, bi);
+       xfs_defer_add(tp, &bi->bi_list, &xfs_bmap_update_defer_type);
+}
+
 /* Release a passive AG ref after finishing mapping work. */
 static inline void
 xfs_bmap_update_put_group(
index 3fafd3881a0bb2f372694e4680c7e28a2dc3ca13..6fee6a5083436b83a2dc5d92566b47ff57ca1a93 100644 (file)
@@ -68,4 +68,8 @@ struct xfs_bud_log_item {
 extern struct kmem_cache       *xfs_bui_cache;
 extern struct kmem_cache       *xfs_bud_cache;
 
+struct xfs_bmap_intent;
+
+void xfs_bmap_defer_add(struct xfs_trans *tp, struct xfs_bmap_intent *bi);
+
 #endif /* __XFS_BMAP_ITEM_H__ */