]> git.proxmox.com Git - mirror_zfs.git/log
mirror_zfs.git
4 years agoZTS: Misc fixes for FreeBSD
Ryan Moeller [Mon, 24 Feb 2020 18:17:55 +0000 (13:17 -0500)]
ZTS: Misc fixes for FreeBSD

* Force UFS sync before snap in vol rollback tests
* rw is not a valid share option on FreeBSD, use ro instead
* zfs_unmount_nested: mountpoint is in the pool, rmdir *before* export
* Fix some more platform checks
* Fix disappearing group in delegate tests
* Don't try delegating for jailed, only root can set it

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

4 years agoRemove unused structs and members in dmu_send.c
Matthew Ahrens [Mon, 24 Feb 2020 17:50:14 +0000 (09:50 -0800)]
Remove unused structs and members in dmu_send.c

There are several structs (and members of structs) related to redaction,
which are no longer used.  This commit removes them.

Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #10039

4 years agoZTS: Eliminate partitioning from zpool_destroy
Ryan Moeller [Sat, 22 Feb 2020 00:00:23 +0000 (19:00 -0500)]
ZTS: Eliminate partitioning from zpool_destroy

The zpool destroy tests partition a single disk to create two pools.

This can be done using two disks and no partitioning instead.
And temporarily allow vol recursion for FreeBSD while in here.

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

4 years agoZTS: Refactor is_shared, fix impl on FreeBSD
Ryan Moeller [Fri, 21 Feb 2020 23:59:20 +0000 (18:59 -0500)]
ZTS: Refactor is_shared, fix impl on FreeBSD

FreeBSD doesn't have a `share` command.  It does have showmount.

Split the separate platform impls out of is_shared_impl.
Dispatch to the correct platform impl function from is_shared.
Eliminate the use of is_shared_impl from tests.  is_shared works.

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

4 years agoZTS: Move privilege tests to sunos.run
Ryan Moeller [Fri, 21 Feb 2020 16:52:44 +0000 (11:52 -0500)]
ZTS: Move privilege tests to sunos.run

These tests are unspported on FreeBSD and Linux for lack of pfexec.

Move the privilege tests to sunos.run and remove the platform checks.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10035

4 years agoZTS: Don't use lsblk on FreeBSD
Ryan Moeller [Fri, 21 Feb 2020 16:38:34 +0000 (11:38 -0500)]
ZTS: Don't use lsblk on FreeBSD

These tests use lsblk to find the sector size of a disk.
FreeBSD doesn't have lsblk.

Use diskinfo -v to get sector size on FreeBSD.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>\
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10033

4 years agoZTS: Fix userquota_006_pos on FreeBSD
Ryan Moeller [Thu, 20 Feb 2020 16:14:25 +0000 (11:14 -0500)]
ZTS: Fix userquota_006_pos on FreeBSD

FreeBSD uses `pw` for account management. `userquota_006_pos`
erroneously invokes the non-existent `groupdel` command on FreeBSD.

Use `pw groupdel -n` instead of `groupdel` on FreeBSD.

Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10032

4 years agoZTS: Check the right mount options on FreeBSD
Ryan Moeller [Thu, 20 Feb 2020 16:12:24 +0000 (11:12 -0500)]
ZTS: Check the right mount options on FreeBSD

FreeBSD does not support the "devices" and "nodevices" mount options.

Do not check these options on FreeBSD.

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

4 years agoZTS: Fix faulty slog_replay_fs_001 test
Ryan Moeller [Thu, 20 Feb 2020 16:11:51 +0000 (11:11 -0500)]
ZTS: Fix faulty slog_replay_fs_001 test

This test is supposed to verify zil operations. For TX_WRITE, writes
must be synchronous in order to be entered in the zil. Linux seems to
be doing sync writes even when they are not asked for, but on FreeBSD
the test does not do what is intended.

Use dd oflag=sync for the parts of this test that are supposed to
result in TX_WRITE zil entries.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10022

4 years agoFix icp include directories for in-tree build
Arvind Sankar [Thu, 20 Feb 2020 16:10:47 +0000 (11:10 -0500)]
Fix icp include directories for in-tree build

When zfs is built in-tree using --enable-linux-builtin, the compile
commands are executed from the kernel build directory. If the build
directory is different from the kernel source directory, passing
-Ifs/zfs/icp will not find the headers as they are not present in the
build directory.

Fix this by adding @abs_top_srcdir@ to pull the headers from the zfs
source tree instead.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10021

4 years agoZTS: Eliminate partitioning from zpool_create etc
Ryan Moeller [Thu, 20 Feb 2020 16:10:13 +0000 (11:10 -0500)]
ZTS: Eliminate partitioning from zpool_create etc

These tests can be made to work without a bunch of complex
partitioning of physical disks.

Use the 3 disks directly, creating a few file disks if needed for a
compelling reason.

Reduce the use of shared variables that don't have a clear utility.

Catch the fallout in tests that include cfg/shlib from zpool_create.

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

4 years agoZTS: Fix zpool_create/create-o_ashift on FreeBSD
Ryan Moeller [Wed, 19 Feb 2020 18:27:23 +0000 (13:27 -0500)]
ZTS: Fix zpool_create/create-o_ashift on FreeBSD

For some unknown reason, egrep was misbehaving with this pattern on
FreeBSD.  The command works fine run interactively from a shell, but
in the test the output of egrep is empty.

Work around the issue by using a filter in the awk script instead.

While here, add a bit of diagnostic output and other simplifications
to the awk script as well.

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

4 years agoZTS: Avoid nonportable cmp flag
Ryan Moeller [Wed, 19 Feb 2020 17:03:31 +0000 (12:03 -0500)]
ZTS: Avoid nonportable cmp flag

FreeBSD doesn't have the -n flag for cmp.

Read the area for the first four labels from the disk to a separate
file to compare instead of using the special flag to limit the size.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10024

4 years agoAdd notice that forcefully unmount is not supported on Linux
Mariusz Zaborski [Tue, 18 Feb 2020 21:36:23 +0000 (22:36 +0100)]
Add notice that forcefully unmount is not supported on Linux

The Linux VFS will never allow a filesystem which is in use to
be unmounted.  This behavior differs from other platforms like
FreeBSD which allow a filesystem to be force unmounted.  This
will result in errors being returned to applications actively
using the filesystem.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Mariusz Zaborski <oshogbo@vexillium.org>
Closes #10013

4 years agoZTS: Move free to Linux commands list
Ryan Moeller [Tue, 18 Feb 2020 19:23:41 +0000 (14:23 -0500)]
ZTS: Move free to Linux commands list

FreeBSD does not have the free command. This command is only used by
Linux in a perf hostinfo function.

Move free from the list of common commands to the list of Linux
commands.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10011

