stand/zfs: Add a third argument to zfs_probe_dev: part_too

Pass in 'true' if you'd like to search this device's partitions or
'false' if you should just search the device. EFI and (in the future)
kboot have discrete partitions that aren't accessed via the full disk
device. Weird things happen if you try to search in these cases.

Sponsored by:		Netflix
This commit is contained in:
Warner Losh 2022-12-16 16:19:51 -07:00
parent c1871a3372
commit 71bbe6fb70
6 changed files with 9 additions and 7 deletions

View File

@ -115,7 +115,7 @@ efi_zfs_probe(void)
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) {
if (zfs_probe_dev(devname, &guid, false) == 0) {
insert_zfs(pd->pd_handle, guid);
if (pd->pd_handle == boot_img->DeviceHandle)
pool_guid = guid;

View File

@ -453,7 +453,7 @@ i386_zfs_probe(void)
for (dev.dd.d_unit = 0; bd_unit2bios(&dev) >= 0; dev.dd.d_unit++) {
snprintf(devname, sizeof(devname), "%s%d:", bioshd.dv_name,
dev.dd.d_unit);
zfs_probe_dev(devname, NULL);
zfs_probe_dev(devname, NULL, true);
}
}
#endif

View File

@ -706,9 +706,9 @@ i386_zfs_probe(void)
dev.dd.d_unit);
/* If this is not boot disk, use generic probe. */
if (dev.dd.d_unit != boot_unit)
zfs_probe_dev(devname, NULL);
zfs_probe_dev(devname, NULL, true);
else
zfs_probe_dev(devname, &pool_guid);
zfs_probe_dev(devname, &pool_guid, true);
if (pool_guid != 0 && bdev == NULL) {
bdev = malloc(sizeof (struct i386_devdesc));

View File

@ -49,7 +49,7 @@ struct zfs_devdesc {
};
char *zfs_fmtdev(struct devdesc *);
int zfs_probe_dev(const char *devname, uint64_t *pool_guid);
int zfs_probe_dev(const char *devname, uint64_t *pool_guid, bool part_too);
int zfs_list(const char *name);
int zfs_get_bootonce(void *, const char *, char *, size_t);
int zfs_get_bootenv(void *, nvlist_t **);

View File

@ -1492,7 +1492,7 @@ zfs_attach_nvstore(void *vdev)
}
int
zfs_probe_dev(const char *devname, uint64_t *pool_guid)
zfs_probe_dev(const char *devname, uint64_t *pool_guid, bool parts_too)
{
struct ptable *table;
struct zfs_probe_args pa;
@ -1508,6 +1508,8 @@ zfs_probe_dev(const char *devname, uint64_t *pool_guid)
ret = zfs_probe(pa.fd, pool_guid);
if (ret == 0)
return (0);
if (!parts_too)
return (ENXIO);
/* Probe each partition */
ret = ioctl(pa.fd, DIOCGMEDIASIZE, &mediasz);

View File

@ -313,7 +313,7 @@ userboot_zfs_probe(void)
for (unit = 0; unit < userboot_disk_maxunit; unit++) {
sprintf(devname, "disk%d:", unit);
pool_guid = 0;
zfs_probe_dev(devname, &pool_guid);
zfs_probe_dev(devname, &pool_guid, true);
if (pool_guid != 0)
userboot_zfs_found = 1;
}