[PATCH 00/17] ext4l: Move compatibility stubs to standard Linux headers
From: Simon Glass <simon.glass@canonical.com> The ext4 Linux port (ext4l) includes many compatibility stubs in ext4_uboot.h. This makes it harder to maintain and compare against upstream Linux, since the stubs are all in one U-Boot-specific file rather than in their canonical header locations. This series moves these stubs to their proper locations in the Linux header hierarchy: - Cache alignment macros to linux/cache.h - Pointer macros to linux/slab.h - Compiler attributes to linux/compiler_attributes.h - Inode helpers and state bits to linux/fs.h - Memory and kunit stubs to standard headers - Little-endian bitops to asm-generic/bitops/le.h - UUID helpers to linux/statfs.h - Time functions to linux/time.h - Buffer operations to linux/buffer_head.h - Block device stubs to linux/blkdev.h - Folio operations to proper headers - Super operations to linux/fs/super_types.h - Lock and scheduler stubs to proper headers This makes the U-Boot Linux compatibility layer more closely mirror the actual Linux header structure, easing future synchronisation with upstream ext4 changes. Simon Glass (17): ext4l: Move cache alignment and pointer macros to headers ext4l: Move inode helpers to standard linux headers ext4l: Move inode state bits to linux/fs.h ext4l: Move memory and kunit stubs to standard headers ext4l: Create asm-generic/bitops/le.h for little-endian bitops ext4l: Move uuid_to_fsid to linux/statfs.h and use hexdump.h ext4l: Move time functions to linux/time.h ext4l: Move buffer and filesystem helpers to standard headers ext4l: Move block device atomic write stubs to linux/blkdev.h ext4l: Move get_block_t typedef to linux/fs.h ext4l: Move buffer operations to linux/buffer_head.h ext4l: Move inode stubs to proper headers ext4l: Move folio operations to proper headers ext4l: Move super_operations to linux/fs/super_types.h ext4l: Move lock and scheduler stubs to proper headers ext4l: Move lock bit operations to asm-generic/bitops/lock.h ext4l: Move superblock write stubs to linux/fs/super_types.h fs/ext4l/ext4_uboot.h | 325 +++++++--------------------- include/asm-generic/bitops/le.h | 76 +++++++ include/asm-generic/bitops/lock.h | 30 +++ include/kunit/static_stub.h | 12 +- include/linux/blkdev.h | 5 + include/linux/buffer_head.h | 74 +++++++ include/linux/cache.h | 22 ++ include/linux/compiler_attributes.h | 10 + include/linux/cred.h | 3 + include/linux/fs.h | 85 +++++++- include/linux/fs/super_types.h | 33 +++ include/linux/mutex.h | 1 + include/linux/pagemap.h | 18 ++ include/linux/pagevec.h | 11 + include/linux/sched.h | 1 + include/linux/sched/mm.h | 32 +++ include/linux/slab.h | 9 + include/linux/spinlock.h | 4 + include/linux/statfs.h | 19 ++ include/linux/time.h | 14 ++ include/linux/writeback.h | 8 + 21 files changed, 537 insertions(+), 255 deletions(-) create mode 100644 include/asm-generic/bitops/le.h create mode 100644 include/asm-generic/bitops/lock.h create mode 100644 include/linux/cache.h create mode 100644 include/linux/sched/mm.h -- 2.43.0 base-commit: f900786595b058fec921a56375bd3951fcae4553 branch: extv
From: Simon Glass <simon.glass@canonical.com> Move several compatibility macros to their proper Linux headers: - Create linux/cache.h with ____cacheline_aligned_in_smp stub - Move ZERO_OR_NULL_PTR to linux/slab.h - Add __counted_by stub to linux/compiler_attributes.h This reduces ext4_uboot.h by moving these definitions to their canonical locations in the Linux header hierarchy. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 10 ++++------ include/linux/cache.h | 22 ++++++++++++++++++++++ include/linux/compiler_attributes.h | 10 ++++++++++ include/linux/slab.h | 9 +++++++++ 4 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 include/linux/cache.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index eadff92aecb..2255458a46d 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -118,11 +118,10 @@ /* completion - use Linux header */ #include <linux/completion.h> -/* Cache alignment - stub */ -#define ____cacheline_aligned_in_smp +/* Cache alignment - use linux/cache.h */ +#include <linux/cache.h> -/* Pointer check macros */ -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= PAGE_SIZE) +/* ZERO_OR_NULL_PTR is in linux/slab.h */ /* data_race is in linux/compiler.h */ /* REQ_META, REQ_PRIO, REQ_RAHEAD are in linux/blk_types.h */ @@ -154,8 +153,7 @@ /* kiocb, iov_iter - use linux/uio.h */ #include <linux/uio.h> -/* __counted_by attribute - not available in U-Boot */ -#define __counted_by(x) +/* __counted_by is in linux/compiler_attributes.h */ /* dir_context, filldir_t are in linux/fs.h */ diff --git a/include/linux/cache.h b/include/linux/cache.h new file mode 100644 index 00000000000..2fb4e00faa7 --- /dev/null +++ b/include/linux/cache.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Cache alignment definitions for U-Boot + * + * Based on Linux include/linux/cache.h + */ +#ifndef _LINUX_CACHE_H +#define _LINUX_CACHE_H + +/* + * U-Boot is single-threaded, so cache line alignment for SMP is not needed. + * These are provided for compatibility with Linux code. + */ +#ifndef ____cacheline_aligned_in_smp +#define ____cacheline_aligned_in_smp +#endif + +#ifndef __cacheline_aligned_in_smp +#define __cacheline_aligned_in_smp +#endif + +#endif /* _LINUX_CACHE_H */ diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h index 44c9a08d734..097fce857c5 100644 --- a/include/linux/compiler_attributes.h +++ b/include/linux/compiler_attributes.h @@ -270,4 +270,14 @@ */ #define __weak __attribute__((__weak__)) +/* + * __counted_by(member) - flexible array bounds annotation + * + * Used to annotate flexible array members with the struct member that + * holds the count. Not available in all compilers, so stub it out. + */ +#ifndef __counted_by +#define __counted_by(member) +#endif + #endif /* __LINUX_COMPILER_ATTRIBUTES_H */ diff --git a/include/linux/slab.h b/include/linux/slab.h index 15d561f0527..628126e0a3b 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -56,6 +56,15 @@ #define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Track pages reclaimed */ #define SLAB_ACCOUNT 0x00000000UL /* Account to memcg (no-op) */ +/* + * Check if pointer is zero or in the zero page (used by SLUB allocator). + * PAGE_SIZE fallback for when this header is included standalone. + */ +#ifndef PAGE_SIZE +#define PAGE_SIZE 4096 +#endif +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= PAGE_SIZE) + void *kmalloc(size_t size, gfp_t flags); static inline void *kzalloc(size_t size, gfp_t flags) -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move several inode-related stubs to their canonical Linux header locations: - inode_needs_sync and is_bad_inode to linux/fs.h - in_group_p to linux/cred.h These are standard Linux kernel interfaces that belong in their respective headers rather than in the ext4l compatibility layer. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 9 +++------ include/linux/cred.h | 3 +++ include/linux/fs.h | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 2255458a46d..d21462407a8 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -197,8 +197,7 @@ static inline void memalloc_nofs_restore(unsigned int flags) { } struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); /* wait_on_bit_io is now in linux/wait_bit.h */ -/* inode_needs_sync - stub */ -#define inode_needs_sync(inode) (0) +/* inode_needs_sync is in linux/fs.h */ /* Memory barriers are now in linux/smp.h */ @@ -222,8 +221,7 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); /* percpu_counter operations are in linux/percpu_counter.h */ -/* Group permission - stub */ -#define in_group_p(gid) (0) +/* in_group_p is in linux/cred.h */ /* Quota operations - use linux/quotaops.h */ #include <linux/quotaops.h> @@ -270,8 +268,7 @@ int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode, #endif /* ext4_init_security is provided by xattr.h */ -/* inode state stubs */ -#define is_bad_inode(inode) (0) +/* is_bad_inode is in linux/fs.h */ /* Block device operations - stubs */ #define sb_issue_zeroout(sb, blk, num, gfp) ({ (void)(sb); (void)(blk); (void)(num); (void)(gfp); 0; }) diff --git a/include/linux/cred.h b/include/linux/cred.h index a3a972a5a73..32b15dfc72e 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h @@ -59,4 +59,7 @@ struct user_namespace { extern struct user_namespace init_user_ns; +/* in_group_p - check if current process is in group (always false in U-Boot) */ +#define in_group_p(gid) (0) + #endif /* _LINUX_CRED_H */ diff --git a/include/linux/fs.h b/include/linux/fs.h index 1b0059ca1a7..b6a0596a9de 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -305,6 +305,12 @@ enum { #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND) #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE) +/* inode_needs_sync - check if inode needs synchronous writes (always false) */ +#define inode_needs_sync(inode) (0) + +/* is_bad_inode - check if inode is marked bad (always false in U-Boot) */ +#define is_bad_inode(inode) (0) + /** * struct fstrim_range - fstrim ioctl argument * @start: first byte to trim -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move the inode state bit definitions (I_NEW, I_FREEING, I_DIRTY_DATASYNC, I_DIRTY_TIME) to linux/fs.h where they belong in the Linux kernel header hierarchy. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 10 ++-------- include/linux/fs.h | 6 ++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index d21462407a8..2274f24f426 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -410,11 +410,7 @@ static inline int bdev_read_only(struct block_device *bdev) /* kuid_t and kgid_t - from linux/cred.h */ #include <linux/cred.h> -/* Inode state bits */ -#define I_NEW (1 << 0) -#define I_FREEING (1 << 1) -#define I_DIRTY_DATASYNC (1 << 2) - +/* Inode state bits (I_NEW, I_FREEING, etc.) are in linux/fs.h */ /* S_SYNC, S_NOATIME, etc. inode flags are in linux/fs.h */ /* S_IRWXUGO is in linux/fs.h */ @@ -423,9 +419,7 @@ static inline int bdev_read_only(struct block_device *bdev) #define WHITEOUT_MODE 0 /* RENAME_* flags are in linux/fs.h */ - -/* Inode dirty state flags */ -#define I_DIRTY_TIME (1 << 3) +/* I_DIRTY_TIME is in linux/fs.h */ /* SB_LAZYTIME is in linux/fs.h */ /* ATTR_* iattr valid flags are in linux/fs.h */ diff --git a/include/linux/fs.h b/include/linux/fs.h index b6a0596a9de..475085e18ee 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -311,6 +311,12 @@ enum { /* is_bad_inode - check if inode is marked bad (always false in U-Boot) */ #define is_bad_inode(inode) (0) +/* Inode state bits for i_state field */ +#define I_NEW (1 << 0) +#define I_FREEING (1 << 1) +#define I_DIRTY_DATASYNC (1 << 2) +#define I_DIRTY_TIME (1 << 3) + /** * struct fstrim_range - fstrim ioctl argument * @start: first byte to trim -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move several compatibility stubs to their canonical Linux header locations: - Create linux/sched/mm.h with memalloc_nofs_save/restore stubs - Create kunit/static_stub.h with KUNIT_STATIC_STUB_REDIRECT stub - Add IS_CASEFOLDED to linux/fs.h This continues reducing ext4_uboot.h by placing these definitions in their proper locations in the Linux header hierarchy. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 12 +++++------- include/kunit/static_stub.h | 12 ++++++++---- include/linux/fs.h | 3 ++- include/linux/sched/mm.h | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 include/linux/sched/mm.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 2274f24f426..a493fb58ad7 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -163,12 +163,10 @@ /* percpu rw semaphore is in linux/percpu.h */ -/* Memory allocation context - stubs */ -static inline unsigned int memalloc_nofs_save(void) { return 0; } -static inline void memalloc_nofs_restore(unsigned int flags) { } +/* Memory allocation context - use linux/sched/mm.h */ +#include <linux/sched/mm.h> -/* Inode flags - stubs */ -#define IS_CASEFOLDED(inode) (0) +/* IS_CASEFOLDED is in linux/fs.h */ /* IS_ENCRYPTED and FSCRYPT_SET_CONTEXT_MAX_SIZE are in ext4_fscrypt.h */ #define S_NOQUOTA 0 @@ -216,8 +214,8 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); #define __test_and_set_bit_le(nr, addr) \ ({ int __old = test_bit(nr, addr); set_bit(nr, addr); __old; }) -/* KUNIT stub */ -#define KUNIT_STATIC_STUB_REDIRECT(...) do { } while (0) +/* KUNIT stub - use kunit/static_stub.h */ +#include <kunit/static_stub.h> /* percpu_counter operations are in linux/percpu_counter.h */ diff --git a/include/kunit/static_stub.h b/include/kunit/static_stub.h index 995a919f641..265622c519b 100644 --- a/include/kunit/static_stub.h +++ b/include/kunit/static_stub.h @@ -1,13 +1,17 @@ /* SPDX-License-Identifier: GPL-2.0 */ +/* + * KUnit static stub support for U-Boot + * + * Based on Linux include/kunit/static_stub.h + */ #ifndef _KUNIT_STATIC_STUB_H #define _KUNIT_STATIC_STUB_H /* - * Stub header for U-Boot ext4l. + * KUNIT_STATIC_STUB_REDIRECT - call a replacement stub if one exists * - * KUnit static stubs are for kernel unit testing - not needed in U-Boot. + * U-Boot doesn't support KUnit, so this is a no-op. */ - -#define KUNIT_STATIC_STUB_REDIRECT(func, args...) do { } while (0) +#define KUNIT_STATIC_STUB_REDIRECT(...) do { } while (0) #endif /* _KUNIT_STATIC_STUB_H */ diff --git a/include/linux/fs.h b/include/linux/fs.h index 475085e18ee..993985f88f3 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -300,10 +300,11 @@ enum { /* inode_newsize_ok - check if new size is valid (always ok in U-Boot) */ #define inode_newsize_ok(i, s) ({ (void)(i); (void)(s); 0; }) -/* IS_SYNC, IS_APPEND, IS_IMMUTABLE - inode flag checks */ +/* IS_SYNC, IS_APPEND, IS_IMMUTABLE, IS_CASEFOLDED - inode flag checks */ #define IS_SYNC(inode) (0) #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND) #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE) +#define IS_CASEFOLDED(inode) (0) /* Case-folding not supported */ /* inode_needs_sync - check if inode needs synchronous writes (always false) */ #define inode_needs_sync(inode) (0) diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h new file mode 100644 index 00000000000..7a105f768cb --- /dev/null +++ b/include/linux/sched/mm.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Memory allocation context helpers for U-Boot + * + * Based on Linux include/linux/sched/mm.h + */ +#ifndef _LINUX_SCHED_MM_H +#define _LINUX_SCHED_MM_H + +/** + * memalloc_nofs_save() - Mark implicit GFP_NOFS allocation scope + * + * U-Boot stub - no filesystem allocation context tracking needed. + * + * Return: 0 (no flags to restore) + */ +static inline unsigned int memalloc_nofs_save(void) +{ + return 0; +} + +/** + * memalloc_nofs_restore() - End implicit GFP_NOFS scope + * @flags: flags returned by memalloc_nofs_save() + * + * U-Boot stub - no filesystem allocation context tracking needed. + */ +static inline void memalloc_nofs_restore(unsigned int flags) +{ +} + +#endif /* _LINUX_SCHED_MM_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move little-endian bit operations to asm-generic/bitops/le.h: - find_next_zero_bit_le, find_next_bit_le - test_bit_le, __set_bit_le, __clear_bit_le - __test_and_set_bit_le, __test_and_clear_bit_le This matches the Linux kernel header organisation and removes duplicate implementations from ext4_uboot.h. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 38 ++--------------- include/asm-generic/bitops/le.h | 76 +++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 35 deletions(-) create mode 100644 include/asm-generic/bitops/le.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index a493fb58ad7..6f2ea69a888 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -204,15 +204,8 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); * We implement them in interface.c for sandbox. */ -/* Little-endian bit operations - use arch-provided find_next_zero_bit */ -#define find_next_zero_bit_le(addr, size, offset) \ - find_next_zero_bit((void *)addr, size, offset) -#define __set_bit_le(nr, addr) set_bit(nr, addr) -#define test_bit_le(nr, addr) test_bit(nr, addr) -#define __test_and_clear_bit_le(nr, addr) \ - ({ int __old = test_bit(nr, addr); clear_bit(nr, addr); __old; }) -#define __test_and_set_bit_le(nr, addr) \ - ({ int __old = test_bit(nr, addr); set_bit(nr, addr); __old; }) +/* Little-endian bit operations - use asm-generic/bitops/le.h */ +#include <asm-generic/bitops/le.h> /* KUNIT stub - use kunit/static_stub.h */ #include <kunit/static_stub.h> @@ -1280,32 +1273,7 @@ struct buffer_head *__bread(struct block_device *bdev, sector_t block, unsigned /* XArray is now in linux/xarray.h */ /* Per-CPU stubs are in linux/percpu.h */ -/* Bit operations for little-endian bitmaps */ -#define __clear_bit_le(bit, addr) clear_bit_le(bit, addr) - -static inline void clear_bit_le(int nr, void *addr) -{ - unsigned char *p = (unsigned char *)addr + (nr >> 3); - - *p &= ~(1 << (nr & 7)); -} - -#define find_next_bit_le(addr, size, offset) \ - ext4_find_next_bit_le(addr, size, offset) - -static inline unsigned long ext4_find_next_bit_le(const void *addr, - unsigned long size, - unsigned long offset) -{ - const unsigned char *p = addr; - unsigned long bit; - - for (bit = offset; bit < size; bit++) { - if (p[bit >> 3] & (1 << (bit & 7))) - return bit; - } - return size; -} +/* Little-endian bit operations are in asm-generic/bitops/le.h */ /* atomic64 operations are now in asm-generic/atomic.h */ diff --git a/include/asm-generic/bitops/le.h b/include/asm-generic/bitops/le.h new file mode 100644 index 00000000000..78c7207c691 --- /dev/null +++ b/include/asm-generic/bitops/le.h @@ -0,0 +1,76 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Little-endian bitops for U-Boot + * + * Based on Linux include/asm-generic/bitops/le.h + */ +#ifndef _ASM_GENERIC_BITOPS_LE_H +#define _ASM_GENERIC_BITOPS_LE_H + +#include <asm/bitops.h> + +/* + * Little-endian bit operations. + * These operate on byte boundaries regardless of CPU endianness. + */ + +#define find_next_zero_bit_le(addr, size, offset) \ + find_next_zero_bit((void *)(addr), (size), (offset)) + +#define find_next_bit_le(addr, size, offset) \ + ext4_find_next_bit_le((addr), (size), (offset)) + +static inline int test_bit_le(int nr, const void *addr) +{ + return test_bit(nr, addr); +} + +static inline void __set_bit_le(int nr, void *addr) +{ + set_bit(nr, addr); +} + +static inline void __clear_bit_le(int nr, void *addr) +{ + clear_bit(nr, addr); +} + +static inline int __test_and_set_bit_le(int nr, void *addr) +{ + int old = test_bit(nr, addr); + + set_bit(nr, addr); + return old; +} + +static inline int __test_and_clear_bit_le(int nr, void *addr) +{ + int old = test_bit(nr, addr); + + clear_bit(nr, addr); + return old; +} + +/* + * ext4_find_next_bit_le - find next set bit in little-endian bitmap + * @addr: bitmap address + * @size: bitmap size in bits + * @offset: starting bit position + * + * Return: bit position of next set bit, or @size if none found + */ +static inline unsigned long ext4_find_next_bit_le(const void *addr, + unsigned long size, + unsigned long offset) +{ + const unsigned char *p = addr; + unsigned long bit; + + for (bit = offset; bit < size; bit++) { + if (p[bit >> 3] & (1 << (bit & 7))) + return bit; + } + return size; +} + +#endif /* _ASM_GENERIC_BITOPS_LE_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move uuid_to_fsid() to linux/statfs.h where it belongs in the Linux kernel header hierarchy. Also use hexdump.h for DUMP_PREFIX_* types, with a stub for print_hex_dump since the Linux kernel has a different function signature than U-Boot. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 21 ++++++++------------- include/linux/statfs.h | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 6f2ea69a888..09e58989888 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1003,8 +1003,13 @@ static u64 __attribute__((unused)) __ext4_sectors[2]; /* system_state, SYSTEM_HALT, etc. are in linux/kernel.h */ -/* Hex dump */ -#define DUMP_PREFIX_ADDRESS 0 +/* + * Hex dump - DUMP_PREFIX_* types are in hexdump.h. + * However, the Linux kernel print_hex_dump has a different signature + * (includes log level) than U-Boot's, so we stub it out here. + */ +#include <hexdump.h> +#undef print_hex_dump #define print_hex_dump(l, p, pt, rg, gc, b, len, a) do { } while (0) /* SLAB_RECLAIM_ACCOUNT, SLAB_ACCOUNT are in linux/slab.h */ @@ -1037,17 +1042,7 @@ struct super_operations { /* export_operations and fid - use linux/exportfs.h */ #include <linux/exportfs.h> -/* uuid_to_fsid - convert UUID to fsid */ -static inline __kernel_fsid_t uuid_to_fsid(const u8 *uuid) -{ - __kernel_fsid_t fsid; - - fsid.val[0] = (uuid[0] << 24) | (uuid[1] << 16) | - (uuid[2] << 8) | uuid[3]; - fsid.val[1] = (uuid[4] << 24) | (uuid[5] << 16) | - (uuid[6] << 8) | uuid[7]; - return fsid; -} +/* uuid_to_fsid is in linux/statfs.h */ /* kstatfs - use linux/statfs.h */ #include <linux/statfs.h> diff --git a/include/linux/statfs.h b/include/linux/statfs.h index bdc3f9b9e87..6ba93c5b292 100644 --- a/include/linux/statfs.h +++ b/include/linux/statfs.h @@ -39,4 +39,23 @@ struct kstatfs { long f_spare[4]; }; +/** + * uuid_to_fsid - convert UUID to filesystem ID + * @uuid: UUID to convert (at least 8 bytes) + * + * Converts the first 8 bytes of a UUID to a filesystem ID. + * + * Return: the filesystem ID + */ +static inline __kernel_fsid_t uuid_to_fsid(const u8 *uuid) +{ + __kernel_fsid_t fsid; + + fsid.val[0] = (uuid[0] << 24) | (uuid[1] << 16) | + (uuid[2] << 8) | uuid[3]; + fsid.val[1] = (uuid[4] << 24) | (uuid[5] << 16) | + (uuid[6] << 8) | uuid[7]; + return fsid; +} + #endif /* _LINUX_STATFS_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Add ktime_get_real_seconds() and time_before32() to linux/time.h where they belong in the Linux kernel header hierarchy. This removes these stubs from ext4_uboot.h. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 4 +--- include/linux/time.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 09e58989888..d1ec4a84b97 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -229,9 +229,7 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); #define sb_find_get_block(sb, block) ((struct buffer_head *)NULL) #define sync_dirty_buffer(bh) submit_bh(REQ_OP_WRITE, bh) -/* Time functions - use boot-relative time for timestamps */ -#define ktime_get_real_seconds() (get_timer(0) / 1000) -#define time_before32(a, b) (0) +/* Time functions - ktime_get_real_seconds, time_before32 are in linux/time.h */ /* Inode operations - iget_locked and new_inode are in interface.c */ extern struct inode *new_inode(struct super_block *sb); diff --git a/include/linux/time.h b/include/linux/time.h index b23598295c2..17471d2c26c 100644 --- a/include/linux/time.h +++ b/include/linux/time.h @@ -174,4 +174,18 @@ struct timespec64 { long tv_nsec; }; +/* + * time_before32 - check if 32-bit time @b is before time @a + * + * U-Boot stub - time comparison not supported, always returns false. + */ +#define time_before32(b, a) (0) + +/* + * ktime_get_real_seconds - get current wall-clock time in seconds + * + * U-Boot implementation uses get_timer() to return boot-relative time. + */ +#define ktime_get_real_seconds() (get_timer(0) / 1000) + #endif -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move several definitions to their canonical Linux header locations: - MAX_LFS_FILESIZE to linux/fs.h - end_buffer_read_sync() to linux/buffer_head.h This continues reducing ext4_uboot.h by placing these definitions in their proper locations in the Linux header hierarchy. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 13 ++----------- include/linux/buffer_head.h | 14 ++++++++++++++ include/linux/fs.h | 3 +++ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index d1ec4a84b97..b44939bfe5a 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -979,15 +979,7 @@ static inline const char *simple_get_link(struct dentry *dentry, /* QFMT_VFS_* quota format constants are in linux/quotaops.h */ -/* Buffer read sync */ -static inline void end_buffer_read_sync(struct buffer_head *bh, int uptodate) -{ - if (uptodate) - set_buffer_uptodate(bh); - else - clear_buffer_uptodate(bh); - unlock_buffer(bh); -} +/* end_buffer_read_sync is in linux/buffer_head.h */ /* REQ_OP_READ is in linux/blk_types.h */ /* SB_ACTIVE is in linux/fs.h */ @@ -1103,8 +1095,7 @@ void end_buffer_write_sync(struct buffer_head *bh, int uptodate); /* EXT4 magic number */ #define EXT4_SUPER_MAGIC 0xEF53 -/* Max file size for large files */ -#define MAX_LFS_FILESIZE ((loff_t)LLONG_MAX) +/* MAX_LFS_FILESIZE is in linux/fs.h */ /* blockgroup_lock - use linux/blockgroup_lock.h */ #include <linux/blockgroup_lock.h> diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index a160b7d1a67..591f2ec1cbb 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -213,4 +213,18 @@ static inline bool noop_dirty_folio(struct address_space *mapping, return false; } +/* + * end_buffer_read_sync - completion handler for synchronous buffer reads + * @bh: buffer head that completed + * @uptodate: whether the read was successful + */ +static inline void end_buffer_read_sync(struct buffer_head *bh, int uptodate) +{ + if (uptodate) + set_buffer_uptodate(bh); + else + clear_buffer_uptodate(bh); + unlock_buffer(bh); +} + #endif /* _LINUX_BUFFER_HEAD_H */ diff --git a/include/linux/fs.h b/include/linux/fs.h index 993985f88f3..5f1d702bab4 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -318,6 +318,9 @@ enum { #define I_DIRTY_DATASYNC (1 << 2) #define I_DIRTY_TIME (1 << 3) +/* Maximum file size for large files */ +#define MAX_LFS_FILESIZE ((loff_t)LLONG_MAX) + /** * struct fstrim_range - fstrim ioctl argument * @start: first byte to trim -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move bdev_can_atomic_write(), bdev_atomic_write_unit_max_bytes(), and bdev_atomic_write_unit_min_bytes() stubs to linux/blkdev.h where they belong in the Linux kernel header hierarchy. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 5 +---- include/linux/blkdev.h | 5 +++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index b44939bfe5a..b44126a733a 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1181,10 +1181,7 @@ void free_page(unsigned long addr); void *fs_dax_get_by_bdev(struct block_device *bdev, u64 *start, u64 *len, void *holder); -/* Block device atomic write stubs */ -#define bdev_can_atomic_write(bdev) ({ (void)(bdev); 0; }) -#define bdev_atomic_write_unit_max_bytes(bdev) ({ (void)(bdev); (unsigned int)0; }) -#define bdev_atomic_write_unit_min_bytes(bdev) ({ (void)(bdev); 0UL; }) +/* Block device atomic write stubs are in linux/blkdev.h */ /* Superblock blocksize - declaration for stub.c */ int sb_set_blocksize(struct super_block *sb, int size); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index f1a4cc12d3c..eaf2984c08f 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -50,4 +50,9 @@ struct blk_plug { */ #define blk_finish_plug(plug) do { (void)(plug); } while (0) +/* Block device atomic write support - not supported in U-Boot */ +#define bdev_can_atomic_write(bdev) ({ (void)(bdev); 0; }) +#define bdev_atomic_write_unit_max_bytes(bdev) ({ (void)(bdev); (unsigned int)0; }) +#define bdev_atomic_write_unit_min_bytes(bdev) ({ (void)(bdev); 0UL; }) + #endif /* _LINUX_BLKDEV_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move the get_block_t callback typedef to linux/fs.h where it belongs in the Linux kernel header hierarchy. This type is used for filesystem block mapping callbacks. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 8 +------- include/linux/fs.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index b44126a733a..8a2d18ccaf5 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -327,13 +327,7 @@ BUFFER_FNS(OwnsData, ownsdata) #define BH_Cached (BH_JBDPrivateStart + 2) BUFFER_FNS(Cached, cached) -/* Forward declare for get_block_t */ -struct inode; -struct buffer_head; - -/* get_block_t - block mapping callback */ -typedef int (get_block_t)(struct inode *inode, sector_t iblock, - struct buffer_head *bh_result, int create); +/* get_block_t is in linux/fs.h */ /* crc32c - from linux/crc32c.h */ #include <linux/crc32c.h> diff --git a/include/linux/fs.h b/include/linux/fs.h index 5f1d702bab4..a6ad309e5c8 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -321,6 +321,18 @@ enum { /* Maximum file size for large files */ #define MAX_LFS_FILESIZE ((loff_t)LLONG_MAX) +/** + * get_block_t - block mapping callback type + * @inode: inode to map blocks for + * @iblock: logical block number + * @bh_result: buffer head to fill with mapping + * @create: whether to create new blocks + * + * Callback function type for filesystem block mapping. + */ +typedef int (get_block_t)(struct inode *inode, sector_t iblock, + struct buffer_head *bh_result, int create); + /** * struct fstrim_range - fstrim ioctl argument * @start: first byte to trim -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move buffer-related operations to linux/buffer_head.h: - Buffer cache lookup: sb_find_get_block(), sb_find_get_block_nonatomic(), __find_get_block_nonatomic() - Buffer dirty operations: sync_dirty_buffer(), mark_buffer_dirty(), mark_buffer_dirty_inode(), write_dirty_buffer() - Buffer allocation: alloc_buffer_head(), free_buffer_head(), sb_getblk(), __getblk(), sb_getblk_gfp(), getblk_unmovable() - Buffer read: bh_read(), bh_read_nowait(), bh_readahead_batch() - Other: bh_uptodate_or_lock(), submit_bh() declaration Also move IS_DIRSYNC() and IS_NOSEC() to linux/fs.h with the other inode flag checking macros. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 44 ++++++++++++------------------------- include/linux/buffer_head.h | 41 ++++++++++++++++++++++++++++++++++ include/linux/fs.h | 2 ++ 3 files changed, 57 insertions(+), 30 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 8a2d18ccaf5..4ec4d713eb4 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -189,10 +189,7 @@ /* Trace stubs are now in ext4_trace.h */ -/* Buffer operations - wait_on_buffer, lock_buffer, unlock_buffer etc are in linux/buffer_head.h */ -#define mark_buffer_dirty_inode(bh, i) sync_dirty_buffer(bh) -#define mark_buffer_dirty(bh) sync_dirty_buffer(bh) -struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); +/* Buffer operations are in linux/buffer_head.h */ /* wait_on_bit_io is now in linux/wait_bit.h */ /* inode_needs_sync is in linux/fs.h */ @@ -225,9 +222,7 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); /* Random number functions - use linux/random.h */ #include <linux/random.h> -/* Buffer cache operations */ -#define sb_find_get_block(sb, block) ((struct buffer_head *)NULL) -#define sync_dirty_buffer(bh) submit_bh(REQ_OP_WRITE, bh) +/* Buffer cache operations - sb_find_get_block, sync_dirty_buffer are in linux/buffer_head.h */ /* Time functions - ktime_get_real_seconds, time_before32 are in linux/time.h */ @@ -240,7 +235,7 @@ extern struct inode *new_inode(struct super_block *sb); #define insert_inode_locked(inode) (0) #define unlock_new_inode(inode) do { } while (0) #define clear_nlink(inode) do { } while (0) -#define IS_DIRSYNC(inode) ({ (void)(inode); 0; }) +/* IS_DIRSYNC is in linux/fs.h */ /* fscrypt_prepare_new_inode, fscrypt_set_context are in ext4_fscrypt.h */ @@ -619,9 +614,7 @@ struct dx_hash_info { /* rwsem_is_locked is in linux/rwsem.h */ -/* Buffer operations */ -#define sb_getblk_gfp(sb, blk, gfp) sb_getblk((sb), (blk)) -#define bh_uptodate_or_lock(bh) (1) +/* Buffer operations - sb_getblk_gfp, bh_uptodate_or_lock are in linux/buffer_head.h */ /* ext4_read_bh is stubbed in interface.c */ /* Inode locking stubs are in linux/fs.h */ @@ -639,8 +632,7 @@ struct dx_hash_info { #define generic_atomic_write_valid(iocb, from) ({ (void)(iocb); (void)(from); 0; }) #define vfs_setpos(file, offset, maxsize) ({ (void)(file); (void)(maxsize); (offset); }) -/* Security checks - no security in U-Boot */ -#define IS_NOSEC(inode) (1) +/* IS_NOSEC is in linux/fs.h */ /* Filemap operations and fault handlers are in linux/pagemap.h */ @@ -778,7 +770,7 @@ void mapping_clear_folio_cache(struct address_space *mapping); /* try_to_writeback_inodes_sb is in linux/writeback.h */ /* Buffer operations - additional */ -#define getblk_unmovable(bdev, block, size) sb_getblk(bdev->bd_super, block) +/* getblk_unmovable is in linux/buffer_head.h */ #define create_empty_buffers(f, s, flags) ({ (void)(f); (void)(s); (void)(flags); (struct buffer_head *)NULL; }) /* bh_offset returns offset of b_data within the folio */ #define bh_offset(bh) ((bh)->b_folio ? \ @@ -1094,8 +1086,8 @@ void end_buffer_write_sync(struct buffer_head *bh, int uptodate); /* blockgroup_lock - use linux/blockgroup_lock.h */ #include <linux/blockgroup_lock.h> +/* submit_bh is in linux/buffer_head.h */ /* Buffer submission stubs - declarations for stub.c implementations */ -int submit_bh(int op_flags, struct buffer_head *bh); struct buffer_head *bdev_getblk(struct block_device *bdev, sector_t block, unsigned int size, gfp_t gfp); int trylock_buffer(struct buffer_head *bh); @@ -1298,11 +1290,7 @@ struct buffer_head *__bread(struct block_device *bdev, sector_t block, unsigned /* schedule_timeout_uninterruptible, need_resched are in linux/sched.h */ -/* Block device operations */ -#define sb_find_get_block_nonatomic(sb, block) \ - ({ (void)(sb); (void)(block); (struct buffer_head *)NULL; }) -#define __find_get_block_nonatomic(bdev, block, size) \ - ({ (void)(bdev); (void)(block); (void)(size); (struct buffer_head *)NULL; }) +/* sb_find_get_block_nonatomic, __find_get_block_nonatomic are in linux/buffer_head.h */ #define bdev_discard_granularity(bdev) \ ({ (void)(bdev); 0U; }) @@ -1377,9 +1365,9 @@ bool __folio_start_writeback(struct folio *folio, bool keep_write); /* get_current_ioprio is in linux/ioprio.h */ /* JBD2 checkpoint.c stubs */ -#define mutex_lock_io(m) mutex_lock(m) -#define write_dirty_buffer(bh, flags) sync_dirty_buffer(bh) -#define spin_needbreak(l) ({ (void)(l); 0; }) +/* mutex_lock_io is in linux/mutex.h */ +/* write_dirty_buffer is in linux/buffer_head.h */ +/* spin_needbreak is in linux/spinlock.h */ /* JBD2 commit.c stubs (folio_trylock is in linux/pagemap.h) */ #define clear_bit_unlock(nr, addr) clear_bit(nr, addr) @@ -1388,7 +1376,7 @@ bool __folio_start_writeback(struct folio *folio, bool keep_write); #define filemap_fdatawait_range_keep_errors(m, s, e) \ ({ (void)(m); (void)(s); (void)(e); 0; }) #define crc32_be(crc, p, len) crc32(crc, p, len) -void free_buffer_head(struct buffer_head *bh); +/* free_buffer_head is in linux/buffer_head.h */ /* ext4l support functions (support.c) */ void ext4l_crc32c_init(void); @@ -1415,9 +1403,7 @@ struct disk_partition *ext4l_get_partition(void); #define cond_resched_lock(lock) do { (void)(lock); } while (0) /* JBD2 journal.c stubs */ -struct buffer_head *alloc_buffer_head(gfp_t gfp_mask); -struct buffer_head *__getblk(struct block_device *bdev, sector_t block, - unsigned int size); +/* alloc_buffer_head, __getblk are in linux/buffer_head.h */ int bmap(struct inode *inode, sector_t *block); /* seq_file operations for /proc - stubs */ @@ -1438,9 +1424,7 @@ loff_t seq_lseek(struct file *f, loff_t o, int w); /* lockdep_init_map and lock_class_key are in linux/lockdep.h */ /* Block device operations for journal.c */ -int bh_read(struct buffer_head *bh, int flags); -#define bh_read_nowait(bh, flags) bh_read(bh, flags) -#define bh_readahead_batch(n, bhs, f) do { (void)(n); (void)(bhs); (void)(f); } while (0) +/* bh_read, bh_read_nowait, bh_readahead_batch are in linux/buffer_head.h */ #define truncate_inode_pages_range(m, s, e) \ do { (void)(m); (void)(s); (void)(e); } while (0) #define blkdev_issue_discard(bdev, s, n, gfp) \ diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 591f2ec1cbb..3e5893ab99d 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -187,6 +187,37 @@ void __brelse(struct buffer_head *bh); #define unlock_buffer(bh) clear_buffer_locked(bh) #define test_clear_buffer_dirty(bh) ({ (void)(bh); 0; }) +/* Buffer I/O submission - implemented in ext4l/stub.c */ +int submit_bh(int op_flags, struct buffer_head *bh); + +/* Buffer read functions - implemented in ext4l/support.c */ +int bh_read(struct buffer_head *bh, int flags); +#define bh_read_nowait(bh, flags) bh_read(bh, flags) +#define bh_readahead_batch(n, bhs, f) do { (void)(n); (void)(bhs); (void)(f); } while (0) + +/* + * Buffer dirty operations. + * In U-Boot we write buffers synchronously, so marking dirty writes immediately. + */ +#define sync_dirty_buffer(bh) submit_bh(REQ_OP_WRITE, (bh)) +#define mark_buffer_dirty(bh) sync_dirty_buffer(bh) +#define mark_buffer_dirty_inode(bh, i) sync_dirty_buffer(bh) +#define write_dirty_buffer(bh, flags) sync_dirty_buffer(bh) + +/* Buffer uptodate check - always returns true (buffer assumed uptodate) */ +#define bh_uptodate_or_lock(bh) (1) + +/* Buffer allocation functions - implemented in ext4l */ +struct super_block; +struct buffer_head *alloc_buffer_head(gfp_t gfp_mask); +void free_buffer_head(struct buffer_head *bh); +struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); +struct buffer_head *__getblk(struct block_device *bdev, sector_t block, + unsigned int size); +#define sb_getblk_gfp(sb, blk, gfp) sb_getblk((sb), (blk)) +#define getblk_unmovable(bdev, block, size) \ + sb_getblk((bdev)->bd_super, (block)) + /* * Folio migration stubs - U-Boot doesn't support memory migration */ @@ -227,4 +258,14 @@ static inline void end_buffer_read_sync(struct buffer_head *bh, int uptodate) unlock_buffer(bh); } +/* + * Buffer cache lookup stubs - U-Boot doesn't maintain a buffer cache + */ +#define sb_find_get_block(sb, block) \ + ({ (void)(sb); (void)(block); (struct buffer_head *)NULL; }) +#define sb_find_get_block_nonatomic(sb, block) \ + ({ (void)(sb); (void)(block); (struct buffer_head *)NULL; }) +#define __find_get_block_nonatomic(bdev, block, size) \ + ({ (void)(bdev); (void)(block); (void)(size); (struct buffer_head *)NULL; }) + #endif /* _LINUX_BUFFER_HEAD_H */ diff --git a/include/linux/fs.h b/include/linux/fs.h index a6ad309e5c8..431dc0c513a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -305,6 +305,8 @@ enum { #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND) #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE) #define IS_CASEFOLDED(inode) (0) /* Case-folding not supported */ +#define IS_DIRSYNC(inode) ({ (void)(inode); 0; }) +#define IS_NOSEC(inode) (1) /* No security checks in U-Boot */ /* inode_needs_sync - check if inode needs synchronous writes (always false) */ #define inode_needs_sync(inode) (0) -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move inode-related stubs to their proper Linux headers: - inode_io_list_del() to linux/writeback.h - inode_is_open_for_write(), inode_is_dirtytime_only() to linux/fs.h - icount_read(), i_uid_write(), i_gid_write(), inode_fsuid_set() to linux/fs.h - inode_init_owner(), insert_inode_locked(), unlock_new_inode() to linux/fs.h - clear_nlink(), set_nlink(), inc_nlink(), drop_nlink() to linux/fs.h - IS_NOQUOTA(), IS_SWAPFILE() to linux/fs.h - inode_set_ctime_current(), inode_set_mtime_to_ts(), inode_set_flags() to linux/fs.h - inode_set_cached_link(), init_special_inode(), make_bad_inode() to linux/fs.h - iget_failed(), find_inode_by_ino_rcu(), mark_inode_dirty() to linux/fs.h - invalidate_inode_buffers(), clear_inode() to linux/fs.h - i_uid_needs_update(), i_gid_needs_update(), i_uid_update(), i_gid_update() - lock_two_nondirectories(), unlock_two_nondirectories() to linux/fs.h - alloc_inode_sb(), inode_generic_drop() to linux/fs.h Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 66 ++++++++++----------------------------- include/linux/fs.h | 53 +++++++++++++++++++++++++++++++ include/linux/writeback.h | 8 +++++ 3 files changed, 78 insertions(+), 49 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 4ec4d713eb4..49dd566262b 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -214,9 +214,7 @@ /* Quota operations - use linux/quotaops.h */ #include <linux/quotaops.h> -/* icount - inode reference count */ -#define icount_read(inode) (1) - +/* icount_read is in linux/fs.h */ /* d_inode is now in linux/dcache.h */ /* Random number functions - use linux/random.h */ @@ -228,13 +226,8 @@ /* Inode operations - iget_locked and new_inode are in interface.c */ extern struct inode *new_inode(struct super_block *sb); -#define i_uid_write(inode, uid) do { } while (0) -#define i_gid_write(inode, gid) do { } while (0) -#define inode_fsuid_set(inode, idmap) do { } while (0) -#define inode_init_owner(idmap, i, dir, mode) do { (i)->i_mode = (mode); } while (0) -#define insert_inode_locked(inode) (0) -#define unlock_new_inode(inode) do { } while (0) -#define clear_nlink(inode) do { } while (0) +/* i_uid_write, i_gid_write, inode_fsuid_set, inode_init_owner are in linux/fs.h */ +/* insert_inode_locked, unlock_new_inode, clear_nlink are in linux/fs.h */ /* IS_DIRSYNC is in linux/fs.h */ /* fscrypt_prepare_new_inode, fscrypt_set_context are in ext4_fscrypt.h */ @@ -335,9 +328,7 @@ BUFFER_FNS(Cached, cached) /* errseq_t is defined in linux/fs.h */ /* time64_t is now in linux/time.h */ -/* IS_NOQUOTA - stub */ -#define IS_NOQUOTA(inode) (0) - +/* IS_NOQUOTA is in linux/fs.h */ /* dentry, name_snapshot are now in linux/dcache.h */ /* VM types - use linux/mm_types.h */ @@ -640,8 +631,7 @@ struct dx_hash_info { #define daxdev_mapping_supported(f, i, d) ({ (void)(f); (void)(i); (void)(d); 1; }) /* Inode time/size operations - inode_newsize_ok, i_blocksize, IS_SYNC are in linux/fs.h */ -#define inode_set_ctime_current(i) ({ (void)(i); (struct timespec64){}; }) -#define inode_set_mtime_to_ts(i, ts) ({ (void)(i); (ts); }) +/* inode_set_ctime_current, inode_set_mtime_to_ts are in linux/fs.h */ /* Case-folding stubs - not supported in U-Boot */ #define sb_no_casefold_compat_fallback(sb) ({ (void)(sb); 1; }) @@ -754,10 +744,8 @@ void mapping_clear_folio_cache(struct address_space *mapping); /* dquot_file_open is in linux/quotaops.h */ -/* Inode I/O list management */ -#define inode_io_list_del(inode) do { } while (0) -#define inode_is_open_for_write(i) (0) -#define inode_is_dirtytime_only(i) (0) +/* inode_io_list_del is in linux/writeback.h */ +/* inode_is_open_for_write, inode_is_dirtytime_only are in linux/fs.h */ /* Folio operations and writeback stubs are in linux/pagemap.h */ #define folio_batch_release(fb) do { } while (0) @@ -805,9 +793,9 @@ static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode, /* Inode version operations - use linux/iversion.h */ #include <linux/iversion.h> -#define inode_set_flags(i, f, m) do { } while (0) +/* inode_set_flags is in linux/fs.h */ -/* Inode credential helpers */ +/* Inode credential helpers - i_uid_read, i_gid_read need struct inode */ static inline unsigned int i_uid_read(const struct inode *inode) { return inode->i_uid.val; @@ -818,10 +806,7 @@ static inline unsigned int i_gid_read(const struct inode *inode) return inode->i_gid.val; } -#define i_uid_needs_update(m, a, i) ({ (void)(m); (void)(a); (void)(i); 0; }) -#define i_gid_needs_update(m, a, i) ({ (void)(m); (void)(a); (void)(i); 0; }) -#define i_uid_update(m, a, i) do { } while (0) -#define i_gid_update(m, a, i) do { } while (0) +/* i_uid_needs_update, i_gid_needs_update, i_uid_update, i_gid_update are in linux/fs.h */ /* Device encoding helpers are now in linux/kdev_t.h */ #include <linux/kdev_t.h> @@ -831,15 +816,9 @@ static inline unsigned int i_gid_read(const struct inode *inode) /* Inode allocation/state operations */ extern struct inode *iget_locked(struct super_block *sb, unsigned long ino); -#define set_nlink(i, n) do { (i)->i_nlink = (n); } while (0) -#define inc_nlink(i) do { (i)->i_nlink++; } while (0) -#define drop_nlink(i) do { (i)->i_nlink--; } while (0) -#define inode_set_cached_link(i, l, len) do { } while (0) -#define init_special_inode(i, m, d) do { } while (0) -#define make_bad_inode(i) do { } while (0) -#define iget_failed(i) do { } while (0) -#define find_inode_by_ino_rcu(sb, ino) ((struct inode *)NULL) -#define mark_inode_dirty(i) do { } while (0) +/* set_nlink, inc_nlink, drop_nlink are in linux/fs.h */ +/* inode_set_cached_link, init_special_inode, make_bad_inode are in linux/fs.h */ +/* iget_failed, find_inode_by_ino_rcu, mark_inode_dirty are in linux/fs.h */ /* Attribute operations */ #define setattr_prepare(m, d, a) ({ (void)(m); (void)(d); (void)(a); 0; }) @@ -1118,11 +1097,8 @@ void fs_put_dax(void *dax, void *holder); /* fscrypt declarations are in ext4_fscrypt.h */ -/* Inode allocation - declaration for stub.c */ -void *alloc_inode_sb(struct super_block *sb, struct kmem_cache *cache, - gfp_t gfp); +/* alloc_inode_sb, inode_generic_drop are in linux/fs.h */ /* inode_set_iversion is in linux/iversion.h */ -int inode_generic_drop(struct inode *inode); /* rwlock_init is a macro in linux/spinlock.h */ @@ -1130,10 +1106,7 @@ int inode_generic_drop(struct inode *inode); #define kmem_cache_create_usercopy(n, sz, al, fl, uo, us, c) \ kmem_cache_create(n, sz, al, fl, c) -/* Inode buffer operations */ -#define invalidate_inode_buffers(i) do { } while (0) -#define clear_inode(i) do { } while (0) - +/* invalidate_inode_buffers, clear_inode are in linux/fs.h */ /* fsverity_cleanup_inode is in linux/fsverity.h */ /* NFS export helpers are now in linux/exportfs.h */ @@ -1458,19 +1431,14 @@ loff_t seq_lseek(struct file *f, loff_t o, int w); /* filemap_release_folio is in linux/pagemap.h */ -/* IS_SWAPFILE - check if inode is a swap file */ -#define IS_SWAPFILE(inode) ({ (void)(inode); 0; }) +/* IS_SWAPFILE is in linux/fs.h */ /* PAGE_MASK - mask for page alignment */ #ifndef PAGE_MASK #define PAGE_MASK (~(PAGE_SIZE - 1)) #endif -/* lock_two_nondirectories - lock two inodes in order */ -#define lock_two_nondirectories(i1, i2) \ - do { (void)(i1); (void)(i2); } while (0) -#define unlock_two_nondirectories(i1, i2) \ - do { (void)(i1); (void)(i2); } while (0) +/* lock_two_nondirectories, unlock_two_nondirectories are in linux/fs.h */ /* * Stubs for resize.c diff --git a/include/linux/fs.h b/include/linux/fs.h index 431dc0c513a..aac88e7c68c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -314,6 +314,12 @@ enum { /* is_bad_inode - check if inode is marked bad (always false in U-Boot) */ #define is_bad_inode(inode) (0) +/* inode_is_open_for_write - check if inode has open writers (always false) */ +#define inode_is_open_for_write(inode) ({ (void)(inode); 0; }) + +/* inode_is_dirtytime_only - check if inode has only dirty time (always false) */ +#define inode_is_dirtytime_only(inode) ({ (void)(inode); 0; }) + /* Inode state bits for i_state field */ #define I_NEW (1 << 0) #define I_FREEING (1 << 1) @@ -323,6 +329,53 @@ enum { /* Maximum file size for large files */ #define MAX_LFS_FILESIZE ((loff_t)LLONG_MAX) +/* + * Inode operation stubs - U-Boot has simplified inode handling + */ +#define icount_read(inode) (1) +#define i_uid_write(inode, uid) do { } while (0) +#define i_gid_write(inode, gid) do { } while (0) +#define inode_fsuid_set(inode, idmap) do { } while (0) +#define inode_init_owner(idmap, i, dir, mode) \ + do { (i)->i_mode = (mode); } while (0) +#define insert_inode_locked(inode) (0) +#define unlock_new_inode(inode) do { } while (0) +#define clear_nlink(inode) do { } while (0) +#define set_nlink(i, n) do { (i)->i_nlink = (n); } while (0) +#define inc_nlink(i) do { (i)->i_nlink++; } while (0) +#define drop_nlink(i) do { (i)->i_nlink--; } while (0) +#define IS_NOQUOTA(inode) (0) +#define IS_SWAPFILE(inode) ({ (void)(inode); 0; }) +#define inode_set_ctime_current(i) ({ (void)(i); (struct timespec64){}; }) +#define inode_set_mtime_to_ts(i, ts) ({ (void)(i); (ts); }) +#define inode_set_flags(i, f, m) do { } while (0) +#define inode_set_cached_link(i, l, len) do { } while (0) +#define init_special_inode(i, m, d) do { } while (0) +#define make_bad_inode(i) do { } while (0) +#define iget_failed(i) do { } while (0) +#define find_inode_by_ino_rcu(sb, ino) ((struct inode *)NULL) +#define mark_inode_dirty(i) do { } while (0) +#define invalidate_inode_buffers(i) do { } while (0) +#define clear_inode(i) do { } while (0) + +/* Inode credential helpers */ +#define i_uid_needs_update(m, a, i) ({ (void)(m); (void)(a); (void)(i); 0; }) +#define i_gid_needs_update(m, a, i) ({ (void)(m); (void)(a); (void)(i); 0; }) +#define i_uid_update(m, a, i) do { } while (0) +#define i_gid_update(m, a, i) do { } while (0) + +/* lock_two_nondirectories - lock two inodes in order */ +#define lock_two_nondirectories(i1, i2) \ + do { (void)(i1); (void)(i2); } while (0) +#define unlock_two_nondirectories(i1, i2) \ + do { (void)(i1); (void)(i2); } while (0) + +/* Inode allocation - implemented in ext4l/stub.c */ +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); + /** * get_block_t - block mapping callback type * @inode: inode to map blocks for diff --git a/include/linux/writeback.h b/include/linux/writeback.h index e408e3ddebb..8875b099082 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -46,4 +46,12 @@ static inline xa_mark_t wbc_to_tag(struct writeback_control *wbc) #define try_to_writeback_inodes_sb(sb, reason) \ do { (void)(sb); (void)(reason); } while (0) +/** + * inode_io_list_del() - remove inode from I/O list + * @inode: inode to remove + * + * U-Boot stub - no I/O list management. + */ +#define inode_io_list_del(inode) do { (void)(inode); } while (0) + #endif /* WRITEBACK_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move folio-related definitions to their proper Linux headers: - folio_batch_release() to linux/pagevec.h - Block/buffer folio operations: bh_offset(), block_invalidate_folio(), block_dirty_folio(), block_read_full_folio(), etc. to linux/buffer_head.h - Folio function declarations: __filemap_get_folio(), folio_put(), folio_get(), etc. to linux/pagemap.h - Folio writeback and read stubs to linux/pagemap.h - Writeback control stubs: wbc_init_bio(), wbc_account_cgroup_owner() to linux/pagemap.h Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 49 ++++++------------------------------- include/linux/buffer_head.h | 19 ++++++++++++++ include/linux/pagemap.h | 18 ++++++++++++++ include/linux/pagevec.h | 11 +++++++++ 4 files changed, 56 insertions(+), 41 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 49dd566262b..12250b8daf4 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -690,14 +690,7 @@ struct dx_hash_info { /* address_space_operations is in linux/fs.h */ /* buffer_migrate_folio, buffer_migrate_folio_norefs, noop_dirty_folio are in linux/buffer_head.h */ /* readahead_control, FGP_*, kmap/kunmap, folio stubs are in linux/pagemap.h */ - -/* Folio operations - implemented in support.c */ -struct folio *__filemap_get_folio(struct address_space *mapping, - pgoff_t index, unsigned int fgp_flags, - gfp_t gfp); -void folio_put(struct folio *folio); -void folio_get(struct folio *folio); -void mapping_clear_folio_cache(struct address_space *mapping); +/* __filemap_get_folio, folio_put, folio_get, mapping_clear_folio_cache are in linux/pagemap.h */ /* projid_t is now in linux/projid.h */ @@ -748,7 +741,7 @@ void mapping_clear_folio_cache(struct address_space *mapping); /* inode_is_open_for_write, inode_is_dirtytime_only are in linux/fs.h */ /* Folio operations and writeback stubs are in linux/pagemap.h */ -#define folio_batch_release(fb) do { } while (0) +/* folio_batch_release is in linux/pagevec.h */ /* Quota stubs are in linux/quotaops.h */ @@ -757,20 +750,8 @@ void mapping_clear_folio_cache(struct address_space *mapping); /* Filemap operations are in linux/pagemap.h */ /* try_to_writeback_inodes_sb is in linux/writeback.h */ -/* Buffer operations - additional */ -/* getblk_unmovable is in linux/buffer_head.h */ -#define create_empty_buffers(f, s, flags) ({ (void)(f); (void)(s); (void)(flags); (struct buffer_head *)NULL; }) -/* bh_offset returns offset of b_data within the folio */ -#define bh_offset(bh) ((bh)->b_folio ? \ - (unsigned long)((char *)(bh)->b_data - (char *)(bh)->b_folio->data) : 0UL) -#define block_invalidate_folio(f, o, l) do { } while (0) -#define block_write_end(pos, len, copied, folio) ({ (void)(pos); (void)(len); (void)(folio); (copied); }) -#define block_dirty_folio(m, f) ({ (void)(m); (void)(f); false; }) -#define try_to_free_buffers(f) ({ (void)(f); true; }) -#define block_commit_write(f, f2, t) do { } while (0) -#define block_page_mkwrite(v, f, g) ((vm_fault_t)0) -#define map_bh(bh, sb, block) do { } while (0) -#define write_begin_get_folio(iocb, m, idx, l) ({ (void)(iocb); (void)(m); (void)(idx); (void)(l); (struct folio *)NULL; }) +/* Buffer/block folio operations are in linux/buffer_head.h */ +/* write_begin_get_folio is in linux/pagemap.h */ /* fscrypt_name, fscrypt_match_name, and fscrypt stubs are in ext4_fscrypt.h */ @@ -1283,17 +1264,8 @@ struct buffer_head *__bread(struct block_device *bdev, sector_t block, unsigned /* fscrypt page-io stubs are in ext4_fscrypt.h */ -/* folio writeback operations */ -#define folio_end_writeback(f) do { (void)(f); } while (0) -#define folio_start_writeback(f) do { (void)(f); } while (0) -#define folio_start_writeback_keepwrite(f) do { (void)(f); } while (0) -bool __folio_start_writeback(struct folio *folio, bool keep_write); - -/* writeback control stubs */ -#define wbc_init_bio(wbc, bio) do { (void)(wbc); (void)(bio); } while (0) -#define wbc_account_cgroup_owner(wbc, folio, bytes) \ - do { (void)(wbc); (void)(folio); (void)(bytes); } while (0) - +/* folio writeback operations are in linux/pagemap.h */ +/* writeback control stubs are in linux/pagemap.h */ /* bio_add_folio is in linux/bio.h */ /* @@ -1303,10 +1275,7 @@ bool __folio_start_writeback(struct folio *folio, bool keep_write); /* mempool is now in linux/mempool.h */ #include <linux/mempool.h> -/* folio read operations */ -#define folio_end_read(f, success) do { (void)(f); (void)(success); } while (0) -#define folio_set_mappedtodisk(f) do { (void)(f); } while (0) - +/* folio read operations are in linux/pagemap.h */ /* fscrypt readpage stubs are in ext4_fscrypt.h */ /* fsverity stubs are in linux/fsverity.h */ @@ -1316,9 +1285,7 @@ bool __folio_start_writeback(struct folio *folio, bool keep_write); /* prefetch operations */ #define prefetchw(addr) do { (void)(addr); } while (0) -/* block read operations */ -#define block_read_full_folio(folio, get_block) \ - ({ (void)(folio); (void)(get_block); 0; }) +/* block_read_full_folio is in linux/buffer_head.h */ /* * Stubs for fast_commit.c diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 3e5893ab99d..ea317a6488d 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -268,4 +268,23 @@ static inline void end_buffer_read_sync(struct buffer_head *bh, int uptodate) #define __find_get_block_nonatomic(bdev, block, size) \ ({ (void)(bdev); (void)(block); (void)(size); (struct buffer_head *)NULL; }) +/* + * Block/buffer folio operations - U-Boot stubs + */ +#define create_empty_buffers(f, s, flags) \ + ({ (void)(f); (void)(s); (void)(flags); (struct buffer_head *)NULL; }) +/* bh_offset returns offset of b_data within the folio */ +#define bh_offset(bh) ((bh)->b_folio ? \ + (unsigned long)((char *)(bh)->b_data - (char *)(bh)->b_folio->data) : 0UL) +#define block_invalidate_folio(f, o, l) do { } while (0) +#define block_write_end(pos, len, copied, folio) \ + ({ (void)(pos); (void)(len); (void)(folio); (copied); }) +#define block_dirty_folio(m, f) ({ (void)(m); (void)(f); false; }) +#define try_to_free_buffers(f) ({ (void)(f); true; }) +#define block_commit_write(f, f2, t) do { } while (0) +#define block_page_mkwrite(v, f, g) ((vm_fault_t)0) +#define map_bh(bh, sb, block) do { } while (0) +#define block_read_full_folio(folio, get_block) \ + ({ (void)(folio); (void)(get_block); 0; }) + #endif /* _LINUX_BUFFER_HEAD_H */ diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 19a64993955..eb689fa885f 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -94,11 +94,29 @@ struct folio { #define folio_end_writeback(f) do { (void)(f); } while (0) #define folio_start_writeback(f) do { (void)(f); } while (0) #define folio_start_writeback_keepwrite(f) do { (void)(f); } while (0) +bool __folio_start_writeback(struct folio *folio, bool keep_write); #define folio_end_read(f, success) do { (void)(f); (void)(success); } while (0) #define folio_set_mappedtodisk(f) do { (void)(f); } while (0) #define folio_redirty_for_writepage(wbc, folio) \ ({ (void)(wbc); (void)(folio); false; }) +/* Folio operations - implemented in ext4l/support.c */ +struct folio *__filemap_get_folio(struct address_space *mapping, + pgoff_t index, unsigned int fgp_flags, + gfp_t gfp); +void folio_put(struct folio *folio); +void folio_get(struct folio *folio); +void mapping_clear_folio_cache(struct address_space *mapping); + +/* Writeback control stubs */ +#define wbc_init_bio(wbc, bio) do { (void)(wbc); (void)(bio); } while (0) +#define wbc_account_cgroup_owner(wbc, folio, bytes) \ + do { (void)(wbc); (void)(folio); (void)(bytes); } while (0) + +/* Write begin helper */ +#define write_begin_get_folio(iocb, m, idx, l) \ + ({ (void)(iocb); (void)(m); (void)(idx); (void)(l); (struct folio *)NULL; }) + /* * offset_in_folio - calculate offset of pointer within folio's data * diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index b794ff8f47c..b83a8420b3d 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -43,4 +43,15 @@ static inline unsigned int folio_batch_add(struct folio_batch *fbatch, return PAGEVEC_SIZE - fbatch->nr; } +/** + * folio_batch_release() - release a batch of folios + * @fbatch: batch to release + * + * U-Boot stub - no-op. + */ +static inline void folio_batch_release(struct folio_batch *fbatch) +{ + (void)fbatch; +} + #endif /* _LINUX_PAGEVEC_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move struct super_operations to linux/fs/super_types.h where the Linux kernel defines it, alongside struct super_block. Add forward declarations for the types used by super_operations members. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 21 +-------------------- include/linux/fs/super_types.h | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 12250b8daf4..1ac7b63819a 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -954,26 +954,7 @@ static u64 __attribute__((unused)) __ext4_sectors[2]; struct kstatfs; struct fid; -/* super_operations - for VFS */ -struct super_operations { - struct inode *(*alloc_inode)(struct super_block *); - void (*free_inode)(struct inode *); - void (*destroy_inode)(struct inode *); - int (*write_inode)(struct inode *, struct writeback_control *); - void (*dirty_inode)(struct inode *, int); - int (*drop_inode)(struct inode *); - void (*evict_inode)(struct inode *); - void (*put_super)(struct super_block *); - int (*sync_fs)(struct super_block *, int); - int (*freeze_fs)(struct super_block *); - int (*unfreeze_fs)(struct super_block *); - int (*statfs)(struct dentry *, struct kstatfs *); - int (*show_options)(struct seq_file *, struct dentry *); - void (*shutdown)(struct super_block *); - ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); - ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); - struct dentry *(*get_dquots)(struct inode *); -}; +/* super_operations is in linux/fs/super_types.h */ /* export_operations and fid - use linux/exportfs.h */ #include <linux/exportfs.h> diff --git a/include/linux/fs/super_types.h b/include/linux/fs/super_types.h index f3ed772ef40..67e02a04bfb 100644 --- a/include/linux/fs/super_types.h +++ b/include/linux/fs/super_types.h @@ -20,6 +20,10 @@ struct file_system_type; struct super_operations; struct export_operations; struct xattr_handler; +struct inode; +struct writeback_control; +struct kstatfs; +struct seq_file; /* sb_writers stub */ struct sb_writers { @@ -54,6 +58,28 @@ struct super_block { struct list_head s_inodes; }; +/* super_operations - VFS superblock operations */ +struct super_operations { + struct inode *(*alloc_inode)(struct super_block *); + void (*free_inode)(struct inode *); + void (*destroy_inode)(struct inode *); + int (*write_inode)(struct inode *, struct writeback_control *); + void (*dirty_inode)(struct inode *, int); + int (*drop_inode)(struct inode *); + void (*evict_inode)(struct inode *); + void (*put_super)(struct super_block *); + int (*sync_fs)(struct super_block *, int); + int (*freeze_fs)(struct super_block *); + int (*unfreeze_fs)(struct super_block *); + int (*statfs)(struct dentry *, struct kstatfs *); + int (*show_options)(struct seq_file *, struct dentry *); + void (*shutdown)(struct super_block *); + ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); + ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, + loff_t); + struct dentry *(*get_dquots)(struct inode *); +}; + /* Superblock flags - also defined in linux/fs.h */ #ifndef SB_RDONLY #define SB_RDONLY (1 << 0) /* Read-only mount */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move mutex_lock_io() to linux/mutex.h where the Linux kernel defines it. Move spin_needbreak() to linux/spinlock.h where the Linux kernel defines it. Move cond_resched_lock() to linux/sched.h where the Linux kernel defines it. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 3 +-- include/linux/mutex.h | 1 + include/linux/sched.h | 1 + include/linux/spinlock.h | 3 +++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 1ac7b63819a..5ab32cba969 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1320,8 +1320,7 @@ struct disk_partition *ext4l_get_partition(void); /* DEFINE_WAIT stub - creates a wait queue entry */ #define DEFINE_WAIT(name) int name = 0 -/* cond_resched_lock - conditionally reschedule while holding a lock */ -#define cond_resched_lock(lock) do { (void)(lock); } while (0) +/* cond_resched_lock is in linux/sched.h */ /* JBD2 journal.c stubs */ /* alloc_buffer_head, __getblk are in linux/buffer_head.h */ diff --git a/include/linux/mutex.h b/include/linux/mutex.h index b13d85ef4e9..2246feaf261 100644 --- a/include/linux/mutex.h +++ b/include/linux/mutex.h @@ -25,6 +25,7 @@ struct mutex { #define mutex_trylock(lock) ({ 1; }) #define mutex_is_locked(lock) ({ 0; }) #define mutex_destroy(lock) do { } while (0) +#define mutex_lock_io(lock) mutex_lock(lock) #define __MUTEX_INITIALIZER(lockname) { .locked = 0 } diff --git a/include/linux/sched.h b/include/linux/sched.h index 579468ee414..9dca8f89f79 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -35,6 +35,7 @@ extern struct task_struct *current; #define TASK_UNINTERRUPTIBLE 2 #define cond_resched() do { } while (0) +#define cond_resched_lock(lock) do { (void)(lock); } while (0) #define yield() do { } while (0) /* Note: schedule() is implemented in common/cyclic.c */ diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index 75afad92b9e..09fe285dfed 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h @@ -78,6 +78,9 @@ typedef struct { /* Assert variants */ #define assert_spin_locked(lock) do { } while (0) +/* spin_needbreak - check if lock should be released (always false in U-Boot) */ +#define spin_needbreak(lock) ({ (void)(lock); 0; }) + /* Read-write lock type - just an int for U-Boot */ typedef int rwlock_t; -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create asm-generic/bitops/lock.h with clear_bit_unlock() and test_and_set_bit_lock() stubs, matching the Linux kernel's location. Move write_trylock() to linux/spinlock.h where the Linux kernel defines it. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 9 ++++----- include/asm-generic/bitops/lock.h | 30 ++++++++++++++++++++++++++++++ include/linux/spinlock.h | 1 + 3 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 include/asm-generic/bitops/lock.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 5ab32cba969..7d1704945a3 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -669,8 +669,7 @@ struct dx_hash_info { /* hrtimer - use linux/hrtimer.h */ #include <linux/hrtimer.h> -/* write lock variants */ -#define write_trylock(lock) ({ (void)(lock); 1; }) +/* write_trylock is in linux/spinlock.h */ /* percpu_counter_init/destroy are in linux/percpu_counter.h */ @@ -1291,7 +1290,8 @@ struct buffer_head *__bread(struct block_device *bdev, sector_t block, unsigned /* spin_needbreak is in linux/spinlock.h */ /* JBD2 commit.c stubs (folio_trylock is in linux/pagemap.h) */ -#define clear_bit_unlock(nr, addr) clear_bit(nr, addr) +/* clear_bit_unlock is in asm-generic/bitops/lock.h */ +#include <asm-generic/bitops/lock.h> /* smp_mb__after_atomic is now in linux/smp.h */ #define ktime_get_coarse_real_ts64(ts) do { (ts)->tv_sec = 0; (ts)->tv_nsec = 0; } while (0) #define filemap_fdatawait_range_keep_errors(m, s, e) \ @@ -1391,8 +1391,7 @@ loff_t seq_lseek(struct file *f, loff_t o, int w); * Stubs for resize.c */ -/* test_and_set_bit_lock - test and set a bit atomically */ -#define test_and_set_bit_lock(nr, addr) test_and_set_bit(nr, addr) +/* test_and_set_bit_lock is in asm-generic/bitops/lock.h */ /* time_is_before_jiffies - check if time is before current jiffies */ #define time_is_before_jiffies(a) ({ (void)(a); 0; }) diff --git a/include/asm-generic/bitops/lock.h b/include/asm-generic/bitops/lock.h new file mode 100644 index 00000000000..34fe437b1f1 --- /dev/null +++ b/include/asm-generic/bitops/lock.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Locking bit operations + * + * U-Boot stub - single-threaded, no actual locking needed. + */ +#ifndef _ASM_GENERIC_BITOPS_LOCK_H +#define _ASM_GENERIC_BITOPS_LOCK_H + +#include <linux/bitops.h> + +/** + * clear_bit_unlock - clear a bit with release semantics + * @nr: bit number to clear + * @addr: address of the bitmap + * + * U-Boot stub - just calls clear_bit() since we're single-threaded. + */ +#define clear_bit_unlock(nr, addr) clear_bit(nr, addr) + +/** + * test_and_set_bit_lock - test and set a bit with acquire semantics + * @nr: bit number to test and set + * @addr: address of the bitmap + * + * U-Boot stub - just calls test_and_set_bit() since we're single-threaded. + */ +#define test_and_set_bit_lock(nr, addr) test_and_set_bit(nr, addr) + +#endif /* _ASM_GENERIC_BITOPS_LOCK_H */ diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index 09fe285dfed..d938cd69d2b 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h @@ -101,5 +101,6 @@ typedef int rwlock_t; #define read_unlock_irqrestore(lock, flags) do { (void)(flags); } while (0) #define write_lock_irqsave(lock, flags) do { (void)(flags); } while (0) #define write_unlock_irqrestore(lock, flags) do { (void)(flags); } while (0) +#define write_trylock(lock) ({ (void)(lock); 1; }) #endif /* __LINUX_SPINLOCK_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move sb_start_write(), sb_end_write(), and sb_start_write_trylock() to linux/fs/super_types.h alongside the other superblock definitions. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 5 +---- include/linux/fs/super_types.h | 7 +++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 7d1704945a3..2f73325e521 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1086,10 +1086,7 @@ void *kvzalloc(size_t size, gfp_t flags); /* Time operations - ktime_get_ns is in linux/ktime.h */ /* nsecs_to_jiffies is in linux/jiffies.h */ -/* Superblock write operations */ -#define sb_start_write_trylock(sb) ({ (void)(sb); 1; }) -#define sb_start_write(sb) do { } while (0) -#define sb_end_write(sb) do { } while (0) +/* sb_start_write, sb_end_write are in linux/fs/super_types.h */ /* schedule_timeout_interruptible is in linux/sched.h */ diff --git a/include/linux/fs/super_types.h b/include/linux/fs/super_types.h index 67e02a04bfb..c575d268c43 100644 --- a/include/linux/fs/super_types.h +++ b/include/linux/fs/super_types.h @@ -91,4 +91,11 @@ static inline bool sb_rdonly(const struct super_block *sb) return sb->s_flags & SB_RDONLY; } +/* + * Superblock write operations - U-Boot is single-threaded, no locking needed + */ +#define sb_start_write(sb) do { (void)(sb); } while (0) +#define sb_end_write(sb) do { (void)(sb); } while (0) +#define sb_start_write_trylock(sb) ({ (void)(sb); 1; }) + #endif /* _LINUX_FS_SUPER_TYPES_H */ -- 2.43.0
participants (1)
-
Simon Glass