]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoAdd 'zfs send --saved' flag
Tom Caputi [Fri, 10 Jan 2020 18:16:58 +0000 (13:16 -0500)]
Add 'zfs send --saved' flag

This commit adds the --saved (-S) to the 'zfs send' command.
This flag allows a user to send a partially received dataset,
which can be useful when migrating a backup server to new
hardware. This flag is compatible with resumable receives, so
even if the saved send is interrupted, it can be resumed.
The flag does not require any user / kernel ABI changes or any
new feature flags in the send stream format.

Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Alek Pinchuk <apinchuk@datto.com>
Reviewed-by: Paul Zuchowski <pzuchowski@datto.com>
Reviewed-by: Christian Schwarz <me@cschwarz.com>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #9007

4 years agoZTS: Improve zts-auto_offline_001_pos
Brian Behlendorf [Fri, 10 Jan 2020 17:14:49 +0000 (09:14 -0800)]
ZTS: Improve zts-auto_offline_001_pos

The zts-auto_offline_001_pos test could exceed the 10 minute test
limit and be KILLED by the test infrastructure.  To prevent this
speed up the test case by:

* Removing redundant pool configurations.  Each of the following
  vdev types is tested once: mirror, raidz, cache, and special.

* The block_device_wait function need only wait on the block
  device which has been removed as part of the test.

Reviewed-by: Paul Zuchowski <pzuchowski@datto.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9827

4 years ago Performance tests, fio enhancements
Kjeld Schouten-Lebbing [Thu, 9 Jan 2020 19:21:33 +0000 (20:21 +0100)]
 Performance tests, fio enhancements

- Set fixed chunk pattern, for sane compression
- Adjust buffer to blocksize, for cross blocksize repeatability
- Use fixed seed, for improved repeatability
- Move comp-percent and comp-chunk to variables
- set variables (mostly) to old defaults

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
Closes #9793

4 years agoZTS: Provide an alternative to shuf for FreeBSD
Ryan Moeller [Thu, 9 Jan 2020 17:31:17 +0000 (12:31 -0500)]
ZTS: Provide an alternative to shuf for FreeBSD

There was a shuf package but the upstream for the port has recently
disappeared, so it is no longer available.

Create a function to hide the usage of shuf. Implement using seq|random
on FreeBSD.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes #9824

4 years agoRemove parameter names from libzfs.h signatures
Nick Black [Thu, 9 Jan 2020 01:50:05 +0000 (20:50 -0500)]
Remove parameter names from libzfs.h signatures

Most of libzfs.h doesn't provide names for the parameters
in its signatures. These few functions included them. That
wouldn't be a problem, per se, but the 'lines' parameter
conflicts with the 'lines' #define from terminfo's term.h,
present for at least a decade. This makes it difficult to
compile code making use of both ZFS and terminfo.

Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Nick Black <dankamongmen@gmail.com>
Closes #9821

4 years agoZTS: Eliminate functions named 'random'
Ryan Moeller [Wed, 8 Jan 2020 17:08:30 +0000 (12:08 -0500)]
ZTS: Eliminate functions named 'random'

The name overlaps with a command needed by FreeBSD.
There is also no sense having two 'random' functions that do nearly
the same thing, so consolidate to just the more general one and name
it 'random_int_between'.

Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes #9820

4 years agoAvoid here-documents in systemd mount generator
lorenz [Wed, 8 Jan 2020 01:03:00 +0000 (02:03 +0100)]
Avoid here-documents in systemd mount generator

On some systems - openSUSE, for example - there is not yet a writeable
temporary file system available, so bash bails out with an error,

  'cannot create temp file for here-document: Read-only file system',

on the here documents in zfs-mount-generator. The simple fix is to
change these into a multi-line echo statement.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-By: Richard Laager <rlaager@wiktel.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Lorenz Hüdepohl <dev@stellardeath.org>
Closes #9802

4 years agozfs-module-parameters(5): add all missing items
DeHackEd [Tue, 7 Jan 2020 20:41:53 +0000 (15:41 -0500)]
zfs-module-parameters(5): add all missing items

I ran a report against the output of `modinfo zfs.ko`. This commit adds
everything missing and corrects a few renamed module parameters.
Specifically:

* zfs_checksums_per second renamed in ad796b8a3
* vdev_ms_count_limit renamed in c853f382d

Also fixes some variable type inconsistencies (unsigned int => uint)

Reviewed-by: George Amanakis <gamanakis@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: DHE <git@dehacked.net>
Closes #9809

4 years agoZTS: Add sunos.run to dist data
Ryan Moeller [Tue, 7 Jan 2020 20:38:12 +0000 (15:38 -0500)]
ZTS: Add sunos.run to dist data

This was missed when the file was introduced.

Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes #9815

4 years agoFix "zpool add -n" for dedup, special and log devices
loli10K [Mon, 6 Jan 2020 23:40:06 +0000 (00:40 +0100)]
Fix "zpool add -n" for dedup, special and log devices

For dedup, special and log devices "zpool add -n" does not print
correctly their vdev type:

~# zpool add -n pool dedup /tmp/dedup special /tmp/special log /tmp/log
would update 'pool' to the following configuration:
pool
  /tmp/normal
  /tmp/dedup
  /tmp/special
  /tmp/log

This could lead storage administrators to modify their ZFS pools to
unexpected and unintended vdev configurations.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes #9783
Closes #9390

4 years agoFix QAT allocation failure return value
Brian Behlendorf [Mon, 6 Jan 2020 19:17:53 +0000 (11:17 -0800)]
Fix QAT allocation failure return value

When qat_compress() fails to allocate the required contiguous memory
it mistakenly returns success.  This prevents the fallback software
compression from taking over and (un)compressing the block.

Resolve the issue by correctly setting the local 'status' variable
on all exit paths.  Furthermore, initialize it to CPA_STATUS_FAIL
to ensure qat_compress() always fails safe to guard against any
similar bugs in the future.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9784
Closes #9788

4 years agoZTS: Cleanup partition tables
Brian Behlendorf [Mon, 6 Jan 2020 19:14:19 +0000 (11:14 -0800)]
ZTS: Cleanup partition tables

The cleanup_devices function should remove any partitions created
on the device and force the partition table to be reread.  This
is needed to ensure that blkid has an up to date version of what
devices and partitions are used by zfs.

The cleanup_devices call was removed from inuse_008_pos.ksh since
it operated on partitions instead of devices and was not needed.

Lastly ddidecode may be called by parted and was therefore added
to the constrained path.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9806

4 years agoFix ZPOOL_VDEV_NAME_PATH option description
Brian Behlendorf [Mon, 6 Jan 2020 18:43:32 +0000 (10:43 -0800)]
Fix ZPOOL_VDEV_NAME_PATH option description

The corresponding zpool status option is -P and not -p.  Update
this description to reference the correct option.

Reviewed-by: loli10K <ezomori.nozomu@gmail.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9803

4 years agoZTS: Add helper for disk device check
Ryan Moeller [Fri, 3 Jan 2020 17:10:17 +0000 (12:10 -0500)]
ZTS: Add helper for disk device check

Replace `test -b` and equivalents with `is_disk_device`, so that `-c`
is used instead on FreeBSD which has no block cache layer for devices.

Reviewed-by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes #9795

4 years agoZTS: Move dumpdev tests to sunos.run
Ryan Moeller [Fri, 3 Jan 2020 17:08:23 +0000 (12:08 -0500)]
ZTS: Move dumpdev tests to sunos.run

Neither FreeBSD nor Linux support dumping to zvols.

DilOS still uses these tests, so the files are kept and the tests have
been relocated to sunos.run.

An `is_illumos` function was added to libtest.shlib to eliminate some
awkward platform checks.

A few functions that are not expected to be used outside of illumos
have been sanitized of extraneous FreeBSD adaptations.

Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes #9794

4 years agoStatic symbols exported by ICP
Brian Behlendorf [Fri, 3 Jan 2020 02:08:45 +0000 (18:08 -0800)]
Static symbols exported by ICP

The crypto_cipher_init_prov and crypto_cipher_init are declared static
and should not be exported by the ICP.  This resolves the following
warnings observed when building with the 5.4 kernel.

WARNING: "crypto_cipher_init" [.../icp] is a static EXPORT_SYMBOL
WARNING: "crypto_cipher_init_prov" [.../icp] is a static EXPORT_SYMBOL

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9791

4 years agoAdd FreeBSD core handling in zloop.sh
Ryan Moeller [Thu, 2 Jan 2020 21:48:06 +0000 (16:48 -0500)]
Add FreeBSD core handling in zloop.sh

And use the correct path to libtool and ztest.

Reviewed-By: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes #9790

4 years agoImprove Pull Request guidelines
Kjeld Schouten-Lebbing [Mon, 30 Dec 2019 17:24:41 +0000 (18:24 +0100)]
Improve Pull Request guidelines

- Splits PR advice into two sections.
- Add "co-authored-by" instructions.
- Add description of draft PR and when using it is appropriate.
- Reword ZFS Test Suite checklist question.
- Link to zfs-tests.sh and zloop.sh.

Reviewed-By: Marcel Schilling <marcel.schilling@mdc-berlin.de>
Reviewed-By: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-By: Richard Laager <rlaager@wiktel.com>
Co-Authored-By: Marcel Schilling <marcel.schilling@mdc-berlin.de>
Co-Authored-By: Brian Behlendorf <behlendorf1@llnl.gov>
Co-Authored-By: Richard Laager <rlaager@wiktel.com>
Signed-off-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
Closes #9753

4 years agozdb: print block checksums with 6 d's of verbosity
Ned Bass [Mon, 30 Dec 2019 17:14:40 +0000 (09:14 -0800)]
zdb: print block checksums with 6 d's of verbosity

Include checksums in the output of 'zdb -dddddd' along
with other indirect block information already displayed.

Example output follows (with long lines trimmed):

$ zdb -dddddd tank/fish 128
Dataset tank/fish [ZPL], ID 259, cr_txg 10, 16.2M, 93 objects, rootbp DV

    Object  lvl   iblk   dblk  dsize  dnsize  lsize   %full  type
       128    2   128K   128K   634K     512     1M  100.00  ZFS plain f
                                               168   bonus  System attri
    dnode flags: USED_BYTES USERUSED_ACCOUNTED USEROBJUSED_ACCOUNTED
    dnode maxblkid: 7
    path    /c
    uid     0
    gid     0
    atime    Sat Dec 21 10:49:26 2019
    mtime    Sat Dec 21 10:49:26 2019
    ctime    Sat Dec 21 10:49:26 2019
    crtime    Sat Dec 21 10:49:26 2019
    gen    41
    mode    100755
    size    964592
    parent    34
    links    1
    pflags    40800000104
Indirect blocks:
               0 L1  0:2c0000:400 0:c021e00:400 20000L/400P F=8 B=41/41
               0  L0 0:227800:13800 20000L/13800P F=1 B=41/41 cksum=167a
           20000  L0 0:25ec00:17c00 20000L/17c00P F=1 B=41/41 cksum=2312
           40000  L0 0:276800:18400 20000L/18400P F=1 B=41/41 cksum=24e0
           60000  L0 0:2a7800:18800 20000L/18800P F=1 B=41/41 cksum=25be
           80000  L0 0:28ec00:18c00 20000L/18c00P F=1 B=41/41 cksum=2579
           a0000  L0 0:24d000:11c00 20000L/11c00P F=1 B=41/41 cksum=140a
           c0000  L0 0:23b000:12000 20000L/12000P F=1 B=41/41 cksum=164e
           e0000  L0 0:221e00:5a00 20000L/5a00P F=1 B=41/41 cksum=9de790

        segment [00000000000000000000000000100000) size    1M

Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Closes #9765

4 years agozfs-load-key.sh: ${ZFS} is not the zfs binary
Ben Cordero [Sun, 29 Dec 2019 19:25:01 +0000 (19:25 +0000)]
zfs-load-key.sh: ${ZFS} is not the zfs binary

A change[1] was merged yesterday that should refer
to the zfs binary in the initramfs, but is actually
an unset shell variable.

This commit changes this line to call `zfs` directly
like the surrounding code.

[1]: cb5b875b273235a4a3ed28e16f416d5bb8865166

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Garrett Fields <ghfields@gmail.com>
Reviewed-by: Richard Laager <rlaager@wiktel.com>
Signed-off-by: Ben Cordero <bencord0@condi.me>
Closes #9780

4 years agoZTS: Fix pool_state cleanup
Brian Behlendorf [Sat, 28 Dec 2019 16:43:23 +0000 (08:43 -0800)]
ZTS: Fix pool_state cleanup

The externally faulted vdev should be brought back online and have
its errors cleared before the pool is destroyed.  Failure to do so
will leave a vdev with a valid active label.  This vdev may then
not be used to create a new pool without the -f flag potentially
leading to subsequent test failures.

Additionally remove an unreachable log_pass from setup.ksh.

Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9777

4 years agoZTS: Replace /var/tmp with $TEST_BASE_DIR
Brian Behlendorf [Sat, 28 Dec 2019 00:41:16 +0000 (16:41 -0800)]
ZTS: Replace /var/tmp with $TEST_BASE_DIR

Remove a few hardcoded instances of /var/tmp.  This should use
the $TEST_BASE_DIR in order to allow the ZTS to be optionally
run in an alternate directory using `zfs-tests.sh -d <path>`.

Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9775

4 years agoZTS: zfs_program_json
Brian Behlendorf [Fri, 27 Dec 2019 20:12:41 +0000 (12:12 -0800)]
ZTS: zfs_program_json

As of Python 3.5 the default behavior of json.tool was changed to
preserve the input order rather than lexical order.  The test case
expects the output to be sorted so apply the --sort-keys option
to the json.tool command when using Python 3.5 and the option is
supported.

    https://docs.python.org/3/library/json.html#module-json.tool

Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9774

4 years agoZTS: devices_001_pos and devices_002_neg
Brian Behlendorf [Fri, 27 Dec 2019 20:11:27 +0000 (12:11 -0800)]
ZTS: devices_001_pos and devices_002_neg

Update the devices_001_pos and devices_002_neg test cases such that the
special block device file created is backed by a ZFS volume.  Specifying
a specific device allows the major and minor numbers to be easily
determined.  Furthermore, this avoids the potentially dangerous behavior
of opening the first block device we happen to find under /dev/.

Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9773

4 years agoAvoid some crashes when importing a pool with corrupt metadata
Steve Mokris [Thu, 26 Dec 2019 18:57:05 +0000 (13:57 -0500)]
Avoid some crashes when importing a pool with corrupt metadata

- Skip invalid DVAs when importing pools in readonly mode
  (in addition to when the config is untrusted).

- Upon encountering a DVA with a null VDEV, fail gracefully
  instead of panicking with a NULL pointer dereference.

Reviewed-by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Steve Mokris <smokris@softpixel.com>
Closes #9022

4 years agoIn initramfs, do not prompt if keylocation is "file://"
sam-lunt [Thu, 26 Dec 2019 18:55:20 +0000 (12:55 -0600)]
In initramfs, do not prompt if keylocation is "file://"

If the encryption key is stored in a file, the initramfs should not
prompt for the password. For example, this could be the case if the boot
partition is stored on removable media that is only present at boot time

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Garrett Fields <ghfields@gmail.com>
Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Sam Lunt <samuel.j.lunt@gmail.com>
Closes #9764

4 years agolibspl: declare aok extern in header
Nick Black [Thu, 26 Dec 2019 18:52:14 +0000 (13:52 -0500)]
libspl: declare aok extern in header

Rather than defining a new instance of 'aok' in every compilation
unit which includes this header, there is a single instance
defined in zone.c, and the header now only declares an extern.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Zuchowski <pzuchowski@datto.com>
Signed-off-by: Nick Black <dankamongmen@gmail.com>
Closes #9752

4 years agoCancel initialize and TRIM before vdev_metaslab_fini()
Brian Behlendorf [Thu, 26 Dec 2019 18:50:23 +0000 (10:50 -0800)]
Cancel initialize and TRIM before vdev_metaslab_fini()

Any running 'zpool initialize' or TRIM must be cancelled prior
to the vdev_metaslab_fini() call in spa_vdev_remove_log() which
will unload the metaslabs and set ms->ms_group == NULL.

Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #8602
Closes #9751

4 years agoZTS: Test case failures
Brian Behlendorf [Thu, 26 Dec 2019 18:49:07 +0000 (10:49 -0800)]
ZTS: Test case failures

* large_dnode_008_pos - Force a pool sync before invoking zdb to
  ensure the updated dnode blocks have been persisted to disk.

* refreserv_raidz - Wait for the /dev/zvol links to be both created
  and removed, this is important because the same device volume
  names are being used repeatedly.

* btree_test - Add missing .gitignore file for btree_test binary.

Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9769

4 years agoUpdate maximum kernel version to 5.4
Brian Behlendorf [Mon, 23 Dec 2019 22:24:36 +0000 (14:24 -0800)]
Update maximum kernel version to 5.4

Increase the maximum supported kernel version to 5.4.  This was
verified using the Fedora 5.4.2-300.fc31.x86_64 kernel.

Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9754
Closes #9759

4 years agoFix test pattern in zts-report.py
Ryan Moeller [Fri, 20 Dec 2019 17:31:59 +0000 (12:31 -0500)]
Fix test pattern in zts-report.py

The pattern was not updated to match when the test output changed to
include a platform identifier for platform specific tests.

Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes #9750

4 years agoColorize zpool status output
Tony Hutter [Fri, 20 Dec 2019 00:26:07 +0000 (16:26 -0800)]
Colorize zpool status output

If the ZFS_COLOR env variable is set, then use ANSI color
output in zpool status:

- Column headers are bold
- Degraded or offline pools/vdevs are yellow
- Non-zero error counters and faulted vdevs/pools are red
- The 'status:' and 'action:' sections are yellow if they're
  displaying a warning.

This also includes a new 'faketty' function in libtest.shlib that is
compatible with FreeBSD (code provided by @freqlabs).

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #9340

4 years agoZTS: Various test case fixes
Brian Behlendorf [Thu, 19 Dec 2019 23:32:56 +0000 (15:32 -0800)]
ZTS: Various test case fixes

* devices_001_pos and devices_002_neg - Failing after FreeBSD ZTS
  merged due to missing 'function' keyword for create_dev_file_linux.

* pool_state - Occasionally fails due to an insufficient delay
  before checking 'zpool status'.  Increasing the delay from 1 to 3
  seconds resolved the issue in local testing.

* procfs_list_basic - Fails when run in-tree because the logged
  command is actually 'lt-zfs'.  Updated the regex accordingly.

Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9748

4 years agoTests for btree implementation used by range trees
John Wren Kennedy [Thu, 19 Dec 2019 19:53:55 +0000 (12:53 -0700)]
Tests for btree implementation used by range trees

Additional test cases for the btree implementation, see #9181.

Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: John Kennedy <john.kennedy@delphix.com>
Closes #9717

4 years agoUpdate zfs.sh work on FreeBSD
Ryan Moeller [Thu, 19 Dec 2019 17:31:16 +0000 (12:31 -0500)]
Update zfs.sh work on FreeBSD

Extend the zfs.sh script to load and unload zfs kmods on FreeBSD.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes #9746

4 years agocppcheck: (warning) Possible null pointer dereference: nvh
Brian Behlendorf [Tue, 17 Dec 2019 00:03:31 +0000 (16:03 -0800)]
cppcheck: (warning) Possible null pointer dereference: nvh

Move the 'nvh = (void *)buf' assignment after the 'buf == NULL'
check to resolve the warning.  Interestingly, cppcheck 1.88
correctly determines that the existing code is safe, while
cppcheck 1.86 reports the warning.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9732

