From patchwork Tue Jan 20 23:43:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1721 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768952715; bh=Z6rhaIQT4vgq21VAw8UHexxO0eFUFYzMLP7UEeyiB9w=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=L8upFZxnsGjIyxtAn9+3QsNKFnY9bXQDtsvYsn9XmpBn6LHEmqd/WNZjwvHeKAP5n kcxNokLLUAKduRDlu9i8Ews7m8U4At4w9sn6j5IMtqZf5r7LcPtTypR5V0qBMd45nZ nNkKqK4NsdVULJi2cZ+/9/hsUFikbrRvN6MaljJlwQikFzQormcXWWcT3WT8ouVwn9 uhdV1f2SNA4OSKd/ggz1NRrRULyRDC0xy2WRbKzY5/yc1yzrlcW4DIBceshXANvN8G WlwjGJg4mfhfz6zHgsc3xIx3ifYmQwiF3E0HylYC4eqVPgnNK0j1zs7b5EQSTVa0Mr SE1Xo+gELGhcA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D71D5695B5 for ; Tue, 20 Jan 2026 16:45:15 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id wrJwfEIl4SJS for ; Tue, 20 Jan 2026 16:45:15 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768952713; bh=Z6rhaIQT4vgq21VAw8UHexxO0eFUFYzMLP7UEeyiB9w=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=QnrSO/dBFLq28TKehqf7DcdeSUtll+JEdVkSIZLmjii4UXd0DFt7WBPsb4S5gSLjI kuvj7X2TvCCxxflbJBwUKlZXV4jjZAoQllXdhphd6oZ2yf+mHIseX46c0aa3NG9Ehm 8WsSprwGsiplynom7f3KGUqjAHklxqZocmsaqOCY/HkaJh36gWMHEi6U2GrIZ8Lemm 8b754qPSXoukst2fA4dggYm8jmWTyeLzQpVOh1TfDECx4jUqKKObjxVD9fIhUOp8GF jtS9bg2svW8ecj9q55KPACl88qSWAyBjL7IlDRbpwwOo5AxDb8TCNI+872qLgN33Br trF8wou0eYjXg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CFC0969597 for ; Tue, 20 Jan 2026 16:45:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768952710; bh=cmzkjcxfDijF7/HgZcz38ML9+aBwJrhasuWFVZHF6fs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IseSzpHx6frHfUjkd/+ySGgIIdn1eVRdTcDJwqPNQGHcKLhI2Onw7PYFTu9X0yfKy YY4gPPOdRp12bLsXmxK5TTR/HSYZBe4iPRvfKr+cDPwAUnw4/fhQRJs5UCcmS3CkjF xe/vmYPrUGB7UC8eTEJNq3GH+NnIjWVa8Kutc9GCcqUMdRTfCzG+UI6zUwH11Eg+pq VLsPesk5Q/lkz7gRmF1QpNvHJWKNfK2+ffF27sKTvR/JtnjpLlLCa0gRRTWBpm0X4c h5/NuIR9I8v1tXe9m53KpwbhKOSwl3ppvwJ05Y+0X5Hm0Bny9yPNVTi94ff+1hyElt 3Lu4fIrJeawdw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5682269555; Tue, 20 Jan 2026 16:45:10 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id TU1hHq1QwGZX; Tue, 20 Jan 2026 16:45:10 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768952704; bh=6cUseMsoEG67F624QDCM8+as0MLYpoNIzwhW5j9wo5M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ugrCPCJmdq6FZN63fRaw7l8TETQsUX1BNYE4QIqxOvV6tLz+eJdNNOv3GjxrpyULl rIvVSDbJlG+3MgOe5oAIGdIvFuOfuW+qAxTQ6aOGqDYo9FAuyHrvD94sGGZv9A9ct2 GA70pSCJhRPFfWadW4vGIrB1Ac/eEXpu7WOH25ozc8vBzE01hCxpmTyOmQ1qkxiL4o nT1nRx+nig666qqjl2IZvNVfNbV8Hl8kEGdJI8CNpdgebtcpNIQOV3lWdC4IiKWAIC qhU5AKyfur83hEOznWtA8CmLfOeLFMlov8uOBg260rEIISJNDgo/AWaiQAKG6nLvK/ XknllLyT6T3+Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0AA4C69597; Tue, 20 Jan 2026 16:45:03 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:43:31 -0700 Message-ID: <20260120234344.495605-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260120234344.495605-1-sjg@u-boot.org> References: <20260120234344.495605-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: GEBZGWPR6GM6HX77CAHZWM7NKPLKMZ72 X-Message-ID-Hash: GEBZGWPR6GM6HX77CAHZWM7NKPLKMZ72 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 11/17] ext4l: Move buffer operations to linux/buffer_head.h List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Move buffer-related operations to linux/buffer_head.h: - Buffer cache lookup: sb_find_get_block(), sb_find_get_block_nonatomic(), __find_get_block_nonatomic() - Buffer dirty operations: sync_dirty_buffer(), mark_buffer_dirty(), mark_buffer_dirty_inode(), write_dirty_buffer() - Buffer allocation: alloc_buffer_head(), free_buffer_head(), sb_getblk(), __getblk(), sb_getblk_gfp(), getblk_unmovable() - Buffer read: bh_read(), bh_read_nowait(), bh_readahead_batch() - Other: bh_uptodate_or_lock(), submit_bh() declaration Also move IS_DIRSYNC() and IS_NOSEC() to linux/fs.h with the other inode flag checking macros. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 44 ++++++++++++------------------------- include/linux/buffer_head.h | 41 ++++++++++++++++++++++++++++++++++ include/linux/fs.h | 2 ++ 3 files changed, 57 insertions(+), 30 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 8a2d18ccaf5..4ec4d713eb4 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -189,10 +189,7 @@ /* Trace stubs are now in ext4_trace.h */ -/* Buffer operations - wait_on_buffer, lock_buffer, unlock_buffer etc are in linux/buffer_head.h */ -#define mark_buffer_dirty_inode(bh, i) sync_dirty_buffer(bh) -#define mark_buffer_dirty(bh) sync_dirty_buffer(bh) -struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); +/* Buffer operations are in linux/buffer_head.h */ /* wait_on_bit_io is now in linux/wait_bit.h */ /* inode_needs_sync is in linux/fs.h */ @@ -225,9 +222,7 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); /* Random number functions - use linux/random.h */ #include -/* Buffer cache operations */ -#define sb_find_get_block(sb, block) ((struct buffer_head *)NULL) -#define sync_dirty_buffer(bh) submit_bh(REQ_OP_WRITE, bh) +/* Buffer cache operations - sb_find_get_block, sync_dirty_buffer are in linux/buffer_head.h */ /* Time functions - ktime_get_real_seconds, time_before32 are in linux/time.h */ @@ -240,7 +235,7 @@ extern struct inode *new_inode(struct super_block *sb); #define insert_inode_locked(inode) (0) #define unlock_new_inode(inode) do { } while (0) #define clear_nlink(inode) do { } while (0) -#define IS_DIRSYNC(inode) ({ (void)(inode); 0; }) +/* IS_DIRSYNC is in linux/fs.h */ /* fscrypt_prepare_new_inode, fscrypt_set_context are in ext4_fscrypt.h */ @@ -619,9 +614,7 @@ struct dx_hash_info { /* rwsem_is_locked is in linux/rwsem.h */ -/* Buffer operations */ -#define sb_getblk_gfp(sb, blk, gfp) sb_getblk((sb), (blk)) -#define bh_uptodate_or_lock(bh) (1) +/* Buffer operations - sb_getblk_gfp, bh_uptodate_or_lock are in linux/buffer_head.h */ /* ext4_read_bh is stubbed in interface.c */ /* Inode locking stubs are in linux/fs.h */ @@ -639,8 +632,7 @@ struct dx_hash_info { #define generic_atomic_write_valid(iocb, from) ({ (void)(iocb); (void)(from); 0; }) #define vfs_setpos(file, offset, maxsize) ({ (void)(file); (void)(maxsize); (offset); }) -/* Security checks - no security in U-Boot */ -#define IS_NOSEC(inode) (1) +/* IS_NOSEC is in linux/fs.h */ /* Filemap operations and fault handlers are in linux/pagemap.h */ @@ -778,7 +770,7 @@ void mapping_clear_folio_cache(struct address_space *mapping); /* try_to_writeback_inodes_sb is in linux/writeback.h */ /* Buffer operations - additional */ -#define getblk_unmovable(bdev, block, size) sb_getblk(bdev->bd_super, block) +/* getblk_unmovable is in linux/buffer_head.h */ #define create_empty_buffers(f, s, flags) ({ (void)(f); (void)(s); (void)(flags); (struct buffer_head *)NULL; }) /* bh_offset returns offset of b_data within the folio */ #define bh_offset(bh) ((bh)->b_folio ? \ @@ -1094,8 +1086,8 @@ void end_buffer_write_sync(struct buffer_head *bh, int uptodate); /* blockgroup_lock - use linux/blockgroup_lock.h */ #include +/* submit_bh is in linux/buffer_head.h */ /* Buffer submission stubs - declarations for stub.c implementations */ -int submit_bh(int op_flags, struct buffer_head *bh); struct buffer_head *bdev_getblk(struct block_device *bdev, sector_t block, unsigned int size, gfp_t gfp); int trylock_buffer(struct buffer_head *bh); @@ -1298,11 +1290,7 @@ struct buffer_head *__bread(struct block_device *bdev, sector_t block, unsigned /* schedule_timeout_uninterruptible, need_resched are in linux/sched.h */ -/* Block device operations */ -#define sb_find_get_block_nonatomic(sb, block) \ - ({ (void)(sb); (void)(block); (struct buffer_head *)NULL; }) -#define __find_get_block_nonatomic(bdev, block, size) \ - ({ (void)(bdev); (void)(block); (void)(size); (struct buffer_head *)NULL; }) +/* sb_find_get_block_nonatomic, __find_get_block_nonatomic are in linux/buffer_head.h */ #define bdev_discard_granularity(bdev) \ ({ (void)(bdev); 0U; }) @@ -1377,9 +1365,9 @@ bool __folio_start_writeback(struct folio *folio, bool keep_write); /* get_current_ioprio is in linux/ioprio.h */ /* JBD2 checkpoint.c stubs */ -#define mutex_lock_io(m) mutex_lock(m) -#define write_dirty_buffer(bh, flags) sync_dirty_buffer(bh) -#define spin_needbreak(l) ({ (void)(l); 0; }) +/* mutex_lock_io is in linux/mutex.h */ +/* write_dirty_buffer is in linux/buffer_head.h */ +/* spin_needbreak is in linux/spinlock.h */ /* JBD2 commit.c stubs (folio_trylock is in linux/pagemap.h) */ #define clear_bit_unlock(nr, addr) clear_bit(nr, addr) @@ -1388,7 +1376,7 @@ bool __folio_start_writeback(struct folio *folio, bool keep_write); #define filemap_fdatawait_range_keep_errors(m, s, e) \ ({ (void)(m); (void)(s); (void)(e); 0; }) #define crc32_be(crc, p, len) crc32(crc, p, len) -void free_buffer_head(struct buffer_head *bh); +/* free_buffer_head is in linux/buffer_head.h */ /* ext4l support functions (support.c) */ void ext4l_crc32c_init(void); @@ -1415,9 +1403,7 @@ struct disk_partition *ext4l_get_partition(void); #define cond_resched_lock(lock) do { (void)(lock); } while (0) /* JBD2 journal.c stubs */ -struct buffer_head *alloc_buffer_head(gfp_t gfp_mask); -struct buffer_head *__getblk(struct block_device *bdev, sector_t block, - unsigned int size); +/* alloc_buffer_head, __getblk are in linux/buffer_head.h */ int bmap(struct inode *inode, sector_t *block); /* seq_file operations for /proc - stubs */ @@ -1438,9 +1424,7 @@ loff_t seq_lseek(struct file *f, loff_t o, int w); /* lockdep_init_map and lock_class_key are in linux/lockdep.h */ /* Block device operations for journal.c */ -int bh_read(struct buffer_head *bh, int flags); -#define bh_read_nowait(bh, flags) bh_read(bh, flags) -#define bh_readahead_batch(n, bhs, f) do { (void)(n); (void)(bhs); (void)(f); } while (0) +/* bh_read, bh_read_nowait, bh_readahead_batch are in linux/buffer_head.h */ #define truncate_inode_pages_range(m, s, e) \ do { (void)(m); (void)(s); (void)(e); } while (0) #define blkdev_issue_discard(bdev, s, n, gfp) \ diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 591f2ec1cbb..3e5893ab99d 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -187,6 +187,37 @@ void __brelse(struct buffer_head *bh); #define unlock_buffer(bh) clear_buffer_locked(bh) #define test_clear_buffer_dirty(bh) ({ (void)(bh); 0; }) +/* Buffer I/O submission - implemented in ext4l/stub.c */ +int submit_bh(int op_flags, struct buffer_head *bh); + +/* Buffer read functions - implemented in ext4l/support.c */ +int bh_read(struct buffer_head *bh, int flags); +#define bh_read_nowait(bh, flags) bh_read(bh, flags) +#define bh_readahead_batch(n, bhs, f) do { (void)(n); (void)(bhs); (void)(f); } while (0) + +/* + * Buffer dirty operations. + * In U-Boot we write buffers synchronously, so marking dirty writes immediately. + */ +#define sync_dirty_buffer(bh) submit_bh(REQ_OP_WRITE, (bh)) +#define mark_buffer_dirty(bh) sync_dirty_buffer(bh) +#define mark_buffer_dirty_inode(bh, i) sync_dirty_buffer(bh) +#define write_dirty_buffer(bh, flags) sync_dirty_buffer(bh) + +/* Buffer uptodate check - always returns true (buffer assumed uptodate) */ +#define bh_uptodate_or_lock(bh) (1) + +/* Buffer allocation functions - implemented in ext4l */ +struct super_block; +struct buffer_head *alloc_buffer_head(gfp_t gfp_mask); +void free_buffer_head(struct buffer_head *bh); +struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); +struct buffer_head *__getblk(struct block_device *bdev, sector_t block, + unsigned int size); +#define sb_getblk_gfp(sb, blk, gfp) sb_getblk((sb), (blk)) +#define getblk_unmovable(bdev, block, size) \ + sb_getblk((bdev)->bd_super, (block)) + /* * Folio migration stubs - U-Boot doesn't support memory migration */ @@ -227,4 +258,14 @@ static inline void end_buffer_read_sync(struct buffer_head *bh, int uptodate) unlock_buffer(bh); } +/* + * Buffer cache lookup stubs - U-Boot doesn't maintain a buffer cache + */ +#define sb_find_get_block(sb, block) \ + ({ (void)(sb); (void)(block); (struct buffer_head *)NULL; }) +#define sb_find_get_block_nonatomic(sb, block) \ + ({ (void)(sb); (void)(block); (struct buffer_head *)NULL; }) +#define __find_get_block_nonatomic(bdev, block, size) \ + ({ (void)(bdev); (void)(block); (void)(size); (struct buffer_head *)NULL; }) + #endif /* _LINUX_BUFFER_HEAD_H */ diff --git a/include/linux/fs.h b/include/linux/fs.h index a6ad309e5c8..431dc0c513a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -305,6 +305,8 @@ enum { #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND) #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE) #define IS_CASEFOLDED(inode) (0) /* Case-folding not supported */ +#define IS_DIRSYNC(inode) ({ (void)(inode); 0; }) +#define IS_NOSEC(inode) (1) /* No security checks in U-Boot */ /* inode_needs_sync - check if inode needs synchronous writes (always false) */ #define inode_needs_sync(inode) (0)