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 v4 0/2] xfs: optimize getfsmap by reusing and advancing the refcount cursor
Date: Wed, 2 Dec 2026 09:21:50 +0800 [thread overview]
Message-ID: <20261202012152.3846288-1-zhangshida2026@163.com> (raw)
From: Shida Zhang <zhangshida@kylinos.cn>
GETFSMAP walks the rmap btree in increasing startblock order and asks
the refcount btree whether each record's blocks are shared. Every
record pays a cursor alloc/free and a root-to-leaf btree search, even
though the next query is almost always the next refcount record.
This series keeps one refcount cursor per group, positions it once, and
advances it with xfs_btree_increment() as the rmap walk moves forward.
Patch 1 factors out the cursor cleanup so patch 2 can add the cached
refcount cursor without duplicating it.
Measured with a kernel-isolated FS_IOC_GETFSMAP loop over the whole data
device (3000 reflinked 256KB files, mkfs -m rmapbt=1,reflink=1 -d
agcount=4, Kunpeng 920 + NVMe), mean of three interleaved A/B runs:
original this series
walk time 3040 us 335 us (9.1x)
xfs_btree_lookup 11.9% ~0% (% of cycles)
The full fsmap output is byte-identical before and after (6421 records).
---
v4:
- the advance loop breaks out at the first COW record instead of
iterating through the COW section (hch); output unchanged
- del_cursors final alignment placed in the prep patch (no churn)
- shortened the rc_done comment and wrapped a long line
v3: https://lore.kernel.org/linux-xfs/20261201074947.3338021-1-zhangshida2026@163.com/
v2: https://lore.kernel.org/linux-xfs/20261126013009.533557-1-zhangshida2026@163.com/
v1: https://lore.kernel.org/linux-xfs/20261123075048.3658960-1-zhangshida@kylinos.cn/
Testing (7.3.4, Kunpeng 920 + NVMe, mkfs -m rmapbt=1,reflink=1):
- data fsmap byte-identical base vs series (6421 records)
- with COW records present (reflink + COW writes), fsmap is
byte-identical base vs series (245 records)
- realtime reflink (rtrefcountbt) path exercised: fsmap over a reflinked
realtime volume is byte-identical, 1000 shared records
- full xfstests -g auto: 1166 tests run; the 29 failures are
pre-existing/environmental (none use fsmap) and match the
unpatched base kernel exactly
Shida Zhang (2):
xfs: factor out a xfs_getfsmap_del_cursors helper
xfs: optimize getfsmap by reusing and advancing the refcount cursor
fs/xfs/xfs_fsmap.c | 146 +++++++++++++++++++++++++++++++++++++--------
1 file changed, 121 insertions(+), 25 deletions(-)
--
2.34.1
next reply other threads:[~2026-12-02 1:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 1:21 zhangshida2026 [this message]
2026-12-02 1:21 ` [PATCH v4 1/2] xfs: factor out a xfs_getfsmap_del_cursors helper zhangshida2026
2026-12-02 1:21 ` [PATCH v4 2/2] xfs: optimize getfsmap by reusing and advancing the refcount cursor zhangshida2026
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=20261202012152.3846288-1-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®