Author: mmacy
Date: Fri Sep 18 23:21:24 2020
New Revision: 365894
URL: https://svnweb.freebsd.org/changeset/base/365894

Log:
  MFV 2.0-rc2
  
  - Fixes divide by zero for unusual hz
  - remove cryptodev dependency

Added:
  head/sys/contrib/openzfs/cmd/zgenhostid/.gitignore
     - copied unchanged from r365893, 
vendor-sys/openzfs/dist/cmd/zgenhostid/.gitignore
  head/sys/contrib/openzfs/cmd/zgenhostid/zgenhostid.c
     - copied unchanged from r365893, 
vendor-sys/openzfs/dist/cmd/zgenhostid/zgenhostid.c
  head/sys/contrib/openzfs/include/libzfsbootenv.h
     - copied unchanged from r365893, 
vendor-sys/openzfs/dist/include/libzfsbootenv.h
  head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_bootenv_os.h
     - copied unchanged from r365893, 
vendor-sys/openzfs/dist/include/os/freebsd/zfs/sys/zfs_bootenv_os.h
  head/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_bootenv_os.h
     - copied unchanged from r365893, 
vendor-sys/openzfs/dist/include/os/linux/zfs/sys/zfs_bootenv_os.h
  head/sys/contrib/openzfs/include/sys/zfs_bootenv.h
     - copied unchanged from r365893, 
vendor-sys/openzfs/dist/include/sys/zfs_bootenv.h
  head/sys/contrib/openzfs/lib/libzfsbootenv/
     - copied from r365893, vendor-sys/openzfs/dist/lib/libzfsbootenv/
  
head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/.gitignore
     - copied unchanged from r365893, 
vendor-sys/openzfs/dist/tests/zfs-tests/tests/functional/cli_root/zpool_events/.gitignore
  
head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/ereports.c
     - copied unchanged from r365893, 
vendor-sys/openzfs/dist/tests/zfs-tests/tests/functional/cli_root/zpool_events/ereports.c
  
head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh
     - copied unchanged from r365893, 
vendor-sys/openzfs/dist/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh
Deleted:
  head/sys/contrib/openzfs/cmd/zgenhostid/zgenhostid
Modified:
  head/cddl/lib/libzpool/Makefile
  head/sys/contrib/openzfs/META
  head/sys/contrib/openzfs/cmd/mount_zfs/mount_zfs.c
  head/sys/contrib/openzfs/cmd/zdb/zdb.c
  head/sys/contrib/openzfs/cmd/zfs/zfs_main.c
  head/sys/contrib/openzfs/cmd/zgenhostid/Makefile.am
  head/sys/contrib/openzfs/cmd/zpool/zpool_main.c
  head/sys/contrib/openzfs/config/deb.am
  head/sys/contrib/openzfs/config/find_system_library.m4
  head/sys/contrib/openzfs/config/rpm.am
  head/sys/contrib/openzfs/config/zfs-build.m4
  head/sys/contrib/openzfs/configure.ac
  head/sys/contrib/openzfs/contrib/dracut/90zfs/module-setup.sh.in
  head/sys/contrib/openzfs/contrib/dracut/90zfs/parse-zfs.sh.in
  head/sys/contrib/openzfs/include/Makefile.am
  head/sys/contrib/openzfs/include/libzfs.h
  head/sys/contrib/openzfs/include/libzfs_core.h
  head/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h
  head/sys/contrib/openzfs/include/os/freebsd/spl/sys/condvar.h
  head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/Makefile.am
  head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_context_os.h
  head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vfsops_os.h
  head/sys/contrib/openzfs/include/os/linux/kernel/linux/mod_compat.h
  head/sys/contrib/openzfs/include/os/linux/spl/sys/condvar.h
  head/sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am
  head/sys/contrib/openzfs/include/sys/Makefile.am
  head/sys/contrib/openzfs/include/sys/dsl_synctask.h
  head/sys/contrib/openzfs/include/sys/fm/fs/zfs.h
  head/sys/contrib/openzfs/include/sys/fm/util.h
  head/sys/contrib/openzfs/include/sys/fs/zfs.h
  head/sys/contrib/openzfs/include/sys/spa.h
  head/sys/contrib/openzfs/include/sys/vdev.h
  head/sys/contrib/openzfs/include/sys/vdev_impl.h
  head/sys/contrib/openzfs/include/sys/zfs_context.h
  head/sys/contrib/openzfs/include/sys/zfs_ioctl.h
  head/sys/contrib/openzfs/include/sys/zio.h
  head/sys/contrib/openzfs/lib/Makefile.am
  head/sys/contrib/openzfs/lib/libefi/rdwr_efi.c
  head/sys/contrib/openzfs/lib/libshare/os/linux/nfs.c
  head/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/stat.h
  head/sys/contrib/openzfs/lib/libzfs/libzfs.pc.in
  head/sys/contrib/openzfs/lib/libzfs/libzfs_dataset.c
  head/sys/contrib/openzfs/lib/libzfs/libzfs_pool.c
  head/sys/contrib/openzfs/lib/libzfs/libzfs_sendrecv.c
  head/sys/contrib/openzfs/lib/libzfs/libzfs_util.c
  head/sys/contrib/openzfs/lib/libzfs/os/linux/libzfs_pool_os.c
  head/sys/contrib/openzfs/lib/libzfs_core/libzfs_core.c
  head/sys/contrib/openzfs/lib/libzfs_core/libzfs_core.pc.in
  head/sys/contrib/openzfs/lib/libzpool/Makefile.am
  head/sys/contrib/openzfs/lib/libzutil/Makefile.am
  head/sys/contrib/openzfs/man/man5/zfs-module-parameters.5
  head/sys/contrib/openzfs/man/man8/zfs-rename.8
  head/sys/contrib/openzfs/man/man8/zfsprops.8
  head/sys/contrib/openzfs/man/man8/zgenhostid.8
  head/sys/contrib/openzfs/man/man8/zpoolprops.8
  head/sys/contrib/openzfs/module/os/freebsd/zfs/kmod_core.c
  head/sys/contrib/openzfs/module/os/freebsd/zfs/sysctl_os.c
  head/sys/contrib/openzfs/module/os/freebsd/zfs/vdev_file.c
  head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_file_os.c
  head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c
  head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops.c
  head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_znode.c
  head/sys/contrib/openzfs/module/os/linux/spl/spl-condvar.c
  head/sys/contrib/openzfs/module/os/linux/zfs/vdev_disk.c
  head/sys/contrib/openzfs/module/os/linux/zfs/vdev_file.c
  head/sys/contrib/openzfs/module/os/linux/zfs/zfs_acl.c
  head/sys/contrib/openzfs/module/os/linux/zfs/zfs_vfsops.c
  head/sys/contrib/openzfs/module/os/linux/zfs/zpl_super.c
  head/sys/contrib/openzfs/module/os/linux/zfs/zpl_xattr.c
  head/sys/contrib/openzfs/module/zcommon/zfs_prop.c
  head/sys/contrib/openzfs/module/zfs/arc.c
  head/sys/contrib/openzfs/module/zfs/dbuf.c
  head/sys/contrib/openzfs/module/zfs/dmu_redact.c
  head/sys/contrib/openzfs/module/zfs/dnode.c
  head/sys/contrib/openzfs/module/zfs/dsl_scan.c
  head/sys/contrib/openzfs/module/zfs/dsl_synctask.c
  head/sys/contrib/openzfs/module/zfs/fm.c
  head/sys/contrib/openzfs/module/zfs/metaslab.c
  head/sys/contrib/openzfs/module/zfs/mmp.c
  head/sys/contrib/openzfs/module/zfs/range_tree.c
  head/sys/contrib/openzfs/module/zfs/spa.c
  head/sys/contrib/openzfs/module/zfs/spa_config.c
  head/sys/contrib/openzfs/module/zfs/spa_history.c
  head/sys/contrib/openzfs/module/zfs/txg.c
  head/sys/contrib/openzfs/module/zfs/vdev.c
  head/sys/contrib/openzfs/module/zfs/vdev_indirect.c
  head/sys/contrib/openzfs/module/zfs/vdev_initialize.c
  head/sys/contrib/openzfs/module/zfs/vdev_label.c
  head/sys/contrib/openzfs/module/zfs/vdev_mirror.c
  head/sys/contrib/openzfs/module/zfs/vdev_raidz.c
  head/sys/contrib/openzfs/module/zfs/vdev_rebuild.c
  head/sys/contrib/openzfs/module/zfs/vdev_removal.c
  head/sys/contrib/openzfs/module/zfs/vdev_trim.c
  head/sys/contrib/openzfs/module/zfs/zfs_fm.c
  head/sys/contrib/openzfs/module/zfs/zfs_ioctl.c
  head/sys/contrib/openzfs/module/zfs/zio.c
  head/sys/contrib/openzfs/module/zfs/zthr.c
  head/sys/contrib/openzfs/rpm/generic/zfs.spec.in
  head/sys/contrib/openzfs/scripts/zfs-tests.sh
  head/sys/contrib/openzfs/tests/runfiles/common.run
  head/sys/contrib/openzfs/tests/zfs-tests/cmd/libzfs_input_check/Makefile.am
  
