All of lore.kernel.org
 help / color / mirror / Atom feed
From: cem@kernel.org
To: linux-xfs@vger.kernel.org
Cc: david@fromorbit.com, hch@lst.de, djwong@kernel.org
Subject: [PATCH 2/3] xfs: convert busy_extents list to a pointer within cil context
Date: Tue, 10 Mar 2026 13:33:15 +0100	[thread overview]
Message-ID: <20260310123324.339310-3-cem@kernel.org> (raw)
In-Reply-To: <20260310123324.339310-1-cem@kernel.org>

From: Carlos Maiolino <cem@kernel.org>

Decouple the busy extents list from the cil context.

By having the object independently allocated, we can transfer
its ownership to the discard code.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
 fs/xfs/xfs_discard.c  |  1 +
 fs/xfs/xfs_log_cil.c  | 17 ++++++++++-------
 fs/xfs/xfs_log_priv.h |  2 +-
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
index f393be78dc46..2db0ea6eedc6 100644
--- a/fs/xfs/xfs_discard.c
+++ b/fs/xfs/xfs_discard.c
@@ -86,6 +86,7 @@ xfs_discard_endio_work(
 
 	xfs_extent_busy_clear(&extents->extent_list, false);
 	kfree(extents->owner);
+	xfs_busy_extents_free(extents);
 }
 
 /*
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index edc368938f30..bb71b5ad6b55 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -101,8 +101,8 @@ xlog_cil_ctx_alloc(void)
 	struct xfs_cil_ctx	*ctx;
 
 	ctx = kzalloc_obj(*ctx, GFP_KERNEL | __GFP_NOFAIL);
+	ctx->busy_extents = xfs_busy_extents_alloc(GFP_KERNEL | __GFP_NOFAIL);
 	INIT_LIST_HEAD(&ctx->committing);
-	INIT_LIST_HEAD(&ctx->busy_extents.extent_list);
 	INIT_LIST_HEAD(&ctx->log_items);
 	INIT_LIST_HEAD(&ctx->lv_chain);
 	INIT_WORK(&ctx->push_work, xlog_cil_push_work);
@@ -131,7 +131,7 @@ xlog_cil_push_pcp_aggregate(
 
 		if (!list_empty(&cilpcp->busy_extents)) {
 			list_splice_init(&cilpcp->busy_extents,
-					&ctx->busy_extents.extent_list);
+					&ctx->busy_extents->extent_list);
 		}
 		if (!list_empty(&cilpcp->log_items))
 			list_splice_init(&cilpcp->log_items, &ctx->log_items);
@@ -994,8 +994,8 @@ xlog_cil_committed(
 
 	xlog_cil_ail_insert(ctx, abort);
 
-	xfs_extent_busy_sort(&ctx->busy_extents.extent_list);
-	xfs_extent_busy_clear(&ctx->busy_extents.extent_list,
+	xfs_extent_busy_sort(&ctx->busy_extents->extent_list);
+	xfs_extent_busy_clear(&ctx->busy_extents->extent_list,
 			      xfs_has_discard(mp) && !abort);
 
 	spin_lock(&ctx->cil->xc_push_lock);
@@ -1004,12 +1004,13 @@ xlog_cil_committed(
 
 	xlog_cil_free_logvec(&ctx->lv_chain);
 
-	if (!list_empty(&ctx->busy_extents.extent_list)) {
-		ctx->busy_extents.owner = ctx;
-		xfs_discard_extents(mp, &ctx->busy_extents);
+	if (!list_empty(&ctx->busy_extents->extent_list)) {
+		ctx->busy_extents->owner = ctx;
+		xfs_discard_extents(mp, ctx->busy_extents);
 		return;
 	}
 
+	xfs_busy_extents_free(ctx->busy_extents);
 	kfree(ctx);
 }
 
@@ -1595,6 +1596,7 @@ xlog_cil_push_work(
 out_skip:
 	up_write(&cil->xc_ctx_lock);
 	xfs_log_ticket_put(new_ctx->ticket);
+	xfs_busy_extents_free(new_ctx->busy_extents);
 	kfree(new_ctx);
 	memalloc_nofs_restore(nofs_flags);
 	return;
@@ -2058,6 +2060,7 @@ xlog_cil_destroy(
 	if (cil->xc_ctx) {
 		if (cil->xc_ctx->ticket)
 			xfs_log_ticket_put(cil->xc_ctx->ticket);
+		xfs_busy_extents_free(cil->xc_ctx->busy_extents);
 		kfree(cil->xc_ctx);
 	}
 
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h
index cf1e4ce61a8c..b0f9923f30cc 100644
--- a/fs/xfs/xfs_log_priv.h
+++ b/fs/xfs/xfs_log_priv.h
@@ -240,7 +240,7 @@ struct xfs_cil_ctx {
 	struct xlog_in_core	*commit_iclog;
 	struct xlog_ticket	*ticket;	/* chkpt ticket */
 	atomic_t		space_used;	/* aggregate size of regions */
-	struct xfs_busy_extents	busy_extents;
+	struct xfs_busy_extents	*busy_extents;
 	struct list_head	log_items;	/* log items in chkpt */
 	struct list_head	lv_chain;	/* logvecs being pushed */
 	struct list_head	iclog_entry;
-- 
2.53.0


  parent reply	other threads:[~2026-03-10 12:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10 12:33 [PATCH 0/3] Decouple busy_extents from cil context cem
2026-03-10 12:33 ` [PATCH 1/3] xfs: add a couple helpers to alloc/free xfs_busy_extents cem
2026-03-10 13:03   ` Christoph Hellwig
2026-03-10 12:33 ` cem [this message]
2026-03-10 13:04   ` [PATCH 2/3] xfs: convert busy_extents list to a pointer within cil context Christoph Hellwig
2026-03-10 12:33 ` [PATCH 3/3] xfs: remove owner field from xfs_extent_busy cem
2026-03-10 13:06   ` Christoph Hellwig

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=20260310123324.339310-3-cem@kernel.org \
    --to=cem@kernel.org \
    --cc=david@fromorbit.com \
    --cc=djwong@kernel.org \
    --cc=hch@lst.de \
    --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.