Bug 220186

Summary: bhyveload zfs boot broken after zfs boot change
Product: Base System Reporter: Andriy Gapon <avg>
Component: binAssignee: Andriy Gapon <avg>
Status: Closed FIXED    
Severity: Affects Only Me CC: allanjude, grehan, tsoome
Priority: --- Keywords: regression
Version: CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
proposed patch none

Description Andriy Gapon freebsd_committer freebsd_triage 2017-06-21 15:05:19 UTC
There was a recent change to the ZFS boot code that makes check all vdev labels for the vdev configuration data.  ZFS boot code now requires information about the disk sizes and, as a side effect, it now rejects disks with a too small size.

That change exposed a problem in bhyveload.  Specifically, it uses fstat(2) to check a size of a disk.  But that seems to work reliably only if the disk is a file.  If the disk is character device, then st_size is zero and the ZFS boot code rejects such a "zero-sized" disk.

It seems that bhyveload, cb_diskioctl() to be precise, needs to check the type of the disk and issue a real DIOCGMEDIASIZE ioctl if it's a character device.

The emulation of illumos fstat64() in sys/cddl/compat/opensolaris/sys/stat.h seems to be the code that can be easily reused.
Comment 1 Andriy Gapon freebsd_committer freebsd_triage 2017-06-21 15:40:39 UTC
Created attachment 183676 [details]
proposed patch
Comment 2 Peter Grehan freebsd_committer freebsd_triage 2017-06-21 15:47:54 UTC
Looks fine to me; please commit !
Comment 3 commit-hook freebsd_committer freebsd_triage 2017-06-21 18:20:07 UTC
A commit references this bug:

Author: avg
Date: Wed Jun 21 18:19:27 UTC 2017
New revision: 320195
URL: https://svnweb.freebsd.org/changeset/base/320195

Log:
  bhyveload: correctly query size of disks

  On FreeBSD fstat(2) works fine for querying sizes of plain files,
  but not so much for character devices.
  So, use DIOCGMEDIASIZE to try to get the correct size for disks
  and disk-like devices (e.g. zvols).

  PR:		220186
  Reviewed by:	tsoome, grehan
  MFC after:	1 week

Changes:
  head/usr.sbin/bhyveload/bhyveload.c
Comment 4 commit-hook freebsd_committer freebsd_triage 2017-09-19 08:20:06 UTC
A commit references this bug:

Author: avg
Date: Tue Sep 19 08:19:20 UTC 2017
New revision: 323739
URL: https://svnweb.freebsd.org/changeset/base/323739

Log:
  MFV r320195: bhyveload: correctly query size of disks

  On FreeBSD fstat(2) works fine for querying sizes of plain files,
  but not so much for character devices.
  So, use DIOCGMEDIASIZE to try to get the correct size for disks
  and disk-like devices (e.g. zvols).

  PR:		220186

Changes:
_U  stable/10/
  stable/10/usr.sbin/bhyveload/bhyveload.c
Comment 5 commit-hook freebsd_committer freebsd_triage 2017-09-19 08:20:08 UTC
A commit references this bug:

Author: avg
Date: Tue Sep 19 08:19:48 UTC 2017
New revision: 323740
URL: https://svnweb.freebsd.org/changeset/base/323740

Log:
  MFV r320195: bhyveload: correctly query size of disks

  On FreeBSD fstat(2) works fine for querying sizes of plain files,
  but not so much for character devices.
  So, use DIOCGMEDIASIZE to try to get the correct size for disks
  and disk-like devices (e.g. zvols).

  PR:		220186

Changes:
_U  stable/11/
  stable/11/usr.sbin/bhyveload/bhyveload.c