4 years agoEnable zpool events tunables and tests on FreeBSD
Ryan Moeller [Tue, 18 Feb 2020 19:22:56 +0000 (14:22 -0500)]
Enable zpool events tunables and tests on FreeBSD

We have have made the necessary changes in our module code to expose
zevents through both devd and the zpool events ioctl. Now the tunables
can be exposed and zpool events tests can be enabled on both platforms.

A few minor tweaks to the tests were needed to accommodate the way wc
formats output on FreeBSD.

zed remains to be ported.

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

4 years agoFactor out some dbuf subroutines and add state change tracing
Matthew Macy [Tue, 18 Feb 2020 19:21:37 +0000 (11:21 -0800)]
Factor out some dbuf subroutines and add state change tracing

Create dedicated dbuf_read_hole and dbuf_read_bonus.
Additionally, add a dtrace probe to allow state change tracing.

Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Will Andrews <wca@FreeBSD.org>
Reviewed by: Brad Lewis <brad.lewis@delphix.com>
Authored-by: Will Andrews <wca@FreeBSD.org>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9923

4 years agoPrefer org.openzfs for features and properties
Richard Laager [Tue, 18 Feb 2020 17:36:50 +0000 (11:36 -0600)]
Prefer org.openzfs for features and properties

Moving forward, we wish to use org.openzfs (no dash) rather than
org.open-zfs or org.zfsonlinux for feature GUIDs and property names.
The existing feature GUIDs cannot be changed.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Richard Laager <rlaager@wiktel.com>
Closes #10003

4 years agoZTS: Move cksum to common system commands
Ryan Moeller [Sun, 16 Feb 2020 20:49:49 +0000 (15:49 -0500)]
ZTS: Move cksum to common system commands

The cksum command is used by delegate tests. We have it on FreeBSD,
so it should not have been moved to the Linux commands list.

Move it back to the common commands list.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10007

4 years agoHonour sync=disabled when relinking tpmfiles
DeHackEd [Sun, 16 Feb 2020 20:44:08 +0000 (15:44 -0500)]
Honour sync=disabled when relinking tpmfiles

Unlinked files don't respect synchronous flush commands, but when they get relinked
their state is unknown. Previously we force flushed all such files even when
sync=disabled. Correct this case.

Reviewed-by: Chunwei Chen <tuxoko@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: DHE <git@dehacked.net>
Closes #10005

4 years agoSystemd mount generator: Generate noauto units; add control properties
InsanePrawn [Wed, 12 Feb 2020 17:01:15 +0000 (18:01 +0100)]
Systemd mount generator: Generate noauto units; add control properties

This commit refactors the systemd mount generators and makes the
following major changes:

- The generator now generates units for datasets marked canmount=noauto,
  too. These units are NOT WantedBy local-fs.target.
  If there are multiple noauto datasets for a path, no noauto unit will
  be created. Datasets with canmount=on are prioritized.

- Introduces handling of new user properties which are now included in
  the zfs-list.cache files:
    - org.openzfs.systemd:requires:
      List of units to require for this mount unit
    - org.openzfs.systemd:requires-mounts-for:
      List of mounts to require by this mount unit
    - org.openzfs.systemd:before:
      List of units to order after this mount unit
    - org.openzfs.systemd:after:
      List of units to order before this mount unit
    - org.openzfs.systemd:wanted-by:
      List of units to add a Wants dependency on this mount unit to
    - org.openzfs.systemd:required-by:
      List of units to add a Requires dependency on this mount unit to
    - org.openzfs.systemd:nofail:
      Toggles between a wants and a requires dependency.
    - org.openzfs.systemd:ignore:
      Do not generate a mount unit for this dataset.

  Consult the updated man page for detailed documentation.

- Restructures and extends the zfs-mount-generator(8) man page with the
  above properties, information on unit ordering and a license header.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Antonio Russo <antonio.e.russo@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
Closes #9649

4 years agoSystemd mount generator: Silence shellcheck warnings
InsanePrawn [Sat, 11 Jan 2020 18:14:23 +0000 (19:14 +0100)]
Systemd mount generator: Silence shellcheck warnings

Silences a warning about an intentionally unquoted variable.
Fixes a warning caused by strings split across lines by slightly
refactoring keyloadcmd.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Antonio Russo <antonio.e.russo@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
Closes #9649

4 years agoSupport setting user properties in a channel program
Jason King [Fri, 14 Feb 2020 21:41:42 +0000 (15:41 -0600)]
Support setting user properties in a channel program

This adds support for setting user properties in a
zfs channel program by adding 'zfs.sync.set_prop'
and 'zfs.check.set_prop' to the ZFS LUA API.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Co-authored-by: Sara Hartse <sara.hartse@delphix.com>
Contributions-by: Jason King <jason.king@joyent.com>
Signed-off-by: Sara Hartse <sara.hartse@delphix.com>
Signed-off-by: Jason King <jason.king@joyent.com>
Closes #9950

4 years agoRemove limit on number of async zio_frees of non-dedup blocks
Matthew Ahrens [Fri, 14 Feb 2020 16:39:46 +0000 (08:39 -0800)]
Remove limit on number of async zio_frees of non-dedup blocks

The module parameter zfs_async_block_max_blocks limits the number of
blocks that can be freed by the background freeing of filesystems and
snapshots (from "zfs destroy"), in one TXG.  This is useful when freeing
dedup blocks, becuase each zio_free() of a dedup block can require an
i/o to read the relevant part of the dedup table (DDT), and will also
dirty that block.

zfs_async_block_max_blocks is set to 100,000 by default.  For the more
typical case where dedup is not used, this can have a negative
performance impact on the rate of background freeing (from "zfs
destroy").  For example, with recordsize=8k, and TXG's syncing once
every 5 seconds, we can free only 160MB of data per second, which may be
much less than the rate we can write data.

This change increases zfs_async_block_max_blocks to be unlimited by
default.  To address the dedup freeing issue, a new tunable is
introduced, zfs_max_async_dedup_frees, which limits the number of
zio_free()'s of dedup blocks done by background destroys, per txg.  The
default is 100,000 free's (same as the old zfs_async_block_max_blocks
default).

Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #10000

4 years agoMake zpool.d/iostat work on FreeBSD
Ryan Moeller [Fri, 14 Feb 2020 16:37:40 +0000 (11:37 -0500)]
Make zpool.d/iostat work on FreeBSD

There are slight differences in the iostat commands between FreeBSD and
Linux.

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

4 years agoUse POSIX stdout/stderr redirect in configure macro
Andrew J. Hesford [Fri, 14 Feb 2020 16:30:29 +0000 (11:30 -0500)]
Use POSIX stdout/stderr redirect in configure macro

This PR fixes an issue wherein redirecting stdout and stderr when
building kernel modules in configure tests relied on a bashism that
does not work as expected when /bin/sh is not bash.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-By: Richard Laager <rlaager@wiktel.com>
Signed-off-by: Andrew J. Hesford <ajh@sideband.org>
Closes #9990
Closes #9998

4 years agoZTS: Misc test fixes for FreeBSD
Ryan Moeller [Thu, 13 Feb 2020 21:52:34 +0000 (16:52 -0500)]
ZTS: Misc test fixes for FreeBSD

Add missing logic for FreeBSD to a few test scripts.

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

4 years agoZTS: Don't include zpool_create.shlib in zpool_add
Ryan Moeller [Thu, 13 Feb 2020 20:11:25 +0000 (15:11 -0500)]
ZTS: Don't include zpool_create.shlib in zpool_add

The zpool_add tests include zpool_create.shlib for a few silly
variables.

Don't use those variables for the file names. Include zpool_add.kshlib
for whatever variables we still need.

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

4 years agoZTS: Eliminate partitioning from zpool_remove
Ryan Moeller [Thu, 13 Feb 2020 20:10:36 +0000 (15:10 -0500)]
ZTS: Eliminate partitioning from zpool_remove

These tests do not need to use partitions.

Get rid of the partitioning and just use the disks directly.

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

4 years agoZTS: Eliminate partitioning from write_dirs
Ryan Moeller [Thu, 13 Feb 2020 20:08:59 +0000 (15:08 -0500)]
ZTS: Eliminate partitioning from write_dirs

These tests do not need to use partitions.

Get rid of the partitioning and just use the disks directly.

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

4 years agoZTS: Cleanup some cleanup functions
Ryan Moeller [Thu, 13 Feb 2020 20:05:32 +0000 (15:05 -0500)]
ZTS: Cleanup some cleanup functions

Cleanup functions should make a best effort to clean up as much as
possible.

Do a consistency pass in a bunch of tests to make the cleanup
functions less prone to failure and fix a few typos here and there.

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

4 years agoFix a typo/whitespace in tests README
Ryan Moeller [Thu, 13 Feb 2020 20:04:47 +0000 (15:04 -0500)]
Fix a typo/whitespace in tests README

Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #9991

4 years agoZTS: Use ECKSUM instead of EBADE in libzfs test
Ryan Moeller [Thu, 13 Feb 2020 20:03:01 +0000 (15:03 -0500)]
ZTS: Use ECKSUM instead of EBADE in libzfs test

Linux defines ECKSUM as EBADE, FreeBSD defines it as EINTEGRITY.

Test for ECKSUM instead of EBADE so we don't have to define EBADE for
this test on FreeBSD.

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

4 years agozfs-mount-generator: Fix escaping for /
Richard Laager [Thu, 13 Feb 2020 19:55:59 +0000 (13:55 -0600)]
zfs-mount-generator: Fix escaping for /

The correct name for the mount unit for / is "-.mount", not ".mount".

Reviewed-by: InsanePrawn <insane.prawny@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Co-authored-by: Antonio Russo <antonio.e.russo@gmail.com>
Signed-off-by: Richard Laager <rlaager@wiktel.com>
Closes #9970

4 years agofix zstreamdump -C
Matthew Ahrens [Thu, 13 Feb 2020 19:24:57 +0000 (11:24 -0800)]
fix zstreamdump -C

zstreamdump -C always fails.  It is not calculating the checksums, but
it's still trying to verify that the (non-calculated) checksum matches
the one stored in the send stream.

This change makes zstreamdump -C not verify checksums.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #9983

4 years agoMissed wakeup when growing kmem cache
Matthew Ahrens [Thu, 13 Feb 2020 19:23:02 +0000 (11:23 -0800)]
Missed wakeup when growing kmem cache

When growing the size of a (VMEM or KVMEM) kmem cache, spl_cache_grow()
always does taskq_dispatch(spl_cache_grow_work), and then waits for the
KMC_BIT_GROWING to be cleared by the taskq thread.

The taskq thread (spl_cache_grow_work()) does:
1. allocate new slab and add to list
2. wake_up_all(skc_waitq)
3. clear_bit(KMC_BIT_GROWING)

Therefore, the waiting thread can wake up before GROWING has been
cleared.  It will see that the growing has not yet completed, and go
back to sleep until it hits the 100ms timeout.

This can have an extreme performance impact on workloads that alloc/free
more than fits in the (statically-sized) magazines.  These workloads
allocate and free slabs with high frequency.

The problem can be observed with `funclatency spl_cache_grow`, which on
some workloads shows that 99.5% of the time it takes <64us to allocate
slabs, but we spend ~70% of our time in outliers, waiting for the 100ms
timeout.

The fix is to do `clear_bit(KMC_BIT_GROWING)` before
`wake_up_all(skc_waitq)`.

A future investigation should evaluate if we still actually need to
taskq_dispatch() at all, and if so on which kernel versions.

Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Wilson <gwilson@delphix.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #9989

4 years agoRemove duplicate dbufs accounting
Alexander Motin [Thu, 13 Feb 2020 19:20:42 +0000 (14:20 -0500)]
Remove duplicate dbufs accounting

Since AVL already has embedded element counter, use dn_dbufs_count
only for dbufs not counted there (bonus buffers) and just add them.
This removes two atomics per dbuf life cycle.

According to profiler it reduces time spent by dbuf_destroy() inside
bottlenecked dbuf_evict_thread() from 13.36% to 9.20% of the core.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored-By: iXsystems, Inc.
Closes #9949

4 years agoZTS: Move user_namespace test to linux.run
Ryan Moeller [Wed, 12 Feb 2020 21:06:00 +0000 (16:06 -0500)]
ZTS: Move user_namespace test to linux.run

Namespaces is a Linux feature not available on other platforms.

Move the user_namespace test out of common.run to linux.run.

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

4 years agoZTS: Interpret env vars in faketty on FreeBSD
Ryan Moeller [Wed, 12 Feb 2020 21:04:51 +0000 (16:04 -0500)]
ZTS: Interpret env vars in faketty on FreeBSD

This was missed in review. On FreeBSD, script does not understand
environment variables being passed as a command.

Use env to make faketty handle env vars on FreeBSD.

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

4 years agoZTS: Fix zdb_display_block on FreeBSD
Ryan Moeller [Wed, 12 Feb 2020 21:01:55 +0000 (16:01 -0500)]
ZTS: Fix zdb_display_block on FreeBSD

Missed this in the review, but wc output on FreeBSD is indented,
so string comparisons mismatch when comparing to an unindented number.

Compare counts as integers instead of strings.

Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Paul Zuchowski <pzuchowski@datto.com>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #9980

4 years agoMove zfs_version_kernel to platform code
Ryan Moeller [Wed, 12 Feb 2020 21:00:19 +0000 (16:00 -0500)]
Move zfs_version_kernel to platform code

