[PATCH 00/23] Reduce ext4_uboot.h by moving definitions to linux headers
From: Simon Glass <simon.glass@canonical.com> This series continues the work to reduce fs/ext4l/ext4_uboot.h by moving definitions to their proper locations in include/linux/ The ext4l compatibility header started at 2584 lines. Previous work reduced it to 1816 lines. This series further reduces it to 1677 lines by moving various definitions to appropriate headers: - Block I/O flags (REQ_OP_*, REQ_SYNC, etc.) to linux/blk_types.h - Block device flags (BLK_OPEN_*) to linux/blkdev.h - Memory allocation flags (__GFP_*, SLAB_*) to linux/slab.h - Scheduler stubs to linux/sched.h - Process flags (PF_MEMALLOC*) to linux/sched.h - System state definitions to linux/kernel.h - Quota format constants to linux/quotaops.h - STATX flags and struct kstat to linux/stat.h - Timer definitions to new linux/hrtimer.h - Inode mutex classes to linux/fs.h - Various other small moves This improves code organisation by placing definitions in headers matching Linux kernel structure, making the codebase easier to maintain and understand. Simon Glass (23): linux: random: Add get_random_u32_below and prandom_u32_max linux: path: Add path_put and d_path stubs linux: Add minmax.h with in_range helper linux: Add writeback.h with writeback operation stubs linux: Add iversion.h with inode version stubs linux: Add namei.h with pathname lookup flags linux: Add fsverity.h with fs-verity stubs linux: quotaops: Add more quota operation stubs linux: Add ioprio.h with I/O priority definitions ext4l: Move rwsem_is_locked to linux/rwsem.h ext4l: Add linux/hrtimer.h with timer stubs ext4l: Move STATX_* and struct kstat to linux/stat.h ext4l: Move REQ_OP and SLAB flags to proper headers ext4l: Move REQ_IDLE and REQ_PREFLUSH to blk_types.h ext4l: Move QFMT_VFS_* constants to quotaops.h ext4l: Move REQ_META, REQ_PRIO, REQ_RAHEAD to blk_types.h ext4l: Move __GFP_MOVABLE and __GFP_FS to slab.h ext4l: Move system_state definitions to linux/kernel.h ext4l: Move BLK_OPEN_* flags to linux/blkdev.h ext4l: Move scheduler stubs to linux/sched.h ext4l: Move PF_MEMALLOC flags to linux/sched.h ext4l: Move SECTOR_SHIFT to linux/blk_types.h ext4l: Move I_MUTEX_* constants to linux/fs.h fs/ext4l/ext4_uboot.h | 245 +++++++++----------------------------- fs/ext4l/stub.c | 44 +------ include/linux/blk_types.h | 22 ++++ include/linux/blkdev.h | 7 ++ include/linux/fs.h | 17 ++- include/linux/fsverity.h | 97 +++++++++++++++ include/linux/hrtimer.h | 39 ++++++ include/linux/ioprio.h | 64 ++++++++++ include/linux/iversion.h | 96 +++++++++++++++ include/linux/kernel.h | 17 +++ include/linux/minmax.h | 52 ++++++++ include/linux/namei.h | 26 ++++ include/linux/path.h | 31 +++++ include/linux/quotaops.h | 61 ++++++++-- include/linux/random.h | 25 +++- include/linux/rwsem.h | 1 + include/linux/sched.h | 11 ++ include/linux/slab.h | 10 ++ include/linux/stat.h | 48 ++++++++ include/linux/writeback.h | 49 ++++++++ 20 files changed, 713 insertions(+), 249 deletions(-) create mode 100644 include/linux/fsverity.h create mode 100644 include/linux/hrtimer.h create mode 100644 include/linux/ioprio.h create mode 100644 include/linux/iversion.h create mode 100644 include/linux/minmax.h create mode 100644 include/linux/namei.h create mode 100644 include/linux/writeback.h -- 2.43.0 base-commit: 91506abfe7c9306ae992fdb0d43dce894ca2f7f0 branch: extt
From: Simon Glass <simon.glass@canonical.com> Add get_random_u32_below() and prandom_u32_max() stub macros to linux/random.h for filesystem code that uses random number generation. Update ext4_uboot.h to use linux/random.h instead of duplicating these 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 | 8 +++----- include/linux/random.h | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 3c6b3ca5507..4fb8f9111b0 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -252,8 +252,8 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); /* d_inode is now in linux/dcache.h */ -/* Random number functions */ -#define get_random_u32_below(max) (0) +/* Random number functions - use linux/random.h */ +#include <linux/random.h> /* Buffer cache operations */ #define sb_find_get_block(sb, block) ((struct buffer_head *)NULL) @@ -1267,9 +1267,7 @@ int ext4_fill_super(struct super_block *sb, struct fs_context *fc); int ext4_commit_super(struct super_block *sb); void ext4_unregister_li_request(struct super_block *sb); -/* prandom */ -#define get_random_u32() 0 -#define prandom_u32_max(max) 0 +/* prandom - get_random_u32, prandom_u32_max are in linux/random.h */ /* ctype */ #include <linux/ctype.h> diff --git a/include/linux/random.h b/include/linux/random.h index cb09c6c6b05..1a9de842a4c 100644 --- a/include/linux/random.h +++ b/include/linux/random.h @@ -1,6 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * Stub definitions for random number generation. + * Random number generation definitions for U-Boot + * + * Based on Linux random.h - random number generation. + * U-Boot stub - returns constant values. */ #ifndef _LINUX_RANDOM_H #define _LINUX_RANDOM_H @@ -12,4 +15,24 @@ #define get_random_u32() 0 #define get_random_u64() 0ULL +/** + * get_random_u32_below() - get random number below a ceiling + * @ceil: upper bound (exclusive) + * + * U-Boot stub - always returns 0. + * + * Return: random value in [0, ceil) + */ +#define get_random_u32_below(ceil) (0) + +/** + * prandom_u32_max() - get random number up to a maximum + * @max: upper bound (inclusive) + * + * U-Boot stub - always returns 0. + * + * Return: random value in [0, max] + */ +#define prandom_u32_max(max) (0) + #endif /* _LINUX_RANDOM_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Add path_put() macro and d_path() stub function to linux/path.h for filesystem code that uses path operations. Update linux/fs.h to include linux/path.h instead of duplicating the struct path definition. Update ext4_uboot.h to use linux/path.h instead of duplicating these 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 | 12 +++--------- include/linux/fs.h | 7 ++----- include/linux/path.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 4fb8f9111b0..7ad24732cf4 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -928,13 +928,8 @@ void mapping_clear_folio_cache(struct address_space *mapping); #define sb_start_pagefault(sb) do { (void)(sb); } while (0) #define sb_end_pagefault(sb) do { (void)(sb); } while (0) -/* d_path - get pathname - stub returns empty path */ -static inline char *d_path(const struct path *path, char *buf, int buflen) -{ - if (buflen > 0) - buf[0] = '\0'; - return buf; -} +/* d_path, path_put - use linux/path.h */ +#include <linux/path.h> /* fscrypt_file_open is in ext4_fscrypt.h */ #define fsverity_file_open(i, f) ({ (void)(i); (void)(f); 0; }) @@ -1379,8 +1374,7 @@ int inode_generic_drop(struct inode *inode); /* NFS export helpers are now in linux/exportfs.h */ -/* Path operations */ -#define path_put(p) do { } while (0) +/* Path operations - path_put, d_path are in linux/path.h */ /* I/O priority - declaration for stub.c */ int IOPRIO_PRIO_VALUE(int class, int data); diff --git a/include/linux/fs.h b/include/linux/fs.h index 7393fd0d316..28b57b59484 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -51,11 +51,8 @@ struct vfsmount { struct dentry *mnt_root; }; -/* path - pathname components */ -struct path { - struct vfsmount *mnt; - struct dentry *dentry; -}; +/* path - use linux/path.h */ +#include <linux/path.h> /* Buffer operations are in buffer_head.h */ diff --git a/include/linux/path.h b/include/linux/path.h index 27cc071026a..3ebcb16e3c7 100644 --- a/include/linux/path.h +++ b/include/linux/path.h @@ -1,4 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Path definitions for U-Boot + * + * Based on Linux path.h - filesystem path operations. + */ #ifndef _LINUX_PATH_H #define _LINUX_PATH_H @@ -10,4 +15,30 @@ struct path { struct dentry *dentry; }; +/** + * path_put() - release a path reference + * @path: path to release + * + * U-Boot stub - no reference counting. + */ +#define path_put(path) do { (void)(path); } while (0) + +/** + * d_path() - get pathname from path structure + * @path: path to convert + * @buf: buffer for pathname + * @buflen: size of buffer + * + * U-Boot stub - returns empty string. + * + * Return: pointer to pathname in buffer + */ +static inline char *d_path(const struct path *path, char *buf, int buflen) +{ + (void)path; + if (buflen > 0) + buf[0] = '\0'; + return buf; +} + #endif /* _LINUX_PATH_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create linux/minmax.h with in_range(), in_range64(), and in_range32() helper functions for range checking operations. Update ext4_uboot.h to use linux/minmax.h instead of duplicating the in_range definition. 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/minmax.h | 52 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 include/linux/minmax.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 7ad24732cf4..bfeb31f465c 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -815,12 +815,8 @@ static inline unsigned long memweight(const void *ptr, size_t bytes) #define sb_no_casefold_compat_fallback(sb) ({ (void)(sb); 1; }) #define generic_ci_validate_strict_name(d, n) ({ (void)(d); (void)(n); 1; }) -/* in_range helper - check if value is in range [start, start+len) */ -static inline int in_range(unsigned long val, unsigned long start, - unsigned long len) -{ - return val >= start && val < start + len; -} +/* in_range - use linux/minmax.h */ +#include <linux/minmax.h> /* Quota stub */ #define dquot_reclaim_block(i, n) do { } while (0) diff --git a/include/linux/minmax.h b/include/linux/minmax.h new file mode 100644 index 00000000000..52ce477459d --- /dev/null +++ b/include/linux/minmax.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Min/max and related utilities for U-Boot + * + * Based on Linux minmax.h - min, max, clamp, and range helpers. + */ +#ifndef _LINUX_MINMAX_H +#define _LINUX_MINMAX_H + +#include <linux/types.h> + +/** + * in_range - check if value is within a range + * @val: value to test + * @start: start of range (inclusive) + * @len: length of range + * + * Return: true if @val is in [@start, @start + @len), false otherwise + */ +static inline bool in_range(unsigned long val, unsigned long start, + unsigned long len) +{ + return val >= start && val < start + len; +} + +/** + * in_range64 - check if 64-bit value is within a range + * @val: value to test + * @start: start of range (inclusive) + * @len: length of range + * + * Return: true if @val is in [@start, @start + @len), false otherwise + */ +static inline bool in_range64(u64 val, u64 start, u64 len) +{ + return (val - start) < len; +} + +/** + * in_range32 - check if 32-bit value is within a range + * @val: value to test + * @start: start of range (inclusive) + * @len: length of range + * + * Return: true if @val is in [@start, @start + @len), false otherwise + */ +static inline bool in_range32(u32 val, u32 start, u32 len) +{ + return (val - start) < len; +} + +#endif /* _LINUX_MINMAX_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create linux/writeback.h with wbc_to_tag() function, WB_REASON_* constants, and try_to_writeback_inodes_sb() stub for filesystem writeback control. Update ext4_uboot.h to use linux/writeback.h instead of duplicating these 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 | 14 +++-------- include/linux/writeback.h | 49 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 11 deletions(-) create mode 100644 include/linux/writeback.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index bfeb31f465c..873f02cf508 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -863,19 +863,11 @@ static inline unsigned long memweight(const void *ptr, size_t bytes) #include <linux/pagemap.h> #include <linux/xarray.h> -/* wbc_to_tag - convert writeback control to pagecache tag */ -static inline xa_mark_t wbc_to_tag(struct writeback_control *wbc) -{ - if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) - return PAGECACHE_TAG_TOWRITE; - return PAGECACHE_TAG_DIRTY; -} +/* wbc_to_tag, WB_REASON_* - use linux/writeback.h */ +#include <linux/writeback.h> /* blk_plug is now in linux/blkdev.h */ -/* Writeback reasons */ -#define WB_REASON_FS_FREE_SPACE 0 - /* address_space_operations is in linux/fs.h */ /* buffer_migrate_folio, buffer_migrate_folio_norefs, noop_dirty_folio are in linux/buffer_head.h */ /* readahead_control, FGP_*, kmap/kunmap, folio stubs are in linux/pagemap.h */ @@ -952,7 +944,7 @@ void mapping_clear_folio_cache(struct address_space *mapping); /* percpu_counter_sub is in linux/percpu_counter.h */ /* Filemap operations are in linux/pagemap.h */ -#define try_to_writeback_inodes_sb(sb, r) do { } while (0) +/* try_to_writeback_inodes_sb is in linux/writeback.h */ /* Buffer operations - additional */ #define getblk_unmovable(bdev, block, size) sb_getblk(bdev->bd_super, block) diff --git a/include/linux/writeback.h b/include/linux/writeback.h new file mode 100644 index 00000000000..e408e3ddebb --- /dev/null +++ b/include/linux/writeback.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Writeback definitions for U-Boot + * + * Based on Linux writeback.h - writeback control and operations. + * U-Boot stub - writeback operations are no-ops. + */ +#ifndef WRITEBACK_H +#define WRITEBACK_H + +#include <linux/pagemap.h> +#include <linux/xarray.h> + +/* Forward declarations */ +struct super_block; +struct writeback_control; + +/* Writeback reasons */ +#define WB_REASON_FS_FREE_SPACE 0 +#define WB_REASON_SYNC 1 +#define WB_REASON_PERIODIC 2 +#define WB_REASON_LAPTOP_TIMER 3 +#define WB_REASON_VMSCAN 4 +#define WB_REASON_FORKER_THREAD 5 + +/** + * wbc_to_tag() - convert writeback control to pagecache tag + * @wbc: writeback control structure + * + * Return: PAGECACHE_TAG_TOWRITE for sync writes, PAGECACHE_TAG_DIRTY otherwise + */ +static inline xa_mark_t wbc_to_tag(struct writeback_control *wbc) +{ + if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) + return PAGECACHE_TAG_TOWRITE; + return PAGECACHE_TAG_DIRTY; +} + +/** + * try_to_writeback_inodes_sb() - try to start writeback on superblock + * @sb: superblock to writeback + * @reason: reason for writeback + * + * U-Boot stub - no-op since writeback is synchronous. + */ +#define try_to_writeback_inodes_sb(sb, reason) \ + do { (void)(sb); (void)(reason); } while (0) + +#endif /* WRITEBACK_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create linux/iversion.h with inode version operation stubs including inode_peek_iversion(), inode_set_iversion(), inode_inc_iversion(), inode_eq_iversion(), and inode_query_iversion(). U-Boot does not track inode versions, so these are all no-ops or return constant values. Update ext4_uboot.h to use linux/iversion.h and remove the inode_set_iversion() implementation from stub.c since it is now a macro. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 14 ++---- fs/ext4l/stub.c | 4 +- include/linux/iversion.h | 96 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 13 deletions(-) create mode 100644 include/linux/iversion.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 873f02cf508..35d1c8125df 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -982,13 +982,9 @@ static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode, return ts; } -/* Inode version operations */ -#define inode_peek_iversion_raw(i) (0ULL) -#define inode_peek_iversion(i) (0ULL) +/* Inode version operations - use linux/iversion.h */ +#include <linux/iversion.h> #define inode_set_flags(i, f, m) do { } while (0) -#define inode_set_iversion_raw(i, v) do { } while (0) -#define inode_set_iversion_queried(i, v) do { } while (0) -#define inode_inc_iversion(i) do { } while (0) /* Inode credential helpers */ static inline unsigned int i_uid_read(const struct inode *inode) @@ -1062,9 +1058,7 @@ extern struct inode *iget_locked(struct super_block *sb, unsigned long ino); /* Readahead operations are in linux/pagemap.h */ -/* Inode version operations */ -#define inode_eq_iversion(i, v) ({ (void)(i); (void)(v); 1; }) -#define inode_query_iversion(i) ({ (void)(i); 0ULL; }) +/* Inode version operations are in linux/iversion.h */ /* dir_emit, dir_relax_shared are in linux/fs.h */ @@ -1344,7 +1338,7 @@ void fs_put_dax(void *dax, void *holder); /* Inode allocation - declaration for stub.c */ void *alloc_inode_sb(struct super_block *sb, struct kmem_cache *cache, gfp_t gfp); -void inode_set_iversion(struct inode *inode, u64 version); +/* inode_set_iversion is in linux/iversion.h */ int inode_generic_drop(struct inode *inode); /* rwlock_init is a macro in linux/spinlock.h */ diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c index c14132815cd..e223ec21936 100644 --- a/fs/ext4l/stub.c +++ b/fs/ext4l/stub.c @@ -346,9 +346,7 @@ void *alloc_inode_sb(struct super_block *sb, struct kmem_cache *cache, return NULL; } -void inode_set_iversion(struct inode *inode, u64 version) -{ -} +/* inode_set_iversion is now a macro in linux/iversion.h */ /* rwlock_init is now a macro in linux/spinlock.h */ diff --git a/include/linux/iversion.h b/include/linux/iversion.h new file mode 100644 index 00000000000..be0ccc64c6d --- /dev/null +++ b/include/linux/iversion.h @@ -0,0 +1,96 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Inode version definitions for U-Boot + * + * Based on Linux iversion.h - inode version management. + * U-Boot stub - version tracking not supported. + */ +#ifndef _LINUX_IVERSION_H +#define _LINUX_IVERSION_H + +#include <linux/types.h> + +/* Forward declarations */ +struct inode; + +/** + * inode_peek_iversion_raw() - read inode version without side effects + * @inode: inode to read + * + * U-Boot stub - always returns 0. + * + * Return: inode version + */ +#define inode_peek_iversion_raw(inode) (0ULL) + +/** + * inode_peek_iversion() - read inode version + * @inode: inode to read + * + * U-Boot stub - always returns 0. + * + * Return: inode version + */ +#define inode_peek_iversion(inode) (0ULL) + +/** + * inode_set_iversion_raw() - set inode version directly + * @inode: inode to modify + * @version: version to set + * + * U-Boot stub - no-op. + */ +#define inode_set_iversion_raw(inode, version) \ + do { (void)(inode); (void)(version); } while (0) + +/** + * inode_set_iversion() - set inode version + * @inode: inode to modify + * @version: version to set + * + * U-Boot stub - no-op. + */ +#define inode_set_iversion(inode, version) \ + do { (void)(inode); (void)(version); } while (0) + +/** + * inode_set_iversion_queried() - set inode version as queried + * @inode: inode to modify + * @version: version to set + * + * U-Boot stub - no-op. + */ +#define inode_set_iversion_queried(inode, version) \ + do { (void)(inode); (void)(version); } while (0) + +/** + * inode_inc_iversion() - increment inode version + * @inode: inode to modify + * + * U-Boot stub - no-op. + */ +#define inode_inc_iversion(inode) do { (void)(inode); } while (0) + +/** + * inode_eq_iversion() - check if inode version matches + * @inode: inode to check + * @version: version to compare + * + * U-Boot stub - always returns true. + * + * Return: true if versions match + */ +#define inode_eq_iversion(inode, version) \ + ({ (void)(inode); (void)(version); true; }) + +/** + * inode_query_iversion() - query inode version + * @inode: inode to query + * + * U-Boot stub - always returns 0. + * + * Return: inode version + */ +#define inode_query_iversion(inode) ({ (void)(inode); 0ULL; }) + +#endif /* _LINUX_IVERSION_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create linux/namei.h with LOOKUP_* flags for pathname resolution operations used by filesystem code. Update ext4_uboot.h to use linux/namei.h instead of duplicating the LOOKUP_FOLLOW definition. 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/namei.h | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 include/linux/namei.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 35d1c8125df..0b1778ad0a6 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1254,8 +1254,8 @@ void ext4_unregister_li_request(struct super_block *sb); /* Timer and timing stubs are in linux/jiffies.h */ -/* Path lookup flags */ -#define LOOKUP_FOLLOW 0x0001 +/* Path lookup flags - use linux/namei.h */ +#include <linux/namei.h> /* I/O priority classes */ #define IOPRIO_CLASS_BE 2 diff --git a/include/linux/namei.h b/include/linux/namei.h new file mode 100644 index 00000000000..7b66fb242d6 --- /dev/null +++ b/include/linux/namei.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Pathname lookup definitions for U-Boot + * + * Based on Linux namei.h - pathname resolution flags. + */ +#ifndef _LINUX_NAMEI_H +#define _LINUX_NAMEI_H + +/* Pathname lookup flags */ +#define LOOKUP_FOLLOW 0x0001 /* Follow links at end */ +#define LOOKUP_DIRECTORY 0x0002 /* Require a directory */ +#define LOOKUP_AUTOMOUNT 0x0004 /* Force terminal automount */ +#define LOOKUP_EMPTY 0x0008 /* Accept empty path */ +#define LOOKUP_DOWN 0x0020 /* Follow mounts at start */ +#define LOOKUP_MOUNTPOINT 0x0040 /* Follow mounts at end */ +#define LOOKUP_REVAL 0x0080 /* Revalidate cache */ +#define LOOKUP_RCU 0x0100 /* RCU mode */ +#define LOOKUP_CACHED 0x0200 /* Cached lookup only */ +#define LOOKUP_PARENT 0x0400 /* Looking up parent */ +#define LOOKUP_OPEN 0x10000 /* Opening file */ +#define LOOKUP_CREATE 0x20000 /* Creating file */ +#define LOOKUP_EXCL 0x40000 /* Exclusive create */ +#define LOOKUP_RENAME_TARGET 0x80000 /* Rename target */ + +#endif /* _LINUX_NAMEI_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create linux/fsverity.h with fs-verity operation stubs including IS_VERITY(), fsverity_file_open(), fsverity_prepare_setattr(), fsverity_active(), fsverity_cleanup_inode(), fsverity_verify_bio(), fsverity_enqueue_verify_work(), and fsverity_verify_folio(). U-Boot does not support fs-verity, so these are all no-ops or return constant values indicating no verification. Update ext4_uboot.h to use linux/fsverity.h instead of duplicating these 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 | 16 +++---- include/linux/fsverity.h | 97 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 11 deletions(-) create mode 100644 include/linux/fsverity.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 0b1778ad0a6..dc8c9a97877 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -920,7 +920,8 @@ void mapping_clear_folio_cache(struct address_space *mapping); #include <linux/path.h> /* fscrypt_file_open is in ext4_fscrypt.h */ -#define fsverity_file_open(i, f) ({ (void)(i); (void)(f); 0; }) +/* fsverity_file_open is in linux/fsverity.h */ +#include <linux/fsverity.h> /* Quota file open - stub */ #define dquot_file_open(i, f) ({ (void)(i); (void)(f); 0; }) @@ -963,9 +964,7 @@ void mapping_clear_folio_cache(struct address_space *mapping); /* 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; }) -#define fsverity_active(i) (0) +/* fsverity stubs are in linux/fsverity.h */ /* Inode time setters - needed for ext4.h */ static inline struct timespec64 inode_set_atime_to_ts(struct inode *inode, @@ -1351,8 +1350,7 @@ int inode_generic_drop(struct inode *inode); #define invalidate_inode_buffers(i) do { } while (0) #define clear_inode(i) do { } while (0) -/* fsverity stubs (fscrypt macros are in ext4_fscrypt.h) */ -#define fsverity_cleanup_inode(i) do { } while (0) +/* fsverity_cleanup_inode is in linux/fsverity.h */ /* NFS export helpers are now in linux/exportfs.h */ @@ -1610,11 +1608,7 @@ bool __folio_start_writeback(struct folio *folio, bool keep_write); /* fscrypt readpage stubs are in ext4_fscrypt.h */ -/* fsverity stubs */ -#define fsverity_verify_bio(bio) do { (void)(bio); } while (0) -#define fsverity_enqueue_verify_work(work) do { (void)(work); } while (0) -#define fsverity_verify_folio(f) ({ (void)(f); 1; }) -#define IS_VERITY(inode) (0) +/* fsverity stubs are in linux/fsverity.h */ /* readahead operations are in linux/pagemap.h */ diff --git a/include/linux/fsverity.h b/include/linux/fsverity.h new file mode 100644 index 00000000000..738bea02d3e --- /dev/null +++ b/include/linux/fsverity.h @@ -0,0 +1,97 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * fs-verity definitions for U-Boot + * + * Based on Linux fsverity.h - fs-verity verification. + * U-Boot stub - fs-verity not supported. + */ +#ifndef _LINUX_FSVERITY_H +#define _LINUX_FSVERITY_H + +/* Forward declarations */ +struct bio; +struct dentry; +struct file; +struct folio; +struct iattr; +struct inode; +struct work_struct; + +/** + * IS_VERITY() - check if inode has fs-verity enabled + * @inode: inode to check + * + * U-Boot stub - always returns false. + */ +#define IS_VERITY(inode) (0) + +/** + * fsverity_file_open() - check verity on file open + * @inode: inode being opened + * @file: file being opened + * + * U-Boot stub - always succeeds. + * + * Return: 0 + */ +#define fsverity_file_open(inode, file) \ + ({ (void)(inode); (void)(file); 0; }) + +/** + * fsverity_prepare_setattr() - prepare for attribute change + * @dentry: dentry being modified + * @attr: new attributes + * + * U-Boot stub - always succeeds. + * + * Return: 0 + */ +#define fsverity_prepare_setattr(dentry, attr) \ + ({ (void)(dentry); (void)(attr); 0; }) + +/** + * fsverity_active() - check if verity is active on inode + * @inode: inode to check + * + * U-Boot stub - always returns false. + * + * Return: false + */ +#define fsverity_active(inode) ({ (void)(inode); 0; }) + +/** + * fsverity_cleanup_inode() - cleanup verity data on inode + * @inode: inode to clean up + * + * U-Boot stub - no-op. + */ +#define fsverity_cleanup_inode(inode) do { (void)(inode); } while (0) + +/** + * fsverity_verify_bio() - verify bio data + * @bio: bio to verify + * + * U-Boot stub - no-op. + */ +#define fsverity_verify_bio(bio) do { (void)(bio); } while (0) + +/** + * fsverity_enqueue_verify_work() - enqueue verification work + * @work: work item + * + * U-Boot stub - no-op. + */ +#define fsverity_enqueue_verify_work(work) \ + do { (void)(work); } while (0) + +/** + * fsverity_verify_folio() - verify folio data + * @folio: folio to verify + * + * U-Boot stub - always succeeds. + * + * Return: true (verified) + */ +#define fsverity_verify_folio(folio) ({ (void)(folio); true; }) + +#endif /* _LINUX_FSVERITY_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Extend linux/quotaops.h with additional quota stubs needed by ext4l: - dquot_alloc_block_nofail, dquot_alloc_block, dquot_free_block - dquot_claim_block, dquot_reclaim_block, dquot_reserve_block - dquot_release_reservation_block, dquot_initialize_needed - dquot_alloc_space_nodirty, dquot_free_space_nodirty - is_quota_modification, dquot_writeback_dquots - sb_any_quota_suspended The block allocation macros update inode->i_blocks to track allocated blocks without actual quota enforcement. Update ext4_uboot.h to use linux/quotaops.h and remove the function implementations from stub.c since they are now 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 | 35 +++++-------------------- fs/ext4l/stub.c | 30 +-------------------- include/linux/quotaops.h | 56 +++++++++++++++++++++++++++++++++------- 3 files changed, 54 insertions(+), 67 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index dc8c9a97877..83dcf772c45 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -239,13 +239,8 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); /* Group permission - stub */ #define in_group_p(gid) (0) -/* 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) +/* Quota operations - use linux/quotaops.h */ +#include <linux/quotaops.h> /* icount - inode reference count */ #define icount_read(inode) (1) @@ -818,8 +813,7 @@ static inline unsigned long memweight(const void *ptr, size_t bytes) /* in_range - use linux/minmax.h */ #include <linux/minmax.h> -/* Quota stub */ -#define dquot_reclaim_block(i, n) do { } while (0) +/* dquot_reclaim_block is in linux/quotaops.h */ /* fiemap stubs are now in linux/fiemap.h */ @@ -923,8 +917,7 @@ void mapping_clear_folio_cache(struct address_space *mapping); /* fsverity_file_open is in linux/fsverity.h */ #include <linux/fsverity.h> -/* Quota file open - stub */ -#define dquot_file_open(i, f) ({ (void)(i); (void)(f); 0; }) +/* dquot_file_open is in linux/quotaops.h */ /* Inode I/O list management */ #define inode_io_list_del(inode) do { } while (0) @@ -934,13 +927,7 @@ void mapping_clear_folio_cache(struct address_space *mapping); /* Folio operations and writeback stubs are in linux/pagemap.h */ #define folio_batch_release(fb) do { } while (0) -/* Quota stubs - additional */ -#define dquot_claim_block(i, n) ({ (void)(i); (void)(n); 0; }) -#define dquot_reserve_block(i, n) ({ (void)(i); (void)(n); 0; }) -#define dquot_release_reservation_block(i, n) do { } while (0) -#define dquot_initialize_needed(i) (0) -#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; }) +/* Quota stubs are in linux/quotaops.h */ /* percpu_counter_sub is in linux/percpu_counter.h */ @@ -1455,12 +1442,7 @@ 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 - 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); -void dquot_free_block(struct inode *inode, loff_t nr); +/* Quota operations are in linux/quotaops.h */ /* Block device file operations - stubs */ #define set_blocksize(f, size) ({ (void)(f); (void)(size); 0; }) @@ -1468,10 +1450,7 @@ struct buffer_head *__bread(struct block_device *bdev, sector_t block, unsigned /* 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) -#define dquot_resume(sb, type) do { (void)(sb); (void)(type); } while (0) -#define sb_any_quota_suspended(sb) ({ (void)(sb); 0; }) +/* Quota stubs for super.c are in linux/quotaops.h */ /* * Stubs for mballoc.c diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c index e223ec21936..bdb8b8bb675 100644 --- a/fs/ext4l/stub.c +++ b/fs/ext4l/stub.c @@ -620,35 +620,7 @@ long ext4_ioctl(struct file *file, unsigned int cmd, unsigned long arg) /* nop_mnt_idmap - no-op mount ID map for xattr.c */ struct mnt_idmap nop_mnt_idmap; -/* Quota stubs for xattr.c */ -int dquot_alloc_space_nodirty(struct inode *inode, loff_t size) -{ - return 0; -} - -void dquot_free_space_nodirty(struct inode *inode, loff_t size) -{ -} - -int dquot_alloc_block(struct inode *inode, loff_t nr) -{ - /* - * Update i_blocks to reflect the allocated blocks. - * i_blocks is in 512-byte units, so convert from fs blocks. - */ - inode->i_blocks += nr << (inode->i_blkbits - 9); - - return 0; -} - -void dquot_free_block(struct inode *inode, loff_t nr) -{ - /* - * Update i_blocks to reflect the freed blocks. - * i_blocks is in 512-byte units, so convert from fs blocks. - */ - inode->i_blocks -= nr << (inode->i_blkbits - 9); -} +/* Quota stubs are now macros in linux/quotaops.h */ /* * JBD2 stubs - temporary stubs until other jbd2 files are added diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 04988ace843..b32e7b7ab70 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h @@ -6,27 +6,62 @@ * Author: Marco van Wieringen <mvw@planets.elm.net> * * Stub definitions for quota operations. - * U-Boot doesn't support disk quotas. + * U-Boot does not support disk quotas. */ #ifndef _LINUX_QUOTAOPS_H #define _LINUX_QUOTAOPS_H +#include <linux/types.h> + struct inode; struct dentry; struct kqid; +struct mnt_idmap; +struct iattr; +struct super_block; + +/* Quota initialisation and cleanup */ +#define dquot_initialize(inode) ({ (void)(inode); 0; }) +#define dquot_initialize_needed(inode) (0) +#define dquot_drop(inode) do { (void)(inode); } while (0) + +/* Inode quota operations */ +#define dquot_alloc_inode(inode) ({ (void)(inode); 0; }) +#define dquot_free_inode(inode) do { (void)(inode); } while (0) -#define dquot_initialize(inode) 0 -#define dquot_drop(inode) do { } while (0) -#define dquot_alloc_inode(inode) 0 -#define dquot_free_inode(inode) do { } while (0) -#define dquot_transfer(inode, attr) 0 +/* Block quota operations */ +#define dquot_alloc_block(inode, nr) \ + ({ (inode)->i_blocks += (nr) << ((inode)->i_blkbits - 9); 0; }) +#define dquot_alloc_block_nofail(inode, nr) \ + ({ (inode)->i_blocks += (nr) << ((inode)->i_blkbits - 9); 0; }) +#define dquot_free_block(inode, nr) \ + do { (inode)->i_blocks -= (nr) << ((inode)->i_blkbits - 9); } while (0) +#define dquot_claim_block(inode, nr) ({ (void)(inode); (void)(nr); 0; }) +#define dquot_reclaim_block(inode, nr) do { } while (0) +#define dquot_reserve_block(inode, nr) ({ (void)(inode); (void)(nr); 0; }) +#define dquot_release_reservation_block(inode, nr) \ + do { (void)(inode); (void)(nr); } while (0) + +/* Space quota operations */ +#define dquot_alloc_space_nodirty(inode, size) ({ (void)(inode); (void)(size); 0; }) +#define dquot_free_space_nodirty(inode, size) do { (void)(inode); (void)(size); } while (0) #define dquot_claim_space_nodirty(inode, nr) 0 #define dquot_reclaim_space_nodirty(inode, nr) do { } while (0) -#define dquot_disable(sb, type, flags) 0 -#define dquot_suspend(sb, type) 0 -#define dquot_resume(sb, type) 0 -#define dquot_file_open(inode, file) 0 +/* Transfer and modification checks */ +#define dquot_transfer(idmap, inode, attr) \ + ({ (void)(idmap); (void)(inode); (void)(attr); 0; }) +#define is_quota_modification(idmap, inode, attr) \ + ({ (void)(idmap); (void)(inode); (void)(attr); 0; }) + +/* Quota control */ +#define dquot_disable(sb, type, flags) 0 +#define dquot_suspend(sb, type) ({ (void)(sb); (void)(type); 0; }) +#define dquot_resume(sb, type) do { (void)(sb); (void)(type); } while (0) +#define dquot_writeback_dquots(sb, type) do { (void)(sb); (void)(type); } while (0) +#define dquot_file_open(inode, file) ({ (void)(inode); (void)(file); 0; }) + +/* Quota status queries */ #define sb_has_quota_usage_enabled(sb, type) 0 #define sb_has_quota_limits_enabled(sb, type) 0 #define sb_has_quota_suspended(sb, type) 0 @@ -34,5 +69,6 @@ struct kqid; #define sb_has_quota_active(sb, type) 0 #define sb_any_quota_loaded(sb) 0 #define sb_any_quota_active(sb) 0 +#define sb_any_quota_suspended(sb) ({ (void)(sb); 0; }) #endif /* _LINUX_QUOTAOPS_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create linux/ioprio.h with I/O priority class definitions and helper macros including IOPRIO_CLASS_*, IOPRIO_PRIO_VALUE(), IOPRIO_PRIO_CLASS(), get_current_ioprio(), and set_task_ioprio(). Update ext4_uboot.h to use linux/ioprio.h and remove the function implementations from stub.c since they are now 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 | 13 ++++----- fs/ext4l/stub.c | 10 +------ include/linux/ioprio.h | 64 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 17 deletions(-) create mode 100644 include/linux/ioprio.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 83dcf772c45..aae248a6930 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1243,8 +1243,8 @@ void ext4_unregister_li_request(struct super_block *sb); /* Path lookup flags - use linux/namei.h */ #include <linux/namei.h> -/* I/O priority classes */ -#define IOPRIO_CLASS_BE 2 +/* I/O priority classes - use linux/ioprio.h */ +#include <linux/ioprio.h> /* SB_INLINECRYPT, SB_SILENT, SB_POSIXACL are in linux/fs.h */ #define SB_I_CGROUPWB 0 /* Not supported in U-Boot */ @@ -1343,8 +1343,7 @@ int inode_generic_drop(struct inode *inode); /* Path operations - path_put, d_path are in linux/path.h */ -/* I/O priority - declaration for stub.c */ -int IOPRIO_PRIO_VALUE(int class, int data); +/* I/O priority stubs are in linux/ioprio.h */ /* kmemdup_nul is in linux/slab.h */ /* fscrypt declarations are in ext4_fscrypt.h */ @@ -1393,8 +1392,7 @@ unsigned int bdev_max_discard_sectors(struct block_device *bdev); /* bgl_lock_init is now in linux/blockgroup_lock.h */ -/* Task I/O priority - declaration for stub.c */ -void set_task_ioprio(void *task, int ioprio); +/* set_task_ioprio is in linux/ioprio.h */ /* Superblock identity functions */ static inline void super_set_uuid(struct super_block *sb, const u8 *uuid, @@ -1617,8 +1615,7 @@ bool __folio_start_writeback(struct folio *folio, bool keep_write); /* d_alloc, d_drop are now in linux/dcache.h */ -/* get_current_ioprio - I/O priority (not used in U-Boot) */ -#define get_current_ioprio() (0) +/* get_current_ioprio is in linux/ioprio.h */ /* JBD2 checkpoint.c stubs */ #define mutex_lock_io(m) mutex_lock(m) diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c index bdb8b8bb675..1b9c72a6cc2 100644 --- a/fs/ext4l/stub.c +++ b/fs/ext4l/stub.c @@ -400,15 +400,7 @@ int ___ratelimit(struct ratelimit_state *rs, const char *func) return 1; } -/* I/O priority */ -int IOPRIO_PRIO_VALUE(int class, int data) -{ - return (class << 13) | data; -} - -void set_task_ioprio(void *task, int ioprio) -{ -} +/* I/O priority stubs are now in linux/ioprio.h */ /* ext4_fc_init is now in fast_commit.c */ diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h new file mode 100644 index 00000000000..2cec5cac818 --- /dev/null +++ b/include/linux/ioprio.h @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * I/O priority definitions for U-Boot + * + * Based on Linux ioprio.h - I/O scheduling priority. + * U-Boot stub - I/O priority not supported. + */ +#ifndef IOPRIO_H +#define IOPRIO_H + +/* I/O priority classes */ +#define IOPRIO_CLASS_NONE 0 +#define IOPRIO_CLASS_RT 1 +#define IOPRIO_CLASS_BE 2 +#define IOPRIO_CLASS_IDLE 3 + +/* I/O priority levels (0-7, lower is higher priority) */ +#define IOPRIO_NR_LEVELS 8 +#define IOPRIO_BE_NR IOPRIO_NR_LEVELS + +/** + * IOPRIO_PRIO_VALUE() - create I/O priority value from class and level + * @class: I/O priority class + * @data: priority level within class + * + * Return: encoded priority value + */ +#define IOPRIO_PRIO_VALUE(class, data) (((class) << 13) | (data)) + +/** + * IOPRIO_PRIO_CLASS() - extract class from priority value + * @ioprio: encoded priority + * + * Return: I/O priority class + */ +#define IOPRIO_PRIO_CLASS(ioprio) (((ioprio) >> 13) & 0x3) + +/** + * IOPRIO_PRIO_DATA() - extract data/level from priority value + * @ioprio: encoded priority + * + * Return: priority level + */ +#define IOPRIO_PRIO_DATA(ioprio) ((ioprio) & 0x1fff) + +/** + * get_current_ioprio() - get I/O priority of current task + * + * U-Boot stub - always returns 0. + * + * Return: I/O priority value + */ +#define get_current_ioprio() (0) + +/** + * set_task_ioprio() - set I/O priority of a task + * @task: task to modify (ignored) + * @ioprio: priority to set (ignored) + * + * U-Boot stub - no-op. + */ +#define set_task_ioprio(task, ioprio) do { (void)(task); (void)(ioprio); } while (0) + +#endif /* IOPRIO_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move the rwsem_is_locked() stub macro to linux/rwsem.h where it belongs with other rwsem operations. This reduces duplication in ext4_uboot.h and places the definition with related rwsem functions. 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/rwsem.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index aae248a6930..58479ccb2fe 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -758,8 +758,7 @@ static inline unsigned long memweight(const void *ptr, size_t bytes) /* extents.c stubs */ -/* rwsem is_locked stub */ -#define rwsem_is_locked(sem) (1) +/* rwsem_is_locked is in linux/rwsem.h */ /* Buffer operations */ #define sb_getblk_gfp(sb, blk, gfp) sb_getblk((sb), (blk)) diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h index ea70829d135..7beaf5062ed 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h @@ -24,5 +24,6 @@ struct rw_semaphore { #define down_write_trylock(sem) 1 #define up_write(sem) do { } while (0) #define downgrade_write(sem) do { } while (0) +#define rwsem_is_locked(sem) (1) #endif /* _LINUX_RWSEM_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Create include/linux/hrtimer.h with high-resolution timer definitions. This includes the hrtimer_mode enum values and schedule_hrtimeout() stub, matching Linux kernel organisation. These are stubs since U-Boot does not support high-resolution timers. 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/hrtimer.h | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 include/linux/hrtimer.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 58479ccb2fe..89d1296c18b 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -839,9 +839,8 @@ static inline unsigned long memweight(const void *ptr, size_t bytes) /* ktime functions - use linux/ktime.h */ #include <linux/ktime.h> -/* hrtimer stubs */ -#define HRTIMER_MODE_ABS 0 -#define schedule_hrtimeout(exp, mode) ({ (void)(exp); (void)(mode); 0; }) +/* hrtimer - use linux/hrtimer.h */ +#include <linux/hrtimer.h> /* write lock variants */ #define write_trylock(lock) ({ (void)(lock); 1; }) diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h new file mode 100644 index 00000000000..98178498b2d --- /dev/null +++ b/include/linux/hrtimer.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * High-resolution timer definitions for U-Boot + * + * Based on Linux hrtimer.h - high resolution timers. + * U-Boot stub - high-resolution timers not supported. + */ +#ifndef _LINUX_HRTIMER_H +#define _LINUX_HRTIMER_H + +/* High-resolution timer modes */ +enum hrtimer_mode { + HRTIMER_MODE_ABS = 0x00, + HRTIMER_MODE_REL = 0x01, + HRTIMER_MODE_PINNED = 0x02, + HRTIMER_MODE_SOFT = 0x04, + HRTIMER_MODE_HARD = 0x08, + + HRTIMER_MODE_ABS_PINNED = HRTIMER_MODE_ABS | HRTIMER_MODE_PINNED, + HRTIMER_MODE_REL_PINNED = HRTIMER_MODE_REL | HRTIMER_MODE_PINNED, + HRTIMER_MODE_ABS_SOFT = HRTIMER_MODE_ABS | HRTIMER_MODE_SOFT, + HRTIMER_MODE_REL_SOFT = HRTIMER_MODE_REL | HRTIMER_MODE_SOFT, + HRTIMER_MODE_ABS_HARD = HRTIMER_MODE_ABS | HRTIMER_MODE_HARD, + HRTIMER_MODE_REL_HARD = HRTIMER_MODE_REL | HRTIMER_MODE_HARD, +}; + +/** + * schedule_hrtimeout() - sleep until timeout with high-resolution timer + * @expires: timeout value (ktime_t) + * @mode: timer mode + * + * U-Boot stub - returns immediately. + * + * Return: 0 + */ +#define schedule_hrtimeout(expires, mode) \ + ({ (void)(expires); (void)(mode); 0; }) + +#endif /* _LINUX_HRTIMER_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move the STATX_* flags and struct kstat definition to include/linux/stat.h where they belong alongside the struct stat definitions, matching Linux kernel organisation. This reduces ext4_uboot.h by 40 lines. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 41 +----------------------------------- include/linux/stat.h | 48 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 89d1296c18b..d017d86247b 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -491,48 +491,9 @@ static inline int bdev_read_only(struct block_device *bdev) /* SB_LAZYTIME is in linux/fs.h */ /* ATTR_* iattr valid flags are in linux/fs.h */ - -/* STATX flags and attributes */ -#define STATX_BTIME 0x00000800U -#define STATX_DIOALIGN 0x00002000U -#define STATX_WRITE_ATOMIC 0x00004000U -#define STATX_ATTR_COMPRESSED 0x00000004 -#define STATX_ATTR_IMMUTABLE 0x00000010 -#define STATX_ATTR_APPEND 0x00000020 -#define STATX_ATTR_NODUMP 0x00000040 -#define STATX_ATTR_ENCRYPTED 0x00000800 -#define STATX_ATTR_VERITY 0x00100000 - +/* STATX_* flags and struct kstat are in linux/stat.h */ /* VM fault return values are in linux/mm_types.h */ - /* struct path is defined in linux/fs.h */ - -/* struct kstat - stat buffer */ -struct kstat { - u64 ino; - dev_t dev; - umode_t mode; - unsigned int nlink; - uid_t uid; - gid_t gid; - dev_t rdev; - loff_t size; - struct timespec64 atime; - struct timespec64 mtime; - struct timespec64 ctime; - struct timespec64 btime; - u64 blocks; - u32 blksize; - u64 attributes; - u64 attributes_mask; - u32 result_mask; - u32 dio_mem_align; - u32 dio_offset_align; - u32 atomic_write_unit_min; - u32 atomic_write_unit_max; - u32 atomic_write_segments_max; -}; - /* VM structs (vm_area_struct, page, vm_fault, vm_operations_struct) are in linux/mm_types.h */ /* Forward declaration for swap */ diff --git a/include/linux/stat.h b/include/linux/stat.h index b65bff7e97d..9a5babbc5be 100644 --- a/include/linux/stat.h +++ b/include/linux/stat.h @@ -180,4 +180,52 @@ struct stat { } #endif +/* + * STATX flags and attributes + */ +#define STATX_BTIME 0x00000800U /* Want/got btime */ +#define STATX_DIOALIGN 0x00002000U /* Want/got dio alignment */ +#define STATX_WRITE_ATOMIC 0x00004000U /* Want/got atomic writes */ + +/* File attributes for STATX */ +#define STATX_ATTR_COMPRESSED 0x00000004 /* Compressed file */ +#define STATX_ATTR_IMMUTABLE 0x00000010 /* Immutable file */ +#define STATX_ATTR_APPEND 0x00000020 /* Append-only file */ +#define STATX_ATTR_NODUMP 0x00000040 /* No dump file */ +#define STATX_ATTR_ENCRYPTED 0x00000800 /* Encrypted file */ +#define STATX_ATTR_VERITY 0x00100000 /* Verity protected file */ + +#include <linux/time.h> + +/** + * struct kstat - stat buffer for VFS + * + * Extended stat buffer used internally by the VFS. Contains all information + * returned by statx() system call. + */ +struct kstat { + u64 ino; + dev_t dev; + umode_t mode; + unsigned int nlink; + uid_t uid; + gid_t gid; + dev_t rdev; + loff_t size; + struct timespec64 atime; + struct timespec64 mtime; + struct timespec64 ctime; + struct timespec64 btime; /* Birth/creation time */ + u64 blocks; + u32 blksize; + u64 attributes; + u64 attributes_mask; + u32 result_mask; + u32 dio_mem_align; + u32 dio_offset_align; + u32 atomic_write_unit_min; + u32 atomic_write_unit_max; + u32 atomic_write_segments_max; +}; + #endif -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move block I/O request operation codes and flags (REQ_OP_READ, REQ_OP_WRITE, REQ_OP_MASK, REQ_SYNC, REQ_FUA) to include/linux/blk_types.h where they belong with other block layer types. Move slab cache creation flags (SLAB_RECLAIM_ACCOUNT, SLAB_ACCOUNT) to include/linux/slab.h with other slab definitions. This matches Linux kernel header organisation and reduces duplication in ext4_uboot.h Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 14 +++----------- include/linux/blk_types.h | 9 +++++++++ include/linux/slab.h | 4 ++++ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index d017d86247b..1622fec4e64 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1106,8 +1106,8 @@ static inline void end_buffer_read_sync(struct buffer_head *bh, int uptodate) clear_buffer_uptodate(bh); unlock_buffer(bh); } -#define REQ_OP_READ 0 +/* REQ_OP_READ is in linux/blk_types.h */ /* SB_ACTIVE is in linux/fs.h */ /* Part stat - not used in U-Boot. Note: sectors[X] is passed as second arg */ @@ -1127,9 +1127,7 @@ static u64 __attribute__((unused)) __ext4_sectors[2]; #define DUMP_PREFIX_ADDRESS 0 #define print_hex_dump(l, p, pt, rg, gc, b, len, a) do { } while (0) -/* Slab flags */ -#define SLAB_RECLAIM_ACCOUNT 0 -#define SLAB_ACCOUNT 0 +/* SLAB_RECLAIM_ACCOUNT, SLAB_ACCOUNT are in linux/slab.h */ /* Forward declarations for super_operations and export_operations */ struct kstatfs; @@ -1214,13 +1212,7 @@ void ext4_unregister_li_request(struct super_block *sb); #define BLK_OPEN_WRITE (1 << 1) #define BLK_OPEN_RESTRICT_WRITES (1 << 2) -/* Request operation (bits 0-7) and flags (bits 8+) */ -#define REQ_OP_WRITE 1 -#define REQ_OP_MASK 0xff - -/* ensure these values are outside the operations mask */ -#define REQ_SYNC (1 << 8) -#define REQ_FUA (1 << 9) +/* REQ_OP_*, REQ_SYNC, REQ_FUA are in linux/blk_types.h */ /* blk_holder_ops for block device */ struct blk_holder_ops { diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index aa7ea50d233..9d770f4bd6e 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -15,4 +15,13 @@ /* Block I/O operation flags */ typedef __u32 __bitwise blk_opf_t; +/* Block operation codes (bits 0-7) */ +#define REQ_OP_READ 0 +#define REQ_OP_WRITE 1 +#define REQ_OP_MASK 0xff + +/* Block request flags (bits 8+) */ +#define REQ_SYNC (1 << 8) /* Synchronous I/O */ +#define REQ_FUA (1 << 9) /* Forced unit access */ + #endif /* _LINUX_BLK_TYPES_H */ diff --git a/include/linux/slab.h b/include/linux/slab.h index 4f413f93fa3..1b212ca0e4a 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -46,6 +46,10 @@ #define GFP_NOIO ((gfp_t)0) #endif +/* Slab cache creation flags */ +#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Track pages reclaimed */ +#define SLAB_ACCOUNT 0x00000000UL /* Account to memcg (no-op) */ + void *kmalloc(size_t size, gfp_t flags); static inline void *kzalloc(size_t size, gfp_t flags) -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move the remaining block I/O request flags (REQ_IDLE, REQ_PREFLUSH) to include/linux/blk_types.h with other request flags. This consolidates all REQ_* flags in one location, matching Linux kernel 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 | 6 +----- include/linux/blk_types.h | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 1622fec4e64..03534115e71 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1557,11 +1557,7 @@ bool __folio_start_writeback(struct folio *folio, bool keep_write); /* Dentry name snapshot operations are now in linux/dcache.h */ /* lockdep_assert_not_held is in linux/lockdep.h */ - -/* Request flags for block I/O */ -#define REQ_IDLE 0 -#define REQ_PREFLUSH 0 - +/* REQ_IDLE, REQ_PREFLUSH are in linux/blk_types.h */ /* wake_up_bit is now in linux/wait_bit.h */ /* d_alloc, d_drop are now in linux/dcache.h */ diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 9d770f4bd6e..ccbee4b9876 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -23,5 +23,7 @@ typedef __u32 __bitwise blk_opf_t; /* Block request flags (bits 8+) */ #define REQ_SYNC (1 << 8) /* Synchronous I/O */ #define REQ_FUA (1 << 9) /* Forced unit access */ +#define REQ_PREFLUSH (1 << 10) /* Request cache flush */ +#define REQ_IDLE (1 << 11) /* Anticipate more I/O */ #endif /* _LINUX_BLK_TYPES_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move the quota format identifiers (QFMT_VFS_OLD, QFMT_VFS_V0, QFMT_VFS_V1) to include/linux/quotaops.h with other quota definitions. This consolidates quota-related constants in one 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 | 5 +---- include/linux/quotaops.h | 5 +++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 03534115e71..d11981a858a 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1092,10 +1092,7 @@ static inline const char *simple_get_link(struct dentry *dentry, * Additional stubs for super.c */ -/* Quota format constants */ -#define QFMT_VFS_OLD 1 -#define QFMT_VFS_V0 2 -#define QFMT_VFS_V1 4 +/* QFMT_VFS_* quota format constants are in linux/quotaops.h */ /* Buffer read sync */ static inline void end_buffer_read_sync(struct buffer_head *bh, int uptodate) diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index b32e7b7ab70..b96e33887b8 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h @@ -61,6 +61,11 @@ struct super_block; #define dquot_writeback_dquots(sb, type) do { (void)(sb); (void)(type); } while (0) #define dquot_file_open(inode, file) ({ (void)(inode); (void)(file); 0; }) +/* Quota format identifiers */ +#define QFMT_VFS_OLD 1 /* Original quota format */ +#define QFMT_VFS_V0 2 /* 32-bit UID/GID quota */ +#define QFMT_VFS_V1 4 /* 32-bit UID/GID with grace period */ + /* Quota status queries */ #define sb_has_quota_usage_enabled(sb, type) 0 #define sb_has_quota_limits_enabled(sb, type) 0 -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move the remaining block I/O request flags to include/linux/blk_types.h with other request flags, matching Linux kernel 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 | 5 +---- include/linux/blk_types.h | 3 +++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index d11981a858a..931889f6046 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -125,10 +125,7 @@ #define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= PAGE_SIZE) #define data_race(expr) (expr) -/* Block I/O request flags - stubs */ -#define REQ_META 0 -#define REQ_PRIO 0 -#define REQ_RAHEAD 0 +/* REQ_META, REQ_PRIO, REQ_RAHEAD are in linux/blk_types.h */ /* GFP flags - stubs */ #define __GFP_MOVABLE 0 diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index ccbee4b9876..a842300ae64 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -25,5 +25,8 @@ typedef __u32 __bitwise blk_opf_t; #define REQ_FUA (1 << 9) /* Forced unit access */ #define REQ_PREFLUSH (1 << 10) /* Request cache flush */ #define REQ_IDLE (1 << 11) /* Anticipate more I/O */ +#define REQ_META (1 << 12) /* Metadata I/O request */ +#define REQ_PRIO (1 << 13) /* Boost priority */ +#define REQ_RAHEAD (1 << 14) /* Read ahead */ #endif /* _LINUX_BLK_TYPES_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move the memory allocation flags to include/linux/slab.h with other GFP flags, matching Linux kernel 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 | 5 +---- include/linux/slab.h | 6 ++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 931889f6046..b35559b8b18 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -126,10 +126,7 @@ #define data_race(expr) (expr) /* REQ_META, REQ_PRIO, REQ_RAHEAD are in linux/blk_types.h */ - -/* GFP flags - stubs */ -#define __GFP_MOVABLE 0 -#define __GFP_FS 0 +/* __GFP_MOVABLE, __GFP_FS are in linux/slab.h */ /* Capabilities - use linux/capability.h */ #include <linux/capability.h> diff --git a/include/linux/slab.h b/include/linux/slab.h index 1b212ca0e4a..fb809063593 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -42,6 +42,12 @@ #ifndef __GFP_NOFAIL #define __GFP_NOFAIL ((gfp_t)0) #endif +#ifndef __GFP_MOVABLE +#define __GFP_MOVABLE ((gfp_t)0) +#endif +#ifndef __GFP_FS +#define __GFP_FS ((gfp_t)0) +#endif #ifndef GFP_NOIO #define GFP_NOIO ((gfp_t)0) #endif -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Add the system_states enum and system_state macro to linux/kernel.h where it belongs in Linux kernel organisation. U-Boot is single-threaded so system_state is always SYSTEM_RUNNING Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 6 +----- include/linux/kernel.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index b35559b8b18..9e3d59a3174 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1108,11 +1108,7 @@ static u64 __attribute__((unused)) __ext4_sectors[2]; #define sectors __ext4_sectors #define part_stat_read(p, f) ({ (void)(p); (void)(f); 0ULL; }) -/* System state - U-Boot is always running */ -#define system_state 0 -#define SYSTEM_HALT 1 -#define SYSTEM_POWER_OFF 2 -#define SYSTEM_RESTART 3 +/* system_state, SYSTEM_HALT, etc. are in linux/kernel.h */ /* Hex dump */ #define DUMP_PREFIX_ADDRESS 0 diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 9467edd65ab..d6cd54f20b9 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -296,4 +296,21 @@ */ #define find_closest(x, a, as) __find_closest(x, a, as, <=) +/* + * System state values - stub for U-Boot. + * U-Boot is always in running state. + */ +enum system_states { + SYSTEM_BOOTING, + SYSTEM_SCHEDULING, + SYSTEM_FREEING_INITMEM, + SYSTEM_RUNNING, + SYSTEM_HALT, + SYSTEM_POWER_OFF, + SYSTEM_RESTART, + SYSTEM_SUSPEND, +}; + +#define system_state SYSTEM_RUNNING + #endif -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move the block device open flags to include/linux/blkdev.h where they belong with other block device definitions, matching Linux kernel 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 | 6 +----- include/linux/blkdev.h | 7 +++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 9e3d59a3174..dc6d4c3910a 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1194,11 +1194,7 @@ void ext4_unregister_li_request(struct super_block *sb); #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) -#define BLK_OPEN_WRITE (1 << 1) -#define BLK_OPEN_RESTRICT_WRITES (1 << 2) - +/* BLK_OPEN_* flags are in linux/blkdev.h */ /* REQ_OP_*, REQ_SYNC, REQ_FUA are in linux/blk_types.h */ /* blk_holder_ops for block device */ diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 8c848139a7e..f1a4cc12d3c 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -18,6 +18,13 @@ struct gendisk; /* Block size helpers */ #define bdev_logical_block_size(bdev) 512 +/* Block device open flags */ +#define BLK_OPEN_READ (1 << 0) +#define BLK_OPEN_WRITE (1 << 1) +#define BLK_OPEN_EXCL (1 << 2) +#define BLK_OPEN_NDELAY (1 << 3) +#define BLK_OPEN_RESTRICT_WRITES (1 << 4) + /** * struct blk_plug - block I/O plug * -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move schedule_timeout_interruptible(), schedule_timeout_uninterruptible(), and need_resched() to include/linux/sched.h where they belong with other scheduler functions. These are stubs since U-Boot is single-threaded. 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/sched.h | 7 +++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index dc6d4c3910a..206bf4d784f 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1294,8 +1294,7 @@ void *kvzalloc(size_t size, gfp_t flags); #define sb_start_write(sb) do { } while (0) #define sb_end_write(sb) do { } while (0) -/* Scheduler stubs */ -#define schedule_timeout_interruptible(t) ({ (void)(t); 0; }) +/* schedule_timeout_interruptible is in linux/sched.h */ /* Page allocation - declarations for stub.c */ unsigned long get_zeroed_page(gfp_t gfp); @@ -1465,9 +1464,7 @@ static inline unsigned long ext4_find_next_bit_le(const void *addr, /* raw_cpu_ptr - get pointer to per-CPU data for current CPU */ #define raw_cpu_ptr(ptr) (ptr) -/* Scheduler stubs */ -#define schedule_timeout_uninterruptible(t) do { } while (0) -#define need_resched() (0) +/* schedule_timeout_uninterruptible, need_resched are in linux/sched.h */ /* Block device operations */ #define sb_find_get_block_nonatomic(sb, block) \ diff --git a/include/linux/sched.h b/include/linux/sched.h index 04672cee991..ff36a6443c8 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -41,4 +41,11 @@ extern struct task_struct *current; #define signal_pending(task) 0 #define fatal_signal_pending(task) 0 +/* Scheduler timeout stubs - return immediately in U-Boot */ +#define schedule_timeout_interruptible(timeout) ({ (void)(timeout); 0; }) +#define schedule_timeout_uninterruptible(timeout) do { (void)(timeout); } while (0) + +/* Check if rescheduling is needed - always false in single-threaded U-Boot */ +#define need_resched() (0) + #endif /* _LINUX_SCHED_H */ -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Move the process flags (PF_MEMALLOC, PF_MEMALLOC_NOFS) to include/linux/sched.h where they belong with other task_struct-related definitions, matching Linux kernel 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 | 8 ++------ include/linux/sched.h | 4 ++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 206bf4d784f..0a1b7406127 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -493,8 +493,7 @@ static inline int bdev_read_only(struct block_device *bdev) /* Forward declaration for swap */ struct swap_info_struct; -/* Process flags */ -#define PF_MEMALLOC 0x00000800 +/* PF_MEMALLOC is in linux/sched.h */ /* Forward declarations for inode operations */ struct inode_operations; @@ -1354,10 +1353,7 @@ static inline void super_set_uuid(struct super_block *sb, const u8 *uuid, /* Nested inode locking stub */ #define inode_lock_nested(i, c) do { (void)(i); (void)(c); } while (0) -/* Process flags */ -#ifndef PF_MEMALLOC_NOFS -#define PF_MEMALLOC_NOFS 0x00040000 -#endif +/* PF_MEMALLOC_NOFS is in linux/sched.h */ /* generic_set_sb_d_ops, d_make_root are now in linux/dcache.h */ diff --git a/include/linux/sched.h b/include/linux/sched.h index ff36a6443c8..579468ee414 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -16,6 +16,10 @@ struct io_context { unsigned int ioprio; }; +/* Process flags */ +#define PF_MEMALLOC 0x00000800 /* Allocating memory */ +#define PF_MEMALLOC_NOFS 0x00040000 /* GFP_NOFS allocations */ + struct task_struct { int pid; char comm[16]; -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Add SECTOR_SHIFT and SECTOR_SIZE definitions to include/linux/blk_types.h where they belong with other block layer types, matching Linux kernel 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 | 4 +--- include/linux/blk_types.h | 8 ++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 0a1b7406127..f3b1aaaa408 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1611,9 +1611,7 @@ int bh_read(struct buffer_head *bh, int flags); ({ (void)(bdev); (void)(s); (void)(n); (void)(gfp); 0; }) #define blkdev_issue_zeroout(bdev, s, n, gfp, f) \ ({ (void)(bdev); (void)(s); (void)(n); (void)(gfp); (void)(f); 0; }) -#ifndef SECTOR_SHIFT -#define SECTOR_SHIFT 9 -#endif +/* SECTOR_SHIFT, SECTOR_SIZE are in linux/blk_types.h */ /* mapping_max_folio_order is in linux/pagemap.h */ /* Memory allocation for journal.c */ diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index a842300ae64..1c3c7c99e48 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -12,6 +12,14 @@ #include <linux/types.h> +/* Sector size definitions */ +#ifndef SECTOR_SHIFT +#define SECTOR_SHIFT 9 +#endif +#ifndef SECTOR_SIZE +#define SECTOR_SIZE (1 << SECTOR_SHIFT) +#endif + /* Block I/O operation flags */ typedef __u32 __bitwise blk_opf_t; -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Add the inode mutex nesting classes (I_MUTEX_NORMAL, I_MUTEX_PARENT, I_MUTEX_CHILD, I_MUTEX_XATTR, etc.) to include/linux/fs.h where they belong with other filesystem-related definitions, matching Linux kernel 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 | 6 +----- include/linux/fs.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index f3b1aaaa408..ba462af45e4 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1344,11 +1344,7 @@ static inline void super_set_uuid(struct super_block *sb, const u8 *uuid, #define xattr_handler_can_list(h, d) ({ (void)(h); (void)(d); 0; }) #define xattr_prefix(h) ({ (void)(h); (const char *)NULL; }) -/* Inode lock mutex classes */ -#define I_MUTEX_XATTR 5 -#define I_MUTEX_CHILD 4 -#define I_MUTEX_PARENT 3 -#define I_MUTEX_NORMAL 2 +/* I_MUTEX_* inode lock classes are in linux/fs.h */ /* Nested inode locking stub */ #define inode_lock_nested(i, c) do { (void)(i); (void)(c); } while (0) diff --git a/include/linux/fs.h b/include/linux/fs.h index 28b57b59484..5c357cdacd2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -260,4 +260,14 @@ static inline bool dir_emit(struct dir_context *ctx, const char *name, int len, #define dir_relax_shared(i) ({ (void)(i); 1; }) +/* Inode mutex nesting classes */ +enum { + I_MUTEX_NORMAL, + I_MUTEX_PARENT, + I_MUTEX_CHILD, + I_MUTEX_XATTR, + I_MUTEX_NONDIR2, + I_MUTEX_PARENT2, +}; + #endif /* _LINUX_FS_H */ -- 2.43.0
participants (1)
-
Simon Glass