From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.119 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796032965; b=LHnuXJoGRW5dTsfzMeDuKGIXNX9wsGivvNM0fY3tWSkGLzAQw4JyFShApVHsIC2WFUJ5 7i6+ddUuRc1VEKyQXDrWQUqxh5rYiG9tiE3WWKviOt7zdX5jCNOz3WuhEtCSIS/ZOvsjq B1ydEk4Y2symObWkgWhxys6taEVywkhWA03D+qfJs1cMGUKsLC42+3cqRHcf7sX8Y/Z2S lUUif7HI9R2p3WjNWtzw2nIcWd1iYkfJWDbCmp2UJyf7W3WrwN8jnAmsWLfFDpRxHMyhY XoocGUGbUAIq1qKpmz5GVh6GVJjy3YdqhozFOdUgS5qZ4s+WYw7kMVjrFNbTMWsSVVg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796032965; 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=FXf5ooL/eYs/2uqetkxoqw8VWUyzss75t2O6PNjjHo0HXU57/xjy1qauduXjkrC8QbiY ufTjb1VzVJ+6IeYTRsevtIOtx+F27ibaNbup/HH5TF4W0Tzgo/TWaqb9ajHUe/nz/S+Ij myalV+qdPxdxNiohlLp5Nn4IpzrZt4Qp6XEp3zqUOWn2w+Up71pc8yuQ5PP/3XAQj1NKM zM0PXCg8s3KXI2M9CAGodaq/90MAQC6bkO7Jfha2Uemlf84RHPoTEZTFRMwj/+8APXTRd 9JqISgrYqm7II/qiwO9uFVhJRGeDBB9lFzaTEdTwtvSTQT2pqt63tQdvkVw9edoVDeQ== 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=FDdfHiR2; arc=none smtp.remote-ip=115.124.30.119 Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) (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 CE2BD606A32E for ; Mon, 30 Nov 2026 10:02:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CE2BD606A32E 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=FDdfHiR2 DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796032956; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=CG/ouoBDFxorfmrbknPe7LvSuVmjQuRCE0L20ntPsas=; b=FDdfHiR2N60+wBd8io9KBLNCoxz9AGH5QvUVCv1hgr6oZPLPv4aiy8RTdQCq06jCO4suLH+W4Wg39WhdNBEy610Izy7seodkZDCh4vpjV3nBJ3v2c/DxFf8VAiO10J6eXobnxIaO6aUrMxwXq5O7MnpRf1XC2sQq9R+dvj06j6Q= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R821e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037026112;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0XFj1zBk_1796032954; Received: from localhost(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0XFj1zBk_1796032954 cluster:ay36) by smtp.aliyun-inc.com; Mon, 30 Nov 2026 18:02:35 +0800 From: Joseph Qi To: Heming Zhao , hch@lst.de Cc: Andrew Morton , Mark Fasheh , Joel Becker , ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Joseph Qi Subject: [RFC PATCH v13 03/10] ocfs2: add ocfs2_get_clusters_uncached() Date: Mon, 30 Nov 2026 18:01:56 +0800 Message-Id: <20261130100203.383093-4-joseph.qi@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20261130100203.383093-1-joseph.qi@linux.alibaba.com> References: <20261130100203.383093-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