[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251118082208.1034186-7-chizhiling@163.com>
Date: Tue, 18 Nov 2025 16:22:07 +0800
From: Chi Zhiling <chizhiling@....com>
To: linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>,
Jan Kara <jack@...e.cz>,
Matthew Wilcox <willy@...radead.org>,
Namjae Jeon <linkinjeon@...nel.org>,
Sungjong Seo <sj1557.seo@...sung.com>,
Yuezhang Mo <yuezhang.mo@...y.com>,
Chi Zhiling <chizhiling@...inos.cn>
Subject: [RFC PATCH 6/7] exfat: introduce exfat_count_contig_clusters
From: Chi Zhiling <chizhiling@...inos.cn>
This patch introduces exfat_count_contig_clusters to obtain batch entries,
which is an infrastructure used to support iomap.
Signed-off-by: Chi Zhiling <chizhiling@...inos.cn>
---
fs/exfat/exfat_fs.h | 2 ++
fs/exfat/fatent.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
index d52893276e9a..421dd7c61cca 100644
--- a/fs/exfat/exfat_fs.h
+++ b/fs/exfat/exfat_fs.h
@@ -449,6 +449,8 @@ int exfat_find_last_cluster(struct super_block *sb, struct exfat_chain *p_chain,
unsigned int *ret_clu);
int exfat_count_num_clusters(struct super_block *sb,
struct exfat_chain *p_chain, unsigned int *ret_count);
+int exfat_count_contig_clusters(struct super_block *sb,
+ struct exfat_chain *p_chain, unsigned int *ret_count);
/* balloc.c */
int exfat_load_bitmap(struct super_block *sb);
diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c
index d980d17176c2..9dcee9524155 100644
--- a/fs/exfat/fatent.c
+++ b/fs/exfat/fatent.c
@@ -524,3 +524,36 @@ int exfat_count_num_clusters(struct super_block *sb,
return 0;
}
+
+int exfat_count_contig_clusters(struct super_block *sb,
+ struct exfat_chain *p_chain, unsigned int *ret_count)
+{
+ struct buffer_head *bh = NULL;
+ unsigned int clu, next_clu;
+ unsigned int count;
+
+ if (!p_chain->dir || p_chain->dir == EXFAT_EOF_CLUSTER) {
+ *ret_count = 0;
+ return 0;
+ }
+
+ if (p_chain->flags == ALLOC_NO_FAT_CHAIN) {
+ *ret_count = p_chain->size;
+ return 0;
+ }
+
+ clu = p_chain->dir;
+ for (count = 1; count < p_chain->size; count++) {
+ if (exfat_ent_get(sb, clu, &next_clu, &bh))
+ return -EIO;
+ if (++clu != next_clu)
+ break;
+ }
+
+ /* TODO: Update p_claim to help caller read ahead the next block */
+
+ brelse(bh);
+ *ret_count = count;
+
+ return 0;
+}
--
2.43.0
Powered by blists - more mailing lists