Commit Graph

1080 Commits

Author SHA1 Message Date
Simon Glass
aa0782825e ext4l: Add fsmap.c to the build
Update fsmap.c to use ext4_uboot.h and add the required stubs:
- struct fsmap and related FMR_* macros
- trace_ext4_fsmap_* stub macros
- list_sort and sort stub macros

Cover-letter:
ext4l: Add jbd2 and remaining ext4l files to build
This series continues the ext4l port by adding the jbd2 journaling layer
and remaining ext4l files to the build.

Changes:
- Fix pr_emerg() macro to use log_emer()
- Import jbd2 source files from Linux 6.18
- Add jbd2 files to build: checkpoint, commit, journal, recovery,
  revoke, transaction
- Add ext4l files to build: migrate, mmp, move_extent, resize, fsmap

Each file addition includes the necessary stubs in ext4_uboot.h and
removes redundant stubs from stub.c as real implementations become
available.
END

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 14:15:36 -07:00
Simon Glass
a9422f0bf2 ext4l: Add resize.c to the build
Add filesystem-resize support.

Use ext4_uboot.h compatibility layer and add stubs for:
- test_and_set_bit_lock - forwards to test_and_set_bit
- div64_u64 - simple 64-bit division
- time_is_before_jiffies - always returns false

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 14:15:36 -07:00
Simon Glass
6e336ef205 ext4l: Add move_extent.c to the build
Add support for extent-moving for write operations.

Use ext4_uboot.h compatibility layer and add stubs for:
- down_write_nested - forwards to down_write
- filemap_release_folio, IS_SWAPFILE, PAGE_MASK
- lock_two_nondirectories, unlock_two_nondirectories

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 14:15:36 -07:00
Simon Glass
4dd4cfcc71 ext4l: Add mmp.c to the build
Add support for multi-mount protection.

Use ext4_uboot.h compatibility layer and add stubs for:
- init_utsname() - returns static node name "u-boot"
- sb_start_write/sb_end_write - no-op stubs

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 14:15:36 -07:00
Simon Glass
f8f6570a77 ext4l: Add migrate.c to the build
Add extent migration support for write operations.

Use the ext4_uboot.h compatibility layer instead of Linux headers.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 14:15:36 -07:00
Simon Glass
5c428be137 jbd2: Add transaction.c to the build
Add transaction.c to the jbd2 Makefile and update includes to use the
ext4l compatibility layer.

Add stubs for various functions needed by transaction.c including
atomic_add_return, prepare_to_wait_exclusive, rwsem_acquire_read,
hrtimer functions, and JBD2 trace stubs.

Remove JBD2 transaction function stubs that are now provided by
transaction.c.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 14:15:36 -07:00
Simon Glass
81d8264b76 jbd2: Add revoke.c to the build
Add revoke.c to the jbd2 Makefile and update its includes to use the
compatibility layer.

Add stubs for hash_64 and __find_get_block_nonatomic()

Remove JBD2 revoke function stubs that are now provided by revoke.c.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 14:15:36 -07:00
Simon Glass
87f7e16bfa jbd2: Add recovery.c to the build
Add recovery.c to the jbd2 Makefile and update includes to use the ext4l
compatibility layer.

Add stubs for revoke.c functions that recovery.c depends on and tweak a
few so things build.

Fix sync_blockdev to return int instead of void.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 14:15:36 -07:00
Simon Glass
525cff9f6c jbd2: Add journal.c to the build
Add journal.c to the jbd2 Makefile and update includes to use the
ext4l compatibility layer.

Add stubs for functions from recovery.c, revoke.c, and transaction.c
that journal.c depends on.

Remove JBD2 function stubs from stub.c that are now provided by
journal.c.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 14:15:36 -07:00
Simon Glass
c113b81eab jbd2: Add checkpoint.c to the build
Update checkpoint.c includes to use ext4_uboot.h compatibility layer.
Add jbd2/Makefile and include jbd2 in the build via fs/Makefile

