git: 0661997cea16 - main - loader(8): embedded MD should be the most preferred currdev

From: Navdeep Parhar <np_at_FreeBSD.org>
Date: Fri, 20 Mar 2026 14:44:51 UTC
The branch main has been updated by np:

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

commit 0661997cea165e951e4e215e6aed41596d8b1d52
Author:     Navdeep Parhar <np@FreeBSD.org>
AuthorDate: 2026-03-20 00:39:17 +0000
Commit:     Navdeep Parhar <np@FreeBSD.org>
CommitDate: 2026-03-20 14:40:41 +0000

    loader(8): embedded MD should be the most preferred currdev
    
    A loader built with MD_IMAGE_SIZE is almost always meant for use with
    its embedded image and should try that as currdev before anything else.
    Recent changes (d69fc3a9dc71, 784150fd2535) seem to have relaxed the ZFS
    code's search for a rootfs and exposed this problem.
    
    Reviewed by:    imp, tsoome
    MFC after:      1 week
    Sponsored by:   Chelsio Communications
    Differential Revision:  https://reviews.freebsd.org/D55979
---
 stand/efi/loader/main.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
index f83db2e0668d..1fd6c8d74195 100644
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -597,6 +597,15 @@ find_currdev(bool do_bootmgr, char *boot_info, size_t boot_info_sz)
 		} /* Nothing specified, try normal match */
 	}
 
+#ifdef MD_IMAGE_SIZE
+	/*
+	 * If there is an embedded MD, try to use that.
+	 */
+	printf("Trying MD\n");
+	if (probe_md_currdev())
+		return (0);
+#endif /* MD_IMAGE_SIZE */
+
 #ifdef EFI_ZFS_BOOT
 	zfsinfo_list_t *zfsinfo = efizfs_get_zfsinfo_list();
 	zfsinfo_t *zi;
@@ -616,15 +625,6 @@ find_currdev(bool do_bootmgr, char *boot_info, size_t boot_info_sz)
 	}
 #endif /* EFI_ZFS_BOOT */
 
-#ifdef MD_IMAGE_SIZE
-	/*
-	 * If there is an embedded MD, try to use that.
-	 */
-	printf("Trying MD\n");
-	if (probe_md_currdev())
-		return (0);
-#endif /* MD_IMAGE_SIZE */
-
 	/*
 	 * Try to find the block device by its handle based on the
 	 * image we're booting. If we can't find a sane partition,