From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796391725; b=2ZUfARIRqNlqf0CRD8xhCCOcCS+P+3zFVEwFm5bus12YZg9aJxSeAUMl8fDi32fryHqO elgOYByOcid8uonLe6kVLLgxpXXR/KKywY4yVrbF1FbUW0eQ7xjw+2HYLnKWidhNfLFz/ 6FKY58kX/2JLIbIzOg3l+wghoh3ZHBnEkufMwk1DMemnDUAIjwIKuH0Td+9FKx5n9uqKf dVihztG8nyWysdDbD8m6ldnMNtpjaMKrdwVAjwUueFZ+cHPJOvd5eY4JM0H+O6xjzPie8 ZzMbm2SYzwbDKvbFVbjeXYvKsDCMCXMk0rvfO4VWogD85VttewyS9cCsVAnGAaZDtEw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796391725; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=13vKkZaq7SUNcycbqPmsCbmVJOeLo6sdZgIEGxfGUqw=; b=YdWMRdlq2jFE2ef9qWVZkCyfGdrl5nxuyLaRN+7ZIYOvjdZXIzoWAPyVVaNDjiy8erBR ixZK10BRD0khWc3PCXhxSrSK+TKjvdvoVNl6+oa+/iISZYhrEg9x9gk6coDkq7cr9zWoS m+Ewot/jlmg0837UoqdsXi9FJbnFXSFBHYlUDlVuO18nADVB4gA03zUwb8Gw+EBhEqey+ Tgi8fi7ukCnu4wZOhGLBBRX5t9I6LveBaqw5H8zpTbBlLxiw6VwwXzNQ8SDpVFWgC0b9t 6qlZaDSq4yV5ciFk35Bb+B+/cBOtsxtnx1uagaKsXAIvJeWh/fMF/btD4nWZ0Pc22Sw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hAKq2klu; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0520E606A322 for ; Fri, 4 Dec 2026 13:42:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hAKq2klu Received: by smtp.kernel.org (Postfix) with ESMTPSA id 727AA1F00897; Fri, 4 Dec 2026 13:42:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796391724; bh=13vKkZaq7SUNcycbqPmsCbmVJOeLo6sdZgIEGxfGUqw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=hAKq2kluAOv/NRCHcVrtQ5nInFRVWRSlKUY15y1r1pIyw0UqDNS+GLYgXCFg5G5Qx T4z9cXmVi/nakh/GafUa3E+9dIde6xISeb/LWoVNbWMDolnsOxa3B6tk65DZHbjRMW 1YSk7i105eKzPXtgbS3hOll6fbjKKacF19+vLohJ/bH+HOJb6iYn4BSXs2oQ5IIk2i PrHFW7MUbQpDRdEAeP9OqZ+5swZ8y1RlhQpKGB/ru1V7O2TE/TNo7kMfSH3sIsmxfs KM8FK+q3ZkSfRbpjSyfcWqtOqKjox9Qww0VYGxTE3+yQs+YugZbbuvUS8O0v3B//9I 1SQ+hPTOYZ/sQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] ext4: stop walking the whole fsmap meta_list for every extent Reply-To: sashiko-reviews@lists.linux.dev To: "Jyun-An Chen" , linux-ext4@vger.kernel.org Cc: tytso@mit.edu In-Reply-To: <20261204132915.73095-1-jun930436@gmail.com> References: <20261204132915.73095-1-jun930436@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 13:42:04 +0000 X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list > ext4_getfsmap_datadev_helper() is called once per free extent and > ext4_getfsmap_meta_helper() once per block group that starts with used > blocks. Both walk the entire remaining gfi_meta_list on every call, > although the list is sorted by fmr_physical (list_sort() in > ext4_getfsmap_find_fixed_metadata(), and entries are only ever removed > afterwards). A GETFSMAP query therefore costs > O(free extents * fixed metadata extents). >=20 > For example, a 4 TiB filesystem (default mkfs, flex_bg=3D16) has 6210 > merged fixed metadata extents; with 200k free-space fragments near the > start of the device, a single GETFSMAP call returns 408k records. > GETFSMAP needs no privileges. >=20 > Stop each walk at the first extent that starts beyond both the current > range (fsb for the free-extent case, fs_end for the metadata case) and > gfi_next_fsblk. Because the list is sorted, no later extent can satisfy > either branch, and since neither branch runs again, gfi_next_fsblk and > the local fsb cannot change for the rest of the walk. The output is > therefore unchanged. >=20 > Time for one GETFSMAP call returning all records, measured in QEMU > (TCG, arm64) with and without this patch: >=20 > image before after > 4 TiB, 200k free fragments near start 92.7 s 3.6 s > 1 TiB, 200k free fragments near start 3.6 s 0.94 s > 4 TiB, mostly allocated (meta_helper) 17.2 s 13.0 s >=20 > Assisted-by: Claude Code:claude-opus-5-5 > Signed-off-by: Jyun-An Chen Sashiko has reviewed this patch and found no issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204132915.7309= 5-1-jun930436@gmail.com?part=3D1