All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Carlos Maiolino <cem@kernel.org>
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH] libxfs: deferred items should call xfs_perag_intent_{get,put}
Date: Fri, 9 Jun 2023 08:14:20 -0700	[thread overview]
Message-ID: <20230609151420.GZ1325469@frogsfrogsfrogs> (raw)

From: Darrick J. Wong <djwong@kernel.org>

Make the intent item _get_group and _put_group functions call
xfs_perag_intent_{get,put} to match the kernel.  In userspace they're
the same thing so this makes no difference.  However, let's not leave
unnecessary discrepancies with the kernel code.

Fixes: 7cb26322f74 ("xfs: allow queued AG intents to drain before scrubbing")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 libxfs/defer_item.c |   42 ++++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c
index dc00d6d671d..6c5c7dd5677 100644
--- a/libxfs/defer_item.c
+++ b/libxfs/defer_item.c
@@ -70,7 +70,7 @@ xfs_extent_free_create_done(
 	return NULL;
 }
 
-/* Take a passive ref to the AG containing the space we're freeing. */
+/* Take an active ref to the AG containing the space we're freeing. */
 void
 xfs_extent_free_get_group(
 	struct xfs_mount		*mp,
@@ -79,15 +79,15 @@ xfs_extent_free_get_group(
 	xfs_agnumber_t			agno;
 
 	agno = XFS_FSB_TO_AGNO(mp, xefi->xefi_startblock);
-	xefi->xefi_pag = xfs_perag_get(mp, agno);
+	xefi->xefi_pag = xfs_perag_intent_get(mp, agno);
 }
 
-/* Release a passive AG ref after some freeing work. */
+/* Release an active AG ref after some freeing work. */
 static inline void
 xfs_extent_free_put_group(
 	struct xfs_extent_free_item	*xefi)
 {
-	xfs_perag_put(xefi->xefi_pag);
+	xfs_perag_intent_put(xefi->xefi_pag);
 }
 
 /* Process a free extent. */
@@ -104,6 +104,7 @@ xfs_extent_free_finish_item(
 	int				error;
 
 	xefi = container_of(item, struct xfs_extent_free_item, xefi_list);
+
 	oinfo.oi_owner = xefi->xefi_owner;
 	if (xefi->xefi_flags & XFS_EFI_ATTR_FORK)
 		oinfo.oi_flags |= XFS_OWNER_INFO_ATTR_FORK;
@@ -166,6 +167,7 @@ xfs_agfl_free_finish_item(
 	xfs_agblock_t			agbno;
 
 	xefi = container_of(item, struct xfs_extent_free_item, xefi_list);
+
 	ASSERT(xefi->xefi_blockcount == 1);
 	agbno = XFS_FSB_TO_AGBNO(mp, xefi->xefi_startblock);
 	oinfo.oi_owner = xefi->xefi_owner;
@@ -232,7 +234,7 @@ xfs_rmap_update_create_done(
 	return NULL;
 }
 
-/* Take a passive ref to the AG containing the space we're rmapping. */
+/* Take an active ref to the AG containing the space we're rmapping. */
 void
 xfs_rmap_update_get_group(
 	struct xfs_mount	*mp,
@@ -241,15 +243,15 @@ xfs_rmap_update_get_group(
 	xfs_agnumber_t	agno;
 
 	agno = XFS_FSB_TO_AGNO(mp, ri->ri_bmap.br_startblock);
-	ri->ri_pag = xfs_perag_get(mp, agno);
+	ri->ri_pag = xfs_perag_intent_get(mp, agno);
 }
 
-/* Release a passive AG ref after finishing rmapping work. */
+/* Release an active AG ref after finishing rmapping work. */
 static inline void
 xfs_rmap_update_put_group(
 	struct xfs_rmap_intent	*ri)
 {
-	xfs_perag_put(ri->ri_pag);
+	xfs_perag_intent_put(ri->ri_pag);
 }
 
 /* Process a deferred rmap update. */
@@ -344,7 +346,7 @@ xfs_refcount_update_create_done(
 	return NULL;
 }
 
-/* Take a passive ref to the AG containing the space we're refcounting. */
+/* Take an active ref to the AG containing the space we're refcounting. */
 void
 xfs_refcount_update_get_group(
 	struct xfs_mount		*mp,
@@ -353,15 +355,15 @@ xfs_refcount_update_get_group(
 	xfs_agnumber_t			agno;
 
 	agno = XFS_FSB_TO_AGNO(mp, ri->ri_startblock);
-	ri->ri_pag = xfs_perag_get(mp, agno);
+	ri->ri_pag = xfs_perag_intent_get(mp, agno);
 }
 
-/* Release a passive AG ref after finishing refcounting work. */
+/* Release an active AG ref after finishing refcounting work. */
 static inline void
 xfs_refcount_update_put_group(
 	struct xfs_refcount_intent	*ri)
 {
-	xfs_perag_put(ri->ri_pag);
+	xfs_perag_intent_put(ri->ri_pag);
 }
 
 /* Process a deferred refcount update. */
@@ -461,7 +463,7 @@ xfs_bmap_update_create_done(
 	return NULL;
 }
 
-/* Take a passive ref to the AG containing the space we're mapping. */
+/* Take an active ref to the AG containing the space we're mapping. */
 void
 xfs_bmap_update_get_group(
 	struct xfs_mount	*mp,
@@ -470,15 +472,23 @@ xfs_bmap_update_get_group(
 	xfs_agnumber_t		agno;
 
 	agno = XFS_FSB_TO_AGNO(mp, bi->bi_bmap.br_startblock);
-	bi->bi_pag = xfs_perag_get(mp, agno);
+
+	/*
+	 * Bump the intent count on behalf of the deferred rmap and refcount
+	 * intent items that that we can queue when we finish this bmap work.
+	 * This new intent item will bump the intent count before the bmap
+	 * intent drops the intent count, ensuring that the intent count
+	 * remains nonzero across the transaction roll.
+	 */
+	bi->bi_pag = xfs_perag_intent_get(mp, agno);
 }
 
-/* Release a passive AG ref after finishing mapping work. */
+/* Release an active 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);
+	xfs_perag_intent_put(bi->bi_pag);
 }
 
 /* Process a deferred rmap update. */

                 reply	other threads:[~2023-06-09 15:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230609151420.GZ1325469@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=cem@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.