]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agolibzfs: calculate receive times with sub-second precision
наб [Wed, 16 Feb 2022 00:42:30 +0000 (01:42 +0100)]
libzfs: calculate receive times with sub-second precision

Provide two digits of precision when reporting send/receive
times.  Tiny snapshots may take significantly less than a second
and rounding up to a full second can introduce a significant error.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13047

2 years agoCross-platform xattr user namespace compatibility
Ryan Moeller [Wed, 16 Feb 2022 00:35:30 +0000 (19:35 -0500)]
Cross-platform xattr user namespace compatibility

ZFS on Linux originally implemented xattr namespaces in a way that is
incompatible with other operating systems.  On illumos, xattrs do not
have namespaces.  Every xattr name is visible.  FreeBSD has two
universally defined namespaces: EXTATTR_NAMESPACE_USER and
EXTATTR_NAMESPACE_SYSTEM.  The system namespace is used for protected
FreeBSD-specific attributes such as MAC labels and pnfs state.  These
attributes have the namespace string "freebsd:system:" prefixed to the
name in the encoding scheme used by ZFS.  The user namespace is used
for general purpose user attributes and obeys normal access control
mechanisms.  These attributes have no namespace string prefixed, so
xattrs written on illumos are accessible in the user namespace on
FreeBSD, and xattrs written to the user namespace on FreeBSD are
accessible by the same name on illumos.

Linux has several xattr namespaces.  On Linux, ZFS encodes the
namespace in the xattr name for every namespace, including the user
namespace.  As a consequence, an xattr in the user namespace with the
name "foo" is stored by ZFS with the name "user.foo" and therefore
appears on FreeBSD and illumos to have the name "user.foo" rather than
"foo".  Conversely, none of the xattrs written on FreeBSD or illumos
are accessible on Linux unless the name happens to be prefixed with one
of the Linux xattr namespaces, in which case the namespace is stripped
from the name.  This makes xattrs entirely incompatible between Linux
and other platforms.

We want to make the encoding of user namespace xattrs compatible across
platforms.  A critical requirement of this compatibility is for xattrs
from existing pools from FreeBSD and illumos to be accessible by the
same names in the user namespace on Linux.  It is also necessary that
existing pools with xattrs written by Linux retain access to those
xattrs by the same names on Linux.  Making user namespace xattrs from
Linux accessible by the correct names on other platforms is important.
The handling of other namespaces is not required to be consistent.

Add a fallback mechanism for listing and getting xattrs to treat xattrs
as being in the user namespace if they do not match a known prefix.

Do not allow setting or getting xattrs with a name that is prefixed
with one of the namespace names used by ZFS on supported platforms.

Allow choosing between legacy illumos and FreeBSD compatibility and
legacy Linux compatibility with a new tunable.  This facilitates
replication and migration of pools between hosts with different
compatibility needs.

The tunable controls whether or not to prefix the namespace to the
name.  If the xattr is already present with the alternate prefix,
remove it so only the new version persists.  By default the platform's
existing convention is used.

Reviewed-by: Christian Schwarz <christian.schwarz@nutanix.com>
Reviewed-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #11919

2 years agomodule: icp: remove provider stats
наб [Wed, 2 Feb 2022 22:11:34 +0000 (23:11 +0100)]
module: icp: remove provider stats

These were all folded into a single kstat at
  /proc/spl/kstat/kcf/NONAME_provider_stats
with no way to know which one it actually was,
and only the AES and SHA (so not Skein) ones were ever updated

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: enforce KCF_{OPS_CLASSSIZE,MAXMECHTAB}
наб [Fri, 7 Jan 2022 00:32:14 +0000 (01:32 +0100)]
module: icp: enforce KCF_{OPS_CLASSSIZE,MAXMECHTAB}

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove unused pd_{remove_cv,hash_limit}
наб [Mon, 27 Dec 2021 02:02:17 +0000 (03:02 +0100)]
module: icp: remove unused pd_{remove_cv,hash_limit}

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove vestigia of crypto sessions
наб [Mon, 27 Dec 2021 01:53:32 +0000 (02:53 +0100)]
module: icp: remove vestigia of crypto sessions

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove unused (and mostly faked) cm_{{min,max}_key_length,mech_flags}
наб [Mon, 27 Dec 2021 01:39:55 +0000 (02:39 +0100)]
module: icp: remove unused (and mostly faked) cm_{{min,max}_key_length,mech_flags}

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove unused crypto_provider_handle_t
наб [Mon, 27 Dec 2021 01:32:37 +0000 (02:32 +0100)]
module: icp: remove unused crypto_provider_handle_t

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove pre-set entries from mechtabs
наб [Sat, 25 Dec 2021 03:37:22 +0000 (04:37 +0100)]
module: icp: remove pre-set entries from mechtabs

They don't do anything except clogging up the AVL tree

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: rip out insane crypto_req_handle_t mechanism, inline KM_SLEEP
наб [Sat, 25 Dec 2021 03:34:29 +0000 (04:34 +0100)]
module: icp: rip out insane crypto_req_handle_t mechanism, inline KM_SLEEP

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agoinclude: crypto: clean out api.h
наб [Sat, 25 Dec 2021 03:00:34 +0000 (04:00 +0100)]
include: crypto: clean out api.h

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove unused headers. Migrate {ops => sched}_impl
наб [Sat, 25 Dec 2021 02:50:01 +0000 (03:50 +0100)]
module: icp: remove unused headers. Migrate {ops => sched}_impl

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agoinclude: crypto: clean out unused SYSCALL32 and flags
наб [Sat, 25 Dec 2021 02:44:06 +0000 (03:44 +0100)]
include: crypto: clean out unused SYSCALL32 and flags

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove algorithm name defines used only in the default mechtab
наб [Sat, 25 Dec 2021 02:40:59 +0000 (03:40 +0100)]
module: icp: remove algorithm name defines used only in the default mechtab

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agoinclude: crypto: remove unused algorithm name defines
наб [Sat, 25 Dec 2021 02:37:53 +0000 (03:37 +0100)]
include: crypto: remove unused algorithm name defines

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove set-but-unused cd_miscdata
наб [Sat, 25 Dec 2021 02:33:19 +0000 (03:33 +0100)]
module: icp: remove set-but-unused cd_miscdata

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: fold away all key formats except CRYPTO_KEY_RAW
наб [Sat, 25 Dec 2021 02:23:07 +0000 (03:23 +0100)]
module: icp: fold away all key formats except CRYPTO_KEY_RAW

It's the only one actually used

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove unused CRYPTO_* error codes
наб [Sat, 25 Dec 2021 01:50:25 +0000 (02:50 +0100)]
module: icp: remove unused CRYPTO_* error codes

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: rip out modhash. Replace the one user with AVL
наб [Sat, 25 Dec 2021 00:07:58 +0000 (01:07 +0100)]
module: icp: rip out modhash. Replace the one user with AVL

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove unused me_mutex
наб [Sat, 25 Dec 2021 00:51:28 +0000 (01:51 +0100)]
module: icp: remove unused me_mutex

It only needs to be locked if dynamic changes can occur. They can't.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove unused me_threshold
наб [Sat, 25 Dec 2021 00:32:06 +0000 (01:32 +0100)]
module: icp: remove unused me_threshold

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove unused struct crypto_ctx::cc_{session,flags,opstate}
наб [Fri, 24 Dec 2021 23:26:17 +0000 (00:26 +0100)]
module: icp: remove unused struct crypto_ctx::cc_{session,flags,opstate}

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove unused gswq, kcfpool, [as]req_cache, reqid_table, obsolete kstat
наб [Fri, 24 Dec 2021 23:10:57 +0000 (00:10 +0100)]
module: icp: remove unused gswq, kcfpool, [as]req_cache, reqid_table, obsolete kstat

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove unused notification framework
наб [Fri, 24 Dec 2021 16:43:28 +0000 (17:43 +0100)]
module: icp: remove unused notification framework

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove unused kcf_op_{group,type}, req_params, ...
наб [Fri, 24 Dec 2021 16:34:19 +0000 (17:34 +0100)]
module: icp: remove unused kcf_op_{group,type}, req_params, ...

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove unused p[di]_flags
наб [Fri, 24 Dec 2021 16:04:32 +0000 (17:04 +0100)]
module: icp: remove unused p[di]_flags

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove unused CRYPTO_{NOTIFY_OPDONE,SKIP_REQID,RESTRICTED}
наб [Fri, 24 Dec 2021 15:43:18 +0000 (16:43 +0100)]
module: icp: remove unused CRYPTO_{NOTIFY_OPDONE,SKIP_REQID,RESTRICTED}

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove unused CRYPTO_ALWAYS_QUEUE
наб [Fri, 24 Dec 2021 15:26:11 +0000 (16:26 +0100)]
module: icp: remove unused CRYPTO_ALWAYS_QUEUE

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove unused kcf_digest.c
наб [Fri, 24 Dec 2021 15:26:25 +0000 (16:26 +0100)]
module: icp: remove unused kcf_digest.c

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: drop software provider generation numbers
наб [Fri, 24 Dec 2021 14:39:47 +0000 (15:39 +0100)]
module: icp: drop software provider generation numbers

We register all providers at once, before anything happens

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove unused kcf_mac operations
наб [Thu, 23 Dec 2021 19:11:01 +0000 (20:11 +0100)]
module: icp: remove unused kcf_mac operations

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove unused kcf_cipher operations
наб [Thu, 23 Dec 2021 19:06:22 +0000 (20:06 +0100)]
module: icp: remove unused kcf_cipher operations

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: remove other provider types
наб [Thu, 23 Dec 2021 18:51:00 +0000 (19:51 +0100)]
module: icp: remove other provider types

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: use original mechanisms
наб [Thu, 23 Dec 2021 17:44:07 +0000 (18:44 +0100)]
module: icp: use original mechanisms

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: use original description
наб [Thu, 23 Dec 2021 17:34:23 +0000 (18:34 +0100)]
module: icp: use original description

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: guarantee the ops vector is persistent
наб [Thu, 23 Dec 2021 17:27:44 +0000 (18:27 +0100)]
module: icp: guarantee the ops vector is persistent

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: have a static 8 providers
наб [Thu, 23 Dec 2021 02:22:27 +0000 (03:22 +0100)]
module: icp: have a static 8 providers

This is currently twice the amount we actually have (sha[12], skein,
aes), and 512 * sizeof(void*) = 4096: 128x more than we need and a waste
of most of a page in the kernel address space

Plus, there's no need to actually allocate it dynamically: it's always
got a static size. Put it in .data

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: spi: crypto_ops_t: remove unused op types
наб [Wed, 22 Dec 2021 22:29:25 +0000 (23:29 +0100)]
module: icp: spi: crypto_ops_t: remove unused op types

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: spi: flatten struct crypto_ops, crypto_provider_info
наб [Wed, 22 Dec 2021 21:09:28 +0000 (22:09 +0100)]
module: icp: spi: flatten struct crypto_ops, crypto_provider_info

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: spi: remove crypto_control_ops_t
наб [Wed, 22 Dec 2021 21:03:00 +0000 (22:03 +0100)]
module: icp: spi: remove crypto_control_ops_t

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agomodule: icp: spi: remove crypto_{provider,op}_notification()
наб [Wed, 22 Dec 2021 20:55:37 +0000 (21:55 +0100)]
module: icp: spi: remove crypto_{provider,op}_notification()

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12901

2 years agoAdd spa _os() hooks
Jorgen Lundman [Tue, 15 Feb 2022 23:54:25 +0000 (08:54 +0900)]
Add spa _os() hooks

Add hooks for when spa is created, exported, activated and
deactivated. Used by macOS to attach iokit, and lock
kext as busy (to stop unloads).

Userland, Linux, and, FreeBSD have empty stubs.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jorgen Lundman <lundman@lundman.net>
Closes #12801

2 years agoAvoid dirtying the final TXGs when exporting a pool
George Amanakis [Tue, 15 Feb 2022 23:48:59 +0000 (00:48 +0100)]
Avoid dirtying the final TXGs when exporting a pool

There are two codepaths than can dirty final TXGs:

1) If calling spa_export_common()->spa_unload()->
   spa_unload_log_sm_flush_all() after the spa_final_txg is set, then
   spa_sync()->spa_flush_metaslabs() may end up dirtying the final
   TXGs. Then we have the following panic:
   Call Trace:
    <TASK>
    dump_stack_lvl+0x46/0x62
    spl_panic+0xea/0x102 [spl]
    dbuf_dirty+0xcd6/0x11b0 [zfs]
    zap_lockdir_impl+0x321/0x590 [zfs]
    zap_lockdir+0xed/0x150 [zfs]
    zap_update+0x69/0x250 [zfs]
    feature_sync+0x5f/0x190 [zfs]
    space_map_alloc+0x83/0xc0 [zfs]
    spa_generate_syncing_log_sm+0x10b/0x2f0 [zfs]
    spa_flush_metaslabs+0xb2/0x350 [zfs]
    spa_sync_iterate_to_convergence+0x15a/0x320 [zfs]
    spa_sync+0x2e0/0x840 [zfs]
    txg_sync_thread+0x2b1/0x3f0 [zfs]
    thread_generic_wrapper+0x62/0xa0 [spl]
    kthread+0x127/0x150
    ret_from_fork+0x22/0x30
    </TASK>

2) Calling vdev_*_stop_all() for a second time in spa_unload() after
   spa_export_common() unnecessarily delays the final TXGs beyond what
   spa_final_txg is set at.

Fix this by performing the check and call for
spa_unload_log_sm_flush_all() before the spa_final_txg is set in
spa_export_common(). Also check if the spa_final_txg has already been
set in spa_unload() and skip those calls in this case.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: George Amanakis <gamanakis@gmail.com>
External-issue: https://www.illumos.org/issues/9081
Closes #13048
Closes #13098

2 years agoRename fallthrough to zfs_fallthrough
Jorgen Lundman [Tue, 15 Feb 2022 16:58:59 +0000 (01:58 +0900)]
Rename fallthrough to zfs_fallthrough

Unfortunately macOS has obj-C keyword "fallthrough" in the OS headers.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com>
Signed-off-by: Jorgen Lundman <lundman@lundman.net>
Closes #13097

2 years agolibzfs: sendrecv: fix missing error output for invalid properties
наб [Mon, 14 Feb 2022 13:29:27 +0000 (14:29 +0100)]
libzfs: sendrecv: fix missing error output for invalid properties