4 years agocppcheck: (error) Address of local auto-variable assigned
Brian Behlendorf [Mon, 16 Dec 2019 23:53:43 +0000 (15:53 -0800)]
cppcheck: (error) Address of local auto-variable assigned

Suppress autoVariables warnings in the lua interpreter.  The usage
here while unconventional in intentional and the same as upstream.

[module/lua/ldebug.c:327]: (error) Address of local auto-variable
    assigned to a function parameter.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9732

4 years agocppcheck: (error) Null pointer dereference: who_perm
Brian Behlendorf [Mon, 16 Dec 2019 23:49:28 +0000 (15:49 -0800)]
cppcheck: (error) Null pointer dereference: who_perm

As indicated by the VERIFY the local who_perm variable can never
be NULL in parse_fs_perm().  Due to the existence of the is_set
conditional, which is always true, cppcheck 1.88 was reporting
a possible NULL reference.  Resolve the issue by removing the
extraneous is_set variable.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9732

4 years agocppcheck: (warning) Possible null pointer dereference: dnp
Brian Behlendorf [Mon, 16 Dec 2019 18:55:11 +0000 (10:55 -0800)]
cppcheck: (warning) Possible null pointer dereference: dnp

The dnp argument can only be set to NULL when the DNODE_DRY_RUN flag
is set.  In which case, an early return path will be executed and a
NULL pointer dereference at the given location is impossible.  Add
an additional ASSERT to silence the cppcheck warning and document
that dbp must never be NULL at the point in the function.

[module/zfs/dnode.c:1566]: (warning) Possible null pointer deref: dnp

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9732

4 years agocppcheck: (error) Memory leak: vtoc
Brian Behlendorf [Mon, 16 Dec 2019 18:40:29 +0000 (10:40 -0800)]
cppcheck: (error) Memory leak: vtoc

Resolve the reported memory leak by using a dedicated local vptr
variable to store the pointer reported by calloc().  Only assign the
passed **vtoc function argument on success, in all other cases vptr
is freed.

[lib/libefi/rdwr_efi.c:403]: (error) Memory leak: vtoc
[lib/libefi/rdwr_efi.c:422]: (error) Memory leak: vtoc
[lib/libefi/rdwr_efi.c:440]: (error) Memory leak: vtoc
[lib/libefi/rdwr_efi.c:454]: (error) Memory leak: vtoc
[lib/libefi/rdwr_efi.c:470]: (error) Memory leak: vtoc

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9732

4 years agocppcheck: (error) Shifting signed 64-bit value by 63 bits
Ubuntu [Sat, 14 Dec 2019 00:16:42 +0000 (00:16 +0000)]
cppcheck: (error) Shifting signed 64-bit value by 63 bits

As of cppcheck 1.82 surpress the warning regarding shifting too many
bits for __divdi3() implemention.  The algorithm used here is correct.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9732

4 years agocppcheck: (error) Uninitialized variable
Ubuntu [Sat, 14 Dec 2019 00:07:48 +0000 (00:07 +0000)]
cppcheck: (error) Uninitialized variable

As of cppcheck 1.82 warnings are issued when using the list_for_each_*
functions with an uninitialized variable.  Functionally, this is fine
but to resolve the warning initialize these variables.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9732

4 years agocppcheck: (error) Uninitialized variable
Ubuntu [Fri, 13 Dec 2019 23:56:37 +0000 (23:56 +0000)]
cppcheck: (error) Uninitialized variable

Resolve the following uninitialized variable warnings.  In practice
these were unreachable due to the goto.  Replacing the goto with a
return resolves the warning and yields more readable code.

[module/icp/algs/modes/ccm.c:892]: (error) Uninitialized variable: ccm_param
[module/icp/algs/modes/ccm.c:893]: (error) Uninitialized variable: ccm_param
[module/icp/algs/modes/gcm.c:564]: (error) Uninitialized variable: gcm_param
[module/icp/algs/modes/gcm.c:565]: (error) Uninitialized variable: gcm_param
[module/icp/algs/modes/gcm.c:599]: (error) Uninitialized variable: gmac_param
[module/icp/algs/modes/gcm.c:600]: (error) Uninitialized variable: gmac_param

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9732

4 years agoExchanged two "${ZFS} get -H -o value" commands
Garrett Fields [Wed, 18 Dec 2019 20:32:31 +0000 (15:32 -0500)]
Exchanged two "${ZFS} get -H -o value" commands

Initramfs uses "get_fs_value()" elsewhere.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
Signed-off-by: Garrett Fields <ghfields@gmail.com>
Closes #9736

4 years agoUpdate ZTS to work on FreeBSD
Matthew Macy [Wed, 18 Dec 2019 20:29:43 +0000 (12:29 -0800)]
Update ZTS to work on FreeBSD

Update the common ZTS scripts and individual test cases as needed
in order to allow them to be run on FreeBSD.  The high level goal
is to provide compatibility wrappers whenever possible to minimize
changes to individual test cases.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes #9692

4 years agoMinor performance fix for NEON RAID-Z
Romain Dolbeau [Wed, 18 Dec 2019 03:34:52 +0000 (04:34 +0100)]
Minor performance fix for NEON RAID-Z

