Linux XFS filesystem development
 help / color / mirror / Atom feed
* [PATCH v3 0/2] xfs: optimize getfsmap by reusing and advancing the refcount cursor
@ 2026-12-01  7:49 zhangshida2026
  2026-12-01  7:49 ` [PATCH v3 1/2] xfs: factor out a xfs_getfsmap_del_cursors helper zhangshida2026
  2026-12-01  7:49 ` [PATCH v3 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-01  7:49 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           3016 us     330 us   (9.1x)
  xfs_btree_lookup    10.9%       ~0%      (% of cycles)

The full fsmap output is byte-identical before and after (6421 records).

---

v3:
 - the advance loop now stops at COW records to match
   xfs_refcount_find_shared() exactly (v2 could skip them)
 - removed Suggested-by
 - renamed rc_eof -> rc_done
 - dropped the summary-only init-helper comment and the single-use
   aglen and cur locals; del_cursors uses a local error flag
 - re-measured with the COW fix

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 | 144 +++++++++++++++++++++++++++++++++++++--------
 1 file changed, 119 insertions(+), 25 deletions(-)

-- 
2.34.1


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

end of thread, other threads:[~2026-12-01  8:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  7:49 [PATCH v3 0/2] xfs: optimize getfsmap by reusing and advancing the refcount cursor zhangshida2026
2026-12-01  7:49 ` [PATCH v3 1/2] xfs: factor out a xfs_getfsmap_del_cursors helper zhangshida2026
2026-12-01  7:49 ` [PATCH v3 2/2] xfs: optimize getfsmap by reusing and advancing the refcount cursor zhangshida2026
2026-12-01  8:31   ` Christoph Hellwig

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