grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Chang via Grub-devel <grub-devel@gnu.org>
To: The development of GNU GRUB <grub-devel@gnu.org>
Cc: Michael Chang <mchang@suse.com>, Neal Gompa <ngompa13@gmail.com>,
	Marta Lewandowska <mlewando@redhat.com>
Subject: [PATCH v2 7/9] btrfs: add environment block to reserved header area
Date: Mon, 15 Sep 2025 17:08:46 +0800	[thread overview]
Message-ID: <20250915090848.131937-8-mchang@suse.com> (raw)
In-Reply-To: <20250915090848.131937-1-mchang@suse.com>

This patch reserves space for the GRUB environment block inside the
Btrfs header. The block is placed at an offset of 256 KiB from the start
of the device and occupies one sector. To protect the space, overflow
guard sectors are placed before and after the reserved block.

The Btrfs header already defines regions for bootloader use. By adding
this entry, GRUB gains a fixed and safe location to store the
environment block without conflicting with other structures in the
header.

Signed-off-by: Michael Chang <mchang@suse.com>
---
 grub-core/fs/btrfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
index 7bf8d922f..d35ff5fa5 100644
--- a/grub-core/fs/btrfs.c
+++ b/grub-core/fs/btrfs.c
@@ -2341,7 +2341,7 @@ struct embed_region {
 
 static const struct {
   struct embed_region available;
-  struct embed_region used[6];
+  struct embed_region used[7];
 } btrfs_head = {
   .available = {0, GRUB_DISK_KiB_TO_SECTORS (1024)}, /* The first 1 MiB. */
   .used = {
@@ -2349,6 +2349,7 @@ static const struct {
     {GRUB_DISK_KiB_TO_SECTORS (64) - 1, 1},                        /* Overflow guard. */
     {GRUB_DISK_KiB_TO_SECTORS (64), GRUB_DISK_KiB_TO_SECTORS (4)}, /* 4 KiB superblock. */
     {GRUB_DISK_KiB_TO_SECTORS (68), 1},                            /* Overflow guard. */
+    {(ENV_BTRFS_OFFSET >> GRUB_DISK_SECTOR_BITS) - 1, 3},          /* Environment Block. */
     {GRUB_DISK_KiB_TO_SECTORS (1024) - 1, 1},                      /* Overflow guard. */
     {0, 0}                                                         /* Array terminator. */
   }
-- 
2.51.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

  parent reply	other threads:[~2025-09-15  9:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-15  9:08 [PATCH v2 0/9] Add support for external environment block on Btrfs Michael Chang via Grub-devel
2025-09-15  9:08 ` [PATCH v2 1/9] util/grub-editenv: add basic structures and probe call for external envblk Michael Chang via Grub-devel
2025-09-15  9:08 ` [PATCH v2 2/9] util/grub-editenv: add fs_envblk open helper Michael Chang via Grub-devel
2025-09-15  9:08 ` [PATCH v2 3/9] util/grub-editenv: add fs_envblk write helper Michael Chang via Grub-devel
2025-09-15  9:08 ` [PATCH v2 4/9] util/grub-editenv: wire set_variables to optional fs_envblk Michael Chang via Grub-devel
2025-09-15  9:08 ` [PATCH v2 5/9] util/grub-editenv: wire unset_variables " Michael Chang via Grub-devel
2025-09-15  9:08 ` [PATCH v2 6/9] util/grub-editenv: wire list_variables " Michael Chang via Grub-devel
2025-09-17 15:16   ` Sudhakar Kuppusamy
2025-09-15  9:08 ` Michael Chang via Grub-devel [this message]
2025-09-15  9:08 ` [PATCH v2 8/9] 00_header.in: wire grub.cfg to use env_block when present Michael Chang via Grub-devel
2025-09-15  9:08 ` [PATCH v2 9/9] docs: add Btrfs env block and special env vars Michael Chang via Grub-devel
2025-09-16 12:05 ` [PATCH v2 0/9] Add support for external environment block on Btrfs Neal Gompa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250915090848.131937-8-mchang@suse.com \
    --to=grub-devel@gnu.org \
    --cc=mchang@suse.com \
    --cc=mlewando@redhat.com \
    --cc=ngompa13@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).