From patchwork Sun Dec 21 11:38:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1012 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=1766317149; bh=hLICk3F2F8YfVEo1Jm4BDak+n8E8UeFfhjek3CWbdFY=; 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=KXU1TYJbSzgiLm4iHpl5qDf2y1gjVGfchrkdUdLzRCwzqHSgICdOSip++Yh82yr2a 7qjVfbie41v25jCecsHVRIIdYDtC1VDyHoDVqvHSeLkw2y4O1idaSlDSbbxQfu45x/ VgHnTPJsi58Oy14E70KU08aMwh/01dN5Mo2+2J9Bp8Y9/EYr1QoTwTTTW19vKc3FFc Dv1VzO2JrEb0+CV0X4675WW4cpcTw/jxE39YPGYtTkCnY9n9UvsQNyilU66Gq77a15 eM9dPSw7s1WMk4XgWtaegPIkYdoYKYahLR/mDQnNxexJfMl8wGnzp2eyrtnWG8Zddp h0l8dcZYIgHbg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1A15764CEA for ; Sun, 21 Dec 2025 04:39:09 -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 NowJkACnaD9T for ; Sun, 21 Dec 2025 04:39:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766317147; bh=hLICk3F2F8YfVEo1Jm4BDak+n8E8UeFfhjek3CWbdFY=; 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=rUYImknBwpqlj9/qDx49x2Ag8DTmEtUrlfScEdhpbwrIn8EnPUNE6wUw89aMJ/KiU bsT8LvBkg0ZIT7s21bzGvl+dyBAG/kXpLzAejN/mIigkjy4fJck78fAZK8P2U5Xago 1vUdJ5bQQtn+vzqX4sk6MM7Z9clEo2aPu/AbmJ1YSI9zQProrIgxkrDvmPLSw8q31+ 4h4AUnf2b8Xjuh//SF7z+lkRY0teklcWEnyH9rbSOk4bjf1F9+zJw9oIES4obD/Wu+ RaPsQs1Xz6LhMIdKLprJZy3PhNmvn8eN5dODzgC/BQlo4zHL79Ix+k7SJMba0GRC8d MzsNFYy4HUAmw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6918A64CEE for ; Sun, 21 Dec 2025 04:39:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766317145; bh=VheEVc7KH4Go3sTvNzoYE52h5rTwuimA37b1oie73IM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QbjI6JqGlSiKqnThG/qpqqGqVM/usvqjmWhb9RJmz2BTsoqf5UgiI8Iq4TaTbvRLf FbgOe2hw+EzqYmTnVQgu4Ajqo/w7aogEyhNU4iCQz3vuWMDHuVzBYLAgHO4faHETcO pqnXxRAp2mB61m4omyUBg7v43qhnRjIefoHSaLJ4G4+K6IRNO74uEY2oQ5EADdf8/8 j6NdiisBdhIRqnLvC4EA6dt8EByhJik3pxb0kKOYZb8HB05HFoHp6jDX8eFMu74XXb k1A7EsR17IMbeB4j9BGbY86IviuiNCVTD+12HRm+vg+cf+LC8cDMpLuVHFX5OPlkGz Rt+7njJFWRo/A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 928E764CEE; Sun, 21 Dec 2025 04:39:05 -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 Zojmi7QM0udc; Sun, 21 Dec 2025 04:39:05 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766317144; bh=Q4H68KZSdcASd8CDVuwx/u7rP/DPVrv39lctgBwYgSM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fd1Ug2deH2lW6sTgUt/n/iqZhgsocBRgXsgFhRWFM6ZKu0qFgerwHIwEYuC5gbYCJ fCiPCwUEDuSUFum9ASobtKmEGpZ0Vjs3gvheKLof1hEPxametmzaQwRtQRXYLziFcv C4dP0A0oCBqiPz94hcUylYSWAUwHbEEZ5iP8JMDp2Jm5frHc2vy3BlvsPFrv+ygiNY nIXmtWDy7d5H7GUk3tlxg6c+aeiTvUg5qHtCjuiTVQvpuv9p5bRazPsDEgTnPpgNti 4x092yCJ/Ns0hfqGY6i98hGNHQfvVM3QWEKe9Ux/Fc6VifHiQD1kQw3sdjt6BNP6is xidR4vcVCxtSA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 499FA64CEA; Sun, 21 Dec 2025 04:39:04 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 21 Dec 2025 04:38:14 -0700 Message-ID: <20251221113820.812060-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251221113820.812060-1-sjg@u-boot.org> References: <20251221113820.812060-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VYA4YSSYMUDPNDIYEZNZSNZHECZHIDWO X-Message-ID-Hash: VYA4YSSYMUDPNDIYEZNZSNZHECZHIDWO 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 08/10] ext4l: Add page-io.c to build 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 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 Signed-off-by: Simon Glass --- fs/ext4l/Makefile | 2 +- fs/ext4l/ext4_uboot.h | 99 +++++++++++++++++++++++++++++++++++++++++++ fs/ext4l/page-io.c | 15 +------ fs/ext4l/stub.c | 37 ++++------------ 4 files changed, 110 insertions(+), 43 deletions(-) diff --git a/fs/ext4l/Makefile b/fs/ext4l/Makefile index dc3858165c3..506e76b959e 100644 --- a/fs/ext4l/Makefile +++ b/fs/ext4l/Makefile @@ -8,6 +8,6 @@ obj-y := interface.o stub.o obj-y += balloc.o bitmap.o block_validity.o dir.o ext4_jbd2.o extents.o \ extents_status.o file.o fsync.o hash.o ialloc.o \ indirect.o inline.o inode.o mballoc.o \ - namei.o super.o symlink.o xattr.o \ + namei.o page_io.o super.o symlink.o xattr.o \ xattr_hurd.o xattr_trusted.o \ xattr_user.o orphan.o diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 9ea3afdd798..c5895dc902a 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -834,6 +834,7 @@ struct inode { atomic_t i_writecount; /* Count of writers */ struct rw_semaphore i_rwsem; /* inode lock */ const char *i_link; /* Symlink target for fast symlinks */ + unsigned short i_write_hint; /* Write life time hint */ }; /* Inode time accessors */ @@ -1515,6 +1516,7 @@ static inline char *d_path(const struct path *path, char *buf, int buflen) /* fscrypt stubs - additional */ #define fscrypt_inode_uses_fs_layer_crypto(i) (0) #define fscrypt_decrypt_pagecache_blocks(f, l, o) ({ (void)(f); (void)(l); (void)(o); 0; }) +#define fscrypt_encrypt_pagecache_blocks(f, l, o, g) ({ (void)(f); (void)(l); (void)(o); (void)(g); (struct page *)NULL; }) #define fscrypt_zeroout_range(i, lb, pb, l) ({ (void)(i); (void)(lb); (void)(pb); (void)(l); 0; }) #define fscrypt_limit_io_blocks(i, lb, l) (l) #define fscrypt_prepare_setattr(d, a) ({ (void)(d); (void)(a); 0; }) @@ -2565,4 +2567,101 @@ struct seq_operations { #define bdev_discard_granularity(bdev) \ ({ (void)(bdev); 0U; }) +/* + * Stubs for page-io.c + */ + +/* bio_vec - segment in a bio */ +struct bio_vec { + struct page *bv_page; + unsigned int bv_len; + unsigned int bv_offset; +}; + +/* bvec_iter - iterator for bio_vec */ +struct bvec_iter { + sector_t bi_sector; + unsigned int bi_size; + unsigned int bi_idx; + unsigned int bi_bvec_done; +}; + +/* bio - block I/O structure */ +struct bio { + struct bio *bi_next; + struct block_device *bi_bdev; + unsigned long bi_opf; + unsigned short bi_flags; + unsigned short bi_ioprio; + unsigned short bi_write_hint; + int bi_status; + struct bvec_iter bi_iter; + atomic_t __bi_remaining; + void *bi_private; + void (*bi_end_io)(struct bio *); +}; + +/* folio_iter for bio iteration */ +struct folio_iter { + int i; + struct folio *folio; + size_t offset; + size_t length; +}; + +/* bio operations - stubs */ +#define bio_for_each_folio_all(fi, bio) \ + for ((fi).i = 0; (fi).i < 0; (fi).i++) +#define bio_put(bio) free(bio) +#define bio_alloc(bdev, vecs, op, gfp) ((struct bio *)calloc(1, sizeof(struct bio))) +#define submit_bio(bio) do { } while (0) +#define BIO_MAX_VECS 256 + +/* refcount operations - map to atomic */ +#define refcount_set(r, v) atomic_set((atomic_t *)(r), v) +#define refcount_dec_and_test(r) atomic_dec_and_test((atomic_t *)(r)) +#define refcount_inc(r) atomic_inc((atomic_t *)(r)) + +/* xchg - exchange value atomically */ +#define xchg(ptr, new) ({ typeof(*(ptr)) __old = *(ptr); *(ptr) = (new); __old; }) + +/* printk_ratelimited - just use regular printk */ +#define printk_ratelimited(fmt, ...) do { } while (0) + +/* mapping_set_error - record error in address_space */ +#define mapping_set_error(m, e) do { (void)(m); (void)(e); } while (0) + +/* blk_status_to_errno - convert block status to errno */ +#define blk_status_to_errno(status) (-(status)) + +/* atomic_inc - increment atomic */ +#define atomic_inc(v) ((v)->counter++) + +/* GFP_NOIO - allocation without I/O */ +#define GFP_NOIO 0 + +/* fscrypt stubs for page-io.c */ +#define fscrypt_is_bounce_folio(f) ({ (void)(f); 0; }) +#define fscrypt_pagecache_folio(f) (f) +#define fscrypt_free_bounce_page(p) do { (void)(p); } while (0) +#define fscrypt_set_bio_crypt_ctx_bh(bio, bh, gfp) \ + do { (void)(bio); (void)(bh); (void)(gfp); } while (0) +#define fscrypt_mergeable_bio_bh(bio, bh) \ + ({ (void)(bio); (void)(bh); 1; }) + +/* folio writeback operations */ +#define folio_end_writeback(f) do { (void)(f); } while (0) +#define folio_start_writeback(f) do { (void)(f); } while (0) +#define folio_start_writeback_keepwrite(f) do { (void)(f); } while (0) +bool __folio_start_writeback(struct folio *folio, bool keep_write); + +/* writeback control stubs */ +#define wbc_init_bio(wbc, bio) do { (void)(wbc); (void)(bio); } while (0) +#define wbc_account_cgroup_owner(wbc, folio, bytes) \ + do { (void)(wbc); (void)(folio); (void)(bytes); } while (0) + +/* bio operations */ +#define bio_add_folio(bio, folio, len, off) \ + ({ (void)(bio); (void)(folio); (void)(len); (void)(off); 1; }) + #endif /* __EXT4_UBOOT_H__ */ diff --git a/fs/ext4l/page-io.c b/fs/ext4l/page-io.c index 39abfeec5f3..657c6f4eedb 100644 --- a/fs/ext4l/page-io.c +++ b/fs/ext4l/page-io.c @@ -7,24 +7,11 @@ * Written by Theodore Ts'o, 2010. */ -#include +#include "ext4_uboot.h" #include -#include -#include -#include #include -#include -#include -#include #include -#include -#include -#include -#include #include -#include -#include -#include #include "ext4_jbd2.h" #include "xattr.h" diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c index ca8a2bc0f91..935e93f49f1 100644 --- a/fs/ext4l/stub.c +++ b/fs/ext4l/stub.c @@ -199,6 +199,14 @@ int ext4_fc_replay_check_excluded(struct super_block *sb, unsigned long long blk return 0; } +/* + * Stubs for page-io.c + */ +bool __folio_start_writeback(struct folio *folio, bool keep_write) +{ + return false; +} + /* ext4_read_bh is now in super.c */ /* ext4_sb_bread_nofail is now in super.c */ @@ -262,34 +270,7 @@ int ext4_fc_commit(void *journal, unsigned int tid) /* Inline data is now in inline.c */ -/* I/O submit */ -void ext4_io_submit_init(void *io, void *wbc) -{ -} - - -void *ext4_init_io_end(struct inode *inode, int gfp) -{ - return NULL; -} - -void ext4_io_submit(void *io) -{ -} - -void ext4_put_io_end_defer(void *io_end) -{ -} - -void ext4_put_io_end(void *io_end) -{ -} - -void *ext4_alloc_io_end_vec(void *io_end, unsigned long num) -{ - return NULL; -} - +/* 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)