[Concept,3/9] fs: ext4l: Add m_seq field to ext4_map_blocks struct

Message ID 20260107234426.3508161-4-sjg@u-boot.org
State New
Headers
Series Align ext4l with Linux kernel v6.19 implementation |

Commit Message

Simon Glass Jan. 7, 2026, 11:44 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Add the m_seq (extent status sequence) field to struct ext4_map_blocks
to match the Linux kernel structure. This field is used in Linux for
tracking extent status cache coherency but is unused in U-Boot's
single-threaded environment.

Update ext4_es_lookup_extent() to accept an optional m_seqp parameter
matching the Linux kernel API, and update all call sites accordingly.
The sequence value is never actually used in U-Boot, but having the
field and parameter present allows the code to match Linux more closely.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 fs/ext4l/ext4.h           | 1 +
 fs/ext4l/extents.c        | 2 +-
 fs/ext4l/extents_status.c | 2 +-
 fs/ext4l/extents_status.h | 2 +-
 fs/ext4l/inode.c          | 8 ++++----
 5 files changed, 8 insertions(+), 7 deletions(-)
  

Patch

diff --git a/fs/ext4l/ext4.h b/fs/ext4l/ext4.h
index 47054daffc2..1cbeebaf0a6 100644
--- a/fs/ext4l/ext4.h
+++ b/fs/ext4l/ext4.h
@@ -235,6 +235,7 @@  struct ext4_map_blocks {
 	ext4_lblk_t m_lblk;
 	unsigned int m_len;
 	unsigned int m_flags;
+	u64 m_seq;	/* Extent status sequence (unused in U-Boot) */
 };
 
 /*
diff --git a/fs/ext4l/extents.c b/fs/ext4l/extents.c
index 955f587426b..d2103fbac83 100644
--- a/fs/ext4l/extents.c
+++ b/fs/ext4l/extents.c
@@ -2200,7 +2200,7 @@  static int ext4_fill_es_cache_info(struct inode *inode,
 	while (block <= end) {
 		next = 0;
 		flags = 0;
-		if (!ext4_es_lookup_extent(inode, block, &next, &es))
+		if (!ext4_es_lookup_extent(inode, block, &next, &es, NULL))
 			break;
 		if (ext4_es_is_unwritten(&es))
 			flags |= FIEMAP_EXTENT_UNWRITTEN;
diff --git a/fs/ext4l/extents_status.c b/fs/ext4l/extents_status.c
index f557c7c23c2..706e267a79f 100644
--- a/fs/ext4l/extents_status.c
+++ b/fs/ext4l/extents_status.c
@@ -1037,7 +1037,7 @@  void ext4_es_cache_extent(struct inode *inode, ext4_lblk_t lblk,
  */
 int ext4_es_lookup_extent(struct inode *inode, ext4_lblk_t lblk,
 			  ext4_lblk_t *next_lblk,
-			  struct extent_status *es)
+			  struct extent_status *es, u64 *m_seqp)
 {
 	struct ext4_es_tree *tree;
 	struct ext4_es_stats *stats;
diff --git a/fs/ext4l/extents_status.h b/fs/ext4l/extents_status.h
index 8f9c008d11e..e668cda0d92 100644
--- a/fs/ext4l/extents_status.h
+++ b/fs/ext4l/extents_status.h
@@ -148,7 +148,7 @@  extern void ext4_es_find_extent_range(struct inode *inode,
 				      struct extent_status *es);
 extern int ext4_es_lookup_extent(struct inode *inode, ext4_lblk_t lblk,
 				 ext4_lblk_t *next_lblk,
-				 struct extent_status *es);
+				 struct extent_status *es, u64 *m_seqp);
 extern bool ext4_es_scan_range(struct inode *inode,
 			       int (*matching_fn)(struct extent_status *es),
 			       ext4_lblk_t lblk, ext4_lblk_t end);
diff --git a/fs/ext4l/inode.c b/fs/ext4l/inode.c
index 7001c7299cd..04b7c734f7f 100644
--- a/fs/ext4l/inode.c
+++ b/fs/ext4l/inode.c
@@ -627,7 +627,7 @@  static int ext4_map_create_blocks(handle_t *handle, struct inode *inode,
 	 * extent status tree.
 	 */
 	if (flags & EXT4_GET_BLOCKS_PRE_IO &&
-	    ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es)) {
+	    ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es, &map->m_seq)) {
 		if (ext4_es_is_written(&es))
 			return retval;
 	}
@@ -701,7 +701,7 @@  int ext4_map_blocks(handle_t *handle, struct inode *inode,
 		ext4_check_map_extents_env(inode);
 
 	/* Lookup extent status tree firstly */
-	if (ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es)) {
+	if (ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es, &map->m_seq)) {
 		if (ext4_es_is_written(&es) || ext4_es_is_unwritten(&es)) {
 			map->m_pblk = ext4_es_pblock(&es) +
 					map->m_lblk - es.es_lblk;
@@ -1885,7 +1885,7 @@  static int ext4_da_map_blocks(struct inode *inode, struct ext4_map_blocks *map)
 	ext4_check_map_extents_env(inode);
 
 	/* Lookup extent status tree firstly */
-	if (ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es)) {
+	if (ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es, NULL)) {
 		map->m_len = min_t(unsigned int, map->m_len,
 				   es.es_len - (map->m_lblk - es.es_lblk));
 
@@ -1938,7 +1938,7 @@  add_delayed:
 	 * is held in write mode, before inserting a new da entry in
 	 * the extent status tree.
 	 */
-	if (ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es)) {
+	if (ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es, NULL)) {
 		map->m_len = min_t(unsigned int, map->m_len,
 				   es.es_len - (map->m_lblk - es.es_lblk));