Author: mmacy Date: Thu Oct 1 23:28:21 2020 New Revision: 366350 URL: https://svnweb.freebsd.org/changeset/base/366350
Log: OpenZFS: MFV 2.0-rc3-gfc5966 - Annotate FreeBSD sysctls with CTLFLAG_MPSAFE - Reduce stack usage of Lua - Don't save user FPU context in kernel threads - Add support for procfs_list - Code cleanup in zio_crypt - Add DB_RF_NOPREFETCH to dbuf_read()s in dnode.c - Drop references when skipping dmu_send due to EXDEV - Eliminate gratuitous bzeroing in dbuf_stats_hash_table_data - Fix legacy compat for platform IOCs Added: head/sys/contrib/openzfs/.github/ - copied from r366349, vendor-sys/openzfs/dist/.github/ head/sys/contrib/openzfs/contrib/intel_qat/ - copied from r366349, vendor-sys/openzfs/dist/contrib/intel_qat/ head/sys/contrib/openzfs/tests/zfs-tests/cmd/badsend/ - copied from r366349, vendor-sys/openzfs/dist/tests/zfs-tests/cmd/badsend/ head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send_invalid.ksh - copied unchanged from r366349, vendor-sys/openzfs/dist/tests/zfs-tests/tests/functional/rsend/send_invalid.ksh Modified: head/sys/contrib/openzfs/cmd/zfs/zfs_main.c head/sys/contrib/openzfs/config/kernel-config-defined.m4 head/sys/contrib/openzfs/config/kernel-objtool.m4 head/sys/contrib/openzfs/configure.ac head/sys/contrib/openzfs/contrib/initramfs/scripts/zfs head/sys/contrib/openzfs/include/os/freebsd/spl/sys/kstat.h head/sys/contrib/openzfs/include/os/freebsd/spl/sys/procfs_list.h head/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd_x86.h head/sys/contrib/openzfs/include/os/linux/spl/sys/procfs_list.h head/sys/contrib/openzfs/include/sys/frame.h head/sys/contrib/openzfs/include/sys/lua/luaconf.h head/sys/contrib/openzfs/include/sys/zfs_context.h head/sys/contrib/openzfs/include/sys/zstd/zstd.h head/sys/contrib/openzfs/lib/libshare/os/freebsd/nfs.c head/sys/contrib/openzfs/lib/libshare/os/linux/nfs.c head/sys/contrib/openzfs/lib/libzpool/kernel.c head/sys/contrib/openzfs/man/man8/zfs-userspace.8 head/sys/contrib/openzfs/man/man8/zpool-remove.8 head/sys/contrib/openzfs/module/lua/llimits.h head/sys/contrib/openzfs/module/os/freebsd/spl/spl_kstat.c head/sys/contrib/openzfs/module/os/freebsd/spl/spl_procfs_list.c head/sys/contrib/openzfs/module/os/freebsd/spl/spl_taskq.c 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/zfs_ioctl_compat.c head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c head/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c head/sys/contrib/openzfs/module/os/linux/spl/spl-procfs-list.c head/sys/contrib/openzfs/module/os/linux/zfs/vdev_disk.c head/sys/contrib/openzfs/module/os/linux/zfs/zfs_debug.c head/sys/contrib/openzfs/module/zfs/arc.c head/sys/contrib/openzfs/module/zfs/dbuf_stats.c head/sys/contrib/openzfs/module/zfs/dmu_send.c head/sys/contrib/openzfs/module/zfs/dnode.c head/sys/contrib/openzfs/module/zfs/dsl_crypt.c head/sys/contrib/openzfs/module/zfs/spa_misc.c head/sys/contrib/openzfs/module/zfs/spa_stats.c head/sys/contrib/openzfs/module/zfs/zfs_log.c head/sys/contrib/openzfs/module/zstd/zfs_zstd.c head/sys/contrib/openzfs/tests/runfiles/common.run head/sys/contrib/openzfs/tests/zfs-tests/cmd/Makefile.am head/sys/contrib/openzfs/tests/zfs-tests/include/commands.cfg head/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/Makefile.am Directory Properties: head/sys/contrib/openzfs/ (props changed) Modified: head/sys/contrib/openzfs/cmd/zfs/zfs_main.c ============================================================================== --- head/sys/contrib/openzfs/cmd/zfs/zfs_main.c Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/cmd/zfs/zfs_main.c Thu Oct 1 23:28:21 2020 (r366350) @@ -363,16 +363,16 @@ get_usage(zfs_help_t idx) return (gettext("\tuserspace [-Hinp] [-o field[,...]] " "[-s field] ...\n" "\t [-S field] ... [-t type[,...]] " - "<filesystem|snapshot>\n")); + "<filesystem|snapshot|path>\n")); case HELP_GROUPSPACE: return (gettext("\tgroupspace [-Hinp] [-o field[,...]] " "[-s field] ...\n" "\t [-S field] ... [-t type[,...]] " - "<filesystem|snapshot>\n")); + "<filesystem|snapshot|path>\n")); case HELP_PROJECTSPACE: return (gettext("\tprojectspace [-Hp] [-o field[,...]] " "[-s field] ... \n" - "\t [-S field] ... <filesystem|snapshot>\n")); + "\t [-S field] ... <filesystem|snapshot|path>\n")); case HELP_PROJECT: return (gettext("\tproject [-d|-r] <directory|file ...>\n" "\tproject -c [-0] [-d|-r] [-p id] <directory|file ...>\n" @@ -2481,11 +2481,13 @@ zfs_do_upgrade(int argc, char **argv) /* * zfs userspace [-Hinp] [-o field[,...]] [-s field [-s field]...] - * [-S field [-S field]...] [-t type[,...]] filesystem | snapshot + * [-S field [-S field]...] [-t type[,...]] + * filesystem | snapshot | path * zfs groupspace [-Hinp] [-o field[,...]] [-s field [-s field]...] - * [-S field [-S field]...] [-t type[,...]] filesystem | snapshot + * [-S field [-S field]...] [-t type[,...]] + * filesystem | snapshot | path * zfs projectspace [-Hp] [-o field[,...]] [-s field [-s field]...] - * [-S field [-S field]...] filesystem | snapshot + * [-S field [-S field]...] filesystem | snapshot | path * * -H Scripted mode; elide headers and separate columns by tabs. * -i Translate SID to POSIX ID. @@ -3191,7 +3193,7 @@ zfs_do_userspace(int argc, char **argv) } while (delim != NULL); } - if ((zhp = zfs_open(g_zfs, argv[0], ZFS_TYPE_FILESYSTEM | + if ((zhp = zfs_path_to_zhandle(g_zfs, argv[0], ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT)) == NULL) return (1); if (zhp->zfs_head_type != ZFS_TYPE_FILESYSTEM) { Modified: head/sys/contrib/openzfs/config/kernel-config-defined.m4 ============================================================================== --- head/sys/contrib/openzfs/config/kernel-config-defined.m4 Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/config/kernel-config-defined.m4 Thu Oct 1 23:28:21 2020 (r366350) @@ -91,7 +91,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_DEBUG_LOCK_ALLOC], AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC], [ AC_MSG_CHECKING([whether mutex_lock() is GPL-only]) - ZFS_LINUX_TEST_RESULT([config_debug_lock_alloc], [ + ZFS_LINUX_TEST_RESULT([config_debug_lock_alloc_license], [ AC_MSG_RESULT(no) ],[ AC_MSG_RESULT(yes) Modified: head/sys/contrib/openzfs/config/kernel-objtool.m4 ============================================================================== --- head/sys/contrib/openzfs/config/kernel-objtool.m4 Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/config/kernel-objtool.m4 Thu Oct 1 23:28:21 2020 (r366350) @@ -6,10 +6,11 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_OBJTOOL], [ dnl # 4.6 API for compile-time stack validation ZFS_LINUX_TEST_SRC([objtool], [ #undef __ASSEMBLY__ + #include <asm/ptrace.h> #include <asm/frame.h> ],[ #if !defined(FRAME_BEGIN) - CTASSERT(1); + #error "FRAME_BEGIN is not defined" #endif ]) @@ -18,7 +19,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_OBJTOOL], [ #include <linux/frame.h> ],[ #if !defined(STACK_FRAME_NON_STANDARD) - CTASSERT(1); + #error "STACK_FRAME_NON_STANDARD is not defined." #endif ]) ]) Modified: head/sys/contrib/openzfs/configure.ac ============================================================================== --- head/sys/contrib/openzfs/configure.ac Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/configure.ac Thu Oct 1 23:28:21 2020 (r366350) @@ -204,6 +204,7 @@ AC_CONFIG_FILES([ tests/zfs-tests/Makefile tests/zfs-tests/callbacks/Makefile tests/zfs-tests/cmd/Makefile + tests/zfs-tests/cmd/badsend/Makefile tests/zfs-tests/cmd/btree_test/Makefile tests/zfs-tests/cmd/chg_usr_exec/Makefile tests/zfs-tests/cmd/devname2devid/Makefile Modified: head/sys/contrib/openzfs/contrib/initramfs/scripts/zfs ============================================================================== --- head/sys/contrib/openzfs/contrib/initramfs/scripts/zfs Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/contrib/initramfs/scripts/zfs Thu Oct 1 23:28:21 2020 (r366350) @@ -15,8 +15,8 @@ # See "4.5 Disable root prompt on the initramfs" of Securing Debian Manual: # https://www.debian.org/doc/manuals/securing-debian-howto/ch4.en.html shell() { - if type panic > /dev/null 2>&1; then - panic $@ + if command -v panic > /dev/null 2>&1; then + panic else /bin/sh fi @@ -26,22 +26,23 @@ shell() { # pools and mounting any filesystems. pre_mountroot() { - if type run_scripts > /dev/null 2>&1 && \ - [ -f "/scripts/local-top" -o -d "/scripts/local-top" ] + if command -v run_scripts > /dev/null 2>&1 then - [ "$quiet" != "y" ] && \ - zfs_log_begin_msg "Running /scripts/local-top" - run_scripts /scripts/local-top - [ "$quiet" != "y" ] && zfs_log_end_msg - fi + if [ -f "/scripts/local-top" ] || [ -d "/scripts/local-top" ] + then + [ "$quiet" != "y" ] && \ + zfs_log_begin_msg "Running /scripts/local-top" + run_scripts /scripts/local-top + [ "$quiet" != "y" ] && zfs_log_end_msg + fi - if type run_scripts > /dev/null 2>&1 && \ - [ -f "/scripts/local-premount" -o -d "/scripts/local-premount" ] - then - [ "$quiet" != "y" ] && \ - zfs_log_begin_msg "Running /scripts/local-premount" - run_scripts /scripts/local-premount - [ "$quiet" != "y" ] && zfs_log_end_msg + if [ -f "/scripts/local-premount" ] || [ -d "/scripts/local-premount" ] + then + [ "$quiet" != "y" ] && \ + zfs_log_begin_msg "Running /scripts/local-premount" + run_scripts /scripts/local-premount + [ "$quiet" != "y" ] && zfs_log_end_msg + fi fi } @@ -57,10 +58,10 @@ disable_plymouth() # Get a ZFS filesystem property value. get_fs_value() { - local fs="$1" - local value=$2 + fs="$1" + value=$2 - "${ZFS}" get -H -ovalue $value "$fs" 2> /dev/null + "${ZFS}" get -H -ovalue "$value" "$fs" 2> /dev/null } # Find the 'bootfs' property on pool $1. @@ -68,7 +69,7 @@ get_fs_value() # pool by exporting it again. find_rootfs() { - local pool="$1" + pool="$1" # If 'POOL_IMPORTED' isn't set, no pool imported and therefore # we won't be able to find a root fs. @@ -84,7 +85,7 @@ find_rootfs() # Make sure it's not '-' and that it starts with /. if [ "${ZFS_BOOTFS}" != "-" ] && \ - $(get_fs_value "${ZFS_BOOTFS}" mountpoint | grep -q '^/$') + get_fs_value "${ZFS_BOOTFS}" mountpoint | grep -q '^/$' then # Keep it mounted POOL_IMPORTED=1 @@ -101,14 +102,13 @@ find_rootfs() # Support function to get a list of all pools, separated with ';' find_pools() { - local CMD="$*" - local pools pool + CMD="$*" pools=$($CMD 2> /dev/null | \ grep -E "pool:|^[a-zA-Z0-9]" | \ sed 's@.*: @@' | \ - while read pool; do \ - echo -n "$pool;" + while read -r pool; do \ + printf "%s" "$pool;" done) echo "${pools%%;}" # Return without the last ';'. @@ -117,8 +117,6 @@ find_pools() # Get a list of all available pools get_pools() { - local available_pools npools - if [ -n "${ZFS_POOL_IMPORT}" ]; then echo "$ZFS_POOL_IMPORT" return 0 @@ -159,9 +157,8 @@ get_pools() # Filter out any exceptions... if [ -n "$ZFS_POOL_EXCEPTIONS" ] then - local found="" - local apools="" - local pool exception + found="" + apools="" OLD_IFS="$IFS" ; IFS=";" for pool in $available_pools @@ -194,8 +191,7 @@ get_pools() # Import given pool $1 import_pool() { - local pool="$1" - local dirs dir + pool="$1" # Verify that the pool isn't already imported # Make as sure as we can to not require '-f' to import. @@ -205,7 +201,7 @@ import_pool() # to something we can use later with the real import(s). We want to # make sure we find all by* dirs, BUT by-vdev should be first (if it # exists). - if [ -n "$USE_DISK_BY_ID" -a -z "$ZPOOL_IMPORT_PATH" ] + if [ -n "$USE_DISK_BY_ID" ] && [ -z "$ZPOOL_IMPORT_PATH" ] then dirs="$(for dir in $(echo /dev/disk/by-*) do @@ -213,7 +209,7 @@ import_pool() echo "$dir" | grep -q /by-vdev && continue [ ! -d "$dir" ] && continue - echo -n "$dir:" + printf "%s" "$dir:" done | sed 's,:$,,g')" if [ -d "/dev/disk/by-vdev" ] @@ -277,7 +273,7 @@ import_pool() # with more logging etc. load_module_initrd() { - if [ "$ZFS_INITRD_PRE_MOUNTROOT_SLEEP" > 0 ] + if [ "$ZFS_INITRD_PRE_MOUNTROOT_SLEEP" -gt 0 ] 2>/dev/null then if [ "$quiet" != "y" ]; then zfs_log_begin_msg "Sleeping for" \ @@ -288,9 +284,9 @@ load_module_initrd() fi # Wait for all of the /dev/{hd,sd}[a-z] device nodes to appear. - if type wait_for_udev > /dev/null 2>&1 ; then + if command -v wait_for_udev > /dev/null 2>&1 ; then wait_for_udev 10 - elif type wait_for_dev > /dev/null 2>&1 ; then + elif command -v wait_for_dev > /dev/null 2>&1 ; then wait_for_dev fi @@ -300,7 +296,7 @@ load_module_initrd() # Load the module load_module "zfs" || return 1 - if [ "$ZFS_INITRD_POST_MODPROBE_SLEEP" > 0 ] + if [ "$ZFS_INITRD_POST_MODPROBE_SLEEP" -gt 0 ] 2>/dev/null then if [ "$quiet" != "y" ]; then zfs_log_begin_msg "Sleeping for" \ @@ -316,12 +312,10 @@ load_module_initrd() # Mount a given filesystem mount_fs() { - local fs="$1" - local mountpoint + fs="$1" # Check that the filesystem exists - "${ZFS}" list -oname -tfilesystem -H "${fs}" > /dev/null 2>&1 - [ "$?" -ne 0 ] && return 1 + "${ZFS}" list -oname -tfilesystem -H "${fs}" > /dev/null 2>&1 || return 1 # Skip filesystems with canmount=off. The root fs should not have # canmount=off, but ignore it for backwards compatibility just in case. @@ -333,14 +327,14 @@ mount_fs() # Need the _original_ datasets mountpoint! mountpoint=$(get_fs_value "$fs" mountpoint) - if [ "$mountpoint" = "legacy" -o "$mountpoint" = "none" ]; then + if [ "$mountpoint" = "legacy" ] || [ "$mountpoint" = "none" ]; then # Can't use the mountpoint property. Might be one of our # clones. Check the 'org.zol:mountpoint' property set in # clone_snap() if that's usable. mountpoint=$(get_fs_value "$fs" org.zol:mountpoint) - if [ "$mountpoint" = "legacy" -o \ - "$mountpoint" = "none" -o \ - "$mountpoint" = "-" ] + if [ "$mountpoint" = "legacy" ] || + [ "$mountpoint" = "none" ] || + [ "$mountpoint" = "-" ] then if [ "$fs" != "${ZFS_BOOTFS}" ]; then # We don't have a proper mountpoint and this @@ -396,10 +390,10 @@ mount_fs() # Unlock a ZFS native encrypted filesystem. decrypt_fs() { - local fs="$1" - + fs="$1" + # If pool encryption is active and the zfs command understands '-o encryption' - if [ "$(zpool list -H -o feature@encryption $(echo "${fs}" | awk -F\/ '{print $1}'))" = 'active' ]; then + if [ "$(zpool list -H -o feature@encryption "$(echo "${fs}" | awk -F/ '{print $1}')")" = 'active' ]; then # Determine dataset that holds key for root dataset ENCRYPTIONROOT="$(get_fs_value "${fs}" encryptionroot)" @@ -427,7 +421,7 @@ decrypt_fs() TRY_COUNT=$((TRY_COUNT - 1)) done - # Prompt with systemd, if active + # Prompt with systemd, if active elif [ -e /run/systemd/system ]; then echo "systemd-ask-password" > /run/zfs_console_askpwd_cmd while [ $TRY_COUNT -gt 0 ]; do @@ -454,7 +448,7 @@ decrypt_fs() # Destroy a given filesystem. destroy_fs() { - local fs="$1" + fs="$1" [ "$quiet" != "y" ] && \ zfs_log_begin_msg "Destroying '$fs'" @@ -489,9 +483,9 @@ destroy_fs() # mounted with a 'zfs mount -a' in the init/systemd scripts). clone_snap() { - local snap="$1" - local destfs="$2" - local mountpoint="$3" + snap="$1" + destfs="$2" + mountpoint="$3" [ "$quiet" != "y" ] && zfs_log_begin_msg "Cloning '$snap' to '$destfs'" @@ -529,7 +523,7 @@ clone_snap() # Rollback a given snapshot. rollback_snap() { - local snap="$1" + snap="$1" [ "$quiet" != "y" ] && zfs_log_begin_msg "Rollback $snap" @@ -559,9 +553,8 @@ rollback_snap() # to the user to choose from. ask_user_snap() { - local fs="$1" - local i=1 - local SNAP snapnr snap debug + fs="$1" + i=1 # We need to temporarily disable debugging. Set 'debug' so we # remember to enabled it again. @@ -574,16 +567,16 @@ ask_user_snap() # Because we need the resulting snapshot, which is sent on # stdout to the caller, we use stderr for our questions. echo "What snapshot do you want to boot from?" > /dev/stderr - while read snap; do + while read -r snap; do echo " $i: ${snap}" > /dev/stderr - eval `echo SNAP_$i=$snap` + eval "$(echo SNAP_$i=$snap)" i=$((i + 1)) done <<EOT $("${ZFS}" list -H -oname -tsnapshot -r "${fs}") EOT - echo -n " Snap nr [1-$((i-1))]? " > /dev/stderr - read snapnr + echo "%s" " Snap nr [1-$((i-1))]? " > /dev/stderr + read -r snapnr # Re-enable debugging. if [ -n "${debug}" ]; then @@ -591,16 +584,16 @@ EOT set -x fi - echo "$(eval echo "$"SNAP_$snapnr)" + echo "$(eval echo '$SNAP_'$snapnr)" } setup_snapshot_booting() { - local snap="$1" - local s destfs subfs mountpoint retval=0 filesystems fs + snap="$1" + retval=0 - # Make sure that the snapshot specified actually exist. - if [ ! $(get_fs_value "${snap}" type) ] + # Make sure that the snapshot specified actually exists. + if [ ! "$(get_fs_value "${snap}" type)" ] then # Snapshot does not exist (...@<null> ?) # ask the user for a snapshot to use. @@ -617,7 +610,7 @@ setup_snapshot_booting() then # If the destination dataset for the clone # already exists, destroy it. Recursively - if [ $(get_fs_value "${rootfs}_${snapname}" type) ]; then + if [ "$(get_fs_value "${rootfs}_${snapname}" type)" ]; then filesystems=$("${ZFS}" list -oname -tfilesystem -H \ -r -Sname "${ZFS_BOOTFS}") for fs in $filesystems; do @@ -652,8 +645,8 @@ setup_snapshot_booting() # with clone_snap(). If legacy or none, then use # the sub fs value. mountpoint=$(get_fs_value "${s%%@*}" mountpoint) - if [ "$mountpoint" = "legacy" -o \ - "$mountpoint" = "none" ] + if [ "$mountpoint" = "legacy" ] || \ + [ "$mountpoint" = "none" ] then if [ -n "${subfs}" ]; then mountpoint="${subfs}" @@ -678,8 +671,6 @@ setup_snapshot_booting() # This is the main function. mountroot() { - local snaporig snapsub destfs pool POOLS - # ---------------------------------------------------------------- # I N I T I A L S E T U P @@ -742,7 +733,7 @@ mountroot() # No longer set in the defaults file, but it could have been set in # get_pools() in some circumstances. If it's something, but not 'yes', # it's no good to us. - [ -n "$USE_DISK_BY_ID" -a "$USE_DISK_BY_ID" != 'yes' ] && \ + [ -n "$USE_DISK_BY_ID" ] && [ "$USE_DISK_BY_ID" != 'yes' ] && \ unset USE_DISK_BY_ID # ---------------------------------------------------------------- @@ -788,12 +779,12 @@ mountroot() # ------------ # If we have 'ROOT' (see above), but not 'ZFS_BOOTFS', then use # 'ROOT' - [ -n "$ROOT" -a -z "${ZFS_BOOTFS}" ] && ZFS_BOOTFS="$ROOT" + [ -n "$ROOT" ] && [ -z "${ZFS_BOOTFS}" ] && ZFS_BOOTFS="$ROOT" # ------------ # Check for the `-B zfs-bootfs=%s/%u,...` kind of parameter. # NOTE: Only use the pool name and dataset. The rest is not - # supported by ZoL (whatever it's for). + # supported by OpenZFS (whatever it's for). if [ -z "$ZFS_RPOOL" ] then # The ${zfs-bootfs} variable is set at the kernel command @@ -809,11 +800,11 @@ mountroot() # ------------ # No root fs or pool specified - do auto detect. - if [ -z "$ZFS_RPOOL" -a -z "${ZFS_BOOTFS}" ] + if [ -z "$ZFS_RPOOL" ] && [ -z "${ZFS_BOOTFS}" ] then # Do auto detect. Do this by 'cheating' - set 'root=zfs:AUTO' # which will be caught later - ROOT=zfs:AUTO + ROOT='zfs:AUTO' fi # ---------------------------------------------------------------- @@ -858,7 +849,7 @@ mountroot() fi # Import the pool (if not already done so in the AUTO check above). - if [ -n "$ZFS_RPOOL" -a -z "${POOL_IMPORTED}" ] + if [ -n "$ZFS_RPOOL" ] && [ -z "${POOL_IMPORTED}" ] then [ "$quiet" != "y" ] && \ zfs_log_begin_msg "Importing ZFS root pool '$ZFS_RPOOL'" @@ -971,7 +962,7 @@ mountroot() touch /run/zfs_unlock_complete if [ -e /run/zfs_unlock_complete_notify ]; then - read zfs_unlock_complete_notify < /run/zfs_unlock_complete_notify + read -r zfs_unlock_complete_notify < /run/zfs_unlock_complete_notify fi # ------------ @@ -989,8 +980,8 @@ mountroot() echo echo "=> waiting for ENTER before continuing because of 'zfsdebug=1'. " - echo -n " 'c' for shell, 'r' for reboot, 'ENTER' to continue. " - read b + printf "%s" " 'c' for shell, 'r' for reboot, 'ENTER' to continue. " + read -r b [ "$b" = "c" ] && /bin/sh [ "$b" = "r" ] && reboot -f @@ -1000,12 +991,14 @@ mountroot() # ------------ # Run local bottom script - if type run_scripts > /dev/null 2>&1 && \ - [ -f "/scripts/local-bottom" -o -d "/scripts/local-bottom" ] + if command -v run_scripts > /dev/null 2>&1 then - [ "$quiet" != "y" ] && \ - zfs_log_begin_msg "Running /scripts/local-bottom" - run_scripts /scripts/local-bottom - [ "$quiet" != "y" ] && zfs_log_end_msg + if [ -f "/scripts/local-bottom" ] || [ -d "/scripts/local-bottom" ] + then + [ "$quiet" != "y" ] && \ + zfs_log_begin_msg "Running /scripts/local-bottom" + run_scripts /scripts/local-bottom + [ "$quiet" != "y" ] && zfs_log_end_msg + fi fi } Modified: head/sys/contrib/openzfs/include/os/freebsd/spl/sys/kstat.h ============================================================================== --- head/sys/contrib/openzfs/include/os/freebsd/spl/sys/kstat.h Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/include/os/freebsd/spl/sys/kstat.h Thu Oct 1 23:28:21 2020 (r366350) @@ -83,6 +83,14 @@ typedef struct kstat_s kstat_t; typedef int kid_t; /* unique kstat id */ typedef int kstat_update_t(struct kstat_s *, int); /* dynamic update cb */ +struct seq_file { + char *sf_buf; + size_t sf_size; +}; + +void seq_printf(struct seq_file *m, const char *fmt, ...); + + typedef struct kstat_module { char ksm_name[KSTAT_STRLEN+1]; /* module name */ struct list_head ksm_module_list; /* module linkage */ @@ -92,6 +100,7 @@ typedef struct kstat_module { typedef struct kstat_raw_ops { int (*headers)(char *buf, size_t size); + int (*seq_headers)(struct seq_file *); int (*data)(char *buf, size_t size, void *data); void *(*addr)(kstat_t *ksp, loff_t index); } kstat_raw_ops_t; @@ -112,6 +121,7 @@ struct kstat_s { size_t ks_data_size; /* size of kstat data section */ kstat_update_t *ks_update; /* dynamic updates */ void *ks_private; /* private data */ + void *ks_private1; /* private data */ kmutex_t ks_private_lock; /* kstat private data lock */ kmutex_t *ks_lock; /* kstat data lock */ struct list_head ks_list; /* kstat linkage */ @@ -185,6 +195,12 @@ extern void __kstat_set_raw_ops(kstat_t *ksp, int (*data)(char *buf, size_t size, void *data), void* (*addr)(kstat_t *ksp, loff_t index)); +extern void __kstat_set_seq_raw_ops(kstat_t *ksp, + int (*headers)(struct seq_file *), + int (*data)(char *buf, size_t size, void *data), + void* (*addr)(kstat_t *ksp, loff_t index)); + + extern kstat_t *__kstat_create(const char *ks_module, int ks_instance, const char *ks_name, const char *ks_class, uchar_t ks_type, uint_t ks_ndata, uchar_t ks_flags); @@ -196,6 +212,8 @@ extern void kstat_waitq_exit(kstat_io_t *); extern void kstat_runq_enter(kstat_io_t *); extern void kstat_runq_exit(kstat_io_t *); +#define kstat_set_seq_raw_ops(k, h, d, a) \ + __kstat_set_seq_raw_ops(k, h, d, a) #define kstat_set_raw_ops(k, h, d, a) \ __kstat_set_raw_ops(k, h, d, a) #define kstat_create(m, i, n, c, t, s, f) \ Modified: head/sys/contrib/openzfs/include/os/freebsd/spl/sys/procfs_list.h ============================================================================== --- head/sys/contrib/openzfs/include/os/freebsd/spl/sys/procfs_list.h Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/include/os/freebsd/spl/sys/procfs_list.h Thu Oct 1 23:28:21 2020 (r366350) @@ -33,16 +33,18 @@ * procfs list manipulation */ -struct seq_file { }; -void seq_printf(struct seq_file *m, const char *fmt, ...); - -typedef struct procfs_list { +typedef struct procfs_list procfs_list_t; +struct procfs_list { void *pl_private; + void *pl_next_data; kmutex_t pl_lock; list_t pl_list; uint64_t pl_next_id; + int (*pl_show)(struct seq_file *f, void *p); + int (*pl_show_header)(struct seq_file *f); + int (*pl_clear)(procfs_list_t *procfs_list); size_t pl_node_offset; -} procfs_list_t; +}; typedef struct procfs_list_node { list_node_t pln_link; @@ -50,6 +52,7 @@ typedef struct procfs_list_node { } procfs_list_node_t; void procfs_list_install(const char *module, + const char *submodule, const char *name, mode_t mode, procfs_list_t *procfs_list, Modified: head/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd_x86.h ============================================================================== --- head/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd_x86.h Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/include/os/freebsd/spl/sys/simd_x86.h Thu Oct 1 23:28:21 2020 (r366350) @@ -29,6 +29,7 @@ #include <sys/cdefs.h> #include <sys/types.h> #include <sys/systm.h> +#include <sys/proc.h> #ifdef __i386__ #include <x86/fpu.h> #else @@ -42,16 +43,15 @@ #define kfpu_allowed() 1 #define kfpu_initialize(tsk) do {} while (0) -#define kfpu_begin() { \ - critical_enter(); \ - fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX); \ +#define kfpu_begin() { \ + if (__predict_false(!is_fpu_kern_thread(0))) \ + fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX);\ } -#define kfpu_end() \ - { \ - fpu_kern_leave(curthread, NULL); \ - critical_exit(); \ - } +#define kfpu_end() { \ + if (__predict_false(curpcb->pcb_flags & PCB_FPUNOSAVE)) \ + fpu_kern_leave(curthread, NULL); \ +} /* * Check if OS supports AVX and AVX2 by checking XCR0 Modified: head/sys/contrib/openzfs/include/os/linux/spl/sys/procfs_list.h ============================================================================== --- head/sys/contrib/openzfs/include/os/linux/spl/sys/procfs_list.h Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/include/os/linux/spl/sys/procfs_list.h Thu Oct 1 23:28:21 2020 (r366350) @@ -57,6 +57,7 @@ typedef struct procfs_list_node { } procfs_list_node_t; void procfs_list_install(const char *module, + const char *submodule, const char *name, mode_t mode, procfs_list_t *procfs_list, Modified: head/sys/contrib/openzfs/include/sys/frame.h ============================================================================== --- head/sys/contrib/openzfs/include/sys/frame.h Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/include/sys/frame.h Thu Oct 1 23:28:21 2020 (r366350) @@ -23,7 +23,8 @@ extern "C" { #endif -#if defined(__KERNEL__) && defined(HAVE_STACK_FRAME_NON_STANDARD) +#if defined(__KERNEL__) && defined(HAVE_KERNEL_OBJTOOL) && \ + defined(HAVE_STACK_FRAME_NON_STANDARD) #include <linux/frame.h> #else #define STACK_FRAME_NON_STANDARD(func) Modified: head/sys/contrib/openzfs/include/sys/lua/luaconf.h ============================================================================== --- head/sys/contrib/openzfs/include/sys/lua/luaconf.h Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/include/sys/lua/luaconf.h Thu Oct 1 23:28:21 2020 (r366350) @@ -368,11 +368,7 @@ extern int lcompat_hashnum(int64_t); @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. ** CHANGE it if it uses too much C-stack space. */ -#ifdef __linux__ #define LUAL_BUFFERSIZE 512 -#else -#define LUAL_BUFFERSIZE 1024 -#endif /* Modified: head/sys/contrib/openzfs/include/sys/zfs_context.h ============================================================================== --- head/sys/contrib/openzfs/include/sys/zfs_context.h Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/include/sys/zfs_context.h Thu Oct 1 23:28:21 2020 (r366350) @@ -386,6 +386,7 @@ typedef struct procfs_list_node { } procfs_list_node_t; void procfs_list_install(const char *module, + const char *submodule, const char *name, mode_t mode, procfs_list_t *procfs_list, Modified: head/sys/contrib/openzfs/include/sys/zstd/zstd.h ============================================================================== --- head/sys/contrib/openzfs/include/sys/zstd/zstd.h Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/include/sys/zstd/zstd.h Thu Oct 1 23:28:21 2020 (r366350) @@ -90,6 +90,7 @@ int zfs_zstd_decompress_level(void *s_start, void *d_s size_t d_len, uint8_t *level); int zfs_zstd_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n); +void zfs_zstd_cache_reap_now(void); #ifdef __cplusplus } Modified: head/sys/contrib/openzfs/lib/libshare/os/freebsd/nfs.c ============================================================================== --- head/sys/contrib/openzfs/lib/libshare/os/freebsd/nfs.c Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/lib/libshare/os/freebsd/nfs.c Thu Oct 1 23:28:21 2020 (r366350) @@ -228,21 +228,33 @@ nfs_copy_entries(char *filename, const char *mountpoin int error = SA_OK; char *line; - /* - * If the file doesn't exist then there is nothing more - * we need to do. - */ FILE *oldfp = fopen(ZFS_EXPORTS_FILE, "r"); - if (oldfp == NULL) - return (SA_OK); - FILE *newfp = fopen(filename, "w+"); + if (newfp == NULL) { + fprintf(stderr, "failed to open %s file: %s", filename, + strerror(errno)); + fclose(oldfp); + return (SA_SYSTEM_ERR); + } fputs(FILE_HEADER, newfp); - while ((line = zgetline(oldfp, mountpoint)) != NULL) - fprintf(newfp, "%s\n", line); - if (ferror(oldfp) != 0) { - error = ferror(oldfp); + + /* + * The ZFS_EXPORTS_FILE may not exist yet. If that's the + * case then just write out the new file. + */ + if (oldfp != NULL) { + while ((line = zgetline(oldfp, mountpoint)) != NULL) + fprintf(newfp, "%s\n", line); + if (ferror(oldfp) != 0) { + error = ferror(oldfp); + } + if (fclose(oldfp) != 0) { + fprintf(stderr, "Unable to close file %s: %s\n", + filename, strerror(errno)); + error = error != 0 ? error : SA_SYSTEM_ERR; + } } + if (error == 0 && ferror(newfp) != 0) { error = ferror(newfp); } @@ -252,8 +264,6 @@ nfs_copy_entries(char *filename, const char *mountpoin filename, strerror(errno)); error = error != 0 ? error : SA_SYSTEM_ERR; } - fclose(oldfp); - return (error); } Modified: head/sys/contrib/openzfs/lib/libshare/os/linux/nfs.c ============================================================================== --- head/sys/contrib/openzfs/lib/libshare/os/linux/nfs.c Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/lib/libshare/os/linux/nfs.c Thu Oct 1 23:28:21 2020 (r366350) @@ -393,7 +393,15 @@ static char * nfs_init_tmpfile(void) { char *tmpfile = NULL; + struct stat sb; + if (stat(ZFS_EXPORTS_DIR, &sb) < 0 && + mkdir(ZFS_EXPORTS_DIR, 0755) < 0) { + fprintf(stderr, "failed to create %s: %s\n", + ZFS_EXPORTS_DIR, strerror(errno)); + return (NULL); + } + if (asprintf(&tmpfile, "%s%s", ZFS_EXPORTS_FILE, ".XXXXXXXX") == -1) { fprintf(stderr, "Unable to allocate temporary file\n"); return (NULL); @@ -481,36 +489,49 @@ nfs_copy_entries(char *filename, const char *mountpoin size_t buflen = 0; int error = SA_OK; - /* - * If the file doesn't exist then there is nothing more - * we need to do. - */ FILE *oldfp = fopen(ZFS_EXPORTS_FILE, "r"); - if (oldfp == NULL) - return (SA_OK); - FILE *newfp = fopen(filename, "w+"); + if (newfp == NULL) { + fprintf(stderr, "failed to open %s file: %s", filename, + strerror(errno)); + fclose(oldfp); + return (SA_SYSTEM_ERR); + } fputs(FILE_HEADER, newfp); - while ((getline(&buf, &buflen, oldfp)) != -1) { - char *space = NULL; - if (buf[0] == '\n' || buf[0] == '#') - continue; + /* + * The ZFS_EXPORTS_FILE may not exist yet. If that's the + * case then just write out the new file. + */ + if (oldfp != NULL) { + while (getline(&buf, &buflen, oldfp) != -1) { + char *space = NULL; - if ((space = strchr(buf, ' ')) != NULL) { - int mountpoint_len = strlen(mountpoint); - - if (space - buf == mountpoint_len && - strncmp(mountpoint, buf, mountpoint_len) == 0) { + if (buf[0] == '\n' || buf[0] == '#') continue; + + if ((space = strchr(buf, ' ')) != NULL) { + int mountpoint_len = strlen(mountpoint); + + if (space - buf == mountpoint_len && + strncmp(mountpoint, buf, + mountpoint_len) == 0) { + continue; + } } + fputs(buf, newfp); } - fputs(buf, newfp); - } - if (oldfp != NULL && ferror(oldfp) != 0) { - error = ferror(oldfp); + if (ferror(oldfp) != 0) { + error = ferror(oldfp); + } + if (fclose(oldfp) != 0) { + fprintf(stderr, "Unable to close file %s: %s\n", + filename, strerror(errno)); + error = error != 0 ? error : SA_SYSTEM_ERR; + } } + if (error == 0 && ferror(newfp) != 0) { error = ferror(newfp); } @@ -521,8 +542,6 @@ nfs_copy_entries(char *filename, const char *mountpoin filename, strerror(errno)); error = error != 0 ? error : SA_SYSTEM_ERR; } - fclose(oldfp); - return (error); } @@ -701,13 +720,5 @@ static const sa_share_ops_t nfs_shareops = { void libshare_nfs_init(void) { - struct stat sb; - nfs_fstype = register_fstype("nfs", &nfs_shareops); - - if (stat(ZFS_EXPORTS_DIR, &sb) < 0 && - mkdir(ZFS_EXPORTS_DIR, 0755) < 0) { - fprintf(stderr, "failed to create %s: %s\n", - ZFS_EXPORTS_DIR, strerror(errno)); - } } Modified: head/sys/contrib/openzfs/lib/libzpool/kernel.c ============================================================================== --- head/sys/contrib/openzfs/lib/libzpool/kernel.c Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/lib/libzpool/kernel.c Thu Oct 1 23:28:21 2020 (r366350) @@ -444,6 +444,7 @@ seq_printf(struct seq_file *m, const char *fmt, ...) void procfs_list_install(const char *module, + const char *submodule, const char *name, mode_t mode, procfs_list_t *procfs_list, Modified: head/sys/contrib/openzfs/man/man8/zfs-userspace.8 ============================================================================== --- head/sys/contrib/openzfs/man/man8/zfs-userspace.8 Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/man/man8/zfs-userspace.8 Thu Oct 1 23:28:21 2020 (r366350) @@ -44,7 +44,7 @@ .Oo Fl s Ar field Oc Ns ... .Oo Fl S Ar field Oc Ns ... .Oo Fl t Ar type Ns Oo , Ns Ar type Oc Ns ... Oc -.Ar filesystem Ns | Ns Ar snapshot +.Ar filesystem Ns | Ns Ar snapshot Ns | Ns Ar path .Nm .Cm groupspace .Op Fl Hinp @@ -52,14 +52,14 @@ .Oo Fl s Ar field Oc Ns ... .Oo Fl S Ar field Oc Ns ... .Oo Fl t Ar type Ns Oo , Ns Ar type Oc Ns ... Oc -.Ar filesystem Ns | Ns Ar snapshot +.Ar filesystem Ns | Ns Ar snapshot Ns | Ns Ar path .Nm .Cm projectspace .Op Fl Hp .Oo Fl o Ar field Ns Oo , Ns Ar field Oc Ns ... Oc .Oo Fl s Ar field Oc Ns ... .Oo Fl S Ar field Oc Ns ... -.Ar filesystem Ns | Ns Ar snapshot +.Ar filesystem Ns | Ns Ar snapshot Ns | Ns Ar path .Sh DESCRIPTION .Bl -tag -width "" .It Xo @@ -70,10 +70,11 @@ .Oo Fl s Ar field Oc Ns ... .Oo Fl S Ar field Oc Ns ... .Oo Fl t Ar type Ns Oo , Ns Ar type Oc Ns ... Oc -.Ar filesystem Ns | Ns Ar snapshot +.Ar filesystem Ns | Ns Ar snapshot Ns | Ns Ar path .Xc -Displays space consumed by, and quotas on, each user in the specified filesystem -or snapshot. +Displays space consumed by, and quotas on, each user in the specified filesystem, +snapshot, or path. +If a path is given, the filesystem that contains that path will be used. This corresponds to the .Sy userused@ Ns Em user , .Sy userobjused@ Ns Em user , @@ -167,7 +168,7 @@ except that the default types to display are .Oo Fl o Ar field Ns Oo , Ns Ar field Oc Ns ... Oc .Oo Fl s Ar field Oc Ns ... .Oo Fl S Ar field Oc Ns ... -.Ar filesystem Ns | Ns Ar snapshot +.Ar filesystem Ns | Ns Ar snapshot Ns | Ns Ar path .Xc Displays space consumed by, and quotas on, each project in the specified filesystem or snapshot. This subcommand is identical to Modified: head/sys/contrib/openzfs/man/man8/zpool-remove.8 ============================================================================== --- head/sys/contrib/openzfs/man/man8/zpool-remove.8 Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/man/man8/zpool-remove.8 Thu Oct 1 23:28:21 2020 (r366350) @@ -55,6 +55,8 @@ This command supports removing hot spare, cache, log, non-redundant primary top-level vdevs, including dedup and special vdevs. When the primary pool storage includes a top-level raidz vdev only hot spare, cache, and log devices can be removed. +Note that keys for all encrypted datasets must be loaded for top-level vdevs +to be removed. .sp Removing a top-level vdev reduces the total amount of space in the storage pool. The specified device will be evacuated by copying all allocated space from it to Modified: head/sys/contrib/openzfs/module/lua/llimits.h ============================================================================== --- head/sys/contrib/openzfs/module/lua/llimits.h Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/module/lua/llimits.h Thu Oct 1 23:28:21 2020 (r366350) @@ -126,16 +126,7 @@ typedef LUAI_UACNUMBER l_uacNumber; * Minimum amount of available stack space (in bytes) to make a C call. With * gsub() recursion, the stack space between each luaD_call() is 1256 bytes. */ -#if defined(__FreeBSD__) -/* - * FreeBSD needs a few extra bytes in unoptimized debug builds to avoid a - * double-fault handling the error when the max call depth is exceeded just - * before the C stack runs out. 64 bytes seems to do the trick. - */ -#define LUAI_MINCSTACK 4160 -#else #define LUAI_MINCSTACK 4096 -#endif /* ** maximum number of upvalues in a closure (both C and Lua). (Value Modified: head/sys/contrib/openzfs/module/os/freebsd/spl/spl_kstat.c ============================================================================== --- head/sys/contrib/openzfs/module/os/freebsd/spl/spl_kstat.c Thu Oct 1 23:11:58 2020 (r366349) +++ head/sys/contrib/openzfs/module/os/freebsd/spl/spl_kstat.c Thu Oct 1 23:28:21 2020 (r366350) @@ -55,6 +55,17 @@ __kstat_set_raw_ops(kstat_t *ksp, ksp->ks_raw_ops.addr = addr; } +void +__kstat_set_seq_raw_ops(kstat_t *ksp, + int (*headers)(struct seq_file *f), + int (*data)(char *buf, size_t size, void *data), + void *(*addr)(kstat_t *ksp, loff_t index)) +{ + ksp->ks_raw_ops.seq_headers = headers; + ksp->ks_raw_ops.data = data; + ksp->ks_raw_ops.addr = addr; +} + static int kstat_default_update(kstat_t *ksp, int rw) { @@ -160,7 +171,7 @@ kstat_sysctl_raw(SYSCTL_HANDLER_ARGS) void *data; kstat_t *ksp = arg1; void *(*addr_op)(kstat_t *ksp, loff_t index); - int n, rc = 0; + int n, has_header, rc = 0; sb = sbuf_new_auto(); if (sb == NULL) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"