head/sys/contrib/openzfs/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c
  head/sys/contrib/openzfs/tests/zfs-tests/include/commands.cfg
  head/sys/contrib/openzfs/tests/zfs-tests/include/tunables.cfg
  
head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh
  
head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh
  head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/setup.ksh
  
head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh
  
head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_prop_ashift.ksh
  
head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_attach/attach-o_ashift.ksh
  
head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_021_pos.ksh
  
head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_022_pos.ksh
  
head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/Makefile.am
  
head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace-o_ashift.ksh
  
head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace_prop_ashift.ksh
  
head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_set/zpool_set_ashift.ksh
  
head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/misc.cfg
  
head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_002_pos.ksh
  
head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh
Directory Properties:
  head/sys/contrib/openzfs/   (props changed)

Modified: head/cddl/lib/libzpool/Makefile
==============================================================================
--- head/cddl/lib/libzpool/Makefile     Fri Sep 18 22:59:44 2020        
(r365893)
+++ head/cddl/lib/libzpool/Makefile     Fri Sep 18 23:21:24 2020        
(r365894)
@@ -234,6 +234,7 @@ CFLAGS+= \
        -DHAVE_ISSETUGID \
        -include ${SRCTOP}/sys/modules/zfs/zfs_config.h \
        -I${SRCTOP}/sys/modules/zfs \
+       -I${ZFSTOP}/include/os/freebsd/zfs \
        -DLIB_ZPOOL_BUILD -DZFS_DEBUG \
 
 # XXX: pthread doesn't have mutex_owned() equivalent, so we need to look

Modified: head/sys/contrib/openzfs/META
==============================================================================
--- head/sys/contrib/openzfs/META       Fri Sep 18 22:59:44 2020        
(r365893)
+++ head/sys/contrib/openzfs/META       Fri Sep 18 23:21:24 2020        
(r365894)
@@ -2,7 +2,7 @@ Meta:          1
 Name:          zfs
 Branch:        1.0
 Version:       2.0.0
-Release:       rc1
+Release:       rc2
 Release-Tags:  relext
 License:       CDDL
 Author:        OpenZFS

Modified: head/sys/contrib/openzfs/cmd/mount_zfs/mount_zfs.c
==============================================================================
--- head/sys/contrib/openzfs/cmd/mount_zfs/mount_zfs.c  Fri Sep 18 22:59:44 
2020        (r365893)
+++ head/sys/contrib/openzfs/cmd/mount_zfs/mount_zfs.c  Fri Sep 18 23:21:24 
2020        (r365894)
@@ -182,6 +182,7 @@ main(int argc, char **argv)
        int error, c;
 
        (void) setlocale(LC_ALL, "");
+       (void) setlocale(LC_NUMERIC, "C");
        (void) textdomain(TEXT_DOMAIN);
 
        opterr = 0;