The NEON code replicates too closely the SSE code, including
a masked 16-bits shift. But NEON, like AltiVec (#9539), has
unsigned 8-bits shift, so use that instead and drop the masking.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Romain Dolbeau <romain.dolbeau@european-processor-initiative.eu>
Closes #9725

4 years agoCreate symbolic links in /dev/disk/by-vdev for nvme disk devices
Thomas Geppert [Wed, 18 Dec 2019 01:50:20 +0000 (02:50 +0100)]
Create symbolic links in /dev/disk/by-vdev for nvme disk devices

The existing rules miss nvme disk devices because of the trailing
digits in the KERNEL device name, e.g. nvme0n1. Partitions of nvme
disk devices are already properly handled by the existing rule for
ENV{DEVTYPE}=="partition".

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Thomas Geppert <geppi@digitx.de>
Closes #9730

4 years agoMoves Codecov Ignore to LCOV
Kjeld Schouten-Lebbing [Wed, 18 Dec 2019 01:47:58 +0000 (02:47 +0100)]
Moves Codecov Ignore to LCOV

Rely on ax_code_coverage to exclude test directories.

- Removes broken codecov ignore
- Places ignore section in ax_code_coverage
- Forwards users from codecov to LCOV for ignores

Reviewed-by: Prakash Surya <prakash.surya@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Laager <rlaager@wiktel.com>
Signed-off-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
Closes #9726

4 years agoForce systems with kernel option "quiet" to display prompt for password
Garrett Fields [Wed, 18 Dec 2019 01:45:06 +0000 (20:45 -0500)]
Force systems with kernel option "quiet" to display prompt for password

On systems that utilize TTY for password entry, if the kernel
option "quiet" is set, the system would appear to freeze on a
blank screen, when in fact it is waiting for password entry
from the user.

Since TTY is the fallback method, this has no effect on systemd
or plymouth password prompting.

By temporarily setting "printk" to "7", running the command,
then resuming with the original "printk" state, the user can
see the password prompt.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Garrett Fields <ghfields@gmail.com>
Closes #9731

4 years agoinitramfs: setup keymapping and video for prompts
Richard Laager [Tue, 17 Dec 2019 00:54:51 +0000 (18:54 -0600)]
initramfs: setup keymapping and video for prompts

From Steve Langasek <steve.langasek@canonical.com>:
> The poorly-named 'FRAMEBUFFER' option in initramfs-tools controls
> whether the console_setup and plymouth scripts are included and used
> in the initramfs. These are required for any initramfs which will be
> prompting for user input: console_setup because without it the user's
> configured keymap will not be set up, and plymouth because you are
> not guaranteed to have working video output in the initramfs without
> it (e.g. some nvidia+UEFI configurations with the default GRUB
> behavior).

> The zfs initramfs script may need to prompt the user for passphrases
> for encrypted zfs datasets, and we don't know definitively whether
> this is the case or not at the time the initramfs is constructed (and
> it's difficult to dynamically populate initramfs config variables
> anyway), therefore the zfs-initramfs package should just set
> FRAMEBUFFER=yes in a conf snippet the same way that the
> cryptsetup-initramfs package does
> (/usr/share/initramfs-tools/conf-hooks.d/cryptsetup).

https://bugs.launchpad.net/ubuntu/+source/zfs-linux/+bug/1856408

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Steve Langasek <steve.langasek@canonical.com>
Signed-off-by: Richard Laager <rlaager@wiktel.com>
Closes #9723

4 years agoFix zfs_xattr_owner_unlinked on FreeBSD and comment
Matthew Macy [Mon, 16 Dec 2019 17:49:05 +0000 (09:49 -0800)]
Fix zfs_xattr_owner_unlinked on FreeBSD and comment

Explain FreeBSD VFS' unfortunate idiosyncratic locking requirements.
There is no functional change for other platforms.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9720

4 years agoDon't fail to apply umask for O_TMPFILE files
Tomohiro Kusumi [Fri, 13 Dec 2019 23:02:23 +0000 (08:02 +0900)]
Don't fail to apply umask for O_TMPFILE files

Apply umask to `mode` which will eventually be applied to inode.
This is needed since VFS doesn't apply umask for O_TMPFILE files.

(Note that zpl_init_acl() applies `ip->i_mode &= ~current_umask();`
only when POSIX ACL is used.)

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Closes #8997
Closes #8998

4 years agoAllow empty ds_props_obj to be destroyed
Tom Caputi [Fri, 13 Dec 2019 19:51:39 +0000 (14:51 -0500)]
Allow empty ds_props_obj to be destroyed

Currently, 'zfs list' and 'zfs get' commands can be slow when
working with snapshots that have a ds_props_obj. This is
because the code that discovers all of the properties for these
snapshots needs to read this object for each snapshot, which
almost always ends up causing an extra random synchronous read
for each snapshot. This performance penalty exists even if the
properties on that snapshot have been unset because the object
is normally only freed when the snapshot is freed, even though
it is only created when it is needed.

This patch allows the user to regain 'zfs list' performance on
these snapshots by destroying the ds_props_obj when it no longer
has any entries left. In practice on a production machine, this
optimization seems to make 'zfs list' about 55% faster.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Zuchowski <pzuchowski@datto.com>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #9704

4 years agoMake zfs_replay.c work on FreeBSD
Matthew Macy [Fri, 13 Dec 2019 15:54:10 +0000 (07:54 -0800)]
Make zfs_replay.c work on FreeBSD

FreeBSD's vfs currently doesn't permit file systems
to do their own locking. To avoid having to have
duplicate zfs functions with and without locking add
locking here. With luck these changes can be removed
in the future.

Reviewed-by: Sean Eric Fagan <sef@ixsystems.com>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9715

4 years agoFix use-after-free of vd_path in spa_vdev_remove()
Matthew Ahrens [Wed, 11 Dec 2019 23:38:21 +0000 (15:38 -0800)]
Fix use-after-free of vd_path in spa_vdev_remove()

After spa_vdev_remove_aux() is called, the config nvlist is no longer
valid, as it's been replaced by the new one (with the specified device
removed).  Therefore any pointers into the nvlist are no longer valid.
So we can't save the result of
`fnvlist_lookup_string(nv, ZPOOL_CONFIG_PATH)` (in vd_path) across the
call to spa_vdev_remove_aux().

Instead, use spa_strdup() to save a copy of the string before calling
spa_vdev_remove_aux.

Found by AddressSanitizer:

ERROR: AddressSanitizer: heap-use-after-free on address ...
READ of size 34 at 0x608000a1fcd0 thread T686
    #0 0x7fe88b0c166d  (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x5166d)
    #1 0x7fe88a5acd6e in spa_strdup spa_misc.c:1447
    #2 0x7fe88a688034 in spa_vdev_remove vdev_removal.c:2259
    #3 0x55ffbc7748f8 in ztest_vdev_aux_add_remove ztest.c:3229
    #4 0x55ffbc769fba in ztest_execute ztest.c:6714
    #5 0x55ffbc779a90 in ztest_thread ztest.c:6761
    #6 0x7fe889cbc6da in start_thread
    #7 0x7fe8899e588e in __clone

0x608000a1fcd0 is located 48 bytes inside of 88-byte region
freed by thread T686 here:
    #0 0x7fe88b14e7b8 in __interceptor_free
    #1 0x7fe88ae541c5 in nvlist_free nvpair.c:874
    #2 0x7fe88ae543ba in nvpair_free nvpair.c:844
    #3 0x7fe88ae57400 in nvlist_remove_nvpair nvpair.c:978
    #4 0x7fe88a683c81 in spa_vdev_remove_aux vdev_removal.c:185
    #5 0x7fe88a68857c in spa_vdev_remove vdev_removal.c:2221
    #6 0x55ffbc7748f8 in ztest_vdev_aux_add_remove ztest.c:3229
    #7 0x55ffbc769fba in ztest_execute ztest.c:6714
    #8 0x55ffbc779a90 in ztest_thread ztest.c:6761
    #9 0x7fe889cbc6da in start_thread

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #9706

4 years agoRelocate common quota functions to shared code
Ryan Moeller [Wed, 11 Dec 2019 20:12:08 +0000 (15:12 -0500)]
Relocate common quota functions to shared code

