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=1796222121; b=To0qcubmYK9xlyrPZLNJCA50eOEWiR2ts8n+FL23c0DPBYmmCxzh5AtENob7gZMXPaVz XXPJCOF6iFcI7VILUeJlY0Z2tjdBDr899y8Y/xWsdGXNIJRhisxc75lAn77pBLbg5mTx+ NbWy73rwZK8RxG0egko+yjhgJAv3pJ77bxOrlMOU8OeQaMnUpZ2COjA3mEUTU7NP0/K7R V8KtdGO/Rz1zpbTBv11IJdB2Sok+TQb6EP1UUEeelEZCF/kLW4BNQFh0BNCMn//EKd4J7 caOjyCA83pfQrAuHL9LhglOHb0AWBHOcGwF36ddsrsxqBKvIrGdWBuWsrUtFe8daX8A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796222121; 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=y19H0tT7Wm0jsL7DVRM2883mtOmpGvoXMHXOs24M/dTLLQRgWRnMwksde4nQDkGoaBTj 7xji99PnDj60NgmRfDij9gFnvSkKOFQUozku+LhGQJP3P8wVrevgqOQ3CNerc61PwjIUo 5/e6u5urRaWwUkyeS0rUfNuR9iVUlj/v9M0Te+Ft+oTCZBDbV0fNOjr/bS/6lf7dadcYD bSFrNpyjmfmLbpxhhrqeDMbwm6Omv5eKTo8jxB2wFe+ejas7D6iLCnaO8Vs8RWN2o59QG BxiqWBbUTbpZPHOxzAZXpRZbFatsRRZpaDPn4VhKM830zx9tzhgvnDJlJ7HizfPv/4Q== 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=d4rgjd5l; 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 7A5A5606A31A for ; Wed, 2 Dec 2026 14:35:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7A5A5606A31A 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=d4rgjd5l DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796222113; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=CG/ouoBDFxorfmrbknPe7LvSuVmjQuRCE0L20ntPsas=; b=d4rgjd5lTLpXrdoSO8jjJlBU7Di0spFe1bOwib0/Y+c6E9G5zf+BCEMR51LX3beVY/9lPYYvUSxtg08nuQGB9dra4VcIzBxHuOXjVHuPMzwVTbZtIZ9LQhYZqS54f7nASFIq+8SgPanK8LKd7tB3hHPfjybOFq46yuNork5zXQU= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R961e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037033178;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0XGBGYte_1796222111; Received: from localhost(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0XGBGYte_1796222111 cluster:ay36) by smtp.aliyun-inc.com; Wed, 02 Dec 2026 22:35:12 +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 v15 03/10] ocfs2: add ocfs2_get_clusters_uncached() Date: Wed, 2 Dec 2026 22:35:00 +0800 Message-Id: <20261202143507.1754776-4-joseph.qi@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20261202143507.1754776-1-joseph.qi@linux.alibaba.com> References: <20261202143507.1754776-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