Fixes: 7633c0aedd20f48646409b16b0e4524da24f7f9a ("libzfs: sendrecv:
fix unused, remove argsused")

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Amanakis <gamanakis@gmail.com>
Reviewed-by: Ryan Moeller <freqlabs@FreeBSD.org>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13100
Closes #13101

2 years agozfs-receive.8: properly unlight = in option setting
наб [Mon, 14 Feb 2022 12:22:52 +0000 (13:22 +0100)]
zfs-receive.8: properly unlight = in option setting

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Amanakis <gamanakis@gmail.com>
Reviewed-by: Ryan Moeller <freqlabs@FreeBSD.org>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13101

2 years agozfs-receive.8: fix Op Fl x Ar encryption in running text
наб [Mon, 14 Feb 2022 12:20:33 +0000 (13:20 +0100)]
zfs-receive.8: fix Op Fl x Ar encryption in running text

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Amanakis <gamanakis@gmail.com>
Reviewed-by: Ryan Moeller <freqlabs@FreeBSD.org>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13101

2 years agoSilence uninitialized warnings in dsl_dataset.c
Rich Ercolani [Mon, 14 Feb 2022 18:04:50 +0000 (13:04 -0500)]
Silence uninitialized warnings in dsl_dataset.c

On newer compilers, dsl_dataset.c now warns (or, on DEBUG, errors)
on uninitialized variable usage.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #13083

2 years agoZTS: Fix checkpoint_ro_rewind.ksh
Brian Behlendorf [Sun, 13 Feb 2022 22:22:49 +0000 (14:22 -0800)]
ZTS: Fix checkpoint_ro_rewind.ksh

Related to commit 90b77a036.  Retry the `zpool export` if the pool is
"busy" indicating there is a process accessing the mount point.  This
can happen after an import and allowing it to be retried will avoid
spurious test failures.

Reviewed by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #13092

2 years agoZTS: Fix zpool_expand_001_pos
Brian Behlendorf [Sun, 13 Feb 2022 22:22:00 +0000 (14:22 -0800)]
ZTS: Fix zpool_expand_001_pos

The dRAID section of the zpool_expand_001_pos test would reliably fail
because the calculated expansion size assumed the dRAID top-level vdev
was created with a distributed spare.  Create the vdev as expected to
resolve the test failure.

This test case flaw was accidentally caused by changing the default
number of dRAID distributed spares from one to zero while dRAID was
being developed.

Additionally, remove zpool_expand_005_pos from the list of possible
faulty tests.  It appears to be passing consistently in my testing.

Reviewed by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #13091

2 years agoFix gcc warning in kfpu_begin()
Brian Behlendorf [Fri, 11 Feb 2022 22:31:45 +0000 (14:31 -0800)]
Fix gcc warning in kfpu_begin()

Observed when building on CentOS 8 Stream.  Remove the `out`
label at the end of the function and instead return.

  linux/simd_x86.h: In function 'kfpu_begin':
  linux/simd_x86.h:337:1: error: label at end of compound statement

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Attila Fülöp <attila@fueloep.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #13089

2 years agoZTS: Fix problem with zdb_objset_id test
Paul Zuchowski [Fri, 11 Feb 2022 21:32:08 +0000 (16:32 -0500)]
ZTS: Fix problem with zdb_objset_id test

Use large numbers for datasets with numeric names to avoid name
and id collisions.  Sporadic test failures were observed when the
test would create $TESTPOOL/100 with an objset ID of 100.

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

2 years agozpool-import.8: WARNING should be emphasised
наб [Thu, 10 Feb 2022 18:43:25 +0000 (19:43 +0100)]
zpool-import.8: WARNING should be emphasised

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13082

2 years agozpool-import.8: newpool is Ar, not Sy
наб [Thu, 10 Feb 2022 18:43:08 +0000 (19:43 +0100)]
zpool-import.8: newpool is Ar, not Sy

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13082

2 years agozpoolprops.7: document leaked
наб [Fri, 11 Feb 2022 19:49:07 +0000 (20:49 +0100)]
zpoolprops.7: document leaked

It's noted very scarcely in the code as it stands, indeed the only
actual comment on this is

  /*
   * We have finished background destroying, but there is still
   * some space left in the dp_free_dir. Transfer this leaked
   * space to the dp_leak_dir.
   */

Introduced in fbeddd60b79690b6a6ececc9b00b6014d21405aa ("Illumos 4390 -
I/O errors can corrupt space map when deleting fs/vol"),
which explains, alongside the references, that this can only happen
with a corrupted pool

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13081

2 years agoCorrect a typo in zfs-receive.8
Zhu Chuang [Fri, 11 Feb 2022 19:47:35 +0000 (03:47 +0800)]
Correct a typo in zfs-receive.8

Should be  `-o keyformat=passphrase` instead of `-o -keyformat=passphrase`

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chuang Zhu <chuang@melty.land>
Closes #13072

2 years agocontrib: rename initrd READMEs to README.md
наб [Wed, 26 Jan 2022 13:44:08 +0000 (14:44 +0100)]
contrib: rename initrd READMEs to README.md

It's an unhelpful naming scheme and one that breaks GitHub autoreadme.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13017

2 years agocontrib: dracut: zfs-{rollback,snapshot}-bootfs: don't shell for test
наб [Wed, 26 Jan 2022 13:42:13 +0000 (14:42 +0100)]
contrib: dracut: zfs-{rollback,snapshot}-bootfs: don't shell for test

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13017

2 years agodracut: README: rewrite
наб [Wed, 26 Jan 2022 13:38:29 +0000 (14:38 +0100)]
dracut: README: rewrite

The documentation in the dracut README has grown stale and inaccurate.
Remove the stale content and write a short and useful reference manual.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13012
Closes #13017

2 years agoZTS: Fix zvol_misc_volmode test
Brian Behlendorf [Thu, 10 Feb 2022 01:00:03 +0000 (17:00 -0800)]
ZTS: Fix zvol_misc_volmode test

Changing volmode may need to remove minors, which could be open, so
call udev_wait() before we "zfs set volmode=<value>".  This ensures
no udev process has the zvol open (i.e. blkid) and the kernel
zvol_remove_minor_impl() function won't skip removing the in use
device.

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

2 years agoAdd dataset_kstats_update.. to mmap read/write paths
drowfx [Wed, 9 Feb 2022 22:41:42 +0000 (23:41 +0100)]
Add dataset_kstats_update.. to mmap read/write paths

This allows reads/writes caused by accesses to mmap files to be
accounted correctly in the per-dataset kstats for both Linux and
FreeBSD.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <freqlabs@FreeBSD.org>
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Closes #12994
Closes #13044

2 years agoReceive checks should allow unencrypted child datasets
Attila Fülöp [Wed, 9 Feb 2022 22:38:33 +0000 (23:38 +0100)]
Receive checks should allow unencrypted child datasets

dmu_recv_begin_check() unconditionally sets the DS_HOLD_FLAG_DECRYPT
flag before calling dsl_dataset_hold_flags(). If the key on the
receiving side isn't loaded or the send stream contains embedded
blocks, the receive check fails for a stream which is perfectly
valid and could be received without any problem. This seems like
a remnant of the initial design, where unencrypted datasets below
encrypted ones weren't allowed.

Add a condition to set `DS_HOLD_FLAG_DECRYPT` only for encrypted
datasets, modify an existing test to detect this regression and add
a test for raw replication streams.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Amanakis <gamanakis@gmail.com>
Co-authored-by: George Amanakis <gamanakis@gmail.com>
Signed-off-by: Attila Fülöp <attila@fueloep.org>
Closes #13033
Closes #13076

2 years agoRename EMPTY_TASKQ into taskq_empty
Jorgen Lundman [Wed, 9 Feb 2022 22:04:26 +0000 (07:04 +0900)]
Rename EMPTY_TASKQ into taskq_empty

To follow a change in illumos taskq

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Nguyen <tony.nguyen@delphix.com>
Signed-off-by: Jorgen Lundman <lundman@lundman.net>
Closes #12802

2 years agoPropagate KERNEL_* to *.spec
Damian Szuberski [Tue, 8 Feb 2022 22:17:37 +0000 (17:17 -0500)]
Propagate KERNEL_* to *.spec

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Authored-by: Damian Szuberski <szuberskidamian@gmail.com>
Signed-off-by: Peter Levine <plevine457@gmail.com>
Closes #13046

2 years agoAdd support for $KERNEL_{CC,LD,LLVM} variables
Peter Levine [Wed, 2 Feb 2022 05:44:59 +0000 (00:44 -0500)]
Add support for $KERNEL_{CC,LD,LLVM} variables

Currently, $(CC), $(LD), and $(LLVM) variables aren't passed to kbuild
while building modules.  This causes modules to build with the default
GNU GCC toolchain and prevents experimenting with other toolchains such
as CLANG/LLVM.  It can also lead to build failure if the CFLAGS/LDFLAGS
passed are incompatible with gcc/ld.

Pass $KERNEL_CC, $KERNEL_LD, and $KERNEL_LLVM as $(CC), $(LD), and
$(LLVM), respectively, to kbuild for each that is defined in the
environment.  This should take care of the majority of alternative
toolchain use cases.

Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Peter Levine <plevine457@gmail.com>
Closes #13046

2 years agoLinux 5.16 compat: don't use XSTATE_XSAVE to save FPU state
Attila Fülöp [Wed, 9 Feb 2022 20:50:10 +0000 (21:50 +0100)]
Linux 5.16 compat: don't use XSTATE_XSAVE to save FPU state

Linux 5.16 moved XSTATE_XSAVE and XSTATE_XRESTORE out of our reach,
so add our own XSAVE{,OPT,S} code and use it for Linux 5.16.

Please note that this differs from previous behavior in that it
won't handle exceptions created by XSAVE an XRSTOR. This is sensible
for three reasons.

 - Exceptions during XSAVE and XRSTOR can only occur if the feature
   is not supported or enabled or the memory operand isn't aligned
   on a 64 byte boundary. If this happens something else went
   terribly wrong, and it may be better to stop execution.

 - Previously we just printed a warning and didn't handle the fault,
   this is arguable for the above reason.

 - All other *SAVE instruction also don't handle exceptions, so this
   at least aligns behavior.

Finally add a test to catch such a regression in the future.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Attila Fülöp <attila@fueloep.org>
Closes #13042
Closes #13059

2 years agoRemove unused files from GitHub runners
Damian Szuberski [Wed, 9 Feb 2022 19:50:13 +0000 (20:50 +0100)]
Remove unused files from GitHub runners

Majority of the software installed by default in GitHub runners is
irrelevant to OpenZFS. Reclaimed space could be used for more/bigger
vdev files. File deletion happens in the background, leveraging
`systemd-run` - the workflow is not significantly slowed down.

Before
```
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        84G   53G   31G  63% /
```

After
```
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        84G   15G   70G  18% /
```

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes #13066

2 years ago`mount.zfs -o zfsutil` leverages `zfs_mount_at()`
Damian Szuberski [Tue, 8 Feb 2022 18:53:23 +0000 (19:53 +0100)]
`mount.zfs -o zfsutil` leverages `zfs_mount_at()`

Using `zfs_mount_at()` gives opportunity to properly propagate
mountopts from what's stored in a pool to the `mount(2)` syscall
invocation. It fixes cases when mount options are set to incorrect
values and rectification is impossible (e. g. Linux initrd boot
sequence in #7947).
Moved debug information printing after all variables are
initialized - printed text reflects what is passed to `mount(2)`.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Issue #7947
Closes #13021

2 years agoRemove unneeded "extern inline" function declarations
Tomohiro Kusumi [Tue, 8 Feb 2022 18:48:57 +0000 (03:48 +0900)]
Remove unneeded "extern inline" function declarations

All of these externs are already #included as static inline
functions via corresponding headers.

Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Closes #13073

2 years agoAdd `--enable=all` to ShellCheck by default
Damian Szuberski [Mon, 7 Feb 2022 19:59:09 +0000 (20:59 +0100)]
Add `--enable=all` to ShellCheck by default

Change enforced shell type from `dash` to `sh` and excluded
`SC2039` and `SC3043` by default. `local` keyword is accepted by all
POSIX shells from practical point of view. There is no need anymore
to enforce dash so `local` is accepted.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes #13020

2 years agoExtract workflows dependencies
Damian Szuberski [Mon, 7 Feb 2022 19:44:17 +0000 (20:44 +0100)]
Extract workflows dependencies

- Move build dependencies moved to
  `.github/workflows/build-dependencies.txt` shared among workflows.

- Change `ubuntu-latest` -> `ubuntu-20.04` to avoid unexpected
  runner environment updates in `zloop` workflow.

- Change `ubuntu-20.04` -> `ubuntu-latest` to track changes in
  runner environment in `checkstyle` workflow.

- Kernel buffer is flushed before ZTS invocation to avoid storing
  the same data after each test case run.

- `make` is invoked with consistent set of options to reduce
  clutter in logs.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes #13037

2 years agozvol: make calls to platform ops static
Christian Schwarz [Mon, 7 Feb 2022 18:24:38 +0000 (19:24 +0100)]
zvol: make calls to platform ops static

There's no need to make the platform ops dynamic dispatch.

This change replaces the dynamic dispatch with static calls to the
platform-specific functions.
To avoid name collisions, prefix all platform-specific functions
with `zvol_os_`.
I actually find `zvol_..._os` slightly nicer to read in the calling
code, but having it as a prefix is useful.

Advantage:
- easier jump-to-definition / grepping
- potential benefits to static analysis
- better legibility

Future work: also prefix remaining `static` functions in zvol_os.c.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Christian Schwarz <christian.schwarz@nutanix.com>
Closes #12965

2 years agoAdd more control/visibility to spa_load_verify().
Alexander Motin [Fri, 4 Feb 2022 21:06:38 +0000 (16:06 -0500)]
Add more control/visibility to spa_load_verify().

Use error thresholds from policy to control whether to scrub data
and/or metadata.  If threshold is set to UINT64_MAX, then caller
probably does not care about result and we may skip that part.

By default import neither set the data error threshold nor read
the error counter, so skip the data scrub for faster import.
Metadata are still scrubbed and fail if even single error found.

While there just for symmetry return number of metadata errors in
case threshold is not set to zero and we haven't reached it.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Pavel Zakharov <pavel.zakharov@delphix.com>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Closes #13022

2 years agozfs_set_prop_nvlist: make it easier to spot the call to dsl_props_set
Christian Schwarz [Fri, 4 Feb 2022 19:52:10 +0000 (20:52 +0100)]
zfs_set_prop_nvlist: make it easier to spot the call to dsl_props_set

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Christian Schwarz <christian.schwarz@nutanix.com>
Closes #12963

2 years agodsl_dir_tempreserve_impl: remove unused `deferred` variable
Christian Schwarz [Fri, 4 Feb 2022 18:33:34 +0000 (19:33 +0100)]
dsl_dir_tempreserve_impl: remove unused `deferred` variable

The following commit moved the users of `deferred` into function
dsl_pool_unreserved_space:

    commit d2734cce68cf740e015312314415f9034c67851c
    Author: Serapheim Dimitropoulos <serapheim.dimitro@delphix.com>
    Date:   Fri Dec 16 14:11:29 2016 -0800

        OpenZFS 9166 - zfs storage pool checkpoint

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <freqlabs@FreeBSD.org>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Christian Schwarz <christian.schwarz@nutanix.com>
Closes #13056

2 years agoZTS: Update enospc_002_pos test case
Brian Behlendorf [Fri, 4 Feb 2022 17:36:46 +0000 (09:36 -0800)]
ZTS: Update enospc_002_pos test case

The on-disk cost of creating a snapshot or bookmark is sufficiently low
that it is difficult to make it reliably fail even when the pool is
"full".  In order to avoid false positives remove these two checks from
the test case.

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

2 years agoFix clearing set-uid and set-gid bits on a file when replying a write
Pawel Jakub Dawidek [Thu, 3 Feb 2022 22:37:57 +0000 (14:37 -0800)]
Fix clearing set-uid and set-gid bits on a file when replying a write

POSIX requires that set-uid and set-gid bits to be removed when an
unprivileged user writes to a file and ZFS does that during normal
operation.

The problem arrises when the write is stored in the ZIL and replayed.
During replay we have no access to original credentials of the process
doing the write, so zfs_write() will be performed with the root
credentials. When root is doing the write set-uid and set-gid bits
are not removed from the file.

To correct that, log a separate TX_SETATTR entry that removed those bits
on first write to such file.

Idea from: Christian Schwarz

Add test for ZIL replay of setuid/setgid clearing.

Improve various edge cases when clearing setid bits:
- The setid bits can be readded during a single write, so make sure to check
  for them on every chunk write.
- Log TX_SETATTR record at most once per transaction group (if the setid bits
  are keep coming back).
- Move zfs_log_setattr() outside of zp->z_acl_lock.

Reviewed-by: Dan McDonald <danmcd@joyent.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Co-authored-by: Christian Schwarz <me@cschwarz.com>
Signed-off-by: Pawel Jakub Dawidek <pawel@dawidek.net>
Closes #13027

2 years agoAdd `--enable-asan` and `--enable-ubsan` switches
Damian Szuberski [Thu, 3 Feb 2022 22:35:38 +0000 (23:35 +0100)]
Add `--enable-asan` and `--enable-ubsan` switches

`configure` now accepts `--enable-asan` and `--enable-ubsan` switches
which results in passing `-fsanitize=address`
and `-fsanitize=undefined`, respectively, to the compiler. Those
flags are enabled in GitHub workflows for ZTS and zloop. Errors
reported by both instrumentations are corrected, except for:

- Memory leak reporting is (temporarily) suppressed. The cost of
  fixing them is relatively high compared to the gains.

- Checksum computing functions in `module/zcommon/zfs_fletcher*`
  have UBSan errors suppressed. It is completely impractical
  to enforce 64-byte payload alignment there due to performance
  impact.

- There's no ASan heap poisoning in `module/zstd/lib/zstd.c`. A custom
  memory allocator is used there rendering that measure
  unfeasible.

- Memory leaks detection has to be suppressed for `cmd/zvol_id`.
  `zvol_id` is run by udev with the help of `ptrace(2)`. Tracing is
  incompatible with memory leaks detection.

Reviewed-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes #12928

2 years agozed-functions.sh: escape newline to produce valid json
Phil Kauffman [Thu, 3 Feb 2022 22:31:57 +0000 (16:31 -0600)]
zed-functions.sh: escape newline to produce valid json

This was discovered when using Discords Slack compatible webhook.

Slack webhooks works without the escape, however Discord rightly refuses
the POST as it contains invalid JSON.

https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook

Valid (while escaping the newline:
```
+ msg_json='{"text": "*ZFS scrub_finish error for test on quartz*\nZFS has detected a data error:\n\n   eid: 124\n class: scrub_finish\n  host: quartz\n  time: \n error: \n objid: :\n  pool: test\n"}'
```

Invalid (no escape):
```
+ msg_json='{"text": "*ZFS scrub_finish error for test on quartz*
ZFS has detected a data error:\n\n   eid: 124\n class: scrub_finish\n  host: quartz\n  time: \n error: \n objid: :\n  pool: test\n"}'
```
The new line gets rendered and not sent inside the JSON as intended.

```
++ curl -X POST https://discord.com/api/webhooks/{webhook.id}/{webhook.token}/slack --header 'Content-Type: application/json' --data-binary '{"text": "*ZFS scrub_finish error for test on quartz*
ZFS has detected a data error:\n\n   eid: 124\n class: scrub_finish\n  host: quartz\n  time: \n error: \n objid: :\n  pool: test\n"}'
+ msg_out='{"message": "Cannot send an empty message", "code": 50006}'
```

Test method:
`root@quartz:/etc/zfs/zed.d# export ZED_ZEDLET_DIR=/etc/zfs/zed.d; export ZEVENT_EID=124; export ZEVENT_SUBCLASS=scrub_finish; export ZEVENT_POOL=test; export ZED_NOTIFY_DATA=1; bash -x ./data-notify.sh`

Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Philip Kauffman <philip@kauffman.me>
Closes #13049

2 years agoAdd enumerated vdev names to 'zpool iostat -v' and 'zpool list -v'
Akash B [Thu, 3 Feb 2022 22:29:29 +0000 (03:59 +0530)]
Add enumerated vdev names to 'zpool iostat -v' and 'zpool list -v'

This commit adds enumerated names to disambiguate between the
different vdevs. Previously only 'zpool status' showed enumerated
vdev names, now 'zpool list -v' and 'zpool iostat -v' also shows
the enumerated vdev names.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Dipak Ghosh <dipak.ghosh@hpe.com>
Signed-off-by: Akash B <akash-b@hpe.com>
Closes #12510
Closes #13031

2 years agoReport dnodes with faulty bonuslen
George Amanakis [Thu, 3 Feb 2022 22:28:19 +0000 (23:28 +0100)]
Report dnodes with faulty bonuslen

In files created/modified before 4254acb there may be a corruption of
xattrs which is not reported during scrub and normal send/receive. It
manifests only as an error when raw sending/receiving. This happens
because currently only the raw receive path checks for discrepancies
between the dnode bonus length and the spill pointer flag.

In case we encounter a dnode whose bonus length is greater than the
predicted one, we should report an error. Modify in this regard
dnode_sync() with an assertion at the end, dump_dnode() to error out,
dsl_scan_recurse() to report errors during a scrub, and zstream to
report a warning when dumping. Also added a test to verify spill blocks
are sent correctly in a raw send.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: George Amanakis <gamanakis@gmail.com>
Closes #12720
Closes #13014

2 years agoNotice if the test-runner dies
наб [Wed, 2 Feb 2022 22:17:46 +0000 (23:17 +0100)]
Notice if the test-runner dies

Currently, we seem to only care if the results collector errors.
We also should care if the test-runner died.

Authored-by: Rich Ercolani <rincebrain@gmail.com>
Co-authored-by: Rich Ercolani <rincebrain@gmail.com>
Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12998

2 years agoFix trivial calloc(3) arguments order
Tomohiro Kusumi [Wed, 2 Feb 2022 19:27:35 +0000 (04:27 +0900)]
Fix trivial calloc(3) arguments order

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <freqlabs@FreeBSD.org>
Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Closes #13052

2 years agoSimplify resume token generation
Ryan Moeller [Mon, 8 Nov 2021 22:35:05 +0000 (22:35 +0000)]
Simplify resume token generation

* Improve naming.
* Reduce indentation.
* Avoid boilerplate logic duplication.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967

2 years agolibzfs_sendrecv: Factor out lzc_flags_from_resume_nvl
Ryan Moeller [Mon, 13 Sep 2021 15:11:43 +0000 (15:11 +0000)]
libzfs_sendrecv: Factor out lzc_flags_from_resume_nvl

Improve the readability of zfs_send_resume_impl by moving resume nvl
decoding into a separate helper function.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967

2 years agolibzfs_sendrecv: Refactor find_redact_book
Ryan Moeller [Mon, 13 Sep 2021 15:10:56 +0000 (15:10 +0000)]
libzfs_sendrecv: Refactor find_redact_book

Factor out get_bookmarks, find_redact_pair, and get_redact_complete
helper functions to improve the readability of find_redact_book.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967

2 years agolibzfs_sendrecv: Fix some comment style nits
Ryan Moeller [Mon, 13 Sep 2021 14:51:02 +0000 (14:51 +0000)]
libzfs_sendrecv: Fix some comment style nits

* Capitalize and punctuate complete sentences.
* Add a blank line between functions.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967

2 years agolibzfs_sendrecv: Style pass on dump_filesystems
Ryan Moeller [Wed, 18 Aug 2021 21:01:21 +0000 (21:01 +0000)]
libzfs_sendrecv: Style pass on dump_filesystems

* Add a high level comment.
* Eliminate unnecessarily void arg.
* Capitalize and punctuate complete sentences in comments.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967

2 years agolibzfs_sendrecv: Style pass on dump_filesystem
Ryan Moeller [Wed, 18 Aug 2021 18:01:04 +0000 (18:01 +0000)]
libzfs_sendrecv: Style pass on dump_filesystem

* Add high level comments.
* Eliminate unnecessarily void arg.
* Avoid unnecessary line wrapping.
* Initialize sdd fields with the correct types.
* Remove extra whitespace.
* Refactor replication checks for clarity.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967

2 years agolibzfs_sendrecv: Style pass on dump_snapshot
Ryan Moeller [Wed, 18 Aug 2021 17:04:46 +0000 (17:04 +0000)]
libzfs_sendrecv: Style pass on dump_snapshot

* Add a high level comment.
* Avoid unnecessary line wrapping.
* Simplify size accounting logic.
* Eliminate unnecessary buffer on the stack.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967

2 years agolibzfs_sendrecv: Style pass on send_print_verbose
Ryan Moeller [Thu, 12 Aug 2021 16:50:50 +0000 (16:50 +0000)]
libzfs_sendrecv: Style pass on send_print_verbose

* Add missing dgettext calls.
* Avoid unnecessary line wraps.
* Factor out duplicated parsable check.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967

2 years agolibzfs_sendrecv: Pull header line out of loop
Ryan Moeller [Thu, 12 Aug 2021 16:48:56 +0000 (16:48 +0000)]
libzfs_sendrecv: Pull header line out of loop

This makes the header print before the sleep as well, which is fine.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967

2 years agolibzfs_sendrecv: Initialize in case of failure
Ryan Moeller [Thu, 5 Aug 2021 15:32:57 +0000 (15:32 +0000)]
libzfs_sendrecv: Initialize in case of failure

In zfs_send_progress, initialize \*bytes_written and \*blocks_visited
in case we have to return early due to ioctl failure.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967

2 years agolibzfs_sendrecv: Style pass on dump_ioctl
Ryan Moeller [Thu, 5 Aug 2021 15:29:24 +0000 (15:29 +0000)]
libzfs_sendrecv: Style pass on dump_ioctl

* Don't bother building a debug nvlist if we can't return it.
* Save errno after ioctl failure in case snprintf clobbers it.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967

2 years agolibzfs_sendrecv: Style pass on zfs_send_space
Ryan Moeller [Thu, 5 Aug 2021 15:28:32 +0000 (15:28 +0000)]
libzfs_sendrecv: Style pass on zfs_send_space

* Reduce indentation.
* Move locals closer to use.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967

2 years agolibzfs_sendrecv: Style pass on send_iterate_fs
Ryan Moeller [Tue, 27 Jul 2021 16:20:15 +0000 (16:20 +0000)]
libzfs_sendrecv: Style pass on send_iterate_fs

* Capitalize and punctuate complete sentences in comments.
* Separate out a group of locals to add a comment on their purpose.
* Remove unnecessary line wrapping.
* Make it clear that dds_origin is a string by using explicit character
  comparison to check for an empty string, rather than implictly
  treating it as a boolean.
* Reorganize manipulation of props and holds nvlists to improve
  clarity.
* There's no need to initialize the snapname buffer with zeros, we're
  immediately overwriting it.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967

2 years agolibzfs_sendrecv: Style pass on send_iterate_prop
Ryan Moeller [Tue, 27 Jul 2021 16:18:29 +0000 (16:18 +0000)]
libzfs_sendrecv: Style pass on send_iterate_prop

* Add a high level comment.
* Move locals closer to point of use.
* Use fnv* routines rather than explicit verification of success.
* Factor out duplicated code by introducing isspacelimit to clarify
  behavior.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967

2 years agolibzfs_sendrecv: Style pass on send_iterate_snap
Ryan Moeller [Tue, 27 Jul 2021 13:49:59 +0000 (13:49 +0000)]
libzfs_sendrecv: Style pass on send_iterate_snap

* Add a high level comment.
* Use local variables to reduce line wrapping.
* Remove extra braces and insert space for clarity.
* Assert precondition that the dataset name contains '@' for sanity.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967

2 years agolibzfs_sendrecv: Fix leaked holds nvlist
Ryan Moeller [Tue, 27 Jul 2021 13:48:42 +0000 (13:48 +0000)]
libzfs_sendrecv: Fix leaked holds nvlist

There is no need to allocate a holds nvlist.  lzc_get_holds does that
for us.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967

2 years agolibzfs_sendrecv: Avoid extra avl_find
Ryan Moeller [Tue, 27 Jul 2021 13:47:27 +0000 (13:47 +0000)]
libzfs_sendrecv: Avoid extra avl_find

avl_add does avl_find internally, then avl_insert.  We're already doing
the avl_find, so using avl_insert directly avoids repeating the search.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967