Linux uses sysfs to determine the module version, FreeBSD uses a
different method.

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

4 years agoZTS: Move zpool_split_wholedisks to linux.run
Ryan Moeller [Wed, 12 Feb 2020 20:59:28 +0000 (15:59 -0500)]
ZTS: Move zpool_split_wholedisks to linux.run

This test uses the scsi_debug Linux kernel module.

Move the test to linux.run until we have an alternative to scsi_debug
worked out on FreeBSD.

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

4 years agozdb: Always print symlink target
Justin Keogh [Wed, 12 Feb 2020 19:36:05 +0000 (19:36 +0000)]
zdb: Always print symlink target

When zdb is printing paths, also print the symlink target if it exists.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Signed-off-by: Justin Keogh <commits@v6y.net>
Closes #9925

4 years agozcp: add zfs.sync.bookmark
Christian Schwarz [Thu, 16 Jan 2020 01:15:05 +0000 (02:15 +0100)]
zcp: add zfs.sync.bookmark

Add support for bookmark creation and cloning.

Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Christian Schwarz <me@cschwarz.com>
Closes #9571

4 years agoImplement bookmark copying
Christian Schwarz [Mon, 11 Nov 2019 07:24:14 +0000 (23:24 -0800)]
Implement bookmark copying

This feature allows copying existing bookmarks using

    zfs bookmark fs#target fs#newbookmark

There are some niche use cases for such functionality,
e.g. when using bookmarks as markers for replication progress.

Copying redaction bookmarks produces a normal bookmark that
cannot be used for redacted send (we are not duplicating
the redaction object).

ZCP support for bookmarking (both creation and copying) will be
implemented in a separate patch based on this work.

Overview:

- Terminology:
    - source = existing snapshot or bookmark
    - new/bmark = new bookmark
- Implement bookmark copying in `dsl_bookmark.c`
  - create new bookmark node
  - copy source's `zbn_phys` to new's `zbn_phys`
  - zero-out redaction object id in copy
- Extend existing bookmark ioctl nvlist schema to accept
  bookmarks as sources
  - => `dsl_bookmark_create_nvl_validate` is authoritative
- use `dsl_dataset_is_before` check for both snapshot
  and bookmark sources
- Adjust CLI
  - refactor shortname expansion logic in `zfs_do_bookmark`
- Update man pages
  - warn about redaction bookmark handling
- Add test cases
  - CLI
  - pyyzfs libzfs_core bindings

Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Christian Schwarz <me@cschwarz.com>
Closes #9571

4 years agoAddress Coverity warnings in #9902
Matthew Macy [Tue, 11 Feb 2020 21:12:41 +0000 (13:12 -0800)]
Address Coverity warnings in #9902

Coverity reports the variable may be NULL, but due to the
way the dirty records are handled this cannot be the case.
Add a comment and VERIFY to make this clear and silence
the warning.

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

4 years agoAdd missing dmu_buf_unlock_parent() calls to dbuf_read_impl()
Brian Behlendorf [Mon, 10 Feb 2020 22:54:12 +0000 (14:54 -0800)]
Add missing dmu_buf_unlock_parent() calls to dbuf_read_impl()

As explained by the comment in dbuf_read() and above dbuf_read_impl().
Under all circumstances the parent lock specified by dblt should be
dropped when existing dbuf_read_impl().  This was not being done for
two exist paths.  Additionally, ensure the mutex is unlocked before
dropping the parent lock.

Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9968

4 years agoFix zdb -R with 'b' flag
Paul Zuchowski [Mon, 10 Feb 2020 22:00:05 +0000 (18:00 -0400)]
Fix zdb -R with 'b' flag

zdb -R :b fails due to the indirect block being compressed,
and the 'b' and 'd' flag not working in tandem when specified.
Fix the flag parsing code and create a zfs test for zdb -R
block display.  Also fix the zio flags where the dotted notation
for the vdev portion of DVA (i.e. 0.0:offset:length) fails.

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

4 years agobash scripts: use /usr/bin/env for bash shebangs
Graham Christensen [Mon, 10 Feb 2020 21:13:46 +0000 (16:13 -0500)]
bash scripts: use /usr/bin/env for bash shebangs

Not all systems / distros have a `/bin/bash`, and these scripts are
more difficult to run at development time.

For example, my system is NixOS which doesn't have a /bin/bash. This
is not a problem for NixOS building ZFS as a package: the build
environment automatically replaces these shebangs with corrected
paths.

The problem is much more annoying at development time: either the
scripts don't run, or I correct them for my local machine and deal with
a perpetually dirty work tree.

Before committing this patch I confirmed there are existing scripts
which use `/usr/bin/env` to locate bash, so I am thinking this is a
safe transformation.

There are a handful of other shebangs in this repository which don't
work on my system. This patch is useful on its own specifically for
`commitcheck.sh`, otherwise I can't validate my commits before
submission.

Here are the remaining shebangs which NixOS systems won't have:

       1274 #!/bin/ksh -p
         91 #!/bin/ksh
         89 #! /bin/ksh -p
          2 #!/bin/sed -f
          1 #!/usr/bin/perl -w
          1 #!/usr/bin/ksh
          1 #!/bin/nawk -f

plus this which will create an invalid shebang in
`tests/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib`:

        echo "#!/bin/ksh" > $TEST_BASE_DIR/exitsZero.ksh

I chose to leave those alone for now, and gauge the interest in this
much smaller patch first.

The fixes for these are easy enough by simply using `/usr/bin/env ksh`:

         91 #!/bin/ksh
          1 #!/usr/bin/ksh

The fix for the other set is much trickier. Quoting the GNU coreutils
manual:

    Most operating systems (e.g. GNU/Linux, BSDs) treat all text after
    the first space as a single argument. When using env in a script it
    is thus not possible to specify multiple arguments.

and not all `env`'s support arguments.

Mine (GNU Coreutils 8.31) does, though this feature is new since
April 2018, GNU Coreutils 8.30:
https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=668306ed86c8c79b0af0db8b9c882654ebb66db2

and worse, requires the -S argument:

    -S, --split-string=S  process and split S into separate arguments;
                          used to pass multiple arguments on shebang
                          lines

Example:

    $ seq 1 2 | $(nix-build '<nixpkgs>' -A coreutils)/bin/env "sort -nr"
    /nix/[...]-coreutils-8.31/bin/env: ‘sort -nr’: No such file or directory
    /nix/[...]-coreutils-8.31/bin/env: use -[v]S to pass options in shebang lines

    $ seq 1 2 | $(nix-build '<nixpkgs>' -A coreutils)/bin/env "-S sort -nr"
    2
    1

GNU Coreutils says FreeBSD's `env` does, though I wonder if FreeBSD's
would be unhappy with the `-S`:
https://www.gnu.org/software/coreutils/manual/html_node/env-invocation.html#env-invocation

BusyBox v1.30.1 does not, and does not have a `-S`-like option:

    $ seq 1 2 | $(nix-build '<nixpkgs>' -A busybox)/bin/env "sort -nr"
    env: can't execute 'sort -nr': No such file or directory

Toybox 0.8.1 also does not, and also does not have a `-S` option:

    $ seq 1 2 | $(nix-build '<nixpkgs>' -A toybox)/bin/env "sort -nr"
    env: exec sort -nr: No such file or directory

---

At any rate, if this patch merges and the remaining ~1,500 are updated,
the much larger patch should probably include a checkstyle-like test
asserting all new shebangs use `/usr/bin/env`. I also don't mind
dealing with NixOS weirdness if the project would prefer that.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Graham Christensen <graham@grahamc.com>
Closes #9893

4 years agoShare some code for spa deadman tunables
Ryan Moeller [Mon, 10 Feb 2020 21:11:30 +0000 (16:11 -0500)]
Share some code for spa deadman tunables

We need to do the same thing to update all spas on any OS for these
tunables, so let's share the code.

While here let's match the types of the literals initializing the
variables with the type of the variable.

Reviewed-by: Allan Jude <allanjude@freebsd.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Olaf Faaland <faaland1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #9964

4 years agoZTS: Test zvol I/O in different volmodes
Ryan Moeller [Mon, 10 Feb 2020 21:10:25 +0000 (16:10 -0500)]
ZTS: Test zvol I/O in different volmodes

We found that our zvol code had some issues with volmode=dev that were
not revealed by ZTS.

Add some basic I/O operations to exercise more code paths in the
volmode test.

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

4 years agoICP: Improve AES-GCM performance
Attila Fülöp [Mon, 10 Feb 2020 20:59:50 +0000 (21:59 +0100)]
ICP: Improve AES-GCM performance

Currently SIMD accelerated AES-GCM performance is limited by two
factors:

a. The need to disable preemption and interrupts and save the FPU
state before using it and to do the reverse when done. Due to the
way the code is organized (see (b) below) we have to pay this price
twice for each 16 byte GCM block processed.

b. Most processing is done in C, operating on single GCM blocks.
The use of SIMD instructions is limited to the AES encryption of the
counter block (AES-NI) and the Galois multiplication (PCLMULQDQ).
This leads to the FPU not being fully utilized for crypto
operations.

To solve (a) we do crypto processing in larger chunks while owning
the FPU. An `icp_gcm_avx_chunk_size` module parameter was introduced
to make this chunk size tweakable. It defaults to 32 KiB. This step
alone roughly doubles performance. (b) is tackled by porting and
using the highly optimized openssl AES-GCM assembler routines, which
do all the processing (CTR, AES, GMULT) in a single routine. Both
steps together result in up to 32x reduction of the time spend in
the en/decryption routines, leading up to approximately 12x
throughput increase for large (128 KiB) blocks.

Lastly, this commit changes the default encryption algorithm from
AES-CCM to AES-GCM when setting the `encryption=on` property.

Reviewed-By: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-By: Jason King <jason.king@joyent.com>
Reviewed-By: Tom Caputi <tcaputi@datto.com>
Reviewed-By: Richard Laager <rlaager@wiktel.com>
Signed-off-by: Attila Fülöp <attila@fueloep.org>
Closes #9749

4 years agoFactor out dbuf_sync_bonus
Matthew Macy [Fri, 7 Feb 2020 22:22:29 +0000 (14:22 -0800)]
Factor out dbuf_sync_bonus

Factor the portion of dbuf_sync_leaf() responsible for handling bonus
buffers out in to its own dbuf_sync_bonus() helper function.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9909

4 years agoZTS: Add an is_dilos function for future ZTS updates
Igor K [Fri, 7 Feb 2020 20:32:52 +0000 (23:32 +0300)]
ZTS: Add an is_dilos function for future ZTS updates

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

4 years agoZTS: Use wc -c instead of --bytes for portability
Ryan Moeller [Fri, 7 Feb 2020 20:31:38 +0000 (15:31 -0500)]
ZTS: Use wc -c instead of --bytes for portability

FreeBSD does not have the long opts for wc.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #9963

4 years agoLinux 5.6 compat: timestamp_truncate()
Brian Behlendorf [Thu, 6 Feb 2020 20:37:25 +0000 (12:37 -0800)]
Linux 5.6 compat: timestamp_truncate()

The timestamp_truncate() function was added, it replaces the existing
timespec64_trunc() function.  This change renames our wrapper function
to be consistent with the upstream name and updates the compatibility
code for older kernels accordingly.

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

4 years agoLinux 5.6 compat: struct proc_ops
Brian Behlendorf [Thu, 6 Feb 2020 18:30:41 +0000 (10:30 -0800)]
Linux 5.6 compat: struct proc_ops

The proc_ops structure was introduced to replace the use of of the
file_operations structure when registering proc handlers.  This
change creates a new kstat_proc_op_t typedef for compatibility
which can be used to pass around the correct structure.

This change additionally adds the 'const' keyword to all of the
existing proc operations structures.

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

4 years agoReduce number of atomic_add() calls in aggsum
Alexander Motin [Thu, 6 Feb 2020 21:21:06 +0000 (16:21 -0500)]
Reduce number of atomic_add() calls in aggsum

Previous code used 4 atomics to do aggsum_flush_bucket() and 2 more to
re-borrow after the flush.  But since asc_borrowed and asc_delta are
accessed only while holding asc_lock, it makes no any sense to modify
as_lower_bound and as_upper_bound in multiple steps.  Instead of that
the new code uses only 2 atomics in all the cases, one per as_*_bound
variable.  I think even that is overkill, simple atomic store and
load could be used here, since all modifications are done under the
as_lock, but there are no such primitives in ZFS code now.

While there, make borrow code consider previous borrow value, so that
on mixed request patterns reduce chance of needing to borrow again if
much larger request follows tiny one that needed borrow.

Also reduce as_numbuckets from uint64_t to u_int.  It makes no sense
to use so large division operation on every aggsum_add().

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored-By: iXsystems, Inc.
Closes #9930

4 years agoReplace static per-cpu with dynamic per-cpu data
Romain Dolbeau [Thu, 6 Feb 2020 17:26:13 +0000 (18:26 +0100)]
Replace static per-cpu with dynamic per-cpu data

This solves the issue of loading the spl module on RISC-V.

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

4 years agoFix static data to link with -fno-common
Romain Dolbeau [Thu, 6 Feb 2020 17:25:29 +0000 (18:25 +0100)]
Fix static data to link with -fno-common

