[Concept,06/33] ext4l: Move sb_ functions and SB_ macros to super_types.h

Message ID 20260121220857.2137568-7-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 superblock-related functions and macros from ext4_uboot.h to
include/linux/fs/super_types.h where struct super_block is defined.

This includes:
- sb_start_intwrite(), sb_end_intwrite(), sb_start_intwrite_trylock()
- sb_start_pagefault(), sb_end_pagefault()
- sb_set_blocksize(), sb_min_blocksize(), sb_bdev_nr_blocks()
- sb_issue_zeroout(), sb_issue_discard()
- sb_is_blkdev_sb(), sb_no_casefold_compat_fallback()
- super_set_uuid()
- SB_I_CGROUPWB, SB_I_ALLOW_HSM

Co-developed-by: Claude (Anthropic)
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 fs/ext4l/ext4_uboot.h          | 42 --------------------------------
 include/linux/fs/super_types.h | 44 ++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 42 deletions(-)
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 6f4ebd7e68b..0cddc46cf98 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -132,7 +132,6 @@  int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode,
 #endif
 
 /* Block device operations - stubs */
-#define sb_issue_zeroout(sb, blk, num, gfp)	({ (void)(sb); (void)(blk); (void)(num); (void)(gfp); 0; })
 #define blkdev_issue_flush(bdev)		({ (void)(bdev); 0; })
 
 #include <linux/rcupdate.h>
