summaryrefslogtreecommitdiff
path: root/stand
diff options
context:
space:
mode:
authorToomas Soome <tsoome@FreeBSD.org>2020-09-23 08:22:14 +0000
committerToomas Soome <tsoome@FreeBSD.org>2020-09-23 08:22:14 +0000
commit867ae3c38d1aa97300bd35f457037b3f1a0a103f (patch)
treef62c57aa8871cf85c39db16ba4282abee9ff8ed4 /stand
parent6155466afb8d1a01ad315e5592dafc1c1feb59a9 (diff)
downloadsrc-test-867ae3c38d1aa97300bd35f457037b3f1a0a103f.tar.gz
src-test-867ae3c38d1aa97300bd35f457037b3f1a0a103f.zip
loader: zfs_probe_dev should pick first matching zfs pool
During devswitch probe, we pick boot pool based on boot disk, if the boot disk happens to have multiple pools in freebsd-zfs partitions, the current code does pick last pool from boot disk as boot pool. While there is no way at that stage to test, the more logical approach would be to pick first matching pool. This patch is assuming we do pass pool guid pointer with guid value 0, this will help us to determine, if the guid value is already set or not. The general suggestion would be not to share disk between different pools. Reported by: Alexander Leidinger
Notes
Notes: svn path=/head/; revision=366066
Diffstat (limited to 'stand')
-rw-r--r--stand/efi/libefi/efizfs.c3
-rw-r--r--stand/libsa/zfs/zfs.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/stand/efi/libefi/efizfs.c b/stand/efi/libefi/efizfs.c
index aedb9c2294cd7..7f3986d471408 100644
--- a/stand/efi/libefi/efizfs.c
+++ b/stand/efi/libefi/efizfs.c
@@ -99,7 +99,7 @@ efi_zfs_probe(void)
pdinfo_list_t *hdi;
pdinfo_t *hd, *pd = NULL;
char devname[SPECNAMELEN + 1];
- uint64_t guid;
+ uint64_t guid;
hdi = efiblk_get_pdinfo_list(&efipart_hddev);
STAILQ_INIT(&zfsinfo);
@@ -114,6 +114,7 @@ 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) == 0) {
insert_zfs(pd->pd_handle, guid);
if (pd->pd_handle == boot_img->DeviceHandle)
diff --git a/stand/libsa/zfs/zfs.c b/stand/libsa/zfs/zfs.c
index ea0fdace680c2..645c87031e53b 100644
--- a/stand/libsa/zfs/zfs.c
+++ b/stand/libsa/zfs/zfs.c
@@ -651,7 +651,8 @@ zfs_probe(int fd, uint64_t *pool_guid)
spa = NULL;
ret = vdev_probe(vdev_read, vdev_write, (void *)(uintptr_t)fd, &spa);
if (ret == 0 && pool_guid != NULL)
- *pool_guid = spa->spa_guid;
+ if (*pool_guid == 0)
+ *pool_guid = spa->spa_guid;
return (ret);
}