-fno-common is the new default in GCC 10, replacing -fcommon in
GCC <= 9, so static data must only be allocated once.

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

4 years agoFix unknown cc flag -fno-ipa-sra
Ryan Moeller [Thu, 6 Feb 2020 17:24:37 +0000 (12:24 -0500)]
Fix unknown cc flag -fno-ipa-sra

Clang does not recognize -fno-ipa-sra, so add a check for it.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Prakash Surya <prakash.surya@delphix.com>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #9946

4 years agoSuggest using visudo to edit
Gerardwx [Wed, 5 Feb 2020 19:31:53 +0000 (14:31 -0500)]
Suggest using visudo to edit

Suggest visudo which allows editing the sudoers file in a safe fashion.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Gerardwx <gerardw@alum.mit.edu>
Closes #9918

4 years agoFew microoptimizations to dbuf layer
Alexander Motin [Wed, 5 Feb 2020 19:08:44 +0000 (14:08 -0500)]
Few microoptimizations to dbuf layer

Move db_link into the same cache line as db_blkid and db_level.
It allows significantly reduce avl_add() time in dbuf_create() on
systems with large RAM and huge number of dbufs per dnode.

Avoid few accesses to dbuf_caches[].size, which is highly congested
under high IOPS and never stays in cache for a long time.  Use local
value we are receiving from zfs_refcount_add_many() any way.

Remove cache_size_bytes_max bump from dbuf_evict_one().  I don't see
a point to do it on dbuf eviction after we done it on insertion in
dbuf_rele_and_unlock().

Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored-By: iXsystems, Inc.
Closes #9931

4 years agoConvert dbuf dirty record record list to a list_t
Matthew Macy [Wed, 5 Feb 2020 19:07:19 +0000 (11:07 -0800)]
Convert dbuf dirty record record list to a list_t

Additionally pull in state machine comments about
upcoming async cow work.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9902

4 years agoPrepare ks_data before calling kstat_install()
Alexander Motin [Tue, 4 Feb 2020 16:49:12 +0000 (11:49 -0500)]
Prepare ks_data before calling kstat_install()

It violated sequence described in kstat.h, and at least on FreeBSD
kstat_install() uses provided names to create the sysctls.  If the
names are not available at the time, it ends up bad.

Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored-By: iXsystems, Inc.
Closes #9933

4 years agoUse -Werror to check if the compiler supports specific options
韩朴宇 [Tue, 4 Feb 2020 16:47:38 +0000 (00:47 +0800)]
Use -Werror to check if the compiler supports specific options

Be default, clang treats unknown warning option as warning.
We need to use -Werror to make it an error.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: 12101111 <w12101111@gmail.com>
Closes #9927

4 years agoRestore aclmode and remove acltype on FreeBSD
Ryan Moeller [Tue, 4 Feb 2020 16:40:08 +0000 (11:40 -0500)]
Restore aclmode and remove acltype on FreeBSD

This replaces the placeholder ZFS_PROP_PRIVATE with ZFS_PROP_ACLMODE,
matching what is done in the NFSv4 ACLs PR (#9709).

On FreeBSD we hide ZFS_PROP_ACLTYPE, while on Linux we hide
ZFS_PROP_ACLMODE.

The tests already assume this arrangement.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #9913

4 years agoFix const-correctness in raidz math
Ryan Moeller [Mon, 3 Feb 2020 18:52:41 +0000 (13:52 -0500)]
Fix const-correctness in raidz math

Clang warns (errors) that "cast from 'const void *' to 'struct v *'
drops const qualifier."

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

4 years agoasync zvol minor node creation interferes with receive
Matthew Ahrens [Mon, 3 Feb 2020 17:33:14 +0000 (09:33 -0800)]
async zvol minor node creation interferes with receive

When we finish a zfs receive, dmu_recv_end_sync() calls
zvol_create_minors(async=TRUE).  This kicks off some other threads that
create the minor device nodes (in /dev/zvol/poolname/...).  These async
threads call zvol_prefetch_minors_impl() and zvol_create_minor(), which
both call dmu_objset_own(), which puts a "long hold" on the dataset.
Since the zvol minor node creation is asynchronous, this can happen
after the `ZFS_IOC_RECV[_NEW]` ioctl and `zfs receive` process have
completed.

After the first receive ioctl has completed, userland may attempt to do
another receive into the same dataset (e.g. the next incremental
stream).  This second receive and the asynchronous minor node creation
can interfere with one another in several different ways, because they
both require exclusive access to the dataset:

1. When the second receive is finishing up, dmu_recv_end_check() does
dsl_dataset_handoff_check(), which can fail with EBUSY if the async
minor node creation already has a "long hold" on this dataset.  This
causes the 2nd receive to fail.

2. The async udev rule can fail if zvol_id and/or systemd-udevd try to
open the device while the the second receive's async attempt at minor
node creation owns the dataset (via zvol_prefetch_minors_impl).  This
causes the minor node (/dev/zd*) to exist, but the udev-generated
/dev/zvol/... to not exist.

3. The async minor node creation can silently fail with EBUSY if the
first receive's zvol_create_minor() trys to own the dataset while the
second receive's zvol_prefetch_minors_impl already owns the dataset.

To address these problems, this change synchronously creates the minor
node.  To avoid the lock ordering problems that the asynchrony was
introduced to fix (see #3681), we create the minor nodes from open
context, with no locks held, rather than from syncing contex as was
originally done.

Implementation notes:

We generally do not need to traverse children or prefetch anything (e.g.
when running the recv, snapshot, create, or clone subcommands of zfs).
We only need recursion when importing/opening a pool and when loading
encryption keys.  The existing recursive, asynchronous, prefetching code
is preserved for use in these cases.

Channel programs may need to create zvol minor nodes, when creating a
snapshot of a zvol with the snapdev property set.  We figure out what
snapshots are created when running the LUA program in syncing context.
In this case we need to remember what snapshots were created, and then
try to create their minor nodes from open context, after the LUA code
has completed.

There are additional zvol use cases that asynchronously own the dataset,
which can cause similar problems.  E.g. changing the volmode or snapdev
properties.  These are less problematic because they are not recursive
and don't touch datasets that are not involved in the operation, there
is still potential for interference with subsequent operations.  In the
future, these cases should be similarly converted to create the zvol
minor node synchronously from open context.

The async tasks of removing and renaming minors do not own the objset,
so they do not have this problem.  However, it may make sense to also
convert these operations to happen synchronously from open context, in
the future.

Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Prakash Surya <prakash.surya@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
External-issue: DLPX-65948
Closes #7863
Closes #9885

4 years agoDisable "-fipa-sra" when using "--enable-debuginfo"
Prakash Surya [Mon, 3 Feb 2020 17:21:05 +0000 (09:21 -0800)]
Disable "-fipa-sra" when using "--enable-debuginfo"

To better enable dynamic tracing tools (e.g. "bpftrace") this change
disables the "-fipa-sra" compilation optimization. This way, function
signatures are not changed by the compiler, which allows us to better
attach to kprobes and kretprobes with dynamic tracing tools. Otherwise,
the compiler may append ".isra" to the function name, and possibly
change the function arguments as well.

Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Prakash Surya <prakash.surya@delphix.com>
Closes #9921

4 years agoZTS: Only use ext4 on Linux
Ryan Moeller [Fri, 31 Jan 2020 17:00:47 +0000 (12:00 -0500)]
ZTS: Only use ext4 on Linux

And while here, add a workaround for FreeBSD to ensure dirty data is
synced before taking a snapshot, by remounting read-only, then remount
again read-write after the snapshot.

Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #9914

4 years agoLeft-align index props
Ryan Moeller [Fri, 31 Jan 2020 16:55:51 +0000 (11:55 -0500)]
Left-align index props

Index type props display as strings, which should be aligned to the
left not to the right.

Before:
```
FreeBSD-13_0-CURRENT-r356528 ➜  ~ zfs list -ro name,aclmode,mountpoint
NAME        ACLMODE  MOUNTPOINT
p0      passthrough  /p0
p0/foo      discard  /p0/foo
```

After:
```
FreeBSD-13_0-CURRENT-r356528 ➜  ~ zfs list -ro name,aclmode,mountpoint
NAME    ACLMODE      MOUNTPOINT
p0      passthrough  /p0
p0/foo  discard      /p0/foo
```

Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #9912

4 years agoUse the correct spelling of 'jailed' in tests
Ryan Moeller [Fri, 31 Jan 2020 16:52:29 +0000 (11:52 -0500)]
Use the correct spelling of 'jailed' in tests

FreeBSD has jails, not zones.

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

4 years agoZTS: Fix a few defaults
Ryan Moeller [Fri, 31 Jan 2020 16:51:23 +0000 (11:51 -0500)]
ZTS: Fix a few defaults

Linux was missing a default value for DEV_DSKDIR. Set it to /dev.
Fix resulting fallout.

SLICE_PREFIX seems like a good candidate for including in the defaults.

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

4 years agoZTS: FreeBSD tunable for DISABLE_IVSET_GUID_CHECK
Ryan Moeller [Wed, 29 Jan 2020 19:25:15 +0000 (14:25 -0500)]
ZTS: FreeBSD tunable for DISABLE_IVSET_GUID_CHECK

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #9907

4 years agoZTS: Simplify zero_partitions on FreeBSD
Ryan Moeller [Wed, 29 Jan 2020 19:24:18 +0000 (14:24 -0500)]
ZTS: Simplify zero_partitions on FreeBSD

We can avoid a great deal of `sleep 3` by simply destroying the whole
partition table in one shot with gpart.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #9908

4 years agoZTS: Reverse constrained path lookup order
Ryan Moeller [Wed, 29 Jan 2020 19:23:20 +0000 (14:23 -0500)]
ZTS: Reverse constrained path lookup order

FreeBSD base system zfs utils are in /sbin. ZoF utils install to
/usr/local/sbin.

Ensure we link to the ZoF utils not the base utils when searching for
utils to constrain paths to for the tests.

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

4 years agoZTS: Don't use edonr on FreeBSD
Ryan Moeller [Tue, 28 Jan 2020 16:38:02 +0000 (11:38 -0500)]
ZTS: Don't use edonr on FreeBSD

FreeBSD doesn't support feature@edonr.

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

4 years agoZTS: Eliminate random and shuf, consolidate code
Ryan Moeller [Tue, 28 Jan 2020 16:36:33 +0000 (11:36 -0500)]
ZTS: Eliminate random and shuf, consolidate code

Both GNU and FreeBSD sort have -R to randomize input.

Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #9900

4 years agoAdd an .editorconfig; document git whitespace settings
Graham Christensen [Mon, 27 Jan 2020 21:32:52 +0000 (16:32 -0500)]
Add an .editorconfig; document git whitespace settings

Most of the projects I work on don't use tabs, and while authoring my
first patch I had to wrestle with my editor to not introduce
whitespace editors.

The `.editorconfig` file is supported by a large number of editors
out of the box, and many more with plugins.

As a first-time contributor, I can't say for certain these settings
are totally correct, but thus far git and my editor are satisfied
enough.

I considered adding `git config --local format.signOff true` but
wanted to respect the warning:

    format.signOff
        A boolean value which lets you enable the -s/--signoff
        option of format-patch by default.  Note: Adding the
Signed-off-by: line to a patch should be a conscious act and
        means that you certify you have the rights to submit this
        work under the same open source license. Please see the
        SubmittingPatches document for further discussion.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Graham Christensen <graham@grahamc.com>
Closes #9892

4 years agoZTS: Move more tests out of common.run
Ryan Moeller [Mon, 27 Jan 2020 21:29:25 +0000 (16:29 -0500)]
ZTS: Move more tests out of common.run

These tests won't run on all platforms as currently implemented:
 * add_nested_replacing_spare (needs zed)
 * fault (needs zed)
 * mmp (needs multihost_history)
 * umount_unlink_drained (needs procfs)
 * zpool_expand (needs udev events and zed)
 * zpool_reopen (needs scsi_debug)
 * zvol_swap_003_pos (needs to modify vfstab)
 * zvol_swap_00[56]_pos (needs swaphigh/swaplen)

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

4 years agozdb: add support for object ranges for zdb -d
Ned Bass [Fri, 24 Jan 2020 19:00:46 +0000 (11:00 -0800)]
zdb: add support for object ranges for zdb -d

Allow a range of object identifiers to dump with -d. This may
be useful when dumping a large dataset and you want to break
it up into multiple phases, or to resume where a previous scan
left off. Object type selection flags are supported to reduce
the performance overhead of verbosely dumping unwanted objects,
and to reduce the amount of post-processing work needed to
filter out unwanted objects from zdb output.

This change extends existing syntax in a backward-compatible
way. That is, the base case of a range is to specify a single
object identifier to dump. Ranges and object identifiers can
be intermixed as command line parameters.

Usage synopsis:

    Object ranges take the form <start>:<end>[:<flags>]
        start    Starting object number
        end      Ending object number, or -1 for no upper bound
        flags    Optional flags to select object types:
         A    All objects (this is the default)
         d    ZFS directories
         f    ZFS files
         m    SPA space maps
         z    ZAPs
         -    Negate effect of next flag

Examples:

 # Dump all file objects
 zdb -dd tank/fish 0:-1:f

 # Dump all file and directory objects
 zdb -dd tank/fish 0:-1:fd

 # Dump all types except file and directory objects
 zdb -dd tank/fish 0:-1:A-f-d

 # Dump object IDs in a specific range
 zdb -dd tank/fish 1000:2000

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

4 years agoPerformance tests, some variables missing PERF_ prefix
Tony Nguyen [Fri, 24 Jan 2020 05:18:02 +0000 (22:18 -0700)]
Performance tests, some variables missing PERF_ prefix

Adding the expected PERF_ prefix to RANDSEED, COMPPERCENT,
and COMPCHUNK.

Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Nguyen <tony.nguyen@delphix.com>
Closes #9877

4 years agoZTS: zpool offline requires whole disk name
John Wren Kennedy [Fri, 24 Jan 2020 05:14:55 +0000 (22:14 -0700)]
ZTS: zpool offline requires whole disk name

When used with non-loop devices, zdb_004_pos fails because the disk
argument provided is the partition rather than the expected whole disk
name.

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

4 years agodsl_bookmark_create_check: fix NULL pointer deref if dbca_errors == NULL
Christian Schwarz [Fri, 24 Jan 2020 05:13:42 +0000 (06:13 +0100)]
dsl_bookmark_create_check: fix NULL pointer deref if dbca_errors == NULL

Discovered in preparation of zcp support for creating bookmarks.
Handle the case where dbca_errors is NULL.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Christian Schwarz <me@cschwarz.com>
Closes #9880

4 years agoentity_namecheck: doc comment: include space as allowed character
Christian Schwarz [Fri, 24 Jan 2020 05:11:54 +0000 (06:11 +0100)]
entity_namecheck: doc comment: include space as allowed character

The helper function valid_char already allows it but
the doc comment was out of date.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Christian Schwarz <me@cschwarz.com>
Closes #9879

4 years agoscripts/zfs-test.sh: example for -t
Christian Schwarz [Fri, 24 Jan 2020 05:11:06 +0000 (06:11 +0100)]
scripts/zfs-test.sh: example for -t

Add an example for running a single test case.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Signed-off-by: Christian Schwarz <me@cschwarz.com>
Closes #9878

4 years agoZTS: Get xattr tests running on FreeBSD
Ryan Moeller [Fri, 24 Jan 2020 01:14:40 +0000 (20:14 -0500)]
ZTS: Get xattr tests running on FreeBSD

This mostly involves reworking platform checks to make illumos the
exception (thanks to their unusual way of exposing xattrs). Other
platforms are able to take advantage of the recently added xattr
wrappers in libtest.

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

4 years agoAdd AltiVec RAID-Z
Romain Dolbeau [Thu, 23 Jan 2020 19:01:24 +0000 (20:01 +0100)]
Add AltiVec RAID-Z

Implements the RAID-Z function using AltiVec SIMD.
This is basically the NEON code translated to AltiVec.

Note that the 'fletcher' algorithm requires 64-bits
operations, and the initial implementations of AltiVec
(PPC74xx a.k.a. G4, PPC970 a.k.a. G5) only has up to
32-bits operations, so no 'fletcher'.

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

4 years agoZTS: Add missing export for DEV_DSKDIR default
Ryan Moeller [Thu, 23 Jan 2020 17:38:09 +0000 (12:38 -0500)]
ZTS: Add missing export for DEV_DSKDIR default

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

4 years agodmu_send: redacted: fix memory leak on invalid redaction/from bookmark
Christian Schwarz [Sat, 18 Jan 2020 20:40:30 +0000 (21:40 +0100)]
dmu_send: redacted: fix memory leak on invalid redaction/from bookmark

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Signed-off-by: Christian Schwarz <me@cschwarz.com>
Closes #9867

4 years agocmd/zfs: redact: better error message for common usage errors
Christian Schwarz [Mon, 25 Nov 2019 19:08:20 +0000 (20:08 +0100)]
cmd/zfs: redact: better error message for common usage errors

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Signed-off-by: Christian Schwarz <me@cschwarz.com>
Closes #9867

4 years agocmd/zfs: send: meaningful error message for incorrect redaction bookmark
Christian Schwarz [Sat, 23 Nov 2019 15:31:38 +0000 (16:31 +0100)]
cmd/zfs: send: meaningful error message for incorrect redaction bookmark

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Signed-off-by: Christian Schwarz <me@cschwarz.com>
Closes #9867

4 years agoSimplify FreeBSD's locking requirements in zfs_replay.c
Matthew Macy [Thu, 23 Jan 2020 01:55:56 +0000 (17:55 -0800)]
Simplify FreeBSD's locking requirements in zfs_replay.c

Now that the FreeBSD zfs_vnops code avoids asserting that
a vnode lock is held when z_replay is true we can limit
the FreeBSD specific changes to the couple of changes
where it is necessary to drop the vnode locks because
a function returns with it held.

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

4 years agoSupport inheriting properties in channel programs
Jason King [Thu, 23 Jan 2020 01:03:17 +0000 (19:03 -0600)]
Support inheriting properties in channel programs

This adds support in channel programs to inherit properties analogous
to `zfs inherit` by adding `zfs.sync.inherit` and `zfs.check.inherit`
functions to the ZFS LUA API.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jason King <jason.king@joyent.com>
Closes #9738

4 years agoOrder zfs-import-*.service after multipathd
Richard Laager [Wed, 22 Jan 2020 20:45:25 +0000 (14:45 -0600)]
Order zfs-import-*.service after multipathd

If someone is using both multipathd and ZFS, they are probably using
them together.  Ordering the zpool imports after multipathd is ready
fixes import issues for multipath configurations.

Tested-by: Mike Pastore <mike@oobak.org>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Laager <rlaager@wiktel.com>
Closes #9863

4 years agoDisable get_numeric_property for xattr on FreeBSD
Matthew Macy [Tue, 21 Jan 2020 23:06:10 +0000 (15:06 -0800)]
Disable get_numeric_property for xattr on FreeBSD

FreeBSD doesn't have a mount flag for determining the
disposition of xattr. Disable so that it is fetched
by the default route so that 'zfs get xattr' returns
the correct value.

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

4 years agoUpdate tunable macro usage for disable_ivset_guid_check
Matthew Macy [Tue, 21 Jan 2020 23:05:23 +0000 (15:05 -0800)]
Update tunable macro usage for disable_ivset_guid_check

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

4 years agoRe-consolidate zio_delay_interrupt
Matthew Macy [Tue, 21 Jan 2020 23:04:13 +0000 (15:04 -0800)]
Re-consolidate zio_delay_interrupt

With recent SPL changes there is no longer any need for a per
platform version.

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

4 years agoZTS: Eliminate partitioning in zpool_import setup
Ryan Moeller [Fri, 17 Jan 2020 20:41:45 +0000 (15:41 -0500)]
ZTS: Eliminate partitioning in zpool_import setup

There doesn't seem to be a need for this complexity.

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