Add necessary stubs and definitions:
- JBD2 trace stubs (trace_jbd2_checkpoint, etc.)
- mutex_lock_io, write_dirty_buffer, spin_needbreak stubs
- bd_dev field to struct block_device
- Temporary JBD2 function stubs until other jbd2 files are added

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 14:15:36 -07:00
Simon Glass
33ba48ad14 jbd2: Add journal.c from Linux
Add the JBD2 journaling layer core journal management from the
Linux 6.18 kernel ext4 filesystem driver.

journal.c handles:
- Journal initialisation and destruction
- Superblock management
- Journal thread (kjournald2) operations
- Block-mapping for journal storage
- Feature flag management
- Journal format versioning
- Fast-commit support infrastructure

This file provides the main journal_t structure management and
is the entry point for creating and destroying journals.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 14:15:36 -07:00
Simon Glass
d2feaa01d8 jbd2: Add transaction.c from Linux
Add the JBD2 journaling layer transaction management from the
Linux 6.18 kernel ext4 filesystem driver.

transaction.c handles:
- Transaction lifecycle (start, stop, restart)
- Handle management for filesystem operations
- Buffer attachment to transactions
- Transaction state machine
- Credit reservation and accounting
- Metadata and data buffer journaling

This is the core transaction API that ext4 uses to ensure
atomic updates to filesystem metadata.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 14:15:36 -07:00
Simon Glass
c5bf8fcdf2 jbd2: Add recovery.c and commit.c from Linux
Add the JBD2 journaling layer recovery and commit functionality
from the Linux 6.18 kernel ext4 filesystem driver.

recovery.c handles:
- Journal recovery after unclean shutdown
- Transaction replay and verification
- Descriptor block parsing
- Revoke block processing

commit.c handles:
- Transaction commit processing
- Descriptor block writing
- Data and metadata buffer submission
- Checksum calculation for journal blocks

These files are needed for journal integrity and crash recovery in the
ext4 filesystem.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 14:15:36 -07:00
Simon Glass
83206febed jbd2: Add checkpoint.c and revoke.c from Linux
Add the JBD2 journaling layer checkpoint and revoke functionality
from the Linux 6.18 kernel ext4 filesystem driver.

checkpoint.c handles:
- Log space management and checkpointing
- Buffer flushing and cleanup
- Transaction checkpoint processing

revoke.c handles:
- Block revocation for journal recovery
- Revoke record management
- Hash table for revoked blocks

These files are part of the JBD2 (Journaling Block Device 2) layer
that provides transaction support for ext4.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 14:15:36 -07:00
Simon Glass
717c508ac9 ext4l: Add fast_commit.c to build
Add the fast commit module (fast_commit.c) to the build. This implements
ext4's fast commit journaling feature for improved performance.

Stubs added for:
- Wait bit operations (DEFINE_WAIT_BIT, bit_waitqueue, etc.)
- Dentry name snapshot operations
- Fast commit trace functions
- JBD2 fast commit functions (jbd2_fc_get_buf, jbd2_fc_begin_commit, etc.)
- Dentry allocation (d_alloc, d_drop)
- get_current_ioprio, wake_up_bit
- REQ_IDLE, REQ_PREFLUSH block I/O flags

Move name_snapshot struct definition after qstr is defined.

Remove fast commit stub functions now implemented in fast_commit.c.

Series-to: concept
Cover-letter:
ext4l: Add more ext4 files to the build (part E)
This adds more files to the build. Most are fairly small but some still
require a fair few additions to ext4_uboot.h and the stub.c files.

At this point, we are close to having all the files in place, so can
move on to actually making ext4 work.
END

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 11:36:34 +00:00
Simon Glass
6447413a63 ext4l: Add readpage.c to build
Add the readpage module (readpage.c) to the build. This implements
ext4's page reading infrastructure for reading file data.

