From: 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> --- fs/ext4l/ext4_uboot.h | 35 ++++++++ fs/ext4l/stub.c | 182 +++++++----------------------------------- fs/jbd2/Makefile | 2 +- fs/jbd2/transaction.c | 15 +--- 4 files changed, 64 insertions(+), 170 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index f43c3a999f9..e57e479a462 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -130,7 +130,9 @@ struct kobject { struct lockdep_map { int dummy; }; struct lock_class_key { int dummy; }; #define rwsem_acquire(l, s, t, i) do { } while (0) +#define rwsem_acquire_read(l, s, t, i) do { } while (0) #define rwsem_release(l, i) do { } while (0) +#define _THIS_IP_ ((unsigned long)0) /* completion - stub */ struct completion { @@ -140,6 +142,10 @@ struct completion { /* Cache alignment - stub */ #define ____cacheline_aligned_in_smp +/* Pointer check macros */ +#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 @@ -321,6 +327,8 @@ extern struct user_namespace init_user_ns; #define lock_buffer(bh) do { } while (0) #define unlock_buffer(bh) do { } while (0) #define sb_getblk(sb, block) ((struct buffer_head *)NULL) +#define test_clear_buffer_dirty(bh) ({ (void)(bh); 0; }) +#define wait_on_bit_io(addr, bit, mode) do { (void)(addr); (void)(bit); (void)(mode); } while (0) /* inode_needs_sync - stub */ #define inode_needs_sync(inode) (0) @@ -1068,6 +1076,7 @@ static inline unsigned long memweight(const void *ptr, size_t bytes) #define filemap_invalidate_lock_shared(m) do { } while (0) #define filemap_invalidate_unlock_shared(m) do { } while (0) #define filemap_write_and_wait_range(m, s, e) ({ (void)(m); (void)(s); (void)(e); 0; }) +#define filemap_fdatawrite_range(m, s, e) ({ (void)(m); (void)(s); (void)(e); 0; }) #define truncate_pagecache(i, s) do { } while (0) #define pagecache_isize_extended(i, f, t) do { } while (0) #define invalidate_mapping_pages(m, s, e) do { (void)(m); (void)(s); (void)(e); } while (0) @@ -1181,6 +1190,15 @@ static inline ktime_t ktime_sub(ktime_t a, ktime_t b) return a - b; } +static inline ktime_t ktime_add_ns(ktime_t kt, s64 ns) +{ + return kt + ns; +} + +/* hrtimer stubs */ +#define HRTIMER_MODE_ABS 0 +#define schedule_hrtimeout(exp, mode) ({ (void)(exp); (void)(mode); 0; }) + /* write lock variants */ #define write_trylock(lock) ({ (void)(lock); 1; }) @@ -2088,6 +2106,8 @@ struct fs_parse_result { #define time_after(a, b) time_before(b, a) #endif #define msecs_to_jiffies(m) ((m) * HZ / 1000) +#define jiffies_to_msecs(j) ((j) * 1000 / HZ) +#define round_jiffies_up(j) (j) /* Path lookup flags */ #define LOOKUP_FOLLOW 0x0001 @@ -2490,6 +2510,12 @@ static inline int atomic_inc_return(atomic_t *v) return ++(v->counter); } +/* atomic_add_return - add and return new value */ +static inline int atomic_add_return(int i, atomic_t *v) +{ + return (v->counter += i); +} + /* pde_data - proc dir entry data (not supported in U-Boot) */ #define pde_data(inode) ((void *)NULL) @@ -2728,6 +2754,8 @@ struct wait_bit_entry { ({ (void)(word); (void)(bit); (wait_queue_head_t *)NULL; }) #define prepare_to_wait(wq, wait, state) \ do { (void)(wq); (void)(wait); (void)(state); } while (0) +#define prepare_to_wait_exclusive(wq, wait, state) \ + do { (void)(wq); (void)(wait); (void)(state); } while (0) #define finish_wait(wq, wait) \ do { (void)(wq); (void)(wait); } while (0) @@ -2823,6 +2851,13 @@ struct wait_bit_entry { do { (void)(d); (void)(tid); (void)(stats); } while (0) #define trace_jbd2_end_commit(j, t) do { (void)(j); (void)(t); } while (0) +/* JBD2 transaction.c trace stubs */ +#define trace_jbd2_handle_start(...) do { } while (0) +#define trace_jbd2_handle_extend(...) do { } while (0) +#define trace_jbd2_handle_restart(...) do { } while (0) +#define trace_jbd2_handle_stats(...) do { } while (0) +#define trace_jbd2_lock_buffer_stall(...) do { } while (0) + /* JBD2 journal.c stubs */ #define alloc_buffer_head(gfp) ((struct buffer_head *)kzalloc(sizeof(struct buffer_head), gfp)) #define __getblk(bdev, block, size) ({ (void)(bdev); (void)(block); (void)(size); (struct buffer_head *)NULL; }) diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c index 989ae2c85c1..5448040e14c 100644 --- a/fs/ext4l/stub.c +++ b/fs/ext4l/stub.c @@ -31,75 +31,26 @@ typedef void bh_end_io_t(struct buffer_head *bh, int uptodate); /* ext4_decode_error is now in super.c */ /* - * JBD2 journal stubs + * JBD2 journal stubs - most now in transaction.c, journal.c, revoke.c */ struct jbd2_journal_handle; typedef struct jbd2_journal_handle handle_t; struct journal_s; typedef struct journal_s journal_t; -struct jbd2_buffer_trigger_type; - -handle_t *jbd2__journal_start(journal_t *journal, int nblocks, int rsv_blocks, - int revoke_records, int gfp_mask, int type, - unsigned int line_no) -{ - return NULL; -} - -int jbd2_journal_stop(handle_t *handle) -{ - return 0; -} - -void jbd2_journal_free_reserved(handle_t *handle) -{ -} - -int jbd2_journal_start_reserved(handle_t *handle, int type, unsigned int line) -{ - return 0; -} - -int jbd2_journal_extend(handle_t *handle, int nblocks, int revoke_records) -{ - return 0; -} - -int jbd2_journal_get_write_access(handle_t *handle, struct buffer_head *bh) -{ - return 0; -} - -void jbd2_journal_set_triggers(struct buffer_head *bh, - struct jbd2_buffer_trigger_type *type) -{ -} - -int jbd2_journal_forget(handle_t *handle, struct buffer_head *bh) -{ - return 0; -} +/* jbd2__journal_start is now in transaction.c */ +/* jbd2_journal_stop is now in transaction.c */ +/* jbd2_journal_free_reserved is now in transaction.c */ +/* jbd2_journal_start_reserved is now in transaction.c */ +/* jbd2_journal_extend is now in transaction.c */ +/* jbd2_journal_get_write_access is now in transaction.c */ +/* jbd2_journal_set_triggers is now in transaction.c */ +/* jbd2_journal_forget is now in transaction.c */ /* jbd2_journal_revoke is now in revoke.c */ - -int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh) -{ - return 0; -} - -int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) -{ - return 0; -} - +/* jbd2_journal_get_create_access is now in transaction.c */ +/* jbd2_journal_dirty_metadata is now in transaction.c */ /* jbd2_journal_force_commit_nested is now in journal.c */ - -int jbd2__journal_restart(void *handle, int nblocks, int revoke_records, - int gfp_mask) -{ - return 0; -} - +/* jbd2__journal_restart is now in transaction.c */ /* jbd2_trans_will_send_data_barrier is now in journal.c */ /* @@ -232,61 +183,22 @@ struct ext4_iloc; /* Xattr functions are now in xattr.c */ -/* More JBD2 stubs */ -int jbd2_journal_inode_ranged_write(void *handle, struct inode *inode, - loff_t start, loff_t len) -{ - return 0; -} - - +/* jbd2_journal_inode_ranged_write is now in transaction.c */ /* ext4_read_bh_lock is now in super.c */ - -/* Fast commit */ /* ext4_fc_commit is now in fast_commit.c */ - /* ext4_force_commit is now in super.c */ - /* Inline data is now in inline.c */ - /* I/O submit stubs are now in page-io.c */ - -/* JBD2 ordered truncate */ -int jbd2_journal_begin_ordered_truncate(void *ji, loff_t new_size) -{ - return 0; -} - -void jbd2_journal_invalidate_folio(void *journal, void *folio, - unsigned long off, unsigned int len) -{ -} - +/* jbd2_journal_begin_ordered_truncate is now in transaction.c */ +/* jbd2_journal_invalidate_folio is now in transaction.c */ /* jbd2_log_wait_commit is now in journal.c */ - /* ext4_fc_track_range is now in fast_commit.c */ - -/* JBD2 journal update locking */ -void jbd2_journal_lock_updates(void *journal) -{ -} - -void jbd2_journal_unlock_updates(void *journal) -{ -} - +/* jbd2_journal_lock_updates is now in transaction.c */ +/* jbd2_journal_unlock_updates is now in transaction.c */ /* jbd2_journal_flush is now in journal.c */ - - /* ext4_fc_track_inode is now in fast_commit.c */ /* ext4_fc_init_inode is now in fast_commit.c */ - -/* JBD2 */ -int jbd2_journal_inode_ranged_wait(void *handle, struct inode *inode, - loff_t start, loff_t len) -{ - return 0; -} +/* jbd2_journal_inode_ranged_wait is now in transaction.c */ /* Inline data functions are now in inline.c */ @@ -309,12 +221,7 @@ int jbd2_journal_inode_ranged_wait(void *handle, struct inode *inode, /* xattr stubs are now in xattr.c */ /* jbd2_inode_cache is now in journal.c */ - -int jbd2_journal_try_to_free_buffers(journal_t *journal, struct folio *folio) -{ - return 1; -} - +/* jbd2_journal_try_to_free_buffers is now in transaction.c */ /* jbd2_journal_init_jbd_inode is now in journal.c */ /* ext4_read_inline_link is now in inline.c */ @@ -759,54 +666,25 @@ void dquot_free_block(struct inode *inode, loff_t nr) /* __jbd2_update_log_tail is now in journal.c */ /* jbd2_journal_grab_journal_head is now in journal.c */ /* jbd2_journal_put_journal_head is now in journal.c */ - -void jbd2_journal_free_transaction(void *transaction) -{ -} - +/* jbd2_journal_free_transaction is now in transaction.c */ /* jbd2_log_start_commit is now in journal.c */ - /* jbd2_journal_get_descriptor_buffer is now in journal.c */ /* jbd2_journal_update_sb_log_tail is now in journal.c */ /* jbd2_free is now in journal.c */ - /* journal_tag_bytes is now in journal.c */ - -void jbd2_journal_wait_updates(void *journal) -{ -} - -void jbd2_journal_refile_buffer(void *journal, void *jh) -{ -} - +/* jbd2_journal_wait_updates is now in transaction.c */ +/* jbd2_journal_refile_buffer is now in transaction.c */ /* jbd2_clear_buffer_revoked_flags is now in revoke.c */ /* jbd2_journal_switch_revoke_table is now in revoke.c */ /* jbd2_journal_write_revoke_records is now in revoke.c */ - -void jbd2_buffer_abort_trigger(void *jh, void *triggers) -{ -} - +/* jbd2_buffer_abort_trigger is now in transaction.c */ /* jbd2_journal_next_log_block is now in journal.c */ /* jbd2_journal_write_metadata_buffer is now in journal.c */ /* jbd2_descriptor_block_csum_set is now in journal.c */ /* jbd2_update_log_tail is now in journal.c */ - -void jbd2_journal_file_buffer(void *jh, void *transaction, int type) -{ -} - -void __jbd2_journal_refile_buffer(void *jh) -{ -} - +/* jbd2_journal_file_buffer is now in transaction.c */ +/* __jbd2_journal_refile_buffer is now in transaction.c */ /* cond_resched_lock is now a macro in ext4_uboot.h */ - -/* - * JBD2 stubs for journal.c - functions from transaction.c - */ - /* jbd2_journal_recover is now in recovery.c */ /* jbd2_journal_skip_recovery is now in recovery.c */ /* jbd2_journal_destroy_revoke is now in revoke.c */ @@ -815,11 +693,5 @@ void __jbd2_journal_refile_buffer(void *jh) /* jbd2_journal_set_revoke is now in revoke.c */ /* jbd2_journal_clear_revoke is now in revoke.c */ /* jbd2_journal_destroy_revoke_table is now in revoke.c */ - -void jbd2_buffer_frozen_trigger(void *jh, void *mapped_data, void *triggers) -{ -} - -void __jbd2_journal_file_buffer(void *jh, void *transaction, int type) -{ -} +/* jbd2_buffer_frozen_trigger is now in transaction.c */ +/* __jbd2_journal_file_buffer is now in transaction.c */ diff --git a/fs/jbd2/Makefile b/fs/jbd2/Makefile index 5501c364abc..820417d36ca 100644 --- a/fs/jbd2/Makefile +++ b/fs/jbd2/Makefile @@ -3,4 +3,4 @@ # Makefile for JBD2 journaling layer (used by ext4l) # -obj-y := checkpoint.o commit.o journal.o recovery.o revoke.o +obj-y := checkpoint.o commit.o journal.o recovery.o revoke.o transaction.o diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index 3e510564de6..a524f490c79 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -14,21 +14,8 @@ * filesystem). */ -#include <linux/time.h> -#include <linux/fs.h> +#include "../ext4l/ext4_uboot.h" #include <linux/jbd2.h> -#include <linux/errno.h> -#include <linux/slab.h> -#include <linux/timer.h> -#include <linux/mm.h> -#include <linux/highmem.h> -#include <linux/hrtimer.h> -#include <linux/backing-dev.h> -#include <linux/bug.h> -#include <linux/module.h> -#include <linux/sched/mm.h> - -#include <trace/events/jbd2.h> static void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh); static void __jbd2_journal_unfile_buffer(struct journal_head *jh); -- 2.43.0