On Thu, Oct 02, 2025 at 06:04:07PM +0200, Daniel Kiper wrote:
> On Thu, Oct 02, 2025 at 02:46:20PM +0800, Michael Chang via Grub-devel wrote:
> > 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 <[email protected]>
> > Reviewed-by: Neal Gompa <[email protected]>
> > ---
> > 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. */
>
> {(ENV_BTRFS_OFFSET >> GRUB_DISK_SECTOR_BITS) - 1, 1}, /* Overflow guard. */
> {(ENV_BTRFS_OFFSET >> GRUB_DISK_SECTOR_BITS), 1}, /* Environment block.
> */
> {(ENV_BTRFS_OFFSET >> GRUB_DISK_SECTOR_BITS) + 1, 1}, /* Overflow guard. */
Yes, that makes it clearer. Will do the change.
>
> > {GRUB_DISK_KiB_TO_SECTORS (1024) - 1, 1}, /*
> > Overflow guard. */
> > {0, 0} /*
> > Array terminator. */
>
> Plus comments from patch #1...
Sure, no problem.
>
> And could you add a patch which updates outdated link to the Btrfs
> documentation just before btrfs_head variable?
Thanks for spotting that. Of course I can do it.
Thanks,
Michael
>
> Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel