ZFS on Linux/src ddb4e69module/os/linux/zfs zpl_inode.c, tests/runfiles linux.run

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 at llnl.gov>
Reviewed-by: Tony Hutter <hutter2 at llnl.gov>
Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro at gmail.com>
Closes #8997 
Closes #8998 

ZFS on Linux/src c317c8cmodule/zfs dsl_prop.c

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 at llnl.gov>
Reviewed-by: Paul Zuchowski <pzuchowski at datto.com>
Signed-off-by: Tom Caputi <tcaputi at datto.com>
Closes #9704 
DeltaFile
+19-2module/zfs/dsl_prop.c
+19-21 files

ZFS on Linux/src 13a9a6finclude/os/linux/zfs/sys zfs_vnops.h, module/os/linux/zfs zfs_vnops.c zfs_znode.c

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 at ixsystems.com>
Reviewed-by: Jorgen Lundman <lundman at lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Closes #9715 

ZFS on Linux/src 9bb0d89module/zfs vdev_removal.c

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


    [17 lines not shown]

ZFS on Linux/src 957c7aainclude/os/linux/zfs/sys zfs_vfsops.h, include/sys zfs_quota.h zfs_fuid.h

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 at lundman.net>
Reviewed-by: Igor Kozhukhov <igor at dilos.org>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Ryan Moeller <ryan at ixsystems.com>
Closes #9710 

ZFS on Linux/src 4bc7219cmd/zfs zfs_main.c, man/man8 zfs-jail.8 zfsprops.8

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 at lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Signed-off-by: Ryan Moeller <ryan at ixsystems.com>
Closes #9686 

ZFS on Linux/src 657ce25include/os/linux/zfs/sys zfs_vnops.h, module/os/linux/zfs zfs_vnops.c zpl_inode.c

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 at lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Closes #9708 

ZFS on Linux/src f0bf435cmd/zdb zdb.c, man/man8 zdb.8

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 at ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Paul Zuchowski <pzuchowski at datto.com>
Closes #9612 
Closes #9630 

ZFS on Linux/src b119e2cinclude/os/linux/kernel/linux simd_x86.h

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 at suse.cz/

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

ZFS on Linux/src 362ae8dinclude/sys zfs_ioctl_impl.h, module/os/linux/zfs zfs_ioctl_os.c

Abstract away platform specific superblock references

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

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

ZFS on Linux/src 7bda69atests/zfs-tests/tests/functional/resilver resilver_restart_001.ksh

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 at llnl.gov>
Reviewed-by: John Kennedy <john.kennedy at delphix.com>
Reviewed-by: Kjeld Schouten <kjeld at schouten-lebbing.nl>
Signed-off-by: John Poduska <jpoduska at datto.com>
Issue #9588 
Closes #9677 
Closes #9703 

ZFS on Linux/src 3c502d3include/sys zio.h, module/zfs zio.c

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 at lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Don Brady <don.brady at delphix.com>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Closes #9691 

ZFS on Linux/src ea79e90module/zfs dsl_dataset.c

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 at llnl.gov>
Reviewed-by: Richard Laager <rlaager at wiktel.com>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Closes #9696 

ZFS on Linux/src a25861dmodule/os/linux/zfs vdev_disk.c

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 at schouten-lebbing.nl>
Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Closes #9680 

ZFS on Linux/src 5927917.github codecov.yml

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 at llnl.gov>
Reviewed-by: Ryan Moeller <ryan at ixsystems.com>
Reviewed-by: Richard Laager <rlaager at wiktel.com>
Signed-off-by: Kjeld Schouten-Lebbing <kjeld at schouten-lebbing.nl>
Closes #9700 

ZFS on Linux/src 0dcef9bmodule/zcommon zprop_common.c zfeature_common.c

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 at schouten-lebbing.nl>
Reviewed-by: Jorgen Lundman <lundman at lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Closes #9684 

ZFS on Linux/src 69b7e3ftests/zfs-tests/tests/functional/rsend send_realloc_files.ksh

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 at llnl.gov>
Signed-off-by: Kjeld Schouten-Lebbing <kjeld at schouten-lebbing.nl>
Issue #9645
Closes #9679 

ZFS on Linux/src 3ac34camodule/icp/algs/modes gcm.c

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 at llnl.gov>
Reviewed-by: Tom Caputi <tcaputi at datto.com>
Signed-off-by: Attila Fülöp <attila at fueloep.org>
Closes #9660 

ZFS on Linux/src f784828.github codecov.yml

Fix codecov ignore, wrong syntax

The current codecov ignore syntax is incorrect.
Corrected it.

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

ZFS on Linux/src 1f65475include/os/linux/spl/sys debug.h

Remove stale ASSERTV comment

Followup for #9671, remove stale comment.

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

ZFS on Linux/src f95704cman/man8 zfsprops.8, module/zcommon zfs_prop.c

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 at lundman.net>
Reviewed-by: Allan Jude <allanjude at freebsd.org>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Signed-off-by: Ryan Moeller <ryan at ixsystems.com>
Closes #9664 

ZFS on Linux/src 054a049include/sys/fs zfs.h, tests/zfs-tests/cmd/libzfs_input_check libzfs_input_check.c

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 at lundman.net>
Reviewed-by: Allan Jude <allanjude at freebsd.org>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Closes #9667 

ZFS on Linux/src e64e84einclude/sys spa_impl.h spa.h, module/os/linux/zfs spa_misc_os.c

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 at lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Closes #9670 

ZFS on Linux/src 2a8ba60module/zfs vdev_indirect_mapping.c dbuf.c

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 at llnl.gov>
Reviewed-by: Jorgen Lundman <lundman at lundman.net>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Closes #9671 

ZFS on Linux/src 12395c7cmd/arc_summary arc_summary3

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 at ixsystems.com>
Reviewed-by: Kjeld Schouten <kjeld at schouten-lebbing.nl>
Signed-off-by: George Amanakis <gamanakis at gmail.com>
Closes #9669 

ZFS on Linux/src be627fcinclude/os/linux/zfs/sys zfs_context_os.h Makefile.am, include/sys zfs_context.h

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 at lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Don Brady <don.brady at delphix.com>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Closes #9668 

ZFS on Linux/src 618b6adtests/zfs-tests/include libtest.shlib properties.shlib, tests/zfs-tests/tests/functional/cli_root/zfs_set property_alias_001_pos.ksh

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 at llnl.gov>
Reviewed-by: John Kennedy <john.kennedy at delphix.com>
Reviewed-by: Michael Niewöhner <foss at mniewoehner.de>
Signed-off-by: Kjeld Schouten-Lebbing <kjeld at schouten-lebbing.nl>
Closes #9645 

ZFS on Linux/src 5a08977cmd/zdb zdb.c

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 at llnl.gov>
Reviewed-by: Igor Kozhukhov <igor at dilos.org>
Signed-off-by: Paul Zuchowski <pzuchowski at datto.com>
Closes #9644
Closes #9657 
DeltaFile
+6-1cmd/zdb/zdb.c
+6-11 files

ZFS on Linux/src 54c8366module/icp/algs/modes gcm.c, module/icp/core kcf_prov_lib.c

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 at llnl.gov>
Reviewed-by: Tom Caputi <tcaputi at datto.com>
Reviewed-by: Kjeld Schouten <kjeld at schouten-lebbing.nl>
Signed-off-by: Attila Fülöp <attila at fueloep.org>
Closes #9659 

ZFS on Linux/src 7af7286.github codecov.yml

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 at llnl.gov>
Signed-off-by: Kjeld Schouten-Lebbing <kjeld at schouten-lebbing.nl>
Closes #9650 

ZFS on Linux/src 5ff2249module/zfs arc.c

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 at datto.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Alexander Motin <mav at FreeBSD.org>
Sponsored-By: iXsystems, Inc.
Closes #9648 
DeltaFile
+16-3module/zfs/arc.c
+16-31 files

ZFS on Linux/src 624222alib/libzfs libzfs_dataset.c, man/man8 zfsprops.8

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 at delphix.com>
Reviewed-by: Kjeld Schouten <kjeld at schouten-lebbing.nl>
Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Closes #9131
Closes #9355 

ZFS on Linux/src b367334module/zcommon zfs_fletcher.c, module/zfs vdev_raidz_math.c

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 at freebsd.org>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Closes #9666 

ZFS on Linux/src bff8fb3module/zfs dmu_diff.c

Mark write_record static

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

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

ZFS on Linux/src 74d1d74include/os/linux/spl/sys sysmacros.h, module/lua ltablib.c

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 at freebsd.org>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Closes #9663 

ZFS on Linux/src e69bb31. .gitignore, module .gitignore

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 at ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Kjeld Schouten <kjeld at schouten-lebbing.nl>
Signed-off-by: Michael Niewöhner <foss at mniewoehner.de>
Closes #9656 
DeltaFile
+0-12.gitignore
+1-0module/.gitignore
+1-122 files

ZFS on Linux/src 5142032include/sys zfs_ioctl_impl.h, module/os/linux/zfs zfs_ioctl_os.c

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 at lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Closes #9624 

ZFS on Linux/src 42a826einclude/sys mntent.h

Add FreeBSD required defines to mntent.h

Linux and FreeBSD use different names for suid / setuid.

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

ZFS on Linux/src 758699bmodule/nvpair nvpair.c

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 at lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Closes #9643 

ZFS on Linux/src 101f9b1cmd/arc_summary arc_summary3 arc_summary2, cmd/arcstat arcstat

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 at llnl.gov>
Signed-off-by: Ryan Moeller <ryan at ixsystems.com>
Closes #9641 

ZFS on Linux/src c54687clib/libspl/asm-x86_64 atomic.S

Make asm-x86_64/atomic.S build on FreeBSD

Include the required headers for FreeBSD.

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

ZFS on Linux/src f348c78lib/libzpool kernel.c, module/os/linux/zfs vdev_file.c

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 at lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Closes #9633 

ZFS on Linux/src 77323bcinclude/sys zio_crypt.h

Add FreeBSD support to zio_crypto.h

Minimal compatibility changes for FreeBSD.

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

ZFS on Linux/src a5b762ainclude/sys zfs_ioctl.h, module/os/linux/zfs zfs_ioctl_os.c

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 at schouten-lebbing.nl>
Reviewed-by: Jorgen Lundman <lundman at lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Closes #9625 

ZFS on Linux/src a7c3588tests/zfs-tests/tests/functional/cli_root/zpool_attach attach-o_ashift.ksh

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

ZFS on Linux/src d6f67dfinclude/os/linux/spl/sys uio.h, include/sys abd.h zfs_project.h

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 at llnl.gov>
Reviewed-by: Kjeld Schouten <kjeld at schouten-lebbing.nl>
Signed-off-by: Matt Macy <mmacy at FreeBSD.org>
Closes #9615 

ZFS on Linux/src c940bf0etc/systemd/system-generators zfs-mount-generator.in

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 at gmail.com>
Reviewed-by: Richard Laager <rlaager at wiktel.com>
Signed-off-by: InsanePrawn <insane.prawny at gmail.com>
Closes #9611

ZFS on Linux/src 70d2dd9etc/systemd/system-generators zfs-mount-generator.in

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 at gmail.com>
Reviewed-by: Richard Laager <rlaager at wiktel.com>
Signed-off-by: InsanePrawn <insane.prawny at gmail.com>
Closes #9611

ZFS on Linux/src d8ce455etc/systemd/system-generators zfs-mount-generator.in

Fix small typo in systemd mount generator

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

ZFS on Linux/src 7c1bf0clib/libspl/include assert.h, lib/libzpool kernel.c

Implement -A (ignore ASSERTs) for zdb

The command line switch -A (ignore ASSERTs) has always been available 
in zdb but was never connected up to the correct global variable.

There are times when you need zdb to ignore asserts and keep dumping 
out whatever information it can get despite the ASSERT(s) failing. 
It was always intended to be part of zdb but was incomplete.

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