]> git.proxmox.com Git - mirror_zfs.git/log
mirror_zfs.git
2 years agolinux: libshare/smb: cache smb_available
наб [Sun, 17 Apr 2022 13:00:15 +0000 (15:00 +0200)]
linux: libshare/smb: cache smb_available

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

2 years agolibzfs: zfs_unshare: minor cleanup
наб [Fri, 18 Mar 2022 17:40:13 +0000 (18:40 +0100)]
libzfs: zfs_unshare: minor cleanup

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

2 years agotests: add zfs_unshare_008_pos checking whitespace escaping
наб [Sun, 6 Mar 2022 00:39:54 +0000 (01:39 +0100)]
tests: add zfs_unshare_008_pos checking whitespace escaping

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

2 years agolibshare/nfs: escape mount points when needed
наб [Mon, 28 Feb 2022 19:42:22 +0000 (20:42 +0100)]
libshare/nfs: escape mount points when needed

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

2 years agolinux: libshare/nfs: bsearch() over valid keys
наб [Mon, 28 Feb 2022 16:44:06 +0000 (17:44 +0100)]
linux: libshare/nfs: bsearch() over valid keys

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

2 years agolibzfs: mount: zfs_unshare: don't reallocate mountpoint
наб [Mon, 28 Feb 2022 15:55:16 +0000 (16:55 +0100)]
libzfs: mount: zfs_unshare: don't reallocate mountpoint

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

2 years agoReplace libzfs sharing _nfs() and _smb() APIs with protocol lists
наб [Mon, 28 Feb 2022 15:52:07 +0000 (16:52 +0100)]
Replace libzfs sharing _nfs() and _smb() APIs with protocol lists

With the additional benefit of removing all the _all() functions and
treating a NULL list as "all" ‒ the remaining all function is for all
/datasets/, which is consistent with the rest of the API

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

2 years agoPublish libshare protocols, use enum-based API
наб [Mon, 28 Feb 2022 14:46:25 +0000 (15:46 +0100)]
Publish libshare protocols, use enum-based API

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

2 years agolibshare: delineate obsolete errors
наб [Mon, 28 Feb 2022 14:00:49 +0000 (15:00 +0100)]
libshare: delineate obsolete errors

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

2 years agolibshare: use AVL tree with static data, pass all data in arguments
наб [Mon, 28 Feb 2022 13:50:28 +0000 (14:50 +0100)]
libshare: use AVL tree with static data, pass all data in arguments

This makes it so we don't leak a consistent 64 bytes anymore,
makes the searches simpler and faster, removes /all allocations/
from the driver (quite trivially, since they were absolutely needless),
and makes libshare thread-safe (except, maybe, linux/smb, but that only
does pointer-width loads/stores so it's also mostly fine, except for
leaking smb_shares)

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

2 years agolibshare: interface: {=> const} char *
наб [Mon, 28 Feb 2022 12:37:06 +0000 (13:37 +0100)]
libshare: interface: {=> const} char *

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

2 years agolibshare/smb: cleanup
наб [Mon, 28 Feb 2022 12:13:10 +0000 (13:13 +0100)]
libshare/smb: cleanup

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

2 years agolibshare/nfs: destaticify nfs_lock_fd
наб [Mon, 28 Feb 2022 11:57:47 +0000 (12:57 +0100)]
libshare/nfs: destaticify nfs_lock_fd

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

2 years agofreebsd: libshare/nfs: write directly in translate_opts()
наб [Mon, 28 Feb 2022 11:55:07 +0000 (12:55 +0100)]
freebsd: libshare/nfs: write directly in translate_opts()

This renders it thread-safe

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

2 years agofreebsd: libshare/nfs: constify static const data
наб [Mon, 28 Feb 2022 11:40:14 +0000 (12:40 +0100)]
freebsd: libshare/nfs: constify static const data

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

2 years agoAdd missing AC_MSG_RESULT(no) to configure
Brian Behlendorf [Thu, 12 May 2022 16:12:32 +0000 (09:12 -0700)]
Add missing AC_MSG_RESULT(no) to configure

When the HAVE_IOPS_MKDIR_USERNS check fails output result
as required.

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

2 years agoztest: reduce runtile of zloop.sh in CI
Brian Behlendorf [Thu, 12 May 2022 16:11:29 +0000 (09:11 -0700)]
ztest: reduce runtile of zloop.sh in CI

The zloop.sh script is primarily designed to randomly stress
the DMU and SPA layers.  This can result in some unrealistic
(or even impossible) scenarios being tested which then fail.

Since the longer we run zloop.sh the more likely this is to occur
this commit reduces the runtime.  The intention being that normally
this will result in a clean CI run unless the PR does introduce
serious breaking change.

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

2 years agoAdded a workaround for Linux KASAN builds
Rich Ercolani [Wed, 11 May 2022 20:26:55 +0000 (16:26 -0400)]
Added a workaround for Linux KASAN builds

Linux passes -Wframe-larger-than=1024, which breaks
our build in a number of places with -Werror.

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

2 years agoudev: zvol_id: simplify/modernise
наб [Wed, 11 May 2022 17:58:19 +0000 (19:58 +0200)]
udev: zvol_id: simplify/modernise

zero-alloc, sensibler errors, don't close (or free) before exit.

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

2 years agoztest: O_CLOEXEC ztest_fd_rand
наб [Tue, 3 May 2022 14:58:40 +0000 (16:58 +0200)]
ztest: O_CLOEXEC ztest_fd_rand

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

2 years agoztest: take -B ./path/to/ztest, LD_LIBRARY_PATH=./path/lib:$L_L_P
наб [Tue, 3 May 2022 14:55:14 +0000 (16:55 +0200)]
ztest: take -B ./path/to/ztest, LD_LIBRARY_PATH=./path/lib:$L_L_P

This changes the behaviour of -B from the illumos one which would,
in the example in the manual, take just ./chroots/lenny;
this, however, is more versatile, and scales much better for systems
with ZFS in /usr/local, for example

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