Stubs added for:
- mempool operations (mempool_t, mempool_alloc, etc.)
- folio read operations (folio_end_read, folio_set_mappedtodisk)
- fscrypt read operations (fscrypt_decrypt_bio, etc.)
- fsverity operations (fsverity_verify_bio, etc.)
- readahead operations (readahead_count, readahead_folio)
- prefetchw and block_read_full_folio

Remove ext4_mpage_readpages stub now implemented in readpage.c.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 11:36:34 +00:00
Simon Glass
4b5ee06af7 ext4l: Add page-io.c to build
Add the page I/O module (page-io.c) to the build. This implements
ext4's asynchronous page writeback infrastructure.

Stubs added for:
- bio structure and related operations
- folio_iter for bio iteration
- refcount operations (mapped to atomic)
- fscrypt bounce folio operations
- folio writeback operations
- writeback control operations
- i_write_hint member to inode struct

Remove stub functions now implemented in page-io.c:
- ext4_io_submit_init, ext4_init_io_end
- ext4_io_submit, ext4_put_io_end_defer
- ext4_put_io_end, ext4_alloc_io_end_vec

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 11:36:34 +00:00
Simon Glass
593b2d9dd4 ext4l: Add mballoc.c to build
Add the multiblock allocator (mballoc.c) to the build. This implements
the ext4 block allocation routines.

Stubs added for:
- Per-CPU operations (simplified to single-threaded)
- XArray operations
- RCU list operations
- Block device properties
- Various trace functions
- Atomic operations (atomic_sub, atomic64_sub, atomic_inc_return)
- WARN_RATELIMIT, folio_get, array_index_nospec
- seq_operations for procfs
- DEFINE_RAW_FLEX macro

Remove stub functions that are now properly implemented:
- ext4_mb_new_blocks
- ext4_free_blocks
- ext4_discard_preallocations
- ext4_mb_mark_bb

Add ext4_fc_replay_check_excluded stub for fast commit replay.
Add file member to struct seq_file for procfs compatibility.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 11:36:34 +00:00
Simon Glass
00009659d9 ext4l: Add inline.c to build
Add the ext4 inline data implementation file to the build.

Add stubs to ext4_uboot.h:
- FGP_WRITEBEGIN flag (combined from FGP_LOCK | FGP_WRITE | FGP_CREAT |
  FGP_STABLE)
- kmap_local_folio, kunmap_local for memory mapping
- folio_zero_tail, folio_zero_segment for folio zeroing
- mapping_gfp_mask for address space GFP mask

Remove obsolete inline data stubs from stub.c that are now provided
by inline.c.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 11:36:34 +00:00
Simon Glass
c9c040e276 ext4l: Add xattr.c to build
Add the ext4 extended attributes core implementation file to the build.

Add stubs and definitions to ext4_uboot.h:
- inode_get_ctime_sec, inode_get_mtime_sec, inode_set_ctime,
  inode_set_atime, inode_set_mtime functions
- WARN_ONCE, pr_warn_once macros
- lockdep_assert_held_read stub
- struct mb_cache, struct mb_cache_entry and mb_cache_* function stubs
- xattr_handler_can_list, xattr_prefix stubs
- I_MUTEX_* constants and inode_lock_nested stub
- PF_MEMALLOC_NOFS constant
- struct mnt_idmap definition and nop_mnt_idmap declaration
- kvmalloc macro
- dquot_alloc_space_nodirty, dquot_free_space_nodirty,
  dquot_alloc_block, dquot_free_block declarations

Add stub implementations:
- nop_mnt_idmap global
- dquot_* functions for quota operations

Remove obsolete xattr stubs from stub.c that are now provided by xattr.c.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 11:36:34 +00:00
Simon Glass
841d3a5b40 ext4l: Add namei.c to build
Add directory name operations (lookup, create, link, unlink, symlink,
mkdir, rmdir, mknod, rename, tmpfile) to the ext4l filesystem.

Add stubs for:
- fscrypt name operations (match, prepare symlink/link/rename)
- Dentry operations (d_splice_alias, d_obtain_alias, d_instantiate, etc)
- Fast commit tracking functions
- Inline directory functions
- Fileattr get/set

Extend inode_operations struct with directory operation members.
Add permission mode constants (S_IRWXUGO) and rename flags.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 11:36:34 +00:00
Simon Glass
1345cf686d ext4l: Add symlink.c to build
Add symlink.c which provides symlink inode operations.

Changes needed:
- Add ext4_uboot.h include to symlink.c
- Add delayed_call struct and set_delayed_call macro
- Add kfree_link definition
- Add nd_terminate_link helper function
- Add get_link member to inode_operations struct
- Add simple_get_link function for fast symlinks
- Add i_link field to struct inode
- Add fscrypt_get_symlink and fscrypt_symlink_getattr stubs
- Add ext4_read_inline_link stub
- Remove ext4_symlink_inode_operations and
  ext4_fast_symlink_inode_operations stubs from stub.c

Drop some duplicate declarations in ext4_uboot.h

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 11:36:34 +00:00
Simon Glass
0519a66f3d ext4l: Add fsync.c to build
Add fsync.c which provides filesystem sync operations.

Changes needed:
- Add ext4_uboot.h include to fsync.c
- Remove redundant Linux header includes
- Add trace_ext4_sync_file_enter/exit stubs
- Add dentry operation stubs (d_find_any_alias, dget_parent)
- Add sync operation stubs (sync_mapping_buffers, sync_inode_metadata,
  generic_buffers_fsync_noflush, file_write_and_wait_range,
  file_check_and_advance_wb_err)
- Add jbd2_trans_will_send_data_barrier stub
- Remove ext4_sync_file stub from stub.c (now in fsync.c)

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 11:36:34 +00:00
Simon Glass
b45cae614c ext4l: Add file.c to build
Add file.c which provides file operations for ext4l filesystem.

Changes needed for file.c support:
- Add i_writecount and i_rwsem fields to struct inode
- Add IOMAP_DIO_* flags to linux/iomap.h
- Add vm_operations_struct definition
- Add VM flags (VM_SHARED, VM_HUGEPAGE, etc.)
- Add vm_area_desc and pipe_inode_info structures
- Add FMODE_* flags and SEEK_HOLE/SEEK_DATA to linux/fs.h
- Add vfsmount, path structs and f_path to struct file
- Add inode_trylock*, lockdep_assert_held_write macros
- Add filemap_fault, filemap_map_pages stubs
- Add inode_operations struct definition
- Add various stubs: d_path, fscrypt_file_open, fsverity_file_open,
  dquot_file_open, sb_start_intwrite_trylock, ext4_listxattr

Simplify ext4_file_operations and ext4_file_inode_operations
initializers to use only the members defined in U-Boot's structs.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-21 11:36:34 +00:00
Simon Glass
3b4667ed88 ext4l: Add super.c to build
Add super.c to the ext4l Makefile and provide the infrastructure
needed to compile it:

- Add stubs for block device operations (bdev_file_open_by_dev,
  bdev_fput, bdev_getblk, submit_bh, trylock_buffer)
- Add stubs for NFS export helpers (generic_fh_to_dentry/parent)
- Add stubs for filesystem operations (sync_filesystem, dquot_suspend)
- Add stubs for string operations (strreplace, strtomem_pad)
- Add stubs for memory allocation (alloc_inode_sb, kvzalloc)
- Add stubs for ratelimit, workqueue, and trace functions
- Add fs_context and fs_parameter structures for mount options
- Add blk_holder_ops structure for block device holder operations
- Add pragma to suppress unused function/variable warnings
- Add __maybe_unused to __init/__exit macros in init.h

The only change to super.c itself is replacing the Linux kernel
includes with the U-Boot compatibility header ext4_uboot.h.

