Author: tsoome
Date: Mon Dec 17 07:43:29 2018
New Revision: 342161
URL: https://svnweb.freebsd.org/changeset/base/342161

Log:
  loader: zfs reader should not probe partitionless disks (UEFI case)
  
  With r342151 I did fix the BIOS version of zfs_probe_dev() from accessing
  the whole disk, but the fix was not complete - we actually did not check
  if the device name was really for whole disk. Since UEFI version
  is only calling the zfs_probe_dev() with partitions and not with whole
  disk, the UEFI loader was not able to find the zfs pools.
  
  This update does correct the issue by calling archsw.arch_getdev() to
  translate the device name back to dev_desc, and we have whole disk when both
  partition and slice values are -1.
  
  Reported by:  alvisen_gmail.com
  Differential Revision:        https://reviews.freebsd.org/D18558

Modified:
  head/stand/libsa/zfs/zfs.c

Modified: head/stand/libsa/zfs/zfs.c
==============================================================================
--- head/stand/libsa/zfs/zfs.c  Mon Dec 17 07:09:46 2018        (r342160)
+++ head/stand/libsa/zfs/zfs.c  Mon Dec 17 07:43:29 2018        (r342161)
@@ -33,15 +33,16 @@ __FBSDID("$FreeBSD$");
  *     Stand-alone file reading package.
  */
 
+#include <stand.h>
 #include <sys/disk.h>
 #include <sys/param.h>
 #include <sys/time.h>
 #include <sys/queue.h>
+#include <disk.h>
 #include <part.h>
 #include <stddef.h>
 #include <stdarg.h>
 #include <string.h>
-#include <stand.h>
 #include <bootstrap.h>
 
 #include "libzfs.h"
@@ -517,6 +518,7 @@ zfs_probe_partition(void *arg, const char *partname,
 int
 zfs_probe_dev(const char *devname, uint64_t *pool_guid)
 {
+       struct disk_devdesc *dev;
        struct ptable *table;
        struct zfs_probe_args pa;
        uint64_t mediasz;
@@ -532,6 +534,17 @@ zfs_probe_dev(const char *devname, uint64_t *pool_guid
         * disks and some systems will misreport the disk sizes and will
         * hang while accessing the disk.
         */
+       if (archsw.arch_getdev((void **)&dev, devname, NULL) == 0) {
+               int partition = dev->d_partition;
+               int slice = dev->d_slice;
+
+               free(dev);
+               if (partition != -1 && slice != -1) {
+                       ret = zfs_probe(pa.fd, pool_guid);
+                       if (ret == 0)
+                               return (0);
+               }
+       }
 
        /* Probe each partition */
        ret = ioctl(pa.fd, DIOCGMEDIASIZE, &mediasz);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to