Bug 222227 - ZFS: Confusing error message when attempting to create zpool on too small media
Summary: ZFS: Confusing error message when attempting to create zpool on too small media
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Alan Somers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-11 14:54 UTC by Marie Helene Kvello-Aune
Modified: 2018-03-05 20:44 UTC (History)
1 user (show)

See Also:
asomers: mfc-stable10+
asomers: mfc-stable11+


Attachments
truss output (18.63 KB, text/plain)
2017-09-11 15:18 UTC, Marie Helene Kvello-Aune
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marie Helene Kvello-Aune 2017-09-11 14:54:50 UTC
When attempting to create a zpool on a too small media (say, a 1.4MB 3.5" floppy), the error message is "cannot create 'poolname': no such pool or dataset"

I'd expect an error message along the lines of 'underlying block device too small'.

Steps to reproduce:
1) Have a floppy or other ridiculously small r/w media accessible on the system

In this example, the floppy is /dev/da0.

2) Execute following commands to prepare media
# gpart create -s gpt da0
da0 created
# gpart add -t freebsd-zfs da0
da0p1 created
# gpart show da0
=>  40  2800  da0  GPT  (1.4M)
    40  2800    1  freebsd-zfs  (1.4M)

3) Attempt to create pool
# zpool create floppytest /dev/da0p1
cannot create 'floppytest': no such pool or dataset
Comment 1 Marie Helene Kvello-Aune 2017-09-11 15:18:24 UTC
Created attachment 186261 [details]
truss output

Attaching output of  # truss zpool create floppytest da0p1. I think relevant output is towards the end, but I'm not too familiar with truss so including all of it.
Comment 2 Alan Somers freebsd_committer 2017-09-28 14:53:26 UTC
I can reproduce this bug when using GEOM devices but not file-backed vdevs.  I've got a pretty good idea what the problem is.
Comment 3 Alan Somers freebsd_committer 2017-09-28 15:24:45 UTC
Code review in progress:
https://reviews.freebsd.org/D12531
Comment 4 commit-hook freebsd_committer 2017-10-23 23:06:04 UTC
A commit references this bug:

Author: asomers
Date: Mon Oct 23 23:05:29 UTC 2017
New revision: 324940
URL: https://svnweb.freebsd.org/changeset/base/324940

Log:
  Fix the error message when creating a zpool on a too-small device

  Don't check for SPA_MINDEVSIZE in vdev_geom_attach when opening by path.
  It's redundant with the check in vdev_open, and failing to attach here
  results in the wrong error message being printed.  However, still check for
  it in some other situations:

  * When opening by guids, so we don't get bogged down reading from slow
    devices like floppy drives.
  * In vdev_geom_read_pool_label for the same reason, because we iterate over
    all providers.
  * If the caller requests that we verify the guid, because then we'll have to
    read from the device before vdev_open verifies the size.

  PR:		222227
  Reported by:	Marie Helene Kvello-Aune <marieheleneka@gmail.com>
  Reviewed by:	avg, mav
  MFC after:	3 weeks
  Sponsored by:	Spectra Logic Corp
  Differential Revision:	https://reviews.freebsd.org/D12531

Changes:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
Comment 5 commit-hook freebsd_committer 2017-11-28 16:35:45 UTC
A commit references this bug:

Author: asomers
Date: Tue Nov 28 16:34:56 UTC 2017
New revision: 326319
URL: https://svnweb.freebsd.org/changeset/base/326319

Log:
  MFC r324940:

  Fix the error message when creating a zpool on a too-small device

  Don't check for SPA_MINDEVSIZE in vdev_geom_attach when opening by path.
  It's redundant with the check in vdev_open, and failing to attach here
  results in the wrong error message being printed.  However, still check for
  it in some other situations:

  * When opening by guids, so we don't get bogged down reading from slow
    devices like floppy drives.
  * In vdev_geom_read_pool_label for the same reason, because we iterate over
    all providers.
  * If the caller requests that we verify the guid, because then we'll have to
    read from the device before vdev_open verifies the size.

  PR:		222227
  Reported by:	Marie Helene Kvello-Aune <marieheleneka@gmail.com>
  Reviewed by:	avg, mav
  Sponsored by:	Spectra Logic Corp
  Differential Revision:	https://reviews.freebsd.org/D12531

Changes:
_U  stable/11/
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
Comment 6 commit-hook freebsd_committer 2018-03-05 20:44:46 UTC
A commit references this bug:

Author: asomers
Date: Mon Mar  5 20:43:43 UTC 2018
New revision: 330524
URL: https://svnweb.freebsd.org/changeset/base/330524

Log:
  MFC r324940:

  Fix the error message when creating a zpool on a too-small device

  Don't check for SPA_MINDEVSIZE in vdev_geom_attach when opening by path.
  It's redundant with the check in vdev_open, and failing to attach here
  results in the wrong error message being printed.  However, still check for
  it in some other situations:

  * When opening by guids, so we don't get bogged down reading from slow
    devices like floppy drives.
  * In vdev_geom_read_pool_label for the same reason, because we iterate over
    all providers.
  * If the caller requests that we verify the guid, because then we'll have to
    read from the device before vdev_open verifies the size.

  PR:		222227
  Reported by:	Marie Helene Kvello-Aune <marieheleneka@gmail.com>
  Reviewed by:	avg, mav
  Sponsored by:	Spectra Logic Corp
  Differential Revision:	https://reviews.freebsd.org/D12531

Changes:
_U  stable/10/
  stable/10/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c