The super_set_uuid() function was stubbed as a no-op, causing the
filesystem UUID to display as all zeros during mount. Implement it
to copy the UUID from the ext4 superblock to the VFS super_block
structure.
Before: mounted filesystem 00000000-0000-0000-0000-000000000000 r/w
After: mounted filesystem d4ddb235-df85-4963-a923-7cddc5ad9355 r/w
Add a way to read from tests as well.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add documentation explaining how ext4's directory hash algorithm
selection works based on the platform's char signedness. GCC
automatically defines __CHAR_UNSIGNED__ on platforms where char is
unsigned (e.g., ARM), which affects the hash algorithm used.
The filesystem stores the hash variant in the superblock flags,
ensuring correct operation regardless of the mounting platform.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Enable EXT4L_PRINTF when CONFIG_EXT4L_DEBUG is set so that ext4_msg()
and other diagnostic macros print full messages instead of empty
strings.
Use EXT4L_PRINTF instead of CONFIG_PRINTK since U-Boot requires CONFIG_
options to be defined in Kconfig.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add ext4l_write_block() to enable writing blocks to disk, which is
needed for ext4_commit_super() during read-write mounts. Also update
submit_bh() to call the write function and return proper error codes.
Set the BH_Mapped flag in sb_getblk() and bdev_getblk() since ext4
checks this flag in ext4_commit_super() to verify the buffer is valid.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Change sb_rdonly() to return 0 to allow read-write mounting.
This enables the filesystem to be mounted without the read-only
restriction.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Fix format warning: atomic64_t.counter is 'long' on 32-bit systems,
so cast to 'long long' for %lld format.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
The atomic types were incorrectly added to linux/types.h but they
already exist in asm-generic/atomic.h. Remove them and update ext4l
to include the correct header.
Fixes: e911e32822 ("linux: Move common types to types.h")
Series-to: concept
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Fix several issues preventing ext4_fill_super() from completing:
- Fix shrinker_alloc() to return a dummy shrinker instead of NULL
- Fix getblk_unmovable() to use sb_getblk() instead of returning NULL
- Fix mb_cache_create() to allocate a cache structure
- Implement d_make_root() to create root dentry for mount
- Add ext4_init_system_zone() call for block validity checking
- Add global task_struct for journal_info consistency
- Store super_block pointer after successful mount
The filesystem now mounts successfully in read-only mode.
Series-to: concept
Series-links: 87
Cover-letter:
fs: ext4l: Add support for mounting ext4 filesystems (part G)
This series adds the ext4l filesystem driver, which is a port of the
Linux ext4 driver to U-Boot. It allows mounting ext4 filesystems in
read-only mode.
The driver uses Linux kernel code directly where possible, with
compatibility shims to handle differences between Linux and U-Boot.
This approach makes it easier to keep the driver up to date with
upstream changes.
Key features:
- Read-only mounting of ext4 filesystems
- Support for extents, flex_bg, and other ext4 features
- Buffer cache for improved performance
- CRC32C checksums for metadata verification
END
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add inode allocation and block mapping functions:
- iget_locked() - allocate inode by number
- new_inode() - allocate new empty inode
- ext4_uboot_bmap() - map logical to physical block
- bmap() - VFS interface for block mapping
Also add i_count reference counter to struct inode.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Set sb_rdonly() to return 1 since U-Boot currently only supports
read-only filesystem access.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add ext4l_crc32c() which uses the Castagnoli polynomial (0x82F63B78)
required for ext4 checksums. The table is initialised on first mount.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Replace broken rbtree stubs with the real implementation from
lib/rbtree.c. The previous stubs had critical bugs:
- rb_link_node() only did *(rb_link) = node without initializing
rb_left and rb_right to NULL, causing crashes when traversing
the extent status tree
- rb_next/rb_prev were wrong (just returned right/left child)
- rb_insert_color was a no-op, breaking tree balancing
Include <linux/rbtree.h> and remove the conflicting struct definitions
and broken operation macros.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a Kconfig option to control ext4_msg() output. By default, mount
messages and other informational output are suppressed to reduce
console noise. Enable CONFIG_EXT4L_DEBUG to restore these messages
for debugging.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add support.c with buffer_head I/O infrastructure for ext4l:
- Buffer cache for caching buffer_heads across lookups
- Buffer allocation/free functions
- Block I/O functions (sb_getblk, sb_bread, brelse, submit_bh, bh_read)
This keeps interface.c focused on the U-Boot filesystem layer interface.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Set up essential super_block fields after allocation:
- Link bd_super back to super_block
- Set initial blocksize to 1024 (will be updated by ext4_fill_super)
- Clear flags for read-write mount
- Clear s_fs_info (will be set by ext4_fill_super)
Add the call to ext4_fill_super() which performs the actual filesystem
mount. This requires making ext4_fill_super() non-static in super.c.
Also fix an uninitialised variable warning in
ext4_journalled_submit_inode_data_buffers().
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add allocation of ext4_fs_context structure which holds mount options
and will be needed for mounting the filesystem.
Move struct ext4_fs_context definition from super.c to ext4.h so it
can be used by interface.c.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add allocation of fs_context structure which will be needed for
mounting the filesystem via ext4_fill_super().
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add allocations for super_block, block_device, and address_space
structures in ext4l_probe(). These will be needed for the full
filesystem mount operation.
Use goto-based error handling for proper cleanup on failure.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add ext4_init_es() call to initialise the extent status cache. This
is needed for ext4 to track the status of extents in memory.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Call ext4_init_mballoc() from ext4l_probe() when CONFIG_EXT4_WRITE
is enabled to initialise the multi-block allocator caches before
any write operations.
Include ext4.h to get the function declaration.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Update CONFIG_EXT4_WRITE to depend on either FS_EXT4 or FS_EXT4L,
allowing write support to be enabled for the Linux-ported ext4l
filesystem as well.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add jbd2_journal_init_global() which initializes the JBD2 journal
subsystem caches. This wraps the existing journal_init() with a
static guard to ensure it's only called once.
Call this from ext4l_probe() when CONFIG_EXT4_JOURNAL is enabled
to initialize the journal subsystem before any journal operations.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Update ext4_uboot.h to include the new linux headers instead of
defining types locally. Remove duplicate definitions of:
- MAX_JIFFY_OFFSET (now in linux/jiffies.h)
- BDEVNAME_SIZE (now in linux/blkdev.h)
- rwlock_t (now in linux/spinlock.h)
Remove rwlock_init() stub from stub.c since it's now a macro.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a config option to control whether journal (jbd2) support is
included for ext4 filesystems. This defaults to y
Update fs/Makefile to conditionally include jbd2/ based on this
config instead of FS_EXT4L.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Move ktime_t, sector_t, blkcnt_t, atomic_t, and atomic64_t to
linux/types.h to match Linux kernel header organisation.
Remove the duplicate definitions from linux/compat.h and
fs/ext4l/ext4_uboot.h since they are now in the canonical location.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a minimal ext4l probe function that:
- Reads the superblock from the block device
- Validates the ext4 magic number
- Returns proper error codes (-EINVAL, -ENOMEM, -EIO)
Create include/ext4l.h header with function declarations and
documentation. Update fs_legacy.c to use the header.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>