Series-to: concept
Cover-letter:
ext4l: Add more ext4 files to the build (part D)
This series continues the ext4l port by adding super.c to the build. The
super.c file contains the superblock operations and filesystem
registration code from the kernel's ext4 driver.

To support this effort compilation, this series adds numerous stubs and
compatibility shims for Linux kernel interfaces not available in
U-Boot, including block device operations, filesystem context
handling, NFS export helpers, and various utility functions.

In particular, fs/ext4l/ext4_uboot.h contains a lot of U-Boot specific
declarations and stubs, with fs/ext4l/stub.c containing various others.

The goal is to eventually have a fully functional ext4 implementation
ported from Linux that can be used for both reading and writing ext4
filesystems in U-Boot.
END

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-20 14:09:14 -07:00
Simon Glass
5f4cc9eb3c ext4l: Add dir.c to build
Add dir.c to the Makefile and provide necessary stubs:
- Replace Linux includes with ext4_uboot.h
- Add fscrypt directory operation stubs
- Add readahead, inode version, and dir_emit stubs
- Add struct file_operations with needed members
- Add generic_read_dir, ext4_llseek, ext4_htree_fill_tree stubs
- Add ext4_ioctl, ext4_sync_file, ext4_dirblock_csum_verify stubs

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-20 14:09:14 -07:00
Simon Glass
e3f8042575 ext4l: Add inode.c to build
Add inode.c to the Makefile with minimal changes:
- Replace Linux kernel includes with ext4_uboot.h
- Add cast in ext4_inode_peek_iversion() to fix const qualifier warning
- Add __maybe_unused to variables in ext4_print_free_blocks()

Update ext4_uboot.h with additional stubs needed by inode.c:
- address_space_operations: add migrate_folio, swap_activate members,
  fix write_begin/write_end/writepages signatures
- Add buffer_migrate_folio, buffer_migrate_folio_norefs, noop_dirty_folio

Add stub functions in stub.c for inode.c dependencies:
- Inline data: ext4_try_to_write_inline_data, ext4_generic_write_inline_data,
  ext4_write_inline_data_end
- xattr: ext4_xattr_delete_inode, ext4_xattr_inode_array_free
- JBD2: jbd2_inode_cache, jbd2_journal_try_to_free_buffers,
  jbd2_journal_init_jbd_inode

Also add required stub headers:
- linux/mpage.h - multi-page I/O stub
- linux/rmap.h - reverse mapping stub
- linux/atomic.h - atomic operations stub

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-20 14:09:14 -07:00
Simon Glass
14253d1733 ext4l: Add kiocb, iov_iter structures and IOCB_* constants
Add infrastructure needed for file.c and other VFS-integrated files:

- Add struct kiocb (kernel I/O control block)
- Add struct iov_iter forward declaration
- Add IOCB_DIRECT, IOCB_NOWAIT, IOCB_ATOMIC constants
- Add iov_iter_truncate, iov_iter_count, iov_iter_alignment stubs
- Remove ext4_init_acl macro (provided by acl.h)

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-20 14:09:14 -07:00
Simon Glass
8558bdc0e2 ext4l: Add xattr_user.c and xattr_hurd.c
Add xattr_user.c and xattr_hurd.c to the ext4l build:

- Update includes to use ext4_uboot.h
- Add d_sb member to struct dentry
- Add XATTR_HURD_PREFIX to linux/xattr.h

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-20 14:09:14 -07:00
Simon Glass
5e40f1668d ext4l: Add xattr_trusted.c
Add xattr_trusted.c to the ext4l build with necessary changes:

- Update xattr_trusted.c includes to use ext4_uboot.h
- Add xattr.h include to ialloc.c for ext4_init_security
- Remove duplicate ext4_init_security declaration from ext4_uboot.h
  (now provided by xattr.h inline stub)
- Add ext4_xattr_get and ext4_xattr_set stubs

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-20 14:09:14 -07:00
Simon Glass
42df586aeb ext4l: Add orphan.c and required support
Add orphan.c to the ext4l build and fix various build issues:

