Bug 241070 - dumpon: dumpon opens geom devices non-exclusively
Summary: dumpon: dumpon opens geom devices non-exclusively
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-geom (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-05 02:43 UTC by Alan Somers
Modified: 2022-11-11 23:13 UTC (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Somers freebsd_committer freebsd_triage 2019-10-05 02:43:58 UTC
dumpon opens geom devices non-exclusively.  This might be required in order to share a device for swap and dump purposes.  However, it's also dangerous as it allows a single device to be used as both a dump device and a storage device.

Steps to reproduce:

> sudo dumpon vtbd1
> sudo zpool create foo vtbd1
Comment 1 commit-hook freebsd_committer freebsd_triage 2019-10-05 03:20:19 UTC
A commit references this bug:

Author: asomers
Date: Sat Oct  5 03:19:55 UTC 2019
New revision: 353118
URL: https://svnweb.freebsd.org/changeset/base/353118

Log:
  ZFS: fix several of the "zpool create" tests

  * Remove zpool_create_013_neg.  FreeBSD doesn't have an equivalent of
    Solaris's metadevices.  GEOM would be the equivalent, but since all geoms
    are the same from ZFS's perspective, this test would be redundant with
    zpool_create_012_neg

  * Remove zpool_create_014_neg.  FreeBSD does not support swapping to regular
    files.

  * Remove zpool_create_016_pos.  This test is redundant with literally every
    other test that creates a disk-backed pool.

  * s:/etc/vfstab:/etc/fstab in zpool_create_011_neg

  * Delete the VTOC-related portion of zpool_create_008_pos.  FreeBSD doesn't
    use VTOC.

  * Replace dumpadm with dumpon and swap with swapon in multiple tests.

  * In zpool_create_015_neg, don't require "zpool create -n" to fail.  It's
    reasonable for that variant to succeed, because it doesn't actually open
    the zvol.

  * Greatly simplify zpool_create_012_neg.  Make it safer, too, but not
    interfering with the system's regular swap devices.

  * Expect zpool_create_011_neg to fail (PR 241070)

  * Delete some redundant cleanup steps in various tests

  * Remove some unneeeded ATF timeout specifications.  The default is fine.

  PR:		241070
  MFC after:	2 weeks
  Sponsored by:	Axcient

Changes:
  head/ObsoleteFiles.inc
  head/tests/sys/cddl/zfs/include/commands.txt
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_create/Makefile
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create.kshlib
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_008_pos.ksh
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_011_neg.ksh
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_012_neg.ksh
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_013_neg.ksh
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_014_neg.ksh
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_015_neg.ksh
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_016_pos.ksh
  head/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_test.sh
Comment 2 commit-hook freebsd_committer freebsd_triage 2019-10-30 02:03:47 UTC
A commit references this bug:

Author: asomers
Date: Wed Oct 30 02:03:42 UTC 2019
New revision: 354165
URL: https://svnweb.freebsd.org/changeset/base/354165

Log:
  MFC r353117-r353118, r353281-r353282, r353284-r353289, r353309-r353310, r353360-r353361, r353366, r353379

  r353117:
  ZFS: the hotspare_add_004_neg test needs at least two disks

  Sponsored by:	Axcient

  r353118:
  ZFS: fix several of the "zpool create" tests

  * Remove zpool_create_013_neg.  FreeBSD doesn't have an equivalent of
    Solaris's metadevices.  GEOM would be the equivalent, but since all geoms
    are the same from ZFS's perspective, this test would be redundant with
    zpool_create_012_neg

  * Remove zpool_create_014_neg.  FreeBSD does not support swapping to regular
    files.

  * Remove zpool_create_016_pos.  This test is redundant with literally every
    other test that creates a disk-backed pool.

  * s:/etc/vfstab:/etc/fstab in zpool_create_011_neg

  * Delete the VTOC-related portion of zpool_create_008_pos.  FreeBSD doesn't
    use VTOC.

  * Replace dumpadm with dumpon and swap with swapon in multiple tests.

  * In zpool_create_015_neg, don't require "zpool create -n" to fail.  It's
    reasonable for that variant to succeed, because it doesn't actually open
    the zvol.

  * Greatly simplify zpool_create_012_neg.  Make it safer, too, but not
    interfering with the system's regular swap devices.

  * Expect zpool_create_011_neg to fail (PR 241070)

  * Delete some redundant cleanup steps in various tests

  * Remove some unneeeded ATF timeout specifications.  The default is fine.

  PR:		241070
  Sponsored by:	Axcient

  r353281:
  ZFS: fix several zvol_misc tests

  * Adapt zvol_misc_001_neg to use dumpon instead of Solaris's dumpadm
  * Disable zvol_misc_003_neg, zvol_misc_005_neg, and zvol_misc_006_pos,
    because they involve using a zvol as a dump device, which FreeBSD does not
    yet support.

  Sponsored by:	Axcient

  r353282:
  zfs: fix the slog_012_neg test

  This test attempts to corrupt a file-backed vdev by deleting it and then
  recreating it with truncate.  But that doesn't work, because the pool
  already has the vdev open, and it happily hangs on to the open-but-deleted
  file.  Fix by truncating the file without deleting it.

  Sponsored by:	Axcient

  r353284:
  ZFS: fix the zpool_get_002_pos test

  ZFS has grown some additional properties that hadn't been added to the
  config file yet.  While I'm here, improve the error message, and remove a
  superfluous command.

  Sponsored by:	Axcient

  r353285:
  zfs: fix the zdb_001_neg test

  The test needed to be updated for r331701 (MFV illumos 8671400), which added
  a "-k" option.

  Sponsored by:	Axcient

  r353286:
  zfs: skip the zfsd tests if zfsd is not running

  Sponsored by:	Axcient
  Differential Revision:	https://reviews.freebsd.org/D21878

  r353287:
  ZFS: fix the delegate tests

  These tests have never worked correctly

  * Replace runwattr with sudo
  * Fix a scoping bug with the "dtst" variable
  * Cleanup user properties created during tests
  * Eliminate the checks for refreservation and send support. They will always
    be supported.
  * Fix verify_fs_snapshot. It seemed to assume that permissions would not yet
    be delegated, but that's not how it's actually used.
  * Combine verify_fs_promote with verify_vol_promote
  * Remove some useless sleeps
  * Fix backwards condition in verify_vol_volsize
  * Remove some redundant cleanup steps in the tests. cleanup.ksh will handle
    everything.
  * Disable some parts of the tests that FreeBSD doesn't support:
      * Creating snapshots with mkdir
      * devices
      * shareisci
      * sharenfs
      * xattr
      * zoned

  The sharenfs parts could probably be reenabled with more work to remove the
  Solarisms.

  Sponsored by:	Axcient
  Differential Revision:	https://reviews.freebsd.org/D21898

  r353288:
  ZFS: mark hotspare_scrub_002_pos as an expected failure

  "zpool scrub" doesn't detect all errors on active spares in raidz arrays

  PR:		241069
  Sponsored by:	Axcient

  r353289:
  ZFS: fix the redundancy tests

  * Fix force_sync_path, which ensures that a file is fully flushed to disk.
    Apparently "zpool history"'s performance has improved, but exporting and
    importing the pool still works.
  * Fix file_dva by using undocumented zdb syntax to clarify that we're
    interested in the pool's root file system, not the pool itself. This
    should also fix the zpool_clear_001_pos test.
  * Remove a redundant cleanup step

  Sponsored by:	Axcient
  Differential Revision:	https://reviews.freebsd.org/D21901

  r353309:
  zfs: fix the zfsd_autoreplace_003_pos test

  The test declared that it only needed 5 disks, but actually tried to use 6.
  Fix it to use just 5, which is all it really needs.

  Sponsored by:	Axcient

  r353310:
  zfs: fix the zfsd_hotspare_007_pos test

  It was trying to destroy the pool while zfsd was detaching the spare, and
  "zpool destroy" failed.  Fix by waiting until the spare has fully detached.

  Sponsored by:	Axcient

  r353360:
  ZFS: multiple fixes to the zpool_import tests

  * Don't create a UFS mountpoint just to store some temporary files.  The
    tests should always be executed with a sufficiently large TMPDIR.
    Creating the UFS mountpoint is not only unneccessary, but it slowed
    zpool_import_missing_002_pos greatly, because that test moves large files
    between TMPDIR and the UFS mountpoint.  This change also allows many of
    the tests to be executed with just a single test disk, instead of two.

  * Move zpool_import_missing_002_pos's backup device dir from / to $PWD to
    prevent cross-device moves.  On my system, these two changes improved that
    test's speed by 39x.  It should also prevent ENOSPC errors seen in CI.

  * If insufficient disks are available, don't try to partition one of them.
    Just rely on Kyua to skip the test.  Users who care will configure Kyua
    with sufficient disks.

  Sponsored by:	Axcient

  r353361:
  ZFS: in the tests, don't override PWD

  The ZFS test suite was overriding the common $PWD variable with the path to
  the pwd command, even though no test wanted to use it that way.  Most tests
  didn't notice, because ksh93 eventually restored it to its proper meaning.

  Sponsored by:	Axcient

  r353366:
  ZFS: fix the zpool_add_010_pos test

  The test is necessarily racy, because it depends on being able to complete a
  "zpool add" before a previous resilver finishes.  But it was racier than it
  needed to be.  Move the first "zpool add" to before the resilver starts.

  Sponsored by:	Axcient

  r353379:
  zfs: multiple improvements to the zpool_add tests

  * Don't partition a disk if too few are available.  Just rely on Kyua to
    ensure that the tests aren't run with insufficient disks.

  * Remove redundant cleanup steps

  * In zpool_add_003_pos, store the temporary file in $PWD so Kyua will
    automatically clean it up.

  * Update zpool_add_005_pos to use dumpon instead of dumpadm.  This test had
    never been ported to FreeBSD.

  * In zpool_add_005_pos, don't format the dump disk with UFS.  That was
    pointless.

  Sponsored by:	Axcient
  > Description of fields to fill in above:                     76 columns --|
  > PR:                       If and which Problem Report is related.
  > Submitted by:             If someone else sent in the change.
  > Reported by:              If someone else reported the issue.
  > Reviewed by:              If someone else reviewed your modification.
  > Approved by:              If you needed approval for this commit.
  > Obtained from:            If the change is from a third party.
  > MFC after:                N [day[s]|week[s]|month[s]].  Request a reminder email.
  > MFH:                      Ports tree branch name.  Request approval for merge.
  > Relnotes:                 Set to 'yes' for mention in release notes.
  > Security:                 Vulnerability reference (one per line) or description.
  > Sponsored by:             If the change was sponsored by an organization (each collaborator).
  > Differential Revision:    https://reviews.freebsd.org/D### (*full* phabric URL needed).
  > Empty fields above will be automatically removed.

  _M   12
  M    12/ObsoleteFiles.inc
  M    12/tests/sys/cddl/zfs/include/commands.txt
  M    12/tests/sys/cddl/zfs/include/libtest.kshlib
  M    12/tests/sys/cddl/zfs/tests/cli_root/zdb/zdb_001_neg.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/cleanup.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/setup.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_001_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_002_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_003_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_004_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_005_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_006_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_007_neg.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_008_neg.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_009_neg.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_010_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_test.sh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/Makefile
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create.kshlib
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_008_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_011_neg.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_012_neg.ksh
  D    12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_013_neg.ksh
  D    12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_014_neg.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_015_neg.ksh
  D    12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_016_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_test.sh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_get/zpool_get.cfg
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_get/zpool_get_002_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_import/cleanup.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_import/setup.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import.cfg
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_all_001_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_test.sh
  M    12/tests/sys/cddl/zfs/tests/delegate/delegate_common.kshlib
  M    12/tests/sys/cddl/zfs/tests/delegate/zfs_allow_001_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/delegate/zfs_allow_002_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/delegate/zfs_allow_003_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/delegate/zfs_allow_007_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/delegate/zfs_allow_010_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/delegate/zfs_allow_012_neg.ksh
  M    12/tests/sys/cddl/zfs/tests/delegate/zfs_allow_test.sh
  M    12/tests/sys/cddl/zfs/tests/delegate/zfs_unallow_007_neg.ksh
  M    12/tests/sys/cddl/zfs/tests/delegate/zfs_unallow_test.sh
  M    12/tests/sys/cddl/zfs/tests/hotspare/hotspare_test.sh
  M    12/tests/sys/cddl/zfs/tests/redundancy/redundancy.kshlib
  M    12/tests/sys/cddl/zfs/tests/redundancy/redundancy_001_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/slog/slog_012_neg.ksh
  M    12/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_003_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_007_pos.ksh
  M    12/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh
  M    12/tests/sys/cddl/zfs/tests/zvol/zvol_misc/zvol_misc_001_neg.ksh
  M    12/tests/sys/cddl/zfs/tests/zvol/zvol_misc/zvol_misc_test.sh

Changes:
_U  stable/12/
  stable/12/ObsoleteFiles.inc
  stable/12/tests/sys/cddl/zfs/include/commands.txt
  stable/12/tests/sys/cddl/zfs/include/libtest.kshlib
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zdb/zdb_001_neg.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/cleanup.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/setup.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_001_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_002_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_003_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_004_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_005_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_006_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_007_neg.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_008_neg.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_009_neg.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_010_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_test.sh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/Makefile
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create.kshlib
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_008_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_011_neg.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_012_neg.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_013_neg.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_014_neg.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_015_neg.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_016_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_create/zpool_create_test.sh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_get/zpool_get.cfg
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_get/zpool_get_002_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_import/cleanup.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_import/setup.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import.cfg
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_all_001_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/cli_root/zpool_import/zpool_import_test.sh
  stable/12/tests/sys/cddl/zfs/tests/delegate/delegate_common.kshlib
  stable/12/tests/sys/cddl/zfs/tests/delegate/zfs_allow_001_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/delegate/zfs_allow_002_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/delegate/zfs_allow_003_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/delegate/zfs_allow_007_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/delegate/zfs_allow_010_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/delegate/zfs_allow_012_neg.ksh
  stable/12/tests/sys/cddl/zfs/tests/delegate/zfs_allow_test.sh
  stable/12/tests/sys/cddl/zfs/tests/delegate/zfs_unallow_007_neg.ksh
  stable/12/tests/sys/cddl/zfs/tests/delegate/zfs_unallow_test.sh
  stable/12/tests/sys/cddl/zfs/tests/hotspare/hotspare_test.sh
  stable/12/tests/sys/cddl/zfs/tests/redundancy/redundancy.kshlib
  stable/12/tests/sys/cddl/zfs/tests/redundancy/redundancy_001_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/slog/slog_012_neg.ksh
  stable/12/tests/sys/cddl/zfs/tests/zfsd/zfsd_autoreplace_003_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/zfsd/zfsd_hotspare_007_pos.ksh
  stable/12/tests/sys/cddl/zfs/tests/zfsd/zfsd_test.sh
  stable/12/tests/sys/cddl/zfs/tests/zvol/zvol_misc/zvol_misc_001_neg.ksh
  stable/12/tests/sys/cddl/zfs/tests/zvol/zvol_misc/zvol_misc_test.sh
Comment 3 Mark Johnston freebsd_committer freebsd_triage 2020-07-13 14:36:00 UTC
(In reply to Alan Somers from comment #0)
It is also required for savecore to work.  rc.d/dumpon runs before savecore, but savecore wants to be able to write to the dump device in order to clear headers from a previous dump.
Comment 4 Ravi Pokala 2020-07-14 17:26:49 UTC
(In reply to Mark Johnston from comment #3)

> rc.d/dumpon runs before savecore

That seems like a bug: it opens a window where we might start swapping before having saved the core.
Comment 5 Mark Johnston freebsd_committer freebsd_triage 2020-07-14 17:56:11 UTC
(In reply to Ravi Pokala from comment #4)
I think it's a "known" bug.  When dumping we start writing as far into the dump device as possible (i.e., the end of the dump lines up with the end of the dump device), and this policy happens to minimize the risk that swapping will overwrite dump data.

I'm not sure that we could really reorder the scripts.  savecore depends on local filesystems being mounted and clean, and we want dumpon to run as early as possible.  It is also handy to be able to run savecore manually after the system has finished booting.  Swapping during boot is also (hopefully) rather unusual.
Comment 6 Ed Maste freebsd_committer freebsd_triage 2022-03-10 15:02:41 UTC
What should we do about this? At a minimum we can make note of this in an appropriate man page. Is it worth the effort of plumbing geom support to allow swap and dump to share a device but no others?
Comment 7 Eric van Gyzen freebsd_committer freebsd_triage 2022-11-04 13:13:48 UTC
If you fix this bug, these test cases will also need changes:

 tests/sys/cddl/zfs/tests/cli_root/zpool_add/zpool_add_005_pos.ksh
 tests/sys/cddl/zfs/tests/hotspare/hotspare_add_003_neg.ksh
 tests/sys/cddl/zfs/tests/hotspare/hotspare_create_001_neg.ksh

Enable those tests by adding this to /etc/kyua/kyua.conf, for example:

 test_suites.FreeBSD.disks = '/dev/vtbd1 /dev/vtbd2 ...'

See https://reviews.freebsd.org/D37257 for some context.
Comment 8 Poul-Henning Kamp freebsd_committer freebsd_triage 2022-11-07 10:12:08 UTC
I suggest we discontinue the shared dump/swap device support.

It made sense back when disk partitions where a limited resources and disks and main memory were closer in size (and cost a fortune).

These days, in particular with mini-dumps, it makes absolutely no sense.
Comment 9 Alan Somers freebsd_committer freebsd_triage 2022-11-07 15:40:40 UTC
(In reply to Poul-Henning Kamp from comment #8)
Where would you put dumps instead?  On a dedicated partition?  That would work for new installs, but there are an awful lot of legacy installs that still might want to dump.
Comment 10 Poul-Henning Kamp freebsd_committer freebsd_triage 2022-11-07 17:38:23 UTC
I would just document it, and let whichever one of swapon or dumpon which comes last fail.

If we do this on a major release boundary, that's livable.
Comment 11 commit-hook freebsd_committer freebsd_triage 2022-11-11 20:45:25 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=11ed0a95bfa76791dc6428eb2d47a986c0c6f8a3

commit 11ed0a95bfa76791dc6428eb2d47a986c0c6f8a3
Author:     Eric van Gyzen <vangyzen@FreeBSD.org>
AuthorDate: 2022-11-03 02:42:54 +0000
Commit:     Eric van Gyzen <vangyzen@FreeBSD.org>
CommitDate: 2022-11-11 20:43:47 +0000

    zfs tests: stop writing to arbitrary devices

    TL;DR:  Three ZFS tests created ZFS pools on all unmounted devices listed
    in /etc/fstab, corrupting their contents.  Stop that.

    Imagine my surprise when the ESP on my main dev/test VM would "randomly"
    become corrupted, making it unbootable.  Three tests collect various devices
    from the system and try to add them to a test pool.  The test expects this
    to fail because it _assumes_ these devices are in use and ZFS will correctly
    reject the request.

    My /etc/fstab has two entries for devices in /dev:

        /dev/gpt/swap0  none        swap    sw,trimonce,late
        /dev/gpt/esp0   /boot/efi   msdosfs rw,noauto

    Note the `noauto` on the ESP.  In a remarkable example of irony, I chose
    this because it should keep the ESP more protected from corruption;
    in fact, mounting it would have protected it from this case.

    The tests added all of these devices to a test pool in a _single command_,
    expecting the command to fail.  The swap device was in use, so the command
    correctly failed, but the ESP was added and therefore corrupted.  However,
    since the command correctly failed, the test didn't notice the ESP problem.
    If each device had been added with its own command, the test _might_ have
    noticed that one of them incorrectly succeeded.  However, two of these
    tests would not have noticed:

    hotspare_create_001_neg was incorrectly specified as needing the Solaris
    dumpadm command, so it was skipped.  _Some_ of the test needs that command,
    but it checks for its presence and runs fine without it.

    Due to bug 241070, zpool_add_005_pos was marked as an expected failure.
    Due to the coarse level of integration with ATF, this test would still
    "pass" even if it failed for the wrong reason.  I wrote bug 267554 to
    reconsider the use of atf_expect_fail in these tests.

    Let's further consider the use of various devices found around the system.
    In addition to devices in /etc/fstab, the tests also used mounted devices
    listed by the `mount` command.  If ZFS behaves correctly, it will refuse
    to added mounted devices and swap devices to a pool.  However, these are
    unit tests used by developers to ensure that ZFS still works after they
    modify it, so it's reasonable to expect ZFS to do the _wrong_ thing
    sometimes.  Using random host devices is unsafe.

    Fix the root problem by using only the disks provided via the "disks"
    variable in kyua.conf.  Use one to create a UFS file system and mount it.
    Use another as a swap device.  Use a third as a dump device, but expect
    it to fail due to bug 241070.

    While I'm here:

    Due to commit 6b6e2954dd65, we can simply add a second dump device and
    remove it in cleanup.  We no longer need to save, replace, and restore the
    pre-existing dump device.

    The cleanup_devices function used `camcontrol inquiry` to distinguish disks
    from other devices, such as partitions.  That works fine for SCSI, but not
    for ATA or VirtIO block.  Use `geom disk list` instead.

    PR:             241070
    PR:             267554
    Reviewed by:    asomers
    Sponsored by:   Dell Inc.
    Differential Revision:  https://reviews.freebsd.org/D37257

 tests/sys/cddl/zfs/include/libtest.kshlib          |  2 +-
 .../zfs/tests/cli_root/zpool_add/zpool_add.kshlib  | 68 ----------------------
 .../tests/cli_root/zpool_add/zpool_add_005_pos.ksh | 29 ++++++---
 .../zfs/tests/cli_root/zpool_add/zpool_add_test.sh |  3 +-
 .../zfs/tests/hotspare/hotspare_add_003_neg.ksh    | 60 +++++++++----------
 .../zfs/tests/hotspare/hotspare_create_001_neg.ksh | 60 +++++++++----------
 tests/sys/cddl/zfs/tests/hotspare/hotspare_test.sh |  4 +-
 7 files changed, 83 insertions(+), 143 deletions(-)