Modified: head/sys/contrib/openzfs/cmd/zdb/zdb.c
==============================================================================
--- head/sys/contrib/openzfs/cmd/zdb/zdb.c      Fri Sep 18 22:59:44 2020        
(r365893)
+++ head/sys/contrib/openzfs/cmd/zdb/zdb.c      Fri Sep 18 23:21:24 2020        
(r365894)
@@ -5340,11 +5340,6 @@ load_unflushed_svr_segs_cb(spa_t *spa, space_map_entry
        if (txg < metaslab_unflushed_txg(ms))
                return (0);
 
-       vdev_indirect_mapping_t *vim = vd->vdev_indirect_mapping;
-       ASSERT(vim != NULL);
-       if (offset >= vdev_indirect_mapping_max_offset(vim))
-               return (0);
-
        if (sme->sme_type == SM_ALLOC)
                range_tree_add(svr->svr_allocd_segs, offset, size);
        else
@@ -5406,9 +5401,6 @@ zdb_claim_removing(spa_t *spa, zdb_cb_t *zcb)
        range_tree_t *allocs = range_tree_create(NULL, RANGE_SEG64, NULL, 0, 0);
        for (uint64_t msi = 0; msi < vd->vdev_ms_count; msi++) {
                metaslab_t *msp = vd->vdev_ms[msi];
-
-               if (msp->ms_start >= vdev_indirect_mapping_max_offset(vim))
-                       break;
 
                ASSERT0(range_tree_space(allocs));
                if (msp->ms_sm != NULL)

Modified: head/sys/contrib/openzfs/cmd/zfs/zfs_main.c
==============================================================================
--- head/sys/contrib/openzfs/cmd/zfs/zfs_main.c Fri Sep 18 22:59:44 2020        
(r365893)
+++ head/sys/contrib/openzfs/cmd/zfs/zfs_main.c Fri Sep 18 23:21:24 2020        
(r365894)
@@ -8468,6 +8468,7 @@ main(int argc, char **argv)
        char **newargv;
 
        (void) setlocale(LC_ALL, "");
+       (void) setlocale(LC_NUMERIC, "C");
        (void) textdomain(TEXT_DOMAIN);
 
        opterr = 0;

Copied: head/sys/contrib/openzfs/cmd/zgenhostid/.gitignore (from r365893, 
vendor-sys/openzfs/dist/cmd/zgenhostid/.gitignore)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/contrib/openzfs/cmd/zgenhostid/.gitignore  Fri Sep 18 23:21:24 
2020        (r365894, copy of r365893, 
vendor-sys/openzfs/dist/cmd/zgenhostid/.gitignore)
@@ -0,0 +1 @@
+/zgenhostid

Modified: head/sys/contrib/openzfs/cmd/zgenhostid/Makefile.am
==============================================================================
--- head/sys/contrib/openzfs/cmd/zgenhostid/Makefile.am Fri Sep 18 22:59:44 
2020        (r365893)
+++ head/sys/contrib/openzfs/cmd/zgenhostid/Makefile.am Fri Sep 18 23:21:24 
2020        (r365894)
@@ -1 +1,5 @@
-dist_bin_SCRIPTS = zgenhostid
+include $(top_srcdir)/config/Rules.am
+
+bin_PROGRAMS = zgenhostid
+
+zgenhostid_SOURCES = zgenhostid.c

Copied: head/sys/contrib/openzfs/cmd/zgenhostid/zgenhostid.c (from r365893, 
vendor-sys/openzfs/dist/cmd/zgenhostid/zgenhostid.c)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/contrib/openzfs/cmd/zgenhostid/zgenhostid.c        Fri Sep 18 
23:21:24 2020        (r365894, copy of r365893, 
vendor-sys/openzfs/dist/cmd/zgenhostid/zgenhostid.c)
@@ -0,0 +1,152 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2020, Georgy Yakovlev.  All rights reserved.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <unistd.h>
+
+static void usage(void);
+
+static void
+usage(void)
+{
+       (void) fprintf(stderr,
+           "usage: zgenhostid [-fh] [-o path] [value]\n\n"
+           "  -f\t\t force hostid file write\n"
+           "  -h\t\t print this usage and exit\n"
+           "  -o <filename>\t write hostid to this file\n\n"
+           "If hostid file is not present, store a hostid in it.\n"
+           "The optional value must be an 8-digit hex number between"
+           "1 and 2^32-1.\n"
+           "If no value is provided, a random one will"
+           "be generated.\n"
+           "The value must be unique among your systems.\n");
+       exit(EXIT_FAILURE);
+       /* NOTREACHED */
+}
+
+int
+main(int argc, char **argv)
+{
+       /* default file path, can be optionally set by user */
+       char path[PATH_MAX] = "/etc/hostid";
+       /* holds converted user input or lrand48() generated value */
+       unsigned long input_i = 0;
+
+       int opt;
+       int pathlen;
+       int force_fwrite = 0;
+       while ((opt = getopt_long(argc, argv, "fo:h?", 0, 0)) != -1) {
+               switch (opt) {
+               case 'f':
+                       force_fwrite = 1;
+                       break;
+               case 'o':
+                       pathlen = snprintf(path, sizeof (path), "%s", optarg);
+                       if (pathlen >= sizeof (path)) {
+                               fprintf(stderr, "%s\n", strerror(EOVERFLOW));
+                               exit(EXIT_FAILURE);
+                       } else if (pathlen < 1) {
+                               fprintf(stderr, "%s\n", strerror(EINVAL));
+                               exit(EXIT_FAILURE);
+                       }
+                       break;
+               case 'h':
+               case '?':
+                       usage();
+               }
+       }
+
+       char *in_s = argv[optind];
+       if (in_s != NULL) {
+               /* increment pointer by 2 if string is 0x prefixed */
+               if (strncasecmp("0x", in_s, 2) == 0) {
+                       in_s += 2;
+               }
+
+               /* need to be exactly 8 characters */
+               const char *hex = "0123456789abcdefABCDEF";
+               if (strlen(in_s) != 8 || strspn(in_s, hex) != 8) {
+                       fprintf(stderr, "%s\n", strerror(ERANGE));
+                       usage();
+               }
+
+               input_i = strtoul(in_s, NULL, 16);
+               if (errno != 0) {
+                       perror("strtoul");
+                       exit(EXIT_FAILURE);
+               }
+
+               if (input_i < 0x1 || input_i > UINT32_MAX) {
+                       fprintf(stderr, "%s\n", strerror(ERANGE));
+                       usage();
+               }
+       }
+
+       struct stat fstat;
+       if (force_fwrite == 0 && stat(path, &fstat) == 0 &&
+           S_ISREG(fstat.st_mode)) {
+               fprintf(stderr, "%s: %s\n", path, strerror(EEXIST));
+                       exit(EXIT_FAILURE);
+       }
+
+       /*
+        * generate if not provided by user
+        * also handle unlikely zero return from lrand48()
+        */
+       while (input_i == 0) {
+               srand48(getpid() ^ time(NULL));
+               input_i = lrand48();
+       }
+
+       FILE *fp = fopen(path, "wb");
+       if (!fp) {
+               perror("fopen");
+               exit(EXIT_FAILURE);
+       }
+
+       /*
+        * we need just 4 bytes in native endianess
+        * not using sethostid() because it may be missing or just a stub
+        */
+       uint32_t hostid = input_i;
+       int written = fwrite(&hostid, 1, 4, fp);
+       if (written != 4) {
+               perror("fwrite");
+               exit(EXIT_FAILURE);
+       }
+
+       fclose(fp);
+       exit(EXIT_SUCCESS);
+}

Modified: head/sys/contrib/openzfs/cmd/zpool/zpool_main.c
==============================================================================
--- head/sys/contrib/openzfs/cmd/zpool/zpool_main.c     Fri Sep 18 22:59:44 
2020        (r365893)
+++ head/sys/contrib/openzfs/cmd/zpool/zpool_main.c     Fri Sep 18 23:21:24 
2020        (r365894)
@@ -2654,6 +2654,13 @@ show_import(nvlist_t *config)
                    errata);
                break;
 
+       case ZPOOL_STATUS_NON_NATIVE_ASHIFT:
+               printf_color(ANSI_BOLD, gettext("status: "));
+               printf_color(ANSI_YELLOW, gettext("One or more devices are "
+                   "configured to use a non-native block size.\n"
+                   "\tExpect reduced performance.\n"));
+               break;
+
        default:
                /*
                 * No other status can be seen when importing pools.
@@ -10229,6 +10236,7 @@ main(int argc, char **argv)
        char **newargv;
 
        (void) setlocale(LC_ALL, "");
+       (void) setlocale(LC_NUMERIC, "C");
        (void) textdomain(TEXT_DOMAIN);
        srand(time(NULL));
 

Modified: head/sys/contrib/openzfs/config/deb.am
==============================================================================
--- head/sys/contrib/openzfs/config/deb.am      Fri Sep 18 22:59:44 2020        
(r365893)
+++ head/sys/contrib/openzfs/config/deb.am      Fri Sep 18 23:21:24 2020        
(r365894)
@@ -35,7 +35,7 @@ deb-dkms: deb-local rpm-dkms
        fakeroot $(ALIEN) --bump=0 --scripts --to-deb --target=$$debarch $$pkg1 
|| exit 1; \
        $(RM) $$pkg1
 
-deb-utils: deb-local rpm-utils
+deb-utils: deb-local rpm-utils-initramfs
        name=${PACKAGE}; \
        version=${VERSION}-${RELEASE}; \
        arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \

Modified: head/sys/contrib/openzfs/config/find_system_library.m4
==============================================================================
--- head/sys/contrib/openzfs/config/find_system_library.m4      Fri Sep 18 
22:59:44 2020        (r365893)
+++ head/sys/contrib/openzfs/config/find_system_library.m4      Fri Sep 18 
23:21:24 2020        (r365894)
@@ -11,10 +11,12 @@ AC_DEFUN([ZFS_AC_FIND_SYSTEM_LIBRARY], [
 
     _header_found=
     _library_found=
+    _pc_found=
 
     AS_IF([test -n "$2"], [PKG_CHECK_MODULES([$1], [$2], [
        _header_found=1
        _library_found=1
+       _pc_found=1
     ], [:])])
 
     # set _header_found/_library_found if the user passed in CFLAGS/LIBS
@@ -82,6 +84,9 @@ AC_DEFUN([ZFS_AC_FIND_SYSTEM_LIBRARY], [
     AS_IF([test "x$_header_found" = "x1" && test "x$_library_found" = "x1"], [
        AC_SUBST([$1]_CFLAGS)
        AC_SUBST([$1]_LIBS)
+       AS_IF([test "x$_pc_found" = "x1"], [
+           AC_SUBST([$1]_PC, [$2])
+       ])
        AC_DEFINE([HAVE_][$1], [1], [Define if you have [$5]])
        $7
     ],[dnl ELSE

Modified: head/sys/contrib/openzfs/config/rpm.am
==============================================================================
--- head/sys/contrib/openzfs/config/rpm.am      Fri Sep 18 22:59:44 2020        
(r365893)
+++ head/sys/contrib/openzfs/config/rpm.am      Fri Sep 18 23:21:24 2020        
(r365894)
@@ -7,7 +7,7 @@
 ###############################################################################
 
 PHONY += srpm srpms srpm-kmod srpm-dkms srpm-utils
-PHONY += rpm rpms rpm-kmod rpm-dkms rpm-utils
+PHONY += rpm rpms rpm-kmod rpm-dkms rpm-utils rpm-utils-initramfs
 PHONY += srpm-common rpm-common rpm-local
 
 srpm-kmod srpm-dkms srpm-utils: dist
@@ -35,9 +35,21 @@ rpm-dkms: srpm-dkms
        $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-dkms" \
                def='${RPM_DEFINE_COMMON} ${RPM_DEFINE_DKMS}' rpm-common
 
+# The rpm-utils and rpm-utils-initramfs targets are identical except for the
+# zfs-initramfs package: rpm-utils never includes it, rpm-utils-initramfs
+# includes it if detected at configure time. The zfs-initramfs package does
+# not work on any known RPM-based distribution and the resulting RPM is only
+# used to create a Debian package. The rpm-utils-initramfs target is not
+# intended to be specified by the user directly, it is provided as a
+# dependency of the deb-utils target.
+
 rpm-utils: srpm-utils
        $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" \
                def='${RPM_DEFINE_COMMON} ${RPM_DEFINE_UTIL}' rpm-common
+
+rpm-utils-initramfs: srpm-utils
+       $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" \
+               def='${RPM_DEFINE_COMMON} ${RPM_DEFINE_UTIL} 
${RPM_DEFINE_INITRAMFS}' rpm-common
 
 rpm: rpm-kmod rpm-dkms rpm-utils
 rpms: rpm-kmod rpm-dkms rpm-utils

Modified: head/sys/contrib/openzfs/config/zfs-build.m4
==============================================================================
--- head/sys/contrib/openzfs/config/zfs-build.m4        Fri Sep 18 22:59:44 
2020        (r365893)
+++ head/sys/contrib/openzfs/config/zfs-build.m4        Fri Sep 18 23:21:24 
2020        (r365894)
@@ -282,7 +282,6 @@ AC_DEFUN([ZFS_AC_RPM], [
        AS_IF([test -n "$udevruledir" ], [
                RPM_DEFINE_UTIL=${RPM_DEFINE_UTIL}' --define "_udevruledir 
$(udevruledir)"'
        ])
-       RPM_DEFINE_UTIL=${RPM_DEFINE_UTIL}' $(DEFINE_INITRAMFS)'
        RPM_DEFINE_UTIL=${RPM_DEFINE_UTIL}' $(DEFINE_SYSTEMD)'
        RPM_DEFINE_UTIL=${RPM_DEFINE_UTIL}' $(DEFINE_PYZFS)'
        RPM_DEFINE_UTIL=${RPM_DEFINE_UTIL}' $(DEFINE_PAM)'
@@ -542,13 +541,13 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [
 
        AC_MSG_CHECKING([whether initramfs-tools is available])
        if test -d /usr/share/initramfs-tools ; then
-               DEFINE_INITRAMFS='--define "_initramfs 1"'
+               RPM_DEFINE_INITRAMFS='--define "_initramfs 1"'
                AC_MSG_RESULT([yes])
        else
-               DEFINE_INITRAMFS=''
+               RPM_DEFINE_INITRAMFS=''
                AC_MSG_RESULT([no])
        fi
-       AC_SUBST(DEFINE_INITRAMFS)
+       AC_SUBST(RPM_DEFINE_INITRAMFS)
 ])
 
 dnl #

Modified: head/sys/contrib/openzfs/configure.ac
==============================================================================
--- head/sys/contrib/openzfs/configure.ac       Fri Sep 18 22:59:44 2020        
(r365893)
+++ head/sys/contrib/openzfs/configure.ac       Fri Sep 18 23:21:24 2020        
(r365894)
@@ -161,6 +161,8 @@ AC_CONFIG_FILES([
        lib/libuutil/Makefile
        lib/libzfs/Makefile
        lib/libzfs/libzfs.pc
+       lib/libzfsbootenv/Makefile
+       lib/libzfsbootenv/libzfsbootenv.pc
        lib/libzfs_core/Makefile
        lib/libzfs_core/libzfs_core.pc
        lib/libzpool/Makefile

Modified: head/sys/contrib/openzfs/contrib/dracut/90zfs/module-setup.sh.in
==============================================================================
--- head/sys/contrib/openzfs/contrib/dracut/90zfs/module-setup.sh.in    Fri Sep 
18 22:59:44 2020        (r365893)
+++ head/sys/contrib/openzfs/contrib/dracut/90zfs/module-setup.sh.in    Fri Sep 
18 23:21:24 2020        (r365894)
@@ -5,7 +5,7 @@ check() {
        [ "${1}" = "-d" ] && return 0
 
        # Verify the zfs tool chain
-       for tool in "@sbindir@/zpool" "@sbindir@/zfs" 
"@mounthelperdir@/mount.zfs" ; do
+       for tool in "@bindir@/zgenhostid" "@sbindir@/zpool" "@sbindir@/zfs" 
"@mounthelperdir@/mount.zfs" ; do
                test -x "$tool" || return 1
        done
        # Verify grep exists
@@ -38,6 +38,7 @@ install() {
        inst_rules @udevruledir@/60-zvol.rules
        dracut_install hostid
        dracut_install grep
+       dracut_install @bindir@/zgenhostid
        dracut_install @sbindir@/zfs
        dracut_install @sbindir@/zpool
        # Workaround for zfsonlinux/zfs#4749 by ensuring libgcc_s.so(.1) is 
included
@@ -83,11 +84,7 @@ install() {
        fi
 
        # Synchronize initramfs and system hostid
-       AA=`hostid | cut -b 1,2`
-       BB=`hostid | cut -b 3,4`
-       CC=`hostid | cut -b 5,6`
-       DD=`hostid | cut -b 7,8`
-       echo -ne "\\x${DD}\\x${CC}\\x${BB}\\x${AA}" > "${initdir}/etc/hostid"
+       zgenhostid -o "${initdir}/etc/hostid" "$(hostid)"
 
        if dracut_module_included "systemd"; then
                mkdir -p 
"${initdir}/$systemdsystemunitdir/zfs-import.target.wants"

Modified: head/sys/contrib/openzfs/contrib/dracut/90zfs/parse-zfs.sh.in
==============================================================================
--- head/sys/contrib/openzfs/contrib/dracut/90zfs/parse-zfs.sh.in       Fri Sep 
18 22:59:44 2020        (r365893)
+++ head/sys/contrib/openzfs/contrib/dracut/90zfs/parse-zfs.sh.in       Fri Sep 
18 23:21:24 2020        (r365894)
@@ -6,11 +6,7 @@
 spl_hostid=$(getarg spl_hostid=)
 if [ -n "${spl_hostid}" ] ; then
        info "ZFS: Using hostid from command line: ${spl_hostid}"
-       AA=$(echo "${spl_hostid}" | cut -b 1,2)
-       BB=$(echo "${spl_hostid}" | cut -b 3,4)
-       CC=$(echo "${spl_hostid}" | cut -b 5,6)
-       DD=$(echo "${spl_hostid}" | cut -b 7,8)
-       echo -ne "\\x${DD}\\x${CC}\\x${BB}\\x${AA}" >/etc/hostid
+       zgenhostid -f "${spl_hostid}"
 elif [ -f "/etc/hostid" ] ; then
        info "ZFS: Using hostid from /etc/hostid: $(hostid)"
 else

Modified: head/sys/contrib/openzfs/include/Makefile.am
==============================================================================
--- head/sys/contrib/openzfs/include/Makefile.am        Fri Sep 18 22:59:44 
2020        (r365893)
+++ head/sys/contrib/openzfs/include/Makefile.am        Fri Sep 18 23:21:24 
2020        (r365894)
@@ -15,6 +15,7 @@ USER_H = \
        libuutil.h \
        libuutil_impl.h \
        libzfs.h \
+       libzfsbootenv.h \
        libzfs_core.h \
        libzfs_impl.h \
        libzutil.h \

Modified: head/sys/contrib/openzfs/include/libzfs.h
==============================================================================
--- head/sys/contrib/openzfs/include/libzfs.h   Fri Sep 18 22:59:44 2020        
(r365893)
+++ head/sys/contrib/openzfs/include/libzfs.h   Fri Sep 18 23:21:24 2020        
(r365894)
@@ -892,8 +892,8 @@ extern int zpool_in_use(libzfs_handle_t *, int, pool_s
  * Label manipulation.
  */
 extern int zpool_clear_label(int);
-extern int zpool_set_bootenv(zpool_handle_t *, const char *);
-extern int zpool_get_bootenv(zpool_handle_t *, char *, size_t, off_t);
+extern int zpool_set_bootenv(zpool_handle_t *, const nvlist_t *);
+extern int zpool_get_bootenv(zpool_handle_t *, nvlist_t **);
 
 /*
  * Management interfaces for SMB ACL files

Modified: head/sys/contrib/openzfs/include/libzfs_core.h
==============================================================================
--- head/sys/contrib/openzfs/include/libzfs_core.h      Fri Sep 18 22:59:44 
2020        (r365893)
+++ head/sys/contrib/openzfs/include/libzfs_core.h      Fri Sep 18 23:21:24 
2020        (r365894)
@@ -135,7 +135,7 @@ int lzc_wait(const char *, zpool_wait_activity_t, bool
 int lzc_wait_tag(const char *, zpool_wait_activity_t, uint64_t, boolean_t *);
 int lzc_wait_fs(const char *, zfs_wait_activity_t, boolean_t *);
 
-int lzc_set_bootenv(const char *, const char *);
+int lzc_set_bootenv(const char *, const nvlist_t *);
 int lzc_get_bootenv(const char *, nvlist_t **);
 #ifdef __cplusplus
 }

Copied: head/sys/contrib/openzfs/include/libzfsbootenv.h (from r365893, 
vendor-sys/openzfs/dist/include/libzfsbootenv.h)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/contrib/openzfs/include/libzfsbootenv.h    Fri Sep 18 23:21:24 
2020        (r365894, copy of r365893, 
vendor-sys/openzfs/dist/include/libzfsbootenv.h)
@@ -0,0 +1,41 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2020 Toomas Soome <tso...@me.com>
+ */
+
+#ifndef _LIBZFSBOOTENV_H
+#define        _LIBZFSBOOTENV_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum lzbe_flags {
+       lzbe_add,       /* add data to existing nvlist */
+       lzbe_replace    /* replace current nvlist */
+} lzbe_flags_t;
+
+extern int lzbe_nvlist_get(const char *, const char *, void **);
+extern int lzbe_nvlist_set(const char *, const char *, void *);
+extern void lzbe_nvlist_free(void *);
+extern int lzbe_add_pair(void *, const char *, const char *, void *, size_t);
+extern int lzbe_remove_pair(void *, const char *);
+extern int lzbe_set_boot_device(const char *, lzbe_flags_t, const char *);
+extern int lzbe_get_boot_device(const char *, char **);
+extern int lzbe_bootenv_print(const char *, const char *, FILE *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LIBZFSBOOTENV_H */

Modified: head/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h
==============================================================================
--- head/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h      Fri Sep 
18 22:59:44 2020        (r365893)
+++ head/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h      Fri Sep 
18 23:21:24 2020        (r365894)
@@ -206,8 +206,10 @@ typedef int enum_t;
 #define        __XSI_VISIBLE 1000
 #endif
 #define        ARRAY_SIZE(a) (sizeof (a) / sizeof (a[0]))
-#define        open64 open
 #define        mmap64 mmap
+/* Note: this file can be used on linux/macOS when bootstrapping tools. */
+#if defined(__FreeBSD__)
+#define        open64 open
 #define        pwrite64 pwrite
 #define        ftruncate64 ftruncate
 #define        lseek64 lseek
@@ -217,6 +219,7 @@ typedef int enum_t;
 #define        statfs64 statfs
 #define        readdir64 readdir
 #define        dirent64 dirent
+#endif
 #define        P2ALIGN(x, align)               ((x) & -(align))
 #define        P2CROSS(x, y, align)    (((x) ^ (y)) > (align) - 1)
 #define        P2ROUNDUP(x, align)             ((((x) - 1) | ((align) - 1)) + 
1)

Modified: head/sys/contrib/openzfs/include/os/freebsd/spl/sys/condvar.h
==============================================================================
--- head/sys/contrib/openzfs/include/os/freebsd/spl/sys/condvar.h       Fri Sep 
18 22:59:44 2020        (r365893)
+++ head/sys/contrib/openzfs/include/os/freebsd/spl/sys/condvar.h       Fri Sep 
18 23:21:24 2020        (r365894)
@@ -142,8 +142,14 @@ cv_timedwait_sig(kcondvar_t *cvp, kmutex_t *mp, clock_
        return (1);
 }
 
-#define        cv_timedwait_io cv_timedwait
-#define        cv_timedwait_sig_io cv_timedwait_sig
+#define        cv_timedwait_io         cv_timedwait
+#define        cv_timedwait_idle       cv_timedwait
+#define        cv_timedwait_sig_io     cv_timedwait_sig
+#define        cv_wait_io              cv_wait
+#define        cv_wait_io_sig          cv_wait_sig
+#define        cv_wait_idle            cv_wait
+#define        cv_timedwait_io_hires   cv_timedwait_hires
+#define        cv_timedwait_idle_hires cv_timedwait_hires
 
 static inline int
 cv_timedwait_hires(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim, hrtime_t res,

Modified: head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/Makefile.am
==============================================================================
--- head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/Makefile.am     Fri Sep 
18 22:59:44 2020        (r365893)
+++ head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/Makefile.am     Fri Sep 
18 23:21:24 2020        (r365894)
@@ -2,6 +2,7 @@ KERNEL_H = \
        freebsd_crypto.h \
        sha2.h \
        vdev_os.h \
+       zfs_bootenv_os.h \
        zfs_context_os.h \
        zfs_ctldir.h \
        zfs_dir.h \

Copied: head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_bootenv_os.h 
(from r365893, 
vendor-sys/openzfs/dist/include/os/freebsd/zfs/sys/zfs_bootenv_os.h)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_bootenv_os.h        
Fri Sep 18 23:21:24 2020        (r365894, copy of r365893, 
vendor-sys/openzfs/dist/include/os/freebsd/zfs/sys/zfs_bootenv_os.h)
@@ -0,0 +1,29 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2020 Toomas Soome <tso...@me.com>
+ */
+
+#ifndef _ZFS_BOOTENV_OS_H
+#define        _ZFS_BOOTENV_OS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define        BOOTENV_OS              BE_FREEBSD_VENDOR
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ZFS_BOOTENV_OS_H */

Modified: head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_context_os.h
==============================================================================
--- head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_context_os.h        
Fri Sep 18 22:59:44 2020        (r365893)
+++ head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_context_os.h        
Fri Sep 18 23:21:24 2020        (r365894)
@@ -41,9 +41,6 @@
 #include <sys/ccompat.h>
 #include <linux/types.h>
 
-#define        cv_wait_io(cv, mp)                      cv_wait(cv, mp)
-#define        cv_wait_io_sig(cv, mp)                  cv_wait_sig(cv, mp)
-
 #define        cond_resched()          kern_yield(PRI_USER)
 
 #define        taskq_create_sysdc(a, b, d, e, p, dc, f) \
@@ -75,7 +72,7 @@ extern struct mtx zfs_debug_mtx;
        }          \
 } while (0)
 
-#define        MSEC_TO_TICK(msec)      ((msec) / (MILLISEC / hz))
+#define        MSEC_TO_TICK(msec)      (howmany((hrtime_t)(msec) * hz, 
MILLISEC))
 extern int hz;
 extern int tick;
 typedef int fstrans_cookie_t;
@@ -84,7 +81,6 @@ typedef int fstrans_cookie_t;
 #define        signal_pending(x) SIGPENDING(x)
 #define        current curthread
 #define        thread_join(x)
-#define        cv_wait_io(cv, mp)                      cv_wait(cv, mp)
 typedef struct opensolaris_utsname     utsname_t;
 extern utsname_t *utsname(void);
 extern int spa_import_rootpool(const char *name, bool checkpointrewind);

Modified: head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vfsops_os.h
==============================================================================
--- head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vfsops_os.h Fri Sep 
18 22:59:44 2020        (r365893)
+++ head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vfsops_os.h Fri Sep 
18 23:21:24 2020        (r365894)
@@ -27,18 +27,31 @@
 #ifndef        _SYS_FS_ZFS_VFSOPS_H
 #define        _SYS_FS_ZFS_VFSOPS_H
 
+#if __FreeBSD_version >= 1300109
+#define        TEARDOWN_INACTIVE_RMS
+#endif
+
 #include <sys/dataset_kstats.h>
 #include <sys/list.h>
 #include <sys/vfs.h>
 #include <sys/zil.h>
 #include <sys/sa.h>
 #include <sys/rrwlock.h>
