From patchwork Tue Apr 21 18:34:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2231 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=1776796557; bh=E5ZG1rkLoGc5BsKGl+1nLbj96Ae/wlirzpKiaTuv3b4=; 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=jYPGDo2FdcApG+Uy1EJaR4bflcpE4c2KbALZg/jZjyYyHLFb5aTyrUiBiNxXn6bqZ 49zxy2lNlhioiR5B0x6In1r8C74EC1DQSKmtw9NS1ZWhQb/pNSaMEbTt4MUY7/CHss CJW0pD8vQzaSH9i/x95E4R0ABW/ATug3PLWSCm/U= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6707B6A601 for ; Tue, 21 Apr 2026 12:35:57 -0600 (MDT) 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 bWP9UZP5rIO7 for ; Tue, 21 Apr 2026 12:35:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796557; bh=E5ZG1rkLoGc5BsKGl+1nLbj96Ae/wlirzpKiaTuv3b4=; 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=jYPGDo2FdcApG+Uy1EJaR4bflcpE4c2KbALZg/jZjyYyHLFb5aTyrUiBiNxXn6bqZ 49zxy2lNlhioiR5B0x6In1r8C74EC1DQSKmtw9NS1ZWhQb/pNSaMEbTt4MUY7/CHss CJW0pD8vQzaSH9i/x95E4R0ABW/ATug3PLWSCm/U= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 50F656A603 for ; Tue, 21 Apr 2026 12:35:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796554; bh=7aLV8u2kobfE1fsRBnoO7vHay3h9x84jFe2yxx35E90=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mraMBEYZzBSk5hb4mbZZUkNWe3B52xYyMbn7+K5lhViuaxr7ij4X1VdqY4SB3E3DO oPp20BADVYaeHVf/X3kC8kbxGlQTzTx4COvxNeHqJ0HUf9xLy9tIPcdFPJP3o9WqN7 5gpjTv933pVQBhVtBg8jCA5cI4UXRphvgvlKesbs= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ED9066A601; Tue, 21 Apr 2026 12:35:54 -0600 (MDT) 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 ukbh_aAWZ8dX; Tue, 21 Apr 2026 12:35:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776796550; bh=TLjfsP1AhEjfK2GHBhVEVVQRgP9TuzEemroyR5E2qes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VNfZlPFlBnkv3Enz8q0lfGPQDYG5o3fwEgWgHQdJnCHv/DTnxfsoplj76fAaXTaNY EOaWVXf8dlemMAXw++5a7wJwmIl2X5jHOXbKUPEZUCRnVA+gVD0WwmooZVtASrCveU VVtEHddlUUj5GVyPQp/2oeyjamIQhVq9IcizLOR4= Received: from u-boot.org (unknown [174.51.25.52]) by mail.u-boot.org (Postfix) with ESMTPSA id 1A1486A528; Tue, 21 Apr 2026 12:35:50 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 21 Apr 2026 12:34:45 -0600 Message-ID: <20260421183511.2044469-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260421183511.2044469-1-sjg@u-boot.org> References: <20260421183511.2044469-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: SI3GCLBWAEFZ3A2YD2DHPKOKXRFBN5AA X-Message-ID-Hash: SI3GCLBWAEFZ3A2YD2DHPKOKXRFBN5AA 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/16] fs: isofs: Read file content via the uncached path 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 isofs_read() streams whole files through isofs_bread(), which goes through sb_bread() and therefore populates the shared buffer-head cache. For a multi-megabyte kernel or initrd this exhausts the U-Boot malloc heap after a few megabytes (each cached block costs roughly sizeof(buffer_head) + sizeof(folio) + blocksize) and the read fails partway through with -EIO before the file is fully read. Introduce isofs_bread_uncached() alongside isofs_bread() and use it for file content reads in the interface layer. Directory traversal still uses the cached path because repeated metadata lookups benefit from it; only the streaming file read changes. Signed-off-by: Simon Glass --- fs/isofs/inode.c | 8 ++++++++ fs/isofs/interface.c | 9 +++++++-- fs/isofs/isofs.h | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index 3d9e9301a9f..7639471edf2 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c @@ -811,6 +811,14 @@ struct buffer_head *isofs_bread(struct inode *inode, sector_t block) return sb_bread(inode->i_sb, blknr); } +struct buffer_head *isofs_bread_uncached(struct inode *inode, sector_t block) +{ + sector_t blknr = isofs_bmap(inode, block); + if (!blknr) + return NULL; + return sb_bread_uncached(inode->i_sb, blknr); +} + static int isofs_read_folio(struct file *file, struct folio *folio) { return mpage_read_folio(folio, isofs_get_block); diff --git a/fs/isofs/interface.c b/fs/isofs/interface.c index 6f07f9951f1..5f8cc749e08 100644 --- a/fs/isofs/interface.c +++ b/fs/isofs/interface.c @@ -478,8 +478,13 @@ int isofs_read(const char *filename, void *buf, loff_t offset, loff_t len, block = offset / blksize; blk_off = offset % blksize; - /* Read the block using isofs_bread (handles block mapping) */ - bh = isofs_bread(inode, block); + /* + * Use the uncached read path: the buffer cache is shared + * across the whole VFS layer, and populating it from a + * streaming file read of an arbitrarily large file would + * exhaust the malloc heap before the read completes. + */ + bh = isofs_bread_uncached(inode, block); if (!bh) return -EIO; diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h index 95d85f58733..7382bcc62b5 100644 --- a/fs/isofs/isofs.h +++ b/fs/isofs/isofs.h @@ -126,6 +126,22 @@ int get_acorn_filename(struct iso_directory_record *, char *, struct inode *); extern struct dentry *isofs_lookup(struct inode *, struct dentry *, unsigned int flags); extern struct buffer_head *isofs_bread(struct inode *, sector_t); + +/** + * isofs_bread_uncached() - Read a file block without populating the cache + * + * Mirrors isofs_bread() but uses sb_bread_uncached() so the block is freed + * the moment the caller drops its reference. Useful for streaming large + * files (e.g. the casper kernel/initrd), where caching every block would + * exhaust the U-Boot malloc heap long before the read completes. + * + * @inode: Inode the block belongs to + * @block: Logical block number within the inode + * Return: buffer_head with the block contents, or NULL if the logical + * block does not map to a disk block + */ +extern struct buffer_head *isofs_bread_uncached(struct inode *inode, + sector_t block); extern int isofs_get_blocks(struct inode *, sector_t, struct buffer_head **, unsigned long); struct inode *__isofs_iget(struct super_block *sb,