- Add atomic_inc/atomic_dec macros to ext4_uboot.h
- Add s_flags member to struct super_block and SB_RDONLY constant
- Add bdev_read_only() stub function
- Add kvfree() and kvmalloc_array() to linux/slab.h
- Add stub functions for orphan.c: ext4_reserve_inode_write,
  ext4_superblock_csum_set, ext4_mark_iloc_dirty, ext4_truncate,
  ext4_feature_set_ok, ext4_bread
- Fix orphan.c to use U-Boot include pattern
- Remove linux/atomic.h include from buffer_head.h (types provided
  by ext4_uboot.h)
- Add kunit/static_stub.h and linux/nospec.h stub headers
- Simplify seq_file.h macros

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-20 14:09:14 -07:00
Simon Glass
c29defa81d ext4l: Add stubs for xattr functions used by ialloc.c
Add stub declarations and implementations for xattr functions that
ialloc.c calls but which are defined in xattr.c (not yet compiled):
- __ext4_xattr_set_credits
- ext4_init_security

Add declarations to ext4_uboot.h and implementations to stub.c.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-20 14:09:13 -07:00
Simon Glass
390a94ee47 ext4l: Fix unused variable warnings in extents_status.c
Mark variables as __maybe_unused where they are only used in macro
calls that expand to no-ops in U-Boot's single-threaded environment:
- tree in ext4_es_try_to_merge_left/right
- es_stats in ext4_seq_es_shrinker_info_show
- ei in ext4_clear_inode_es, ext4_remove_pending, ext4_is_pending

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-20 14:09:13 -07:00
Simon Glass
60a16564a1 ext4l: Add extents_status.c compilation support
Add the extent status tree implementation to the ext4l build. This
module tracks extent status in memory to support delayed allocation
and SEEK_DATA/SEEK_HOLE operations.

Changes:
- Add extents_status.o to Makefile
- Add include guard to acl.h
- Add shrinker, ktime, and ratelimit stubs to ext4_uboot.h
- Guard iomap definitions in ext4_uboot.h when iomap.h is included
- Guard dquot macros when quotaops.h is included
- Remove stub functions now provided by extents_status.c
- Add ext4_da_release_space/update_reserve_space stubs

Series-to: u-boot
Cover-letter:
ext4l: Adjust some of the smaller files (part C)
This series makes various changes to allow some of the ext4l files to
compile successfully.

It provides a basic Kconfig to allow selecting ext4l (ext4 from Linu)
instead of the existing ext4 implementation.

To reduce the large number of include/linux files somewhat and to avoid
exceesive diffs against the Linux files, a new ext4_uboot.h header is
created. This will expand over time.
END

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-18 12:34:17 -07:00
Simon Glass
f04cd9dbc2 ext4l: Add extents.c compilation support
Add extents.c (extent handling) to the build and provide stubs.

Changes to extents.c:
- Replace Linux includes with ext4_uboot.h

Changes to ext4_uboot.h:
- Add __GFP_MOVABLE, __GFP_FS memory allocation flags
- Add FIEMAP_EXTENT_* flags for fiemap operations
- Add FALLOC_FL_* flags for fallocate operations
- Add O_SYNC flag and struct file with f_mapping
- Add struct iomap and iomap_ops for I/O mapping
- Add IOMAP_* type constants
- Add struct fiemap_extent_info and FIEMAP_FLAG_* constants
- Add i_blkbits member to inode struct

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-18 12:34:17 -07:00
Simon Glass
334ad928b4 ext4l: Add balloc.c compilation support
Add balloc.c (block allocation) to the build and provide stubs.

Changes to balloc.c:
- Replace Linux includes with ext4_uboot.h

Changes to mballoc.h:
- Replace Linux includes with ext4_uboot.h

