From: zhangshida2026@163.com
To: Carlos Maiolino <cem@kernel.org>
Cc: "Darrick J . Wong" <djwong@kernel.org>,
Christoph Hellwig <hch@infradead.org>,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
zhangshida2026@163.com, Shida Zhang <zhangshida@kylinos.cn>
Subject: [PATCH v2 1/2] xfs: factor out a xfs_getfsmap_del_cursors helper
Date: Thu, 26 Nov 2026 09:30:08 +0800 [thread overview]
Message-ID: <20261126013009.533557-2-zhangshida2026@163.com> (raw)
In-Reply-To: <20261126013009.533557-1-zhangshida2026@163.com>
From: Shida Zhang <zhangshida@kylinos.cn>
The data and rt device getfsmap walkers open-code the same rmap btree
cursor deletion at group boundaries and at the end of the walk. Fold
it into a helper in preparation for caching a refcount cursor across
the walk.
No functional change.
Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Shida Zhang <zhangshida@kylinos.cn>
---
fs/xfs/xfs_fsmap.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c
index 041bb2105ec..fe9093c0987 100644
--- a/fs/xfs/xfs_fsmap.c
+++ b/fs/xfs/xfs_fsmap.c
@@ -202,6 +202,17 @@ xfs_getfsmap_dev_compare(
return d1->dev - d2->dev;
}
+/* Delete the btree cursors used by a getfsmap group walk. */
+static void
+xfs_getfsmap_del_cursors(
+ struct xfs_btree_cur *bt_cur,
+ int error)
+{
+ if (bt_cur)
+ xfs_btree_del_cursor(bt_cur, error < 0 ?
+ XFS_BTREE_ERROR : XFS_BTREE_NOERROR);
+}
+
/* Decide if this mapping is shared. */
STATIC int
xfs_getfsmap_is_shared(
@@ -545,7 +556,7 @@ __xfs_getfsmap_datadev(
}
if (bt_cur) {
- xfs_btree_del_cursor(bt_cur, XFS_BTREE_NOERROR);
+ xfs_getfsmap_del_cursors(bt_cur, 0);
bt_cur = NULL;
xfs_trans_brelse(tp, info->agf_bp);
info->agf_bp = NULL;
@@ -585,9 +596,7 @@ __xfs_getfsmap_datadev(
info->group = NULL;
}
- if (bt_cur)
- xfs_btree_del_cursor(bt_cur, error < 0 ? XFS_BTREE_ERROR :
- XFS_BTREE_NOERROR);
+ xfs_getfsmap_del_cursors(bt_cur, error);
if (info->agf_bp) {
xfs_trans_brelse(tp, info->agf_bp);
info->agf_bp = NULL;
@@ -989,7 +998,7 @@ xfs_getfsmap_rtdev_rmapbt(
xfs_rtgroup_unlock(to_rtg(bt_cur->bc_group),
XFS_RTGLOCK_RMAP |
XFS_RTGLOCK_REFCOUNT);
- xfs_btree_del_cursor(bt_cur, XFS_BTREE_NOERROR);
+ xfs_getfsmap_del_cursors(bt_cur, 0);
bt_cur = NULL;
}
@@ -1027,8 +1036,7 @@ xfs_getfsmap_rtdev_rmapbt(
if (bt_cur) {
xfs_rtgroup_unlock(to_rtg(bt_cur->bc_group),
XFS_RTGLOCK_RMAP | XFS_RTGLOCK_REFCOUNT);
- xfs_btree_del_cursor(bt_cur, error < 0 ? XFS_BTREE_ERROR :
- XFS_BTREE_NOERROR);
+ xfs_getfsmap_del_cursors(bt_cur, error);
}
/* loop termination case */
--
2.34.1
next prev parent reply other threads:[~2026-11-26 1:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 7:50 [PATCH] xfs: optimize getfsmap by reusing and advancing the refcount cursor Shida Zhang
2026-11-25 6:58 ` Christoph Hellwig
2026-11-26 1:30 ` [PATCH v2 0/2] " zhangshida2026
2026-11-26 1:30 ` zhangshida2026 [this message]
2026-11-30 12:39 ` [PATCH v2 1/2] xfs: factor out a xfs_getfsmap_del_cursors helper Christoph Hellwig
2026-11-26 1:30 ` [PATCH v2 2/2] xfs: optimize getfsmap by reusing and advancing the refcount cursor zhangshida2026
2026-11-30 12:51 ` 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=20261126013009.533557-2-zhangshida2026@163.com \
--to=zhangshida2026@163.com \
--cc=cem@kernel.org \
--cc=djwong@kernel.org \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=zhangshida@kylinos.cn \
/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
all inboxes | Powered by JetHome®