๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.bugs.dist
Article #4880

Bug#1154248: grub2: please backport upstream "fs/fshelp: Coalesce contiguous file blocks" (3-4x faster whole-file reads)

#4880
From: Paul Menzel
Date: Tue, 17 Nov 2026 20:00
76 lines
4658 bytes
Source: grub2
Version: 2.14-5
Severity: wishlist
Tags: patch fixed-upstream


Dear Debian folks,


AI disclaimer: Assisted by claude-opus-5.5.

tl;dr: Please backport commit 5f05a74ab [1][2] for much faster reads 
from disk.

---

Please consider backporting upstream commit 5f05a74ab ("fs/fshelp: 
Coalesce contiguous file blocks") [1][2]. It was committed after the 
grub-2.16 tag, so neither 2.14-5 (unstable) nor 2.16-1 (experimental) 
has it. It applies to both without changes.

Without it, grub_fshelp_read_file() calls grub_disk_read() once per file 
system block, so a file on ext4 reaches the disk driver in 32 KiB pieces 
(one disk cache entry each), even when the file is contiguous on disk. 
With it, contiguous blocks are merged into one request, up to the 
driverโ€™s max_agglomerate (640 KiB for efidisk).

This matters for commands that read a whole file in one grub_file_read() 
call: loading the initrd (also through the LoadFile2 protocol), loading 
the kernel, chainloader, and every file that a verifier such as the tpm 
module reads at open. Commands that read in small chunks, like hashsum 
or cmp, do not benefit.

Measurements, QEMU/OVMF with KVM, x86_64-efi, ext4 /boot, 61 MiB initrd 
in one extent, `time chainloader $f` (reads the whole file in one call, 
then fails at LoadImage), three runs each, in seconds:

     disk         2.14-5               2.14-5 + 5f05a74ab
     NVMe         0.286  0.276  0.207  0.124  0.062  0.064
     virtio-blk   0.260  0.198  0.210  0.113  0.049  0.045
     AHCI         1.131  1.237  1.128  0.465  0.346  0.343

With `set debug=efidisk`, stock 2.14-5 issues 1953 reads of 0x40 sectors 
(32 KiB) for this file. With the backport it issues 197 reads: 97 of 
0x4c0 sectors (608 KiB), 99 of 0x40 sectors and one of 0x2c0 sectors.

Both trees were built from the Debian source package with `./configure 
--target=x86_64 --with-platform=efi`; the only difference is 5f05a74ab. 
The image embeds this configuration:

       serial --unit=0 --speed=115200
       terminal_output serial
       search --no-floppy --fs-uuid --set=root <UUID of /boot>
       set f=/initrd.img-7.3.3+deb14-amd64
       time chainloader $f
       time chainloader $f
       time chainloader $f
       reboot

Upstream follow-up cd106688f ("fs: Clamp agglomerated read size") [3][4] 
fixes a possible 32-bit overflow in the same computation (Coverity CID 
914067, 914068). It does not apply to 2.14 without changes, because it 
touches files 2.14 lacks (disk/nvme.c) or has in a different form. For 
64-bit targets 5f05a74ab alone is fine; for i386 the cast to grub_size_t 
in fshelp.c from cd106688f should come along.


Kind regards,

Paul


[1]: https://gitlab.freedesktop.org/gnu-grub/grub/-/commit/5f05a74ab
[2]: https://gitlab.freedesktop.org/gnu-grub/grub/-/merge_requests/256
[3]: https://gitlab.freedesktop.org/gnu-grub/grub/-/commit/cd106688f
[4]: https://gitlab.freedesktop.org/gnu-grub/grub/-/merge_requests/308
Technical Details
Message-ID: <O0xvr-cvZH-5@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news-fra.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news-fra.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod
From: Paul Menzel <pmenzel@molgen.mpg.de>
Newsgroups: linux.debian.bugs.dist
Subject: Bug#1154248: grub2: please backport upstream "fs/fshelp: Coalesce contiguous file blocks" (3-4x faster whole-file reads)
Date: Tue, 17 Nov 2026 21:00:01 +0100
Message-ID: <O0xvr-cvZH-5@gated-at.bofh.it>
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org  Tue Nov 17 19:55:07 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: -1.451
Reply-To: Paul Menzel <pmenzel@molgen.mpg.de>, 1154248@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: pkg-grub-devel@alioth-lists.debian.net
X-Debian-Pr-Message: report 1154248
X-Debian-Pr-Package: src:grub2
X-Debian-Pr-Keywords: fixed-upstream patch
X-Debian-Pr-Source: grub2
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-US
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/2003187
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 76
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Tue, 17 Nov 2026 20:52:29 +0100
X-Original-Message-ID: <a6678b50-d51e-41f5-a1f5-855b757ce040@molgen.mpg.de>