Changes to ext4_uboot.h:
- Add REQ_META, REQ_PRIO, REQ_RAHEAD block I/O request flags
- Add CAP_SYS_ADMIN, CAP_SYS_RESOURCE capability stubs
- Add capable() stub that always returns true
- Add s_id member to super_block struct

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-18 12:34:17 -07:00
Simon Glass
ff44e2dbb4 ext4l: Add ext4_jbd2.c compilation support
Add ext4_jbd2.c to the build and provide the necessary stubs. To avoid
build warnings while we build out the required interfacing, start a new
stub.c file containing empty functions.

Changes to ext4_jbd2.c:
- Remove trace/events/ext4.h include (not needed)
- Stub out ext4_check_bdev_write_error() since U-Boot lacks async
  I/O error tracking
- Add return after BUG() to silence non-void function warning

Changes to ext4_jbd2.h:
- Include ext4_uboot.h instead of linux/fs.h

Changes to ext4_uboot.h:
- Add sb_writers struct and SB_FREEZE constants
- Add _RET_IP_ macro
- Add mapping_large_folio_support() stub
- Add WARN_ON_ONCE/WARN_ON as proper stubs
- Add BUG(), might_sleep(), sb_rdonly() stubs
- Add trace function stubs
- Add buffer operation stubs (wait_on_buffer, mark_buffer_dirty, etc.)
- Add inode_needs_sync stub
- Include linux/sched.h for current task

Changes to include/linux/buffer_head.h:
- Add inline bh_*_bit functions for buffer state management
- Use bh_ prefixed functions in BUFFER_FNS/TAS_BUFFER_FNS macros

Changes to include/linux/fs.h:
- Add bd_disk to block_device struct

Changes to include/linux/workqueue.h:
- Fix flush_work macro to avoid unused value warning

Add stub functions to interface.c for jbd2 journal functions:
- jbd2__journal_start, jbd2_journal_stop
- jbd2_journal_free_reserved, jbd2_journal_start_reserved
- jbd2_journal_extend, jbd2_journal_get_write_access
- jbd2_journal_set_triggers, jbd2_journal_forget
- jbd2_journal_revoke, jbd2_journal_get_create_access
- jbd2_journal_dirty_metadata
- __ext4_error, __ext4_std_error, ext4_decode_error

Keep full Linux jbd2.h with compatibility header includes.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-18 12:34:17 -07:00
Simon Glass
5ed072d603 linux: Move mutex definitions to linux/mutex.h
Move mutex definitions from compat.h to a dedicated mutex.h header,
matching the Linux structure.

U-Boot is single-threaded so mutexes are no-ops. The new header provides
struct mutex and mutex_init/lock/unlock stubs.

Update compat.h to include linux/mutex.h.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-18 12:34:17 -07:00
Simon Glass
4c245023bb ext4l: Add hash.c compilation support
Add hash.c to the ext4l build with required compatibility headers.

Create ext4_uboot.h with minimal definitions needed for hash.c:
- rol32() rotation function
- struct inode and super_block stubs
- struct qstr and dx_hash_info for directory hashing
- DX_HASH_* constants and EXT4_HTREE_EOF_32BIT
- fscrypt stub functions (encryption not supported)
- ext4_warning macros (stubbed out)

Modify hash.c to use ext4_uboot.h instead of Linux kernel headers.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-18 12:34:17 -07:00
Simon Glass
778701861a ext4l: Plumb in the Kconfig
Update Kconfig options so that CONFIG_EXT4L can be enabled.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-18 12:34:16 -07:00
Simon Glass
7c5788a85d ext4l: Add CONFIG_FS_EXT4L build infrastructure
Add the basic build infrastructure for the ext4l filesystem:

- Add FS_EXT4L Kconfig option in fs/ext4l/Kconfig
- Add ext4l to fs/Kconfig and fs/Makefile
- Add fstype_info entry in fs_legacy.c with unsupported stubs
- Add minimal interface.c with stub probe/close functions

