[PATCH 00/34] ext4l: Clean up ext4_uboot.h by moving definitions to standard headers
From: Simon Glass <simon.glass@canonical.com> This series reorganises fs/ext4l/ext4_uboot.h by moving definitions to their proper locations in the Linux compatibility headers. The goal is to reduce duplication and make these definitions available to other parts of U-Boot. The file is reduced from 3129 lines to 2584 lines (17% reduction). Changes fall into several categories: 1. Moving standard Linux definitions to include/linux/*.h: - Types: pgoff_t, timespec64, time64_t, blk_opf_t - Filesystem: dir_context, FMODE_*, DT_*, S_*, ATTR_*, SB_*, FALLOC_FL_*, RENAME_* - Buffer: buffer_migrate_folio, noop_dirty_folio - Misc: jiffies, printk variants, module stubs, seq_file 2. Creating new Linux compatibility headers: - linux/lockdep.h: lock dependency stubs - linux/percpu.h: per-CPU variable stubs 3. Consolidating ext4l-specific stubs: - fs/ext4l/ext4_trace.h: tracing stubs - fs/ext4l/ext4_fscrypt.h: fscrypt stubs 4. Using existing headers instead of duplicating: - linux/blk_types.h for blk_opf_t - linux/pagevec.h for folio_batch - linux/completion.h for completion stubs - linux/build_bug.h and linux/bug.h for assertion macros 5. Removing dead code and duplicate definitions This cleanup makes the ext4l code more maintainable and brings the Linux compatibility layer closer to the actual Linux kernel structure. There is still more which could be done, but the goal is not to empty the header file, since most of its contents is of no use to the rest of U-Boot. Simon Glass (34): ext4l: Move timespec64 and time64_t to linux/time.h ext4l: Move rol32 to linux/bitops.h ext4l: Move atomic operations to asm-generic/atomic.h ext4l: Consolidate trace stubs into ext4_trace.h ext4l: Remove duplicate macro definitions ext4l: Move flush_workqueue to linux/workqueue.h ext4l: Consolidate fscrypt stubs into ext4_fscrypt.h ext4l: Remove duplicate percpu_counter stubs ext4l: Use linux/completion.h for completion stubs ext4l: Convert dquot_suspend from function to macro ext4l: Remove dead iomap definitions ext4l: Create linux/percpu.h for per-CPU stubs ext4l: Remove redundant forward declarations ext4l: Move buffer operation stubs to linux/buffer_head.h ext4l: Move address_space_operations to linux/fs.h ext4l: Use linux/build_bug.h and linux/bug.h for macros ext4l: Move seq_file definitions to linux/seq_file.h ext4l: Use linux/pagevec.h for folio_batch ext4l: Move printk variants to linux/printk.h ext4l: Move jiffies definitions to linux/jiffies.h ext4l: Move module stubs to linux/module.h ext4l: Create linux/lockdep.h for lock dependency stubs ext4l: Move string helpers to standard locations ext4l: Move FMODE hash flags to linux/fs.h ext4l: Move struct dir_context to linux/fs.h ext4l: Move pgoff_t to linux/types.h ext4l: Use linux/blk_types.h for blk_opf_t ext4l: Move DT_* directory entry types to linux/fs.h ext4l: Move S_* inode flags to linux/fs.h ext4l: Move S_IRUGO to linux/fs.h ext4l: Move FALLOC_FL_* and RENAME_* flags to linux/fs.h ext4l: Move ATTR_* iattr flags to linux/fs.h ext4l: Move SB_* superblock flags to linux/fs.h ext4l: Move buffer migration stubs to linux/buffer_head.h fs/ext4l/ext4_fscrypt.h | 144 +++++++ fs/ext4l/ext4_trace.h | 172 ++++++++ fs/ext4l/ext4_uboot.h | 787 ++++++----------------------------- fs/ext4l/stub.c | 54 +-- include/asm-generic/atomic.h | 53 +++ include/linux/bitops.h | 20 + include/linux/buffer_head.h | 36 ++ include/linux/completion.h | 24 +- include/linux/fs.h | 125 +++++- include/linux/jiffies.h | 14 + include/linux/lockdep.h | 36 ++ include/linux/module.h | 5 + include/linux/percpu.h | 54 +++ include/linux/printk.h | 11 + include/linux/seq_file.h | 13 + include/linux/slab.h | 16 + include/linux/string.h | 41 ++ include/linux/time.h | 8 + include/linux/types.h | 3 + include/linux/workqueue.h | 4 + lib/string.c | 25 ++ 21 files changed, 920 insertions(+), 725 deletions(-) create mode 100644 fs/ext4l/ext4_fscrypt.h create mode 100644 fs/ext4l/ext4_trace.h create mode 100644 include/linux/lockdep.h create mode 100644 include/linux/percpu.h -- 2.43.0 base-commit: a5a45ea2b2f3503462ab0a4ac2163fdbc5ba2c2e branch: extq
From: Simon Glass <simon.glass@canonical.com> Move the timespec64 structure and time64_t typedef from ext4_uboot.h to include/linux/time.h where they logically belong. This reduces duplication and aligns with Linux kernel header organisation. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 11 +++-------- include/linux/time.h | 8 ++++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 4a7e41a75a1..b2a33a17198 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -38,6 +38,7 @@ #include <linux/iomap.h> #include <linux/seq_file.h> #include <linux/rbtree.h> /* Real rbtree implementation */ +#include <linux/time.h> /* For timespec64, time64_t */ #include <u-boot/crc.h> /* For crc32() used by crc32_be */ /* @@ -70,11 +71,7 @@ static inline u32 rol32(u32 word, unsigned int shift) return (word << (shift & 31)) | (word >> ((-shift) & 31)); } -/* Time types */ -struct timespec64 { - time_t tv_sec; - long tv_nsec; -}; +/* Time types - timespec64 and time64_t are now in linux/time.h */ /* * ktime_t, sector_t are now in linux/types.h @@ -544,9 +541,7 @@ struct fscrypt_dummy_policy { }; /* errseq_t is defined in linux/fs.h */ - -/* time64_t */ -typedef s64 time64_t; +/* time64_t is now in linux/time.h */ /* IS_NOQUOTA - stub */ #define IS_NOQUOTA(inode) (0) diff --git a/include/linux/time.h b/include/linux/time.h index 0de44cff8d7..b23598295c2 100644 --- a/include/linux/time.h +++ b/include/linux/time.h @@ -166,4 +166,12 @@ time64_t mktime64(const unsigned int year, const unsigned int mon, const unsigned int min, const unsigned int sec); #endif +/* 64-bit time representation with nanoseconds */ +typedef s64 time64_t; + +struct timespec64 { + time_t tv_sec; + long tv_nsec; +}; + #endif -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move the rol32() rotate-left function from ext4_uboot.h to include/linux/bitops.h where it logically belongs alongside other bit manipulation functions. Also add ror32() for completeness. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 7 +------ include/linux/bitops.h | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index b2a33a17198..68dca2f8d4e 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -65,12 +65,7 @@ #undef no_printk #define no_printk(fmt, ...) ({ 0; }) -/* Rotate left - not available in U-Boot */ -static inline u32 rol32(u32 word, unsigned int shift) -{ - return (word << (shift & 31)) | (word >> ((-shift) & 31)); -} - +/* rol32 and ror32 are now in linux/bitops.h */ /* Time types - timespec64 and time64_t are now in linux/time.h */ /* diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 86f7ee492b4..a3cfbbd5250 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -148,6 +148,26 @@ static inline unsigned long hweight_long(unsigned long w) return sizeof(w) == 4 ? generic_hweight32(w) : generic_hweight64(w); } +/** + * rol32 - rotate a 32-bit value left + * @word: value to rotate + * @shift: bits to roll + */ +static inline u32 rol32(u32 word, unsigned int shift) +{ + return (word << (shift & 31)) | (word >> ((-shift) & 31)); +} + +/** + * ror32 - rotate a 32-bit value right + * @word: value to rotate + * @shift: bits to roll + */ +static inline u32 ror32(u32 word, unsigned int shift) +{ + return (word >> (shift & 31)) | (word << ((-shift) & 31)); +} + #include <asm/bitops.h> /* linux/include/asm-generic/bitops/non-atomic.h */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move atomic operations from ext4_uboot.h to asm-generic/atomic.h where they logically belong. This includes: - atomic_inc_return() - atomic_add_return() - atomic_dec_if_positive() - atomic_add_unless() Remove duplicate definitions from ext4_uboot.h that are now provided by asm-generic/atomic.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 | 30 ++++---------------- include/asm-generic/atomic.h | 53 ++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 24 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 68dca2f8d4e..f208889cbac 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -78,8 +78,7 @@ #include <linux/jiffies.h> #include <linux/blkdev.h> -/* Extra atomic operation not in asm-generic/atomic.h */ -#define atomic_dec_if_positive(v) (--(v)->counter) +/* atomic_dec_if_positive, atomic_add_unless, etc. are now in asm-generic/atomic.h */ /* SMP stubs - U-Boot is single-threaded */ #define raw_smp_processor_id() 0 @@ -433,8 +432,7 @@ int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode, /* spin_trylock is defined in linux/spinlock.h */ -/* Atomic extras */ -#define atomic_add_unless(v, a, u) ({ (void)(v); (void)(a); (void)(u); 1; }) +/* atomic_add_unless is now in asm-generic/atomic.h */ /* Block group lock - stub */ #define bgl_lock_ptr(lock, group) NULL @@ -2548,9 +2546,7 @@ static inline unsigned long ext4_find_next_bit_le(const void *addr, return size; } -/* Atomic64 operations */ -#define atomic64_inc(v) do { (void)(v); } while (0) -#define atomic64_add(i, v) do { (void)(i); (void)(v); } while (0) +/* atomic64 operations are now in asm-generic/atomic.h */ /* CPU cycle counter stub */ #define get_cycles() (0ULL) @@ -2592,17 +2588,7 @@ static inline unsigned long ext4_find_next_bit_le(const void *addr, /* array_index_nospec - bounds checking without speculation (no-op in U-Boot) */ #define array_index_nospec(index, size) (index) -/* atomic_inc_return - increment and return new value */ -static inline int atomic_inc_return(atomic_t *v) -{ - return ++(v->counter); -} - -/* atomic_add_return - add and return new value */ -static inline int atomic_add_return(int i, atomic_t *v) -{ - return (v->counter += i); -} +/* atomic_inc_return and atomic_add_return are now in asm-generic/atomic.h */ /* pde_data - proc dir entry data (not supported in U-Boot) */ #define pde_data(inode) ((void *)NULL) @@ -2640,10 +2626,7 @@ struct seq_operations { #define sb_issue_discard(sb, sector, nr_sects, gfp, flags) \ ({ (void)(sb); (void)(sector); (void)(nr_sects); (void)(gfp); (void)(flags); 0; }) -/* Atomic operations */ -#define atomic_sub(i, v) ((v)->counter -= (i)) -#define atomic64_sub(i, v) ((v)->counter -= (i)) -#define atomic_dec_and_test(v) (--((v)->counter) == 0) +/* atomic_sub, atomic64_sub, atomic_dec_and_test are in asm-generic/atomic.h */ /* RCU list operations - use regular list operations in U-Boot */ #define list_for_each_entry_rcu(pos, head, member, ...) \ @@ -2755,8 +2738,7 @@ struct folio_iter { /* blk_status_to_errno - convert block status to errno */ #define blk_status_to_errno(status) (-(status)) -/* atomic_inc - increment atomic */ -#define atomic_inc(v) ((v)->counter++) +/* atomic_inc is in asm-generic/atomic.h */ /* GFP_NOIO - allocation without I/O */ #define GFP_NOIO 0 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h index 94d0747194a..7825258922a 100644 --- a/include/asm-generic/atomic.h +++ b/include/asm-generic/atomic.h @@ -79,6 +79,59 @@ static inline int atomic_add_negative(int i, volatile atomic_t *v) return val < 0; } +static inline int atomic_inc_return(atomic_t *v) +{ + unsigned long flags = 0; + int val; + + local_irq_save(flags); + val = ++v->counter; + local_irq_restore(flags); + + return val; +} + +static inline int atomic_add_return(int i, atomic_t *v) +{ + unsigned long flags = 0; + int val; + + local_irq_save(flags); + val = (v->counter += i); + local_irq_restore(flags); + + return val; +} + +static inline int atomic_dec_if_positive(atomic_t *v) +{ + unsigned long flags = 0; + int val; + + local_irq_save(flags); + val = v->counter - 1; + if (val >= 0) + v->counter = val; + local_irq_restore(flags); + + return val; +} + +static inline int atomic_add_unless(atomic_t *v, int a, int u) +{ + unsigned long flags = 0; + int ret = 1; + + local_irq_save(flags); + if (v->counter != u) + v->counter += a; + else + ret = 0; + local_irq_restore(flags); + + return ret; +} + static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr) { unsigned long flags = 0; -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> In Linux, trace events are defined in include/trace/events/ext4.h and include/trace/events/jbd2.h. In U-Boot, all these trace points need to be stubbed out since tracing is not supported. Move all trace-stub definitions from ext4_uboot.h into a new dedicated header ext4_trace.h This consolidates ~100 scattered trace stub macros into one organised location, grouped by category (journal, bitmap, inode, extent, writeback, etc.). Note that trace_ext4_error() is a function implemented in stub.c, not a trace stub, so it remains as a function declaration in ext4_uboot.h This reduces ext4_uboot.h by ~190 lines. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_trace.h | 172 +++++++++++++++++++++++++++++++++++++ fs/ext4l/ext4_uboot.h | 191 +----------------------------------------- 2 files changed, 174 insertions(+), 189 deletions(-) create mode 100644 fs/ext4l/ext4_trace.h diff --git a/fs/ext4l/ext4_trace.h b/fs/ext4l/ext4_trace.h new file mode 100644 index 00000000000..a53e1cdfd99 --- /dev/null +++ b/fs/ext4l/ext4_trace.h @@ -0,0 +1,172 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * ext4 and jbd2 trace stubs for U-Boot + * + * In Linux, these are defined as trace events via include/trace/events/ext4.h + * and include/trace/events/jbd2.h. In U-Boot, we stub them out completely. + */ + +#ifndef _EXT4_TRACE_H +#define _EXT4_TRACE_H + +/* ext4 journal traces */ +#define trace_ext4_journal_start_inode(...) do { } while (0) +#define trace_ext4_journal_start_sb(...) do { } while (0) +#define trace_ext4_journal_start_reserved(...) do { } while (0) +#define trace_ext4_forget(...) do { } while (0) + +/* ext4 bitmap traces */ +#define trace_ext4_read_block_bitmap_load(...) do { } while (0) +#define trace_ext4_load_inode_bitmap(...) do { } while (0) + +/* ext4 inode allocation traces */ +#define trace_ext4_free_inode(...) do { } while (0) +#define trace_ext4_allocate_inode(...) do { } while (0) +#define trace_ext4_request_inode(...) do { } while (0) + +/* ext4 extent traces */ +#define trace_ext4_ext_load_extent(...) do { } while (0) +#define trace_ext4_ext_rm_idx(...) do { } while (0) +#define trace_ext4_remove_blocks(...) do { } while (0) +#define trace_ext4_ext_rm_leaf(...) do { } while (0) +#define trace_ext4_ext_remove_space(...) do { } while (0) +#define trace_ext4_ext_remove_space_done(...) do { } while (0) +#define trace_ext4_ext_convert_to_initialized_enter(...) do { } while (0) +#define trace_ext4_ext_convert_to_initialized_fastpath(...) do { } while (0) +#define trace_ext4_ext_handle_unwritten_extents(...) do { } while (0) +#define trace_ext4_get_implied_cluster_alloc_exit(...) do { } while (0) +#define trace_ext4_ext_map_blocks_enter(...) do { } while (0) +#define trace_ext4_ext_map_blocks_exit(...) do { } while (0) +#define trace_ext4_ext_show_extent(...) do { } while (0) + +/* ext4 fallocate traces */ +#define trace_ext4_collapse_range(...) do { } while (0) +#define trace_ext4_insert_range(...) do { } while (0) +#define trace_ext4_zero_range(...) do { } while (0) +#define trace_ext4_fallocate_enter(...) do { } while (0) +#define trace_ext4_fallocate_exit(...) do { } while (0) + +/* ext4 indirect block traces */ +#define trace_ext4_ind_map_blocks_enter(...) do { } while (0) +#define trace_ext4_ind_map_blocks_exit(...) do { } while (0) + +/* ext4 inode traces */ +#define trace_ext4_begin_ordered_truncate(...) do { } while (0) +#define trace_ext4_evict_inode(...) do { } while (0) +#define trace_ext4_load_inode(...) do { } while (0) +#define trace_ext4_other_inode_update_time(...) do { } while (0) +#define trace_ext4_mark_inode_dirty(...) do { } while (0) +#define trace_ext4_drop_inode(...) do { } while (0) +#define trace_ext4_nfs_commit_metadata(...) do { } while (0) + +/* ext4 delayed allocation traces */ +#define trace_ext4_da_update_reserve_space(...) do { } while (0) +#define trace_ext4_da_reserve_space(...) do { } while (0) +#define trace_ext4_da_release_space(...) do { } while (0) +#define trace_ext4_da_write_pages_extent(...) do { } while (0) +#define trace_ext4_alloc_da_blocks(...) do { } while (0) + +/* ext4 writeback traces */ +#define trace_ext4_writepages(...) do { } while (0) +#define trace_ext4_da_write_folios_start(...) do { } while (0) +#define trace_ext4_da_write_folios_end(...) do { } while (0) +#define trace_ext4_writepages_result(...) do { } while (0) +#define trace_ext4_da_write_begin(...) do { } while (0) +#define trace_ext4_da_write_end(...) do { } while (0) +#define trace_ext4_write_begin(...) do { } while (0) +#define trace_ext4_write_end(...) do { } while (0) +#define trace_ext4_journalled_write_end(...) do { } while (0) + +/* ext4 folio traces */ +#define trace_ext4_read_folio(...) do { } while (0) +#define trace_ext4_invalidate_folio(...) do { } while (0) +#define trace_ext4_journalled_invalidate_folio(...) do { } while (0) +#define trace_ext4_release_folio(...) do { } while (0) + +/* ext4 truncate traces */ +#define trace_ext4_punch_hole(...) do { } while (0) +#define trace_ext4_truncate_enter(...) do { } while (0) +#define trace_ext4_truncate_exit(...) do { } while (0) + +/* ext4 sync traces */ +#define trace_ext4_sync_file_enter(...) do { } while (0) +#define trace_ext4_sync_file_exit(...) do { } while (0) +#define trace_ext4_sync_fs(...) do { } while (0) + +/* ext4 unlink traces */ +#define trace_ext4_unlink_enter(...) do { } while (0) +#define trace_ext4_unlink_exit(...) do { } while (0) + +/* ext4 super traces */ +#define trace_ext4_prefetch_bitmaps(...) do { } while (0) +#define trace_ext4_lazy_itable_init(...) do { } while (0) +/* trace_ext4_error is a function implemented in stub.c, not a trace stub */ + +/* ext4 mballoc traces */ +#define trace_ext4_mb_bitmap_load(...) do { } while (0) +#define trace_ext4_mb_buddy_bitmap_load(...) do { } while (0) +#define trace_ext4_mballoc_alloc(...) do { } while (0) +#define trace_ext4_mballoc_prealloc(...) do { } while (0) +#define trace_ext4_mballoc_discard(...) do { } while (0) +#define trace_ext4_mballoc_free(...) do { } while (0) +#define trace_ext4_mb_release_inode_pa(...) do { } while (0) +#define trace_ext4_mb_release_group_pa(...) do { } while (0) +#define trace_ext4_mb_new_inode_pa(...) do { } while (0) +#define trace_ext4_mb_new_group_pa(...) do { } while (0) +#define trace_ext4_discard_blocks(...) do { } while (0) +#define trace_ext4_discard_preallocations(...) do { } while (0) +#define trace_ext4_mb_discard_preallocations(...) do { } while (0) +#define trace_ext4_request_blocks(...) do { } while (0) +#define trace_ext4_allocate_blocks(...) do { } while (0) +#define trace_ext4_free_blocks(...) do { } while (0) +#define trace_ext4_trim_extent(...) do { } while (0) +#define trace_ext4_trim_all_free(...) do { } while (0) + +/* ext4 fast commit traces */ +#define trace_ext4_fc_track_unlink(...) do { } while (0) +#define trace_ext4_fc_track_link(...) do { } while (0) +#define trace_ext4_fc_track_create(...) do { } while (0) +#define trace_ext4_fc_track_inode(...) do { } while (0) +#define trace_ext4_fc_track_range(...) do { } while (0) +#define trace_ext4_fc_cleanup(...) do { } while (0) +#define trace_ext4_fc_stats(...) do { } while (0) +#define trace_ext4_fc_commit_start(...) do { } while (0) +#define trace_ext4_fc_commit_stop(...) do { } while (0) +#define trace_ext4_fc_replay_scan(...) do { } while (0) +#define trace_ext4_fc_replay(...) do { } while (0) + +/* ext4 fsmap traces */ +#define trace_ext4_fsmap_mapping(...) do { } while (0) +#define trace_ext4_fsmap_low_key(...) do { } while (0) +#define trace_ext4_fsmap_high_key(...) do { } while (0) + +/* jbd2 checkpoint traces */ +#define trace_jbd2_checkpoint(...) do { } while (0) +#define trace_jbd2_shrink_checkpoint_list(...) do { } while (0) +#define trace_jbd2_checkpoint_stats(...) do { } while (0) +#define trace_jbd2_drop_transaction(...) do { } while (0) + +/* jbd2 commit traces */ +#define trace_jbd2_submit_inode_data(...) do { } while (0) +#define trace_jbd2_start_commit(...) do { } while (0) +#define trace_jbd2_commit_locking(...) do { } while (0) +#define trace_jbd2_commit_flushing(...) do { } while (0) +#define trace_jbd2_commit_logging(...) do { } while (0) +#define trace_jbd2_run_stats(...) do { } while (0) +#define trace_jbd2_end_commit(...) do { } while (0) + +/* jbd2 handle traces */ +#define trace_jbd2_handle_start(...) do { } while (0) +#define trace_jbd2_handle_extend(...) do { } while (0) +#define trace_jbd2_handle_restart(...) do { } while (0) +#define trace_jbd2_handle_stats(...) do { } while (0) +#define trace_jbd2_lock_buffer_stall(...) do { } while (0) + +/* jbd2 journal traces */ +#define trace_jbd2_update_log_tail(...) do { } while (0) +#define trace_jbd2_shrink_scan_enter(...) do { } while (0) +#define trace_jbd2_shrink_scan_exit(...) do { } while (0) +#define trace_jbd2_shrink_count(...) do { } while (0) +#define trace_jbd2_write_superblock(...) do { } while (0) + +#endif /* _EXT4_TRACE_H */ diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index f208889cbac..5a55984ec75 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -40,6 +40,7 @@ #include <linux/rbtree.h> /* Real rbtree implementation */ #include <linux/time.h> /* For timespec64, time64_t */ #include <u-boot/crc.h> /* For crc32() used by crc32_be */ +#include "ext4_trace.h" /* Trace event stubs */ /* * __CHAR_UNSIGNED__ - directory hash algorithm selection @@ -302,12 +303,7 @@ extern struct user_namespace init_user_ns; /* sb_rdonly - check if filesystem is mounted read-only */ #define sb_rdonly(sb) ((sb)->s_flags & SB_RDONLY) -/* Trace stubs */ -#define trace_ext4_journal_start_inode(...) do { } while (0) -#define trace_ext4_journal_start_sb(...) do { } while (0) -#define trace_ext4_journal_start_reserved(...) do { } while (0) -#define trace_ext4_forget(...) do { } while (0) -#define trace_ext4_read_block_bitmap_load(...) do { } while (0) +/* Trace stubs are now in ext4_trace.h */ /* Buffer operations - stubs */ #define wait_on_buffer(bh) do { } while (0) @@ -367,12 +363,6 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); #define dquot_drop(inode) do { (void)(inode); } while (0) #endif /* _LINUX_QUOTAOPS_H */ -/* Trace stubs for ialloc.c */ -#define trace_ext4_load_inode_bitmap(...) do { } while (0) -#define trace_ext4_free_inode(...) do { } while (0) -#define trace_ext4_allocate_inode(...) do { } while (0) -#define trace_ext4_request_inode(...) do { } while (0) - /* icount - inode reference count */ #define icount_read(inode) (1) @@ -1059,26 +1049,6 @@ static inline unsigned long memweight(const void *ptr, size_t bytes) /* extents.c stubs */ -/* Trace functions for extents.c */ -#define trace_ext4_ext_load_extent(...) do { } while (0) -#define trace_ext4_ext_rm_idx(...) do { } while (0) -#define trace_ext4_remove_blocks(...) do { } while (0) -#define trace_ext4_ext_rm_leaf(...) do { } while (0) -#define trace_ext4_ext_remove_space(...) do { } while (0) -#define trace_ext4_ext_remove_space_done(...) do { } while (0) -#define trace_ext4_ext_convert_to_initialized_enter(...) do { } while (0) -#define trace_ext4_ext_convert_to_initialized_fastpath(...) do { } while (0) -#define trace_ext4_ext_handle_unwritten_extents(...) do { } while (0) -#define trace_ext4_get_implied_cluster_alloc_exit(...) do { } while (0) -#define trace_ext4_ext_map_blocks_enter(...) do { } while (0) -#define trace_ext4_ext_map_blocks_exit(...) do { } while (0) -#define trace_ext4_ext_show_extent(...) do { } while (0) -#define trace_ext4_collapse_range(...) do { } while (0) -#define trace_ext4_insert_range(...) do { } while (0) -#define trace_ext4_zero_range(...) do { } while (0) -#define trace_ext4_fallocate_enter(...) do { } while (0) -#define trace_ext4_fallocate_exit(...) do { } while (0) - /* rwsem is_locked stub */ #define rwsem_is_locked(sem) (1) @@ -1177,10 +1147,6 @@ static inline int in_range(unsigned long val, unsigned long start, /* indirect.c stubs */ -/* Trace functions for indirect.c */ -#define trace_ext4_ind_map_blocks_enter(...) do { } while (0) -#define trace_ext4_ind_map_blocks_exit(...) do { } while (0) - /* umin - unsigned min (Linux 6.x) */ #define umin(x, y) ((x) < (y) ? (x) : (y)) @@ -1443,38 +1409,6 @@ typedef unsigned int projid_t; /* hash_64 - simple 64-bit hash */ #define hash_64(val, bits) ((unsigned long)((val) >> (64 - (bits)))) -/* Trace stubs for inode.c */ -#define trace_ext4_begin_ordered_truncate(...) do { } while (0) -#define trace_ext4_evict_inode(...) do { } while (0) -#define trace_ext4_da_update_reserve_space(...) do { } while (0) -#define trace_ext4_da_reserve_space(...) do { } while (0) -#define trace_ext4_da_release_space(...) do { } while (0) -#define trace_ext4_da_write_pages_extent(...) do { } while (0) -#define trace_ext4_writepages(...) do { } while (0) -#define trace_ext4_da_write_folios_start(...) do { } while (0) -#define trace_ext4_da_write_folios_end(...) do { } while (0) -#define trace_ext4_writepages_result(...) do { } while (0) -#define trace_ext4_da_write_begin(...) do { } while (0) -#define trace_ext4_da_write_end(...) do { } while (0) -#define trace_ext4_alloc_da_blocks(...) do { } while (0) -#define trace_ext4_read_folio(...) do { } while (0) -#define trace_ext4_invalidate_folio(...) do { } while (0) -#define trace_ext4_journalled_invalidate_folio(...) do { } while (0) -#define trace_ext4_release_folio(...) do { } while (0) -#define trace_ext4_punch_hole(...) do { } while (0) -#define trace_ext4_truncate_enter(...) do { } while (0) -#define trace_ext4_truncate_exit(...) do { } while (0) -#define trace_ext4_load_inode(...) do { } while (0) -#define trace_ext4_other_inode_update_time(...) do { } while (0) -#define trace_ext4_mark_inode_dirty(...) do { } while (0) -#define trace_ext4_write_begin(...) do { } while (0) -#define trace_ext4_write_end(...) do { } while (0) -#define trace_ext4_journalled_write_end(...) do { } while (0) -#define trace_ext4_sync_file_enter(...) do { } while (0) -#define trace_ext4_sync_file_exit(...) do { } while (0) -#define trace_ext4_unlink_enter(...) do { } while (0) -#define trace_ext4_unlink_exit(...) do { } while (0) - /* Dentry operations - stubs */ #define d_find_any_alias(i) ({ (void)(i); (struct dentry *)NULL; }) #define dget_parent(d) ({ (void)(d); (struct dentry *)NULL; }) @@ -2296,12 +2230,6 @@ int inode_generic_drop(struct inode *inode); /* rwlock_init is a macro in linux/spinlock.h */ -/* Trace stubs */ -#define trace_ext4_drop_inode(i, d) do { } while (0) -#define trace_ext4_nfs_commit_metadata(i) do { } while (0) -#define trace_ext4_prefetch_bitmaps(...) do { } while (0) -#define trace_ext4_lazy_itable_init(...) do { } while (0) - /* slab usercopy - use regular kmem_cache_create */ #define kmem_cache_create_usercopy(n, sz, al, fl, uo, us, c) \ kmem_cache_create(n, sz, al, fl, c) @@ -2475,9 +2403,6 @@ void dquot_free_block(struct inode *inode, loff_t nr); #define set_blocksize(f, size) ({ (void)(f); (void)(size); 0; }) struct buffer_head *__bread(struct block_device *bdev, sector_t block, unsigned size); -/* Trace stubs for super.c */ -#define trace_ext4_sync_fs(sb, wait) do { (void)(sb); (void)(wait); } while (0) - /* Workqueue operations - stubs */ #define flush_workqueue(wq) do { (void)(wq); } while (0) @@ -2555,28 +2480,6 @@ static inline unsigned long ext4_find_next_bit_le(const void *addr, #undef folio_address #define folio_address(folio) ((folio)->data) -/* Trace stubs for mballoc.c */ -#define trace_ext4_mb_bitmap_load(sb, group) \ - do { (void)(sb); (void)(group); } while (0) -#define trace_ext4_mb_buddy_bitmap_load(sb, group) \ - do { (void)(sb); (void)(group); } while (0) -#define trace_ext4_mballoc_alloc(ac) \ - do { (void)(ac); } while (0) -#define trace_ext4_mballoc_prealloc(ac) \ - do { (void)(ac); } while (0) -#define trace_ext4_mballoc_discard(sb, inode, group, start, len) \ - do { (void)(sb); (void)(inode); (void)(group); (void)(start); (void)(len); } while (0) -#define trace_ext4_mballoc_free(sb, inode, group, start, len) \ - do { (void)(sb); (void)(inode); (void)(group); (void)(start); (void)(len); } while (0) -#define trace_ext4_mb_release_inode_pa(pa, block, count) \ - do { (void)(pa); (void)(block); (void)(count); } while (0) -#define trace_ext4_mb_release_group_pa(sb, pa) \ - do { (void)(sb); (void)(pa); } while (0) -#define trace_ext4_mb_new_inode_pa(ac, pa) \ - do { (void)(ac); (void)(pa); } while (0) -#define trace_ext4_mb_new_group_pa(ac, pa) \ - do { (void)(ac); (void)(pa); } while (0) - /* sb_end_intwrite stub */ #define sb_end_intwrite(sb) do { (void)(sb); } while (0) @@ -2618,10 +2521,6 @@ struct seq_operations { /* Block device properties */ #define bdev_nonrot(bdev) ({ (void)(bdev); 0; }) -/* Trace stub for discard */ -#define trace_ext4_discard_blocks(sb, blk, count) \ - do { (void)(sb); (void)(blk); (void)(count); } while (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; }) @@ -2647,22 +2546,6 @@ struct seq_operations { #define schedule_timeout_uninterruptible(t) do { } while (0) #define need_resched() (0) -/* Trace stubs for mballoc.c */ -#define trace_ext4_discard_preallocations(inode, cnt) \ - do { (void)(inode); (void)(cnt); } while (0) -#define trace_ext4_mb_discard_preallocations(sb, needed) \ - do { (void)(sb); (void)(needed); } while (0) -#define trace_ext4_request_blocks(ar) \ - do { (void)(ar); } while (0) -#define trace_ext4_allocate_blocks(ar, block) \ - do { (void)(ar); (void)(block); } while (0) -#define trace_ext4_free_blocks(inode, block, count, flags) \ - do { (void)(inode); (void)(block); (void)(count); (void)(flags); } while (0) -#define trace_ext4_trim_extent(sb, group, start, count) \ - do { (void)(sb); (void)(group); (void)(start); (void)(count); } while (0) -#define trace_ext4_trim_all_free(sb, group, start, max) \ - do { (void)(sb); (void)(group); (void)(start); (void)(max); } while (0) - /* Block device operations */ #define sb_find_get_block_nonatomic(sb, block) \ ({ (void)(sb); (void)(block); (struct buffer_head *)NULL; }) @@ -2832,18 +2715,6 @@ struct wait_bit_entry { #define release_dentry_name_snapshot(snap) \ do { (void)(snap); } while (0) -/* Fast commit trace stubs */ -#define trace_ext4_fc_track_unlink(handle, inode, dentry, ret) \ - do { (void)(handle); (void)(inode); (void)(dentry); (void)(ret); } while (0) -#define trace_ext4_fc_track_link(handle, inode, dentry, ret) \ - do { (void)(handle); (void)(inode); (void)(dentry); (void)(ret); } while (0) -#define trace_ext4_fc_track_create(handle, inode, dentry, ret) \ - do { (void)(handle); (void)(inode); (void)(dentry); (void)(ret); } while (0) -#define trace_ext4_fc_track_inode(handle, inode, ret) \ - do { (void)(handle); (void)(inode); (void)(ret); } while (0) -#define trace_ext4_fc_track_range(handle, inode, start, end, ret) \ - do { (void)(handle); (void)(inode); (void)(start); (void)(end); (void)(ret); } while (0) - /* lockdep stubs */ #define lockdep_assert_not_held(lock) do { (void)(lock); } while (0) @@ -2851,16 +2722,6 @@ struct wait_bit_entry { #define REQ_IDLE 0 #define REQ_PREFLUSH 0 -/* Fast commit trace stubs */ -#define trace_ext4_fc_cleanup(sb, full, reason) \ - do { (void)(sb); (void)(full); (void)(reason); } while (0) -#define trace_ext4_fc_stats(sb) \ - do { (void)(sb); } while (0) -#define trace_ext4_fc_commit_start(sb, tid) \ - do { (void)(sb); (void)(tid); } while (0) -#define trace_ext4_fc_commit_stop(sb, nblks, status, tid) \ - do { (void)(sb); (void)(nblks); (void)(status); (void)(tid); } while (0) - /* wake_up_bit - wake up threads waiting on a bit */ #define wake_up_bit(word, bit) do { (void)(word); (void)(bit); } while (0) @@ -2868,12 +2729,6 @@ struct wait_bit_entry { #define d_alloc(parent, name) ({ (void)(parent); (void)(name); (struct dentry *)NULL; }) #define d_drop(dentry) do { (void)(dentry); } while (0) -/* More fast commit trace stubs */ -#define trace_ext4_fc_replay_scan(sb, err, off) \ - do { (void)(sb); (void)(err); (void)(off); } while (0) -#define trace_ext4_fc_replay(sb, tag, ino, priv1, priv2) \ - do { (void)(sb); (void)(tag); (void)(ino); (void)(priv1); (void)(priv2); } while (0) - /* get_current_ioprio - I/O priority (not used in U-Boot) */ #define get_current_ioprio() (0) @@ -2882,15 +2737,6 @@ struct wait_bit_entry { #define write_dirty_buffer(bh, flags) sync_dirty_buffer(bh) #define spin_needbreak(l) ({ (void)(l); 0; }) -/* JBD2 trace stubs */ -#define trace_jbd2_checkpoint(j, r) do { (void)(j); (void)(r); } while (0) -#define trace_jbd2_shrink_checkpoint_list(j, f, t, l, n, d) \ - do { (void)(j); (void)(f); (void)(t); (void)(l); (void)(n); (void)(d); } while (0) -#define trace_jbd2_checkpoint_stats(d, tid, stats) \ - do { (void)(d); (void)(tid); (void)(stats); } while (0) -#define trace_jbd2_drop_transaction(j, t) \ - do { (void)(j); (void)(t); } while (0) - /* JBD2 commit.c stubs */ #define clear_bit_unlock(nr, addr) clear_bit(nr, addr) #define smp_mb__after_atomic() do { } while (0) @@ -2925,30 +2771,11 @@ struct disk_partition *ext4l_get_partition(void); /* cond_resched_lock - conditionally reschedule while holding a lock */ #define cond_resched_lock(lock) do { (void)(lock); } while (0) -/* More JBD2 trace stubs for commit.c */ -#define trace_jbd2_submit_inode_data(i) do { (void)(i); } while (0) -#define trace_jbd2_start_commit(j, t) do { (void)(j); (void)(t); } while (0) -#define trace_jbd2_commit_locking(j, t) do { (void)(j); (void)(t); } while (0) -#define trace_jbd2_commit_flushing(j, t) do { (void)(j); (void)(t); } while (0) -#define trace_jbd2_commit_logging(j, t) do { (void)(j); (void)(t); } while (0) -#define trace_jbd2_run_stats(d, tid, stats) \ - do { (void)(d); (void)(tid); (void)(stats); } while (0) -#define trace_jbd2_end_commit(j, t) do { (void)(j); (void)(t); } while (0) - -/* JBD2 transaction.c trace stubs */ -#define trace_jbd2_handle_start(...) do { } while (0) -#define trace_jbd2_handle_extend(...) do { } while (0) -#define trace_jbd2_handle_restart(...) do { } while (0) -#define trace_jbd2_handle_stats(...) do { } while (0) -#define trace_jbd2_lock_buffer_stall(...) do { } 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); int bmap(struct inode *inode, sector_t *block); -#define trace_jbd2_update_log_tail(j, t, b, f) \ - do { (void)(j); (void)(t); (void)(b); (void)(f); } while (0) /* seq_file operations for /proc - stubs */ #define seq_open(f, ops) ({ (void)(f); (void)(ops); 0; }) @@ -2980,16 +2807,6 @@ loff_t seq_lseek(struct file *f, loff_t o, int w); /* lockdep stubs (struct lock_class_key defined earlier) */ #define lockdep_init_map(...) do { } while (0) -/* More JBD2 trace stubs for journal.c */ -#define trace_jbd2_shrink_scan_enter(j, n, c) \ - do { (void)(j); (void)(n); (void)(c); } while (0) -#define trace_jbd2_shrink_scan_exit(j, n, s, c) \ - do { (void)(j); (void)(n); (void)(s); (void)(c); } while (0) -#define trace_jbd2_shrink_count(j, n, c) \ - do { (void)(j); (void)(n); (void)(c); } while (0) -#define trace_jbd2_write_superblock(j, f) \ - do { (void)(j); (void)(f); } while (0) - /* 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) @@ -3088,10 +2905,6 @@ struct fsmap { #define FMH_IF_VALID 0 #define FMH_OF_DEV_T (1 << 0) -#define trace_ext4_fsmap_mapping(sb, d, a, p, l, o) do { } while (0) -#define trace_ext4_fsmap_low_key(sb, d, a, p, l, o) do { } while (0) -#define trace_ext4_fsmap_high_key(sb, d, a, p, l, o) do { } while (0) - /* list_sort and sort stubs for fsmap.c */ #define list_sort(priv, head, cmp) \ do { (void)(priv); (void)(head); (void)(cmp); } while (0) -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Remove several duplicate macros from ext4_uboot.h: - rcu_read_lock, rcu_read_unlock, synchronize_rcu, rcu_assign_pointer, rcu_dereference - were defined in both RCU stubs section and later in RCU list operations section - filemap_invalidate_lock_shared, filemap_invalidate_unlock_shared - sb_end_intwrite Keep the first occurrences and add comments to reference them where duplicates are removed. 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 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 5a55984ec75..8a160a2db19 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -434,6 +434,7 @@ int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode, #define rcu_dereference_protected(p, c) (p) #define rcu_assign_pointer(p, v) ((p) = (v)) #define call_rcu(head, func) do { func(head); } while (0) +#define synchronize_rcu() do { } while (0) /* RCU head for callbacks - defined in linux/compat.h as callback_head */ @@ -1519,8 +1520,7 @@ static inline char *d_path(const struct path *path, char *buf, int buflen) #define filemap_write_and_wait(m) ({ (void)(m); 0; }) #define filemap_dirty_folio(m, f) ({ (void)(m); (void)(f); false; }) #define filemap_lock_folio(m, i) ((struct folio *)NULL) -#define filemap_invalidate_lock_shared(m) do { } while (0) -#define filemap_invalidate_unlock_shared(m) do { } while (0) +/* filemap_invalidate_lock_shared defined earlier */ #define mapping_tagged(m, t) (0) #define tag_pages_for_writeback(m, s, e) do { } while (0) #define try_to_writeback_inodes_sb(sb, r) do { } while (0) @@ -2480,8 +2480,7 @@ static inline unsigned long ext4_find_next_bit_le(const void *addr, #undef folio_address #define folio_address(folio) ((folio)->data) -/* sb_end_intwrite stub */ -#define sb_end_intwrite(sb) do { (void)(sb); } while (0) +/* sb_end_intwrite defined earlier */ /* WARN_RATELIMIT - just evaluate condition, no warning in U-Boot */ #define WARN_RATELIMIT(condition, ...) (condition) @@ -2533,11 +2532,7 @@ struct seq_operations { #define list_del_rcu(entry) list_del(entry) #define list_add_rcu(new, head) list_add(new, head) #define list_add_tail_rcu(new, head) list_add_tail(new, head) -#define rcu_read_lock() do { } while (0) -#define rcu_read_unlock() do { } while (0) -#define synchronize_rcu() do { } while (0) -#define rcu_assign_pointer(p, v) ((p) = (v)) -#define rcu_dereference(p) (p) +/* Other RCU stubs are defined earlier in this file */ /* raw_cpu_ptr - get pointer to per-CPU data for current CPU */ #define raw_cpu_ptr(ptr) (ptr) -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move the flush_workqueue stub from ext4_uboot.h to the common linux/workqueue.h header where other workqueue stubs reside. Also simplify the quota stubs section by removing the unnecessary _LINUX_QUOTAOPS_H guard, since quotaops.h is not included. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 7 ++----- include/linux/workqueue.h | 4 ++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 8a160a2db19..2ffa8ab271b 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -353,15 +353,13 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); /* Group permission - stub */ #define in_group_p(gid) (0) -/* Quota operations - stubs (only define if quotaops.h not included) */ -#ifndef _LINUX_QUOTAOPS_H +/* Quota operations - stubs */ #define dquot_alloc_block_nofail(inode, nr) \ ({ (inode)->i_blocks += (nr) << ((inode)->i_blkbits - 9); 0; }) #define dquot_initialize(inode) ({ (void)(inode); 0; }) #define dquot_free_inode(inode) do { (void)(inode); } while (0) #define dquot_alloc_inode(inode) ({ (void)(inode); 0; }) #define dquot_drop(inode) do { (void)(inode); } while (0) -#endif /* _LINUX_QUOTAOPS_H */ /* icount - inode reference count */ #define icount_read(inode) (1) @@ -2403,8 +2401,7 @@ void dquot_free_block(struct inode *inode, loff_t nr); #define set_blocksize(f, size) ({ (void)(f); (void)(size); 0; }) struct buffer_head *__bread(struct block_device *bdev, sector_t block, unsigned size); -/* Workqueue operations - stubs */ -#define flush_workqueue(wq) do { (void)(wq); } while (0) +/* flush_workqueue is now in linux/workqueue.h */ /* Quota stubs for super.c */ #define dquot_writeback_dquots(sb, type) do { (void)(sb); (void)(type); } while (0) diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index 66f61fa6e77..2ae57341861 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -79,6 +79,10 @@ static inline void destroy_workqueue(struct workqueue_struct *wq) { } +static inline void flush_workqueue(struct workqueue_struct *wq) +{ +} + /* System workqueues - all stubs in U-Boot */ #define system_dfl_wq ((struct workqueue_struct *)1) #define system_wq ((struct workqueue_struct *)1) -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create a dedicated header file for filesystem encryption (fscrypt) stubs that are scattered throughout ext4_uboot.h In Linux, fscrypt provides filesystem-level encryption, but U-Boot does not support this feature. The new ext4_fscrypt.h contains: - Structure definitions (qstr, fscrypt_str, fscrypt_dummy_policy, fscrypt_name) - Inline functions (fscrypt_has_encryption_key, fscrypt_fname_siphash, fscrypt_match_name) - Operation stubs for encryption, directory operations, symlinks - Page I/O and readpage stubs - Function declarations for stub.c implementations This reduces ext4_uboot.h by ~90 lines and makes the fscrypt interface more maintainable by keeping all encryption-related stubs in one place. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_fscrypt.h | 144 ++++++++++++++++++++++++++++++++++++++++ fs/ext4l/ext4_uboot.h | 120 +++++---------------------------- 2 files changed, 160 insertions(+), 104 deletions(-) create mode 100644 fs/ext4l/ext4_fscrypt.h diff --git a/fs/ext4l/ext4_fscrypt.h b/fs/ext4l/ext4_fscrypt.h new file mode 100644 index 00000000000..da91af74343 --- /dev/null +++ b/fs/ext4l/ext4_fscrypt.h @@ -0,0 +1,144 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * fscrypt stubs for U-Boot ext4l + * + * In Linux, fscrypt provides filesystem-level encryption. In U-Boot, + * encryption is not supported, so all fscrypt operations are stubbed out. + */ + +#ifndef _EXT4_FSCRYPT_H +#define _EXT4_FSCRYPT_H + +#include <linux/types.h> +#include <linux/errno.h> +#include <linux/err.h> +#include <linux/string.h> + +/* Forward declarations */ +struct inode; +struct seq_file; +struct page; +struct folio; +struct bio; +struct buffer_head; +struct dentry; +struct super_block; + +/* qstr - quick string for filenames (needed by fscrypt_name) */ +struct qstr { + u32 hash; + u32 len; + const unsigned char *name; +}; + +/* fscrypt_str - encrypted filename string */ +struct fscrypt_str { + unsigned char *name; + u32 len; +}; + +/* fscrypt_dummy_policy - stub */ +struct fscrypt_dummy_policy { + int dummy; +}; + +/* fscrypt_name - stub structure for encrypted filenames */ +struct fscrypt_name { + const struct qstr *usr_fname; + struct fscrypt_str disk_name; + u32 hash; + u32 minor_hash; + bool is_nokey_name; +}; + +/* fscrypt context size */ +#define FSCRYPT_SET_CONTEXT_MAX_SIZE 40 + +/* IS_ENCRYPTED - always false in U-Boot */ +#define IS_ENCRYPTED(inode) (0) + +/* fscrypt inline functions */ +static inline bool fscrypt_has_encryption_key(const struct inode *inode) +{ + return false; +} + +static inline u64 fscrypt_fname_siphash(const struct inode *dir, + const struct qstr *name) +{ + return 0; +} + +static inline int fscrypt_match_name(const struct fscrypt_name *fname, + const u8 *de_name, u32 de_name_len) +{ + if (fname->usr_fname->len != de_name_len) + return 0; + + return !memcmp(fname->usr_fname->name, de_name, de_name_len); +} + +/* fscrypt operation stubs */ +#define fscrypt_prepare_new_inode(dir, i, e) ({ (void)(dir); (void)(i); (void)(e); 0; }) +#define fscrypt_set_context(inode, handle) ({ (void)(inode); (void)(handle); 0; }) +#define fscrypt_file_open(i, f) ({ (void)(i); (void)(f); 0; }) +#define fscrypt_inode_uses_fs_layer_crypto(i) (0) +#define fscrypt_decrypt_pagecache_blocks(f, l, o) ({ (void)(f); (void)(l); (void)(o); 0; }) +#define fscrypt_encrypt_pagecache_blocks(f, l, o, g) \ + ({ (void)(f); (void)(l); (void)(o); (void)(g); (struct page *)NULL; }) +#define fscrypt_zeroout_range(i, lb, pb, l) ({ (void)(i); (void)(lb); (void)(pb); (void)(l); 0; }) +#define fscrypt_limit_io_blocks(i, lb, l) (l) +#define fscrypt_prepare_setattr(d, a) ({ (void)(d); (void)(a); 0; }) +#define fscrypt_dio_supported(i) (1) +#define fscrypt_has_permitted_context(p, c) ({ (void)(p); (void)(c); 1; }) +#define fscrypt_is_nokey_name(d) ({ (void)(d); 0; }) +#define fscrypt_prepare_symlink(d, s, l, m, dl) \ + ({ (void)(d); (void)(m); (dl)->name = (unsigned char *)(s); (dl)->len = (l) + 1; 0; }) +#define fscrypt_encrypt_symlink(i, s, l, d) ({ (void)(i); (void)(s); (void)(l); (void)(d); 0; }) +#define fscrypt_prepare_link(o, d, n) ({ (void)(o); (void)(d); (void)(n); 0; }) +#define fscrypt_prepare_rename(od, ode, nd, nde, f) \ + ({ (void)(od); (void)(ode); (void)(nd); (void)(nde); (void)(f); 0; }) + +/* fscrypt directory operations */ +#define fscrypt_prepare_readdir(i) ({ (void)(i); 0; }) +#define fscrypt_fname_alloc_buffer(len, buf) ({ (void)(len); (void)(buf); 0; }) +#define fscrypt_fname_free_buffer(buf) do { (void)(buf); } while (0) +#define fscrypt_fname_disk_to_usr(i, h1, h2, d, u) \ + ({ (void)(i); (void)(h1); (void)(h2); (void)(d); (void)(u); 0; }) + +/* fscrypt symlink stubs */ +#define fscrypt_get_symlink(i, c, m, d) ({ (void)(i); (void)(c); (void)(m); (void)(d); ERR_PTR(-EOPNOTSUPP); }) +#define fscrypt_symlink_getattr(p, s) ({ (void)(p); (void)(s); 0; }) + +/* fscrypt inode operations */ +#define fscrypt_put_encryption_info(i) do { } while (0) +#define fscrypt_parse_test_dummy_encryption(p, d) ({ (void)(p); (void)(d); 0; }) + +/* fscrypt page-io stubs */ +#define fscrypt_is_bounce_folio(f) ({ (void)(f); 0; }) +#define fscrypt_pagecache_folio(f) (f) +#define fscrypt_free_bounce_page(p) do { (void)(p); } while (0) +#define fscrypt_set_bio_crypt_ctx_bh(bio, bh, gfp) \ + do { (void)(bio); (void)(bh); (void)(gfp); } while (0) +#define fscrypt_mergeable_bio_bh(bio, bh) \ + ({ (void)(bio); (void)(bh); true; }) + +/* fscrypt readpage stubs */ +#define fscrypt_decrypt_bio(bio) ({ (void)(bio); 0; }) +#define fscrypt_enqueue_decrypt_work(work) do { (void)(work); } while (0) +#define fscrypt_mergeable_bio(bio, inode, blk) \ + ({ (void)(bio); (void)(inode); (void)(blk); true; }) +#define fscrypt_set_bio_crypt_ctx(bio, inode, blk, gfp) \ + do { (void)(bio); (void)(inode); (void)(blk); (void)(gfp); } while (0) + +/* fscrypt function declarations (implemented in stub.c) */ +void fscrypt_free_dummy_policy(struct fscrypt_dummy_policy *policy); +int fscrypt_drop_inode(struct inode *inode); +void fscrypt_free_inode(struct inode *inode); +int fscrypt_is_dummy_policy_set(const struct fscrypt_dummy_policy *policy); +int fscrypt_dummy_policies_equal(const struct fscrypt_dummy_policy *p1, + const struct fscrypt_dummy_policy *p2); +void fscrypt_show_test_dummy_encryption(struct seq_file *seq, char sep, + struct super_block *sb); + +#endif /* _EXT4_FSCRYPT_H */ diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 2ffa8ab271b..c6795b35501 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -41,6 +41,7 @@ #include <linux/time.h> /* For timespec64, time64_t */ #include <u-boot/crc.h> /* For crc32() used by crc32_be */ #include "ext4_trace.h" /* Trace event stubs */ +#include "ext4_fscrypt.h" /* fscrypt stubs */ /* * __CHAR_UNSIGNED__ - directory hash algorithm selection @@ -259,11 +260,7 @@ struct fiemap_extent_info { #define CAP_SYS_RESOURCE 0 #define capable(cap) (1) -/* fscrypt_str - stub */ -struct fscrypt_str { - unsigned char *name; - u32 len; -}; +/* fscrypt_str, qstr are now in ext4_fscrypt.h */ /* percpu rw semaphore - stubs */ struct percpu_rw_semaphore { @@ -281,12 +278,9 @@ static inline void memalloc_nofs_restore(unsigned int flags) { } /* Inode flags - stubs */ #define IS_CASEFOLDED(inode) (0) -#define IS_ENCRYPTED(inode) (0) +/* IS_ENCRYPTED and FSCRYPT_SET_CONTEXT_MAX_SIZE are in ext4_fscrypt.h */ #define S_NOQUOTA 0 -/* fscrypt context - stub */ -#define FSCRYPT_SET_CONTEXT_MAX_SIZE 40 - /* User namespace - stub */ struct user_namespace { int dummy; @@ -389,9 +383,7 @@ extern struct inode *new_inode(struct super_block *sb); #define clear_nlink(inode) do { } while (0) #define IS_DIRSYNC(inode) ({ (void)(inode); 0; }) -/* fscrypt stubs */ -#define fscrypt_prepare_new_inode(dir, i, e) ({ (void)(dir); (void)(i); (void)(e); 0; }) -#define fscrypt_set_context(inode, handle) ({ (void)(inode); (void)(handle); 0; }) +/* fscrypt_prepare_new_inode, fscrypt_set_context are in ext4_fscrypt.h */ /* ext4_init_acl is provided by acl.h */ /* xattr stubs for files that don't include xattr.h */ @@ -517,10 +509,7 @@ struct ratelimit_state { int dummy; }; -/* fscrypt_dummy_policy - stub */ -struct fscrypt_dummy_policy { - int dummy; -}; +/* fscrypt_dummy_policy and qstr are now in ext4_fscrypt.h */ /* errseq_t is defined in linux/fs.h */ /* time64_t is now in linux/time.h */ @@ -528,12 +517,6 @@ struct fscrypt_dummy_policy { /* IS_NOQUOTA - stub */ #define IS_NOQUOTA(inode) (0) -/* qstr - quick string for filenames (must be before dentry) */ -struct qstr { - const unsigned char *name; - unsigned int len; -}; - /* dentry - stub */ struct dentry { struct qstr d_name; @@ -981,17 +964,7 @@ struct dx_hash_info { /* seq_file - forward declaration */ struct seq_file; -/* fscrypt stubs - encryption not supported in U-Boot */ -static inline bool fscrypt_has_encryption_key(const struct inode *inode) -{ - return false; -} - -static inline u64 fscrypt_fname_siphash(const struct inode *dir, - const struct qstr *name) -{ - return 0; -} +/* fscrypt_has_encryption_key, fscrypt_fname_siphash are in ext4_fscrypt.h */ /* ext4 warning macros - stubs (only when ext4.h is not included) */ #ifdef EXT4_UBOOT_NO_EXT4_H @@ -1450,8 +1423,7 @@ static inline char *d_path(const struct path *path, char *buf, int buflen) return buf; } -/* fscrypt/fsverity stubs */ -#define fscrypt_file_open(i, f) ({ (void)(i); (void)(f); 0; }) +/* fscrypt_file_open is in ext4_fscrypt.h */ #define fsverity_file_open(i, f) ({ (void)(i); (void)(f); 0; }) /* Quota file open - stub */ @@ -1541,38 +1513,7 @@ static inline char *d_path(const struct path *path, char *buf, int buflen) #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; }) -/* fscrypt stubs - additional */ -#define fscrypt_inode_uses_fs_layer_crypto(i) (0) -#define fscrypt_decrypt_pagecache_blocks(f, l, o) ({ (void)(f); (void)(l); (void)(o); 0; }) -#define fscrypt_encrypt_pagecache_blocks(f, l, o, g) ({ (void)(f); (void)(l); (void)(o); (void)(g); (struct page *)NULL; }) -#define fscrypt_zeroout_range(i, lb, pb, l) ({ (void)(i); (void)(lb); (void)(pb); (void)(l); 0; }) -#define fscrypt_limit_io_blocks(i, lb, l) (l) -#define fscrypt_prepare_setattr(d, a) ({ (void)(d); (void)(a); 0; }) -#define fscrypt_dio_supported(i) (1) -#define fscrypt_has_permitted_context(p, c) ({ (void)(p); (void)(c); 1; }) -#define fscrypt_is_nokey_name(d) ({ (void)(d); 0; }) -#define fscrypt_prepare_symlink(d, s, l, m, dl) ({ (void)(d); (void)(m); (dl)->name = (unsigned char *)(s); (dl)->len = (l) + 1; 0; }) -#define fscrypt_encrypt_symlink(i, s, l, d) ({ (void)(i); (void)(s); (void)(l); (void)(d); 0; }) -#define fscrypt_prepare_link(o, d, n) ({ (void)(o); (void)(d); (void)(n); 0; }) -#define fscrypt_prepare_rename(od, ode, nd, nde, f) ({ (void)(od); (void)(ode); (void)(nd); (void)(nde); (void)(f); 0; }) - -/* fscrypt_name - stub structure for encrypted filenames */ -struct fscrypt_name { - const struct qstr *usr_fname; - struct fscrypt_str disk_name; - u32 hash; - u32 minor_hash; - bool is_nokey_name; -}; - -static inline int fscrypt_match_name(const struct fscrypt_name *fname, - const u8 *de_name, u32 de_name_len) -{ - if (fname->usr_fname->len != de_name_len) - return 0; - - return !memcmp(fname->usr_fname->name, de_name, de_name_len); -} +/* fscrypt_name, fscrypt_match_name, and fscrypt stubs are in ext4_fscrypt.h */ /* fsverity stubs */ #define fsverity_prepare_setattr(d, a) ({ (void)(d); (void)(a); 0; }) @@ -1688,14 +1629,10 @@ extern struct inode *iget_locked(struct super_block *sb, unsigned long ino); * Additional stubs for dir.c */ -/* fscrypt_str - encrypted filename string */ +/* FSTR_INIT - fscrypt_str initializer (fscrypt_str defined in ext4_fscrypt.h) */ #define FSTR_INIT(n, l) { .name = (n), .len = (l) } -/* fscrypt directory operations */ -#define fscrypt_prepare_readdir(i) ({ (void)(i); 0; }) -#define fscrypt_fname_alloc_buffer(len, buf) ({ (void)(len); (void)(buf); 0; }) -#define fscrypt_fname_free_buffer(buf) do { (void)(buf); } while (0) -#define fscrypt_fname_disk_to_usr(i, h1, h2, d, u) ({ (void)(i); (void)(h1); (void)(h2); (void)(d); (void)(u); 0; }) +/* fscrypt directory operations are in ext4_fscrypt.h */ /* Readahead operations */ #define ra_has_index(ra, idx) ({ (void)(ra); (void)(idx); 0; }) @@ -1801,9 +1738,7 @@ static inline const char *simple_get_link(struct dentry *dentry, return inode->i_link; } -/* fscrypt symlink stubs */ -#define fscrypt_get_symlink(i, c, m, d) ({ (void)(i); (void)(c); (void)(m); (void)(d); ERR_PTR(-EOPNOTSUPP); }) -#define fscrypt_symlink_getattr(p, s) ({ (void)(p); (void)(s); 0; }) +/* fscrypt symlink stubs are in ext4_fscrypt.h */ /* * Additional stubs for super.c @@ -2215,10 +2150,7 @@ void wait_for_completion(struct completion *comp); /* DAX - declaration for stub.c */ void fs_put_dax(void *dax, void *holder); -/* fscrypt - declarations for stub.c */ -void fscrypt_free_dummy_policy(struct fscrypt_dummy_policy *policy); -int fscrypt_drop_inode(struct inode *inode); -void fscrypt_free_inode(struct inode *inode); +/* 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, @@ -2236,10 +2168,8 @@ int inode_generic_drop(struct inode *inode); #define invalidate_inode_buffers(i) do { } while (0) #define clear_inode(i) do { } while (0) -/* fscrypt/fsverity additional stubs */ -#define fscrypt_put_encryption_info(i) do { } while (0) +/* fsverity stubs (fscrypt macros are in ext4_fscrypt.h) */ #define fsverity_cleanup_inode(i) do { } while (0) -#define fscrypt_parse_test_dummy_encryption(p, d) ({ (void)(p); (void)(d); 0; }) /* NFS export helpers - declarations for stub.c */ struct dentry *generic_fh_to_dentry(struct super_block *sb, struct fid *fid, @@ -2259,12 +2189,7 @@ int IOPRIO_PRIO_VALUE(int class, int data); char *kmemdup_nul(const char *s, size_t len, gfp_t gfp); #define strscpy_pad(dst, src) strncpy(dst, src, sizeof(dst)) -/* fscrypt/fsverity declarations for stub.c */ -int fscrypt_is_dummy_policy_set(const struct fscrypt_dummy_policy *policy); -int fscrypt_dummy_policies_equal(const struct fscrypt_dummy_policy *p1, - const struct fscrypt_dummy_policy *p2); -void fscrypt_show_test_dummy_encryption(struct seq_file *seq, char sep, - struct super_block *sb); +/* fscrypt declarations are in ext4_fscrypt.h */ /* Memory allocation - declarations for stub.c */ void *kvzalloc(size_t size, gfp_t flags); @@ -2618,14 +2543,7 @@ struct folio_iter { /* GFP_NOIO - allocation without I/O */ #define GFP_NOIO 0 -/* fscrypt stubs for page-io.c */ -#define fscrypt_is_bounce_folio(f) ({ (void)(f); 0; }) -#define fscrypt_pagecache_folio(f) (f) -#define fscrypt_free_bounce_page(p) do { (void)(p); } while (0) -#define fscrypt_set_bio_crypt_ctx_bh(bio, bh, gfp) \ - do { (void)(bio); (void)(bh); (void)(gfp); } while (0) -#define fscrypt_mergeable_bio_bh(bio, bh) \ - ({ (void)(bio); (void)(bh); 1; }) +/* fscrypt page-io stubs are in ext4_fscrypt.h */ /* folio writeback operations */ #define folio_end_writeback(f) do { (void)(f); } while (0) @@ -2657,13 +2575,7 @@ typedef void *mempool_t; #define folio_end_read(f, success) do { (void)(f); (void)(success); } while (0) #define folio_set_mappedtodisk(f) do { (void)(f); } while (0) -/* fscrypt stubs for readpage.c */ -#define fscrypt_decrypt_bio(bio) ({ (void)(bio); 0; }) -#define fscrypt_enqueue_decrypt_work(work) do { (void)(work); } while (0) -#define fscrypt_mergeable_bio(bio, inode, blk) \ - ({ (void)(bio); (void)(inode); (void)(blk); 1; }) -#define fscrypt_set_bio_crypt_ctx(bio, inode, blk, gfp) \ - do { (void)(bio); (void)(inode); (void)(blk); (void)(gfp); } while (0) +/* fscrypt readpage stubs are in ext4_fscrypt.h */ /* fsverity stubs */ #define fsverity_verify_bio(bio) do { (void)(bio); } while (0) -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Remove percpu_counter stubs from ext4_uboot.h that are already defined as inline functions in include/linux/percpu_counter.h The header file provides proper implementations for single-threaded U-Boot operation. Removed duplicates: - percpu_counter_read_positive - percpu_counter_sum_positive - percpu_counter_add - percpu_counter_inc - percpu_counter_dec - percpu_counter_initialized - percpu_counter_init - percpu_counter_destroy - percpu_counter_sub Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index c6795b35501..aee6938977d 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -336,13 +336,7 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); /* KUNIT stub */ #define KUNIT_STATIC_STUB_REDIRECT(...) do { } while (0) -/* percpu_counter operations - stubs */ -#define percpu_counter_read_positive(fbc) ((fbc)->count) -#define percpu_counter_sum_positive(fbc) ((fbc)->count) -#define percpu_counter_add(fbc, amount) ((fbc)->count += (amount)) -#define percpu_counter_inc(fbc) ((fbc)->count++) -#define percpu_counter_dec(fbc) ((fbc)->count--) -#define percpu_counter_initialized(fbc) ((fbc)->initialized) +/* percpu_counter operations are in linux/percpu_counter.h */ /* Group permission - stub */ #define in_group_p(gid) (0) @@ -1188,10 +1182,7 @@ static inline ktime_t ktime_add_ns(ktime_t kt, s64 ns) /* write lock variants */ #define write_trylock(lock) ({ (void)(lock); 1; }) -/* percpu counter init/destroy */ -#define percpu_counter_init(fbc, val, gfp) \ - ({ (fbc)->count = (val); (fbc)->initialized = true; 0; }) -#define percpu_counter_destroy(fbc) do { } while (0) +/* percpu_counter_init/destroy are in linux/percpu_counter.h */ /* ratelimit macros */ #define DEFAULT_RATELIMIT_INTERVAL (5 * 1000) @@ -1480,8 +1471,7 @@ static inline char *d_path(const struct path *path, char *buf, int buflen) #define dquot_transfer(m, i, a) ({ (void)(m); (void)(i); (void)(a); 0; }) #define is_quota_modification(m, i, a) ({ (void)(m); (void)(i); (void)(a); 0; }) -/* Percpu counter sub */ -#define percpu_counter_sub(fbc, amount) ((fbc)->count -= (amount)) +/* percpu_counter_sub is in linux/percpu_counter.h */ /* Filemap operations - additional */ #define filemap_get_folio(m, i) ((struct folio *)NULL) -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Remove the local 'struct completion' definition and the wait_for_completion() function from ext4lm using linux/completion.h instead. The header provides the same stub functionality via macros and static inline functions. Also fix linux/completion.h to use 'static inline' instead of just 'inline' for the U-Boot stub functions to prevent multiple definition errors when the header is included in multiple C files. 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 +++----- fs/ext4l/stub.c | 5 +---- include/linux/completion.h | 24 ++++++++++++------------ 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index aee6938977d..16b0512781f 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -126,10 +126,8 @@ struct lock_class_key { int dummy; }; #define rwsem_release(l, i) do { } while (0) #define _THIS_IP_ ((unsigned long)0) -/* completion - stub */ -struct completion { - unsigned int done; -}; +/* completion - use Linux header */ +#include <linux/completion.h> /* Cache alignment - stub */ #define ____cacheline_aligned_in_smp @@ -2135,7 +2133,7 @@ void invalidate_bdev(struct block_device *bdev); /* Kobject - declarations for stub.c */ void kobject_put(struct kobject *kobj); -void wait_for_completion(struct completion *comp); +/* wait_for_completion is now a macro in linux/completion.h */ /* DAX - declaration for stub.c */ void fs_put_dax(void *dax, void *holder); diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c index 2084faa3b50..6e16af2dc24 100644 --- a/fs/ext4l/stub.c +++ b/fs/ext4l/stub.c @@ -486,10 +486,7 @@ void kobject_put(struct kobject *kobj) { } -/* completion */ -void wait_for_completion(struct completion *comp) -{ -} +/* completion - now uses linux/completion.h macro */ /* DAX */ void *fs_dax_get_by_bdev(struct block_device *bdev, u64 *start, u64 *len, diff --git a/include/linux/completion.h b/include/linux/completion.h index 9835826d285..7336421ea84 100644 --- a/include/linux/completion.h +++ b/include/linux/completion.h @@ -129,39 +129,39 @@ extern void complete_all(struct completion *); #define wait_for_completion(x) do {} while (0) #define wait_for_completion_io(x) do {} while (0) -inline int wait_for_completion_interruptible(struct completion *x) +static inline int wait_for_completion_interruptible(struct completion *x) { return 1; } -inline int wait_for_completion_killable(struct completion *x) +static inline int wait_for_completion_killable(struct completion *x) { return 1; } -inline unsigned long wait_for_completion_timeout(struct completion *x, - unsigned long timeout) +static inline unsigned long wait_for_completion_timeout(struct completion *x, + unsigned long timeout) { return 1; } -inline unsigned long wait_for_completion_io_timeout(struct completion *x, - unsigned long timeout) +static inline unsigned long wait_for_completion_io_timeout(struct completion *x, + unsigned long timeout) { return 1; } -inline long wait_for_completion_interruptible_timeout(struct completion *x, - unsigned long timeout) +static inline long wait_for_completion_interruptible_timeout(struct completion *x, + unsigned long timeout) { return 1; } -inline long wait_for_completion_killable_timeout(struct completion *x, - unsigned long timeout) +static inline long wait_for_completion_killable_timeout(struct completion *x, + unsigned long timeout) { return 1; } -inline bool try_wait_for_completion(struct completion *x) +static inline bool try_wait_for_completion(struct completion *x) { return 1; } -inline bool completion_done(struct completion *x) +static inline bool completion_done(struct completion *x) { return 1; } -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Replace the dquot_suspend() function in stub.c with a macro in ext4_uboot.h The function just returned 0, which is the same as what the macro does. This is consistent with the other quota stubs like dquot_resume which are already 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 | 4 ++-- fs/ext4l/stub.c | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 16b0512781f..0edcb4533b7 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -2303,8 +2303,8 @@ void *bdev_file_open_by_dev(dev_t dev, int flags, void *holder, /* Filesystem sync - declaration for stub.c */ int sync_filesystem(void *sb); -/* Quota - declaration for stub.c */ -int dquot_suspend(void *sb, int flags); +/* Quota - declarations for stub.c */ +#define dquot_suspend(sb, type) ({ (void)(sb); (void)(type); 0; }) int dquot_alloc_space_nodirty(struct inode *inode, loff_t size); void dquot_free_space_nodirty(struct inode *inode, loff_t size); int dquot_alloc_block(struct inode *inode, loff_t nr); diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c index 6e16af2dc24..378ee76b8b5 100644 --- a/fs/ext4l/stub.c +++ b/fs/ext4l/stub.c @@ -444,11 +444,7 @@ int sync_filesystem(void *sb) return 0; } -/* Quota */ -int dquot_suspend(void *sb, int flags) -{ - return 0; -} +/* dquot_suspend is now a macro in ext4_uboot.h */ /* MMP daemon - now in mmp.c */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Remove the iomap type constants and struct definitions that are wrapped in a LINUX_IOMAP_H header guard. Since linux/iomap.h is already included at the top of ext4_uboot.h, this block was dead code that could never be compiled. The definitions also had different values from linux/iomap.h (e.g. IOMAP_MAPPED was 0 vs 2), which could have caused subtle bugs if the guard was ever removed. 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 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 0edcb4533b7..ef40658753b 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -211,35 +211,7 @@ struct dir_context { loff_t pos; }; -/* iomap types - only define if linux/iomap.h not included */ -#ifndef LINUX_IOMAP_H -#define IOMAP_MAPPED 0 -#define IOMAP_INLINE 1 -#define IOMAP_UNWRITTEN 2 -#define IOMAP_DELALLOC 3 -#define IOMAP_HOLE 4 - -struct iomap { - u64 addr; - loff_t offset; - loff_t length; - u16 type; - u16 flags; - struct block_device *bdev; - void *inline_data; -}; - -struct iomap_ops { - int (*iomap_begin)(struct inode *inode, loff_t pos, loff_t length, - unsigned flags, struct iomap *iomap, struct iomap *srcmap); - int (*iomap_end)(struct inode *inode, loff_t pos, loff_t length, - ssize_t written, unsigned flags, struct iomap *iomap); -}; - -/* iomap DIO flags */ -#define IOMAP_DIO_UNWRITTEN (1 << 0) -#define IOMAP_DIO_FORCE_WAIT (1 << 1) -#endif /* LINUX_IOMAP_H */ +/* iomap types and structs are in linux/iomap.h */ /* fiemap types */ #define FIEMAP_FLAG_SYNC 0x00000001 -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create a new header file for per-CPU variable and operation stubs. U-Boot is single-threaded, so per-CPU variables are just regular variables and per-CPU operations are simple direct accesses. The new header includes: - DEFINE_PER_CPU, per_cpu, per_cpu_ptr, this_cpu_inc, this_cpu_read - for_each_possible_cpu, smp_processor_id, num_possible_cpus - alloc_percpu, free_percpu - struct percpu_rw_semaphore and related operations This consolidates scattered per-CPU definitions from ext4_uboot.h and removes the function implementations from stub.c. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 33 +++++--------------------- fs/ext4l/stub.c | 11 ++------- include/linux/percpu.h | 54 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 36 deletions(-) create mode 100644 include/linux/percpu.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index ef40658753b..166768985b1 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -103,8 +103,9 @@ typedef struct { atomic_t refs; } refcount_t; /* RB tree types - from <linux/rbtree.h> included above */ -/* percpu_counter - use Linux header */ +/* percpu - use Linux headers */ #include <linux/percpu_counter.h> +#include <linux/percpu.h> /* Project ID type */ typedef struct { unsigned int val; } kprojid_t; @@ -232,15 +233,7 @@ struct fiemap_extent_info { /* fscrypt_str, qstr are now in ext4_fscrypt.h */ -/* percpu rw semaphore - stubs */ -struct percpu_rw_semaphore { - int dummy; -}; - -#define percpu_down_read(sem) do { } while (0) -#define percpu_up_read(sem) do { } while (0) -#define percpu_down_write(sem) do { } while (0) -#define percpu_up_write(sem) do { } while (0) +/* percpu rw semaphore is in linux/percpu.h */ /* Memory allocation context - stubs */ static inline unsigned int memalloc_nofs_save(void) { return 0; } @@ -2095,9 +2088,7 @@ void fsnotify_sb_error(struct super_block *sb, struct inode *inode, int error); char *file_path(struct file *file, char *buf, int buflen); struct block_device *file_bdev(struct file *file); -/* Percpu rwsem - declarations for stub.c */ -int percpu_init_rwsem(struct percpu_rw_semaphore *sem); -void percpu_free_rwsem(struct percpu_rw_semaphore *sem); +/* percpu_init_rwsem/percpu_free_rwsem are in linux/percpu.h */ /* Block device sync - declarations for stub.c */ int sync_blockdev(struct block_device *bdev); @@ -2302,14 +2293,7 @@ struct xarray { int dummy; }; -/* Per-CPU stubs - U-Boot is single-threaded */ -#define DEFINE_PER_CPU(type, name) type name -#define per_cpu(var, cpu) (var) -#define per_cpu_ptr(ptr, cpu) (ptr) -#define this_cpu_inc(var) ((var)++) -#define this_cpu_read(var) (var) -#define for_each_possible_cpu(cpu) for ((cpu) = 0; (cpu) < 1; (cpu)++) -#define smp_processor_id() 0 +/* Per-CPU stubs are in linux/percpu.h */ /* XArray function stubs */ #define xa_init(xa) do { } while (0) @@ -2392,12 +2376,7 @@ struct seq_operations { /* Block layer constants */ #define BLK_MAX_SEGMENT_SIZE 65536 -/* num_possible_cpus - number of possible CPUs (always 1 in U-Boot) */ -#define num_possible_cpus() 1 - -/* Per-CPU allocation stubs */ -#define alloc_percpu(type) ((type *)kzalloc(sizeof(type), GFP_KERNEL)) -#define free_percpu(ptr) kfree(ptr) +/* num_possible_cpus, alloc_percpu, free_percpu are in linux/percpu.h */ /* Block device properties */ #define bdev_nonrot(bdev) ({ (void)(bdev); 0; }) diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c index 378ee76b8b5..a0c21dfd14c 100644 --- a/fs/ext4l/stub.c +++ b/fs/ext4l/stub.c @@ -455,10 +455,7 @@ void ext4_unregister_sysfs(void *sb) /* jbd2_journal_destroy is now in journal.c */ -/* percpu rwsem */ -void percpu_free_rwsem(struct percpu_rw_semaphore *sem) -{ -} +/* percpu_free_rwsem is now in linux/percpu.h */ /* Block device ops */ int sync_blockdev(struct block_device *bdev) @@ -589,11 +586,7 @@ void iput(struct inode *inode) } } -/* percpu init rwsem */ -int percpu_init_rwsem(struct percpu_rw_semaphore *sem) -{ - return 0; -} +/* percpu_init_rwsem is now in linux/percpu.h */ /* atomic_add and atomic64_add are now in asm-generic/atomic.h */ diff --git a/include/linux/percpu.h b/include/linux/percpu.h new file mode 100644 index 00000000000..3aa71c1451f --- /dev/null +++ b/include/linux/percpu.h @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Per-CPU variable and operation stubs for U-Boot + * + * U-Boot is single-threaded, so per-CPU variables are just regular + * variables and per-CPU operations are simple direct accesses. + */ +#ifndef _LINUX_PERCPU_H +#define _LINUX_PERCPU_H + +#include <linux/types.h> +#include <malloc.h> + +/* + * Per-CPU variable definitions - just regular variables in U-Boot + */ +#define DEFINE_PER_CPU(type, name) type name +#define per_cpu(var, cpu) (var) +#define per_cpu_ptr(ptr, cpu) (ptr) +#define this_cpu_inc(var) ((var)++) +#define this_cpu_read(var) (var) + +/* CPU iteration - only one CPU in U-Boot */ +#define for_each_possible_cpu(cpu) for ((cpu) = 0; (cpu) < 1; (cpu)++) +#define smp_processor_id() 0 +#define num_possible_cpus() 1 + +/* Per-CPU allocation - just regular allocation in U-Boot */ +#define alloc_percpu(type) ((type *)kzalloc(sizeof(type), GFP_KERNEL)) +#define free_percpu(ptr) kfree(ptr) + +/* + * Per-CPU read-write semaphore stubs + * U-Boot is single-threaded, so these are no-ops + */ +struct percpu_rw_semaphore { + int dummy; +}; + +#define percpu_down_read(sem) do { } while (0) +#define percpu_up_read(sem) do { } while (0) +#define percpu_down_write(sem) do { } while (0) +#define percpu_up_write(sem) do { } while (0) + +static inline int percpu_init_rwsem(struct percpu_rw_semaphore *sem) +{ + return 0; +} + +static inline void percpu_free_rwsem(struct percpu_rw_semaphore *sem) +{ +} + +#endif /* _LINUX_PERCPU_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Remove the forward declarations for struct inode and struct address_space since linux/fs.h is already included earlier and provides these declarations. 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 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 166768985b1..e09f5c31ebe 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -166,9 +166,7 @@ struct lock_class_key { int dummy; }; /* File flags */ #define O_SYNC 0 -/* Forward declarations for iomap_ops */ -struct inode; -struct address_space; +/* Forward declarations (struct inode, struct address_space) are in linux/fs.h */ /* Page types */ typedef unsigned long pgoff_t; -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move simple buffer operation stubs to include/linux/buffer_head.h where they belong. These operations are no-ops in single-threaded U-Boot: - wait_on_buffer: no waiting needed - __bforget: no buffer cache to forget from - lock_buffer: uses set_buffer_locked (already in header) - unlock_buffer: uses clear_buffer_locked (already in header) - test_clear_buffer_dirty: always returns 0 The mark_buffer_dirty macros remain in ext4_uboot.h as they depend on sync_dirty_buffer which is defined later in ext4l. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 7 +------ include/linux/buffer_head.h | 9 +++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index e09f5c31ebe..9329d854bd3 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -260,15 +260,10 @@ extern struct user_namespace init_user_ns; /* Trace stubs are now in ext4_trace.h */ -/* Buffer operations - stubs */ -#define wait_on_buffer(bh) do { } while (0) -#define __bforget(bh) do { } while (0) +/* 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) -#define lock_buffer(bh) set_buffer_locked(bh) -#define unlock_buffer(bh) clear_buffer_locked(bh) struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); -#define test_clear_buffer_dirty(bh) ({ (void)(bh); 0; }) #define wait_on_bit_io(addr, bit, mode) do { (void)(addr); (void)(bit); (void)(mode); } while (0) /* inode_needs_sync - stub */ diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index b22df564119..94bd2bab96a 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -177,4 +177,13 @@ static inline void put_bh(struct buffer_head *bh) void brelse(struct buffer_head *bh); void __brelse(struct buffer_head *bh); +/* + * Buffer operation stubs - U-Boot is single-threaded + */ +#define wait_on_buffer(bh) do { } while (0) +#define __bforget(bh) do { } while (0) +#define lock_buffer(bh) set_buffer_locked(bh) +#define unlock_buffer(bh) clear_buffer_locked(bh) +#define test_clear_buffer_dirty(bh) ({ (void)(bh); 0; }) + #endif /* _LINUX_BUFFER_HEAD_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move struct address_space_operations from ext4_uboot.h to linux/fs.h where it belongs alongside struct address_space. This matches the Linux kernel structure where both are defined in include/linux/fs.h. Add necessary forward declarations for types used in the function pointers (struct file, struct folio, struct readahead_control, etc.). 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.h | 31 ++++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 9329d854bd3..715407b83d8 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1224,26 +1224,7 @@ struct readahead_control { #define readahead_pos(rac) ({ (void)(rac); 0LL; }) #define readahead_length(rac) ({ (void)(rac); 0UL; }) -/* Forward declarations for address_space_operations */ -struct writeback_control; -struct swap_info_struct; - -/* address_space_operations stub */ -struct address_space_operations { - int (*read_folio)(struct file *, struct folio *); - void (*readahead)(struct readahead_control *); - sector_t (*bmap)(struct address_space *, sector_t); - void (*invalidate_folio)(struct folio *, size_t, size_t); - bool (*release_folio)(struct folio *, gfp_t); - int (*write_begin)(const struct kiocb *, struct address_space *, loff_t, unsigned, struct folio **, void **); - int (*write_end)(const struct kiocb *, struct address_space *, loff_t, unsigned, unsigned, struct folio *, void *); - int (*writepages)(struct address_space *, struct writeback_control *); - bool (*dirty_folio)(struct address_space *, struct folio *); - bool (*is_partially_uptodate)(struct folio *, size_t, size_t); - int (*error_remove_folio)(struct address_space *, struct folio *); - int (*migrate_folio)(struct address_space *, struct folio *, struct folio *, int); - int (*swap_activate)(struct swap_info_struct *, struct file *, sector_t *); -}; +/* address_space_operations is in linux/fs.h */ /* Stub for buffer_migrate_folio */ static inline int buffer_migrate_folio(struct address_space *mapping, diff --git a/include/linux/fs.h b/include/linux/fs.h index 54c0148ee72..241711eded1 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -15,7 +15,12 @@ struct inode; struct super_block; struct buffer_head; -struct address_space_operations; +struct file; +struct folio; +struct readahead_control; +struct kiocb; +struct writeback_control; +struct swap_info_struct; /* errseq_t - error sequence type */ typedef u32 errseq_t; @@ -55,6 +60,9 @@ struct path { #define FOLIO_CACHE_MAX 64 #endif +/* address_space_operations - forward declare for address_space */ +struct address_space_operations; + /* address_space - extended for inode.c */ struct address_space { struct inode *host; @@ -70,6 +78,27 @@ struct address_space { #endif }; +/* address_space_operations - filesystem address space methods */ +struct address_space_operations { + int (*read_folio)(struct file *, struct folio *); + void (*readahead)(struct readahead_control *); + sector_t (*bmap)(struct address_space *, sector_t); + void (*invalidate_folio)(struct folio *, size_t, size_t); + bool (*release_folio)(struct folio *, gfp_t); + int (*write_begin)(const struct kiocb *, struct address_space *, + loff_t, unsigned, struct folio **, void **); + int (*write_end)(const struct kiocb *, struct address_space *, + loff_t, unsigned, unsigned, struct folio *, void *); + int (*writepages)(struct address_space *, struct writeback_control *); + bool (*dirty_folio)(struct address_space *, struct folio *); + bool (*is_partially_uptodate)(struct folio *, size_t, size_t); + int (*error_remove_folio)(struct address_space *, struct folio *); + int (*migrate_folio)(struct address_space *, struct folio *, + struct folio *, int); + int (*swap_activate)(struct swap_info_struct *, struct file *, + sector_t *); +}; + /* block_device - minimal stub */ struct block_device { struct address_space *bd_mapping; -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> The ext4l code defines local versions of BUILD_BUG_ON(), WARN_ON(), and WARN_ONCE() instead of using the standard U-Boot headers. Use linux/build_bug.h and linux/bug.h to provide these macros. Keep BUG()/BUG_ON() as no-op stubs since linux/bug.h's versions call panic(). Some BUG_ON() conditions check for race conditions that can trigger in single-threaded U-Boot, so they must be stubbed out. Add a bio_sectors() inline function which is now needed because WARN_ONCE() evaluates its arguments (unlike the previous no-op stub). Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 715407b83d8..b13e653c883 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -39,6 +39,8 @@ #include <linux/seq_file.h> #include <linux/rbtree.h> /* Real rbtree implementation */ #include <linux/time.h> /* For timespec64, time64_t */ +#include <linux/build_bug.h> /* For BUILD_BUG_ON */ +#include <linux/bug.h> /* For WARN_ON, WARN_ONCE */ #include <u-boot/crc.h> /* For crc32() used by crc32_be */ #include "ext4_trace.h" /* Trace event stubs */ #include "ext4_fscrypt.h" /* fscrypt stubs */ @@ -248,8 +250,15 @@ struct user_namespace { }; extern struct user_namespace init_user_ns; -/* BUG_ON / BUG - stubs (panic is in vsprintf.h) */ -#define BUG_ON(cond) do { } while (0) +/* + * BUG_ON / BUG - stubs (not using linux/bug.h which panics) + * In Linux, these indicate kernel bugs. In ext4l, some BUG_ON conditions + * that check for race conditions can trigger in single-threaded U-Boot, + * so we stub them out as no-ops. + */ +#undef BUG_ON +#undef BUG +#define BUG_ON(cond) do { (void)(cond); } while (0) #define BUG() do { } while (0) /* might_sleep - stub */ @@ -930,13 +939,8 @@ struct seq_file; #define fallthrough __attribute__((__fallthrough__)) #endif -/* BUILD_BUG_ON - compile-time assertion */ -#define BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)])) - -/* Warning macros - stubs */ -#define WARN_ON_ONCE(cond) ({ (void)(cond); 0; }) -#define WARN_ON(cond) ({ (void)(cond); 0; }) -#define WARN_ONCE(cond, fmt, ...) ({ (void)(cond); 0; }) +/* BUILD_BUG_ON is in linux/build_bug.h */ +/* WARN_ON, WARN_ON_ONCE, WARN_ONCE are in linux/bug.h */ #define pr_warn_once(fmt, ...) do { } while (0) /* lockdep stubs */ @@ -2418,6 +2422,12 @@ struct bio { void (*bi_end_io)(struct bio *); }; +/* bio_sectors - return number of sectors in bio */ +static inline unsigned int bio_sectors(struct bio *bio) +{ + return bio->bi_iter.bi_size >> 9; +} + /* folio_iter for bio iteration */ struct folio_iter { int i; -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move struct seq_operations and SEQ_START_TOKEN to linux/seq_file.h where they belong, following standard Linux header organisation. Also move GFP_NOIO to linux/slab.h with the other GFP flags, and remove the redundant bh_end_io_t typedef since it is already defined in linux/buffer_head.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 | 28 ++++++---------------------- include/linux/seq_file.h | 13 +++++++++++++ include/linux/slab.h | 3 +++ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index b13e653c883..3cc37f65dda 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -524,11 +524,7 @@ typedef long long qsize_t; /* blk_opf_t - block operation flags */ typedef unsigned int blk_opf_t; -/* Forward declare buffer_head for bh_end_io_t */ -struct buffer_head; - -/* bh_end_io_t - buffer head end io callback */ -typedef void bh_end_io_t(struct buffer_head *bh, int uptodate); +/* bh_end_io_t and struct buffer_head are in linux/buffer_head.h */ /* Directory entry types */ #define DT_UNKNOWN 0 @@ -919,9 +915,7 @@ struct dx_hash_info { #define EXT4_HTREE_EOF_64BIT ((1ULL << (64 - 1)) - 1) /* jbd2_buffer_trigger_type is defined in jbd2.h */ - -/* seq_file - forward declaration */ -struct seq_file; +/* struct seq_file is in linux/seq_file.h */ /* fscrypt_has_encryption_key, fscrypt_fname_siphash are in ext4_fscrypt.h */ @@ -1151,8 +1145,7 @@ static inline ktime_t ktime_add_ns(ktime_t kt, s64 ns) int name __attribute__((unused)) = 0 #define __ratelimit(state) ({ (void)(state); 1; }) -/* seq_file tokens */ -#define SEQ_START_TOKEN ((void *)1) +/* SEQ_START_TOKEN is in linux/seq_file.h */ /* folio - memory page container stub */ struct folio { @@ -1874,8 +1867,7 @@ struct kstatfs { long f_spare[4]; }; -/* seq_file stubs */ -struct seq_file; +/* struct seq_file is in linux/seq_file.h */ /* Module stubs */ struct module; @@ -2339,13 +2331,7 @@ static inline unsigned long ext4_find_next_bit_le(const void *addr, /* pde_data - proc dir entry data (not supported in U-Boot) */ #define pde_data(inode) ((void *)NULL) -/* seq_operations for procfs iteration */ -struct seq_operations { - void *(*start)(struct seq_file *m, loff_t *pos); - void (*stop)(struct seq_file *m, void *v); - void *(*next)(struct seq_file *m, void *v, loff_t *pos); - int (*show)(struct seq_file *m, void *v); -}; +/* struct seq_operations is in linux/seq_file.h */ /* DEFINE_RAW_FLEX - define a flexible array struct on the stack (stubbed to NULL) */ #define DEFINE_RAW_FLEX(type, name, member, count) \ @@ -2462,9 +2448,7 @@ struct folio_iter { #define blk_status_to_errno(status) (-(status)) /* atomic_inc is in asm-generic/atomic.h */ - -/* GFP_NOIO - allocation without I/O */ -#define GFP_NOIO 0 +/* GFP_NOIO is in linux/slab.h */ /* fscrypt page-io stubs are in ext4_fscrypt.h */ diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index e4139f48e16..c10da3e4f98 100644 --- a/include/linux/seq_file.h +++ b/include/linux/seq_file.h @@ -2,6 +2,8 @@ #ifndef _LINUX_SEQ_FILE_H #define _LINUX_SEQ_FILE_H +#include <linux/types.h> + /* * Stub definitions for seq_file interface. * U-Boot doesn't use /proc filesystem. @@ -12,6 +14,17 @@ struct seq_file { struct file *file; }; +/* seq_operations for procfs iteration */ +struct seq_operations { + void *(*start)(struct seq_file *m, loff_t *pos); + void (*stop)(struct seq_file *m, void *v); + void *(*next)(struct seq_file *m, void *v, loff_t *pos); + int (*show)(struct seq_file *m, void *v); +}; + +/* SEQ_START_TOKEN for iteration start marker */ +#define SEQ_START_TOKEN ((void *)1) + #define seq_printf(m, fmt, ...) do { (void)(m); } while (0) #define seq_puts(m, s) do { (void)(m); (void)(s); } while (0) #define seq_putc(m, c) do { (void)(m); (void)(c); } while (0) diff --git a/include/linux/slab.h b/include/linux/slab.h index 2b374641534..f0c0add0cbd 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -42,6 +42,9 @@ #ifndef __GFP_NOFAIL #define __GFP_NOFAIL ((gfp_t)0) #endif +#ifndef GFP_NOIO +#define GFP_NOIO ((gfp_t)0) +#endif void *kmalloc(size_t size, gfp_t flags); -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Replace the duplicate struct folio_batch definition and folio_batch_init macro with the existing linux/pagevec.h header which provides the same functionality. This consolidates the folio batch handling into a single location. 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 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 3cc37f65dda..253f09b73f9 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -39,6 +39,7 @@ #include <linux/seq_file.h> #include <linux/rbtree.h> /* Real rbtree implementation */ #include <linux/time.h> /* For timespec64, time64_t */ +#include <linux/pagevec.h> /* For struct folio_batch */ #include <linux/build_bug.h> /* For BUILD_BUG_ON */ #include <linux/bug.h> /* For WARN_ON, WARN_ONCE */ #include <u-boot/crc.h> /* For crc32() used by crc32_be */ @@ -1158,11 +1159,7 @@ struct folio { int _refcount; }; -/* folio_batch - batch of folios */ -struct folio_batch { - unsigned int nr; - struct folio *folios[16]; -}; +/* struct folio_batch is in linux/pagevec.h */ /* folio operations - stubs */ #define folio_mark_dirty(f) do { (void)(f); } while (0) @@ -1182,7 +1179,7 @@ struct folio_batch { #define folio_unlock(f) do { (void)(f); } while (0) /* folio_put and folio_get are implemented in support.c */ #define folio_lock(f) do { (void)(f); } while (0) -#define folio_batch_init(fb) do { (fb)->nr = 0; } while (0) +/* folio_batch_init is in linux/pagevec.h */ #define filemap_get_folios(m, i, e, fb) ({ (void)(m); (void)(i); (void)(e); (void)(fb); 0U; }) /* xa_mark_t - xarray mark type */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> The ext4l code defines pr_warn_once(), printk_ratelimited(), and pr_notice_ratelimited() locally instead of in the common printk header. Move these macros to linux/printk.h where they belong with the other printk macros. Also add additional _once and _ratelimited variants for consistency. 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/printk.h | 11 +++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 253f09b73f9..1c58f64ba2f 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -936,7 +936,7 @@ struct dx_hash_info { /* BUILD_BUG_ON is in linux/build_bug.h */ /* WARN_ON, WARN_ON_ONCE, WARN_ONCE are in linux/bug.h */ -#define pr_warn_once(fmt, ...) do { } while (0) +/* pr_warn_once is in linux/printk.h */ /* lockdep stubs */ #define lockdep_assert_held_read(l) do { (void)(l); } while (0) @@ -2435,8 +2435,7 @@ struct folio_iter { /* xchg - exchange value atomically */ #define xchg(ptr, new) ({ typeof(*(ptr)) __old = *(ptr); *(ptr) = (new); __old; }) -/* printk_ratelimited - just use regular printk */ -#define printk_ratelimited(fmt, ...) do { } while (0) +/* printk_ratelimited is in linux/printk.h */ /* mapping_set_error - record error in address_space */ #define mapping_set_error(m, e) do { (void)(m); (void)(e); } while (0) @@ -2635,8 +2634,7 @@ int bh_read(struct buffer_head *bh, int flags); #define free_pages(addr, order) free((void *)(addr)) #define get_order(size) ilog2(roundup_pow_of_two((size) / PAGE_SIZE)) -/* Ratelimited printk for journal.c */ -#define pr_notice_ratelimited(fmt, ...) pr_notice(fmt, ##__VA_ARGS__) +/* pr_notice_ratelimited is in linux/printk.h */ /* * Stubs for mmp.c diff --git a/include/linux/printk.h b/include/linux/printk.h index 00452944c48..7c075ae9bca 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -84,6 +84,17 @@ #define printk_once(fmt, ...) \ printk(fmt, ##__VA_ARGS__) +/* _once variants - just call the base function (no actual once tracking) */ +#define pr_warn_once(fmt, ...) pr_warn(fmt, ##__VA_ARGS__) +#define pr_info_once(fmt, ...) pr_info(fmt, ##__VA_ARGS__) +#define pr_notice_once(fmt, ...) pr_notice(fmt, ##__VA_ARGS__) + +/* _ratelimited variants - just call the base function (no rate limiting) */ +#define printk_ratelimited(fmt, ...) printk(fmt, ##__VA_ARGS__) +#define pr_notice_ratelimited(fmt, ...) pr_notice(fmt, ##__VA_ARGS__) +#define pr_warn_ratelimited(fmt, ...) pr_warn(fmt, ##__VA_ARGS__) +#define pr_err_ratelimited(fmt, ...) pr_err(fmt, ##__VA_ARGS__) + struct va_format { const char *fmt; va_list *va; -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> The ext4l code defines HZ, jiffies, msecs_to_jiffies(), jiffies_to_msecs(), nsecs_to_jiffies(), and round_jiffies_up() locally instead of in the common jiffies header. Move these to linux/jiffies.h where they belong. Also remove the redundant NSEC_PER_SEC definition since it is already in linux/time.h Time comparison macros time_before() and time_after() are provided by include/time.h which has a better implementation with typecheck() Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 18 +++--------------- include/linux/jiffies.h | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 1c58f64ba2f..44f1d2fabc8 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1968,18 +1968,7 @@ struct fs_parse_result { /* crc16 - use U-Boot's implementation */ #include <linux/crc16.h> -/* Timer and timing stubs */ -#define HZ 1000 -#define jiffies 0UL -#ifndef time_before -#define time_before(a, b) ((long)((a) - (b)) < 0) -#endif -#ifndef time_after -#define time_after(a, b) time_before(b, a) -#endif -#define msecs_to_jiffies(m) ((m) * HZ / 1000) -#define jiffies_to_msecs(j) ((j) * 1000 / HZ) -#define round_jiffies_up(j) (j) +/* Timer and timing stubs are in linux/jiffies.h */ /* Path lookup flags */ #define LOOKUP_FOLLOW 0x0001 @@ -2022,8 +2011,7 @@ void end_buffer_write_sync(struct buffer_head *bh, int uptodate); /* Block size */ #define BLOCK_SIZE 1024 -/* Time constants */ -#define NSEC_PER_SEC 1000000000L +/* NSEC_PER_SEC is in linux/time.h */ /* EXT4 magic number */ #define EXT4_SUPER_MAGIC 0xEF53 @@ -2115,7 +2103,7 @@ void *kvzalloc(size_t size, gfp_t flags); /* Time operations */ #define ktime_get_ns() (0ULL) -#define nsecs_to_jiffies(ns) ((ns) / (NSEC_PER_SEC / HZ)) +/* nsecs_to_jiffies is in linux/jiffies.h */ /* Superblock write operations */ #define sb_start_write_trylock(sb) ({ (void)(sb); 1; }) diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index daef4a337a2..153a2841bf5 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h @@ -15,4 +15,18 @@ #define MAX_JIFFY_OFFSET ((LONG_MAX >> 1) - 1) +/* HZ - timer frequency (simplified for U-Boot) */ +#define HZ 1000 + +/* jiffies - always 0 in U-Boot (no timer tick counter) */ +#define jiffies 0UL + +/* Time comparison macros are in include/time.h */ + +/* Jiffies conversion */ +#define msecs_to_jiffies(m) ((m) * HZ / 1000) +#define jiffies_to_msecs(j) ((j) * 1000 / HZ) +#define nsecs_to_jiffies(ns) ((ns) / (1000000000L / HZ)) +#define round_jiffies_up(j) (j) + #endif /* _LINUX_JIFFIES_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> The ext4l code defines MODULE_ALIAS_FS() and filesystem registration macros register_filesystem() and unregister_filesystem() locally instead of in the common module header. Move these to linux/module.h where they belong with the other module-related stubs. 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/linux/module.h | 5 +++++ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 44f1d2fabc8..4c214fa5bdc 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1866,16 +1866,8 @@ struct kstatfs { /* struct seq_file is in linux/seq_file.h */ -/* Module stubs */ -struct module; -#ifndef THIS_MODULE -#define THIS_MODULE NULL -#endif -#define MODULE_ALIAS_FS(name) - -/* register/unregister filesystem */ -#define register_filesystem(fs) ({ (void)(fs); 0; }) -#define unregister_filesystem(fs) ({ (void)(fs); 0; }) +/* Module stubs and register_filesystem are in linux/module.h */ +#include <linux/module.h> /* EXT4_GOING flags */ #define EXT4_GOING_FLAGS_DEFAULT 0 diff --git a/include/linux/module.h b/include/linux/module.h index fba06096cbc..834f7d66d49 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -33,5 +33,10 @@ struct module; #define MODULE_ALIAS(alias) #define MODULE_SOFTDEP(dep) #define MODULE_INFO(tag, info) +#define MODULE_ALIAS_FS(name) + +/* Filesystem registration - not used in U-Boot */ +#define register_filesystem(fs) ({ (void)(fs); 0; }) +#define unregister_filesystem(fs) ({ (void)(fs); 0; }) #endif /* _LINUX_MODULE_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create a new linux/lockdep.h header to consolidate all the scattered lockdep stubs from ext4_uboot.h. This includes lock_class_key, lockdep_map, and all the lockdep assertion 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 | 22 ++++++---------------- include/linux/lockdep.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 include/linux/lockdep.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 4c214fa5bdc..ce40888879e 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -123,11 +123,7 @@ struct kobject { }; /* lockdep stubs - needed before jbd2.h is included */ -struct lockdep_map { int dummy; }; -struct lock_class_key { int dummy; }; -#define rwsem_acquire(l, s, t, i) do { } while (0) -#define rwsem_acquire_read(l, s, t, i) do { } while (0) -#define rwsem_release(l, i) do { } while (0) +#include <linux/lockdep.h> #define _THIS_IP_ ((unsigned long)0) /* completion - use Linux header */ @@ -388,8 +384,7 @@ int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode, /* RCU head for callbacks - defined in linux/compat.h as callback_head */ -/* lockdep stubs */ -#define lockdep_is_held(lock) (1) +/* lockdep_is_held is in linux/lockdep.h */ /* Memory allocation - use linux/slab.h which is already available */ #include <linux/slab.h> @@ -938,8 +933,7 @@ struct dx_hash_info { /* WARN_ON, WARN_ON_ONCE, WARN_ONCE are in linux/bug.h */ /* pr_warn_once is in linux/printk.h */ -/* lockdep stubs */ -#define lockdep_assert_held_read(l) do { (void)(l); } while (0) +/* lockdep_assert_held_read is in linux/lockdep.h */ /* strtomem_pad - copy string to fixed-size buffer with padding */ #define strtomem_pad(dest, src, pad) do { \ @@ -987,9 +981,7 @@ static inline unsigned long memweight(const void *ptr, size_t bytes) #define inode_trylock_shared(inode) (1) #define inode_dio_wait(inode) do { } while (0) -/* Lock debugging - no-ops in U-Boot */ -#define lockdep_assert_held_write(l) do { } while (0) -#define lockdep_assert_held(l) do { } while (0) +/* Lock debugging stubs are in linux/lockdep.h */ /* File operations */ #define file_modified(file) ({ (void)(file); 0; }) @@ -2502,8 +2494,7 @@ struct wait_bit_entry { #define release_dentry_name_snapshot(snap) \ do { (void)(snap); } while (0) -/* lockdep stubs */ -#define lockdep_assert_not_held(lock) do { (void)(lock); } while (0) +/* lockdep_assert_not_held is in linux/lockdep.h */ /* Request flags for block I/O */ #define REQ_IDLE 0 @@ -2591,8 +2582,7 @@ loff_t seq_lseek(struct file *f, loff_t o, int w); ({ (void)(n); (void)(m); (void)(p); (void)(ops); (void)(d); (struct proc_dir_entry *)NULL; }) #define remove_proc_entry(n, p) do { (void)(n); (void)(p); } while (0) -/* lockdep stubs (struct lock_class_key defined earlier) */ -#define lockdep_init_map(...) do { } while (0) +/* 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); diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h new file mode 100644 index 00000000000..e95b6d171ad --- /dev/null +++ b/include/linux/lockdep.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Lock dependency validator stubs for U-Boot + * + * U-Boot is single-threaded, so lock dependency checking is not needed. + * These stubs allow Linux kernel code to compile unchanged. + */ +#ifndef _LINUX_LOCKDEP_H +#define _LINUX_LOCKDEP_H + +/* Lock class key - used for lockdep annotations */ +struct lock_class_key { + int dummy; +}; + +/* Lockdep map - used for lock tracking */ +struct lockdep_map { + int dummy; +}; + +/* Lockdep assertion macros - all no-ops in U-Boot */ +#define lockdep_is_held(lock) (1) +#define lockdep_assert_held(lock) do { (void)(lock); } while (0) +#define lockdep_assert_held_read(lock) do { (void)(lock); } while (0) +#define lockdep_assert_held_write(lock) do { (void)(lock); } while (0) +#define lockdep_assert_not_held(lock) do { (void)(lock); } while (0) + +/* Lockdep initialisation and tracking - no-ops */ +#define lockdep_init_map(...) do { } while (0) + +/* RW semaphore lockdep stubs */ +#define rwsem_acquire(l, s, t, i) do { } while (0) +#define rwsem_acquire_read(l, s, t, i) do { } while (0) +#define rwsem_release(l, i) do { } while (0) + +#endif /* _LINUX_LOCKDEP_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> The ext4l code defines string helper functions locally instead of in the standard Linux compatibility headers. Move these functions to their proper locations: - strtomem_pad(): macro added to linux/string.h - strscpy_pad(): macro added to linux/string.h - strreplace(): declaration in linux/string.h, implementation in lib/string.c - kmemdup_nul(): declaration in linux/slab.h (alongside kmemdup()), implementation in lib/string.c This makes these functions available to other parts of U-Boot and reduces duplication in ext4l. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 20 ++++---------------- fs/ext4l/stub.c | 32 ++++---------------------------- include/linux/slab.h | 13 +++++++++++++ include/linux/string.h | 41 +++++++++++++++++++++++++++++++++++++++++ lib/string.c | 25 +++++++++++++++++++++++++ 5 files changed, 87 insertions(+), 44 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index ce40888879e..7b90276b2bc 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -934,16 +934,8 @@ struct dx_hash_info { /* pr_warn_once is in linux/printk.h */ /* lockdep_assert_held_read is in linux/lockdep.h */ - -/* strtomem_pad - copy string to fixed-size buffer with padding */ -#define strtomem_pad(dest, src, pad) do { \ - size_t _len = strlen(src); \ - if (_len >= sizeof(dest)) \ - _len = sizeof(dest); \ - memcpy(dest, src, _len); \ - if (_len < sizeof(dest)) \ - memset((char *)(dest) + _len, (pad), sizeof(dest) - _len); \ -} while (0) +/* strtomem_pad is in linux/string.h */ +/* strscpy_pad is in linux/string.h */ /* Memory weight - count set bits */ static inline unsigned long memweight(const void *ptr, size_t bytes) @@ -2075,10 +2067,7 @@ struct dentry *generic_fh_to_parent(struct super_block *sb, struct fid *fid, /* I/O priority - declaration for stub.c */ int IOPRIO_PRIO_VALUE(int class, int data); -/* String operations */ -char *kmemdup_nul(const char *s, size_t len, gfp_t gfp); -#define strscpy_pad(dst, src) strncpy(dst, src, sizeof(dst)) - +/* kmemdup_nul is in linux/slab.h */ /* fscrypt declarations are in ext4_fscrypt.h */ /* Memory allocation - declarations for stub.c */ @@ -2191,8 +2180,7 @@ struct mb_cache_entry { void generic_set_sb_d_ops(struct super_block *sb); struct dentry *d_make_root(struct inode *inode); -/* String operations - declarations for stub.c */ -char *strreplace(const char *str, char old, char new); +/* strreplace is in linux/string.h */ /* Ratelimit - declaration for stub.c */ void ratelimit_state_init(void *rs, int interval, int burst); diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c index a0c21dfd14c..c14132815cd 100644 --- a/fs/ext4l/stub.c +++ b/fs/ext4l/stub.c @@ -373,32 +373,8 @@ int ext4_update_overhead(struct super_block *sb, bool force) return 0; } -/* String stubs */ -/* strtomem_pad is now a macro in ext4_uboot.h */ - -char *strreplace(const char *str, char old, char new) -{ - char *s = (char *)str; - - while (*s) { - if (*s == old) - *s = new; - s++; - } - return (char *)str; -} - -char *kmemdup_nul(const char *s, size_t len, gfp_t gfp) -{ - char *buf; - - buf = kmalloc(len + 1, gfp); - if (buf) { - memcpy(buf, s, len); - buf[len] = '\0'; - } - return buf; -} +/* strtomem_pad, strscpy_pad, strreplace are now in linux/string.h */ +/* kmemdup_nul is now in linux/slab.h, with implementation in lib/string.c */ /* Page allocation */ unsigned long get_zeroed_page(gfp_t gfp) @@ -506,8 +482,8 @@ int sb_set_blocksize(struct super_block *sb, int size) return size; } -/* strscpy_pad is now a macro in ext4_uboot.h */ -/* kmemdup_nul is defined earlier in this file */ +/* strscpy_pad is now a macro in linux/string.h */ +/* kmemdup_nul is now in lib/string.c */ /* Address check */ int generic_check_addressable(unsigned int blocksize_bits, u64 num_blocks) diff --git a/include/linux/slab.h b/include/linux/slab.h index f0c0add0cbd..4f413f93fa3 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -87,6 +87,19 @@ static inline void *krealloc(const void *p, size_t new_size, gfp_t flags) void *kmemdup(const void *src, size_t len, gfp_t gfp); +/** + * kmemdup_nul - Duplicate a string with null termination + * @s: Source string + * @len: Maximum length to copy + * @gfp: GFP flags for allocation + * + * Allocates len + 1 bytes, copies up to @len bytes from @s, and + * ensures the result is null-terminated. + * + * Return: pointer to new string, or NULL on allocation failure + */ +char *kmemdup_nul(const char *s, size_t len, gfp_t gfp); + /* kmem_cache stubs */ struct kmem_cache { int sz; diff --git a/include/linux/string.h b/include/linux/string.h index d943fcce690..591d99c46a1 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -147,6 +147,47 @@ char *memdup(const void *src, size_t len); unsigned long ustrtoul(const char *cp, char **endp, unsigned int base); unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base); +/** + * strreplace() - Replace all occurrences of a character in a string + * @str: The string to operate on + * @old: The character being replaced + * @new: The character @old is replaced with + * + * Replaces all occurrences of character @old with character @new in + * the string @str in place. + * + * Return: pointer to the string @str itself + */ +char *strreplace(char *str, char old, char new); + +/** + * strtomem_pad - Copy string to fixed-size buffer with padding + * @dest: Destination buffer (must be an array, not a pointer) + * @src: Source string + * @pad: Padding character to fill remaining space + * + * Copy @src to @dest, truncating if necessary. If @src is shorter + * than @dest, fill the remaining bytes with @pad. + */ +#define strtomem_pad(dest, src, pad) do { \ + size_t _len = strlen(src); \ + if (_len >= sizeof(dest)) \ + _len = sizeof(dest); \ + memcpy(dest, src, _len); \ + if (_len < sizeof(dest)) \ + memset((char *)(dest) + _len, (pad), \ + sizeof(dest) - _len); \ +} while (0) + +/** + * strscpy_pad - Copy string to fixed-size buffer with padding + * @dest: Destination buffer (must be an array) + * @src: Source string + * + * Copy @src to @dest ensuring null termination and zero-padding. + */ +#define strscpy_pad(dest, src) strncpy(dest, src, sizeof(dest)) + #ifdef __cplusplus } #endif diff --git a/lib/string.c b/lib/string.c index d56f88d4a84..e297eb99df1 100644 --- a/lib/string.c +++ b/lib/string.c @@ -20,6 +20,7 @@ #include <limits.h> #include <linux/compiler.h> #include <linux/ctype.h> +#include <linux/slab.h> #include <linux/string.h> #include <linux/types.h> #include <malloc.h> @@ -802,3 +803,27 @@ void *memchr_inv(const void *start, int c, size_t bytes) return check_bytes8(start, value, bytes % 8); } #endif + +char *strreplace(char *str, char old, char new) +{ + char *s = str; + + while (*s) { + if (*s == old) + *s = new; + s++; + } + return str; +} + +char *kmemdup_nul(const char *s, size_t len, gfp_t gfp) +{ + char *buf; + + buf = kmalloc(len + 1, gfp); + if (buf) { + memcpy(buf, s, len); + buf[len] = '\0'; + } + return buf; +} -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move FMODE_32BITHASH and FMODE_64BITHASH flags from ext4_uboot.h to linux/fs.h where they belong alongside other file mode flags. 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/fs.h | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 7b90276b2bc..4b342089489 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -173,9 +173,7 @@ typedef unsigned long pgoff_t; #define PAGE_SHIFT 12 #endif -/* File mode flags */ -#define FMODE_32BITHASH 0x00000001 -#define FMODE_64BITHASH 0x00000002 +/* FMODE_32BITHASH, FMODE_64BITHASH are in linux/fs.h */ /* struct file is defined in linux/fs.h */ diff --git a/include/linux/fs.h b/include/linux/fs.h index 241711eded1..049033c0cd7 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -36,6 +36,10 @@ typedef unsigned int fmode_t; #define FMODE_CAN_ODIRECT ((__force fmode_t)(1 << 21)) #define FMODE_CAN_ATOMIC_WRITE ((__force fmode_t)(1 << 22)) +/* Directory file mode flags - use low bits for hash mode */ +#define FMODE_32BITHASH ((__force fmode_t)0x00000001) +#define FMODE_64BITHASH ((__force fmode_t)0x00000002) + /* Seek constants */ #ifndef SEEK_HOLE #define SEEK_HOLE 4 -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move the directory iteration types and helpers from ext4_uboot.h to linux/fs.h where they belong as part of the VFS interface: - struct dir_context: context for directory iteration - filldir_t: callback type for directory entry emission - dir_emit(): helper to emit a directory entry - dir_relax_shared(): lock relaxation macro (no-op in U-Boot) This makes these types available for other filesystem implementations. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 17 ++--------------- include/linux/fs.h | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 4b342089489..4cb9b23a8c7 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -198,14 +198,7 @@ struct kiocb { /* __counted_by attribute - not available in U-Boot */ #define __counted_by(x) -/* dir_context for directory iteration */ -struct dir_context; -typedef int (*filldir_t)(struct dir_context *, const char *, int, loff_t, u64, unsigned); - -struct dir_context { - filldir_t actor; - loff_t pos; -}; +/* dir_context, filldir_t are in linux/fs.h */ /* iomap types and structs are in linux/iomap.h */ @@ -1545,13 +1538,7 @@ extern struct inode *iget_locked(struct super_block *sb, unsigned long ino); #define inode_eq_iversion(i, v) ({ (void)(i); (void)(v); 1; }) #define inode_query_iversion(i) ({ (void)(i); 0ULL; }) -/* Directory context operations - call the actor callback */ -static inline bool dir_emit(struct dir_context *ctx, const char *name, int len, - u64 ino, unsigned int type) -{ - return ctx->actor(ctx, name, len, ctx->pos, ino, type) == 0; -} -#define dir_relax_shared(i) ({ (void)(i); 1; }) +/* dir_emit, dir_relax_shared are in linux/fs.h */ /* File llseek */ #define generic_file_llseek_size(f, o, w, m, e) ({ (void)(f); (void)(o); (void)(w); (void)(m); (void)(e); 0LL; }) diff --git a/include/linux/fs.h b/include/linux/fs.h index 049033c0cd7..af9cf21692b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -173,4 +173,23 @@ static inline void inode_init_once(struct inode *inode) /* S_ISDIR, etc. - already in linux/stat.h */ #include <linux/stat.h> +/* Directory context for readdir iteration */ +struct dir_context; +typedef int (*filldir_t)(struct dir_context *, const char *, int, loff_t, + u64, unsigned); + +struct dir_context { + filldir_t actor; + loff_t pos; +}; + +/* dir_emit - emit a directory entry to the context callback */ +static inline bool dir_emit(struct dir_context *ctx, const char *name, int len, + u64 ino, unsigned int type) +{ + return ctx->actor(ctx, name, len, ctx->pos, ino, type) == 0; +} + +#define dir_relax_shared(i) ({ (void)(i); 1; }) + #endif /* _LINUX_FS_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move pgoff_t (page cache offset type) from ext4_uboot.h to linux/types.h where it belongs alongside other fundamental Linux types like sector_t and blkcnt_t. 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/types.h | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 4cb9b23a8c7..08d28fd01ad 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -167,8 +167,7 @@ struct kobject { /* Forward declarations (struct inode, struct address_space) are in linux/fs.h */ -/* Page types */ -typedef unsigned long pgoff_t; +/* pgoff_t is in linux/types.h */ #ifndef PAGE_SHIFT #define PAGE_SHIFT 12 #endif diff --git a/include/linux/types.h b/include/linux/types.h index 957284d37ab..5255eecd407 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -165,6 +165,9 @@ typedef s64 ktime_t; typedef u64 sector_t; typedef u64 blkcnt_t; +/* Page cache offset type */ +typedef unsigned long pgoff_t; + #ifdef __linux__ struct ustat { __kernel_daddr_t f_tfree; -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Use the existing linux/blk_types.h header for blk_opf_t instead of defining it locally in ext4_uboot.h. This avoids duplication and uses the proper __bitwise annotation for type safety. 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 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 08d28fd01ad..68acbd489f4 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -78,10 +78,12 @@ * atomic_t, atomic64_t are now in asm-generic/atomic.h * MAX_JIFFY_OFFSET is now in linux/jiffies.h * BDEVNAME_SIZE is now in linux/blkdev.h + * blk_opf_t is now in linux/blk_types.h */ #include <asm-generic/atomic.h> #include <linux/jiffies.h> #include <linux/blkdev.h> +#include <linux/blk_types.h> /* atomic_dec_if_positive, atomic_add_unless, etc. are now in asm-generic/atomic.h */ @@ -507,8 +509,7 @@ struct folio; /* qsize_t - quota size type */ typedef long long qsize_t; -/* blk_opf_t - block operation flags */ -typedef unsigned int blk_opf_t; +/* blk_opf_t is in linux/blk_types.h */ /* bh_end_io_t and struct buffer_head are in linux/buffer_head.h */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move the DT_* directory entry type constants from ext4_uboot.h to linux/fs.h where they belong alongside struct dir_context and other directory-related definitions. This includes: DT_UNKNOWN, DT_FIFO, DT_CHR, DT_DIR, DT_BLK, DT_REG, DT_LNK, DT_SOCK and DT_WHT Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 11 +---------- include/linux/fs.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 68acbd489f4..cc0cb48fc24 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -513,16 +513,7 @@ typedef long long qsize_t; /* bh_end_io_t and struct buffer_head are in linux/buffer_head.h */ -/* Directory entry types */ -#define DT_UNKNOWN 0 -#define DT_FIFO 1 -#define DT_CHR 2 -#define DT_DIR 4 -#define DT_BLK 6 -#define DT_REG 8 -#define DT_LNK 10 -#define DT_SOCK 12 -#define DT_WHT 14 +/* DT_* directory entry types are in linux/fs.h */ /* mnt_idmap - stub */ struct mnt_idmap { diff --git a/include/linux/fs.h b/include/linux/fs.h index af9cf21692b..7963e931fad 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -173,6 +173,17 @@ static inline void inode_init_once(struct inode *inode) /* S_ISDIR, etc. - already in linux/stat.h */ #include <linux/stat.h> +/* Directory entry types */ +#define DT_UNKNOWN 0 +#define DT_FIFO 1 +#define DT_CHR 2 +#define DT_DIR 4 +#define DT_BLK 6 +#define DT_REG 8 +#define DT_LNK 10 +#define DT_SOCK 12 +#define DT_WHT 14 + /* Directory context for readdir iteration */ struct dir_context; typedef int (*filldir_t)(struct dir_context *, const char *, int, loff_t, -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move the inode attribute flags (S_SYNC, S_NOATIME, S_APPEND, S_IMMUTABLE, S_DAX, S_DIRSYNC, S_ENCRYPTED, S_CASEFOLD, S_VERITY) and the permission constant S_IRWXUGO from ext4_uboot.h to linux/fs.h where they belong alongside other filesystem 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 | 15 ++------------- include/linux/fs.h | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index cc0cb48fc24..2ed5a5d4984 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -589,19 +589,8 @@ static inline int bdev_read_only(struct block_device *bdev) #define I_FREEING (1 << 1) #define I_DIRTY_DATASYNC (1 << 2) -/* Inode flags for i_flags */ -#define S_SYNC 1 -#define S_NOATIME 2 -#define S_APPEND 4 -#define S_IMMUTABLE 8 -#define S_DAX 16 -#define S_DIRSYNC 32 -#define S_ENCRYPTED 64 -#define S_CASEFOLD 128 -#define S_VERITY 256 - -/* Permission mode constants */ -#define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) +/* S_SYNC, S_NOATIME, etc. inode flags are in linux/fs.h */ +/* S_IRWXUGO is in linux/fs.h */ /* Whiteout mode for overlayfs */ #define WHITEOUT_DEV 0 diff --git a/include/linux/fs.h b/include/linux/fs.h index 7963e931fad..2b05c39e88a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -173,6 +173,20 @@ static inline void inode_init_once(struct inode *inode) /* S_ISDIR, etc. - already in linux/stat.h */ #include <linux/stat.h> +/* Inode flags for i_flags field */ +#define S_SYNC 1 /* Synchronous writes */ +#define S_NOATIME 2 /* No access time updates */ +#define S_APPEND 4 /* Append only */ +#define S_IMMUTABLE 8 /* Immutable file */ +#define S_DAX 16 /* Direct access */ +#define S_DIRSYNC 32 /* Directory sync */ +#define S_ENCRYPTED 64 /* Encrypted */ +#define S_CASEFOLD 128 /* Case-folded */ +#define S_VERITY 256 /* Verity enabled */ + +/* Permission mode constants */ +#define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) + /* Directory entry types */ #define DT_UNKNOWN 0 #define DT_FIFO 1 -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move the S_IRUGO permission constant to linux/fs.h alongside S_IRWXUGO. 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.h | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 2ed5a5d4984..5f3fcaae30b 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -2524,10 +2524,7 @@ struct proc_ops { ssize_t seq_read(struct file *f, char *b, size_t s, loff_t *p); loff_t seq_lseek(struct file *f, loff_t o, int w); -/* S_IRUGO file mode if not defined */ -#ifndef S_IRUGO -#define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH) -#endif +/* S_IRUGO is in linux/fs.h */ /* procfs stubs */ #define proc_mkdir(name, parent) ({ (void)(name); (void)(parent); (struct proc_dir_entry *)NULL; }) diff --git a/include/linux/fs.h b/include/linux/fs.h index 2b05c39e88a..25966447cf2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -186,6 +186,7 @@ static inline void inode_init_once(struct inode *inode) /* Permission mode constants */ #define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) +#define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH) /* Directory entry types */ #define DT_UNKNOWN 0 -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move file operation flags from ext4_uboot.h to linux/fs.h: - FALLOC_FL_*: fallocate operation flags (KEEP_SIZE, PUNCH_HOLE, COLLAPSE_RANGE, ZERO_RANGE, INSERT_RANGE, WRITE_ZEROES, ALLOCATE_RANGE, MODE_MASK) - RENAME_*: rename operation flags (NOREPLACE, EXCHANGE, WHITEOUT) Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 15 ++------------- include/linux/fs.h | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 5f3fcaae30b..b7b42392033 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -154,15 +154,7 @@ struct kobject { #define FIEMAP_EXTENT_UNWRITTEN 0x00000800 #define EXT4_FIEMAP_EXTENT_HOLE 0x08000000 -/* FALLOC flags */ -#define FALLOC_FL_KEEP_SIZE 0x01 -#define FALLOC_FL_PUNCH_HOLE 0x02 -#define FALLOC_FL_COLLAPSE_RANGE 0x08 -#define FALLOC_FL_ZERO_RANGE 0x10 -#define FALLOC_FL_INSERT_RANGE 0x20 -#define FALLOC_FL_WRITE_ZEROES 0x40 -#define FALLOC_FL_ALLOCATE_RANGE 0x80 -#define FALLOC_FL_MODE_MASK 0xff +/* FALLOC_FL_* flags are in linux/fs.h */ /* File flags */ #define O_SYNC 0 @@ -596,10 +588,7 @@ static inline int bdev_read_only(struct block_device *bdev) #define WHITEOUT_DEV 0 #define WHITEOUT_MODE 0 -/* Rename flags */ -#define RENAME_NOREPLACE (1 << 0) -#define RENAME_EXCHANGE (1 << 1) -#define RENAME_WHITEOUT (1 << 2) +/* RENAME_* flags are in linux/fs.h */ /* Inode dirty state flags */ #define I_DIRTY_TIME (1 << 3) diff --git a/include/linux/fs.h b/include/linux/fs.h index 25966447cf2..3156a261724 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -188,6 +188,21 @@ static inline void inode_init_once(struct inode *inode) #define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) #define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH) +/* Rename flags */ +#define RENAME_NOREPLACE (1 << 0) +#define RENAME_EXCHANGE (1 << 1) +#define RENAME_WHITEOUT (1 << 2) + +/* fallocate() flags */ +#define FALLOC_FL_KEEP_SIZE 0x01 +#define FALLOC_FL_PUNCH_HOLE 0x02 +#define FALLOC_FL_COLLAPSE_RANGE 0x08 +#define FALLOC_FL_ZERO_RANGE 0x10 +#define FALLOC_FL_INSERT_RANGE 0x20 +#define FALLOC_FL_WRITE_ZEROES 0x40 +#define FALLOC_FL_ALLOCATE_RANGE 0x80 +#define FALLOC_FL_MODE_MASK 0xff + /* Directory entry types */ #define DT_UNKNOWN 0 #define DT_FIFO 1 -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move the ATTR_* flags (used to indicate which fields of struct iattr are valid) from ext4_uboot.h to linux/fs.h alongside the struct iattr definition. This includes: ATTR_MODE, ATTR_UID, ATTR_GID, ATTR_SIZE, ATTR_ATIME, ATTR_MTIME, ATTR_CTIME, ATTR_ATIME_SET, ATTR_MTIME_SET, ATTR_FORCE, ATTR_KILL_SUID, ATTR_KILL_SGID, ATTR_TIMES_SET. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 15 +-------------- include/linux/fs.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index b7b42392033..4baf9410012 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -596,20 +596,7 @@ static inline int bdev_read_only(struct block_device *bdev) /* Superblock flags */ #define SB_LAZYTIME (1 << 25) -/* iattr valid flags */ -#define ATTR_MODE (1 << 0) -#define ATTR_UID (1 << 1) -#define ATTR_GID (1 << 2) -#define ATTR_SIZE (1 << 3) -#define ATTR_ATIME (1 << 4) -#define ATTR_MTIME (1 << 5) -#define ATTR_CTIME (1 << 6) -#define ATTR_ATIME_SET (1 << 7) -#define ATTR_MTIME_SET (1 << 8) -#define ATTR_FORCE (1 << 9) -#define ATTR_KILL_SUID (1 << 11) -#define ATTR_KILL_SGID (1 << 12) -#define ATTR_TIMES_SET ((1 << 7) | (1 << 8)) +/* ATTR_* iattr valid flags are in linux/fs.h */ /* STATX flags and attributes */ #define STATX_BTIME 0x00000800U diff --git a/include/linux/fs.h b/include/linux/fs.h index 3156a261724..ba4463cfc79 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -160,6 +160,21 @@ struct iattr { loff_t ia_size; }; +/* iattr valid flags - specify which fields of iattr are valid */ +#define ATTR_MODE (1 << 0) +#define ATTR_UID (1 << 1) +#define ATTR_GID (1 << 2) +#define ATTR_SIZE (1 << 3) +#define ATTR_ATIME (1 << 4) +#define ATTR_MTIME (1 << 5) +#define ATTR_CTIME (1 << 6) +#define ATTR_ATIME_SET (1 << 7) +#define ATTR_MTIME_SET (1 << 8) +#define ATTR_FORCE (1 << 9) +#define ATTR_KILL_SUID (1 << 11) +#define ATTR_KILL_SGID (1 << 12) +#define ATTR_TIMES_SET (ATTR_ATIME_SET | ATTR_MTIME_SET) + /* writeback_control - defined in linux/compat.h */ /* fsnotify - stub */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move common superblock flags from ext4_uboot.h to linux/fs.h: - SB_RDONLY: read-only mount flag - SB_POSIXACL: POSIX ACL support flag - SB_LAZYTIME: lazy time updates flag - SB_I_VERSION: inode version update flag - SB_INLINECRYPT: inline encryption flag - SB_ACTIVE: superblock active flag - SB_SILENT: silent mount errors flag - SB_FREEZE_*: filesystem freeze level constants Keep SB_I_CGROUPWB and SB_I_ALLOW_HSM as U-Boot stubs since these are not supported. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 26 +++++++------------------- include/linux/fs.h | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 4baf9410012..87cc561538e 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -396,11 +396,7 @@ void iput(struct inode *inode); /* _RET_IP_ - return instruction pointer */ #define _RET_IP_ ((unsigned long)__builtin_return_address(0)) -/* SB_FREEZE constants */ -#define SB_FREEZE_WRITE 1 -#define SB_FREEZE_PAGEFAULT 2 -#define SB_FREEZE_FS 3 -#define SB_FREEZE_COMPLETE 4 +/* SB_FREEZE_* constants are in linux/fs.h */ /* sb_writers stub */ struct sb_writers { @@ -525,9 +521,7 @@ struct fstrim_range { /* block_device is defined in linux/fs.h */ -/* Superblock flags */ -#define SB_RDONLY (1 << 0) -#define SB_I_VERSION (1 << 26) /* Update inode version */ +/* SB_RDONLY, SB_I_VERSION, etc. superblock flags are in linux/fs.h */ /* UUID type */ typedef struct { @@ -593,9 +587,7 @@ static inline int bdev_read_only(struct block_device *bdev) /* Inode dirty state flags */ #define I_DIRTY_TIME (1 << 3) -/* Superblock flags */ -#define SB_LAZYTIME (1 << 25) - +/* SB_LAZYTIME is in linux/fs.h */ /* ATTR_* iattr valid flags are in linux/fs.h */ /* STATX flags and attributes */ @@ -1683,8 +1675,7 @@ static inline void end_buffer_read_sync(struct buffer_head *bh, int uptodate) } #define REQ_OP_READ 0 -/* Superblock flags */ -#define SB_ACTIVE (1 << 30) +/* SB_ACTIVE is in linux/fs.h */ /* Part stat - not used in U-Boot. Note: sectors[X] is passed as second arg */ #define STAT_WRITE 0 @@ -1893,12 +1884,9 @@ struct fs_parse_result { /* I/O priority classes */ #define IOPRIO_CLASS_BE 2 -/* Superblock flags */ -#define SB_INLINECRYPT (1 << 27) -#define SB_SILENT (1 << 15) -#define SB_POSIXACL (1 << 16) -#define SB_I_CGROUPWB 0 -#define SB_I_ALLOW_HSM 0 +/* SB_INLINECRYPT, SB_SILENT, SB_POSIXACL are in linux/fs.h */ +#define SB_I_CGROUPWB 0 /* Not supported in U-Boot */ +#define SB_I_ALLOW_HSM 0 /* Not supported in U-Boot */ /* Block open flags */ #define BLK_OPEN_READ (1 << 0) diff --git a/include/linux/fs.h b/include/linux/fs.h index ba4463cfc79..7393fd0d316 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -208,6 +208,21 @@ static inline void inode_init_once(struct inode *inode) #define RENAME_EXCHANGE (1 << 1) #define RENAME_WHITEOUT (1 << 2) +/* Superblock flags */ +#define SB_RDONLY (1 << 0) /* Read-only mount */ +#define SB_POSIXACL (1 << 16) /* POSIX ACL support */ +#define SB_LAZYTIME (1 << 25) /* Lazy time updates */ +#define SB_I_VERSION (1 << 26) /* Update inode version */ +#define SB_INLINECRYPT (1 << 27) /* Inline encryption */ +#define SB_ACTIVE (1 << 30) /* Superblock is active */ +#define SB_SILENT (1 << 15) /* Silent mount errors */ + +/* Superblock freeze levels */ +#define SB_FREEZE_WRITE 1 +#define SB_FREEZE_PAGEFAULT 2 +#define SB_FREEZE_FS 3 +#define SB_FREEZE_COMPLETE 4 + /* fallocate() flags */ #define FALLOC_FL_KEEP_SIZE 0x01 #define FALLOC_FL_PUNCH_HOLE 0x02 -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move buffer and folio migration stubs from ext4_uboot.h to linux/buffer_head.h where they belong: - buffer_migrate_folio(): folio migration stub (returns -EOPNOTSUPP) - buffer_migrate_folio_norefs(): no-refs folio migration stub - noop_dirty_folio(): no-op dirty folio handler U-Boot doesn't support memory migration, so these remain as stubs. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 22 +--------------------- include/linux/buffer_head.h | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 87cc561538e..91e0ce95467 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1142,27 +1142,7 @@ struct readahead_control { #define readahead_length(rac) ({ (void)(rac); 0UL; }) /* address_space_operations is in linux/fs.h */ - -/* Stub for buffer_migrate_folio */ -static inline int buffer_migrate_folio(struct address_space *mapping, - struct folio *dst, struct folio *src, int mode) -{ - return -EOPNOTSUPP; -} - -/* Stub for buffer_migrate_folio_norefs */ -static inline int buffer_migrate_folio_norefs(struct address_space *mapping, - struct folio *dst, struct folio *src, int mode) -{ - return -EOPNOTSUPP; -} - -/* Stub for noop_dirty_folio */ -static inline bool noop_dirty_folio(struct address_space *mapping, - struct folio *folio) -{ - return false; -} +/* buffer_migrate_folio, buffer_migrate_folio_norefs, noop_dirty_folio are in linux/buffer_head.h */ /* Stub implementations for address_space_operations callbacks */ static inline bool block_is_partially_uptodate(struct folio *folio, diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 94bd2bab96a..a160b7d1a67 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -12,6 +12,7 @@ #include <linux/types.h> #include <linux/list.h> #include <linux/spinlock.h> +#include <linux/errno.h> #include <asm-generic/atomic.h> enum bh_state_bits { @@ -186,4 +187,30 @@ void __brelse(struct buffer_head *bh); #define unlock_buffer(bh) clear_buffer_locked(bh) #define test_clear_buffer_dirty(bh) ({ (void)(bh); 0; }) +/* + * Folio migration stubs - U-Boot doesn't support memory migration + */ +static inline int buffer_migrate_folio(struct address_space *mapping, + struct folio *dst, struct folio *src, + int mode) +{ + return -EOPNOTSUPP; +} + +static inline int buffer_migrate_folio_norefs(struct address_space *mapping, + struct folio *dst, + struct folio *src, int mode) +{ + return -EOPNOTSUPP; +} + +/* + * noop_dirty_folio - no-op dirty folio handler + */ +static inline bool noop_dirty_folio(struct address_space *mapping, + struct folio *folio) +{ + return false; +} + #endif /* _LINUX_BUFFER_HEAD_H */ -- 2.43.0
participants (1)
-
Simon Glass