+#ifdef TEARDOWN_INACTIVE_RMS
+#include <sys/rmlock.h>
+#endif
 #include <sys/zfs_ioctl.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+#ifdef TEARDOWN_INACTIVE_RMS
+typedef struct rmslock zfs_teardown_lock_t;
+#else
+#define        zfs_teardown_lock_t krwlock_t
+#endif
+
 typedef struct zfsvfs zfsvfs_t;
 struct znode;
 
@@ -67,7 +80,7 @@ struct zfsvfs {
        boolean_t       z_atime;        /* enable atimes mount option */
        boolean_t       z_unmounted;    /* unmounted */
        rrmlock_t       z_teardown_lock;
-       krwlock_t       z_teardown_inactive_lock;
+       zfs_teardown_lock_t z_teardown_inactive_lock;
        list_t          z_all_znodes;   /* all vnodes in the fs */
        uint64_t        z_nr_znodes;    /* number of znodes in the fs */
        kmutex_t        z_znodes_lock;  /* lock for z_all_znodes */
@@ -97,6 +110,56 @@ struct zfsvfs {
        kmutex_t        z_hold_mtx[ZFS_OBJ_MTX_SZ];     /* znode hold locks */
        struct task     z_unlinked_drain_task;
 };
+
+#ifdef TEARDOWN_INACTIVE_RMS
+#define        ZFS_INIT_TEARDOWN_INACTIVE(zfsvfs)      \
+       rms_init(&(zfsvfs)->z_teardown_inactive_lock, "zfs teardown inactive")
+
+#define        ZFS_DESTROY_TEARDOWN_INACTIVE(zfsvfs)   \
+       rms_destroy(&(zfsvfs)->z_teardown_inactive_lock)
+
+#define        ZFS_TRYRLOCK_TEARDOWN_INACTIVE(zfsvfs)  \
+       rms_try_rlock(&(zfsvfs)->z_teardown_inactive_lock)
+
+#define        ZFS_RLOCK_TEARDOWN_INACTIVE(zfsvfs)     \
+       rms_rlock(&(zfsvfs)->z_teardown_inactive_lock)
+
+#define        ZFS_RUNLOCK_TEARDOWN_INACTIVE(zfsvfs)   \
+       rms_runlock(&(zfsvfs)->z_teardown_inactive_lock)
+
+#define        ZFS_WLOCK_TEARDOWN_INACTIVE(zfsvfs)     \
+       rms_wlock(&(zfsvfs)->z_teardown_inactive_lock)
+
+#define        ZFS_WUNLOCK_TEARDOWN_INACTIVE(zfsvfs)   \
+       rms_wunlock(&(zfsvfs)->z_teardown_inactive_lock)
+
+#define        ZFS_TEARDOWN_INACTIVE_WLOCKED(zfsvfs)   \
+       rms_wowned(&(zfsvfs)->z_teardown_inactive_lock)
+#else
+#define        ZFS_INIT_TEARDOWN_INACTIVE(zfsvfs)      \
+       rw_init(&(zfsvfs)->z_teardown_inactive_lock, NULL, RW_DEFAULT, NULL)
+
+#define        ZFS_DESTROY_TEARDOWN_INACTIVE(zfsvfs)   \
+       rw_destroy(&(zfsvfs)->z_teardown_inactive_lock)
+
+#define        ZFS_TRYRLOCK_TEARDOWN_INACTIVE(zfsvfs)  \
+       rw_tryenter(&(zfsvfs)->z_teardown_inactive_lock, RW_READER)
+
+#define        ZFS_RLOCK_TEARDOWN_INACTIVE(zfsvfs)     \
+       rw_enter(&(zfsvfs)->z_teardown_inactive_lock, RW_READER)
+
+#define        ZFS_RUNLOCK_TEARDOWN_INACTIVE(zfsvfs)   \
+       rw_exit(&(zfsvfs)->z_teardown_inactive_lock)
+
+#define        ZFS_WLOCK_TEARDOWN_INACTIVE(zfsvfs)     \
+       rw_enter(&(zfsvfs)->z_teardown_inactive_lock, RW_WRITER)
+
+#define        ZFS_WUNLOCK_TEARDOWN_INACTIVE(zfsvfs)   \
+       rw_exit(&(zfsvfs)->z_teardown_inactive_lock)
+
+#define        ZFS_TEARDOWN_INACTIVE_WLOCKED(zfsvfs)   \
+       RW_WRITE_HELD(&(zfsvfs)->z_teardown_inactive_lock)
+#endif
 
 #define        ZSB_XATTR       0x0001          /* Enable user xattrs */
 /*

Modified: head/sys/contrib/openzfs/include/os/linux/kernel/linux/mod_compat.h
==============================================================================
--- head/sys/contrib/openzfs/include/os/linux/kernel/linux/mod_compat.h Fri Sep 
18 22:59:44 2020        (r365893)
+++ head/sys/contrib/openzfs/include/os/linux/kernel/linux/mod_compat.h Fri Sep 
18 23:21:24 2020        (r365894)
@@ -21,6 +21,7 @@
 
 /*
  * Copyright (C) 2016 Gvozden Neskovic <nesko...@gmail.com>.
+ * Copyright (c) 2020 by Delphix. All rights reserved.
  */
 
 #ifndef _MOD_COMPAT_H
@@ -71,6 +72,7 @@ enum scope_prefix_types {
        zfs_txg,
        zfs_vdev,
        zfs_vdev_cache,
+       zfs_vdev_file,
        zfs_vdev_mirror,
        zfs_zevent,
        zfs_zio,

Modified: head/sys/contrib/openzfs/include/os/linux/spl/sys/condvar.h
==============================================================================
--- head/sys/contrib/openzfs/include/os/linux/spl/sys/condvar.h Fri Sep 18 
22:59:44 2020        (r365893)
+++ head/sys/contrib/openzfs/include/os/linux/spl/sys/condvar.h Fri Sep 18 
23:21:24 2020        (r365894)
@@ -80,15 +80,19 @@ extern void __cv_init(kcondvar_t *, char *, kcv_type_t
 extern void __cv_destroy(kcondvar_t *);
 extern void __cv_wait(kcondvar_t *, kmutex_t *);
 extern void __cv_wait_io(kcondvar_t *, kmutex_t *);
+extern void __cv_wait_idle(kcondvar_t *, kmutex_t *);
 extern int __cv_wait_io_sig(kcondvar_t *, kmutex_t *);
 extern int __cv_wait_sig(kcondvar_t *, kmutex_t *);
 extern int __cv_timedwait(kcondvar_t *, kmutex_t *, clock_t);
 extern int __cv_timedwait_io(kcondvar_t *, kmutex_t *, clock_t);
 extern int __cv_timedwait_sig(kcondvar_t *, kmutex_t *, clock_t);
+extern int __cv_timedwait_idle(kcondvar_t *, kmutex_t *, clock_t);
 extern int cv_timedwait_hires(kcondvar_t *, kmutex_t *, hrtime_t,
     hrtime_t res, int flag);
 extern int cv_timedwait_sig_hires(kcondvar_t *, kmutex_t *, hrtime_t,
     hrtime_t res, int flag);
+extern int cv_timedwait_idle_hires(kcondvar_t *, kmutex_t *, hrtime_t,
+    hrtime_t res, int flag);
 extern void __cv_signal(kcondvar_t *);
 extern void __cv_broadcast(kcondvar_t *c);
 
@@ -96,6 +100,7 @@ extern void __cv_broadcast(kcondvar_t *c);
 #define        cv_destroy(cvp)                         __cv_destroy(cvp)
 #define        cv_wait(cvp, mp)                        __cv_wait(cvp, mp)
 #define        cv_wait_io(cvp, mp)                     __cv_wait_io(cvp, mp)
+#define        cv_wait_idle(cvp, mp)                   __cv_wait_idle(cvp, mp)
 #define        cv_wait_io_sig(cvp, mp)                 __cv_wait_io_sig(cvp, 
mp)
 #define        cv_wait_sig(cvp, mp)                    __cv_wait_sig(cvp, mp)
 #define        cv_signal(cvp)                          __cv_signal(cvp)
@@ -109,5 +114,7 @@ extern void __cv_broadcast(kcondvar_t *c);
 #define        cv_timedwait(cvp, mp, t)                __cv_timedwait(cvp, mp, 
t)
 #define        cv_timedwait_io(cvp, mp, t)             __cv_timedwait_io(cvp, 
mp, t)
 #define        cv_timedwait_sig(cvp, mp, t)            __cv_timedwait_sig(cvp, 
mp, t)
+#define        cv_timedwait_idle(cvp, mp, t)           
__cv_timedwait_idle(cvp, mp, t)
+
 
 #endif /* _SPL_CONDVAR_H */

Modified: head/sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am
==============================================================================
--- head/sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am       Fri Sep 
18 22:59:44 2020        (r365893)
+++ head/sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am       Fri Sep 
18 23:21:24 2020        (r365894)
@@ -16,6 +16,7 @@ KERNEL_H = \
        trace_zil.h \
        trace_zio.h \
        trace_zrlock.h \
+       zfs_bootenv_os.h \
        zfs_context_os.h \
        zfs_ctldir.h \
        zfs_dir.h \

Copied: head/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_bootenv_os.h 
(from r365893, 
vendor-sys/openzfs/dist/include/os/linux/zfs/sys/zfs_bootenv_os.h)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_bootenv_os.h  Fri Sep 
18 23:21:24 2020        (r365894, copy of r365893, 
vendor-sys/openzfs/dist/include/os/linux/zfs/sys/zfs_bootenv_os.h)
@@ -0,0 +1,29 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2020 Toomas Soome <tso...@me.com>
+ */
+
+#ifndef _ZFS_BOOTENV_OS_H
+#define        _ZFS_BOOTENV_OS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define        BOOTENV_OS              BE_LINUX_VENDOR
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ZFS_BOOTENV_OS_H */

Modified: head/sys/contrib/openzfs/include/sys/Makefile.am
==============================================================================
--- head/sys/contrib/openzfs/include/sys/Makefile.am    Fri Sep 18 22:59:44 
2020        (r365893)
+++ head/sys/contrib/openzfs/include/sys/Makefile.am    Fri Sep 18 23:21:24 
2020        (r365894)
@@ -102,6 +102,7 @@ COMMON_H = \
        zcp_set.h \
        zfeature.h \
        zfs_acl.h \
+       zfs_bootenv.h \
        zfs_context.h \
        zfs_debug.h \
        zfs_delay.h \

Modified: head/sys/contrib/openzfs/include/sys/dsl_synctask.h
==============================================================================
--- head/sys/contrib/openzfs/include/sys/dsl_synctask.h Fri Sep 18 22:59:44 
2020        (r365893)
+++ head/sys/contrib/openzfs/include/sys/dsl_synctask.h Fri Sep 18 23:21:24 
2020        (r365894)
@@ -112,11 +112,11 @@ void dsl_sync_task_sync(dsl_sync_task_t *, dmu_tx_t *)
 int dsl_sync_task(const char *, dsl_checkfunc_t *,
     dsl_syncfunc_t *, void *, int, zfs_space_check_t);
 void dsl_sync_task_nowait(struct dsl_pool *, dsl_syncfunc_t *,
-    void *, int, zfs_space_check_t, dmu_tx_t *);
+    void *, dmu_tx_t *);
 int dsl_early_sync_task(const char *, dsl_checkfunc_t *,
     dsl_syncfunc_t *, void *, int, zfs_space_check_t);
 void dsl_early_sync_task_nowait(struct dsl_pool *, dsl_syncfunc_t *,
-    void *, int, zfs_space_check_t, dmu_tx_t *);
+    void *, dmu_tx_t *);
 int dsl_sync_task_sig(const char *, dsl_checkfunc_t *, dsl_syncfunc_t *,
     dsl_sigfunc_t *, void *, int, zfs_space_check_t);
 

Modified: head/sys/contrib/openzfs/include/sys/fm/fs/zfs.h
==============================================================================
--- head/sys/contrib/openzfs/include/sys/fm/fs/zfs.h    Fri Sep 18 22:59:44 
2020        (r365893)
+++ head/sys/contrib/openzfs/include/sys/fm/fs/zfs.h    Fri Sep 18 23:21:24 
2020        (r365894)
@@ -23,6 +23,10 @@
  * Use is subject to license terms.
  */
 
+/*
+ *  Copyright (c) 2020 by Delphix. All rights reserved.
+ */
+
 #ifndef        _SYS_FM_FS_ZFS_H
 #define        _SYS_FM_FS_ZFS_H
 
@@ -88,6 +92,7 @@ extern "C" {
 #define        FM_EREPORT_PAYLOAD_ZFS_ZIO_SIZE         "zio_size"
 #define        FM_EREPORT_PAYLOAD_ZFS_ZIO_FLAGS        "zio_flags"
 #define        FM_EREPORT_PAYLOAD_ZFS_ZIO_STAGE        "zio_stage"
+#define        FM_EREPORT_PAYLOAD_ZFS_ZIO_PRIORITY     "zio_priority"
 #define        FM_EREPORT_PAYLOAD_ZFS_ZIO_PIPELINE     "zio_pipeline"
 #define        FM_EREPORT_PAYLOAD_ZFS_ZIO_DELAY        "zio_delay"
 #define        FM_EREPORT_PAYLOAD_ZFS_ZIO_TIMESTAMP    "zio_timestamp"

Modified: head/sys/contrib/openzfs/include/sys/fm/util.h
==============================================================================
--- head/sys/contrib/openzfs/include/sys/fm/util.h      Fri Sep 18 22:59:44 
2020        (r365893)
+++ head/sys/contrib/openzfs/include/sys/fm/util.h      Fri Sep 18 23:21:24 
2020        (r365894)
@@ -104,6 +104,9 @@ extern int zfs_zevent_seek(zfs_zevent_t *, uint64_t);
 extern void zfs_zevent_init(zfs_zevent_t **);
 extern void zfs_zevent_destroy(zfs_zevent_t *);
 
+extern void zfs_zevent_track_duplicate(void);
+extern void zfs_ereport_init(void);
+extern void zfs_ereport_fini(void);
 #else
 
 static inline void fm_init(void) { }

Modified: head/sys/contrib/openzfs/include/sys/fs/zfs.h
==============================================================================
--- head/sys/contrib/openzfs/include/sys/fs/zfs.h       Fri Sep 18 22:59:44 
2020        (r365893)
+++ head/sys/contrib/openzfs/include/sys/fs/zfs.h       Fri Sep 18 23:21:24 
2020        (r365894)
@@ -1336,8 +1336,8 @@ typedef enum zfs_ioc {
        ZFS_IOC_NEXTBOOT,                       /* 0x84 (FreeBSD) */
        ZFS_IOC_JAIL,                           /* 0x85 (FreeBSD) */
        ZFS_IOC_UNJAIL,                         /* 0x86 (FreeBSD) */
-       ZFS_IOC_SET_BOOTENV,                    /* 0x87 (Linux) */
-       ZFS_IOC_GET_BOOTENV,                    /* 0x88 (Linux) */
+       ZFS_IOC_SET_BOOTENV,                    /* 0x87 */
+       ZFS_IOC_GET_BOOTENV,                    /* 0x88 */
        ZFS_IOC_LAST
 } zfs_ioc_t;
 

Modified: head/sys/contrib/openzfs/include/sys/spa.h
==============================================================================
--- head/sys/contrib/openzfs/include/sys/spa.h  Fri Sep 18 22:59:44 2020        
(r365893)
+++ head/sys/contrib/openzfs/include/sys/spa.h  Fri Sep 18 23:21:24 2020        
(r365894)
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, 2019 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2020 by Delphix. All rights reserved.
  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
  * Copyright 2013 Saso Kiselkov. All rights reserved.
@@ -1145,10 +1145,10 @@ extern const char *spa_state_to_name(spa_t *spa);
 struct zbookmark_phys;
 extern void spa_log_error(spa_t *spa, const zbookmark_phys_t *zb);
 extern int zfs_ereport_post(const char *clazz, spa_t *spa, vdev_t *vd,
-    const zbookmark_phys_t *zb, zio_t *zio, uint64_t stateoroffset,
-    uint64_t length);
+    const zbookmark_phys_t *zb, zio_t *zio, uint64_t state);
 extern boolean_t zfs_ereport_is_valid(const char *clazz, spa_t *spa, vdev_t 
*vd,
     zio_t *zio);