The quota functions are common to all implementations and can be
moved to common code.  As a simplification they were moved to the
Linux platform code in the initial refactoring.

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes #9710

4 years agoAdd FreeBSD jail support hooks
Matthew Macy [Wed, 11 Dec 2019 19:58:37 +0000 (11:58 -0800)]
Add FreeBSD jail support hooks

Add the 'zfs jail/unjail' subcommands along with the relevant
documentation from FreeBSD.  This feature is not supported on
Linux and still requires the match kernel ioctls which will
be included when the FreeBSD platform code is integrated.

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes #9686

4 years agoEliminate Linux specific inode usage from common code
Matthew Macy [Wed, 11 Dec 2019 19:53:57 +0000 (11:53 -0800)]
Eliminate Linux specific inode usage from common code

Change many of the znops routines to take a znode rather
than an inode so that zfs_replay code can be largely shared
and in the future the much of the znops code may be shared.

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9708

4 years agozio_decompress_data always ASSERTs successful decompression
Paul Zuchowski [Tue, 10 Dec 2019 23:51:58 +0000 (18:51 -0500)]
zio_decompress_data always ASSERTs successful decompression

This interferes with zdb_read_block trying all the decompression
algorithms when the 'd' flag is specified, as some are
expected to fail.  Also control the output when guessing
algorithms, try the more common compression types first, allow
specifying lsize/psize, and fix an uninitialized variable.

Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Paul Zuchowski <pzuchowski@datto.com>
Closes #9612
Closes #9630

4 years agoSIMD: Use alloc_pages_node to force alignment
Fabian-Gruenbichler [Tue, 10 Dec 2019 20:53:25 +0000 (21:53 +0100)]
SIMD: Use alloc_pages_node to force alignment

fxsave and xsave require the target address to be 16-/64-byte aligned.

kmalloc(_node) does not (yet) offer such fine-grained control over
alignment[0,1], even though it does "the right thing" most of the time
for power-of-2 sizes. unfortunately, alignment is completely off when
using certain debugging or hardening features/configs, such as KASAN,
slub_debug=Z or the not-yet-upstream SLAB_CANARY.

Use alloc_pages_node() instead which allows us to allocate page-aligned
memory. Since fpregs_state is padded to a full page anyway, and this
code is only relevant for x86 which has 4k pages, this approach should
not allocate any unnecessary memory but still guarantee the needed
alignment.

0: https://lwn.net/Articles/787740/
1: https://lore.kernel.org/linux-block/20190826111627.7505-1-vbabka@suse.cz/

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9608
Closes #9674

4 years agoAbstract away platform specific superblock references
Matthew Macy [Tue, 10 Dec 2019 17:21:07 +0000 (09:21 -0800)]
Abstract away platform specific superblock references

The zfsvfs->z_sb field is Linux specified and should be abstracted.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9697

4 years agoZTS: Fixes for spurious failures of resilver_restart_001 test
John Poduska [Tue, 10 Dec 2019 17:10:36 +0000 (12:10 -0500)]
ZTS: Fixes for spurious failures of resilver_restart_001 test

The resilver restart test was reported as failing about 2% of the
time. Two issues were found:

- The event log wasn't large enough, so resilver events were missing
- One 'zpool sync' wasn't enough for resilver to start after zinject

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: John Poduska <jpoduska@datto.com>
Issue #9588
Closes #9677
Closes #9703

4 years agoExclude data from cores unconditionally and metadata conditionally
Matthew Macy [Mon, 9 Dec 2019 20:29:56 +0000 (12:29 -0800)]
Exclude data from cores unconditionally and metadata conditionally

This change allows us to align the code dump logic across platforms.

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Don Brady <don.brady@delphix.com>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9691

4 years agoMark dsl_dataset_deactivate_feature_impl static
Matthew Macy [Mon, 9 Dec 2019 20:26:33 +0000 (12:26 -0800)]
Mark dsl_dataset_deactivate_feature_impl static

The dsl_dataset_deactivate_feature_impl() function is private and
should be marked as such.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Laager <rlaager@wiktel.com>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9696

4 years agoZTS: Fix zpool_reopen_001_pos
Brian Behlendorf [Mon, 9 Dec 2019 19:09:14 +0000 (11:09 -0800)]
ZTS: Fix zpool_reopen_001_pos

Update the vdev_disk_open() retry logic to use a specified number
of milliseconds to be more robust.  Additionally, on failure log
both the time waited and requested timeout to the internal log.

The default maximum allowed open retry time has been increased
from 500ms to 1000ms.

Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9680

4 years agoFixes typo from #9681
Kjeld Schouten [Mon, 9 Dec 2019 18:10:55 +0000 (19:10 +0100)]
Fixes typo from #9681

Going from #9672 to 9681 I made a typo.  This removes that typo.

    The pattern folder /* will not match recursively in the folder.
    Please use this folder /**/*

    source: https://docs.codecov.io/docs/ignoring-paths

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Reviewed-by: Richard Laager <rlaager@wiktel.com>
Signed-off-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
Closes #9700

4 years agoDisable sysfs feature checks on FreeBSD
Matthew Macy [Fri, 6 Dec 2019 17:44:29 +0000 (09:44 -0800)]
Disable sysfs feature checks on FreeBSD

The sysfs infrastructure for reporting supported features and
properties is Linux specific.  Disable it on FreeBSD until it can
be extended to be more portable.

Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9684

4 years agoSet send_realloc_files.ksh to use properties.shlib
Kjeld Schouten [Fri, 6 Dec 2019 17:37:48 +0000 (18:37 +0100)]
Set send_realloc_files.ksh to use properties.shlib

This sets send_realloc_files.ksh to use properties.shlib
(like the other compression related tests)

It was missing from #9645

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
Issue #9645
Closes #9679

4 years agoICP: Fix out of bounds write
Attila Fülöp [Fri, 6 Dec 2019 17:36:19 +0000 (18:36 +0100)]
ICP: Fix out of bounds write

If gcm_mode_encrypt_contiguous_blocks() is called more than once
in succession, with the accumulated lengths being less than
blocksize, ctx->copy_to will be incorrectly advanced. Later, if
out is NULL, the bcopy at line 114 will overflow
ctx->gcm_copy_to since ctx->gcm_remainder_len is larger than the
ctx->gcm_copy_to buffer can hold.

The fix is to set ctx->copy_to only if it's not already set.

For ZoL the issue may be academic, since in all my testing I wasn't
able to hit neither of both conditions needed to trigger it, but
other consumers can easily do so.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tom Caputi <tcaputi@datto.com>
Signed-off-by: Attila Fülöp <attila@fueloep.org>
Closes #9660

4 years agoFix codecov ignore, wrong syntax
Kjeld Schouten [Fri, 6 Dec 2019 17:35:02 +0000 (18:35 +0100)]
Fix codecov ignore, wrong syntax

