Skip to content

Add support for external environment block on Btrfs

Michael Chang via Grub-devel grub-devel 6 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest12 patches 11 repliesIn review
  2. v512 patches 2 repliesSuperseded
  3. v412 patches 17 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v39 patches13 repliesSuperseded
v29 patches2 repliesSuperseded
v18 patches10 repliesSuperseded

Changes in v6 from the cover letter

- Move fs_envblk_spec structure typedef and variable from "btrfs: add environment block to reserved header area" into "util/grub-editenv:
add fs_envblk open helper". The fs_envblk_spec remains empty since no Btrfs area is defined yet.
- Reorder "btrfs: add environment block to reserved header area" to follow all groundwork patches, and provide the defined reserved area to fs_envblk_spec so that it becomes supported in grub-editenv.

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12misc: add z length modifier supportgrub-core/kern/misc.c+20 -03 replies
2/12tests: add z modifier printf teststests/printf_unit_test.c+10 -00 replies
3/12util/grub-editenv: add fs_envblk open helperutil/grub-editenv.c+170 -00 replies
4/12util/grub-editenv: add fs_envblk write helperutil/grub-editenv.c+37 -10 replies
5/12util/grub-editenv: wire set_variables to optional fs_envblkutil/grub-editenv.c+56 -20 replies
6/12util/grub-editenv: wire unset_variables to optional fs_envblkutil/grub-editenv.c+14 -00 replies
7/12util/grub-editenv: wire list_variables to optional fs_envblkutil/grub-editenv.c+7 -00 replies
8/12util/grub-editenv: add probe call for external envblkutil/grub-editenv.c+113 -20 replies
9/12btrfs: add environment block to reserved header areagrub-core/fs/btrfs.c include/grub/fs.h util/grub-editenv.c+19 -20 replies
10/1200_header.in: wire grub.cfg to use env_block when presentutil/grub.d/00_header.in+23 -30 replies
11/12docs: add Btrfs env block and special env varsdocs/grub.texi+60 -02 replies
12/12btrfs: update doc link for bootloader supportgrub-core/fs/btrfs.c+2 -10 replies

Reviews trailers per patch

All 12 patches have a Reviewed-by or Acked-by.

PatchNeal GompaDaniel KiperAvnish ChouhanSudhakar Kuppusamy
1/12R-b R-b
2/12R-b R-b
3/12R-b R-b
4/12R-b R-b R-b
5/12R-b R-b R-b
6/12R-b R-b R-b
7/12R-b R-b R-b R-b
8/12R-b R-b
9/12R-b
10/12R-b R-b
11/12R-b R-b
12/12R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v6 thread

Cover letter [PATCH v6 00/12] Add support for external environment block on Btrfs

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.

The first two patches are new in this series as feedback from the review to use a portable string specifier for size_t. Unfortunately the z length modifier is missing in GRUB printf routine's format specifier. The new patches add support and test case for that. In theory they can be reviewed separately.

And also yet another new patch "btrfs: update doc link for bootloader support" added at the end to address v3 review feedback.

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
v3:
- Replace !fp with explicit (fp == NULL) for clarity
- Fix missing blank line before return statement
- Fix missing space after cast operator
v4:
- Rename ENV_BTRFS_OFFSET to GRUB_ENV_BTRFS_OFFSET
- Move GRUB_ENV_BTRFS_OFFSET into "btrfs: add environment block to reserved header area"
- Adjust patch order to resolve relocated GRUB_ENV_BTRFS_OFFSET
- Add patch "btrfs: update doc link for bootloader support"
- Do better typedef
- Add heads-up comments to both fs_envblk_spec and btrfs_head that they have to stay in sync
- Fix a few places to use explicit checks for NULL, true/false etc
- Use goto labels to cleanup consistently
- Mark function names with trailing "()" in commits and comments
- Rename envblk_fs to envblk_on_block for better clarity
- Avoid redundant curly braces in if .. else if clause
- Highlight overflow guard around envioronment block in embed_region
- Rename a few functions for clarity
- Use portable printf formats for off_t and size_t
- Support z length modifier in GRUB printf format string
- Add z modifier to printf unit test
v5:
- Move fs_envblk_spec table into "btrfs: add environment block to reserved header area"
- Move "util/grub-editenv: add basic structures and probe call for external envblk" the 9th patch behind all wiring patches and rename it to "util/grub-editenv: add probe call for external envblk" as it now only does probing
- Add fs_envblk_init() to wire open helper in the base structures into patch "util/grub-editenv: add fs_envblk open helper"
- Add "Man 5 btrfs" an alternate to the doc link
v6:
- Move fs_envblk_spec structure typedef and variable from "btrfs: add environment block to reserved header area" into "util/grub-editenv:
add fs_envblk open helper". The fs_envblk_spec remains empty since no Btrfs area is defined yet.
- Reorder "btrfs: add environment block to reserved header area" to follow all groundwork patches, and provide the defined reserved area to fs_envblk_spec so that it becomes supported in grub-editenv.

Michael Chang (12):
misc: add z length modifier support
tests: add z modifier printf tests 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 util/grub-editenv: add probe call for external 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
btrfs: update doc link for bootloader support

 docs/grub.texi           |  60 ++++++
 grub-core/fs/btrfs.c     |  13 +-
 grub-core/kern/misc.c    |  20 ++
 include/grub/fs.h        |   2 +
 tests/printf_unit_test.c |  10 +
 util/grub-editenv.c      | 407 ++++++++++++++++++++++++++++++++++++++-
 util/grub.d/00_header.in |  26 ++-
 7 files changed, 529 insertions(+), 9 deletions(-)
Signature · 7 lines
2.51.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel