On Mon, Sep 15, 2025 at 5:08 AM Michael Chang <[email protected]> wrote: > > This patch series adds support for storing the GRUB environment block in > a reserved area of the Btrfs header. On copy on write filesystems such > as Btrfs, the normal file based envblk cannot be updated safely at > runtime because block addresses are not stable. The reserved area > provides a fixed location that GRUB can write directly, allowing > commands such as grub-reboot and savedefault to work on Btrfs volumes. > > The series proceeds in small chunks to keep each change buildable and > easier to review. The first patches add new data structures and helpers > for creating, opening, and writing an environment block in the reserved > area. Later patches update set_variables, unset_variables, and > list_variables so they can use the external block when it is present. An > entry is added to the Btrfs header to reserve space at 256 KiB for the > environment block. Finally, grub.cfg is modified so that load_env and > save_env use the external block automatically when env_block is defined. > > v2: > - Define ENV_BTRFS_OFFSET as 256*1024 > - Do not conflate type and variable definitions > - Align typedef with struct declaration to follow coding style > - Use bool as the return type of is_abstraction() > - Add "if (dev->disk != NULL)" check in is_abstraction() > - Refine the loop logic in is_abstraction() tests > - Remove extra indentation and redundant lines in read_envblk_fs > - Use off_t and size_t for offset and size variables, fix similar cases > throughout > - Use explicit check "(fp == NULL)" instead of "(! fp)", fix similar > cases throughout > - Use bool for the "found" field in var_lookup_ctx > - Add documentation describing the Btrfs environment block and special > environment block variables > > Michael Chang (9): > util/grub-editenv: add basic structures and probe call for external > envblk > util/grub-editenv: add fs_envblk open helper > util/grub-editenv: add fs_envblk write helper > util/grub-editenv: wire set_variables to optional fs_envblk > util/grub-editenv: wire unset_variables to optional fs_envblk > util/grub-editenv: wire list_variables to optional fs_envblk > btrfs: add environment block to reserved header area > 00_header.in: wire grub.cfg to use env_block when present > docs: add Btrfs env block and special env vars > > docs/grub.texi | 60 ++++++ > grub-core/fs/btrfs.c | 3 +- > include/grub/fs.h | 2 + > util/grub-editenv.c | 393 ++++++++++++++++++++++++++++++++++++++- > util/grub.d/00_header.in | 26 ++- > 5 files changed, 477 insertions(+), 7 deletions(-) > > -- > 2.51.0 >
The patches look reasonable to me and things still seem to work. It is much easier to understand all the pieces with this series breakout. :) Reviewed-by: Neal Gompa <[email protected]> -- 真実はいつも一つ!/ Always, there's only one truth! _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