2 years agotests: many_fds: simplify, modernise
наб [Tue, 3 May 2022 13:40:34 +0000 (15:40 +0200)]
tests: many_fds: simplify, modernise

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

2 years agoRemove enable_extended_FILE_stdio()
наб [Tue, 3 May 2022 12:52:53 +0000 (14:52 +0200)]
Remove enable_extended_FILE_stdio()

Even on Illumos it's only available in the 32-bit programming
environment, and, quoth enable_extended_FILE_stdio(3C):
> Historically, 32-bit Solaris applications have been limited to using
> only the file descriptors 0 through 255 with the standard I/O
> functions (see stdio(3C)) in the C library. The extended FILE
> facility allows well-behaved 32-bit applications to use any
> valid file descriptor with the standard I/O functions.
where "well-behaved" means that it
> does not directly access any fields in the FILE structure pointed
> to by the FILE pointer associated with any standard I/O stream,

And the stdio/flush.c implementation reads:
  /*
   * if this is not an internal extended FILE then check
   * if _file is being changed from underneath us.
   * It should not be because if
   * it is then then we lose our ability to guard against
   * silent data corruption.
   */
  if (!iop->__xf_nocheck && bad_fd > -1 && iop->_magic != bad_fd) {
      (void) fprintf(stderr,
          "Application violated extended FILE safety mechanism.\n"
          "Please read the man page for extendedFILE.\nAborting\n");
      abort();
  }

This appears to be an insane workaround for broken implementation with
exposed FILE internals and _file being an u8, both only on non-LP64;
it's shimmed out on all LP64 targets in Illumos,
and we shim it out as well: just get rid of it

