The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v4 0/2] xfs: optimize getfsmap by reusing and advancing the refcount cursor
@ 2026-12-02  1:21 zhangshida2026
  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
  0 siblings, 2 replies; 4+ messages in thread
From: zhangshida2026 @ 2026-12-02  1:21 UTC (permalink / raw)
  To: Carlos Maiolino
  Cc: Darrick J . Wong, Christoph Hellwig, linux-xfs, linux-kernel,
	zhangshida2026, Shida Zhang

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-02  7:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02  1:21 [PATCH v4 0/2] xfs: optimize getfsmap by reusing and advancing the refcount cursor zhangshida2026
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
2026-12-02  7:26   ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox