]> www.infradead.org Git - users/hch/misc.git/commitdiff
xfs: store rtgroup information with a bmap intent
authorDarrick J. Wong <djwong@kernel.org>
Wed, 29 May 2024 04:11:21 +0000 (21:11 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 24 Jul 2024 05:33:38 +0000 (22:33 -0700)
Make the bmap intent items take an active reference to the rtgroup
containing the space that is being mapped or unmapped.  We will need
this functionality once we start enabling rmap and reflink on the rt
volume.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/libxfs/xfs_bmap.h
fs/xfs/xfs_bmap_item.c

index 7592d46e97c661136e53978e0052d7f7caa799b8..eb3670ecd1373fad6c0ab07f925d1f2d6979e3aa 100644 (file)
@@ -248,7 +248,10 @@ struct xfs_bmap_intent {
        enum xfs_bmap_intent_type               bi_type;
        int                                     bi_whichfork;
        struct xfs_inode                        *bi_owner;
-       struct xfs_perag                        *bi_pag;
+       union {
+               struct xfs_perag                *bi_pag;
+               struct xfs_rtgroup              *bi_rtg;
+       };
        struct xfs_bmbt_irec                    bi_bmap;
 };
 
index e224b49b7cff6d6274c9c4611f6d4166185bc831..9a7e97a922b6d377afec086560bc4e302b497582 100644 (file)
@@ -26,6 +26,7 @@
 #include "xfs_log_recover.h"
 #include "xfs_ag.h"
 #include "xfs_trace.h"
+#include "xfs_rtgroup.h"
 
 struct kmem_cache      *xfs_bui_cache;
 struct kmem_cache      *xfs_bud_cache;
@@ -324,8 +325,18 @@ xfs_bmap_update_get_group(
        struct xfs_mount        *mp,
        struct xfs_bmap_intent  *bi)
 {
-       if (xfs_ifork_is_realtime(bi->bi_owner, bi->bi_whichfork))
+       if (xfs_ifork_is_realtime(bi->bi_owner, bi->bi_whichfork)) {
+               if (xfs_has_rtgroups(mp)) {
+                       xfs_rgnumber_t  rgno;
+
+                       rgno = xfs_rtb_to_rgno(mp, bi->bi_bmap.br_startblock);
+                       bi->bi_rtg = xfs_rtgroup_get(mp, rgno);
+               } else {
+                       bi->bi_rtg = NULL;
+               }
+
                return;
+       }
 
        /*
         * Bump the intent count on behalf of the deferred rmap and refcount
@@ -354,8 +365,11 @@ static inline void
 xfs_bmap_update_put_group(
        struct xfs_bmap_intent  *bi)
 {
-       if (xfs_ifork_is_realtime(bi->bi_owner, bi->bi_whichfork))
+       if (xfs_ifork_is_realtime(bi->bi_owner, bi->bi_whichfork)) {
+               if (xfs_has_rtgroups(bi->bi_owner->i_mount))
+                       xfs_rtgroup_put(bi->bi_rtg);
                return;
+       }
 
        xfs_perag_intent_put(bi->bi_pag);
 }