The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d69fc3a9dc71768e125e83d35274f0820063e42d

commit d69fc3a9dc71768e125e83d35274f0820063e42d
Author:     Gleb Smirnoff <[email protected]>
AuthorDate: 2026-02-27 00:57:26 +0000
Commit:     Warner Losh <[email protected]>
CommitDate: 2026-02-27 01:01:36 +0000

    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
---
 stand/efi/include/efizfs.h | 2 --
 stand/efi/libefi/efizfs.c  | 9 +--------
 stand/efi/loader/main.c    | 9 ++++++---
 3 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/stand/efi/include/efizfs.h b/stand/efi/include/efizfs.h
index 45c2ca1c94aa..5f50b7740a55 100644
--- a/stand/efi/include/efizfs.h
+++ b/stand/efi/include/efizfs.h
@@ -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 *);
diff --git a/stand/efi/libefi/efizfs.c b/stand/efi/libefi/efizfs.c
index 1c80f1ae26b9..563cf841143a 100644
--- a/stand/efi/libefi/efizfs.c
+++ b/stand/efi/libefi/efizfs.c
@@ -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;
-                       }
-
                }
        }
 }
diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
index 7ff2cf188509..d8508d7d91a0 100644
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -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 */

Reply via email to