From owner-svn-src-all@freebsd.org Fri Sep 4 22:25:19 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 25AA73D191C; Fri, 4 Sep 2020 22:25:19 +0000 (UTC) (envelope-from mmacy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Bjsgg0L6xz4gpr; Fri, 4 Sep 2020 22:25:19 +0000 (UTC) (envelope-from mmacy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DECC913B2B; Fri, 4 Sep 2020 22:25:18 +0000 (UTC) (envelope-from mmacy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 084MPILu049487; Fri, 4 Sep 2020 22:25:18 GMT (envelope-from mmacy@FreeBSD.org) Received: (from mmacy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 084MPE3K049467; Fri, 4 Sep 2020 22:25:14 GMT (envelope-from mmacy@FreeBSD.org) Message-Id: <202009042225.084MPE3K049467@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmacy set sender to mmacy@FreeBSD.org using -f From: Matt Macy Date: Fri, 4 Sep 2020 22:25:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r365347 - in head: lib/libbe sys/conf sys/contrib/openzfs sys/contrib/openzfs/cmd/zfs sys/contrib/openzfs/config sys/contrib/openzfs/etc/systemd/system sys/contrib/openzfs/etc/systemd/s... X-SVN-Group: head X-SVN-Commit-Author: mmacy X-SVN-Commit-Paths: in head: lib/libbe sys/conf sys/contrib/openzfs sys/contrib/openzfs/cmd/zfs sys/contrib/openzfs/config sys/contrib/openzfs/etc/systemd/system sys/contrib/openzfs/etc/systemd/system-generators sys/cont... X-SVN-Commit-Revision: 365347 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2020 22:25:19 -0000 Author: mmacy Date: Fri Sep 4 22:25:14 2020 New Revision: 365347 URL: https://svnweb.freebsd.org/changeset/base/365347 Log: ZFS: MFV 2.0-rc1-gfd20a8 - fixes jail delegation - fixes raw kstat unsupported complaints - exposes dbgmsg, dbuf, and checksum benchmark stats - restore rename -u support Added: head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vfsops_os.h - copied unchanged from r365345, vendor-sys/openzfs/dist/include/os/freebsd/zfs/sys/zfs_vfsops_os.h head/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vfsops_os.h - copied unchanged from r365345, vendor-sys/openzfs/dist/include/os/linux/zfs/sys/zfs_vfsops_os.h head/sys/contrib/openzfs/include/sys/zfs_vfsops.h - copied unchanged from r365345, vendor-sys/openzfs/dist/include/sys/zfs_vfsops.h head/sys/contrib/openzfs/lib/libspl/os/freebsd/zone.c - copied unchanged from r365345, vendor-sys/openzfs/dist/lib/libspl/os/freebsd/zone.c head/sys/contrib/openzfs/lib/libspl/os/linux/zone.c - copied unchanged from r365345, vendor-sys/openzfs/dist/lib/libspl/os/linux/zone.c head/sys/contrib/openzfs/module/zfs/spa_stats.c - copied unchanged from r365346, vendor-sys/openzfs/dist/module/zfs/spa_stats.c head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_nounmount.ksh - copied unchanged from r365345, vendor-sys/openzfs/dist/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_nounmount.ksh Deleted: head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vfsops.h head/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vfsops.h head/sys/contrib/openzfs/lib/libspl/zone.c head/sys/contrib/openzfs/module/os/freebsd/zfs/spa_stats.c head/sys/contrib/openzfs/module/os/linux/zfs/spa_stats.c Modified: head/lib/libbe/be.c head/sys/conf/files head/sys/contrib/openzfs/cmd/zfs/zfs_main.c head/sys/contrib/openzfs/config/kernel-global_page_state.m4 head/sys/contrib/openzfs/config/zfs-build.m4 head/sys/contrib/openzfs/etc/systemd/system-generators/zfs-mount-generator.in head/sys/contrib/openzfs/etc/systemd/system/zfs-mount.service.in head/sys/contrib/openzfs/include/libzfs.h head/sys/contrib/openzfs/include/libzfs_impl.h head/sys/contrib/openzfs/include/os/freebsd/spl/sys/cred.h head/sys/contrib/openzfs/include/os/freebsd/spl/sys/zone.h head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/Makefile.am head/sys/contrib/openzfs/include/os/linux/kernel/linux/page_compat.h head/sys/contrib/openzfs/include/os/linux/spl/sys/vmsystm.h head/sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am head/sys/contrib/openzfs/include/sys/Makefile.am head/sys/contrib/openzfs/lib/libspl/Makefile.am head/sys/contrib/openzfs/lib/libspl/include/limits.h head/sys/contrib/openzfs/lib/libspl/include/zone.h head/sys/contrib/openzfs/lib/libzfs/libzfs_changelist.c head/sys/contrib/openzfs/lib/libzfs/libzfs_dataset.c head/sys/contrib/openzfs/lib/libzpool/kernel.c head/sys/contrib/openzfs/man/man8/zfs-rename.8 head/sys/contrib/openzfs/module/avl/avl.c head/sys/contrib/openzfs/module/nvpair/nvpair.c head/sys/contrib/openzfs/module/os/freebsd/spl/spl_kstat.c head/sys/contrib/openzfs/module/os/freebsd/spl/spl_zone.c head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c head/sys/contrib/openzfs/module/os/freebsd/zfs/zvol_os.c head/sys/contrib/openzfs/module/os/linux/spl/spl-kstat.c head/sys/contrib/openzfs/module/os/linux/zfs/Makefile.in head/sys/contrib/openzfs/module/os/linux/zfs/arc_os.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/zfs/Makefile.in head/sys/contrib/openzfs/module/zfs/arc.c head/sys/contrib/openzfs/module/zfs/dsl_dir.c head/sys/contrib/openzfs/module/zfs/spa.c head/sys/contrib/openzfs/module/zfs/spa_config.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_raidz.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/tests/runfiles/common.run head/sys/contrib/openzfs/tests/zfs-tests/include/tunables.cfg head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/Makefile.am head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_mountpoint.ksh Directory Properties: head/sys/contrib/openzfs/ (props changed) head/sys/contrib/openzfs/zfs.release.in (props changed) Modified: head/lib/libbe/be.c ============================================================================== --- head/lib/libbe/be.c Fri Sep 4 22:11:58 2020 (r365346) +++ head/lib/libbe/be.c Fri Sep 4 22:25:14 2020 (r365347) @@ -996,8 +996,11 @@ be_rename(libbe_handle_t *lbh, const char *old, const ZFS_TYPE_FILESYSTEM)) == NULL) return (set_error(lbh, BE_ERR_ZFSOPEN)); - - err = zfs_rename(zfs_hdl,full_new, B_FALSE, B_FALSE); + /* recurse, nounmount, forceunmount */ + struct renameflags flags = { + .nounmount = 1, + }; + err = zfs_rename(zfs_hdl, full_new, flags); zfs_close(zfs_hdl); if (err != 0) Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Fri Sep 4 22:11:58 2020 (r365346) +++ head/sys/conf/files Fri Sep 4 22:25:14 2020 (r365347) @@ -206,7 +206,6 @@ contrib/openzfs/module/os/freebsd/zfs/dmu_os.c option contrib/openzfs/module/os/freebsd/zfs/hkdf.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/os/freebsd/zfs/kmod_core.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/os/freebsd/zfs/spa_os.c optional zfs compile-with "${ZFS_C}" -contrib/openzfs/module/os/freebsd/zfs/spa_stats.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/os/freebsd/zfs/sysctl_os.c optional zfs compile-with "${ZFS_C} -include $S/modules/zfs/zfs_config.h" contrib/openzfs/module/os/freebsd/zfs/vdev_file.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/os/freebsd/zfs/vdev_label_os.c optional zfs compile-with "${ZFS_C}" @@ -304,6 +303,7 @@ contrib/openzfs/module/zfs/spa_errlog.c optional zfs contrib/openzfs/module/zfs/spa_history.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/zfs/spa_log_spacemap.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/zfs/spa_misc.c optional zfs compile-with "${ZFS_C}" +contrib/openzfs/module/zfs/spa_stats.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/zfs/space_map.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/zfs/space_reftree.c optional zfs compile-with "${ZFS_C}" contrib/openzfs/module/zfs/txg.c optional zfs compile-with "${ZFS_C}" Modified: head/sys/contrib/openzfs/cmd/zfs/zfs_main.c ============================================================================== --- head/sys/contrib/openzfs/cmd/zfs/zfs_main.c Fri Sep 4 22:11:58 2020 (r365346) +++ head/sys/contrib/openzfs/cmd/zfs/zfs_main.c Fri Sep 4 22:25:14 2020 (r365347) @@ -311,7 +311,8 @@ get_usage(zfs_help_t idx) case HELP_RENAME: return (gettext("\trename [-f] " "\n" - "\trename [-f] -p \n" + "\trename -p [-f] \n" + "\trename -u [-f] \n" "\trename -r \n")); case HELP_ROLLBACK: return (gettext("\trollback [-rRf] \n")); @@ -401,7 +402,7 @@ get_usage(zfs_help_t idx) "<-a | filesystem|volume>\n")); case HELP_CHANGE_KEY: return (gettext("\tchange-key [-l] [-o keyformat=]\n" - "\t [-o keylocation=] [-o pbkfd2iters=]\n" + "\t [-o keylocation=] [-o pbkdf2iters=]\n" "\t \n" "\tchange-key -i [-l] \n")); case HELP_VERSION: @@ -3603,36 +3604,40 @@ zfs_do_list(int argc, char **argv) } /* - * zfs rename [-f] + * zfs rename [-fu] * zfs rename [-f] -p - * zfs rename -r + * zfs rename [-u] -r * * Renames the given dataset to another of the same type. * * The '-p' flag creates all the non-existing ancestors of the target first. + * The '-u' flag prevents file systems from being remounted during rename. */ /* ARGSUSED */ static int zfs_do_rename(int argc, char **argv) { zfs_handle_t *zhp; + renameflags_t flags = { 0 }; int c; int ret = 0; - boolean_t recurse = B_FALSE; + int types; boolean_t parents = B_FALSE; - boolean_t force_unmount = B_FALSE; /* check options */ - while ((c = getopt(argc, argv, "prf")) != -1) { + while ((c = getopt(argc, argv, "pruf")) != -1) { switch (c) { case 'p': parents = B_TRUE; break; case 'r': - recurse = B_TRUE; + flags.recursive = B_TRUE; break; + case 'u': + flags.nounmount = B_TRUE; + break; case 'f': - force_unmount = B_TRUE; + flags.forceunmount = B_TRUE; break; case '?': default: @@ -3661,20 +3666,32 @@ zfs_do_rename(int argc, char **argv) usage(B_FALSE); } - if (recurse && parents) { + if (flags.recursive && parents) { (void) fprintf(stderr, gettext("-p and -r options are mutually " "exclusive\n")); usage(B_FALSE); } - if (recurse && strchr(argv[0], '@') == 0) { + if (flags.nounmount && parents) { + (void) fprintf(stderr, gettext("-u and -p options are mutually " + "exclusive\n")); + usage(B_FALSE); + } + + if (flags.recursive && strchr(argv[0], '@') == 0) { (void) fprintf(stderr, gettext("source dataset for recursive " "rename must be a snapshot\n")); usage(B_FALSE); } - if ((zhp = zfs_open(g_zfs, argv[0], parents ? ZFS_TYPE_FILESYSTEM | - ZFS_TYPE_VOLUME : ZFS_TYPE_DATASET)) == NULL) + if (flags.nounmount) + types = ZFS_TYPE_FILESYSTEM; + else if (parents) + types = ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME; + else + types = ZFS_TYPE_DATASET; + + if ((zhp = zfs_open(g_zfs, argv[0], types)) == NULL) return (1); /* If we were asked and the name looks good, try to create ancestors. */ @@ -3684,7 +3701,7 @@ zfs_do_rename(int argc, char **argv) return (1); } - ret = (zfs_rename(zhp, argv[1], recurse, force_unmount) != 0); + ret = (zfs_rename(zhp, argv[1], flags) != 0); zfs_close(zhp); return (ret); Modified: head/sys/contrib/openzfs/config/kernel-global_page_state.m4 ============================================================================== --- head/sys/contrib/openzfs/config/kernel-global_page_state.m4 Fri Sep 4 22:11:58 2020 (r365346) +++ head/sys/contrib/openzfs/config/kernel-global_page_state.m4 Fri Sep 4 22:25:14 2020 (r365347) @@ -94,9 +94,6 @@ AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_ZONE_PAGE_STATE_SANITY] ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_CHECK([NR_FILE_PAGES]) ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_CHECK([NR_INACTIVE_ANON]) ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_CHECK([NR_INACTIVE_FILE]) - AS_IF([test -z "$ZFS_ENUM_NODE_STAT_ITEM_NR_SLAB_RECLAIMABLE_B"],[ - ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_CHECK([NR_SLAB_RECLAIMABLE]) - ]) AC_MSG_RESULT(yes) ]) @@ -119,18 +116,12 @@ AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_PAGE_STATE], [ [node_stat_item], [$LINUX/include/linux/mmzone.h]) ZFS_AC_KERNEL_ENUM_MEMBER([NR_INACTIVE_FILE], [node_stat_item], [$LINUX/include/linux/mmzone.h]) - ZFS_AC_KERNEL_ENUM_MEMBER([NR_SLAB_RECLAIMABLE], - [node_stat_item], [$LINUX/include/linux/mmzone.h]) - ZFS_AC_KERNEL_ENUM_MEMBER([NR_SLAB_RECLAIMABLE_B], - [node_stat_item], [$LINUX/include/linux/mmzone.h]) ZFS_AC_KERNEL_ENUM_MEMBER([NR_FILE_PAGES], [zone_stat_item], [$LINUX/include/linux/mmzone.h]) ZFS_AC_KERNEL_ENUM_MEMBER([NR_INACTIVE_ANON], [zone_stat_item], [$LINUX/include/linux/mmzone.h]) ZFS_AC_KERNEL_ENUM_MEMBER([NR_INACTIVE_FILE], - [zone_stat_item], [$LINUX/include/linux/mmzone.h]) - ZFS_AC_KERNEL_ENUM_MEMBER([NR_SLAB_RECLAIMABLE], [zone_stat_item], [$LINUX/include/linux/mmzone.h]) ZFS_AC_KERNEL_GLOBAL_ZONE_PAGE_STATE_SANITY Modified: head/sys/contrib/openzfs/config/zfs-build.m4 ============================================================================== --- head/sys/contrib/openzfs/config/zfs-build.m4 Fri Sep 4 22:11:58 2020 (r365346) +++ head/sys/contrib/openzfs/config/zfs-build.m4 Fri Sep 4 22:25:14 2020 (r365347) @@ -418,33 +418,43 @@ dnl # package type for 'make pkg': (rpm | deb | tgz) dnl # AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [ AC_MSG_CHECKING([os distribution]) - if test -f /etc/toss-release ; then - VENDOR=toss ; - elif test -f /etc/fedora-release ; then - VENDOR=fedora ; - elif test -f /etc/redhat-release ; then - VENDOR=redhat ; - elif test -f /etc/gentoo-release ; then - VENDOR=gentoo ; - elif test -f /etc/arch-release ; then - VENDOR=arch ; - elif test -f /etc/SuSE-release ; then - VENDOR=sles ; - elif test -f /etc/slackware-version ; then - VENDOR=slackware ; - elif test -f /etc/lunar.release ; then - VENDOR=lunar ; - elif test -f /etc/lsb-release ; then - VENDOR=ubuntu ; - elif test -f /etc/debian_version ; then - VENDOR=debian ; - elif test -f /etc/alpine-release ; then - VENDOR=alpine ; - elif test -f /bin/freebsd-version ; then - VENDOR=freebsd ; - else - VENDOR= ; - fi + AC_ARG_WITH([vendor], + [AS_HELP_STRING([--with-vendor], + [Distribution vendor @<:@default=check@:>@])], + [with_vendor=$withval], + [with_vendor=check]) + AS_IF([test "x$with_vendor" = "xcheck"],[ + if test -f /etc/toss-release ; then + VENDOR=toss ; + elif test -f /etc/fedora-release ; then + VENDOR=fedora ; + elif test -f /etc/redhat-release ; then + VENDOR=redhat ; + elif test -f /etc/gentoo-release ; then + VENDOR=gentoo ; + elif test -f /etc/arch-release ; then + VENDOR=arch ; + elif test -f /etc/SuSE-release ; then + VENDOR=sles ; + elif test -f /etc/slackware-version ; then + VENDOR=slackware ; + elif test -f /etc/lunar.release ; then + VENDOR=lunar ; + elif test -f /etc/lsb-release ; then + VENDOR=ubuntu ; + elif test -f /etc/debian_version ; then + VENDOR=debian ; + elif test -f /etc/alpine-release ; then + VENDOR=alpine ; + elif test -f /bin/freebsd-version ; then + VENDOR=freebsd ; + else + VENDOR= ; + fi], + [ test "x${with_vendor}" != x],[ + VENDOR="$with_vendor" ], + [ VENDOR= ; ] + ) AC_MSG_RESULT([$VENDOR]) AC_SUBST(VENDOR) Modified: head/sys/contrib/openzfs/etc/systemd/system-generators/zfs-mount-generator.in ============================================================================== --- head/sys/contrib/openzfs/etc/systemd/system-generators/zfs-mount-generator.in Fri Sep 4 22:11:58 2020 (r365346) +++ head/sys/contrib/openzfs/etc/systemd/system-generators/zfs-mount-generator.in Fri Sep 4 22:25:14 2020 (r365347) @@ -38,8 +38,6 @@ do_fail() { is_known() { query="$1" IFS=' ' - # protect against special characters - set -f for element in $2 ; do if [ "$query" = "$element" ] ; then return 0 @@ -54,8 +52,7 @@ is_known() { create_dependencies() { unitfile="$1" suffix="$2" - # protect against special characters - set -f + IFS=' ' for target in $3 ; do target_dir="${dest_norm}/${target}.${suffix}/" mkdir -p "${target_dir}" @@ -72,6 +69,7 @@ else do_fail "zero or three arguments required" fi +pools=$(zpool list -H -o name || true) # All needed information about each ZFS is available from # zfs list -H -t filesystem -o @@ -83,11 +81,11 @@ process_line() { # zfs list -H -o name,... # fields are tab separated IFS="$(printf '\t')" - # protect against special characters in, e.g., mountpoints - set -f # shellcheck disable=SC2086 set -- $1 + dataset="${1}" + pool="${dataset%%/*}" p_mountpoint="${2}" p_canmount="${3}" p_atime="${4}" @@ -120,6 +118,25 @@ process_line() { requiredby="" noauto="off" + # If the pool is already imported, zfs-import.target is not needed. This + # avoids a dependency loop on root-on-ZFS systems: + # systemd-random-seed.service After (via RequiresMountsFor) var-lib.mount + # After zfs-import.target After zfs-import-{cache,scan}.service After + # cryptsetup.service After systemd-random-seed.service. + # + # Pools are newline-separated and may contain spaces in their names. + # There is no better portable way to set IFS to just a newline. Using + # $(printf '\n') doesn't work because $(...) strips trailing newlines. + IFS=" +" + for p in $pools ; do + if [ "$p" = "$pool" ] ; then + after="" + wants="" + break + fi + done + if [ -n "${p_systemd_after}" ] && \ [ "${p_systemd_after}" != "-" ] ; then after="${p_systemd_after} ${after}" @@ -204,6 +221,10 @@ ${keymountdep} [Service] Type=oneshot RemainAfterExit=yes +# This avoids a dependency loop involving systemd-journald.socket if this +# dataset is a parent of the root filesystem. +StandardOutput=null +StandardError=null ExecStart=${keyloadcmd} ExecStop=${keyunloadcmd}" > "${dest_norm}/${keyloadunit}" fi @@ -438,6 +459,8 @@ Options=defaults${opts},zfsutil" > "${dest_norm}/${mou } for cachefile in "${FSLIST}/"* ; do + # Disable glob expansion to protect against special characters when parsing. + set -f # Sort cachefile's lines by canmount, "on" before "noauto" # and feed each line into process_line sort -t "$(printf '\t')" -k 3 -r "${cachefile}" | \ Modified: head/sys/contrib/openzfs/etc/systemd/system/zfs-mount.service.in ============================================================================== --- head/sys/contrib/openzfs/etc/systemd/system/zfs-mount.service.in Fri Sep 4 22:11:58 2020 (r365346) +++ head/sys/contrib/openzfs/etc/systemd/system/zfs-mount.service.in Fri Sep 4 22:25:14 2020 (r365347) @@ -6,7 +6,6 @@ After=systemd-udev-settle.service After=zfs-import.target After=systemd-remount-fs.service Before=local-fs.target -Before=systemd-random-seed.service ConditionPathIsDirectory=/sys/module/zfs [Service] Modified: head/sys/contrib/openzfs/include/libzfs.h ============================================================================== --- head/sys/contrib/openzfs/include/libzfs.h Fri Sep 4 22:11:58 2020 (r365346) +++ head/sys/contrib/openzfs/include/libzfs.h Fri Sep 4 22:25:14 2020 (r365347) @@ -642,7 +642,19 @@ extern int zfs_snapshot(libzfs_handle_t *, const char extern int zfs_snapshot_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, nvlist_t *props); extern int zfs_rollback(zfs_handle_t *, zfs_handle_t *, boolean_t); -extern int zfs_rename(zfs_handle_t *, const char *, boolean_t, boolean_t); + +typedef struct renameflags { + /* recursive rename */ + int recursive : 1; + + /* don't unmount file systems */ + int nounmount : 1; + + /* force unmount file systems */ + int forceunmount : 1; +} renameflags_t; + +extern int zfs_rename(zfs_handle_t *, const char *, renameflags_t); typedef struct sendflags { /* Amount of extra information to print. */ Modified: head/sys/contrib/openzfs/include/libzfs_impl.h ============================================================================== --- head/sys/contrib/openzfs/include/libzfs_impl.h Fri Sep 4 22:11:58 2020 (r365346) +++ head/sys/contrib/openzfs/include/libzfs_impl.h Fri Sep 4 22:25:14 2020 (r365347) @@ -166,6 +166,10 @@ int zprop_expand_list(libzfs_handle_t *hdl, zprop_list * changelist_gather() flag to force it to iterate on mounted datasets only */ #define CL_GATHER_ITER_MOUNTED 2 +/* + * Use this changelist_gather() flag to prevent unmounting of file systems. + */ +#define CL_GATHER_DONT_UNMOUNT 4 typedef struct prop_changelist prop_changelist_t; Modified: head/sys/contrib/openzfs/include/os/freebsd/spl/sys/cred.h ============================================================================== --- head/sys/contrib/openzfs/include/os/freebsd/spl/sys/cred.h Fri Sep 4 22:11:58 2020 (r365346) +++ head/sys/contrib/openzfs/include/os/freebsd/spl/sys/cred.h Fri Sep 4 22:25:14 2020 (r365347) @@ -93,7 +93,7 @@ extern cred_t *zone_kcred(void); extern gid_t crgetrgid(const cred_t *); extern gid_t crgetsgid(const cred_t *); -#define crgetzoneid(x) (0) +#define crgetzoneid(cr) ((cr)->cr_prison->pr_id) extern projid_t crgetprojid(const cred_t *); extern cred_t *crgetmapped(const cred_t *); Modified: head/sys/contrib/openzfs/include/os/freebsd/spl/sys/zone.h ============================================================================== --- head/sys/contrib/openzfs/include/os/freebsd/spl/sys/zone.h Fri Sep 4 22:11:58 2020 (r365346) +++ head/sys/contrib/openzfs/include/os/freebsd/spl/sys/zone.h Fri Sep 4 22:25:14 2020 (r365347) @@ -29,6 +29,8 @@ #ifndef _OPENSOLARIS_SYS_ZONE_H_ #define _OPENSOLARIS_SYS_ZONE_H_ +#include + /* * Macros to help with zone visibility restrictions. */ @@ -36,12 +38,9 @@ #define GLOBAL_ZONEID 0 /* - * Is thread in the global zone? + * Is proc in the global zone? */ -#define INGLOBALZONE(p) in_globalzone((p)) - - -extern boolean_t in_globalzone(struct proc *); +#define INGLOBALZONE(proc) (!jailed((proc)->p_ucred)) /* * Attach the given dataset to the given jail. 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 4 22:11:58 2020 (r365346) +++ head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/Makefile.am Fri Sep 4 22:25:14 2020 (r365347) @@ -6,7 +6,7 @@ KERNEL_H = \ zfs_ctldir.h \ zfs_dir.h \ zfs_ioctl_compat.h \ - zfs_vfsops.h \ + zfs_vfsops_os.h \ zfs_vnops.h \ zfs_znode_impl.h \ zpl.h Copied: head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vfsops_os.h (from r365345, vendor-sys/openzfs/dist/include/os/freebsd/zfs/sys/zfs_vfsops_os.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_vfsops_os.h Fri Sep 4 22:25:14 2020 (r365347, copy of r365345, vendor-sys/openzfs/dist/include/os/freebsd/zfs/sys/zfs_vfsops_os.h) @@ -0,0 +1,176 @@ +/* + * 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) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011 Pawel Jakub Dawidek . + * All rights reserved. + */ + +#ifndef _SYS_FS_ZFS_VFSOPS_H +#define _SYS_FS_ZFS_VFSOPS_H + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct zfsvfs zfsvfs_t; +struct znode; + +struct zfsvfs { + vfs_t *z_vfs; /* generic fs struct */ + zfsvfs_t *z_parent; /* parent fs */ + objset_t *z_os; /* objset reference */ + uint64_t z_flags; /* super_block flags */ + uint64_t z_root; /* id of root znode */ + uint64_t z_unlinkedobj; /* id of unlinked zapobj */ + uint64_t z_max_blksz; /* maximum block size for files */ + uint64_t z_fuid_obj; /* fuid table object number */ + uint64_t z_fuid_size; /* fuid table size */ + avl_tree_t z_fuid_idx; /* fuid tree keyed by index */ + avl_tree_t z_fuid_domain; /* fuid tree keyed by domain */ + krwlock_t z_fuid_lock; /* fuid lock */ + boolean_t z_fuid_loaded; /* fuid tables are loaded */ + boolean_t z_fuid_dirty; /* need to sync fuid table ? */ + struct zfs_fuid_info *z_fuid_replay; /* fuid info for replay */ + zilog_t *z_log; /* intent log pointer */ + uint_t z_acl_mode; /* acl chmod/mode behavior */ + uint_t z_acl_inherit; /* acl inheritance behavior */ + zfs_case_t z_case; /* case-sense */ + boolean_t z_utf8; /* utf8-only */ + int z_norm; /* normalization flags */ + boolean_t z_atime; /* enable atimes mount option */ + boolean_t z_unmounted; /* unmounted */ + rrmlock_t z_teardown_lock; + krwlock_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 */ + struct zfsctl_root *z_ctldir; /* .zfs directory pointer */ + boolean_t z_show_ctldir; /* expose .zfs in the root dir */ + boolean_t z_issnap; /* true if this is a snapshot */ + boolean_t z_vscan; /* virus scan on/off */ + boolean_t z_use_fuids; /* version allows fuids */ + boolean_t z_replay; /* set during ZIL replay */ + boolean_t z_use_sa; /* version allow system attributes */ + boolean_t z_xattr_sa; /* allow xattrs to be stores as SA */ + boolean_t z_use_namecache; /* make use of FreeBSD name cache */ + uint8_t z_xattr; /* xattr type in use */ + uint64_t z_version; /* ZPL version */ + uint64_t z_shares_dir; /* hidden shares dir */ + dataset_kstats_t z_kstat; /* fs kstats */ + kmutex_t z_lock; + uint64_t z_userquota_obj; + uint64_t z_groupquota_obj; + uint64_t z_userobjquota_obj; + uint64_t z_groupobjquota_obj; + uint64_t z_projectquota_obj; + uint64_t z_projectobjquota_obj; + uint64_t z_replay_eof; /* New end of file - replay only */ + sa_attr_type_t *z_attr_table; /* SA attr mapping->id */ +#define ZFS_OBJ_MTX_SZ 64 + kmutex_t z_hold_mtx[ZFS_OBJ_MTX_SZ]; /* znode hold locks */ + struct task z_unlinked_drain_task; +}; + +#define ZSB_XATTR 0x0001 /* Enable user xattrs */ +/* + * Normal filesystems (those not under .zfs/snapshot) have a total + * file ID size limited to 12 bytes (including the length field) due to + * NFSv2 protocol's limitation of 32 bytes for a filehandle. For historical + * reasons, this same limit is being imposed by the Solaris NFSv3 implementation + * (although the NFSv3 protocol actually permits a maximum of 64 bytes). It + * is not possible to expand beyond 12 bytes without abandoning support + * of NFSv2. + * + * For normal filesystems, we partition up the available space as follows: + * 2 bytes fid length (required) + * 6 bytes object number (48 bits) + * 4 bytes generation number (32 bits) + * + * We reserve only 48 bits for the object number, as this is the limit + * currently defined and imposed by the DMU. + */ +typedef struct zfid_short { + uint16_t zf_len; + uint8_t zf_object[6]; /* obj[i] = obj >> (8 * i) */ + uint8_t zf_gen[4]; /* gen[i] = gen >> (8 * i) */ +} zfid_short_t; + +/* + * Filesystems under .zfs/snapshot have a total file ID size of 22[*] bytes + * (including the length field). This makes files under .zfs/snapshot + * accessible by NFSv3 and NFSv4, but not NFSv2. + * + * For files under .zfs/snapshot, we partition up the available space + * as follows: + * 2 bytes fid length (required) + * 6 bytes object number (48 bits) + * 4 bytes generation number (32 bits) + * 6 bytes objset id (48 bits) + * 4 bytes[**] currently just zero (32 bits) + * + * We reserve only 48 bits for the object number and objset id, as these are + * the limits currently defined and imposed by the DMU. + * + * [*] 20 bytes on FreeBSD to fit into the size of struct fid. + * [**] 2 bytes on FreeBSD for the above reason. + */ +typedef struct zfid_long { + zfid_short_t z_fid; + uint8_t zf_setid[6]; /* obj[i] = obj >> (8 * i) */ + uint8_t zf_setgen[2]; /* gen[i] = gen >> (8 * i) */ +} zfid_long_t; + +#define SHORT_FID_LEN (sizeof (zfid_short_t) - sizeof (uint16_t)) +#define LONG_FID_LEN (sizeof (zfid_long_t) - sizeof (uint16_t)) + +extern uint_t zfs_fsyncer_key; +extern int zfs_super_owner; + +extern void zfs_init(void); +extern void zfs_fini(void); + +extern int zfs_suspend_fs(zfsvfs_t *zfsvfs); +extern int zfs_resume_fs(zfsvfs_t *zfsvfs, struct dsl_dataset *ds); +extern int zfs_end_fs(zfsvfs_t *zfsvfs, struct dsl_dataset *ds); +extern int zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers); +extern int zfsvfs_create(const char *name, boolean_t readonly, zfsvfs_t **zfvp); +extern int zfsvfs_create_impl(zfsvfs_t **zfvp, zfsvfs_t *zfsvfs, objset_t *os); +extern void zfsvfs_free(zfsvfs_t *zfsvfs); +extern int zfs_check_global_label(const char *dsname, const char *hexsl); +extern boolean_t zfs_is_readonly(zfsvfs_t *zfsvfs); +extern int zfs_get_temporary_prop(struct dsl_dataset *ds, zfs_prop_t zfs_prop, + uint64_t *val, char *setpoint); +extern int zfs_busy(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_ZFS_VFSOPS_H */ Modified: head/sys/contrib/openzfs/include/os/linux/kernel/linux/page_compat.h ============================================================================== --- head/sys/contrib/openzfs/include/os/linux/kernel/linux/page_compat.h Fri Sep 4 22:11:58 2020 (r365346) +++ head/sys/contrib/openzfs/include/os/linux/kernel/linux/page_compat.h Fri Sep 4 22:25:14 2020 (r365347) @@ -35,16 +35,6 @@ #else #define nr_inactive_file_pages() global_zone_page_state(NR_INACTIVE_FILE) #endif -#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_SLAB_RECLAIMABLE_B) -#define nr_slab_reclaimable_pages() \ - global_node_page_state(NR_SLAB_RECLAIMABLE_B) -#else -#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_SLAB_RECLAIMABLE) -#define nr_slab_reclaimable_pages() global_node_page_state(NR_SLAB_RECLAIMABLE) -#else -#define nr_slab_reclaimable_pages() global_zone_page_state(NR_SLAB_RECLAIMABLE) -#endif -#endif #elif defined(ZFS_GLOBAL_NODE_PAGE_STATE) @@ -64,16 +54,6 @@ #else #define nr_inactive_file_pages() global_page_state(NR_INACTIVE_FILE) #endif -#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_SLAB_RECLAIMABLE_B) -#define nr_slab_reclaimable_pages() \ - global_node_page_state(NR_SLAB_RECLAIMABLE_B) -#else -#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_SLAB_RECLAIMABLE) -#define nr_slab_reclaimable_pages() global_node_page_state(NR_SLAB_RECLAIMABLE) -#else -#define nr_slab_reclaimable_pages() global_page_state(NR_SLAB_RECLAIMABLE) -#endif -#endif #else @@ -81,11 +61,6 @@ #define nr_file_pages() global_page_state(NR_FILE_PAGES) #define nr_inactive_anon_pages() global_page_state(NR_INACTIVE_ANON) #define nr_inactive_file_pages() global_page_state(NR_INACTIVE_FILE) -#ifdef ZFS_ENUM_NODE_STAT_ITEM_NR_SLAB_RECLAIMABLE_B -#define nr_slab_reclaimable_pages() global_page_state(NR_SLAB_RECLAIMABLE_B) -#else -#define nr_slab_reclaimable_pages() global_page_state(NR_SLAB_RECLAIMABLE) -#endif /* ZFS_ENUM_NODE_STAT_ITEM_NR_SLAB_RECLAIMABLE_B */ #endif /* ZFS_GLOBAL_ZONE_PAGE_STATE */ Modified: head/sys/contrib/openzfs/include/os/linux/spl/sys/vmsystm.h ============================================================================== --- head/sys/contrib/openzfs/include/os/linux/spl/sys/vmsystm.h Fri Sep 4 22:11:58 2020 (r365346) +++ head/sys/contrib/openzfs/include/os/linux/spl/sys/vmsystm.h Fri Sep 4 22:25:14 2020 (r365347) @@ -47,17 +47,6 @@ #define membar_producer() smp_wmb() #define physmem zfs_totalram_pages -#ifdef ZFS_ENUM_NODE_STAT_ITEM_NR_SLAB_RECLAIMABLE_B -#define freemem (nr_free_pages() + \ - global_page_state(NR_INACTIVE_FILE) + \ - global_page_state(NR_INACTIVE_ANON) + \ - global_page_state(NR_SLAB_RECLAIMABLE_B)) -#else -#define freemem (nr_free_pages() + \ - global_page_state(NR_INACTIVE_FILE) + \ - global_page_state(NR_INACTIVE_ANON) + \ - global_page_state(NR_SLAB_RECLAIMABLE)) -#endif /* ZFS_ENUM_NODE_STAT_ITEM_NR_SLAB_RECLAIMABLE_B */ #define xcopyin(from, to, size) copy_from_user(to, from, size) #define xcopyout(from, to, size) copy_to_user(to, from, size) 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 4 22:11:58 2020 (r365346) +++ head/sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am Fri Sep 4 22:25:14 2020 (r365347) @@ -19,7 +19,7 @@ KERNEL_H = \ zfs_context_os.h \ zfs_ctldir.h \ zfs_dir.h \ - zfs_vfsops.h \ + zfs_vfsops_os.h \ zfs_vnops.h \ zfs_znode_impl.h \ zpl.h Copied: head/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vfsops_os.h (from r365345, vendor-sys/openzfs/dist/include/os/linux/zfs/sys/zfs_vfsops_os.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vfsops_os.h Fri Sep 4 22:25:14 2020 (r365347, copy of r365345, vendor-sys/openzfs/dist/include/os/linux/zfs/sys/zfs_vfsops_os.h) @@ -0,0 +1,227 @@ +/* + * 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) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018 by Delphix. All rights reserved. + */ + +#ifndef _SYS_FS_ZFS_VFSOPS_H +#define _SYS_FS_ZFS_VFSOPS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct zfsvfs zfsvfs_t; +struct znode; + +/* + * This structure emulates the vfs_t from other platforms. It's purpose + * is to facilitate the handling of mount options and minimize structural + * differences between the platforms. + */ +typedef struct vfs { + struct zfsvfs *vfs_data; + char *vfs_mntpoint; /* Primary mount point */ + uint64_t vfs_xattr; + boolean_t vfs_readonly; + boolean_t vfs_do_readonly; + boolean_t vfs_setuid; + boolean_t vfs_do_setuid; + boolean_t vfs_exec; + boolean_t vfs_do_exec; + boolean_t vfs_devices; + boolean_t vfs_do_devices; + boolean_t vfs_do_xattr; + boolean_t vfs_atime; + boolean_t vfs_do_atime; + boolean_t vfs_relatime; + boolean_t vfs_do_relatime; + boolean_t vfs_nbmand; + boolean_t vfs_do_nbmand; +} vfs_t; + +typedef struct zfs_mnt { + const char *mnt_osname; /* Objset name */ + char *mnt_data; /* Raw mount options */ +} zfs_mnt_t; + +struct zfsvfs { + vfs_t *z_vfs; /* generic fs struct */ + struct super_block *z_sb; /* generic super_block */ + struct zfsvfs *z_parent; /* parent fs */ + objset_t *z_os; /* objset reference */ + uint64_t z_flags; /* super_block flags */ + uint64_t z_root; /* id of root znode */ + uint64_t z_unlinkedobj; /* id of unlinked zapobj */ + uint64_t z_max_blksz; /* maximum block size for files */ + uint64_t z_fuid_obj; /* fuid table object number */ + uint64_t z_fuid_size; /* fuid table size */ + avl_tree_t z_fuid_idx; /* fuid tree keyed by index */ + avl_tree_t z_fuid_domain; /* fuid tree keyed by domain */ + krwlock_t z_fuid_lock; /* fuid lock */ + boolean_t z_fuid_loaded; /* fuid tables are loaded */ + boolean_t z_fuid_dirty; /* need to sync fuid table ? */ + struct zfs_fuid_info *z_fuid_replay; /* fuid info for replay */ + zilog_t *z_log; /* intent log pointer */ + uint_t z_acl_mode; /* acl chmod/mode behavior */ + uint_t z_acl_inherit; /* acl inheritance behavior */ + uint_t z_acl_type; /* type of ACL usable on this FS */ + zfs_case_t z_case; /* case-sense */ + boolean_t z_utf8; /* utf8-only */ + int z_norm; /* normalization flags */ + boolean_t z_relatime; /* enable relatime mount option */ + boolean_t z_unmounted; /* unmounted */ + rrmlock_t z_teardown_lock; + krwlock_t z_teardown_inactive_lock; + list_t z_all_znodes; /* all znodes in the fs */ + uint64_t z_nr_znodes; /* number of znodes in the fs */ + unsigned long z_rollback_time; /* last online rollback time */ + unsigned long z_snap_defer_time; /* last snapshot unmount deferral */ + kmutex_t z_znodes_lock; /* lock for z_all_znodes */ + arc_prune_t *z_arc_prune; /* called by ARC to prune caches */ + struct inode *z_ctldir; /* .zfs directory inode */ + boolean_t z_show_ctldir; /* expose .zfs in the root dir */ + boolean_t z_issnap; /* true if this is a snapshot */ + boolean_t z_vscan; /* virus scan on/off */ + boolean_t z_use_fuids; /* version allows fuids */ + boolean_t z_replay; /* set during ZIL replay */ + boolean_t z_use_sa; /* version allow system attributes */ + boolean_t z_xattr_sa; /* allow xattrs to be stores as SA */ + boolean_t z_draining; /* is true when drain is active */ + boolean_t z_drain_cancel; /* signal the unlinked drain to stop */ + uint64_t z_version; /* ZPL version */ + uint64_t z_shares_dir; /* hidden shares dir */ + dataset_kstats_t z_kstat; /* fs kstats */ + kmutex_t z_lock; + uint64_t z_userquota_obj; + uint64_t z_groupquota_obj; + uint64_t z_userobjquota_obj; + uint64_t z_groupobjquota_obj; + uint64_t z_projectquota_obj; + uint64_t z_projectobjquota_obj; + uint64_t z_replay_eof; /* New end of file - replay only */ + sa_attr_type_t *z_attr_table; /* SA attr mapping->id */ + uint64_t z_hold_size; /* znode hold array size */ + avl_tree_t *z_hold_trees; /* znode hold trees */ + kmutex_t *z_hold_locks; /* znode hold locks */ + taskqid_t z_drain_task; /* task id for the unlink drain task */ +}; + +#define ZSB_XATTR 0x0001 /* Enable user xattrs */ + +/* + * Allow a maximum number of links. While ZFS does not internally limit + * this the inode->i_nlink member is defined as an unsigned int. To be + * safe we use 2^31-1 as the limit. + */ +#define ZFS_LINK_MAX ((1U << 31) - 1U) + +/* + * Normal filesystems (those not under .zfs/snapshot) have a total + * file ID size limited to 12 bytes (including the length field) due to + * NFSv2 protocol's limitation of 32 bytes for a filehandle. For historical + * reasons, this same limit is being imposed by the Solaris NFSv3 implementation + * (although the NFSv3 protocol actually permits a maximum of 64 bytes). It + * is not possible to expand beyond 12 bytes without abandoning support + * of NFSv2. + * + * For normal filesystems, we partition up the available space as follows: + * 2 bytes fid length (required) + * 6 bytes object number (48 bits) + * 4 bytes generation number (32 bits) + * + * We reserve only 48 bits for the object number, as this is the limit + * currently defined and imposed by the DMU. + */ +typedef struct zfid_short { + uint16_t zf_len; + uint8_t zf_object[6]; /* obj[i] = obj >> (8 * i) */ + uint8_t zf_gen[4]; /* gen[i] = gen >> (8 * i) */ +} zfid_short_t; + +/* + * Filesystems under .zfs/snapshot have a total file ID size of 22 bytes + * (including the length field). This makes files under .zfs/snapshot + * accessible by NFSv3 and NFSv4, but not NFSv2. + * + * For files under .zfs/snapshot, we partition up the available space + * as follows: + * 2 bytes fid length (required) + * 6 bytes object number (48 bits) + * 4 bytes generation number (32 bits) + * 6 bytes objset id (48 bits) + * 4 bytes currently just zero (32 bits) + * + * We reserve only 48 bits for the object number and objset id, as these are + * the limits currently defined and imposed by the DMU. + */ +typedef struct zfid_long { + zfid_short_t z_fid; + uint8_t zf_setid[6]; /* obj[i] = obj >> (8 * i) */ + uint8_t zf_setgen[4]; /* gen[i] = gen >> (8 * i) */ +} zfid_long_t; + +#define SHORT_FID_LEN (sizeof (zfid_short_t) - sizeof (uint16_t)) +#define LONG_FID_LEN (sizeof (zfid_long_t) - sizeof (uint16_t)) + +extern void zfs_init(void); +extern void zfs_fini(void); + +extern int zfs_suspend_fs(zfsvfs_t *zfsvfs); +extern int zfs_resume_fs(zfsvfs_t *zfsvfs, struct dsl_dataset *ds); +extern int zfs_end_fs(zfsvfs_t *zfsvfs, struct dsl_dataset *ds); +extern void zfs_exit_fs(zfsvfs_t *zfsvfs); +extern int zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers); +extern int zfsvfs_create(const char *name, boolean_t readony, zfsvfs_t **zfvp); +extern int zfsvfs_create_impl(zfsvfs_t **zfvp, zfsvfs_t *zfsvfs, objset_t *os); +extern void zfsvfs_free(zfsvfs_t *zfsvfs); +extern int zfs_check_global_label(const char *dsname, const char *hexsl); + +extern boolean_t zfs_is_readonly(zfsvfs_t *zfsvfs); +extern int zfs_domount(struct super_block *sb, zfs_mnt_t *zm, int silent); +extern void zfs_preumount(struct super_block *sb); +extern int zfs_umount(struct super_block *sb); +extern int zfs_remount(struct super_block *sb, int *flags, zfs_mnt_t *zm); +extern int zfs_statvfs(struct inode *ip, struct kstatfs *statp); +extern int zfs_vget(struct super_block *sb, struct inode **ipp, fid_t *fidp); +extern int zfs_prune(struct super_block *sb, unsigned long nr_to_scan, + int *objects); +extern int zfs_get_temporary_prop(dsl_dataset_t *ds, zfs_prop_t zfs_prop, + uint64_t *val, char *setpoint); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FS_ZFS_VFSOPS_H */ Modified: head/sys/contrib/openzfs/include/sys/Makefile.am ============================================================================== --- head/sys/contrib/openzfs/include/sys/Makefile.am Fri Sep 4 22:11:58 2020 (r365346) +++ head/sys/contrib/openzfs/include/sys/Makefile.am Fri Sep 4 22:25:14 2020 (r365347) @@ -115,6 +115,7 @@ COMMON_H = \ zfs_sa.h \ zfs_stat.h \ zfs_sysfs.h \ + zfs_vfsops.h \ zfs_znode.h \ zil.h \ zil_impl.h \ Copied: head/sys/contrib/openzfs/include/sys/zfs_vfsops.h (from r365345, vendor-sys/openzfs/dist/include/sys/zfs_vfsops.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/contrib/openzfs/include/sys/zfs_vfsops.h Fri Sep 4 22:25:14 2020 (r365347, copy of r365345, vendor-sys/openzfs/dist/include/sys/zfs_vfsops.h) @@ -0,0 +1,35 @@ +/* + * 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 + */ + +/* + * Portions Copyright 2020 iXsystems, Inc. + */ + +#ifndef _SYS_ZFS_VFSOPS_H +#define _SYS_ZFS_VFSOPS_H + +#ifdef _KERNEL +#include +#endif + +extern void zfsvfs_update_fromname(const char *, const char *); + +#endif /* _SYS_ZFS_VFSOPS_H */ Modified: head/sys/contrib/openzfs/lib/libspl/Makefile.am ============================================================================== --- head/sys/contrib/openzfs/lib/libspl/Makefile.am Fri Sep 4 22:11:58 2020 (r365346) +++ head/sys/contrib/openzfs/lib/libspl/Makefile.am Fri Sep 4 22:25:14 2020 (r365347) @@ -27,7 +27,6 @@ USER_C = \ strlcat.c \ strlcpy.c \ timestamp.c \ - zone.c \ include/sys/list.h \ include/sys/list_impl.h @@ -35,7 +34,8 @@ if BUILD_LINUX USER_C += \ os/linux/getexecname.c \ os/linux/gethostid.c \ - os/linux/getmntany.c + os/linux/getmntany.c \ + os/linux/zone.c endif if BUILD_FREEBSD @@ -43,7 +43,8 @@ USER_C += \ os/freebsd/getexecname.c \ os/freebsd/gethostid.c \ os/freebsd/getmntany.c \ - os/freebsd/mnttab.c + os/freebsd/mnttab.c \ + os/freebsd/zone.c endif *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***