From: cem@kernel.org
To: linux-xfs@vger.kernel.org
Cc: david@fromorbit.com, hch@lst.de, djwong@kernel.org
Subject: [PATCH 3/3] xfs: remove owner field from xfs_extent_busy
Date: Tue, 10 Mar 2026 13:33:16 +0100 [thread overview]
Message-ID: <20260310123324.339310-4-cem@kernel.org> (raw)
In-Reply-To: <20260310123324.339310-1-cem@kernel.org>
From: Carlos Maiolino <cem@kernel.org>
Now that xfs_busy_extents is not embedded into a cil context, we can
get rid of the owner field.
The struct will be freed upon a call to xfs_discard_extents(), whether
at IO completion or by direct calling xfs_discard_endio_work().
What reamains is xlog_cil_commited now being responsible for freeing
the context itself.
Worth mentioning that the busy extents still need to be manually freed
during filesystem shutdown via xlog_cil_destroy() if there is a
remaining context there.
Also, xlog_cil_committed() now unconditionally calls xfs_discard_extents.
This seems safe because it can handle an empty list, and as a bonus,
it will call xfs_discard_endio_work() for such case, without any extra
wiring needed to free the busy extents list in case it is empty.
xfs_discard_endio_work() is also able to properly handle the empty list.
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
fs/xfs/xfs_discard.c | 4 ----
fs/xfs/xfs_extent_busy.h | 7 -------
fs/xfs/xfs_log_cil.c | 13 ++++---------
3 files changed, 4 insertions(+), 20 deletions(-)
diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
index 2db0ea6eedc6..be4bc16dc85c 100644
--- a/fs/xfs/xfs_discard.c
+++ b/fs/xfs/xfs_discard.c
@@ -85,7 +85,6 @@ xfs_discard_endio_work(
container_of(work, struct xfs_busy_extents, endio_work);
xfs_extent_busy_clear(&extents->extent_list, false);
- kfree(extents->owner);
xfs_busy_extents_free(extents);
}
@@ -356,8 +355,6 @@ xfs_trim_perag_extents(
break;
}
- extents->owner = extents;
-
error = xfs_trim_gather_extents(pag, &tcur, extents);
if (error) {
xfs_busy_extents_free(extents);
@@ -697,7 +694,6 @@ xfs_trim_rtgroup_extents(
tr.queued = 0;
tr.batch = XFS_DISCARD_MAX_EXAMINE;
- tr.extents->owner = tr.extents;
xfs_rtgroup_lock(rtg, XFS_RTGLOCK_BITMAP_SHARED);
error = xfs_rtalloc_query_range(rtg, tp, low, high,
diff --git a/fs/xfs/xfs_extent_busy.h b/fs/xfs/xfs_extent_busy.h
index 699f97a53530..5deaa1fbe378 100644
--- a/fs/xfs/xfs_extent_busy.h
+++ b/fs/xfs/xfs_extent_busy.h
@@ -34,13 +34,6 @@ struct xfs_extent_busy {
struct xfs_busy_extents {
struct list_head extent_list;
struct work_struct endio_work;
-
- /*
- * Owner is the object containing the struct xfs_busy_extents to free
- * once the busy extents have been processed. If only the
- * xfs_busy_extents object needs freeing, then point this at itself.
- */
- void *owner;
};
static inline struct xfs_busy_extents *
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index bb71b5ad6b55..befc2691f053 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -976,6 +976,7 @@ xlog_cil_committed(
struct xfs_cil_ctx *ctx)
{
struct xfs_mount *mp = ctx->cil->xc_log->l_mp;
+ struct xfs_busy_extents *busy_extents = ctx->busy_extents;
bool abort = xlog_is_shutdown(ctx->cil->xc_log);
/*
@@ -994,8 +995,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(&busy_extents->extent_list);
+ xfs_extent_busy_clear(&busy_extents->extent_list,
xfs_has_discard(mp) && !abort);
spin_lock(&ctx->cil->xc_push_lock);
@@ -1004,13 +1005,7 @@ 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);
- return;
- }
-
- xfs_busy_extents_free(ctx->busy_extents);
+ xfs_discard_extents(mp, busy_extents);
kfree(ctx);
}
--
2.53.0
next prev 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 ` [PATCH 2/3] xfs: convert busy_extents list to a pointer within cil context cem
2026-03-10 13:04 ` Christoph Hellwig
2026-03-10 12:33 ` cem [this message]
2026-03-10 13:06 ` [PATCH 3/3] xfs: remove owner field from xfs_extent_busy 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-4-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox