From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796174552; b=0SqmJ5RoZUjv/uDh+8pbm/hHuPQo60O9RCoiSWGwUiCW8EW1EIMI4kvbCxbIvbxKd9XN 7ozKRnMy5ozgiVV8uyjcv4cX4qdB58q8pi6k4rUEHNIbNeHVncFbDPdFSrDLhrU6StQst 8+QIYSB1uSsahsbAnVn2UpvkHwOjRoC2k2GcwFujSlnCpYYnuwDgnRe4Q4vJgoxpvPaPM +5ft9lAeCcqE7ww86aDFEE2uweEO+Lvq6oFaCeUf0j3FOnQbDCNU+m2RvPlB1OayoRK4Y mUjh8z2VM+sv/H3zP5Wz2QQ10p452C2T/6O2BWEDc3j5Xt+Co37cFSPyYnaDgejAHZg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796174552; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-CM-TRANSID:X-Coremail-Antispam:X-CM-SenderInfo; bh=u10vcl+VlB6ZeShROkDDfig4cajrpqOC9SE1qRfjLx0=; b=qRaqjTXRUarkLr05IrJTLUWWM+P91LHe7vLPlRSqp+wFANsLjrA4MuMzmwzyf4zC+Npf c111y+Z12UZmz3kJPI9KRi1isd+Y15O6ikdSN/qzmo3BJNdgWMhP73oWePHcln59SqFAv R0m44TaK3KbZEjnr0nWvU3m3w/LQXE46EAXZJHO/u518LdySJVM0M2Z1W7lkVtPSmwp8u yJAPnafQMAqAOu8paPpqITM11H/fpp87KyfVmipRYbrRKTATtjZtcc4BF2AVMqgU2rCah +Blcap0+Huye87/1vfylTnBKGZ1r+zYJ6YPt8zcspdG95hzhqAngnvgbzRtSVNJS8yQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=cNdKe1xB; arc=none smtp.remote-ip=117.135.210.4 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5B9D606A339; Wed, 2 Dec 2026 01:22:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B5B9D606A339 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=cNdKe1xB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=u1 0vcl+VlB6ZeShROkDDfig4cajrpqOC9SE1qRfjLx0=; b=cNdKe1xBXtafz+oX4J 08cCRtkXYAHAYAHo82DUZq427Lg1x0tzEqKLzz2zjmjBVZjnfFpH6l2QETrdKuHj vG8lYmkUB3UQCWWjeswwlruI1ia8D3Jg/Kni7lCwcxgfkUBhemgXQvzRrbByiiMJ GxjUPds8Z4iSBcEm0cZrgTR6c= Received: from localhost.localdomain (unknown []) by gzsmtp4 (Coremail) with SMTP id PygvCgD376Owcg9rCSiYJQ--.18561S2; Wed, 02 Dec 2026 09:21:54 +0800 (CST) From: zhangshida2026@163.com To: Carlos Maiolino Cc: "Darrick J . Wong" , Christoph Hellwig , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, zhangshida2026@163.com, Shida Zhang Subject: [PATCH v4 0/2] xfs: optimize getfsmap by reusing and advancing the refcount cursor Date: Wed, 2 Dec 2026 09:21:50 +0800 Message-Id: <20261202012152.3846288-1-zhangshida2026@163.com> X-Mailer: git-send-email 2.25.1 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:PygvCgD376Owcg9rCSiYJQ--.18561S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7ZryDCF4DZw1DGF4DJFyfXrb_yoW8KryUpr Z5Kr43Cw4Dt3WxZanakw12gF4Sq3y8Aa18Wr9xG3y7CFy7JryIvrn2gF15Za42kryxCr1F qw4q9ayYkFWktFDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zKjgshUUUUU= X-CM-SenderInfo: x2kd0wxvklvtasqslqqrwthudrp/xtbC6BJnc2sPcrKQKwAA3x From: Shida Zhang 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