svn commit: r316704 - head/sys/boot/efi/loader

Toomas Soome tsoome at FreeBSD.org
Tue Apr 11 15:20:34 UTC 2017


Author: tsoome
Date: Tue Apr 11 15:20:32 2017
New Revision: 316704
URL: https://svnweb.freebsd.org/changeset/base/316704

Log:
  loader.efi: only fetch zfs pool guid for the actual boot device
  
  With the zfs probe cleanup, the mistake did slip in the probe code;
  instead of reading the pool GUID for the actual boot device (partition),
  we read GUID for first found pool from the boot disk.
  
  This will break the case when there are both zfs pool and ufs on the boot
  disk, and the ufs is used for boot, not zfs.
  
  Reviewed by:	smh
  Differential Revision:	https://reviews.freebsd.org/D10359

Modified:
  head/sys/boot/efi/loader/main.c

Modified: head/sys/boot/efi/loader/main.c
==============================================================================
--- head/sys/boot/efi/loader/main.c	Tue Apr 11 13:42:26 2017	(r316703)
+++ head/sys/boot/efi/loader/main.c	Tue Apr 11 15:20:32 2017	(r316704)
@@ -804,38 +804,26 @@ efi_zfs_probe(void)
 	pdinfo_t *hd, *pd = NULL;
 	EFI_GUID imgid = LOADED_IMAGE_PROTOCOL;
 	EFI_LOADED_IMAGE *img;
-	EFI_HANDLE boot_disk = NULL;
 	char devname[SPECNAMELEN + 1];
-	uint64_t *guidp = NULL;
 
 	BS->HandleProtocol(IH, &imgid, (VOID**)&img);
-
-	/* Find the handle for the boot disk. */
 	hdi = efiblk_get_pdinfo_list(&efipart_hddev);
-	STAILQ_FOREACH(hd, hdi, pd_link) {
-		STAILQ_FOREACH(pd, &hd->pd_part, pd_link) {
-			if (pd->pd_handle == img->DeviceHandle)
-				boot_disk = hd->pd_handle;
-		}
-	}
 
 	/*
-	 * We provide non-NULL guid pointer if the disk was used for boot,
-	 * and reset after the first found pool.
-	 * Technically this solution is not very correct, we assume the boot
-	 * pool is the first pool on this disk.
+	 * Find the handle for the boot device. The boot1 did find the
+	 * device with loader binary, now we need to search for the
+	 * same device and if it is part of the zfs pool, we record the
+	 * pool GUID for currdev setup.
 	 */
-
 	STAILQ_FOREACH(hd, hdi, pd_link) {
-		if (hd->pd_handle == boot_disk)
-			guidp = &pool_guid;
-
 		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);
-			(void) zfs_probe_dev(devname, guidp);
-			if (guidp != NULL && pool_guid != 0)
-				guidp = NULL;
+			if (pd->pd_handle == img->DeviceHandle)
+				(void) zfs_probe_dev(devname, &pool_guid);
+			else
+				(void) zfs_probe_dev(devname, NULL);
 		}
 	}
 }


More information about the svn-src-all mailing list