[Concept,18/33] ext4l: Move inode and filesystem helpers to linux/fs.h

Message ID 20260121220857.2137568-19-sjg@u-boot.org
State New
Headers
Series Reorganise ext4l compatibility stubs |

Commit Message

Simon Glass Jan. 21, 2026, 10:08 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Move inode lifecycle functions (new_inode, iget_locked, iput), block
mapping (bmap), and simple filesystem helpers (simple_open, simple_get_link)
from ext4_uboot.h to linux/fs.h where they belong.

Also replace the list_sort and sort stub macros with proper includes of
linux/list_sort.h and linux/sort.h.

This reduces ext4_uboot.h from 492 to 466 lines.

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

 fs/ext4l/ext4_uboot.h | 30 +++---------------------------
 include/linux/fs.h    | 20 +++++++++++++++++++-
 2 files changed, 22 insertions(+), 28 deletions(-)
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 14b3d075dd4..1228ced8e6c 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -117,9 +117,6 @@ 
 #include <linux/quotaops.h>
 #include <linux/random.h>
 
-/* Inode operations - iget_locked and new_inode are in interface.c */
-extern struct inode *new_inode(struct super_block *sb);
-
 /* Forward declarations for xattr functions */
 struct super_block;
 struct buffer_head;
@@ -134,8 +131,6 @@  int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode,
 #include <linux/rcupdate.h>
 #include <linux/slab.h>
 
-void iput(struct inode *inode);
-
 #include <linux/sched.h>
 #include <linux/buffer_head.h>
 #include <linux/jbd2.h>
@@ -226,9 +221,6 @@  struct path;
 /* UID/GID bit helpers - use linux/highuid.h */
 #include <linux/highuid.h>
 
-/* Inode allocation/state operations */
-extern struct inode *iget_locked(struct super_block *sb, unsigned long ino);
-
 /* Attribute operations */
 #define setattr_prepare(m, d, a)	({ (void)(m); (void)(d); (void)(a); 0; })
 #define setattr_copy(m, i, a)		do { } while (0)
@@ -261,17 +253,6 @@  static inline void nd_terminate_link(void *name, loff_t len, int maxlen)
 	((char *)name)[min_t(loff_t, len, maxlen)] = '\0';
 }
 
-/* file open helper */
-#define simple_open(i, f)		({ (void)(i); (void)(f); 0; })
-
-/* simple_get_link - for fast symlinks stored in inode */
-static inline const char *simple_get_link(struct dentry *dentry,
-					  struct inode *inode,
-					  struct delayed_call *callback)
-{
-	return inode->i_link;
-}
-
 /*
  * Additional stubs for super.c
  */
@@ -436,9 +417,6 @@  void ext4l_print_msgs(void);
 struct blk_desc *ext4l_get_blk_dev(void);
 struct disk_partition *ext4l_get_partition(void);
 
-/* JBD2 journal.c stubs */
-int bmap(struct inode *inode, sector_t *block);
-
 #include <linux/proc_fs.h>
 
 /* Memory allocation for journal.c */
@@ -483,10 +461,8 @@  int ext4_update_overhead(struct super_block *sb, bool force);
 /* fsmap is now in linux/fsmap.h */
 #include <linux/fsmap.h>
 
-/* list_sort and sort stubs for fsmap.c - not used in U-Boot */
-#define list_sort(priv, head, cmp) \
-	do { (void)(priv); (void)(head); (void)(cmp); } while (0)
-#define sort(base, num, size, cmp, swap) \
-	do { (void)(base); (void)(num); (void)(size); (void)(cmp); (void)(swap); } while (0)
+/* list_sort and sort for fsmap.c */
+#include <linux/list_sort.h>
+#include <linux/sort.h>
 
 #endif /* __EXT4_UBOOT_H__ */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c8006d668b5..07fe8c5e711 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -557,11 +557,29 @@  enum {
 #define unlock_two_nondirectories(i1, i2) \
 	do { (void)(i1); (void)(i2); } while (0)
 
-/* Inode allocation - implemented in ext4l/stub.c */
+/* Inode allocation and lifecycle - implemented in ext4l */
 struct kmem_cache;
 void *alloc_inode_sb(struct super_block *sb, struct kmem_cache *cache,
 		     gfp_t gfp);
 int inode_generic_drop(struct inode *inode);
+struct inode *new_inode(struct super_block *sb);
+struct inode *iget_locked(struct super_block *sb, unsigned long ino);
+void iput(struct inode *inode);
+
+/* Block mapping - implemented in ext4l/stub.c */
+int bmap(struct inode *inode, sector_t *block);
+
+/* Simple filesystem helpers */
+#define simple_open(i, f)		({ (void)(i); (void)(f); 0; })
+
+/* simple_get_link - for fast symlinks stored in inode */
+struct delayed_call;
+static inline const char *simple_get_link(struct dentry *dentry,
+					  struct inode *inode,
+					  struct delayed_call *callback)
+{
+	return inode->i_link;
+}
 
 /**
  * get_block_t - block mapping callback type