]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs: give xfs_bmap_intent its own perag reference
authorDarrick J. Wong <djwong@kernel.org>
Fri, 26 May 2023 13:16:03 +0000 (15:16 +0200)
committerCarlos Maiolino <cem@kernel.org>
Fri, 9 Jun 2023 08:27:28 +0000 (10:27 +0200)
Source kernel commit: 774a99b47b588bf0bd9f65d3b241d5bba0b2fcb0

Give the xfs_bmap_intent an active reference to the perag structure
data.  This reference will be used to enable scrub intent draining
functionality in subsequent patches.  Later, shrink will use these
passive references to know if an AG is quiesced or not.

The reason why we take a passive ref for a file mapping operation is
simple: we're committing to some sort of action involving space in an
AG, so we want to indicate our interest in that AG.  The space is
already allocated, so we need to be able to operate on AGs that are
offline or being shrunk.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
libxfs/defer_item.c
libxfs/xfs_bmap.c
libxfs/xfs_bmap.h

index 285dc9a35d71720fa803b6e5241de43528c5a536..3dbcf11634eb19a80da6761a96768d494c728489 100644 (file)
@@ -390,6 +390,26 @@ xfs_bmap_update_create_done(
        return NULL;
 }
 
+/* Take a passive ref to the AG containing the space we're mapping. */
+void
+xfs_bmap_update_get_group(
+       struct xfs_mount        *mp,
+       struct xfs_bmap_intent  *bi)
+{
+       xfs_agnumber_t          agno;
+
+       agno = XFS_FSB_TO_AGNO(mp, bi->bi_bmap.br_startblock);
+       bi->bi_pag = xfs_perag_get(mp, agno);
+}
+
+/* Release a passive AG ref after finishing mapping work. */
+static inline void
+xfs_bmap_update_put_group(
+       struct xfs_bmap_intent  *bi)
+{
+       xfs_perag_put(bi->bi_pag);
+}
+
 /* Process a deferred rmap update. */
 STATIC int
 xfs_bmap_update_finish_item(
@@ -407,6 +427,8 @@ xfs_bmap_update_finish_item(
                ASSERT(bi->bi_type == XFS_BMAP_UNMAP);
                return -EAGAIN;
        }
+
+       xfs_bmap_update_put_group(bi);
        kmem_cache_free(xfs_bmap_intent_cache, bi);
        return error;
 }
@@ -426,6 +448,8 @@ xfs_bmap_update_cancel_item(
        struct xfs_bmap_intent          *bi;
 
        bi = container_of(item, struct xfs_bmap_intent, bi_list);
+
+       xfs_bmap_update_put_group(bi);
        kmem_cache_free(xfs_bmap_intent_cache, bi);
 }
 
index 76591d077661205d4167608ffdd19f235c9e4cdf..4a7f3d280eadbe70b8f3c2c2cea2fb230aec68ff 100644 (file)
@@ -6068,6 +6068,7 @@ __xfs_bmap_add(
        bi->bi_whichfork = whichfork;
        bi->bi_bmap = *bmap;
 
+       xfs_bmap_update_get_group(tp->t_mountp, bi);
        xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_BMAP, &bi->bi_list);
        return 0;
 }
index dd08361ca5a6998981991ec53d85926395bb598a..e5a492027aea56acb43fb75426d5718152035800 100644 (file)
@@ -238,9 +238,13 @@ struct xfs_bmap_intent {
        enum xfs_bmap_intent_type               bi_type;
        int                                     bi_whichfork;
        struct xfs_inode                        *bi_owner;
+       struct xfs_perag                        *bi_pag;
        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);