@@ -281,7 +280,6 @@  struct dx_hash_info {
 
 #define daxdev_mapping_supported(f, i, d) ({ (void)(f); (void)(i); (void)(d); 1; })
 
-#define sb_no_casefold_compat_fallback(sb)	({ (void)(sb); 1; })
 #define generic_ci_validate_strict_name(d, n)	({ (void)(d); (void)(n); 1; })
 
 #include <linux/minmax.h>
@@ -343,14 +341,6 @@  struct dx_hash_info {
 #define dax_zero_range(i, p, l, d, op)		({ (void)(i); (void)(p); (void)(l); (void)(d); (void)(op); -EOPNOTSUPP; })
 #define dax_break_layout_inode(i, m)		({ (void)(i); (void)(m); 0; })
 
-/* Superblock freezing stubs */
-#define sb_start_intwrite(sb)			do { (void)(sb); } while (0)
-#define sb_end_intwrite(sb)			do { (void)(sb); } while (0)
-#define sb_start_intwrite_trylock(sb)		({ (void)(sb); 1; })
-#define sb_start_pagefault(sb)			do { (void)(sb); } while (0)
-#define sb_end_pagefault(sb)			do { (void)(sb); } while (0)
-
-/* d_path, path_put - use linux/path.h */
 #include <linux/path.h>
 
 #include <linux/fsverity.h>
@@ -465,9 +455,6 @@  void ext4_unregister_li_request(struct super_block *sb);
 /* I/O priority classes - use linux/ioprio.h */
 #include <linux/ioprio.h>
 
-#define SB_I_CGROUPWB			0	/* Not supported in U-Boot */
-#define SB_I_ALLOW_HSM			0	/* Not supported in U-Boot */
-
 /* blk_holder_ops for block device */
 struct blk_holder_ops {
 	void (*mark_dead)(struct block_device *, bool);
@@ -531,32 +518,9 @@  void free_page(unsigned long addr);
 void *fs_dax_get_by_bdev(struct block_device *bdev, u64 *start, u64 *len,
 			 void *holder);
 
-/* Superblock blocksize - declaration for stub.c */
-int sb_set_blocksize(struct super_block *sb, int size);
-
-/* Superblock min blocksize - stub */
-static inline int sb_min_blocksize(struct super_block *sb, int size)
-{
-	return sb_set_blocksize(sb, size);
-}
-
 /* Block device size - declarations for stub.c */
 int generic_check_addressable(unsigned int blocksize_bits, u64 num_blocks);
-u64 sb_bdev_nr_blocks(struct super_block *sb);
 unsigned int bdev_max_discard_sectors(struct block_device *bdev);
-
-/* Superblock identity functions */
-static inline void super_set_uuid(struct super_block *sb, const u8 *uuid,
-				  unsigned len)
-{
-	if (len > sizeof(sb->s_uuid.b))
-		len = sizeof(sb->s_uuid.b);
-	memcpy(sb->s_uuid.b, uuid, len);
-}
-
-/* super_set_sysfs_name_bdev is now in linux/kobject.h */
-
-/* mb_cache - use linux/mbcache.h */
 #include <linux/mbcache.h>
 
 /* xattr helper stubs for xattr.c */
@@ -595,10 +559,6 @@  struct buffer_head *__bread(struct block_device *bdev, sector_t block, unsigned
 /* Block device properties */
 #define bdev_nonrot(bdev)		({ (void)(bdev); 0; })
 
-/* sb_issue_discard - issue discard request (no-op in U-Boot) */
-#define sb_issue_discard(sb, sector, nr_sects, gfp, flags) \
-	({ (void)(sb); (void)(sector); (void)(nr_sects); (void)(gfp); (void)(flags); 0; })
-
 /* raw_cpu_ptr - get pointer to per-CPU data for current CPU */
 #define raw_cpu_ptr(ptr)		(ptr)
 
@@ -650,8 +610,6 @@  void ext4l_print_msgs(void);
 struct blk_desc *ext4l_get_blk_dev(void);
 struct disk_partition *ext4l_get_partition(void);
 
-#define sb_is_blkdev_sb(sb)		({ (void)(sb); 0; })
-
 /* DEFINE_WAIT stub - creates a wait queue entry */
 #define DEFINE_WAIT(name)		int name = 0
 
diff --git a/include/linux/fs/super_types.h b/include/linux/fs/super_types.h
index c575d268c43..189a40dd123 100644
--- a/include/linux/fs/super_types.h
+++ b/include/linux/fs/super_types.h
@@ -9,6 +9,7 @@ 
 
 #include <linux/list.h>
 #include <linux/rwsem.h>
+#include <linux/string.h>
 #include <linux/time.h>
 #include <linux/types.h>
 #include <linux/uuid.h>
@@ -98,4 +99,47 @@  static inline bool sb_rdonly(const struct super_block *sb)
 #define sb_end_write(sb)		do { (void)(sb); } while (0)
 #define sb_start_write_trylock(sb)	({ (void)(sb); 1; })
 
+/* Superblock internal write operations */
+#define sb_start_intwrite(sb)		do { (void)(sb); } while (0)
+#define sb_end_intwrite(sb)		do { (void)(sb); } while (0)
+#define sb_start_intwrite_trylock(sb)	({ (void)(sb); 1; })
+
+/* Superblock pagefault operations */
+#define sb_start_pagefault(sb)		do { (void)(sb); } while (0)
+#define sb_end_pagefault(sb)		do { (void)(sb); } while (0)
+
+/* Superblock internal flags */
+#define SB_I_CGROUPWB			0	/* Not supported in U-Boot */
+#define SB_I_ALLOW_HSM			0	/* Not supported in U-Boot */
+
+/* Superblock block size operations - sb_set_blocksize in stub.c */
+int sb_set_blocksize(struct super_block *sb, int size);
+
+static inline int sb_min_blocksize(struct super_block *sb, int size)
+{
+	return sb_set_blocksize(sb, size);
+}
+
+/* Superblock block device operations */
+u64 sb_bdev_nr_blocks(struct super_block *sb);
+#define sb_is_blkdev_sb(sb)		({ (void)(sb); 0; })
+
+/* Superblock discard/zeroout operations - no-op in U-Boot */
+#define sb_issue_zeroout(sb, blk, num, gfp) \
+	({ (void)(sb); (void)(blk); (void)(num); (void)(gfp); 0; })
+#define sb_issue_discard(sb, sector, nr_sects, gfp, flags) \
+	({ (void)(sb); (void)(sector); (void)(nr_sects); (void)(gfp); (void)(flags); 0; })
+
+/* Case-folding - not supported in U-Boot */
+#define sb_no_casefold_compat_fallback(sb)	({ (void)(sb); 1; })
+
+/* Superblock identity functions */
+static inline void super_set_uuid(struct super_block *sb, const u8 *uuid,
+				  unsigned len)
+{
+	if (len > sizeof(sb->s_uuid.b))
+		len = sizeof(sb->s_uuid.b);
+	memcpy(sb->s_uuid.b, uuid, len);
+}
+
 #endif /* _LINUX_FS_SUPER_TYPES_H */