1112 Commits

Author SHA1 Message Date
Ilias Apalodimas
e005799d8f lmb: Remove lmb_alloc_addr_flags()
lmb_alloc_addr() is just calling lmb_alloc_addr_flags() with LMB_NONE
There's not much we gain from this abstraction, so let's remove the
latter, add a flags argument to lmb_alloc_addr() and make the code a
bit easier to follow.

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Tested-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
(cherry picked from commit 15e0c5e390)
2025-12-24 05:17:05 -07:00
Simon Glass
60788f5431 ext4l: Add ls command support
Implement directory listing (ls) for the ext4l filesystem driver. This
includes path resolution with symlink following (limited to 8 levels to
prevent loops).

Add ext4l_ls() which uses ext4_lookup() for path resolution and
ext4_readdir() for directory enumeration. The dir_context actor callback
formats and prints each directory entry.

Export ext4_lookup() from namei.c and add declarations to ext4.h.

Add test_ls to the Python test suite, which creates a test file using
debugfs and verifies it appears in the directory listing with the
correct size.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>

Cover-letter:
ext4l: Add support for listing directoties (Part H)
This series adds directory-listing support to the ext4l filesystem
driver. It exports a few required functions from the Linux ext4 code,
fixes the dir_emit() stub to properly call the actor callback, and
implements ext4l_ls() with path resolution and symlink following.
END

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-22 16:49:47 -07:00
Simon Glass
8bafb79e32 ext4l: Fix dir_emit() to call the actor callback
The dir_emit() macro was stubbed to do nothing, which meant directory
listing would never output any entries. Replace it with a proper
inline function that calls ctx->actor() to emit each directory entry.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-22 16:49:47 -07:00
Simon Glass
7d409b8f38 ext4l: Export ext4_readdir() for directory listing
Remove the static qualifier from ext4_readdir() so it can be called
from the ext4l interface code for directory listing operations.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-22 16:49:47 -07:00
Simon Glass
d1669b342c ext4l: Add ext4l_msgs env var to print messages on mount
Add runtime control for printing ext4 messages via the ext4l_msgs
environment variable. When set to 'y' or '1', the recorded message
buffer is printed after a successful mount.

This provides a runtime alternative to the compile-time
CONFIG_EXT4L_DEBUG option.

Usage: setenv ext4l_msgs y

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-22 16:49:47 -07:00
Simon Glass
e23afbf3d4 ext4l: Add message buffer to record ext4 messages
Add a 4KB membuf to record ext4 messages for later retrieval. This
allows programmatic access to filesystem messages without requiring
CONFIG_EXT4L_DEBUG to be enabled.

- Add ext4l_msg_buf and ext4l_msg_data in interface.c
- Add ext4l_record_msg() to record messages
- Add ext4l_get_msg_buf() to access the buffer
- Modify __ext4_msg() to always record messages, print only if debug

Note that this increases the number of strings in the ext4l
implementation. For production it might be useful to make this an
option, although the messages can be quite important.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-22 16:49:47 -07:00
Simon Glass
b0caf2015b ext4l: Implement super_set_uuid() to display filesystem UUID
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>
2025-12-22 16:48:59 -07:00
Simon Glass
f27b3371eb ext4l: Document __CHAR_UNSIGNED__ behavior for directory hashing
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>
2025-12-22 16:48:59 -07:00
Simon Glass
7a130b0fc2 ext4l: Use EXT4L_PRINTF to enable ext4 diagnostic messages
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>
2025-12-22 16:48:51 -07:00
Simon Glass
a5eb8cda48 ext4l: Add write support and buffer mapping for mount
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>
2025-12-22 15:09:09 -07:00
Simon Glass
79033aebad fs: ext4l: Mount filesystems read-write
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>
2025-12-22 15:09:09 -07:00
Simon Glass
c532296ec2 ext4l: Fix format warning in mballoc.c
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>
2025-12-22 15:09:09 -07:00
Simon Glass
07d2a31287 linux: Drop duplicate atomic types from types.h
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>
2025-12-22 05:57:24 -07:00
Simon Glass
5144ac35d2 fs: ext4l: Support mounting a filesystem read-only
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>
2025-12-22 05:07:38 -07:00
Simon Glass
0553cf40c7 fs: ext4l: Add inode and bmap functions
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>
2025-12-22 05:07:02 -07:00
Simon Glass
6da1790944 fs: ext4l: Mount filesystems read-only
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>
2025-12-22 05:07:02 -07:00
Simon Glass
d328bf1ff3 fs: ext4l: Add CRC32C implementation
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>
2025-12-22 05:07:02 -07:00
Simon Glass
4b583a0eaa fs: ext4l: Use real rbtree implementation
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>
2025-12-22 05:07:02 -07:00
Simon Glass
918d0e4b8a fs: ext4l: Add CONFIG_EXT4L_DEBUG to control messages
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>
2025-12-22 05:07:02 -07:00
Simon Glass
6131797256 fs: ext4l: Add buffer_head I/O infrastructure
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>
2025-12-22 05:07:02 -07:00
Simon Glass
45a57464b2 fs: ext4l: Initialise super_block and call ext4_fill_super()
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>
2025-12-22 05:07:02 -07:00
Simon Glass
c7adfc2845 fs: ext4l: Allocate ext4_fs_context
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>
2025-12-22 05:07:02 -07:00
Simon Glass
008c189904 fs: ext4l: Allocate fs_context
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>
2025-12-22 05:07:02 -07:00
Simon Glass
aec7912398 fs: ext4l: Add super_block and block_device allocations
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>
2025-12-22 05:07:02 -07:00
Simon Glass
e19326a3dc fs: ext4l: Initialise extent status cache
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>
2025-12-22 05:07:02 -07:00
Simon Glass
9ebcae87df fs: ext4l: Initialise multi-block allocator
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>
2025-12-22 05:07:02 -07:00
Simon Glass
d1a202192f fs: ext4: Allow EXT4_WRITE with FS_EXT4L
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>
2025-12-22 05:07:02 -07:00
Simon Glass
19de128635 fs: jbd2: Add jbd2_journal_init_global() for ext4l
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>
2025-12-22 05:07:02 -07:00
Simon Glass
2ebf0b705e fs: ext4l: Use types from linux headers
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>
2025-12-22 05:07:02 -07:00
Simon Glass
0149e7e138 fs: ext4l: Add CONFIG_EXT4_JOURNAL option
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>
2025-12-22 05:07:01 -07:00
Simon Glass
e911e32822 linux: Move common types to types.h
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>
2025-12-22 05:07:01 -07:00
Simon Glass
7caf11dbaf fs: ext4l: Add minimal probe support
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>
2025-12-22 05:07:01 -07:00
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