]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agomount.zfs.8: match to reality; zfsprops.8: add missing temporary options
наб [Mon, 24 May 2021 18:26:39 +0000 (20:26 +0200)]
mount.zfs.8: match to reality; zfsprops.8: add missing temporary options

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

3 years agomount.zfs.8: modernise
наб [Mon, 24 May 2021 16:15:26 +0000 (18:15 +0200)]
mount.zfs.8: modernise

No changes to the text itself

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

3 years agozfsprops.8: remove nbmand-not-used-on-Linux and pointer to mount(8)
наб [Mon, 24 May 2021 15:53:12 +0000 (17:53 +0200)]
zfsprops.8: remove nbmand-not-used-on-Linux and pointer to mount(8)

Linux man-pages' mount(8) points at fcntl(2), as does mount(2),
and support for it is little-used, deprecated, and configurable
since 4.5.

As far as I can tell, FreeBSD doesn't support nbmand at all ‒
mandatory locks are mostly dead

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

3 years agoVarious Linux kABI cosmetics
наб [Sat, 22 May 2021 00:38:17 +0000 (02:38 +0200)]
Various Linux kABI cosmetics

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

3 years agolinux: don't fall through to 3-arg vfs_getattr
наб [Tue, 25 May 2021 22:44:09 +0000 (00:44 +0200)]
linux: don't fall through to 3-arg vfs_getattr

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

3 years agoFreeBSD: Update dataset_kstats for zvols in dev mode
Alexander Motin [Wed, 26 May 2021 18:14:26 +0000 (14:14 -0400)]
FreeBSD: Update dataset_kstats for zvols in dev mode

Previous commit added accounting for geom mode, but not for dev.
In geom mode we actually have GEOM statistics, while in dev mode
additional accounting actually makes more sense.

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

3 years agoCorrect flaws in arc_summary[23] and their test.
Rich Ercolani [Wed, 26 May 2021 02:02:01 +0000 (22:02 -0400)]
Correct flaws in arc_summary[23] and their test.

The change correctly handles BrokenPipeError and improves the
associated tests.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #12037
Closes #12036

3 years agoFreeBSD: avoid memory allocation in arc_prune_async
Alexander Motin [Wed, 26 May 2021 01:38:34 +0000 (21:38 -0400)]
FreeBSD: avoid memory allocation in arc_prune_async

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

3 years agoFreeBSD: Retry OCF ENOMEM errors.
Alexander Motin [Mon, 24 May 2021 20:42:45 +0000 (16:42 -0400)]
FreeBSD: Retry OCF ENOMEM errors.

ZFS does not expect transient errors from crypto.  For read they are
counted as checksum errors, while for write end up in panic.  To not
panic on random low memory conditions retry ENOMEM errors in the OCF
wrapper function.

While there remove unneeded timeout and priority from msleep().

External-issue: https://reviews.freebsd.org/D30339
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored-By: iXsystems, Inc.
Closes #12077

3 years agoAdd note for printing all dbgmsg entries on FreeBSD
Rich Ercolani [Wed, 26 May 2021 01:08:27 +0000 (21:08 -0400)]
Add note for printing all dbgmsg entries on FreeBSD

I looked for a bit, and couldn't find any documentation on
how to print all logged dbgmsg entries, just messages since
the DTrace probe started, until @allanjude kindly pointed me
toward the sysctl.

So let's add that note where the DTrace probe is mentioned for
FreeBSD, so other people can find it.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #12113

3 years agoPropagate vdev state due to invalid label corruption
vermavipinkumar [Tue, 25 May 2021 18:32:07 +0000 (00:02 +0530)]
Propagate vdev state due to invalid label corruption

Propagate vdev child state to parents on invalid label
Add VDEV_AUX_BAD_LABEL to print_import_config()

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Co-authored-by: Srikanth N S <srikanth.nagasubbaraoseetharaman@hpe.com>
Signed-off-by: Vipin Kumar Verma <vipin.verma@hpe.com>
Closes #12088

3 years agoUpdate tmpfile() existence detection
Rich Ercolani [Thu, 20 May 2021 23:02:36 +0000 (19:02 -0400)]
Update tmpfile() existence detection

Linux changed the tmpfile() signature again in torvalds/linux@6521f89,
which in turn broke our HAVE_TMPFILE detection in configure.

Update that macro to include the new case, and change the signature of
zpl_tmpfile as appropriate.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes: #12060
Closes: #12087
3 years agoFix dRAID sequential resilver silent damage handling
Brian Behlendorf [Thu, 20 May 2021 22:05:26 +0000 (15:05 -0700)]
Fix dRAID sequential resilver silent damage handling

This change addresses two distinct scenarios which are possible
when performing a sequential resilver to a dRAID pool with vdevs
that contain silent unknown damage. Which in this circumstance
took the form of the devices being intentionally overwritten with
zeros. However, it could also result from a device returning incorrect
data while a sequential resilver was in progress.

Scenario 1) A sequential resilver is performed while all of the
dRAID vdevs are ONLINE and there is silent damage present on the
vdev being resilvered. In this case, nothing will be repaired
by vdev_raidz_io_done_reconstruct_known_missing() because
rc->rc_error isn't set on any of the raid columns. To address
this vdev_draid_io_start_read() has been updated to always mark
the resilvering column as ESTALE for sequential resilver IO.

Scenario 2) Multiple columns contain silent damage for the same
block and a sequential resilver is performed. In this case it's
impossible to generate the correct data from parity unless all of
the damaged columns are being sequentially resilvered (and thus
only good data is used to generate parity). This is as expected
and there's nothing which can be done about it. However, we need
to be careful not to make to situation worse. Since we can't
verify the data is actually good without a checksum, we must
only repair the devices which are being sequentially resilvered.
Otherwise, an incorrect repair to a device which previously
contained good data could effectively lock in the damage and
make reconstruction impossible. A check for this was added to
vdev_raidz_io_done_verified() along with a new test case.

Lastly, this change updates the redundancy_draid_spare1 and
redundancy_draid_spare3 test cases to be more representative
of normal dRAID replacement operation.  Specifically, what we
care about is that the scrub run after a sequential resilver
does not find additional blocks which need repair.  This would
indicate the sequential resilver failed to rebuild a section of
one of the devices. Note also the tests were switched to using
the verify_pool() function which still checks for checksum errors.

Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #12061

3 years agozfs-allow.8: mention 'bookmark' permission
Lauri Tirkkonen [Thu, 20 May 2021 16:03:03 +0000 (19:03 +0300)]
zfs-allow.8: mention 'bookmark' permission

Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Lauri Tirkkonen <lauri@hacktheplanet.fi>
Closes #12064

3 years agoSimple change to fix building in recent environments
Rich Ercolani [Thu, 20 May 2021 03:46:42 +0000 (23:46 -0400)]
Simple change to fix building in recent environments

Renamed _fini too for symmetry.

Suggested-by: @ensch
Reviewed-by: Tony Nguyen <tony.nguyen@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #12059
Closes: #11987
Closes: #12056
3 years agoScale worker threads and taskqs with number of CPUs
Alexander Motin [Fri, 14 May 2021 16:13:53 +0000 (12:13 -0400)]
Scale worker threads and taskqs with number of CPUs

While use of dynamic taskqs allows to reduce number of idle threads,
hardcoded 8 taskqs of each kind is a big overkill for small systems,
complicating CPU scheduling, increasing I/O reorder, etc, while
providing no real locking benefits, just not needed there.

On another side, 12*8 worker threads per kind are able to overload
almost any system nowadays.  For example, pool of several fast SSDs
with SHA256 checksum makes system barely responsive during scrub, or
with dedup enabled barely responsive during large file deletion.

To address both problems this patch introduces ZTI_SCALE macro, alike
to ZTI_BATCH, but with multiple taskqs, depending on number of CPUs,
to be used in places where lock scalability is needed, while request
ordering is not so much.  The code is made to create new taskq for
~6 worker threads (less for small systems, but more for very large)
up to 80% of CPU cores (previous 75% was not good for rounding down).
Both number of threads and threads per taskq are now tunable in case
somebody really wants to use all of system power for ZFS.

While obviously some benchmarks show small peak performance reduction
(not so big really, especially on systems with SMT, where use of the
second threads does not give as much performance as the first ones),
they also show dramatic latency reduction and much more smooth user-
space operation in case of high CPU usage by ZFS.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored-By: iXsystems, Inc.
Closes #11966

3 years agoZTS: Increase redundancy test timeout
Brian Behlendorf [Fri, 14 May 2021 16:11:56 +0000 (09:11 -0700)]
ZTS: Increase redundancy test timeout

The redundancy_draid.ksh and redundancy_raidz.ksh tests were updated
by commit 93c8e91fe to additionally verify self-healing.  This
additional check increased the run time which can now occasionally
exceed the default maximum timeout in the CI environment.  To prevent
this from causing failures increase the default timeout for the
redundancy test cases.

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

3 years agoFix dmu_recv_stream test for resumable
Paul Zuchowski [Fri, 14 May 2021 04:46:14 +0000 (00:46 -0400)]
Fix dmu_recv_stream test for resumable

Use dsl_dataset_has_resume_receive_state()
not dsl_dataset_is_zapified() to check if
stream is resumable.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Alek Pinchuk <apinchuk@axcient.com>
Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Signed-off-by: Paul Zuchowski <pzuchowski@datto.com>
Closes #12034

3 years agoFreeBSD: Use SET_ERROR to trace xattr name errors
Ryan Moeller [Wed, 28 Apr 2021 19:19:28 +0000 (19:19 +0000)]
FreeBSD: Use SET_ERROR to trace xattr name errors

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

3 years agoFreeBSD: Don't force xattr mount option
Ryan Moeller [Wed, 28 Apr 2021 18:58:30 +0000 (18:58 +0000)]
FreeBSD: Don't force xattr mount option

The kernel will use the xattr property by default when not overridden
by a mount option.

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

3 years agoRevert "Fix raw sends on encrypted datasets when copying back snapshots"
Brian Behlendorf [Thu, 13 May 2021 17:00:17 +0000 (10:00 -0700)]
Revert "Fix raw sends on encrypted datasets when copying back snapshots"

Commit d1d4769 takes into account the encryption key version to
decide if the local_mac could be zeroed out. However, this could lead
to failure mounting encrypted datasets created with intermediate
versions of ZFS encryption available in master between major releases.
In order to prevent this situation revert d1d4769 pending a more
comprehensive fix which addresses the mount failure case.

Reviewed-by: George Amanakis <gamanakis@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #11294
Issue #12025
Issue #12300
Closes #12033

3 years agoWiden mancheck target to all pages, fix them
наб [Mon, 10 May 2021 15:24:59 +0000 (17:24 +0200)]
Widen mancheck target to all pages, fix them

mandoc: ./man/man8/zfs-mount-generator.8.in:188:2:
        ERROR: skipping end of block that is not open: RE
mandoc: ./man/man8/zfs_ids_to_path.8:38:2:
        ERROR: skipping unknown macro: .LP
mandoc: ./man/man8/zfs_ids_to_path.8:48:2:
        ERROR: inserting missing end of block: Sh breaks Bl
mandoc: ./man/man8/zfs-wait.8:69:2:
        ERROR: skipping end of block that is not open: El
mandoc: ./man/man8/zfs-program.8:460:2:
        ERROR: inserting missing end of block: It breaks Bd
mandoc: ./man/man8/zfs-mount-generator.8:188:2:
        ERROR: skipping end of block that is not open: RE
mandoc: ./man/man8/zstream.8:43:2:
        ERROR: skipping unknown macro: .LP
mandoc: ./man/man8/zstream.8:107:2:
        ERROR: inserting missing end of block: Sh breaks Bl
mandoc: ./man/man8/zstream.8:107:2:
        ERROR: inserting missing end of block: Sh breaks Bl
make: *** [Makefile:1529: mancheck] Error 1

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

3 years agoZTS: Add known exceptions
Brian Behlendorf [Wed, 12 May 2021 02:55:12 +0000 (19:55 -0700)]
ZTS: Add known exceptions

The following seven tests been observed to occasionally fail during
CI testing.  This commit adds them to the list of known somewhat
flaky test cases.

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

3 years agolinux 5.13 compat: bdevops->revalidate_disk() removed
Coleman Kane [Wed, 12 May 2021 02:53:02 +0000 (22:53 -0400)]
linux 5.13 compat: bdevops->revalidate_disk() removed

Linux kernel commit 0f00b82e5413571ed225ddbccad6882d7ea60bc7 removes the
revalidate_disk() handler from struct block_device_operations. This
caused a regression, and this commit eliminates the call to it and the
assignment in the block_device_operations static handler assignment
code, when configure identifies that the kernel doesn't support that
API handler.

Reviewed-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Coleman Kane <ckane@colemankane.org>
Closes #11967
Closes #11977

3 years agomodule/zfs: remove zfs_zevent_console and zfs_zevent_cols
наб [Mon, 10 May 2021 18:00:15 +0000 (20:00 +0200)]
module/zfs: remove zfs_zevent_console and zfs_zevent_cols

zfs_zevent_console committed multiple printk()s per line without
properly continuing them ‒ a single event could easily be fragmented
across over thirty lines, making it useless for direct application

zfs_zevent_cols exists purely to wrap the output from zfs_zevent_console

The niche this was supposed to fill can be better served by something
akin to the all-syslog ZEDLET

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

3 years agoTag 2.1.0-rc5
Brian Behlendorf [Mon, 10 May 2021 22:13:37 +0000 (15:13 -0700)]
Tag 2.1.0-rc5

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
3 years agolibzfs: zfs_asprintf(): don't return undefined pointer
наб [Mon, 3 May 2021 10:30:16 +0000 (12:30 +0200)]
libzfs: zfs_asprintf(): don't return undefined pointer

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

3 years agolibzfsbootenv: lzbe_set_boot_device(): don't free undefined pointer
наб [Mon, 3 May 2021 10:11:30 +0000 (12:11 +0200)]
libzfsbootenv: lzbe_set_boot_device(): don't free undefined pointer

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

3 years agozfs_get_enclosure_sysfs_path(): don't free undefined pointer
наб [Mon, 3 May 2021 10:13:20 +0000 (12:13 +0200)]
zfs_get_enclosure_sysfs_path(): don't free undefined pointer

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

3 years agozfs_get_enclosure_sysfs_path(): don't leak dev path
наб [Mon, 3 May 2021 10:01:13 +0000 (12:01 +0200)]
zfs_get_enclosure_sysfs_path(): don't leak dev path

Also always free tmp2 at the end

Before:
nabijaczleweli@tarta:~/uwu$ valgrind --leak-check=full ./blergh
==8947== Memcheck, a memory error detector
==8947== Using Valgrind-3.14.0 and LibVEX
==8947== Command: ./blergh
==8947==
(null)
==8947==
==8947== HEAP SUMMARY:
==8947==     in use at exit: 23 bytes in 1 blocks
==8947==   total heap usage: 3 allocs, 2 frees, 1,147 bytes allocated
==8947==
==8947== 23 bytes in 1 blocks are definitely lost in loss record 1 of 1
==8947==    at 0x483577F: malloc (vg_replace_malloc.c:299)
==8947==    by 0x48D74B7: vasprintf (vasprintf.c:73)
==8947==    by 0x48B7833: asprintf (asprintf.c:35)
==8947==    by 0x401258: zfs_get_enclosure_sysfs_path
                         (zutil_device_path_os.c:191)
==8947==    by 0x401482: main (blergh.c:107)
==8947==
==8947== LEAK SUMMARY:
==8947==    definitely lost: 23 bytes in 1 blocks
==8947==    indirectly lost: 0 bytes in 0 blocks
==8947==      possibly lost: 0 bytes in 0 blocks
==8947==    still reachable: 0 bytes in 0 blocks
==8947==         suppressed: 0 bytes in 0 blocks
==8947==
==8947== For counts of detected and suppressed errors, rerun with: -v
==8947== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

nabijaczleweli@tarta:~/uwu$ sed -n 191p zutil_device_path_os.c
        tmpsize = asprintf(&tmp1, "/sys/block/%s/device", dev_name);

After:
nabijaczleweli@tarta:~/uwu$ valgrind --leak-check=full ./blergh
==9512== Memcheck, a memory error detector
==9512== Using Valgrind-3.14.0 and LibVEX
==9512== Command: ./blergh
==9512==
(null)
==9512==
==9512== HEAP SUMMARY:
==9512==     in use at exit: 0 bytes in 0 blocks
==9512==   total heap usage: 3 allocs, 3 frees, 1,147 bytes allocated
==9512==
==9512== All heap blocks were freed -- no leaks are possible
==9512==
==9512== For counts of detected and suppressed errors, rerun with: -v
==9512== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

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

3 years agozpool: vdev_run_cmd(): don't free undefined pointers
наб [Mon, 3 May 2021 09:36:02 +0000 (11:36 +0200)]
zpool: vdev_run_cmd(): don't free undefined pointers

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

3 years agolibzfs: zpool_load_compat(): don't free undefined pointers
наб [Fri, 30 Apr 2021 18:49:39 +0000 (20:49 +0200)]
libzfs: zpool_load_compat(): don't free undefined pointers

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

3 years agolibzfs: zpool_load_compat(): open feature file cloexec
наб [Thu, 29 Apr 2021 20:21:41 +0000 (22:21 +0200)]
libzfs: zpool_load_compat(): open feature file cloexec

As a bonus, this also passes the open flags into the open flags instead
of the mode (it worked by accident because O_RDONLY is 0),
correctly detects a failed map,
and prefaults the entire file since we're always writing to every page

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

3 years agocopy-builtin: posix conformance
illiliti [Sat, 8 May 2021 15:58:26 +0000 (15:58 +0000)]
copy-builtin: posix conformance

This commits contains changes to allow running `copy-builtin` without
bash + some minor improvements.

changed shebang to /bin/sh
added -f option to `set` to globally disable unneeded globbing
replaced all `echo` commands within add_after() with `printf`
alternative to avoid possible issues with options (-neE)
dropped non-portable superfluous `readlink` command
replaced superfluous `true` command with `:` builtin alternative
replaced non-portable `--recursive` option of `cp` command with `-R`
alternative
dropped non-portable `local` keyword

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: illiliti <illiliti@protonmail.com>
Closes #12004

3 years agoFix dRAID self-healing short columns
Brian Behlendorf [Sat, 8 May 2021 15:57:25 +0000 (08:57 -0700)]
Fix dRAID self-healing short columns

When dRAID performs a normal read operation only the data columns
in the raid map are read from disk.  This is enough information to
calculate the checksum, verify it, and return the needed data to the
application.  It's only in the event of a checksum failure that the
additional parity and any empty columns must be read since they are
required for parity reconstruction.

Reading these additional columns is handled by vdev_raidz_read_all()
which calls vdev_draid_map_alloc_empty() to expand the raid_map_t
and submit IOs for the missing columns.  This all works correctly,
but it fails to account for any "short" columns.  These are data
columns which are padded with a empty skip sector at the end.
Since that empty sector is not needed for a normal read it's not
read when columns is first read from disk.  However, like the parity
and empty columns the skip sector is needed to perform reconstruction.

The fix is to mark any "short" columns as never being read by clearing
the rc_tried flag when expanding the raid_map_t.  This will cause
the entire column to re-read from disk in the event of a checksum
failure allowing the self-healing functionality to repair the block.

Note that this only effects the self-healing feature because when
scrubbing a pool the parity, data, and empty columns are all read
initially to verify their contents.  Furthermore, only blocks which
contain "short" columns would be effected, and only when the memory
backing the skip sector wasn't already zeroed out.

This change extends the existing redundancy_raidz.ksh test case to
verify self-healing (as well as resilver and scrub).  Then applies
the same test case to dRAID with a slightly modified version of
the test script called redundancy_draid.ksh.  The unused variable
combrec was also removed from both test cases.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #12010

3 years agoReplace ZoL with OpenZFS where applicable
наб [Mon, 3 May 2021 19:21:21 +0000 (21:21 +0200)]
Replace ZoL with OpenZFS where applicable

Afterward, git grep ZoL matches:
  * README.md:  * [ZoL Site](https://zfsonlinux.org)
  - Correct
  * etc/default/zfs.in:# ZoL userland configuration.
  - Changing this would induce a needless upgrade-check,
    if the user has modified the configuration;
    this can be updated the next time the defaults change
  * module/zfs/dmu_send.c:   * ZoL < 0.7 does not handle [...]
  - Before 0.7 is ZoL, so fair enough

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

3 years agoFreeBSD: Remove !FreeBSD ifdef'd code
Ryan Moeller [Mon, 3 May 2021 17:56:08 +0000 (17:56 +0000)]
FreeBSD: Remove !FreeBSD ifdef'd code

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

3 years agoClean up use of zfs_log_create in zfs_dir
Ryan Moeller [Mon, 3 May 2021 17:51:03 +0000 (17:51 +0000)]
Clean up use of zfs_log_create in zfs_dir

zfs_log_create returns void, so there is no reason to cast its return
value to void at the call site.

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

3 years agozed: protect against wait4()/fork() races to the global PID table
наб [Fri, 7 May 2021 22:10:16 +0000 (00:10 +0200)]
zed: protect against wait4()/fork() races to the global PID table

This can be very easily triggered by adding a sleep(1) before
the wait4() on a PID-starved system: the reaper thread would wait
for a child before its entry appeared, letting old entries accumulate:

  Invoking "all-debug.sh" eid=3021 pid=391
  Finished "(null)" eid=0 pid=391 time=0.002432s exit=0
  Invoking "all-syslog.sh" eid=3021 pid=336
  Finished "(null)" eid=0 pid=336 time=0.002432s exit=0
  Invoking "history_event-zfs-list-cacher.sh" eid=3021 pid=347
  Invoking "all-debug.sh" eid=3022 pid=349
  Finished "history_event-zfs-list-cacher.sh" eid=3021 pid=347
                                              time=0.001669s exit=0
  Finished "(null)" eid=0 pid=349 time=0.002404s exit=0
  Invoking "all-syslog.sh" eid=3022 pid=370
  Finished "(null)" eid=0 pid=370 time=0.002427s exit=0
  Invoking "history_event-zfs-list-cacher.sh" eid=3022 pid=391
  avl_find(tree, new_node, &where) == NULL
  ASSERT at ../../module/avl/avl.c:641:avl_add()
  Thread 1 "zed" received signal SIGABRT, Aborted.

By employing this wider lock, we atomise [wait, remove] and [fork, add]:
slowing down the reaper thread now just causes some zombies
to accumulate until it can get to them

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Don Brady <don.brady@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11963
Closes #11965

3 years agoReturn required size when encode_fh size too small
Alyssa Ross [Fri, 7 May 2021 22:08:16 +0000 (22:08 +0000)]
Return required size when encode_fh size too small

Quoting <linux/exportfs.h>:

> encode_fh() should return the fileid_type on success and on error
> returns 255 (if the space needed to encode fh is greater than
> @max_len*4 bytes). On error @max_len contains the minimum size (in 4
> byte unit) needed to encode the file handle.

ZFS was not setting max_len in the case where the handle was too
small.  As a result of this, the `t_name_to_handle_at.c' example in
name_to_handle_at(2) did not work on ZFS.

zfsctl_fid() will itself set max_len if called with a fid that is too
small, so if we give zfs_fid() that behavior as well, the fix is quite
easy: if the handle is too small, just use a zero-size fid instead of
the handle.

Tested by running t_name_to_handle_at on a normal file, a directory, a
.zfs directory, and a snapshot.

Thanks-to: Puck Meerburg <puck@puckipedia.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Nguyen <tony.nguyen@delphix.com>
Signed-off-by: Alyssa Ross <hi@alyssa.is>
Closes #11995

3 years agoSimplify/fix dnode_move() for dn_zfetch
Alexander Motin [Fri, 7 May 2021 22:07:03 +0000 (18:07 -0400)]
Simplify/fix dnode_move() for dn_zfetch

Previous code tried to keep prefetch streams while moving dnode.  But
it was at least not updating per-stream zs_fetchback pointers, causing
use-after-free on next access.  Instead of that I see much easier and
cleaner to just drop old prefetch state and start new from scratch.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored-By: iXsystems, Inc.
Closes #11936
Closes #11998

3 years agoFreeBSD: Initialize/destroy zp->z_lock
Ryan Moeller [Thu, 6 May 2021 16:45:16 +0000 (12:45 -0400)]
FreeBSD: Initialize/destroy zp->z_lock

zp->z_lock is used in shared code for protecting projid and scantime.
We don't exercise these paths much if at all on FreeBSD, so have been
lucky enough not to have issues with the uninitialized locks so far.

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

3 years agoUpdated zfs_dbgmsg_enable documentation to be more accurate
Rich Ercolani [Thu, 6 May 2021 04:16:51 +0000 (00:16 -0400)]
Updated zfs_dbgmsg_enable documentation to be more accurate

Changed the default specified for zfs_dbgmsg_enable, added
clarification of interaction with zfs_flags.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #11984
Closes #11986

3 years agozed.d/zed-functions.sh: fix zed_guid_to_pool() on dash
наб [Tue, 27 Apr 2021 15:27:33 +0000 (17:27 +0200)]
zed.d/zed-functions.sh: fix zed_guid_to_pool() on dash

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11935
Closes #11954

3 years agozed.d/history_event-zfs-list-cacher.sh: no grep for snapshot detection
наб [Fri, 23 Apr 2021 20:41:47 +0000 (22:41 +0200)]
zed.d/history_event-zfs-list-cacher.sh: no grep for snapshot detection

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11935

3 years agozed.d/*-notify.sh: use mktemp instead of generating temp path manually
наб [Fri, 23 Apr 2021 20:41:19 +0000 (22:41 +0200)]
zed.d/*-notify.sh: use mktemp instead of generating temp path manually

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11935

3 years agozed.d/pool_import-led.sh: fix for current zpool scripts
наб [Fri, 23 Apr 2021 20:27:50 +0000 (22:27 +0200)]
zed.d/pool_import-led.sh: fix for current zpool scripts

Also minor clean-up with folding state_to_val() into a case,
unrolling the lesser-available seq into numbers,
ignoring vdev states we don't care about,
and documentation comments

Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11934
Closes #11935

3 years agolibzutil: fix dm_get_underlying_path() return if not a DM device
наб [Thu, 29 Apr 2021 08:40:39 +0000 (10:40 +0200)]
libzutil: fix dm_get_underlying_path() return if not a DM device

For example, this would happily return "/dev/(null)" for /dev/sda1

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11935

3 years agoZTS: Fix xattr_002_neg passing too soon
Ryan Moeller [Fri, 30 Apr 2021 14:37:02 +0000 (10:37 -0400)]
ZTS: Fix xattr_002_neg passing too soon

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

3 years agoFreeBSD: Prune some unneeded definitions
Ryan Moeller [Fri, 30 Apr 2021 14:34:53 +0000 (10:34 -0400)]
FreeBSD: Prune some unneeded definitions

IS_XATTRDIR is never used.
v_count is only used in two places, one immediately followed by the
use of the real name, v_usecount.

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

3 years agovdev_id: variable not getting expanded under map_slot()
Arshad Hussain [Thu, 29 Apr 2021 20:58:49 +0000 (02:28 +0530)]
vdev_id: variable not getting expanded under map_slot()

Under function map_slot() variable passed as args
were not getting properly substituted or expanded.
This patch fixes the substitution issue.

Reviewed-by: Niklas Edmundsson <nikke@acc.umu.se>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Closes #11951
Closes #11959

3 years agovdev_mirror: don't scrub/resilver devices that can't be read
Nathaniel Wesley Filardo [Wed, 28 Apr 2021 00:48:11 +0000 (01:48 +0100)]
vdev_mirror: don't scrub/resilver devices that can't be read

This ensures that we don't accumulate checksum errors against offline or
unavailable devices but, more importantly, means that we don't
needlessly create DTL entries for offline devices that are already
up-to-date.

Consider a 3-way mirror, with disk A always online (and so always with
an empty DTL) and B and C only occasionally online.  When A & B resilver
with C offline, B's DTL will effectively be appended to C's due to these
spurious ZIOs even as the resilver empties B's DTL:

  * These ZIOs land in vdev_mirror_scrub_done() and flag an error

  * That flagged error causes vdev_mirror_io_done() to see
    unexpected_errors, so it issues a ZIO_TYPE_WRITE repair ZIO, which
    inherits ZIO_FLAG_SCAN_THREAD because zio_vdev_child_io() includes
    that flag in ZIO_VDEV_CHILD_FLAGS.

  * That ZIO fails, too, and eventually zio_done() gets its hands on it
    and calls vdev_stat_update().

  * vdev_stat_update() sees the error and this zio...

    * is not speculative,
    * is not due to EIO (but rather ENXIO, since the device is closed)
    * has an ->io_vd != NULL (specifically, the offline leaf device)
    * is a write
    * is for a txg != 0 (but rather the read block's physical birth txg)
    * has ZIO_FLAG_SCAN_THREAD asserted

  * So: vdev_stat_update() calls vdev_dtl_dirty() on the offline vdev.

Then, when A & C resilver with B offline, that story gets replayed and
C's DTL will be appended to B's.

In fact, one does not need this permanently-broken-mirror scenario to
induce badness: breaking a mirror with no DTLs and then scrubbing will
create DTLs for all offline devices.  These DTLs will persist until the
entire mirror is reassembled for the duration of the *resilver*, which,
incidentally, will not consider the devices with good data to be sources
of good data in the case of a read failure.

Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Nathaniel Wesley Filardo <nwfilardo@gmail.com>
Closes #11930

3 years agozfs.spec.in: remove post ldconfig scriptlets
Brian Behlendorf [Wed, 28 Apr 2021 00:45:40 +0000 (17:45 -0700)]
zfs.spec.in: remove post ldconfig scriptlets

In Fedora 28 the packaging guidelines were changed such that ldconfig
should no longer be called in either the %post or %postun scriptlets.
Instead the new compatibility macros %ldconfig_post, %ldconfig_postun,
and %ldocnfig_scriptlets should be used.

Since we only currently support Fedora 31 and newer, we could drop
%post or %postun scriptlets entirely according to the guidelines.
However, since we also use the same spec file for CentOS / RHEL
it's convenient to call the macros which are available starting
with CentOS / RHEL 8.  For CentOS / RHEL 7 we must still call
ldconfig in the traditional way.

https://fedoraproject.org/wiki/Changes/Removing_ldconfig_scriptlets

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

3 years agozdb: ASSERT issues when DEBUG is not defined
Toomas Soome [Tue, 27 Apr 2021 15:33:37 +0000 (18:33 +0300)]
zdb: ASSERT issues when DEBUG is not defined

If zdb is not built with DEBUG mode, the ASSERT macros will be
eliminated.

This will leave vim defined, but not used (gcc warning) and
checkpoint spacemap validation loop will do nothing.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Toomas Soome <tsoome@me.com>
Closes #11932

3 years agoZTS: Add known exceptions
Brian Behlendorf [Tue, 27 Apr 2021 15:27:03 +0000 (08:27 -0700)]
ZTS: Add known exceptions

Both the zpool_initialize_import_export and checkpoint_discard_busy
test cases a known to occasionally fail.  Add them to the list of
known possible failures and reference the appropriate issue on the
tracker.

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

3 years agoDrop "All rights reserved" from files by trasz@FreeBSD.org
Martin Matuška [Tue, 27 Apr 2021 15:25:48 +0000 (17:25 +0200)]
Drop "All rights reserved" from files by trasz@FreeBSD.org

This obeys the change in freebsd/freebsd-src@bce7ee9d4

External-issue: https://reviews.freebsd.org/D26980
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Martin Matuska <mm@FreeBSD.org>
Closes #11947

3 years agoreceive: don't fail inheriting (-x) properties on wrong dataset type
Prawn [Tue, 27 Apr 2021 00:23:51 +0000 (02:23 +0200)]
receive: don't fail inheriting (-x) properties on wrong dataset type

Receiving datasets while blanket inheriting properties like zfs
receive -x mountpoint can generally be desirable, e.g. to avoid
unexpected mounts on backup hosts.

Currently this will fail to receive zvols due to the mountpoint
property being applicable to filesystems only.  This limitation
currently requires operators to special-case their minds and tools
for zvols.

This change gets rid of this limitation for inherit (-x) by
Spiting up the dataset type handling: Warnings for inheriting (-x),
errors for overriding (-o).

Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
Closes #11416
Closes #11840
Closes #11864

3 years agoFreeBSD: damage control racing .. lookups in face of mkdir/rmdir
Mateusz Guzik [Mon, 26 Apr 2021 19:44:40 +0000 (21:44 +0200)]
FreeBSD: damage control racing .. lookups in face of mkdir/rmdir

External-issue: https://reviews.freebsd.org/D29769
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Closes #11926

3 years agoFix AVX512BW Fletcher code on AVX512-but-not-BW machines
Romain Dolbeau [Mon, 26 Apr 2021 19:42:42 +0000 (21:42 +0200)]
Fix AVX512BW Fletcher code on AVX512-but-not-BW machines

Introduce a specific valid function for avx512f+avx512bw (instead
of checking only for avx512f).

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Adam Moss <c@yotes.com>
Signed-off-by: Romain Dolbeau <romain@dolbeau.org>
Closes #11937
Closes #11938

3 years agoTag 2.1.0-rc4
Brian Behlendorf [Thu, 22 Apr 2021 21:54:23 +0000 (14:54 -0700)]
Tag 2.1.0-rc4

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
3 years agozed: protect against wait4()/fork() races to the launched process tree
наб [Thu, 22 Apr 2021 15:48:53 +0000 (17:48 +0200)]
zed: protect against wait4()/fork() races to the launched process tree

As soon as wait4() returns, fork() can immediately return with the same
PID, and race to lock _launched_processes_lock, then try to add the new
(duplicate) PID to _launched_processes, which asserts

By locking before wait4(), we ensure, that, given that same
unfortunate scheduling, _launched_processes_lock cannot be locked by the
spawner before we pop the process in the reaper, and only afterward will
it be added

This moves where the reaper idles when there are children from the
wait4() to the pause(), locking for the duration of that single syscall
in both the no-children and running-children cases; the impact of this
is one to two syscalls (depending on _launched_processes_lock state)
per loop

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Don Brady <don.brady@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11924
Closes #11928

3 years agoFixed incorrect man page reference in zfsprops(8)
Daniel Stevenson [Tue, 20 Apr 2021 17:16:00 +0000 (12:16 -0500)]
Fixed incorrect man page reference in zfsprops(8)

The special_small_blocks section directed readers to zpool(8) for
documentation on special allocation classes, while they are actually
documented in zpoolconcepts(8).

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Daniel Stevenson <daniel@dstev.net>
Closes #11918

3 years agoetc/systemd/zfs-mount-generator: don't fail if no cached pools
наб [Mon, 19 Apr 2021 17:52:44 +0000 (19:52 +0200)]
etc/systemd/zfs-mount-generator: don't fail if no cached pools

If $FSLIST exists but is empty, the generator fails with
  sort: cannot read: '/etc/zfs/zfs-list.cache/*':
  No such file or directory

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

3 years agofreebsd/libshare: nfs: make nfs_is_shared() thread-safe
наб [Sun, 11 Apr 2021 18:12:50 +0000 (20:12 +0200)]
freebsd/libshare: nfs: make nfs_is_shared() thread-safe

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Wilson <gwilson@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11886

3 years agolibshare: nfs: don't leak nfs_lock_fd when lock fails
наб [Sun, 11 Apr 2021 17:27:43 +0000 (19:27 +0200)]
libshare: nfs: don't leak nfs_lock_fd when lock fails

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Wilson <gwilson@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11886

3 years agoZTS: Improve redundancy test scripts
Brian Behlendorf [Mon, 19 Apr 2021 04:58:36 +0000 (21:58 -0700)]
ZTS: Improve redundancy test scripts

- Add additional logging to provide more information about why the
  test failed.  This including logging more of the individual commands
  and the contents and differences of the record files on failure.

- Updated get_vdevs() to properly exclude all top-level vdevs
  including raidz3 and draid[1-3].

- Replaced gnudd with dd.  This is the only remaining place in the
  test suite gnudd is used and it shouldn't be needed.

- The refill_test_env function expects the pool as the first argument
  but never sets the pool variable.

- Only fill the test pools to 50% of capacity instead of 75% to help
  speed up the tests.

- Fix replace_missing_devs() calculation, MINDEVSIZE should be
  MINVDEVSIZE.

- Fix damage_devs() so it overwrites almost all of the device so
  we're guaranteed to damage filesystem blocks.

- redundancy_stripe.ksh should not use log_mustnot to check if the
  pool is healthy since the return value may be misinterpreted.
  Just perform a normal conditional check and log the failure.

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

3 years agoICP: Silence objtool "stack pointer realignment" warnings
Attila Fülöp [Sat, 17 Apr 2021 20:11:18 +0000 (22:11 +0200)]
ICP: Silence objtool "stack pointer realignment" warnings

Objtool requires the use of a DRAP register while aligning the
stack. Since a DRAP register is a gcc concept and we are
notoriously low on registers in the crypto code, it's not worth
the effort to mimic gcc generated stack realignment.

We simply silence the warning by adding the offending object files
to OBJECT_FILES_NON_STANDARD.

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

3 years agolibzfs: refresh property cache after inheriting userprop
наб [Fri, 16 Apr 2021 18:03:20 +0000 (20:03 +0200)]
libzfs: refresh property cache after inheriting userprop

This matches what happens when inheriting a system property

Consider the following program:
int main() {
void *zhp = libzfs_init();
void *dataset = zfs_open(zhp, "zest/__test", 1);

printf("before:");
dump_nvlist(zfs_get_user_props(dataset), 2);
printf("\n");

zfs_prop_inherit(dataset, "xyz.nabijaczleweli:test", 0);
printf("after:");
dump_nvlist(zfs_get_user_props(dataset), 2);
printf("\n");

zfs_refresh_properties(dataset);
printf("refreshed:");
dump_nvlist(zfs_get_user_props(dataset), 2);
printf("\n");
}

And the output before:
# zfs set xyz.nabijaczleweli:test=hehe zest/__test
# ./a.out
before:  xyz.nabijaczleweli:test:
      value: 'hehe'
      source: 'zest/__test'

after:  xyz.nabijaczleweli:test:
      value: 'hehe'
      source: 'zest/__test'

refreshed:

As compared to the output after:
# zfs set xyz.nabijaczleweli:test=hehe zest/__test
# ./a.out
before:  xyz.nabijaczleweli:test:
      value: 'hehe'
      source: 'zest/__test'

after:
refreshed:

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

3 years agolibzfs: don't mark prompt+raw as retriable
наб [Fri, 16 Apr 2021 15:52:47 +0000 (17:52 +0200)]
libzfs: don't mark prompt+raw as retriable

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

3 years agoCombine zio caches if possible
Mateusz Guzik [Sat, 17 Apr 2021 19:36:04 +0000 (21:36 +0200)]
Combine zio caches if possible

This deduplicates 2 sets of caches which use the same allocation size.

Memory savings fluctuate a lot, one sample result is FreeBSD running
"make buildworld" saving ~180MB RAM in reduced page count associated
with zio caches.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Closes #11877

3 years agocontrib/dracut: 90: zfs-{rollback,snapshot}-bootfs: use @sbindir@
наб [Wed, 14 Apr 2021 15:30:59 +0000 (17:30 +0200)]
contrib/dracut: 90: zfs-{rollback,snapshot}-bootfs: use @sbindir@

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

3 years agocontrib/i-t: properly mount root's children with spaces
наб [Tue, 13 Apr 2021 21:23:15 +0000 (23:23 +0200)]
contrib/i-t: properly mount root's children with spaces

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

3 years agocontrib/dracut: 90: mount essential datasets under root
наб [Tue, 13 Apr 2021 20:41:10 +0000 (22:41 +0200)]
contrib/dracut: 90: mount essential datasets under root

This partly mirrors what the i-t script does (though that mounts all
children, recursively) ‒ /etc, /usr, /lib*, and /bin are all essential,
if present, to successfully invoke the real init, which will then mount
everything else it might need in the right order

The following extreme-case set-up boots w/o issues now:
  /               zoot            zfs  rw,relatime,xattr,noacl
  ├─/etc          zoot/etc        zfs  rw,relatime,xattr,noacl
  ├─/usr          zoot/usr        zfs  rw,relatime,xattr,noacl
  │ └─/usr/local  zoot/usr/local  zfs  rw,relatime,xattr,noacl
  ├─/var          zoot/var        zfs  rw,relatime,xattr,noacl
  │ ├─/var/lib    zoot/var/lib    zfs  rw,relatime,xattr,noacl
  │ ├─/var/log    zoot/var/log    zfs  rw,relatime,xattr,posixacl
  │ ├─/var/cache  zoot/var/cache  zfs  rw,relatime,xattr,noacl
  │ └─/var/tmp    zoot/var/tmp    zfs  rw,relatime,xattr,noacl
  ├─/home         zoot/home       zfs  rw,relatime,xattr,noacl
  │ └─/home/nab   zoot/home/nab   zfs  rw,relatime,xattr,noacl
  ├─/boot         zoot/boot       zfs  rw,relatime,xattr,noacl
  ├─/root         zoot/home/root  zfs  rw,relatime,xattr,noacl
  ├─/opt          zoot/opt        zfs  rw,relatime,xattr,noacl
  └─/srv          zoot/srv        zfs  rw,relatime,xattr,noacl

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

3 years agocontrib/dracut: 90: generator: only log to kmsg if debug set on cmdline
наб [Tue, 13 Apr 2021 20:37:59 +0000 (22:37 +0200)]
contrib/dracut: 90: generator: only log to kmsg if debug set on cmdline

"debug" is also used by systemd itself, and there's really no reason for
the generator to write this much garbage by default

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

3 years agocontrib/dracut: 02: don't spill device names across multiple lines
наб [Tue, 13 Apr 2021 20:31:26 +0000 (22:31 +0200)]
contrib/dracut: 02: don't spill device names across multiple lines

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

3 years agoFix crash in zio_done error reporting
Paul Zuchowski [Fri, 16 Apr 2021 18:00:53 +0000 (14:00 -0400)]
Fix crash in zio_done error reporting

Fix NULL pointer dereference when reporting
checksum error for gang block in zio_done.

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

3 years agozfs-send(8): Restore sorting of flags
Ryan Moeller [Fri, 16 Apr 2021 00:43:07 +0000 (20:43 -0400)]
zfs-send(8): Restore sorting of flags

Before #11710 the flags in zfs-send(8) were sorted.
Restore order and bump the date.

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

3 years agolinux/spl: proc: use global table_{min,max} values instead of local ones
наб [Sun, 11 Apr 2021 14:29:00 +0000 (16:29 +0200)]
linux/spl: proc: use global table_{min,max} values instead of local ones

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

3 years agolinux/libspl: gethostid: read from /proc/sys/kernel/spl/hostid, simplify
наб [Sat, 10 Apr 2021 23:51:04 +0000 (01:51 +0200)]
linux/libspl: gethostid: read from /proc/sys/kernel/spl/hostid, simplify

Fixes get_system_hostid() if it was set via the aforementioned sysctl
and simplifies the code a bit.  The kernel and user-space must agree,
after all.

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

3 years agolinux/spl: base proc_dohostid() on proc_dostring()
наб [Sat, 10 Apr 2021 23:18:40 +0000 (01:18 +0200)]
linux/spl: base proc_dohostid() on proc_dostring()

This fixes /proc/sys/kernel/spl/hostid on kernels with mainline commit
32927393dc1ccd60fb2bdc05b9e8e88753761469 ("sysctl: pass kernel pointers
to ->proc_handler") ‒ 5.7-rc1 and up

The access_ok() check in copy_to_user() in proc_copyout_string() would
always fail, so all userspace reads and writes would fail with EINVAL

proc_dostring() strips only the final new-line,
but simple_strtoul() doesn't actually need a back-trimmed string ‒
writing "012345678   \n" is still allowed, as is "012345678zupsko", &c.

This alters what happens when an invalid value is written ‒
previously it'd get set to what-ever simple_strtoul() returned
(probably 0, thereby resetting it to default), now it does nothing

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

3 years agoZFS traverse_visitbp optimization to limit prefetch
Jitendra Patidar [Thu, 15 Apr 2021 20:49:27 +0000 (02:19 +0530)]
ZFS traverse_visitbp optimization to limit prefetch

Traversal code, traverse_visitbp() does visit blocks recursively.
Indirect (Non L0) Block of size 128k could contain, 1024 block pointers
of 128 bytes. In case of full traverse OR incremental traverse, where
all blocks were modified, it could traverse large number of blocks
pointed by indirect. Traversal code does issue prefetch of blocks
traversed below indirect. This could result into large number of
async reads queued on vdev queue. So, account for prefetch issued for
blocks pointed by indirect and limit max prefetch in one go.

Module Param:
zfs_traverse_indirect_prefetch_limit: Limit of prefetch while traversing
an indirect block.

Local counters:
prefetched: Local counter to account for number prefetch done.
pidx: Index for which next prefetch to be issued.
ptidx: Index at which next prefetch to be triggered.

Keep "ptidx" somewhere in the middle of blocks prefetched, so that
blocks prefetch read gets the enough time window before their demand
read is issued.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Jitendra Patidar <jitendra.patidar@nutanix.com>
Closes #11802
Closes #11803

3 years agoZTS: add zed_fd_spill to verify the fds ZEDLETs inherit
наб [Mon, 12 Apr 2021 12:08:33 +0000 (14:08 +0200)]
ZTS: add zed_fd_spill to verify the fds ZEDLETs inherit

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

3 years agozed: set O_CLOEXEC on persistent fds, remove closefrom() from pre-exec
наб [Mon, 12 Apr 2021 12:07:14 +0000 (14:07 +0200)]
zed: set O_CLOEXEC on persistent fds, remove closefrom() from pre-exec

Also don't dup /dev/null over stdio if daemonised

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

3 years agoAdd SIGSTOP and SIGTSTP handling to issig
Paul Dagnelie [Thu, 15 Apr 2021 20:34:35 +0000 (13:34 -0700)]
Add SIGSTOP and SIGTSTP handling to issig

This change adds SIGSTOP and SIGTSTP handling to the issig function;
this mirrors its behavior on Solaris. This way, long running kernel
tasks can be stopped with the appropriate signals. Note that doing
so with ctrl-z on the command line doesn't return control of the tty
to the shell, because tty handling is done separately from stopping
the process. That can be future work, if people feel that it is a
necessary addition.

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

3 years agoFix 'make checkbashisms` warnings
Brian Behlendorf [Thu, 15 Apr 2021 15:53:08 +0000 (08:53 -0700)]
Fix 'make checkbashisms` warnings

The awk command used by the checkbashisms target incorrectly
adds the escape character before the ! and # characters.  This
results in the following warnings because these characters do not
need to be escaped.

    awk: cmd. line:1: warning: regexp escape sequence
        `\!' is not a known regexp operator
    awk: cmd. line:1: warning: regexp escape sequence
        `\#' is not a known regexp operator

Remove the unneeded escape character before ! and #.

Valid escape sequences are:

    https://www.gnu.org/software/gawk/manual/html_node/Escape-Sequences.html

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

3 years agoTag 2.1.0-rc3
Brian Behlendorf [Wed, 14 Apr 2021 21:50:37 +0000 (14:50 -0700)]
Tag 2.1.0-rc3

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
3 years agoFix vdev health padding in zpool list -v
Yuri Pankov [Wed, 14 Apr 2021 16:02:16 +0000 (19:02 +0300)]
Fix vdev health padding in zpool list -v

Do not (incorrectly, right instead left) pad health string itself,
it will be taken care of when printing property value below.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Yuri Pankov <yuripv@FreeBSD.org>
Closes #11899

3 years agoObsolete earlier packages due to version bump
Brian Behlendorf [Tue, 13 Apr 2021 23:33:06 +0000 (16:33 -0700)]
Obsolete earlier packages due to version bump

Follow up to d5ef91af which adds a missing 'obsoletes' for the
libzfs-devel package.

Add a comment to the zfs.spec file as a reminder that previous
versions of the package should be marked as obsolete.

Reviewed-by: Olaf Faaland <faaland1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #11844
Closes #11895

3 years agolinux/libspl: getextmntent(): don't leak mnttab FILE*
наб [Thu, 8 Apr 2021 22:42:03 +0000 (00:42 +0200)]
linux/libspl: getextmntent(): don't leak mnttab FILE*

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

3 years agolibzfs: zfs_mount_at(): load key for encryption root if MS_CRYPT
наб [Tue, 13 Apr 2021 04:26:55 +0000 (06:26 +0200)]
libzfs: zfs_mount_at(): load key for encryption root if MS_CRYPT

zfs_crypto_load_key() only works on encryption roots,
and zfs mount -la would fail if it encounters a datasets that
is sorted before their encroots.

To trigger:
  truncate -s 40G /tmp/test
  dd if=/dev/urandom of=/tmp/k bs=128 count=1 status=none
  zpool create -O encryption=on -O keylocation=file:///tmp/k \
               -O keyformat=passphrase test /tmp/test
  zfs create -o mountpoint=/a test/a
  zfs create -o mountpoint=/b test/b
  zfs umount test
  zfs unload-key test
  zfs mount -la

The final mount errored out with:
  Key load error: Keys must be loaded for
    encryption root of 'test/a' (test).
  Key load error: Keys must be loaded for
    encryption root of 'test/b' (test).

And only /test was mounted

This technically breaks the libzfs API, but the previous behavior was
decidedly a bug.

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

3 years agoFreeBSD: use vnlru_free_vfsops if available
Mateusz Guzik [Mon, 12 Apr 2021 18:01:46 +0000 (20:01 +0200)]
FreeBSD: use vnlru_free_vfsops if available

Fixes issues when zfs is used along with other filesystems.

External-issue: https://cgit.freebsd.org/src/commit/?id=e9272225e6bed840b00eef1c817b188c172338ee
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Closes #11881

3 years agoFreeBSD: add missing seqc write begin/end around zfs_acl_chown_setattr
Mateusz Guzik [Mon, 12 Apr 2021 17:59:57 +0000 (19:59 +0200)]
FreeBSD: add missing seqc write begin/end around zfs_acl_chown_setattr

It happens to trip over an assert but does not matter for correctness at
this time. Done for future proofing.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Closes #11884

3 years agoFreeBSD: add support for lockless symlink lookup
Mateusz Guzik [Mon, 12 Apr 2021 17:59:22 +0000 (19:59 +0200)]
FreeBSD: add support for lockless symlink lookup

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Closes #11883

3 years ago.gitmodules: link to openzfs github repository
наб [Fri, 9 Apr 2021 01:26:45 +0000 (03:26 +0200)]
.gitmodules: link to openzfs github repository

Update the test images link to reference the openzfs github repository.

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

3 years agocmd/zfs receive: allow dry-run (-n) to check property args
Prawn [Mon, 12 Apr 2021 16:35:55 +0000 (18:35 +0200)]
cmd/zfs receive: allow dry-run (-n) to check property args

zfs recv -n does not report some errors it could.  The code to bail
out of the receive if in dry-run mode came a little early, skipping
validation of cmdprops (recv -x and -o) among others.  Move the
check down to enable these additional checks.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
Closes #11862

3 years agoImprovements to the 'compatibility' property
Colm [Mon, 12 Apr 2021 16:08:56 +0000 (17:08 +0100)]
Improvements to the 'compatibility' property

Several improvements to the operation of the 'compatibility' property:

1) Improved handling of unrecognized features:
Change the way unrecognized features in compatibility files are handled.

 * invalid features in files under /usr/share/zfs/compatibility.d
   only get a warning (as these may refer to future features not yet in
   the library),
 * invalid features in files under /etc/zfs/compatibility.d
   get an error (as these are presumed to refer to the current system).

2) Improved error reporting from zpool_load_compat.
Note: slight ABI change to zpool_load_compat for better error reporting.

3) compatibility=legacy inhibits all 'zpool upgrade' operations.

4) Detect when features are enabled outside current compatibility set
   * zpool set compatibility=foo <-- print a warning
   * zpool set feature@xxx=enabled <-- error
   * zpool status <-- indicate this state

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Colm Buckley <colm@tuatha.org>
Closes #11861

3 years agoZTS: fix removal_condense_export test case
Brian Behlendorf [Mon, 12 Apr 2021 04:49:13 +0000 (21:49 -0700)]
ZTS: fix removal_condense_export test case

It's been observed in the CI that the required 25% of obsolete bytes
in the mapping can be to high a threshold for this test resulting in
condensing never being triggered and a test failure.  To prevent these
failures make the existing zfs_condense_indirect_obsolete_pct tuning
available so the obsolete percentage can be reduced from 25% to 5%
during this test.

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

3 years agoUpdate libzfs.abi for zfs_send() change
Brian Behlendorf [Mon, 12 Apr 2021 00:03:55 +0000 (17:03 -0700)]
Update libzfs.abi for zfs_send() change

Commit 099fa7e4 intentionally modified the libzfs ABI.  However, it
failed to include an update for the libzfs.abi file.  This commit
resolves the `make checkabi` warning due to that omission.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #11710

3 years agoBalance parentheses in parameter descriptions
pstef [Sun, 11 Apr 2021 23:35:07 +0000 (01:35 +0200)]
Balance parentheses in parameter descriptions

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Piotr Paweł Stefaniak <pstef@freebsd.org>
Closes #11882

3 years agoZTS: Add known exceptions
Brian Behlendorf [Sun, 11 Apr 2021 22:55:38 +0000 (15:55 -0700)]
ZTS: Add known exceptions

The fault/auto_spare_shared, l2arc/persist_l2arc_007_pos, and
alloc_class/alloc_class_013_pos test cases are not entirely reliable
and may occasionally fail resulting in a false positive in the CI.
Add these tests to known list of possible failures until they can
be made 100% reliable.

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