The current codecov ignore syntax is incorrect.
Corrected it.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Signed-off-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
Closes #9681

4 years agoRemove stale ASSERTV comment
Matthew Macy [Fri, 6 Dec 2019 17:33:27 +0000 (09:33 -0800)]
Remove stale ASSERTV comment

Followup for #9671, remove stale comment.

Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Issue #9671
Closes #9682

4 years agoDisable EDONR on FreeBSD
Matthew Macy [Thu, 5 Dec 2019 21:10:29 +0000 (13:10 -0800)]
Disable EDONR on FreeBSD

FreeBSD uses its own crypto framework in-kernel which, at this time,
has no EDONR implementation.

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Allan Jude <allanjude@freebsd.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes #9664

4 years agoAdd ZFS_IOC offsets for FreeBSD
Matthew Macy [Thu, 5 Dec 2019 21:06:51 +0000 (13:06 -0800)]
Add ZFS_IOC offsets for FreeBSD

FreeBSD requires three additional ioctls, they are ZFS_IOC_NEXTBOOT,
ZFS_IOC_JAIL, and ZFS_IOC_UNJAIL.  These have been added after the
Linux-specific ioctls.  The range 0x80-0xFF has been reserved for
future optional platform-specific ioctls.  Any platform may choose
to implement these as appropriate.

None of the existing ioctl numbers have been changed to maintain
compatibility.  For Linux no vectors have been registered for the
new ioctls and they are reported as unsupported.

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Allan Jude <allanjude@freebsd.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9667

4 years agoRefactor deadman set failmode to be cross platform
Matthew Macy [Thu, 5 Dec 2019 20:40:45 +0000 (12:40 -0800)]
Refactor deadman set failmode to be cross platform

Update zfs_deadman_failmode to use the ZFS_MODULE_PARAM_CALL
wrapper, and split the common and platform specific portions.

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9670

4 years agoReplace ASSERTV macro with compiler annotation
Matthew Macy [Thu, 5 Dec 2019 20:37:00 +0000 (12:37 -0800)]
Replace ASSERTV macro with compiler annotation

Remove the ASSERTV macro and handle suppressing unused
compiler warnings for variables only in ASSERTs using the
__attribute__((unused)) compiler annotation.  The annotation
is understood by both gcc and clang.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9671

4 years agoFix reporting of L2ARC hits/misses in arc_summary3
George Amanakis [Wed, 4 Dec 2019 21:24:56 +0000 (16:24 -0500)]
Fix reporting of L2ARC hits/misses in arc_summary3

arc_summary3 reports L2ARC hits and misses as Bytes, whereas they
should be reported as events. arc_summary2 reports these correctly.

Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: George Amanakis <gamanakis@gmail.com>
Closes #9669

4 years agoRefactor zfs_context.h to build on FreeBSD
Matthew Macy [Wed, 4 Dec 2019 21:12:57 +0000 (13:12 -0800)]
Refactor zfs_context.h to build on FreeBSD

- on Linux move Linux specific headers to zfs_context_os.h
- on FreeBSD move FreeBSD specific definitions to zfs_context_os.h
- remove duplicate tsd_ definitions
- remove unused AT_TYPE

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Don Brady <don.brady@delphix.com>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9668

4 years agoRefactor compression algorithm selection for tests
Kjeld Schouten [Wed, 4 Dec 2019 21:10:12 +0000 (22:10 +0100)]
Refactor compression algorithm selection for tests

- Moves compression algorithms for tests to properties.shlib
- Removes all compression algorithms levels from general tests
- Replaces on with lz4 for compression tests
- Removes random algorithm selection, if not needed
- Cleans copyright header formatting

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Michael Niewöhner <foss@mniewoehner.de>
Signed-off-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
Closes #9645

4 years agoFix zdb_read_block using zio after it is destroyed
Paul Zuchowski [Tue, 3 Dec 2019 22:37:15 +0000 (17:37 -0500)]
Fix zdb_read_block using zio after it is destroyed

The checksum display code of zdb_read_block uses a zio
to read in the block and then calls zio_checksum_compute.
Use a new zio in the call to zio_checksum_compute not the zio
from the read which has been destroyed by zio_wait.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Signed-off-by: Paul Zuchowski <pzuchowski@datto.com>
Closes #9644
Closes #9657

4 years agoICP: Fix null pointer dereference and use after free
Attila Fülöp [Tue, 3 Dec 2019 18:28:48 +0000 (19:28 +0100)]
ICP: Fix null pointer dereference and use after free

In gcm_mode_decrypt_contiguous_blocks(), if vmem_alloc() fails,
bcopy is called with a NULL pointer destination and a length > 0.
This results in undefined behavior. Further ctx->gcm_pt_buf is
freed but not set to NULL, leading to a potential write after
free and a double free due to missing return value handling in
crypto_update_uio(). The code as is may write to ctx->gcm_pt_buf
in gcm_decrypt_final() and may free ctx->gcm_pt_buf again in
aes_decrypt_atomic().

The fix is to slightly rework error handling and check the return
value in crypto_update_uio().

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tom Caputi <tcaputi@datto.com>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Attila Fülöp <attila@fueloep.org>
Closes #9659

4 years agoCodecov tweaks
Kjeld Schouten [Tue, 3 Dec 2019 18:23:48 +0000 (19:23 +0100)]
Codecov tweaks

Modify the Codecov settings to provide a more realistic and stable
report.  The following change were made:

- Precision has been limited to whole percents only, but will round
  to nearest. This means 0.0-0.49 will round to zero (no change) and
  0.51 will round to 1%.

- Exclude the tests/zfs-tests directory from the report.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
Closes #9650

4 years agoFix use-after-free in case of L2ARC prefetch failure
Alexander Motin [Tue, 3 Dec 2019 17:59:30 +0000 (12:59 -0500)]
Fix use-after-free in case of L2ARC prefetch failure

In case L2ARC read failed, l2arc_read_done() creates _different_ ZIO
to read data from the original storage device.  Unfortunately pointer
to the failed ZIO remains in hdr->b_l1hdr.b_acb->acb_zio_head, and if
some other read try to bump the ZIO priority, it will crash.

The problem is reproducible by corrupting L2ARC content and reading
some data with prefetch if l2arc_noprefetch tunable is changed to 0.
With the default setting the issue is probably not reproducible now.

Reviewed-by: Tom Caputi <tcaputi@datto.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored-By: iXsystems, Inc.
Closes #9648

4 years agoIncrease allowed 'special_small_blocks' maximum value
Brian Behlendorf [Tue, 3 Dec 2019 17:58:03 +0000 (09:58 -0800)]
Increase allowed 'special_small_blocks' maximum value

