From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: Heming Zhao <heming.zhao@suse.com>, hch@lst.de
Cc: Andrew Morton <akpm@linux-foundation.org>,
Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>,
ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
Joseph Qi <joseph.qi@linux.alibaba.com>
Subject: [RFC PATCH v13 03/10] ocfs2: add ocfs2_get_clusters_uncached()
Date: Mon, 30 Nov 2026 18:01:56 +0800 [thread overview]
Message-ID: <20261130100203.383093-4-joseph.qi@linux.alibaba.com> (raw)
In-Reply-To: <20261130100203.383093-1-joseph.qi@linux.alibaba.com>
From: Heming Zhao <heming.zhao@suse.com>
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 <joseph.qi@linux.alibaba.com>
Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
---
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
next prev parent reply other threads:[~2026-11-30 10:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 10:01 [RFC PATCH v13 00/10] migrate ocfs2 DIO from buffer_head to iomap Joseph Qi
2026-11-30 10:01 ` [RFC PATCH v13 01/10] ocfs2: Add new ocfs2_map_blocks() to introduce iomap feature Joseph Qi
2026-11-30 10:01 ` [RFC PATCH v13 02/10] ocfs2: switch DIO read path from buffer_head to iomap Joseph Qi
2026-11-30 10:01 ` Joseph Qi [this message]
2026-11-30 10:01 ` [RFC PATCH v13 04/10] ocfs2: refactor ocfs2_lock_allocators() and add a dio variant Joseph Qi
2026-11-30 10:01 ` [RFC PATCH v13 05/10] ocfs2: record the fsync transaction when CoW makes clusters writable Joseph Qi
2026-11-30 10:01 ` [RFC PATCH v13 06/10] ocfs2: rework the direct write context for multi-cluster mappings Joseph Qi
[not found] ` <sashiko-outbox-240858@kernel.org>
2026-11-30 12:00 ` Joseph Qi
2026-11-30 10:02 ` [RFC PATCH v13 07/10] ocfs2: switch dio write path from buffer_head to iomap Joseph Qi
2026-11-30 10:02 ` [RFC PATCH v13 08/10] ocfs2: keep sub-page overwrites of written blocks on direct I/O Joseph Qi
2026-11-30 10:02 ` [RFC PATCH v13 09/10] ocfs2: write the dio zeroed head/tail buffers out before completion Joseph Qi
2026-11-30 10:02 ` [RFC PATCH v13 10/10] ocfs2: make buffered writes wait for in-flight direct writes Joseph Qi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261130100203.383093-4-joseph.qi@linux.alibaba.com \
--to=joseph.qi@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=hch@lst.de \
--cc=heming.zhao@suse.com \
--cc=jlbec@evilplan.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=ocfs2-devel@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®