+extern void zfs_ereport_taskq_fini(void);
 extern nvlist_t *zfs_event_create(spa_t *spa, vdev_t *vd, const char *type,
     const char *name, nvlist_t *aux);
 extern void zfs_post_remove(spa_t *spa, vdev_t *vd);

Modified: head/sys/contrib/openzfs/include/sys/vdev.h
==============================================================================
--- head/sys/contrib/openzfs/include/sys/vdev.h Fri Sep 18 22:59:44 2020        
(r365893)
+++ head/sys/contrib/openzfs/include/sys/vdev.h Fri Sep 18 23:21:24 2020        
(r365894)
@@ -94,7 +94,6 @@ extern void vdev_rele(vdev_t *);
 extern int vdev_metaslab_init(vdev_t *vd, uint64_t txg);
 extern void vdev_metaslab_fini(vdev_t *vd);
 extern void vdev_metaslab_set_size(vdev_t *);
-extern void vdev_ashift_optimize(vdev_t *);
 extern void vdev_expand(vdev_t *vd, uint64_t txg);
 extern void vdev_split(vdev_t *vd);
 extern void vdev_deadman(vdev_t *vd, char *tag);
@@ -181,7 +180,7 @@ extern void vdev_config_generate_stats(vdev_t *vd, nvl
 extern void vdev_label_write(zio_t *zio, vdev_t *vd, int l, abd_t *buf, 
uint64_t
     offset, uint64_t size, zio_done_func_t *done, void *priv, int flags);
 extern int vdev_label_read_bootenv(vdev_t *, nvlist_t *);
-extern int vdev_label_write_bootenv(vdev_t *, char *);
+extern int vdev_label_write_bootenv(vdev_t *, nvlist_t *);
 
 typedef enum {
        VDEV_LABEL_CREATE,      /* create/add a new device */

Modified: head/sys/contrib/openzfs/include/sys/vdev_impl.h
==============================================================================
--- head/sys/contrib/openzfs/include/sys/vdev_impl.h    Fri Sep 18 22:59:44 
2020        (r365893)
+++ head/sys/contrib/openzfs/include/sys/vdev_impl.h    Fri Sep 18 23:21:24 
2020        (r365894)
@@ -476,7 +476,16 @@ typedef struct vdev_phys {
 } vdev_phys_t;
 
 typedef enum vbe_vers {
-       /* The bootenv file is stored as ascii text in the envblock */
+       /*
+        * The bootenv file is stored as ascii text in the envblock.
+        * It is used by the GRUB bootloader used on Linux to store the
+        * contents of the grubenv file. The file is stored as raw ASCII,
+        * and is protected by an embedded checksum. By default, GRUB will
+        * check if the boot filesystem supports storing the environment data
+        * in a special location, and if so, will invoke filesystem specific
+        * logic to retrieve it. This can be overriden by a variable, should
+        * the user so desire.
+        */
        VB_RAW = 0,
 
        /*

Copied: head/sys/contrib/openzfs/include/sys/zfs_bootenv.h (from r365893, 
vendor-sys/openzfs/dist/include/sys/zfs_bootenv.h)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/contrib/openzfs/include/sys/zfs_bootenv.h  Fri Sep 18 23:21:24 
2020        (r365894, copy of r365893, 
vendor-sys/openzfs/dist/include/sys/zfs_bootenv.h)
@@ -0,0 +1,53 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2020 Toomas Soome <tso...@me.com>
+ */
+
+#ifndef _ZFS_BOOTENV_H
+#define        _ZFS_BOOTENV_H
+
+/*
+ * Define macros for label bootenv nvlist pair keys.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define        BOOTENV_VERSION         "version"
+
+#define        BE_ILLUMOS_VENDOR       "illumos"
+#define        BE_FREEBSD_VENDOR       "freebsd"
+#define        BE_GRUB_VENDOR          "grub"
+#define        BE_LINUX_VENDOR         "linux"
+
+#include <sys/zfs_bootenv_os.h>
+
+#define        GRUB_ENVMAP             BE_GRUB_VENDOR ":" "envmap"
+
+#define        FREEBSD_BOOTONCE        BE_FREEBSD_VENDOR ":" "bootonce"
+#define        FREEBSD_BOOTONCE_USED   BE_FREEBSD_VENDOR ":" "bootonce-used"
+#define        FREEBSD_NVSTORE         BE_FREEBSD_VENDOR ":" "nvstore"
+#define        ILLUMOS_BOOTONCE        BE_ILLUMOS_VENDOR ":" "bootonce"
+#define        ILLUMOS_BOOTONCE_USED   BE_ILLUMOS_VENDOR ":" "bootonce-used"
+#define        ILLUMOS_NVSTORE         BE_ILLUMOS_VENDOR ":" "nvstore"
+
+#define        OS_BOOTONCE             BOOTENV_OS ":" "bootonce"
+#define        OS_BOOTONCE_USED        BOOTENV_OS ":" "bootonce-used"
+#define        OS_NVSTORE              BOOTENV_OS ":" "nvstore"
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ZFS_BOOTENV_H */

Modified: head/sys/contrib/openzfs/include/sys/zfs_context.h
==============================================================================
--- head/sys/contrib/openzfs/include/sys/zfs_context.h  Fri Sep 18 22:59:44 
2020        (r365893)
+++ head/sys/contrib/openzfs/include/sys/zfs_context.h  Fri Sep 18 23:21:24 
2020        (r365894)
@@ -325,11 +325,15 @@ extern void cv_signal(kcondvar_t *cv);
 extern void cv_broadcast(kcondvar_t *cv);
 
 #define        cv_timedwait_io(cv, mp, at)             cv_timedwait(cv, mp, at)
+#define        cv_timedwait_idle(cv, mp, at)           cv_timedwait(cv, mp, at)
 #define        cv_timedwait_sig(cv, mp, at)            cv_timedwait(cv, mp, at)
 #define        cv_wait_io(cv, mp)                      cv_wait(cv, mp)
+#define        cv_wait_idle(cv, mp)                    cv_wait(cv, mp)

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to