There may be circumstances where it's desirable that all blocks
in a specified dataset be stored on the special device.  Relax
the artificial 128K limit and allow the special_small_blocks
property to be set up to 1M.  When blocks >1MB have been enabled
via the zfs_max_recordsize module option, this limit is increased
accordingly.

Reviewed-by: Don Brady <don.brady@delphix.com>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9131
Closes #9355

4 years agoWrap module_param_call() routines under __linux__
Matthew Macy [Tue, 3 Dec 2019 17:56:15 +0000 (09:56 -0800)]
Wrap module_param_call() routines under __linux__

The module_param_call() functionality is currently still
Linux-specific and should be wrapped accordingly.

Reviewed-by: Allan Jude <allanjude@freebsd.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9666

4 years agoMark write_record static
Matthew Macy [Tue, 3 Dec 2019 17:51:44 +0000 (09:51 -0800)]
Mark write_record static

The write_record() function is private and should be marked as such.

Reviewed-by: Allan Jude <allanjude@freebsd.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9665

4 years agoMove linux qsort def to platform header
Matthew Macy [Tue, 3 Dec 2019 17:49:40 +0000 (09:49 -0800)]
Move linux qsort def to platform header

Moving qsort to the platform header allows each platform to
provide an appropriate sorting implementation.

Reviewed-by: Allan Jude <allanjude@freebsd.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9663

4 years agoAdapt gitignore for modules
Michael Niewöhner [Mon, 2 Dec 2019 21:23:47 +0000 (22:23 +0100)]
Adapt gitignore for modules

Remove the specific gitignore rules for module left-overs and add a
generic one in modules/.

Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
Closes #9656

4 years agoMove zfs_cmd_t copyin/copyout to platform code
Matthew Macy [Mon, 2 Dec 2019 18:08:27 +0000 (10:08 -0800)]
Move zfs_cmd_t copyin/copyout to platform code

FreeBSD needs to cope with multiple version of the zfs_cmd_t
structure. Allowing the platform code to pre and post
process the cmd structure makes it possible to work with
legacy tooling.

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9624

4 years agoAdd FreeBSD required defines to mntent.h
Matthew Macy [Sat, 30 Nov 2019 23:49:09 +0000 (15:49 -0800)]
Add FreeBSD required defines to mntent.h

Linux and FreeBSD use different names for suid / setuid.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9632

4 years agoRestructure nvlist_nv_alloc to work on FreeBSD
Matthew Macy [Sat, 30 Nov 2019 23:45:07 +0000 (15:45 -0800)]
Restructure nvlist_nv_alloc to work on FreeBSD

KM_PUSHPAGE is an Illumosism - On FreeBSD it's
aliased to the same malloc flag as KM_SLEEP.
The compiler naturally rejects multiple case
statements with the same value.  This is effectively
a no-op since all callers pass a specific KM_* flag.

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9643

4 years agoAdd FreeBSD code to arc_summary and arcstat
Ryan Moeller [Sat, 30 Nov 2019 23:43:23 +0000 (18:43 -0500)]
Add FreeBSD code to arc_summary and arcstat

Adding the FreeBSD code allows arc_summary and arcstat
to be used on FreeBSD.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes #9641

4 years agoMake asm-x86_64/atomic.S build on FreeBSD
Matthew Macy [Sat, 30 Nov 2019 23:42:00 +0000 (15:42 -0800)]
Make asm-x86_64/atomic.S build on FreeBSD

Include the required headers for FreeBSD.

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9634

4 years agoMark Linux fallocate extensions as specific to Linux
Matthew Macy [Sat, 30 Nov 2019 23:40:22 +0000 (15:40 -0800)]
Mark Linux fallocate extensions as specific to Linux

fallocate(2) is a Linux-specific system call which in unavailable
on other platforms.

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9633

4 years agoAdd FreeBSD support to zio_crypto.h
Matthew Macy [Sat, 30 Nov 2019 23:38:16 +0000 (15:38 -0800)]
Add FreeBSD support to zio_crypto.h

Minimal compatibility changes for FreeBSD.

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9631

4 years agoResolve ZoF differences in zfs_ioctl.h
Matthew Macy [Sat, 30 Nov 2019 23:35:54 +0000 (15:35 -0800)]
Resolve ZoF differences in zfs_ioctl.h

FreeBSD needs to be able to pass the jail id to the jail/unjail ioctls
and the struct file in the device structure is unused.

Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9625

4 years agoZTS: Fix attach-o_ashift.ksh for multiple platforms
Igor K [Wed, 27 Nov 2019 22:55:43 +0000 (01:55 +0300)]
ZTS: Fix attach-o_ashift.ksh for multiple platforms

The `-o ashift` option must appear after attach to be properly
interpreted by getopt(3) on all platforms.

Reviewed-by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Signed-off-by: Igor Kozhukhov <igor@dilos.org>
Closes #9636

4 years agoMinor diff reduction with ZoF in include/sys
Matthew Macy [Wed, 27 Nov 2019 19:11:03 +0000 (11:11 -0800)]
Minor diff reduction with ZoF in include/sys

- move linux/ includes to platform headers
- add void * io_bio to zio for tracking the underlying bio
- add freebsd specific fields to abd_scatter

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9615

4 years agoFix encryption logic in systemd mount generator
InsanePrawn [Fri, 22 Nov 2019 17:53:51 +0000 (18:53 +0100)]
Fix encryption logic in systemd mount generator

Previously the generator would skip a dataset if it wasn't mountable by
'zfs mount -a' (legacy/none mountpoint, canmount off/noauto). This also
skipped the generation of key-load units for such datasets, breaking
the dependency handling for mountable child datasets.

Reviewed-by: Antonio Russo <antonio.e.russo@gmail.com>
Reviewed-by: Richard Laager <rlaager@wiktel.com>
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
Closes #9611

4 years agoFix non-absolute path in systemd mount generator
InsanePrawn [Sat, 23 Nov 2019 15:16:06 +0000 (16:16 +0100)]
Fix non-absolute path in systemd mount generator

Systemd will ignore units that try to execute programs from non-absolute
paths. Use hardcoded /bin/sh instead.

Reviewed-by: Antonio Russo <antonio.e.russo@gmail.com>
Reviewed-by: Richard Laager <rlaager@wiktel.com>
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
Closes #9611

4 years agoFix small typo in systemd mount generator
InsanePrawn [Fri, 22 Nov 2019 17:48:03 +0000 (18:48 +0100)]
Fix small typo in systemd mount generator

Reviewed-by: Antonio Russo <antonio.e.russo@gmail.com>
Reviewed-by: Richard Laager <rlaager@wiktel.com>
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
Closes #9611