Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.100 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796119668; b=EXoCq4zKmT7Zj39g8lZqjgH33/zSuirDJ9p3/1n6dRdYZY29wZE2rYjeme0fHKjwXERs ISfWmoLGb2GuxCi2CuKGijLdhsnoQewj+v1GebkiU4c+F0ktLp06HKnVrPe5USSzGVT+F A7UfzcuOoxtEqDZ9AN+Hgl2pzi420oyF4T6n6nQuaz7sXKX7ZMq2OrSQwQ8gFA4ylhq2d yht1UHdazagm5ZaE+mHGdmNesIH9DDPC9o37Ab5y+x9gS6aA0da5Cs07jDMMT3ZOCE/hx Heuse/eX6Pohy1ZkopZf1ZwqHc2jVWZ4YxwIgSS4BEoMuzOAXH8eB4xzZ2zR1TGRPfQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796119668; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc: Subject:Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=CG/ouoBDFxorfmrbknPe7LvSuVmjQuRCE0L20ntPsas=; b=sb4iLdIUtRVhZ2uBPTn0ZA1euRyDsUfNUAdFJUeAa4B/N7+iGcklHJ0CbA+AWY/kticM MvLs2cON6HDNeMMatb6PkUJX9CQ5GRRuJZBZIuuqBvKHhlOdXFYd3AYoX/aZTG6kfqilV 8F7FlsHkzm+QgJt2oxm/Fnn6Zl1L3/k1KZThb8aE0ZpshYvl7qnbtBcm0Z11hrcIhVZnd cpaMO5of/3S0h45f6cU+hS7/UxOYXQfcTHc+Sq8NhFtNM7idxWOf37I8HOymv0jbjHAyP sy0jJmzF9nvGgaVGsFOuvBqVMyHy1G4/i8PfP1AQCoBieJ4BYqBe9aJ4Wnf6q8n0dIQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=byUxfk7y; arc=none smtp.remote-ip=115.124.30.100 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) (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 9E68B606A32A for ; Tue, 1 Dec 2026 10:07:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9E68B606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=byUxfk7y DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796119659; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=CG/ouoBDFxorfmrbknPe7LvSuVmjQuRCE0L20ntPsas=; b=byUxfk7y8JOjkCzsg4UlNpRfHidsgQ3r80VGAFNvwr6zZBAPz72NWKPurnXM2JAc3SQpau6YlbrUZfnq65d0CYDZsFfFBVAFIOOJCD5B/LGsNJDEnxCL59zGrhlQ5b1OvBLM41xzyVmkS4hkySWpvP3rDmV6lsWHCR2qrCseg6A= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045133197;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0XFzGSnu_1796119658; Received: from localhost(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0XFzGSnu_1796119658 cluster:ay36) by smtp.aliyun-inc.com; Tue, 01 Dec 2026 18:07:39 +0800 From: Joseph Qi To: hch@lst.de, Heming Zhao Cc: Andrew Morton , Mark Fasheh , Joel Becker , ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Joseph Qi Subject: [RFC PATCH v14 03/10] ocfs2: add ocfs2_get_clusters_uncached() Date: Tue, 1 Dec 2026 18:07:17 +0800 Message-Id: <20261201100724.2909559-4-joseph.qi@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20261201100724.2909559-1-joseph.qi@linux.alibaba.com> References: <20261201100724.2909559-1-joseph.qi@linux.alibaba.com> 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 From: Heming Zhao ocfs2_get_clusters() consults the extent map cache, which merges adjacent on-disk records into one. A caller that needs to operate on one on-disk record at a time cannot use it: the returned range may span several records, and inserting the lookup result back into the cache is not wanted either. Factor the lookup into __ocfs2_get_clusters() with a cache flag and add ocfs2_get_clusters_uncached(), which reads the extent tree directly and leaves the cache alone. ocfs2_get_clusters() keeps its current behaviour. No functional change. Co-developed-by: Joseph Qi Signed-off-by: Joseph Qi Signed-off-by: Heming Zhao --- fs/ocfs2/extent_map.c | 34 ++++++++++++++++++++++++++-------- fs/ocfs2/extent_map.h | 3 +++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c index eb5dcd17d4375..2510e68fbde85 100644 --- a/fs/ocfs2/extent_map.c +++ b/fs/ocfs2/extent_map.c @@ -602,9 +602,9 @@ int ocfs2_xattr_get_clusters(struct inode *inode, u32 v_cluster, return ret; } -int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, - u32 *p_cluster, u32 *num_clusters, - unsigned int *extent_flags) +static int __ocfs2_get_clusters(struct inode *inode, u32 v_cluster, + u32 *p_cluster, u32 *num_clusters, + unsigned int *extent_flags, bool cache) { int ret; unsigned int hole_len, flags = 0; @@ -617,10 +617,12 @@ int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, goto out; } - ret = ocfs2_extent_map_lookup(inode, v_cluster, p_cluster, - num_clusters, extent_flags); - if (ret == 0) - goto out; + if (cache) { + ret = ocfs2_extent_map_lookup(inode, v_cluster, p_cluster, + num_clusters, extent_flags); + if (ret == 0) + goto out; + } ret = ocfs2_read_inode_block(inode, &di_bh); if (ret) { @@ -650,7 +652,8 @@ int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, p_cluster, num_clusters); flags = rec.e_flags; - ocfs2_extent_map_insert_rec(inode, &rec); + if (cache) + ocfs2_extent_map_insert_rec(inode, &rec); } if (extent_flags) @@ -661,6 +664,21 @@ int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, return ret; } +int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, u32 *p_cluster, + u32 *num_clusters, unsigned int *extent_flags) +{ + return __ocfs2_get_clusters(inode, v_cluster, p_cluster, num_clusters, + extent_flags, true); +} + +int ocfs2_get_clusters_uncached(struct inode *inode, u32 v_cluster, + u32 *p_cluster, u32 *num_clusters, + unsigned int *extent_flags) +{ + return __ocfs2_get_clusters(inode, v_cluster, p_cluster, num_clusters, + extent_flags, false); +} + /* * This expects alloc_sem to be held. The allocation cannot change at * all while the map is in the process of being updated. diff --git a/fs/ocfs2/extent_map.h b/fs/ocfs2/extent_map.h index bc4ed59fb9257..b5b2d511ef9d5 100644 --- a/fs/ocfs2/extent_map.h +++ b/fs/ocfs2/extent_map.h @@ -32,6 +32,9 @@ void ocfs2_extent_map_insert_rec(struct inode *inode, int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, u32 *p_cluster, u32 *num_clusters, unsigned int *extent_flags); +int ocfs2_get_clusters_uncached(struct inode *inode, u32 v_cluster, + u32 *p_cluster, u32 *num_clusters, + unsigned int *extent_flags); int ocfs2_extent_map_get_blocks(struct inode *inode, u64 v_blkno, u64 *p_blkno, u64 *ret_count, unsigned int *extent_flags); -- 2.39.3