This appears to've been originally fixed in illumos-gate
a5f69788de7ac07553de47f7fec8c05a9a94c105 ("PSARC 2006/162 Extended FILE
space for 32-bit Solaris processes", "1085341 32-bit stdio routines
should support file descriptors >255"), which also bears extendedFILE
and enable_extended_FILE_stdio(3C):
  -       unsigned char   _file;  /* UNIX System file descriptor */
  +       unsigned char   _magic; /* Old home of the file descriptor */
  +                               /* Only fileno(3C) can retrieve the
   value now */
and
  +/*
  + * Macros to aid the extended fd FILE work.
  + * This helps isolate the changes to only the 32-bit code
  + * since 64-bit Solaris is not affected by this.
  + */
  +#ifdef  _LP64
  +#define        GET_FD(iop)             ((iop)->_file)
  +#define        SET_FILE(iop, fd)       ((iop)->_file = (fd))
  +#else
  +#define        GET_FD(iop)             \
  +               (((iop)->__extendedfd) ? _file_get(iop) : (iop)->_magic)
  +#define        SET_FILE(iop, fd)       (iop)->_magic = (fd); (iop)->__extendedfd = 0
  +#endif

Also remove the 1k setrlimit(NOFILE) calls: that's the default on Linux,
with 64k on Illumos and 171k on FreeBSD

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

2 years agoautoconf: Fail when __copy_from_user_inatomic is a non-GPL symbol
szubersk [Sat, 7 May 2022 00:53:42 +0000 (00:53 +0000)]
autoconf: Fail when __copy_from_user_inatomic is a non-GPL symbol

A followup to 849c14e04844a2f0e1f7e42886c2cef083563f35
Fix https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1009242

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

2 years agoAdding ZTS test for O_APPEND
Brian Atkinson [Wed, 11 May 2022 15:38:16 +0000 (11:38 -0400)]
Adding ZTS test for O_APPEND

Commit 63b18e4 fixed an issue in zpl_aio_write() to make sure that
kiocb->ki_pos was updated correctly when opening a file with O_APPEND.
Adding a test to verify O_APPEND functionality with lseek can make
sure that all other distros/kernel versions also have the correct
behavior.

Also moved the threadappends_001_pos test into this append test
directory in functional ZTS directory. This way the two append tests
are together for organization purposes.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Brian Atkinson <batkinson@lanl.gov>
Closes #13424

2 years agoRemove constrained path on clean
наб [Tue, 3 May 2022 11:17:50 +0000 (13:17 +0200)]
Remove constrained path on clean

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

2 years agoztest: fix in-tree detection for automatic zdb path
наб [Tue, 3 May 2022 10:22:30 +0000 (12:22 +0200)]
ztest: fix in-tree detection for automatic zdb path

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

2 years agoztest: use $ZDB instead of $ZDB_PATH for zdb
наб [Tue, 3 May 2022 10:15:46 +0000 (12:15 +0200)]
ztest: use $ZDB instead of $ZDB_PATH for zdb

Which actually gets zdb as set in common.sh

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

2 years agoscripts: zpool.sh: cleanup
наб [Fri, 29 Apr 2022 23:21:16 +0000 (01:21 +0200)]
scripts: zpool.sh: cleanup

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

2 years agocppcheck: explicitly exclude kernel code from userspace checks
наб [Mon, 25 Apr 2022 21:27:03 +0000 (23:27 +0200)]
cppcheck: explicitly exclude kernel code from userspace checks

Thus extracting the final shred of utility

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

2 years agoMakefile: respect V=1 for checks
наб [Mon, 11 Apr 2022 22:56:32 +0000 (00:56 +0200)]
Makefile: respect V=1 for checks

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

2 years agoautogen.sh: paper over automake <1.14's lack of %reldir% support
наб [Mon, 11 Apr 2022 21:41:14 +0000 (23:41 +0200)]
autogen.sh: paper over automake <1.14's lack of %reldir% support

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

2 years agocontrib: bash_completion.d: install, fix dist
наб [Sun, 10 Apr 2022 21:10:02 +0000 (23:10 +0200)]
contrib: bash_completion.d: install, fix dist

dist diff:
  -zfs-2.1.99/contrib/bash_completion.d/zfs

install diff:
  +destdir/usr/local/etc/bash_completion.d
  +destdir/usr/local/etc/bash_completion.d/zfs

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

2 years agocmd: move single-file binaries up, extract udev programs to udev/
наб [Sun, 10 Apr 2022 20:47:56 +0000 (22:47 +0200)]
cmd: move single-file binaries up, extract udev programs to udev/

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

2 years agoReplace config/config.awk with simple sed invocation
наб [Sun, 10 Apr 2022 17:00:47 +0000 (19:00 +0200)]
Replace config/config.awk with simple sed invocation

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

2 years agoautoconf: use include directives instead of recursing down test data
наб [Sun, 10 Apr 2022 16:24:48 +0000 (18:24 +0200)]
autoconf: use include directives instead of recursing down test data

We drop /multiple/ seconds off the generation, a dozen off a clean
rebuild, 185 files, and trivialise the distribution,
which can now be trivially generated via the provided snippets

Dist diff:
  -zfs-2.1.99/tests/zfs-tests/tests/functional/pam/utilities.kshlib
  +zfs-2.1.99/tests/zfs-tests/tests/functional/pam/utilities.kshlib.in

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

2 years agoautoconf: use include directives instead of recursing down tests (mostly)
наб [Sun, 10 Apr 2022 00:46:19 +0000 (02:46 +0200)]
autoconf: use include directives instead of recursing down tests (mostly)

Only down to tests/zfs-tests/tests, but pull out C programs into the
main Makefile ‒ this means we get correct dependency tracking for all
programs (and parallelise across them)

dist diff:
  -zfs-2.1.99/tests/zfs-tests/tests/stress/
  -zfs-2.1.99/tests/zfs-tests/tests/stress/Makefile.am
  -zfs-2.1.99/tests/zfs-tests/tests/stress/Makefile.in

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

2 years agoautoconf: use include directives instead of recursing down etc
наб [Sat, 9 Apr 2022 23:19:15 +0000 (01:19 +0200)]
autoconf: use include directives instead of recursing down etc

dist diff:
  -zfs-2.1.99/etc/systemd/system/50-zfs.preset.in
  +zfs-2.1.99/etc/systemd/system/50-zfs.preset

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

2 years agoautoconf: use include directives instead of recursing down contrib
наб [Sat, 9 Apr 2022 22:16:59 +0000 (00:16 +0200)]
autoconf: use include directives instead of recursing down contrib

Also make the pyzfs build actually out-of-tree and quiet by default

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Co-authored-by: Rapptz <rapptz@gmail.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13316

2 years agoautoconf: use include directives instead of recursing down udev
наб [Sat, 9 Apr 2022 18:05:18 +0000 (20:05 +0200)]
autoconf: use include directives instead of recursing down udev

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

2 years agoautoconf: use include directives instead of recursing down rpm
наб [Sat, 9 Apr 2022 17:44:40 +0000 (19:44 +0200)]
autoconf: use include directives instead of recursing down rpm

Also simplify .gitignore

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

2 years agoMove test-runner.1 into top-level man/
наб [Sat, 9 Apr 2022 17:20:52 +0000 (19:20 +0200)]
Move test-runner.1 into top-level man/

dist delta:
  +zfs-2.1.99/man/man1/test-runner.1
  -zfs-2.1.99/tests/test-runner/man/
  -zfs-2.1.99/tests/test-runner/man/test-runner.1

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

2 years agoautoconf: use include directives instead of recursing down man
наб [Sat, 9 Apr 2022 17:19:09 +0000 (19:19 +0200)]
autoconf: use include directives instead of recursing down man

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

2 years agoautoconf: use include directives instead of recursing down scripts
наб [Sat, 9 Apr 2022 16:35:53 +0000 (18:35 +0200)]
autoconf: use include directives instead of recursing down scripts

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

2 years agoautoconf: single-step includes
наб [Sat, 9 Apr 2022 12:37:22 +0000 (14:37 +0200)]
autoconf: single-step includes

Still descend, but only once: we get a lot of mileage out of nodist_

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

2 years agoautoconf: use include directives instead of recursing down cmd
наб [Sat, 9 Apr 2022 02:09:55 +0000 (04:09 +0200)]
autoconf: use include directives instead of recursing down cmd

No installation diff, dist lost
  -zfs-2.1.99/cmd/fsck_zfs/fsck.zfs
which was distributed erroneously, since it's generated

Also clean gitrev on clean

Also add -e 'any possible bashisms' to default checkbashisms flags,
and fully parallelise it and shellcheck, and it works out-of-tree, too

Also align the Release in the dist META file correctly

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

2 years agocmd: zvol_id: don't build with -fno-stack-protector anymore
наб [Fri, 8 Apr 2022 01:58:14 +0000 (03:58 +0200)]
cmd: zvol_id: don't build with -fno-stack-protector anymore

 #569 was opened in 2012 and closed in 2015;
if the issue was still there we'd presumably've seen it?

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

2 years agoautoconf: use include directives instead of recursing down lib
наб [Thu, 7 Apr 2022 23:07:08 +0000 (01:07 +0200)]
autoconf: use include directives instead of recursing down lib

As a bonus, this also adds zfs-mount-generator (previously undescended
down) and libzstd (not included) to CppCheck

As a bonus bonus, abigail rules work out-of-tree, too

Against current trunk:
  $ diff -U0 ./destdir.listing ~/store/code/zfs/destdir.listing
  -destdir/usr/local/include/libspl/sscanf.h

  $ diff --color -U0 ./zfs-2.1.99.tar.gz.listing ../oot/zfs-2.1.99.tar.gz.listing | grep -v @@ | grep -v /Makefile
  -zfs-2.1.99/config/Abigail.am
  -zfs-2.1.99/lib/libspl/include/util/
  -zfs-2.1.99/lib/libspl/include/util/sscanf.h

  $ diff --color -U0 ./zfs-2.1.99.tar.gz.listing ../oot/zfs-2.1.99.tar.gz.listing | grep -v @@ | grep /Makefile
  -zfs-2.1.99/lib/libavl/Makefile.in
  -zfs-2.1.99/lib/libefi/Makefile.in
  -zfs-2.1.99/lib/libicp/Makefile.in
  -zfs-2.1.99/lib/libnvpair/Makefile.in
  -zfs-2.1.99/lib/libshare/Makefile.in
  -zfs-2.1.99/lib/libspl/include/Makefile.in
  -zfs-2.1.99/lib/libspl/include/os/freebsd/Makefile.am
  -zfs-2.1.99/lib/libspl/include/os/freebsd/Makefile.in
  -zfs-2.1.99/lib/libspl/include/os/freebsd/sys/Makefile.am
  -zfs-2.1.99/lib/libspl/include/os/freebsd/sys/Makefile.in
  -zfs-2.1.99/lib/libspl/include/os/linux/Makefile.am
  -zfs-2.1.99/lib/libspl/include/os/linux/Makefile.in
  -zfs-2.1.99/lib/libspl/include/os/linux/sys/Makefile.am
  -zfs-2.1.99/lib/libspl/include/os/linux/sys/Makefile.in
  -zfs-2.1.99/lib/libspl/include/os/Makefile.am
  -zfs-2.1.99/lib/libspl/include/os/Makefile.in
  -zfs-2.1.99/lib/libspl/include/rpc/Makefile.am
  -zfs-2.1.99/lib/libspl/include/rpc/Makefile.in
  -zfs-2.1.99/lib/libspl/include/sys/dktp/Makefile.am
  -zfs-2.1.99/lib/libspl/include/sys/dktp/Makefile.in
  -zfs-2.1.99/lib/libspl/include/sys/Makefile.am
  -zfs-2.1.99/lib/libspl/include/sys/Makefile.in
  -zfs-2.1.99/lib/libspl/include/util/Makefile.am
  -zfs-2.1.99/lib/libspl/include/util/Makefile.in
  -zfs-2.1.99/lib/libspl/Makefile.in
  -zfs-2.1.99/lib/libtpool/Makefile.in
  -zfs-2.1.99/lib/libunicode/Makefile.in
  -zfs-2.1.99/lib/libuutil/Makefile.in
  -zfs-2.1.99/lib/libzfsbootenv/Makefile.in
  -zfs-2.1.99/lib/libzfs_core/Makefile.in
  -zfs-2.1.99/lib/libzfs/Makefile.in
  -zfs-2.1.99/lib/libzpool/Makefile.in
  -zfs-2.1.99/lib/libzstd/Makefile.in
  -zfs-2.1.99/lib/libzutil/Makefile.in
  -zfs-2.1.99/lib/Makefile.in

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

2 years agolibzfs: pool: fix false-positives -Wmaybe-uninitialised
наб [Thu, 7 Apr 2022 20:49:22 +0000 (22:49 +0200)]
libzfs: pool: fix false-positives -Wmaybe-uninitialised

As noted by gcc (Debian 10.2.1-6) 10.2.1 20210110

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

2 years agomodule: Makefile: cppcheck: zfs_config.h lives in builddir
наб [Thu, 7 Apr 2022 00:22:37 +0000 (02:22 +0200)]
module: Makefile: cppcheck: zfs_config.h lives in builddir

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

2 years agoconfig: user: drop ZONENAME, avoid lying about being Linux-only
наб [Wed, 6 Apr 2022 22:41:46 +0000 (00:41 +0200)]
config: user: drop ZONENAME, avoid lying about being Linux-only

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

2 years agolibspl: include: remove [util/]sscanf.h
наб [Wed, 6 Apr 2022 01:12:33 +0000 (03:12 +0200)]
libspl: include: remove [util/]sscanf.h

Unused, empty, installs in a weird location

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

2 years agocopy-builtin: add hooks with sed/>>
наб [Tue, 5 Apr 2022 23:34:25 +0000 (01:34 +0200)]
copy-builtin: add hooks with sed/>>

The order in fs/Makefile doesn't matter,
the order in fs/Kconfig is preserved (ext2 is included as the first
thing in the first if BUILD block, and only once), but I don't think it
matters much either, realistically

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

2 years agoautogen.sh: explicitly build its containing directory
наб [Tue, 5 Apr 2022 22:36:09 +0000 (00:36 +0200)]
autogen.sh: explicitly build its containing directory

No changes in currently-accepted usages (no-argument), but allows
  /src/path/autogen.sh && /src/path/configure
for simpler out-of-tree builds

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

2 years agoRemove compat spl-x.y.z from the distribution
наб [Tue, 5 Apr 2022 22:20:16 +0000 (00:20 +0200)]
Remove compat spl-x.y.z from the distribution

This was added in 93ce2b4ca5a40c41ac945cd3aaf4a4a22bb751e1 ("Update
build system and packaging"), which merged the SPL and ZFS trees,
and included in 0.8.0; "the next major release" was 2.0.0

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

2 years agoMakefile: zfs-tests lives in srcdir; zfs-tests: accept common.sh path
наб [Tue, 5 Apr 2022 22:15:45 +0000 (00:15 +0200)]
Makefile: zfs-tests lives in srcdir; zfs-tests: accept common.sh path

This fixes out-of-tree builds

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

2 years agoWorkaround broken VDEV_UPATH
Rich Ercolani [Tue, 10 May 2022 17:14:07 +0000 (13:14 -0400)]
Workaround broken VDEV_UPATH

Sometimes, for reasons I haven't looked into yet, VDEV_UPATH
gets set to /dev/(null), breaking all these scripts.

It'd be nice to have a fallback case to avoid total failure.

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

2 years agoAdd workaround for broken Linux pipes
Rich Ercolani [Mon, 9 May 2022 23:33:55 +0000 (19:33 -0400)]
Add workaround for broken Linux pipes

Linux has an unresolved hang if you resize a pipe with bytes
in it.

Since there's no obvious way to detect this happening, added a
workaround to disable resizing the pipe buffer if you set an
environment variable.

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

2 years agoabd_os: remove redundant refcount creation for abd_children
hping [Mon, 9 May 2022 23:30:16 +0000 (07:30 +0800)]
abd_os: remove redundant refcount creation for abd_children

Refcount creation for abd_zero_scatter->abd_children is redundant in
abd_alloc_zero_scatter, as it has been done in abd_init_struct.

In addition, abd_children is undefined when ZFS_DEBUG is disabled, the
reference of abd_children in abd_alloc_zero_scatter breaks build of
libzpool when ZFS_DEBUG is disabled.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Signed-off-by: Ping Huang <huangping@smartx.com>
Closes #13429

2 years agoman: zpool-import.8: -d -or -c
наб [Mon, 9 May 2022 23:03:17 +0000 (01:03 +0200)]
man: zpool-import.8: -d -or -c

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

2 years agoFix functions without a prototype
Aidan Harris [Fri, 6 May 2022 18:57:37 +0000 (18:57 +0000)]
Fix functions without a prototype

clang-15 emits the following error message for functions without
a prototype:

fs/zfs/os/linux/spl/spl-kmem-cache.c:1423:27: error:
  a function declaration without a prototype is deprecated
  in all versions of C [-Werror,-Wstrict-prototypes]

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Aidan Harris <me@aidanharr.is>
Closes #13421

2 years agozpool: guard vs_noalloc and vs_pspace with VDEV_STAT_VALID()
наб [Thu, 5 May 2022 16:45:12 +0000 (18:45 +0200)]
zpool: guard vs_noalloc and vs_pspace with VDEV_STAT_VALID()

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

2 years agoCorrected edge case in uncompressed ARC->L2ARC handling
Rich Ercolani [Wed, 4 May 2022 18:59:30 +0000 (14:59 -0400)]
Corrected edge case in uncompressed ARC->L2ARC handling

I genuinely don't know why this didn't come up before,
but adding the LZ4 early abort pointed out this flaw,
in which we're allocating a buffer of one size, and
then telling the compressor that we're handing it buffers
of a different size, which may be Very Different - say,
allocating 512b and then telling it the inputs are 128k.

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

2 years agoFreeBSD: use zero_region instead of allocating a dedicated page
Mateusz Guzik [Wed, 4 May 2022 18:46:37 +0000 (20:46 +0200)]
FreeBSD: use zero_region instead of allocating a dedicated page

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Closes #13406

2 years agoFix incorrect use of unit prefix names in man pages
WHR [Tue, 3 May 2022 12:07:04 +0000 (20:07 +0800)]
Fix incorrect use of unit prefix names in man pages

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com>
Signed-off-by: WHR <msl0000023508@gmail.com>
Closes #13363

2 years agoImprove mg_aliquot math
Alexander Motin [Wed, 4 May 2022 18:33:42 +0000 (14:33 -0400)]
Improve mg_aliquot math

When calculating mg_aliquot alike to #12046 use number of unique data
disks in the vdev, not the total number of children vdev.  Increase
default value of the tunable from 512KB to 1MB to compensate.

Before this change each disk in striped pool was getting 512KB of
sequential data, in 2-wide mirror -- 1MB, in 3-wide RAIDZ1 -- 768KB.
After this change in all the cases each disk should get 1MB.

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

2 years agoReduce dbuf_find() lock contention
Brian Behlendorf [Wed, 4 May 2022 18:17:29 +0000 (11:17 -0700)]
Reduce dbuf_find() lock contention

Holding a dbuf is a common operation which can become highly contended
in dbuf_find() when acquiring the dbuf hash mutex.  This is particularly
true on Linux when reading/writing volumes since by default up to 32
threads from the zvol_taskq may be taking a hold of the same dbuf.
This should also be observable on FreeBSD as long as there are enough
processes accessing the volume concurrently.

This is further aggregrated by the fact that only the block id will
be unique when calculating the dbuf hash for a single volume.  The
objset id, object id, and level will be the same for data blocks.
This has been observed to result in a somehwat less than uniform hash
distribution and a longer than expected max hash chain depth (~20)
on a large memory system (256 GB) using volumes.

This commit improves the siutation by switching the hash mutex to
an rwlock to allow concurrent lookups, and increasing DBUF_RWLOCKS
from 2048 to 8192 to further reduce the odds of a hash collision.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #13405

2 years agoSpeed up WB_SYNC_NONE when a WB_SYNC_ALL occurs simultaneously
Shaan Nobee [Tue, 3 May 2022 20:23:26 +0000 (00:23 +0400)]
Speed up WB_SYNC_NONE when a WB_SYNC_ALL occurs simultaneously

Page writebacks with WB_SYNC_NONE can take several seconds to complete
since they wait for the transaction group to close before being
committed. This is usually not a problem since the caller does not
need to wait. However, if we're simultaneously doing a writeback
with WB_SYNC_ALL (e.g via msync), the latter can block for several
seconds (up to zfs_txg_timeout) due to the active WB_SYNC_NONE
writeback since it needs to wait for the transaction to complete
and the PG_writeback bit to be cleared.

This commit deals with 2 cases:

- No page writeback is active. A WB_SYNC_ALL page writeback starts
  and even completes. But when it's about to check if the PG_writeback
  bit has been cleared, another writeback with WB_SYNC_NONE starts.
  The sync page writeback ends up waiting for the non-sync page
  writeback to complete.

- A page writeback with WB_SYNC_NONE is already active when a
  WB_SYNC_ALL writeback starts. The WB_SYNC_ALL writeback ends up
  waiting for the WB_SYNC_NONE writeback.

The fix works by carefully keeping track of active sync/non-sync
writebacks and committing when beneficial.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Shaan Nobee <sniper111@gmail.com>
Closes #12662
Closes #12790

2 years agoFreeBSD: Clean up the use of ioflags
Pawel Jakub Dawidek [Mon, 2 May 2022 23:26:28 +0000 (16:26 -0700)]
FreeBSD: Clean up the use of ioflags

- Prefer O_* flags over F* flags that mostly mirror O_* flags anyway,
  but O_* flags seem to be preferred.
- Simplify the code as all the F*SYNC flags were defined as FFSYNC flag.
- Don't define FRSYNC flag, so we don't generate unnecessary ZIL commits.
- Remove EXCL define, FreeBSD ignores the excl argument for zfs_create()
  anyway.

Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Pawel Jakub Dawidek <pawel@dawidek.net>
Closes #13400

2 years agoAdd missing replay entry in zvol_replay_vector for TX_SETSAXATTR
Jitendra Patidar [Mon, 2 May 2022 18:01:26 +0000 (23:31 +0530)]
Add missing replay entry in zvol_replay_vector for TX_SETSAXATTR

Commit 361a7e8 (log xattr=sa create/remove/update to ZIL) introduced a
TX_SETSAXATTR, but missed to add a corresponding entry in
zvol_replay_vector. Adding a missing replay entry in zvol_replay_vector.

Reviewed-by: Christian Schwarz <christian.schwarz@nutanix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jitendra Patidar <jitendra.patidar@nutanix.com>
Closes #13396
Closes #13395

2 years agoSilence unused-but-set-variable warnings
Brian Behlendorf [Fri, 29 Apr 2022 21:21:11 +0000 (14:21 -0700)]
Silence unused-but-set-variable warnings

Clang 13.0.0 added support for `Wunused-but-set-parameter` and
`-Wunused-but-set-variable` which correctly detects two unused
variables in zstd resulting in a build failure.  This commit
annotates these instances accordingly.

  https://releases.llvm.org/13.0.1/tools/clang/docs/ReleaseNotes.html#id6

In FSE_createCTable(), malloc() is intentionally defined as NULL when
compiled in the kernel so the variable is unused.

  zstd/lib/compress/fse_compress.c:307:12: error: variable 'size'
  set but not used [-Werror,-Wunused-but-set-variable]

Additionally, in ZSTD_seqDecompressedSize() the assert is compiled
out similarly resulting in an unused variable.

  zstd/lib/compress/zstd_compress_superblock.c:412:12: error: variable
  'litLengthSum' set but not used [-Werror,-Wunused-but-set-variable]

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

2 years agoDefault zfs_max_recordsize to 16M
Rich Ercolani [Thu, 28 Apr 2022 22:12:24 +0000 (18:12 -0400)]
Default zfs_max_recordsize to 16M

Increase the default allowed maximum recordsize from 1M to 16M.
As described in the zfs(4) man page, there are significant costs
which need to be considered before using very large blocks.
However, there are scenarios where they make good sense and
it should no longer be necessary to artificially restrict their
use behind a module option.

Note that for 32-bit platforms we continue to leave this
restriction in place due to the limited virtual address space
available (256-512MB).  On these systems only a handful
of blocks could be cached at any one time severely impacting
performance and potentially stability.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #12830
Closes #13302

2 years agoFix O_APPEND for Linux 3.15 and older kernels
Brian Behlendorf [Wed, 27 Apr 2022 19:56:17 +0000 (12:56 -0700)]
Fix O_APPEND for Linux 3.15 and older kernels

When using a Linux kernel which predates the iov_iter interface the
O_APPEND flag should be applied in zpl_aio_write() via the call to
generic_write_checks().  The updated pos variable  was incorrectly
ignored resulting in the current offset being used.

This issue should only realistically impact the RHEL/CentOS 7.x
kernels which are based on Linux 3.10.

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

2 years agoLinux 5.18 compat: replace __set_page_dirty_nobuffers
Satadru Pramanik [Wed, 27 Apr 2022 19:54:17 +0000 (15:54 -0400)]
Linux 5.18 compat: replace __set_page_dirty_nobuffers

Replace __set_page_dirty_nobuffers with filemap_dirty_folio.

Upstream-commit: 6b1f86f8e9c7f9de7ca1cb987b2cf25e99b1ae3a
("Merge tag 'folio-5.18b' of
git://git.infradead.org/users/willy/pagecache ")

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Authored-by: Satadru Pramanik <satadru@gmail.com>
Signed-off-by: Satadru Pramanik <satadru@gmail.com>
Closes #13325
Closes #13380

2 years agozfs: holds: dequadratify
наб [Sat, 23 Apr 2022 17:21:09 +0000 (19:21 +0200)]
zfs: holds: dequadratify

Before:
  15  0m0.177s
  30  0m0.653s
  45  0m1.289s
  60  0m2.129s
  75  0m3.264s
  90  0m4.397s
  100 0m5.996s
  117 0m8.552s

After:
  30  0m0.053s
  117 0m0.125s

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

2 years agozfs: holds: general cleanup
наб [Sat, 23 Apr 2022 17:19:41 +0000 (19:19 +0200)]
zfs: holds: general cleanup

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

2 years agoPPC get_user workaround
Damian Szuberski [Tue, 26 Apr 2022 17:52:40 +0000 (03:52 +1000)]
PPC get_user workaround

Linux 5.12 PPC 5.12 get_user() and __copy_from_user_inatomic()
inline helpers very indirectly include a reference to the GPL'd
array mmu_feature_keys[] and fails to build. Workaround this by
using copy_from_user() and throwing EFAULT for any calls to
__copy_from_user_inatomic(). This is a workaround until a fix
for Linux commit 7613f5a66becfd0e43a0f34de8518695888f5458
"powerpc/64s/kuap: Use mmu_has_feature()" is fully addressed.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Authored-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes #11958
Closes #12590
Closes #13367

2 years agoautoconf: Pretend `CONFIG_MODULES` is always on
Damian Szuberski [Tue, 26 Apr 2022 17:47:09 +0000 (03:47 +1000)]
autoconf: Pretend `CONFIG_MODULES` is always on

- Unconditionally inject `CONFIG_MODULES` make variable
  and `#define CONFIG_MODULES` to Kbuild in `ZFS_LINUX_COMPILE`
  autoconf function to emulate loadable kernel modules support.
  This allows OpenZFS to perform Linux checks despite
  `CONFIG_MODULES=n` in the actual Linux config.

- Add `ZFS_AC_KERNEL_CONFIG_MODULES` check which encompasses
  the logic from `ZFS_AC_KERNEL_TEST_MODULE` with additional
  diagnostic messages to the user

- Removed `ZFS_AC_KERNEL_TEST_MODULE` as it merely duplicates
  every check in `ZFS_AC_KERNEL_CONFIG_DEFINED`

- Moved `ZFS_AC_MODULE_SYMVERS` after `ZFS_AC_KERNEL_CONFIG_DEFINED`
  so the user has a chance to see the proper diagnostic from the
  steps before.

A workaround for Linux's

```
commit 3e3005df73b535cb849cf4ec8075d6aa3c460f68
Author: Masahiro Yamada <masahiroy@kernel.org>
Date:   Wed Mar 31 22:38:03 2021 +0900

kbuild: unify modules(_install) for in-tree and external modules

If you attempt to build or install modules ('make modules(_install)'
with CONFIG_MODULES disabled, you will get a clear error message, but
nothing for external module builds.

Factor out the modules and modules_install rules into the common part,
so you will get the same error message when you try to build external
modules with CONFIG_MODULES=n.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
```

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

2 years agoImprove log spacemap load time
Alexander Motin [Tue, 26 Apr 2022 17:44:21 +0000 (13:44 -0400)]
Improve log spacemap load time

Previous flushing algorithm limited only total number of log blocks to
the minimum of 256K and 4x number of metaslabs in the pool.  As result,
system with 1500 disks with 1000 metaslabs each, touching several new
metaslabs each TXG could grow spacemap log to huge size without much
benefits.  We've observed one of such systems importing pool for about
45 minutes.

This patch improves the situation from five sides:
 - By limiting maximum period for each metaslab to be flushed to 1000
TXGs, that effectively limits maximum number of per-TXG spacemap logs
to load to the same number.
 - By making flushing more smooth via accounting number of metaslabs
that were touched after the last flush and actually need another flush,
not just ms_unflushed_txg bump.
 - By applying zfs_unflushed_log_block_pct to the number of metaslabs
that were touched after the last flush, not all metaslabs in the pool.
 - By aggressively prefetching per-TXG spacemap logs up to 16 TXGs in
advance, making log spacemap load process for wide HDD pool CPU-bound,
accelerating it by many times.
 - By reducing zfs_unflushed_log_block_max from 256K to 128K, reducing
single-threaded by nature log processing time from ~10 to ~5 minutes.

As further optimization we could skip bumping ms_unflushed_txg for
metaslabs not touched since the last flush, but that would be an
incompatible change, requiring new pool feature.

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

2 years agoImprove zpool status output, list all affected datasets
George Amanakis [Tue, 26 Apr 2022 00:25:42 +0000 (02:25 +0200)]
Improve zpool status output, list all affected datasets

Currently, determining which datasets are affected by corruption is
a manual process.

The primary difficulty in reporting the list of affected snapshots is
that since the error was initially found, the snapshot where the error
originally occurred in, may have been deleted. To solve this issue, we
add the ID of the head dataset of the original snapshot which the error
was detected in, to the stored error report. Then any time a filesystem
is deleted, the errors associated with it are deleted as well. Any time
a clone promote occurs, we modify reports associated with the original
head to refer to the new head. The stored error reports are identified
by this head ID, the birth time of the block which the error occurred
in, as well as some information about the error itself are also stored.

Once this information is stored, we can find the set of datasets
affected by an error by walking back the list of snapshots in the given
head until we find one with the appropriate birth txg, and then traverse
through the snapshots of the clone family, terminating a branch if the
block was replaced in a given snapshot. Then we report this information
back to libzfs, and to the zpool status command, where it is displayed
as follows:

 pool: test
 state: ONLINE
status: One or more devices has experienced an error resulting in data
        corruption.  Applications may be affected.
action: Restore the file in question if possible.  Otherwise restore the
        entire pool from backup.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-8A
  scan: scrub repaired 0B in 00:00:00 with 800 errors on Fri Dec  3
08:27:57 2021
config:

        NAME        STATE     READ WRITE CKSUM
        test        ONLINE       0     0     0
          sdb       ONLINE       0     0 1.58K

errors: Permanent errors have been detected in the following files:

        test@1:/test.0.0
        /test/test.0.0
        /test/1clone/test.0.0

A new feature flag is introduced to mark the presence of this change, as
well as promotion and backwards compatibility logic. This is an updated
version of #9175. Rebase required fixing the tests, updating the ABI of
libzfs, updating the man pages, fixing bugs, fixing the error returns,
and updating the old on-disk error logs to the new format when
activating the feature.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Co-authored-by: TulsiJain <tulsi.jain@delphix.com>
Signed-off-by: George Amanakis <gamanakis@gmail.com>
Closes #9175
Closes #12812

2 years agotests: cli_user: zfs_001_neg: print the problematic lines
наб [Fri, 22 Apr 2022 18:59:51 +0000 (20:59 +0200)]
tests: cli_user: zfs_001_neg: print the problematic lines

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

2 years agoman: zfs-send.8: fix -X synopses and description
наб [Thu, 24 Mar 2022 20:07:07 +0000 (21:07 +0100)]
man: zfs-send.8: fix -X synopses and description

Also clean up the horrendously verbose -X handling in zfs_main()

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

2 years agozvol_wait: Ignore locked zvols
Richard Laager [Fri, 22 Apr 2022 22:37:03 +0000 (17:37 -0500)]
zvol_wait: Ignore locked zvols

"When an encrypted zvol is locked the zfs-volume-wait service does not
start.  The /sbin/zvol_wait should not wait for links when the volume
has property keystatus=unavailable."
-- https://bugs.launchpad.net/ubuntu/+source/zfs-linux/+bug/1888405

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com>
Thanks: James Dingwall <james-launchpad@dingwall.me.uk>
Signed-off-by: Richard Laager <rlaager@wiktel.com>
Closes #10662

2 years agoLinux 5.18 compat: kobj_type.default_attrs replaced with default_groups
наб [Thu, 21 Apr 2022 14:27:15 +0000 (16:27 +0200)]
Linux 5.18 compat: kobj_type.default_attrs replaced with default_groups

Upstream-commit: cdb4f26a63c391317e335e6e683a614358e70aeb ("kobject:
 kobj_type: remove default_attrs")
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13357

2 years agolinux: module: zfs: sysfs: constify types and attrs
наб [Thu, 21 Apr 2022 12:27:51 +0000 (14:27 +0200)]
linux: module: zfs: sysfs: constify types and attrs

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

2 years agoscripts: zfs.sh: explicitly unload all modules via rmmod
наб [Thu, 21 Apr 2022 11:32:06 +0000 (13:32 +0200)]
scripts: zfs.sh: explicitly unload all modules via rmmod

modprobe -r only works for depmodded modules, but this also means we
have to re-iterate legacy modules, and in the right order

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

2 years agoscripts: zfs.sh: explicitly ignore unloaded modules when unloading
наб [Thu, 21 Apr 2022 11:29:12 +0000 (13:29 +0200)]
scripts: zfs.sh: explicitly ignore unloaded modules when unloading

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

2 years agoStrengthen Linux kernel capabilities detection
Damian Szuberski [Thu, 21 Apr 2022 16:37:11 +0000 (18:37 +0200)]
Strengthen Linux kernel capabilities detection

- Add `CONFIG_BLOCK` Linux config requirement to
  `ZFS_AC_KERNEL_CONFIG_DEFINED`. OpenZFS won't compile without
  that block device support due to large amount of functional
  dependencies on it.

- Remove dependency on `groups_alloc()` in
  `ZFS_AC_KERNEL_SRC_GROUP_INFO_GID` to circumvent the missing stub
  in Linux 4.X kernel headers.

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

2 years agocontrib: dracut: remove getargbool polyfill
наб [Tue, 5 Apr 2022 00:56:57 +0000 (02:56 +0200)]
contrib: dracut: remove getargbool polyfill

It was originally released in dracut 008 in February 2011;
we can probably drop it now

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

2 years agoAdd dracut.zfs.7
наб [Mon, 4 Apr 2022 23:14:49 +0000 (01:14 +0200)]
Add dracut.zfs.7

Thorough documentation with a dracut.bootup(7)-style flowchart,
dracut.cmdline(7)-style cmdline listing,
and per-file docs like the old README

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

2 years agocontrib: dracut: zfs-needshutdown: don't list
наб [Mon, 4 Apr 2022 23:09:11 +0000 (01:09 +0200)]
contrib: dracut: zfs-needshutdown: don't list

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

2 years agocontrib: dracut: zfs-{rollback,snapshot}-bootfs: order after key loading
наб [Mon, 4 Apr 2022 22:19:38 +0000 (00:19 +0200)]
contrib: dracut: zfs-{rollback,snapshot}-bootfs: order after key loading

This fixes at least one race I got with an encrypted root

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

2 years agocontrib: dracut: don't require essentials to be under the same encroot
наб [Mon, 4 Apr 2022 21:39:18 +0000 (23:39 +0200)]
contrib: dracut: don't require essentials to be under the same encroot

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

2 years agocontrib: dracut: inline single-use import_pool, move single-use ask_for_password
наб [Mon, 4 Apr 2022 21:24:29 +0000 (23:24 +0200)]
contrib: dracut: inline single-use import_pool, move single-use ask_for_password

Also don't set ROOTFS_MOUNTED; the final mention was removed in dracut
011 from July 2011

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

2 years agocontrib: dracut: zfs-lib: remove find_bootfs
наб [Mon, 4 Apr 2022 21:16:59 +0000 (23:16 +0200)]
contrib: dracut: zfs-lib: remove find_bootfs

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

2 years agocontrib: dracut: zfs-lib: simplify ask_for_password
наб [Mon, 4 Apr 2022 20:57:35 +0000 (22:57 +0200)]
contrib: dracut: zfs-lib: simplify ask_for_password

The only user is mount-zfs.sh (non-systemd systems),
so reduce it to what it needs

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

2 years agocontrib; dracut: flatten zfs-load-key, simplify zfs-env-bootfs
наб [Mon, 4 Apr 2022 20:52:43 +0000 (22:52 +0200)]
contrib; dracut: flatten zfs-load-key, simplify zfs-env-bootfs

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

2 years agocontrib; dracut: centralise root= parsing, actually support root=s
наб [Mon, 4 Apr 2022 20:45:58 +0000 (22:45 +0200)]
contrib; dracut: centralise root= parsing, actually support root=s

So far, everything parsed root= manually, which meant that while
zfs-parse.sh was updated, and supposedly supported + -> ' ' conversion,
it meant nothing

Instead, centralise parsing, and allow:
  root=
  root=zfs
  root=zfs:
  root=zfs:AUTO

  root=ZFS=data/set
  root=zfs:data/set
  root=zfs:ZFS=data/set (as a side-effect; allowed but undocumented)

  rootfstype=zfs AND root=data/set <=> root=data/set
  rootfstype=zfs AND root=         <=> root=zfs:AUTO

So rootfstype=zfs /also/ behaves as expected, and + decoding works

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

2 years agocontrib: dracut: parse-zfs: stop pretending we support FILESYSTEM=
наб [Mon, 4 Apr 2022 18:59:53 +0000 (20:59 +0200)]
contrib: dracut: parse-zfs: stop pretending we support FILESYSTEM=

It was added in the original ae26d0465a ("Add dracut support") commit
in 2011, and was then broken a bit later with the advent of
dracut-zfs-generator, or maybe earlier as part of other churn

Either way, it's broken, and has been in 2.0+ as well, and no-one
complained. Stop pretending we support it at all

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

2 years agocontrib: dracut: parse-zfs: drop initqueue-finished for i/f
наб [Mon, 4 Apr 2022 16:38:07 +0000 (18:38 +0200)]
contrib: dracut: parse-zfs: drop initqueue-finished for i/f

The switch was released in dracut 009 in March 2011,
we can safely get rid of the compatibility hook

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