This allows sandbox to build with CONFIG_FS_EXT4L=y. The filesystem
doesn't work yet - all operations return unsupported.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-18 12:34:16 -07:00
Simon Glass
f90fcc5d04 ext4l: Extract module declarations into their own file
Create include/linux/module.h with stub definitions for kernel module
support. U-Boot doesn't use loadable modules, so these are no-ops.

Includes:
- THIS_MODULE, try_module_get(), module_put()
- module_init(), module_exit()
- module_param() and variants
- MODULE_* macros (LICENSE, AUTHOR, DESCRIPTION, etc.)

Update compat.h to include module.h and remove duplicate definitions.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-17 14:01:22 +00:00
Simon Glass
5ce331eb7e ext4l: bring in Kconfig and Makefile
Copy Kconfig and Makefile from Linux v6.18 fs/ext4 directory.

- Kconfig: configuration options for ext4
- Makefile: build rules

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 13:19:59 +00:00
Simon Glass
00e5dc76b5 ext4l: bring in xattr files
Copy xattr.c, xattr.h, xattr_hurd.c, xattr_security.c, xattr_trusted.c,
and xattr_user.c from Linux v6.18 fs/ext4 directory.

These files implement extended attribute support for ext4:
- xattr.c/h: core xattr implementation
- xattr_hurd: Hurd translator xattr handler
- xattr_security: security label xattr handler
- xattr_trusted: trusted xattr handler
- xattr_user: user xattr handler

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 13:19:59 +00:00
Simon Glass
98ddbdae46 ext4l: bring in resize, symlink, sysfs, truncate, verity, and readpage
Copy resize.c, symlink.c, sysfs.c, truncate.h, verity.c, and readpage.c
from Linux v6.18 fs/ext4 directory.

- resize: online filesystem resize support
- symlink: symbolic link operations
- sysfs: sysfs attribute interface
- truncate.h: truncate-related declarations
- verity: fs-verity support
- readpage: page reading operations

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 13:19:59 +00:00
Simon Glass
1d6c60270f ext4l: bring in migrate, mmp, move_extent, orphan, and page-io
Copy migrate.c, mmp.c, move_extent.c, orphan.c, and page-io.c from
Linux v6.18 fs/ext4 directory.

- migrate: migration between indirect and extent mapping
- mmp: multi-mount protection
- move_extent: extent moving ioctl support
- orphan: orphan inode handling
- page-io: page I/O operations

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 13:19:59 +00:00
Simon Glass
096fea33ba ext4l: bring in inode-test, ioctl, and mballoc headers
Copy inode-test.c, ioctl.c, mballoc.h, and mballoc-test.c from Linux
v6.18 fs/ext4 directory.

- inode-test: KUnit tests for inode timestamp handling
- ioctl: filesystem ioctl handlers
- mballoc.h: multiblock allocator header
- mballoc-test: KUnit tests for multiblock allocator

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 13:19:59 +00:00
Simon Glass
4b9dfbed5f ext4l: bring in indirect and inline
Copy indirect.c and inline.c from Linux v6.18 fs/ext4 directory.

- indirect: indirect block mapping for ext2/ext3 compatibility
- inline: inline data support for small files stored in inode

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 13:19:59 +00:00
Simon Glass
1e271714d9 ext4l: bring in file, fsmap, and ialloc
Copy file.c, fsmap.c, fsmap.h, and ialloc.c from Linux v6.18 fs/ext4
directory.

- file: file operations (open, read, write, mmap, etc.)
- fsmap: filesystem block mapping for GETFSMAP ioctl
- ialloc: inode allocation

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 13:19:59 +00:00
Simon Glass
9295071662 ext4l: bring in ext4_jbd2 and fast_commit
Copy ext4_jbd2.c, ext4_jbd2.h, fast_commit.c, and fast_commit.h from
Linux v6.18 fs/ext4 directory.

- ext4_jbd2: ext4-specific JBD2 journal interface wrappers
- fast_commit: fast commit journal optimization

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 13:19:59 +00:00