From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.111 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796301654; b=zIHxcZT6EOz+3EX61ekUZQHYNZwc+frE2DiatVDCBO3WBTulsujLDIM7rdh20dXHbYa4 h9w6eFmKC62l3O4C582R+FHPr/63qr+9dLE/KUAcU6nGPCdv7s1LTExrCIyj11sR4cbfU /ndWnTX3ka50S86PJvnI8bHAvIE6Sox399+vPOig+gaAFKs3ASsRepocGa9WlcW/92ZKR Q8itUpm1cdkQC48ILoE61Z2w3ViDU2ZF6SFSPlYaYHFw2iSEn7l7mlJrWRukJucwOM/a0 hHUXJ8oIsvqhZ3zt9DUQb2zWHTg+U9TnpRNngoeafKIE8qaTkNaLXBX6Ut0Jsf5qVzg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796301654; 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=aXE5vkjw1/qWBjmAQOrkLhpolDg5kQktY5qo3qyhqkc=; b=dIpeNFvNFoLUqVdgLV6LMxzAhaczlD3Xp1Xx30tdVE+D4OtlJOor0wuHQIQNOfFj2IDr QazceL7QLCpvF8/vxEy2HYfbd3z0ciUI9BQ1U7vBD8TKJjd5fJ6cOHHEaypDb8KJCI7J/ k3KWQUVCEHAmJD6+97zDx3E9GUyLtB17YP+0NmvBX/eiYpXksF0JxSvzZ0RXfGfyTyNXB BW1O85JNjkjzubwvSOALOkBIZeoeQZ13ROcVOUmX9n8aoqbibCc+NHV9no64Uxg61SMsu IVfRG6u8vA68w4GDSvxvnaS+mBW4Ntece3lzL1hecxNLcdTCGJZY+euiJ+/MFl3fcPQ== 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=HrKYesk2; arc=none smtp.remote-ip=115.124.30.111 Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) (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 2BC8F606A68D for ; Thu, 3 Dec 2026 12:40:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2BC8F606A68D 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=HrKYesk2 DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796301643; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=aXE5vkjw1/qWBjmAQOrkLhpolDg5kQktY5qo3qyhqkc=; b=HrKYesk2lZ+SakHcPdDYLPrf5T17RhsfodrNvWI4VX1lnmeIM8JkqPdgBzxKxCwLebvJarhVzqAXyiYMbdsE98VRla3SWaGRGcVu2u9t3hhTyH0BFjAl1+vxyvEYhK/z53q6dZw74rT9QeyJU96hZQIh7ic9t/VCjl2WfC+4bFQ= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045144198;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0XGEIJK5_1796301642; Received: from localhost(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0XGEIJK5_1796301642 cluster:ay36) by smtp.aliyun-inc.com; Thu, 03 Dec 2026 20:40:42 +0800 From: Joseph Qi To: Andrew Morton , Heming Zhao , hch@lst.de Cc: Mark Fasheh , Joel Becker , ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Joseph Qi Subject: [PATCH v16 03/10] ocfs2: add ocfs2_get_clusters_uncached() Date: Thu, 3 Dec 2026 20:40:30 +0800 Message-Id: <20261203124037.4112319-4-joseph.qi@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20261203124037.4112319-1-joseph.qi@linux.alibaba.com> References: <20261203124037.4112319-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 Reviewed-by: Christoph Hellwig --- 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