1
0
mirror of https://git.FreeBSD.org/src.git synced 2026-06-02 11:24:32 +00:00

loader.efi: try all ZFS pools found by efi_zfs_probe()

Remove global uint64_t pool_guid and instead iterate over all pools that
efizfs_get_zfsinfo_list() provides.

The global pool_guid used to mark that we have constructed a ZFS pool and
the pool label that was used for that was stored on a partition that is
the EFI image device handle.

First problem here is that it is too restrictive.  If the very first
device to probe is a spare member of a pool, it will be used to
instantiate a pool but (pd->pd_handle == boot_img->DeviceHandle) won't be
true, thus global pool_guid won't be populated and ZFS boot won't be
tried.

Second problem is that potentially we may find several pools, and all
should be tried to boot.  Note that the code for that is already here -
efizfs_get_zfsinfo_list() is imported by efizfs.h but was not used until
now.

Reviewed by: imp
Differential Revision:	https://reviews.freebsd.org/D55094
This commit is contained in:
Gleb Smirnoff
2026-02-26 17:57:26 -07:00
committed by Warner Losh
parent 86dc5dd0b2
commit d69fc3a9dc
3 changed files with 7 additions and 13 deletions
-2
View File
@@ -49,8 +49,6 @@ typedef struct zfsinfo
uint64_t zi_pool_guid;
} zfsinfo_t;
extern uint64_t pool_guid;
void efi_zfs_probe(void);
EFI_HANDLE efizfs_get_handle_by_guid(uint64_t);
bool efizfs_get_guid_by_handle(EFI_HANDLE, uint64_t *);
+1 -8
View File
@@ -40,8 +40,6 @@
#ifdef EFI_ZFS_BOOT
static zfsinfo_list_t zfsinfo;
uint64_t pool_guid;
zfsinfo_list_t *
efizfs_get_zfsinfo_list(void)
{
@@ -111,13 +109,8 @@ efi_zfs_probe(void)
STAILQ_FOREACH(pd, &hd->pd_part, pd_link) {
snprintf(devname, sizeof(devname), "%s%dp%d:",
efipart_hddev.dv_name, hd->pd_unit, pd->pd_unit);
guid = 0;
if (zfs_probe_dev(devname, &guid, false) == 0) {
if (zfs_probe_dev(devname, &guid, false) == 0)
insert_zfs(pd->pd_handle, guid);
if (pd->pd_handle == boot_img->DeviceHandle)
pool_guid = guid;
}
}
}
}
+6 -3
View File
@@ -588,6 +588,9 @@ find_currdev(bool do_bootmgr, char *boot_info, size_t boot_info_sz)
}
#ifdef EFI_ZFS_BOOT
zfsinfo_list_t *zfsinfo = efizfs_get_zfsinfo_list();
zfsinfo_t *zi;
/*
* Did efi_zfs_probe() detect the boot pool? If so, use the zpool
* it found, if it's sane. ZFS is the only thing that looks for
@@ -595,9 +598,9 @@ find_currdev(bool do_bootmgr, char *boot_info, size_t boot_info_sz)
* if we allow specifying which pool to boot from via UEFI variables
* rather than the bootenv stuff that FreeBSD uses today.
*/
if (pool_guid != 0) {
printf("Trying ZFS pool\n");
if (probe_zfs_currdev(pool_guid))
STAILQ_FOREACH(zi, zfsinfo, zi_link) {
printf("Trying ZFS pool 0x%jx\n", zi->zi_pool_guid);
if (probe_zfs_currdev(zi->zi_pool_guid))
return (0);
}
#endif /* EFI_ZFS_BOOT */