From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.133 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796458776; b=0cVFPOT3SxCBgncNhEpQ2orngKnc8Sy9Qswu1TnlQPe4B2H3yw6QNFgnSgx91M5j6p1s ogdxH8KidYPbUZQv9kaRV75WJY/yZfC9MX2pmSt460c9d2qcIfIykhBLqg11jIUrCTp3R 1mP8tpOYxccJqKasnmgWSr4czR5BOn5UoWk+Wn09nzqcHUSBuHPsw0+GT6h4WG38d2j7a BrfAU+8OksS6TYIeFy7HxjQ2YMudHmaWtg+Rhr/L0CWdCyOSzDAJ2fRoQi+8IOiL/l218 H/d+Zdqf2nDDWXXxjHfXxXLalzjzHp1ZpJmNwTgsmqvX5kJ/WXiUoSz5nqY6SVvYeQA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796458776; 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=Pbgedrfqax7pem9sSs/gV7QRo1/nxmFvspNprv3oWEAI75jz5uYGa/5FcotH+exlwA3T qx7PZ1oji63lYWnKCehoftYxdPIOF7/LKga578CFz86SWmfPuGEKfqTWeceqlpFpUzXsn IxHomiafx593280QI1Kc2GAqakxhu+gb7NdgKNx3/egpYL1PfMP20NnnoFHiXZ85RFsSi ogPS4GXrLuZPv1Ce32dWTybeLq4ZNXGlVOmcN4nc267xFolbBG2HQdWUAk2SujHoB3GSN u5fxXNmXAL/t8JDDlH2vFkhtRQZMUSzpr2lqXufBZWnOlvnL8GYYuR5fMtZND6vlmhA== 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=YF5ysJoP; arc=none smtp.remote-ip=115.124.30.133 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) (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 EB476606A336 for ; Sat, 5 Dec 2026 08:19:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EB476606A336 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=YF5ysJoP DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796458768; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=aXE5vkjw1/qWBjmAQOrkLhpolDg5kQktY5qo3qyhqkc=; b=YF5ysJoPjMax4e1tQTxrWq/weIjpeXgY3xuBET6iDNlM16xEOGmwNqs55obFWQ0QtpgV+gA1hFAk9uNdAbQqVdJDzTQ7xYchqjqGRz7UBeitCJb/pgUq1LBWJMyUXLdFDRlF8ZP0nQmDCvstF84jQX/CcnUkR/Eu7HjQhQwMkzU= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R171e4;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_---0XGJGPae_1796458767; Received: from localhost(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0XGJGPae_1796458767 cluster:ay36) by smtp.aliyun-inc.com; Sat, 05 Dec 2026 16:19:27 +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 v17 03/10] ocfs2: add ocfs2_get_clusters_uncached() Date: Sat, 5 Dec 2026 16:19:16 +0800 Message-Id: <20261205081923.4097763-4-joseph.qi@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20261205081923.4097763-1-joseph.qi@linux.alibaba.com> References: <20261205081923.4097763-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