diff --git a/.github/workflows/checkstyle.yaml b/.github/workflows/checkstyle.yaml index 14a921099e30..553d5df39796 100644 --- a/.github/workflows/checkstyle.yaml +++ b/.github/workflows/checkstyle.yaml @@ -6,7 +6,7 @@ on: jobs: checkstyle: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/zfs-tests-functional.yml b/.github/workflows/zfs-tests-functional.yml index 79973123fd41..cad763287ea9 100644 --- a/.github/workflows/zfs-tests-functional.yml +++ b/.github/workflows/zfs-tests-functional.yml @@ -26,7 +26,7 @@ jobs: xfslibs-dev libattr1-dev libacl1-dev libudev-dev libdevmapper-dev \ libssl-dev libffi-dev libaio-dev libelf-dev libmount-dev \ libpam0g-dev pamtester python-dev python-setuptools python-cffi \ - python3 python3-dev python3-setuptools python3-cffi + python3 python3-dev python3-setuptools python3-cffi python3-packaging - name: Autogen.sh run: | sh autogen.sh @@ -44,6 +44,17 @@ jobs: sudo sed -i.bak 's/updates/extra updates/' /etc/depmod.d/ubuntu.conf sudo depmod sudo modprobe zfs + # Workaround for cloud-init bug + # see https://github.com/openzfs/zfs/issues/12644 + FILE=/lib/udev/rules.d/10-cloud-init-hook-hotplug.rules + if [ -r "${FILE}" ]; then + HASH=$(md5sum "${FILE}" | awk '{ print $1 }') + if [ "${HASH}" = "121ff0ef1936cd2ef65aec0458a35772" ]; then + # Just shove a zd* exclusion right above the hotplug hook... + sudo sed -i -e s/'LABEL="cloudinit_hook"'/'KERNEL=="zd*", GOTO="cloudinit_end"\n&'/ "${FILE}" + sudo udevadm control --reload-rules + fi + fi # Workaround to provide additional free space for testing. # https://github.com/actions/virtual-environments/issues/2840 sudo rm -rf /usr/share/dotnet @@ -52,7 +63,7 @@ jobs: sudo rm -rf "$AGENT_TOOLSDIRECTORY" - name: Tests run: | - /usr/share/zfs/zfs-tests.sh -v -s 3G + /usr/share/zfs/zfs-tests.sh -vR -s 3G - name: Prepare artifacts if: failure() run: | @@ -61,7 +72,7 @@ jobs: sudo cp /var/log/syslog $RESULTS_PATH/ sudo chmod +r $RESULTS_PATH/* # Replace ':' in dir names, actions/upload-artifact doesn't support it - for f in $(find $RESULTS_PATH -name '*:*'); do mv "$f" "${f//:/__}"; done + for f in $(find /var/tmp/test_results -name '*:*'); do mv "$f" "${f//:/__}"; done - uses: actions/upload-artifact@v2 if: failure() with: diff --git a/.github/workflows/zfs-tests-sanity.yml b/.github/workflows/zfs-tests-sanity.yml index df089c81f4ce..78187212bb26 100644 --- a/.github/workflows/zfs-tests-sanity.yml +++ b/.github/workflows/zfs-tests-sanity.yml @@ -22,7 +22,7 @@ jobs: xfslibs-dev libattr1-dev libacl1-dev libudev-dev libdevmapper-dev \ libssl-dev libffi-dev libaio-dev libelf-dev libmount-dev \ libpam0g-dev pamtester python-dev python-setuptools python-cffi \ - python3 python3-dev python3-setuptools python3-cffi + python3 python3-dev python3-setuptools python3-cffi python3-packaging - name: Autogen.sh run: | sh autogen.sh @@ -40,6 +40,17 @@ jobs: sudo sed -i.bak 's/updates/extra updates/' /etc/depmod.d/ubuntu.conf sudo depmod sudo modprobe zfs + # Workaround for cloud-init bug + # see https://github.com/openzfs/zfs/issues/12644 + FILE=/lib/udev/rules.d/10-cloud-init-hook-hotplug.rules + if [ -r "${FILE}" ]; then + HASH=$(md5sum "${FILE}" | awk '{ print $1 }') + if [ "${HASH}" = "121ff0ef1936cd2ef65aec0458a35772" ]; then + # Just shove a zd* exclusion right above the hotplug hook... + sudo sed -i -e s/'LABEL="cloudinit_hook"'/'KERNEL=="zd*", GOTO="cloudinit_end"\n&'/ "${FILE}" + sudo udevadm control --reload-rules + fi + fi # Workaround to provide additional free space for testing. # https://github.com/actions/virtual-environments/issues/2840 sudo rm -rf /usr/share/dotnet @@ -48,7 +59,7 @@ jobs: sudo rm -rf "$AGENT_TOOLSDIRECTORY" - name: Tests run: | - /usr/share/zfs/zfs-tests.sh -v -s 3G -r sanity + /usr/share/zfs/zfs-tests.sh -vR -s 3G -r sanity - name: Prepare artifacts if: failure() run: | @@ -57,7 +68,7 @@ jobs: sudo cp /var/log/syslog $RESULTS_PATH/ sudo chmod +r $RESULTS_PATH/* # Replace ':' in dir names, actions/upload-artifact doesn't support it - for f in $(find $RESULTS_PATH -name '*:*'); do mv "$f" "${f//:/__}"; done + for f in $(find /var/tmp/test_results -name '*:*'); do mv "$f" "${f//:/__}"; done - uses: actions/upload-artifact@v2 if: failure() with: diff --git a/.github/workflows/zloop.yml b/.github/workflows/zloop.yml index 22c02b76e395..cf81ad4bcafc 100644 --- a/.github/workflows/zloop.yml +++ b/.github/workflows/zloop.yml @@ -22,8 +22,8 @@ jobs: xfslibs-dev libattr1-dev libacl1-dev libudev-dev libdevmapper-dev \ libssl-dev libffi-dev libaio-dev libelf-dev libmount-dev \ libpam0g-dev \ - python-dev python-setuptools python-cffi \ - python3 python3-dev python3-setuptools python3-cffi + python-dev python-setuptools python-cffi python-packaging \ + python3 python3-dev python3-setuptools python3-cffi python3-packaging - name: Autogen.sh run: | sh autogen.sh diff --git a/META b/META index 51218270a4ad..10130517955a 100644 --- a/META +++ b/META @@ -1,10 +1,10 @@ Meta: 1 Name: zfs Branch: 1.0 -Version: 2.1.1 +Version: 2.1.2 Release: 1 Release-Tags: relext License: CDDL Author: OpenZFS -Linux-Maximum: 5.14 +Linux-Maximum: 5.15 Linux-Minimum: 3.10 diff --git a/Makefile.am b/Makefile.am index 060729642533..34fe16ce4118 100644 --- a/Makefile.am +++ b/Makefile.am @@ -132,10 +132,11 @@ PHONY += checkabi storeabi checklibabiversion: libabiversion=`abidw -v | $(SED) 's/[^0-9]//g'`; \ - if test $$libabiversion -lt "180"; then \ + if test $$libabiversion -lt "200"; then \ /bin/echo -e "\n" \ - "*** Please use libabigail 1.8.0 version or newer;\n" \ - "*** otherwise results are not consistent!\n"; \ + "*** Please use libabigail 2.0.0 version or newer;\n" \ + "*** otherwise results are not consistent!\n" \ + "(or see https://github.com/openzfs/libabigail-docker )\n"; \ exit 1; \ fi; diff --git a/cmd/mount_zfs/mount_zfs.c b/cmd/mount_zfs/mount_zfs.c index b9be69d1fb02..de3833698a2b 100644 --- a/cmd/mount_zfs/mount_zfs.c +++ b/cmd/mount_zfs/mount_zfs.c @@ -368,7 +368,7 @@ main(int argc, char **argv) "mount the filesystem again.\n"), dataset); return (MOUNT_SYSERR); } - /* fallthru */ + fallthrough; #endif default: (void) fprintf(stderr, gettext("filesystem " diff --git a/cmd/vdev_id/vdev_id b/cmd/vdev_id/vdev_id index cad59c93f078..8cc4399a5668 100755 --- a/cmd/vdev_id/vdev_id +++ b/cmd/vdev_id/vdev_id @@ -375,7 +375,7 @@ sas_handler() { i=$((i + 1)) done - PHY=$(ls -d "$port_dir"/phy* 2>/dev/null | head -1 | awk -F: '{print $NF}') + PHY=$(ls -vd "$port_dir"/phy* 2>/dev/null | head -1 | awk -F: '{print $NF}') if [ -z "$PHY" ] ; then PHY=0 fi @@ -622,8 +622,8 @@ enclosure_handler () { PCI_ID=$(echo "$PCI_ID_LONG" | sed -r 's/^[0-9]+://g') # Name our device according to vdev_id.conf (like "L0" or "U1"). - NAME=$(awk '/channel/{if ($1 == "channel" && $2 == "$PCI_ID" && \ - $3 == "$PORT_ID") {print ${4}int(count[$4])}; count[$4]++}' $CONFIG) + NAME=$(awk "/channel/{if (\$1 == \"channel\" && \$2 == \"$PCI_ID\" && \ + \$3 == \"$PORT_ID\") {print \$4\$3}}" $CONFIG) echo "${NAME}" } diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index e964e3ba8acf..9de41cef2003 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -4096,7 +4096,7 @@ cksum_record_compare(const void *x1, const void *x2) const cksum_record_t *l = (cksum_record_t *)x1; const cksum_record_t *r = (cksum_record_t *)x2; int arraysize = ARRAY_SIZE(l->cksum.zc_word); - int difference; + int difference = 0; for (int i = 0; i < arraysize; i++) { difference = TREE_CMP(l->cksum.zc_word[i], r->cksum.zc_word[i]); @@ -4573,7 +4573,7 @@ dump_path_impl(objset_t *os, uint64_t obj, char *name, uint64_t *retobj) case DMU_OT_DIRECTORY_CONTENTS: if (s != NULL && *(s + 1) != '\0') return (dump_path_impl(os, child_obj, s + 1, retobj)); - /*FALLTHROUGH*/ + fallthrough; case DMU_OT_PLAIN_FILE_CONTENTS: if (retobj != NULL) { *retobj = child_obj; diff --git a/cmd/zed/zed.d/statechange-led.sh b/cmd/zed/zed.d/statechange-led.sh index 0f9da3204317..26e6064fa94a 100755 --- a/cmd/zed/zed.d/statechange-led.sh +++ b/cmd/zed/zed.d/statechange-led.sh @@ -29,7 +29,8 @@ [ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc" . "${ZED_ZEDLET_DIR}/zed-functions.sh" -if [ ! -d /sys/class/enclosure ] ; then +if [ ! -d /sys/class/enclosure ] && [ ! -d /sys/bus/pci/slots ] ; then + # No JBOD enclosure or NVMe slots exit 1 fi @@ -92,6 +93,29 @@ check_and_set_led() done } +# Fault LEDs for JBODs and NVMe drives are handled a little differently. +# +# On JBODs the fault LED is called 'fault' and on a path like this: +# +# /sys/class/enclosure/0:0:1:0/SLOT 10/fault +# +# On NVMe it's called 'attention' and on a path like this: +# +# /sys/bus/pci/slot/0/attention +# +# This function returns the full path to the fault LED file for a given +# enclosure/slot directory. +# +path_to_led() +{ + dir=$1 + if [ -f "$dir/fault" ] ; then + echo "$dir/fault" + elif [ -f "$dir/attention" ] ; then + echo "$dir/attention" + fi +} + state_to_val() { state="$1" @@ -105,6 +129,38 @@ state_to_val() esac } +# +# Given a nvme name like 'nvme0n1', pass back its slot directory +# like "/sys/bus/pci/slots/0" +# +nvme_dev_to_slot() +{ + dev="$1" + + # Get the address "0000:01:00.0" + address=$(cat "/sys/class/block/$dev/device/address") + + # For each /sys/bus/pci/slots subdir that is an actual number + # (rather than weird directories like "1-3/"). + # shellcheck disable=SC2010 + for i in $(ls /sys/bus/pci/slots/ | grep -E "^[0-9]+$") ; do + this_address=$(cat "/sys/bus/pci/slots/$i/address") + + # The format of address is a little different between + # /sys/class/block/$dev/device/address and + # /sys/bus/pci/slots/ + # + # address= "0000:01:00.0" + # this_address = "0000:01:00" + # + if echo "$address" | grep -Eq ^"$this_address" ; then + echo "/sys/bus/pci/slots/$i" + break + fi + done +} + + # process_pool (pool) # # Iterate through a pool and set the vdevs' enclosure slot LEDs to @@ -134,6 +190,11 @@ process_pool() # Get dev name (like 'sda') dev=$(basename "$(echo "$therest" | awk '{print $(NF-1)}')") vdev_enc_sysfs_path=$(realpath "/sys/class/block/$dev/device/enclosure_device"*) + if [ ! -d "$vdev_enc_sysfs_path" ] ; then + # This is not a JBOD disk, but it could be a PCI NVMe drive + vdev_enc_sysfs_path=$(nvme_dev_to_slot "$dev") + fi + current_val=$(echo "$therest" | awk '{print $NF}') if [ "$current_val" != "0" ] ; then @@ -145,9 +206,10 @@ process_pool() continue fi - if [ ! -e "$vdev_enc_sysfs_path/fault" ] ; then + led_path=$(path_to_led "$vdev_enc_sysfs_path") + if [ ! -e "$led_path" ] ; then rc=3 - zed_log_msg "vdev $vdev '$file/fault' doesn't exist" + zed_log_msg "vdev $vdev '$led_path' doesn't exist" continue fi @@ -158,7 +220,7 @@ process_pool() continue fi - if ! check_and_set_led "$vdev_enc_sysfs_path/fault" "$val"; then + if ! check_and_set_led "$led_path" "$val"; then rc=3 fi done @@ -169,7 +231,8 @@ if [ -n "$ZEVENT_VDEV_ENC_SYSFS_PATH" ] && [ -n "$ZEVENT_VDEV_STATE_STR" ] ; the # Got a statechange for an individual vdev val=$(state_to_val "$ZEVENT_VDEV_STATE_STR") vdev=$(basename "$ZEVENT_VDEV_PATH") - check_and_set_led "$ZEVENT_VDEV_ENC_SYSFS_PATH/fault" "$val" + ledpath=$(path_to_led "$ZEVENT_VDEV_ENC_SYSFS_PATH") + check_and_set_led "$ledpath" "$val" else # Process the entire pool poolname=$(zed_guid_to_pool "$ZEVENT_POOL_GUID") diff --git a/cmd/zed/zed.d/zed.rc b/cmd/zed/zed.d/zed.rc index df560f921e60..1c278b2ef96e 100644 --- a/cmd/zed/zed.d/zed.rc +++ b/cmd/zed/zed.d/zed.rc @@ -89,8 +89,8 @@ ## # Turn on/off enclosure LEDs when drives get DEGRADED/FAULTED. This works for -# device mapper and multipath devices as well. Your enclosure must be -# supported by the Linux SES driver for this to work. +# device mapper and multipath devices as well. This works with JBOD enclosures +# and NVMe PCI drives (assuming they're supported by Linux in sysfs). # ZED_USE_ENCLOSURE_LEDS=1 diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 7806d86398a9..d0bb73a72513 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -7475,6 +7475,7 @@ unshare_unmount(int op, int argc, char **argv) if (zfs_prop_get_int(zhp, ZFS_PROP_CANMOUNT) == ZFS_CANMOUNT_NOAUTO) continue; + break; default: break; } diff --git a/cmd/zpool/Makefile.am b/cmd/zpool/Makefile.am index aad45d4f7497..fa494c030e1c 100644 --- a/cmd/zpool/Makefile.am +++ b/cmd/zpool/Makefile.am @@ -26,7 +26,8 @@ zpool_LDADD = \ $(abs_top_builddir)/lib/libzfs/libzfs.la \ $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ $(abs_top_builddir)/lib/libnvpair/libnvpair.la \ - $(abs_top_builddir)/lib/libuutil/libuutil.la + $(abs_top_builddir)/lib/libuutil/libuutil.la \ + $(abs_top_builddir)/lib/libzutil/libzutil.la zpool_LDADD += $(LTLIBINTL) diff --git a/cmd/zpool/zpool.d/ses b/cmd/zpool/zpool.d/ses index f6b7520dfb6c..b1836d676528 100755 --- a/cmd/zpool/zpool.d/ses +++ b/cmd/zpool/zpool.d/ses @@ -41,7 +41,13 @@ for i in $scripts ; do val=$(ls "$VDEV_ENC_SYSFS_PATH/../device/scsi_generic" 2>/dev/null) ;; fault_led) - val=$(cat "$VDEV_ENC_SYSFS_PATH/fault" 2>/dev/null) + # JBODs fault LED is called 'fault', NVMe fault LED is called + # 'attention'. + if [ -f "$VDEV_ENC_SYSFS_PATH/fault" ] ; then + val=$(cat "$VDEV_ENC_SYSFS_PATH/fault" 2>/dev/null) + elif [ -f "$VDEV_ENC_SYSFS_PATH/attention" ] ; then + val=$(cat "$VDEV_ENC_SYSFS_PATH/attention" 2>/dev/null) + fi ;; locate_led) val=$(cat "$VDEV_ENC_SYSFS_PATH/locate" 2>/dev/null) diff --git a/cmd/zpool/zpool_iter.c b/cmd/zpool/zpool_iter.c index 3d7a0cfc35e6..abfa2b7f6b90 100644 --- a/cmd/zpool/zpool_iter.c +++ b/cmd/zpool/zpool_iter.c @@ -264,51 +264,6 @@ for_each_pool(int argc, char **argv, boolean_t unavail, return (ret); } -static int -for_each_vdev_cb(zpool_handle_t *zhp, nvlist_t *nv, pool_vdev_iter_f func, - void *data) -{ - nvlist_t **child; - uint_t c, children; - int ret = 0; - int i; - char *type; - - const char *list[] = { - ZPOOL_CONFIG_SPARES, - ZPOOL_CONFIG_L2CACHE, - ZPOOL_CONFIG_CHILDREN - }; - - for (i = 0; i < ARRAY_SIZE(list); i++) { - if (nvlist_lookup_nvlist_array(nv, list[i], &child, - &children) == 0) { - for (c = 0; c < children; c++) { - uint64_t ishole = 0; - - (void) nvlist_lookup_uint64(child[c], - ZPOOL_CONFIG_IS_HOLE, &ishole); - - if (ishole) - continue; - - ret |= for_each_vdev_cb(zhp, child[c], func, - data); - } - } - } - - if (nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &type) != 0) - return (ret); - - /* Don't run our function on root vdevs */ - if (strcmp(type, VDEV_TYPE_ROOT) != 0) { - ret |= func(zhp, nv, data); - } - - return (ret); -} - /* * This is the equivalent of for_each_pool() for vdevs. It iterates thorough * all vdevs in the pool, ignoring root vdevs and holes, calling func() on @@ -327,7 +282,7 @@ for_each_vdev(zpool_handle_t *zhp, pool_vdev_iter_f func, void *data) verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); } - return (for_each_vdev_cb(zhp, nvroot, func, data)); + return (for_each_vdev_cb((void *) zhp, nvroot, func, data)); } /* @@ -603,7 +558,7 @@ vdev_run_cmd_thread(void *cb_cmd_data) /* For each vdev in the pool run a command */ static int -for_each_vdev_run_cb(zpool_handle_t *zhp, nvlist_t *nv, void *cb_vcdl) +for_each_vdev_run_cb(void *zhp_data, nvlist_t *nv, void *cb_vcdl) { vdev_cmd_data_list_t *vcdl = cb_vcdl; vdev_cmd_data_t *data; @@ -611,6 +566,7 @@ for_each_vdev_run_cb(zpool_handle_t *zhp, nvlist_t *nv, void *cb_vcdl) char *vname = NULL; char *vdev_enc_sysfs_path = NULL; int i, match = 0; + zpool_handle_t *zhp = zhp_data; if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) != 0) return (1); diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index f95aece9561d..9cf0163ab327 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -5165,11 +5165,12 @@ get_stat_flags(zpool_list_t *list) * Return 1 if cb_data->cb_vdev_names[0] is this vdev's name, 0 otherwise. */ static int -is_vdev_cb(zpool_handle_t *zhp, nvlist_t *nv, void *cb_data) +is_vdev_cb(void *zhp_data, nvlist_t *nv, void *cb_data) { iostat_cbdata_t *cb = cb_data; char *name = NULL; int ret = 0; + zpool_handle_t *zhp = zhp_data; name = zpool_vdev_name(g_zfs, zhp, nv, cb->cb_name_flags); diff --git a/cmd/zpool/zpool_util.h b/cmd/zpool/zpool_util.h index 493f8cb98043..da75866f5145 100644 --- a/cmd/zpool/zpool_util.h +++ b/cmd/zpool/zpool_util.h @@ -27,6 +27,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -67,7 +68,6 @@ int for_each_pool(int, char **, boolean_t unavail, zprop_list_t **, boolean_t, zpool_iter_f, void *); /* Vdev list functions */ -typedef int (*pool_vdev_iter_f)(zpool_handle_t *, nvlist_t *, void *); int for_each_vdev(zpool_handle_t *zhp, pool_vdev_iter_f func, void *data); typedef struct zpool_list zpool_list_t; diff --git a/cmd/zpool_influxdb/zpool_influxdb.c b/cmd/zpool_influxdb/zpool_influxdb.c index 35c4770a1c14..d0b6e172ae57 100644 --- a/cmd/zpool_influxdb/zpool_influxdb.c +++ b/cmd/zpool_influxdb/zpool_influxdb.c @@ -117,6 +117,7 @@ escape_string(char *s) case '=': case '\\': *d++ = '\\'; + fallthrough; default: *d = *c; } diff --git a/config/Rules.am b/config/Rules.am index 99587eab2bf8..3b24e3630102 100644 --- a/config/Rules.am +++ b/config/Rules.am @@ -26,6 +26,7 @@ AM_LIBTOOLFLAGS = --silent AM_CFLAGS = -std=gnu99 -Wall -Wstrict-prototypes -Wmissing-prototypes AM_CFLAGS += -fno-strict-aliasing AM_CFLAGS += $(NO_OMIT_FRAME_POINTER) +AM_CFLAGS += $(IMPLICIT_FALLTHROUGH) AM_CFLAGS += $(DEBUG_CFLAGS) AM_CFLAGS += $(ASAN_CFLAGS) AM_CFLAGS += $(CODE_COVERAGE_CFLAGS) $(NO_FORMAT_ZERO_LENGTH) @@ -39,7 +40,6 @@ AM_CPPFLAGS = -D_GNU_SOURCE AM_CPPFLAGS += -D_REENTRANT AM_CPPFLAGS += -D_FILE_OFFSET_BITS=64 AM_CPPFLAGS += -D_LARGEFILE64_SOURCE -AM_CPPFLAGS += -DHAVE_LARGE_STACKS=1 AM_CPPFLAGS += -DLIBEXECDIR=\"$(libexecdir)\" AM_CPPFLAGS += -DRUNSTATEDIR=\"$(runstatedir)\" AM_CPPFLAGS += -DSBINDIR=\"$(sbindir)\" diff --git a/config/always-compiler-options.m4 b/config/always-compiler-options.m4 index a84123317989..ce84f7e60684 100644 --- a/config/always-compiler-options.m4 +++ b/config/always-compiler-options.m4 @@ -161,6 +161,29 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_UNUSED_BUT_SET_VARIABLE], [ AC_SUBST([NO_UNUSED_BUT_SET_VARIABLE]) ]) +dnl # +dnl # Check if gcc supports -Wimplicit-fallthrough option. +dnl # +AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_IMPLICIT_FALLTHROUGH], [ + AC_MSG_CHECKING([whether $CC supports -Wimplicit-fallthrough]) + + saved_flags="$CFLAGS" + CFLAGS="$CFLAGS -Werror -Wimplicit-fallthrough" + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [ + IMPLICIT_FALLTHROUGH=-Wimplicit-fallthrough + AC_DEFINE([HAVE_IMPLICIT_FALLTHROUGH], 1, + [Define if compiler supports -Wimplicit-fallthrough]) + AC_MSG_RESULT([yes]) + ], [ + IMPLICIT_FALLTHROUGH= + AC_MSG_RESULT([no]) + ]) + + CFLAGS="$saved_flags" + AC_SUBST([IMPLICIT_FALLTHROUGH]) +]) + dnl # dnl # Check if gcc supports -fno-omit-frame-pointer option. dnl # diff --git a/config/always-pyzfs.m4 b/config/always-pyzfs.m4 index 76e07b593df2..fa39fd88519c 100644 --- a/config/always-pyzfs.m4 +++ b/config/always-pyzfs.m4 @@ -46,6 +46,21 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_PYZFS], [ ]) AC_SUBST(DEFINE_PYZFS) + dnl # + dnl # Python "packaging" (or, failing that, "distlib") module is required to build and install pyzfs + dnl # + AS_IF([test "x$enable_pyzfs" = xcheck -o "x$enable_pyzfs" = xyes], [ + ZFS_AC_PYTHON_MODULE([packaging], [], [ + ZFS_AC_PYTHON_MODULE([distlib], [], [ + AS_IF([test "x$enable_pyzfs" = xyes], [ + AC_MSG_ERROR("Python $PYTHON_VERSION packaging and distlib modules are not installed") + ], [test "x$enable_pyzfs" != xno], [ + enable_pyzfs=no + ]) + ]) + ]) + ]) + dnl # dnl # Require python-devel libraries dnl # diff --git a/config/ax_python_devel.m4 b/config/ax_python_devel.m4 index faf6c2b0d7ef..fcf73dc20880 100644 --- a/config/ax_python_devel.m4 +++ b/config/ax_python_devel.m4 @@ -97,9 +97,18 @@ AC_DEFUN([AX_PYTHON_DEVEL],[ # Check for a version of Python >= 2.1.0 # AC_MSG_CHECKING([for a version of Python >= '2.1.0']) - ac_supports_python_ver=`$PYTHON -c "import sys; \ - ver = sys.version.split ()[[0]]; \ - print (ver >= '2.1.0')"` + ac_supports_python_ver=`cat<= '3.11.0' + ac_supports_python_ver=`cat< + #include + ],[ + #ifndef bio_set_dev + #error Not a macro + #endif + ], [], [ZFS_META_LICENSE]) +]) + AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_DEV], [ AC_MSG_CHECKING([whether bio_set_dev() is available]) ZFS_LINUX_TEST_RESULT([bio_set_dev], [ @@ -205,6 +223,15 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_DEV], [ AC_DEFINE(HAVE_BIO_SET_DEV_GPL_ONLY, 1, [bio_set_dev() GPL-only]) ]) + + AC_MSG_CHECKING([whether bio_set_dev() is a macro]) + ZFS_LINUX_TEST_RESULT([bio_set_dev_macro], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BIO_SET_DEV_MACRO, 1, + [bio_set_dev() is a macro]) + ],[ + AC_MSG_RESULT(no) + ]) ],[ AC_MSG_RESULT(no) ]) @@ -294,9 +321,8 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO_SUBMIT_BIO], [ ZFS_LINUX_TEST_SRC([submit_bio], [ #include ],[ - blk_qc_t blk_qc; struct bio *bio = NULL; - blk_qc = submit_bio(bio); + (void) submit_bio(bio); ]) ]) @@ -396,6 +422,58 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO_BDEV_DISK], [ ]) ]) +dnl # +dnl # Linux 5.16 API +dnl # +dnl # The Linux 5.16 API for submit_bio changed the return type to be +dnl # void instead of int +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_BDEV_SUBMIT_BIO_RETURNS_VOID], [ + ZFS_LINUX_TEST_SRC([bio_bdev_submit_bio_void], [ + #include + ],[ + struct block_device_operations *bdev = NULL; + __attribute__((unused)) void(*f)(struct bio *) = bdev->submit_bio; + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_BDEV_SUBMIT_BIO_RETURNS_VOID], [ + AC_MSG_CHECKING( + [whether block_device_operations->submit_bio() returns void]) + ZFS_LINUX_TEST_RESULT([bio_bdev_submit_bio_void], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BDEV_SUBMIT_BIO_RETURNS_VOID, 1, + [block_device_operations->submit_bio() returns void]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + +dnl # +dnl # Linux 5.16 API +dnl # +dnl # The Linux 5.16 API moved struct blkcg_gq into linux/blk-cgroup.h, which +dnl # has been around since 2015. This test looks for the presence of that +dnl # header, so that it can be conditionally included where it exists, but +dnl # still be backward compatible with kernels that pre-date its introduction. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_CGROUP_HEADER], [ + ZFS_LINUX_TEST_SRC([blk_cgroup_header], [ + #include + ], []) +]) + +AC_DEFUN([ZFS_AC_KERNEL_BLK_CGROUP_HEADER], [ + AC_MSG_CHECKING([for existence of linux/blk-cgroup.h]) + ZFS_LINUX_TEST_RESULT([blk_cgroup_header],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_LINUX_BLK_CGROUP_HEADER, 1, + [linux/blk-cgroup.h exists]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [ ZFS_AC_KERNEL_SRC_REQ ZFS_AC_KERNEL_SRC_BIO_OPS @@ -407,6 +485,9 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BIO], [ ZFS_AC_KERNEL_SRC_BIO_CURRENT_BIO_LIST ZFS_AC_KERNEL_SRC_BLKG_TRYGET ZFS_AC_KERNEL_SRC_BIO_BDEV_DISK + ZFS_AC_KERNEL_SRC_BDEV_SUBMIT_BIO_RETURNS_VOID + ZFS_AC_KERNEL_SRC_BIO_SET_DEV_MACRO + ZFS_AC_KERNEL_SRC_BLK_CGROUP_HEADER ]) AC_DEFUN([ZFS_AC_KERNEL_BIO], [ @@ -429,4 +510,6 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO], [ ZFS_AC_KERNEL_BIO_CURRENT_BIO_LIST ZFS_AC_KERNEL_BLKG_TRYGET ZFS_AC_KERNEL_BIO_BDEV_DISK + ZFS_AC_KERNEL_BDEV_SUBMIT_BIO_RETURNS_VOID + ZFS_AC_KERNEL_BLK_CGROUP_HEADER ]) diff --git a/config/kernel-blkdev.m4 b/config/kernel-blkdev.m4 index 61e66421f8ec..9c60e5dd4210 100644 --- a/config/kernel-blkdev.m4 +++ b/config/kernel-blkdev.m4 @@ -294,6 +294,27 @@ AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE], [ ]) ]) +dnl # +dnl # 5.13 API change +dnl # blkdev_get_by_path() no longer handles ERESTARTSYS +dnl # +dnl # Unfortunately we're forced to rely solely on the kernel version +dnl # number in order to determine the expected behavior. This was an +dnl # internal change to blkdev_get_by_dev(), see commit a8ed1a0607. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_ERESTARTSYS], [ + AC_MSG_CHECKING([whether blkdev_get_by_path() handles ERESTARTSYS]) + AS_VERSION_COMPARE([$LINUX_VERSION], [5.13.0], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BLKDEV_GET_ERESTARTSYS, 1, + [blkdev_get_by_path() handles ERESTARTSYS]) + ],[ + AC_MSG_RESULT(no) + ],[ + AC_MSG_RESULT(no) + ]) +]) + AC_DEFUN([ZFS_AC_KERNEL_SRC_BLKDEV], [ ZFS_AC_KERNEL_SRC_BLKDEV_GET_BY_PATH ZFS_AC_KERNEL_SRC_BLKDEV_PUT @@ -318,4 +339,5 @@ AC_DEFUN([ZFS_AC_KERNEL_BLKDEV], [ ZFS_AC_KERNEL_BLKDEV_CHECK_DISK_CHANGE ZFS_AC_KERNEL_BLKDEV_BDEV_CHECK_MEDIA_CHANGE ZFS_AC_KERNEL_BLKDEV_BDEV_WHOLE + ZFS_AC_KERNEL_BLKDEV_GET_ERESTARTSYS ]) diff --git a/config/kernel-config-defined.m4 b/config/kernel-config-defined.m4 index 9b9468269ca3..c7d18b49b14e 100644 --- a/config/kernel-config-defined.m4 +++ b/config/kernel-config-defined.m4 @@ -19,7 +19,6 @@ AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEFINED], [ ]) ]) - ZFS_AC_KERNEL_SRC_CONFIG_THREAD_SIZE ZFS_AC_KERNEL_SRC_CONFIG_DEBUG_LOCK_ALLOC ZFS_AC_KERNEL_SRC_CONFIG_TRIM_UNUSED_KSYMS ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_INFLATE @@ -29,42 +28,12 @@ AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEFINED], [ ZFS_LINUX_TEST_COMPILE_ALL([config]) AC_MSG_RESULT([done]) - ZFS_AC_KERNEL_CONFIG_THREAD_SIZE ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC ZFS_AC_KERNEL_CONFIG_TRIM_UNUSED_KSYMS ZFS_AC_KERNEL_CONFIG_ZLIB_INFLATE ZFS_AC_KERNEL_CONFIG_ZLIB_DEFLATE ]) -dnl # -dnl # Check configured THREAD_SIZE -dnl # -dnl # The stack size will vary by architecture, but as of Linux 3.15 on x86_64 -dnl # the default thread stack size was increased to 16K from 8K. Therefore, -dnl # on newer kernels and some architectures stack usage optimizations can be -dnl # conditionally applied to improve performance without negatively impacting -dnl # stability. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_THREAD_SIZE], [ - ZFS_LINUX_TEST_SRC([config_thread_size], [ - #include - ],[ - #if (THREAD_SIZE < 16384) - #error "THREAD_SIZE is less than 16K" - #endif - ]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_CONFIG_THREAD_SIZE], [ - AC_MSG_CHECKING([whether kernel was built with 16K or larger stacks]) - ZFS_LINUX_TEST_RESULT([config_thread_size], [ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_LARGE_STACKS, 1, [kernel has large stacks]) - ],[ - AC_MSG_RESULT([no]) - ]) -]) - dnl # dnl # Check CONFIG_DEBUG_LOCK_ALLOC dnl # diff --git a/config/kernel-fpu.m4 b/config/kernel-fpu.m4 index 4d6fe052289c..faa64f1ec46b 100644 --- a/config/kernel-fpu.m4 +++ b/config/kernel-fpu.m4 @@ -2,6 +2,9 @@ dnl # dnl # Handle differences in kernel FPU code. dnl # dnl # Kernel +dnl # 5.16: XCR code put into asm/fpu/xcr.h +dnl # HAVE_KERNEL_FPU_XCR_HEADER +dnl # dnl # 5.0: Wrappers have been introduced to save/restore the FPU state. dnl # This change was made to the 4.19.38 and 4.14.120 LTS kernels. dnl # HAVE_KERNEL_FPU_INTERNAL @@ -25,6 +28,18 @@ AC_DEFUN([ZFS_AC_KERNEL_FPU_HEADER], [ AC_DEFINE(HAVE_KERNEL_FPU_API_HEADER, 1, [kernel has asm/fpu/api.h]) AC_MSG_RESULT(asm/fpu/api.h) + AC_MSG_CHECKING([whether fpu/xcr header is available]) + ZFS_LINUX_TRY_COMPILE([ + #include + #include + ],[ + ],[ + AC_DEFINE(HAVE_KERNEL_FPU_XCR_HEADER, 1, + [kernel has asm/fpu/xcr.h]) + AC_MSG_RESULT(asm/fpu/xcr.h) + ],[ + AC_MSG_RESULT(no asm/fpu/xcr.h) + ]) ],[ AC_MSG_RESULT(i387.h & xcr.h) ]) diff --git a/config/kernel-pagemap-folio_wait_bit.m4 b/config/kernel-pagemap-folio_wait_bit.m4 new file mode 100644 index 000000000000..e0aaa4a57411 --- /dev/null +++ b/config/kernel-pagemap-folio_wait_bit.m4 @@ -0,0 +1,26 @@ +dnl # +dnl # Linux 5.16 no longer allows directly calling wait_on_page_bit, and +dnl # instead requires you to call folio-specific functions. In this case, +dnl # wait_on_page_bit(pg, PG_writeback) becomes +dnl # folio_wait_bit(pg, PG_writeback) +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_PAGEMAP_FOLIO_WAIT_BIT], [ + ZFS_LINUX_TEST_SRC([pagemap_has_folio_wait_bit], [ + #include + ],[ + static struct folio *f = NULL; + + folio_wait_bit(f, PG_writeback); + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_PAGEMAP_FOLIO_WAIT_BIT], [ + AC_MSG_CHECKING([folio_wait_bit() exists]) + ZFS_LINUX_TEST_RESULT([pagemap_has_folio_wait_bit], [ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_PAGEMAP_FOLIO_WAIT_BIT, 1, + [folio_wait_bit() exists]) + ],[ + AC_MSG_RESULT([no]) + ]) +]) diff --git a/config/kernel-vfs-iov_iter.m4 b/config/kernel-vfs-iov_iter.m4 index bee6d0be9666..ecdda939f1cf 100644 --- a/config/kernel-vfs-iov_iter.m4 +++ b/config/kernel-vfs-iov_iter.m4 @@ -74,6 +74,14 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_IOV_ITER], [ bytes = copy_from_iter((void *)&buf, size, &iter); ]) + + ZFS_LINUX_TEST_SRC([iov_iter_type], [ + #include + #include + ],[ + struct iov_iter iter = { 0 }; + __attribute__((unused)) enum iter_type i = iov_iter_type(&iter); + ]) ]) AC_DEFUN([ZFS_AC_KERNEL_VFS_IOV_ITER], [ @@ -149,6 +157,20 @@ AC_DEFUN([ZFS_AC_KERNEL_VFS_IOV_ITER], [ enable_vfs_iov_iter="no" ]) + dnl # + dnl # This checks for iov_iter_type() in linux/uio.h. It is not + dnl # required, however, and the module will compiled without it + dnl # using direct access of the member attribute + dnl # + AC_MSG_CHECKING([whether iov_iter_type() is available]) + ZFS_LINUX_TEST_RESULT([iov_iter_type], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_IOV_ITER_TYPE, 1, + [iov_iter_type() is available]) + ],[ + AC_MSG_RESULT(no) + ]) + dnl # dnl # As of the 4.9 kernel support is provided for iovecs, kvecs, dnl # bvecs and pipes in the iov_iter structure. As long as the diff --git a/config/kernel.m4 b/config/kernel.m4 index 0b94f3bd9cb6..bdd3caed2b3d 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -134,6 +134,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_SET_SPECIAL_STATE ZFS_AC_KERNEL_SRC_VFS_SET_PAGE_DIRTY_NOBUFFERS ZFS_AC_KERNEL_SRC_STANDALONE_LINUX_STDARG + ZFS_AC_KERNEL_SRC_PAGEMAP_FOLIO_WAIT_BIT AC_MSG_CHECKING([for available kernel interfaces]) ZFS_LINUX_TEST_COMPILE_ALL([kabi]) @@ -241,6 +242,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_SET_SPECIAL_STATE ZFS_AC_KERNEL_VFS_SET_PAGE_DIRTY_NOBUFFERS ZFS_AC_KERNEL_STANDALONE_LINUX_STDARG + ZFS_AC_KERNEL_PAGEMAP_FOLIO_WAIT_BIT ]) dnl # diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index 1af4356cde19..27041c054c26 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -211,6 +211,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [ ZFS_AC_CONFIG_ALWAYS_CC_NO_UNUSED_BUT_SET_VARIABLE ZFS_AC_CONFIG_ALWAYS_CC_NO_BOOL_COMPARE + ZFS_AC_CONFIG_ALWAYS_CC_IMPLICIT_FALLTHROUGH ZFS_AC_CONFIG_ALWAYS_CC_FRAME_LARGER_THAN ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_TRUNCATION ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_ZERO_LENGTH diff --git a/configure.ac b/configure.ac index 6f34b210d2b7..ebc7b276a640 100644 --- a/configure.ac +++ b/configure.ac @@ -221,6 +221,7 @@ AC_CONFIG_FILES([ tests/zfs-tests/cmd/mktree/Makefile tests/zfs-tests/cmd/mmap_exec/Makefile tests/zfs-tests/cmd/mmap_libaio/Makefile + tests/zfs-tests/cmd/mmap_seek/Makefile tests/zfs-tests/cmd/mmapwrite/Makefile tests/zfs-tests/cmd/nvlist_to_lua/Makefile tests/zfs-tests/cmd/randfree_file/Makefile diff --git a/include/libzutil.h b/include/libzutil.h index 82a802678903..6b9facdf9cbe 100644 --- a/include/libzutil.h +++ b/include/libzutil.h @@ -159,6 +159,16 @@ void color_start(char *color); void color_end(void); int printf_color(char *color, char *format, ...); +/* + * These functions are used by the ZFS libraries and cmd/zpool code, but are + * not exported in the ABI. + */ +typedef int (*pool_vdev_iter_f)(void *, nvlist_t *, void *); +int for_each_vdev_cb(void *zhp, nvlist_t *nv, pool_vdev_iter_f func, + void *data); +int for_each_vdev_in_nvlist(nvlist_t *nvroot, pool_vdev_iter_f func, + void *data); +void update_vdevs_config_dev_sysfs_path(nvlist_t *config); #ifdef __cplusplus } #endif diff --git a/include/os/freebsd/linux/compiler.h b/include/os/freebsd/linux/compiler.h index 05e93efa64d7..20903717b58d 100644 --- a/include/os/freebsd/linux/compiler.h +++ b/include/os/freebsd/linux/compiler.h @@ -67,6 +67,7 @@ #define __always_inline inline #define noinline __noinline #define ____cacheline_aligned __aligned(CACHE_LINE_SIZE) +#define fallthrough __attribute__((__fallthrough__)) #if !defined(_KERNEL) && !defined(_STANDALONE) #define likely(x) __builtin_expect(!!(x), 1) diff --git a/include/os/freebsd/spl/sys/random.h b/include/os/freebsd/spl/sys/random.h index 746275e53197..7583166e727b 100644 --- a/include/os/freebsd/spl/sys/random.h +++ b/include/os/freebsd/spl/sys/random.h @@ -51,7 +51,7 @@ random_get_pseudo_bytes(uint8_t *p, size_t s) static inline uint32_t random_in_range(uint32_t range) { -#if __FreeBSD_version >= 1300108 +#if defined(_KERNEL) && __FreeBSD_version >= 1300108 return (prng32_bounded(range)); #else uint32_t r; @@ -61,7 +61,7 @@ random_in_range(uint32_t range) if (range == 1) return (0); - (void) random_get_pseudo_bytes((void *)&r, sizeof (r)); + (void) random_get_pseudo_bytes((uint8_t *)&r, sizeof (r)); return (r % range); #endif diff --git a/include/os/freebsd/spl/sys/vnode.h b/include/os/freebsd/spl/sys/vnode.h index 3670712a0456..3bc8a18eeb72 100644 --- a/include/os/freebsd/spl/sys/vnode.h +++ b/include/os/freebsd/spl/sys/vnode.h @@ -59,6 +59,8 @@ enum symfollow { NO_FOLLOW = NOFOLLOW }; #include #include #include +#include +#include typedef struct vop_vector vnodeops_t; #define VOP_FID VOP_VPTOFH @@ -83,6 +85,22 @@ vn_is_readonly(vnode_t *vp) #define vn_has_cached_data(vp) \ ((vp)->v_object != NULL && \ (vp)->v_object->resident_page_count > 0) + +static __inline void +vn_flush_cached_data(vnode_t *vp, boolean_t sync) +{ +#if __FreeBSD_version > 1300054 + if (vm_object_mightbedirty(vp->v_object)) { +#else + if (vp->v_object->flags & OBJ_MIGHTBEDIRTY) { +#endif + int flags = sync ? OBJPC_SYNC : 0; + zfs_vmobject_wlock(vp->v_object); + vm_object_page_clean(vp->v_object, 0, 0, flags); + zfs_vmobject_wunlock(vp->v_object); + } +} + #define vn_exists(vp) do { } while (0) #define vn_invalid(vp) do { } while (0) #define vn_renamepath(tdvp, svp, tnm, lentnm) do { } while (0) diff --git a/include/os/freebsd/zfs/sys/zfs_context_os.h b/include/os/freebsd/zfs/sys/zfs_context_os.h index 8dbe907d098c..a32eb52c53c1 100644 --- a/include/os/freebsd/zfs/sys/zfs_context_os.h +++ b/include/os/freebsd/zfs/sys/zfs_context_os.h @@ -41,6 +41,10 @@ #include #include +#if KSTACK_PAGES * PAGE_SIZE >= 16384 +#define HAVE_LARGE_STACKS 1 +#endif + #define cond_resched() kern_yield(PRI_USER) #define taskq_create_sysdc(a, b, d, e, p, dc, f) \ diff --git a/include/os/freebsd/zfs/sys/zfs_znode_impl.h b/include/os/freebsd/zfs/sys/zfs_znode_impl.h index e90008c70a87..edb28d041a0c 100644 --- a/include/os/freebsd/zfs/sys/zfs_znode_impl.h +++ b/include/os/freebsd/zfs/sys/zfs_znode_impl.h @@ -118,7 +118,8 @@ extern minor_t zfsdev_minor_alloc(void); #define Z_ISLNK(type) ((type) == VLNK) #define Z_ISDIR(type) ((type) == VDIR) -#define zn_has_cached_data(zp) vn_has_cached_data(ZTOV(zp)) +#define zn_has_cached_data(zp) vn_has_cached_data(ZTOV(zp)) +#define zn_flush_cached_data(zp, sync) vn_flush_cached_data(ZTOV(zp), sync) #define zn_rlimit_fsize(zp, uio) \ vn_rlimit_fsize(ZTOV(zp), GET_UIO_STRUCT(uio), zfs_uio_td(uio)) diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h index 019d5390adec..9fa8884bb7a1 100644 --- a/include/os/linux/kernel/linux/blkdev_compat.h +++ b/include/os/linux/kernel/linux/blkdev_compat.h @@ -30,9 +30,9 @@ #define _ZFS_BLKDEV_H #include -#include #include #include +#include #include /* for SECTOR_* */ #ifndef HAVE_BLK_QUEUE_FLAG_SET diff --git a/include/os/linux/kernel/linux/compiler_compat.h b/include/os/linux/kernel/linux/compiler_compat.h index 921d32f246c5..2c0704da2e51 100644 --- a/include/os/linux/kernel/linux/compiler_compat.h +++ b/include/os/linux/kernel/linux/compiler_compat.h @@ -28,6 +28,14 @@ #include +#if !defined(fallthrough) +#if defined(HAVE_IMPLICIT_FALLTHROUGH) +#define fallthrough __attribute__((__fallthrough__)) +#else +#define fallthrough ((void)0) +#endif +#endif + #if !defined(READ_ONCE) #define READ_ONCE(x) ACCESS_ONCE(x) #endif diff --git a/include/os/linux/kernel/linux/simd_x86.h b/include/os/linux/kernel/linux/simd_x86.h index cdd3286d2147..f2ae0fcbc21a 100644 --- a/include/os/linux/kernel/linux/simd_x86.h +++ b/include/os/linux/kernel/linux/simd_x86.h @@ -88,6 +88,9 @@ #if defined(HAVE_KERNEL_FPU_API_HEADER) #include #include +#if defined(HAVE_KERNEL_FPU_XCR_HEADER) +#include +#endif #else #include #include diff --git a/include/os/linux/spl/sys/random.h b/include/os/linux/spl/sys/random.h index 2c446e155761..52e97e1ce068 100644 --- a/include/os/linux/spl/sys/random.h +++ b/include/os/linux/spl/sys/random.h @@ -46,7 +46,7 @@ random_in_range(uint32_t range) if (range == 1) return (0); - (void) random_get_pseudo_bytes((void *)&r, sizeof (r)); + (void) random_get_pseudo_bytes((uint8_t *)&r, sizeof (r)); return (r % range); } diff --git a/include/os/linux/zfs/sys/zfs_context_os.h b/include/os/linux/zfs/sys/zfs_context_os.h index de7015b929b6..9e4260558285 100644 --- a/include/os/linux/zfs/sys/zfs_context_os.h +++ b/include/os/linux/zfs/sys/zfs_context_os.h @@ -25,5 +25,11 @@ #include #include +#include +#include + +#if THREAD_SIZE >= 16384 +#define HAVE_LARGE_STACKS 1 +#endif #endif diff --git a/include/os/linux/zfs/sys/zfs_znode_impl.h b/include/os/linux/zfs/sys/zfs_znode_impl.h index 0a6273442b71..de46fc8f2bd8 100644 --- a/include/os/linux/zfs/sys/zfs_znode_impl.h +++ b/include/os/linux/zfs/sys/zfs_znode_impl.h @@ -71,6 +71,7 @@ extern "C" { #define Z_ISDIR(type) S_ISDIR(type) #define zn_has_cached_data(zp) ((zp)->z_is_mapped) +#define zn_flush_cached_data(zp, sync) write_inode_now(ZTOI(zp), sync) #define zn_rlimit_fsize(zp, uio) (0) /* diff --git a/include/sys/dnode.h b/include/sys/dnode.h index 2cdc5b8798ad..af8775b9ee00 100644 --- a/include/sys/dnode.h +++ b/include/sys/dnode.h @@ -425,6 +425,7 @@ boolean_t dnode_add_ref(dnode_t *dn, void *ref); void dnode_rele(dnode_t *dn, void *ref); void dnode_rele_and_unlock(dnode_t *dn, void *tag, boolean_t evicting); int dnode_try_claim(objset_t *os, uint64_t object, int slots); +boolean_t dnode_is_dirty(dnode_t *dn); void dnode_setdirty(dnode_t *dn, dmu_tx_t *tx); void dnode_set_dirtyctx(dnode_t *dn, dmu_tx_t *tx, void *tag); void dnode_sync(dnode_t *dn, dmu_tx_t *tx); diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index dbeb323ba428..a6ff94317195 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -650,7 +650,7 @@ random_in_range(uint32_t range) if (range == 1) return (0); - (void) random_get_pseudo_bytes((void *)&r, sizeof (r)); + (void) random_get_pseudo_bytes((uint8_t *)&r, sizeof (r)); return (r % range); } @@ -770,7 +770,6 @@ extern void spl_fstrans_unmark(fstrans_cookie_t); extern int __spl_pf_fstrans_check(void); extern int kmem_cache_reap_active(void); -#define ____cacheline_aligned /* * Kernel modules diff --git a/include/sys/zstd/zstd.h b/include/sys/zstd/zstd.h index e87dda1b18d1..ca32a7464556 100644 --- a/include/sys/zstd/zstd.h +++ b/include/sys/zstd/zstd.h @@ -210,12 +210,14 @@ zfs_get_hdrversion(const zfs_zstdhdr_t *blob) static inline void zfs_set_hdrversion(zfs_zstdhdr_t *blob, uint32_t version) { + /* cppcheck-suppress syntaxError */ BF32_SET(blob->raw_version_level, 0, 24, version); } static inline void zfs_set_hdrlevel(zfs_zstdhdr_t *blob, uint8_t level) { + /* cppcheck-suppress syntaxError */ BF32_SET(blob->raw_version_level, 24, 8, level); } diff --git a/lib/libnvpair/libnvpair.abi b/lib/libnvpair/libnvpair.abi index 9ce0ca16ebbb..4f961c83667d 100644 --- a/lib/libnvpair/libnvpair.abi +++ b/lib/libnvpair/libnvpair.abi @@ -1,10 +1,9 @@ - + + - - @@ -242,7 +241,7 @@ - + @@ -588,227 +587,104 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - + - + - + - + - + - - - - - - - + - + - + - + - + - + - + - + - + - - - - + - - - - - - - - - - - - + + - + - - - - - + + + - + - - - - - - - - - + + + + + + + + - - + + + @@ -831,25 +707,32 @@ - + - + - + - + - + - + + + + + + + + @@ -863,16 +746,9 @@ - - - - - - - + - - + @@ -1236,10 +1112,11 @@ - + - + + @@ -1249,11 +1126,10 @@ - + - - + @@ -1272,38 +1148,53 @@ - + - + - + - + - + - + - + - + - - + + + + + + + + + + + + + + + + + @@ -1313,9 +1204,9 @@ - + - + @@ -1328,9 +1219,35 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1343,190 +1260,89 @@ - - - - - - - + - + + + + + + - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - + + - - - + + + + - - + + - - - - - - - - + + - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + - + - + - + + + + + - @@ -1535,232 +1351,179 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - + + - + + + + - + - + + + + - - - - - + + - - + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1768,28 +1531,7 @@ - - - - - - - - - - - - - - - - - - - - - - + @@ -1797,13 +1539,7 @@ - - - - - - - + @@ -1811,8 +1547,7 @@ - - + @@ -1820,8 +1555,7 @@ - - + @@ -1829,8 +1563,7 @@ - - + @@ -1838,8 +1571,7 @@ - - + @@ -1847,8 +1579,7 @@ - - + @@ -1856,7 +1587,7 @@ - + @@ -1864,7 +1595,7 @@ - + @@ -1872,8 +1603,7 @@ - - + @@ -1881,7 +1611,7 @@ - + @@ -1889,7 +1619,7 @@ - + @@ -1897,7 +1627,7 @@ - + @@ -1905,8 +1635,7 @@ - - + @@ -1914,7 +1643,7 @@ - + @@ -1922,8 +1651,7 @@ - - + @@ -1931,7 +1659,7 @@ - + @@ -1939,7 +1667,7 @@ - + @@ -1947,7 +1675,7 @@ - + @@ -1955,7 +1683,7 @@ - + @@ -1963,7 +1691,7 @@ - + @@ -1971,7 +1699,7 @@ - + @@ -1979,7 +1707,7 @@ - + @@ -1987,7 +1715,7 @@ - + @@ -1995,7 +1723,7 @@ - + @@ -2003,7 +1731,7 @@ - + @@ -2011,73 +1739,158 @@ - - - - - - - - + - + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - + - + @@ -2091,31 +1904,31 @@ - + - + - + - + - + - + - + - - - + + + @@ -2123,11 +1936,15 @@ - + + + + + @@ -2135,8 +1952,10 @@ + + @@ -2207,8 +2026,10 @@ + + @@ -2222,6 +2043,169 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2384,236 +2368,100 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + - - - - - + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - + + + + + + - - - + + + + + - - - - + + + + + - - - + + + + + + - - - + + + + - - - - - - - - - - - - + + + + @@ -2628,34 +2476,20 @@ - + + - - + - - + - - + - - - - - - - - - - - - - + @@ -3114,104 +2948,106 @@ - + - + - - - - + - + - - + + - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + - + - + - + - + - + - - - - + + + + + + + + + + + + + + + + - - - + + + + + + + - - - + + + + - - - + + + + + + + + + - + @@ -3226,6 +3062,7 @@ + @@ -3234,7 +3071,7 @@ - + @@ -3252,7 +3089,6 @@ - @@ -3270,6 +3106,10 @@ + + + + @@ -3282,11 +3122,11 @@ - + - - + + diff --git a/lib/libspl/include/os/freebsd/sys/zfs_context_os.h b/lib/libspl/include/os/freebsd/sys/zfs_context_os.h index f5a136d22125..b9bf487c2aef 100644 --- a/lib/libspl/include/os/freebsd/sys/zfs_context_os.h +++ b/lib/libspl/include/os/freebsd/sys/zfs_context_os.h @@ -29,6 +29,7 @@ #ifndef ZFS_CONTEXT_OS_H_ #define ZFS_CONTEXT_OS_H_ +#define HAVE_LARGE_STACKS 1 #define ZFS_EXPORTS_PATH "/etc/zfs/exports" #endif diff --git a/lib/libspl/include/os/linux/sys/zfs_context_os.h b/lib/libspl/include/os/linux/sys/zfs_context_os.h index 008e57df4eae..81ced5207749 100644 --- a/lib/libspl/include/os/linux/sys/zfs_context_os.h +++ b/lib/libspl/include/os/linux/sys/zfs_context_os.h @@ -22,4 +22,7 @@ #ifndef ZFS_CONTEXT_OS_H #define ZFS_CONTEXT_OS_H + +#define HAVE_LARGE_STACKS 1 + #endif diff --git a/lib/libspl/include/sys/feature_tests.h b/lib/libspl/include/sys/feature_tests.h index 1a68b75f0cdc..a36fd7b8cffb 100644 --- a/lib/libspl/include/sys/feature_tests.h +++ b/lib/libspl/include/sys/feature_tests.h @@ -27,6 +27,15 @@ #ifndef _SYS_FEATURE_TESTS_H #define _SYS_FEATURE_TESTS_H -#define __NORETURN __attribute__((__noreturn__)) +#define ____cacheline_aligned +#define __NORETURN __attribute__((__noreturn__)) + +#if !defined(fallthrough) +#if defined(HAVE_IMPLICIT_FALLTHROUGH) +#define fallthrough __attribute__((__fallthrough__)) +#else +#define fallthrough ((void)0) +#endif +#endif #endif diff --git a/lib/libuutil/libuutil.abi b/lib/libuutil/libuutil.abi index 80af147a1ea1..21418ec1d4a0 100644 --- a/lib/libuutil/libuutil.abi +++ b/lib/libuutil/libuutil.abi @@ -1,12 +1,9 @@ - + - - - @@ -268,7 +265,15 @@ - + + + + + + + + + @@ -305,199 +310,76 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - + + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -508,41 +390,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - @@ -553,185 +410,93 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -742,41 +507,21 @@ - - - - - - - - - - - - - - - - - - - - @@ -787,129 +532,65 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -921,41 +602,21 @@ - - - - - - - - - - - - - - - - - - - - @@ -974,28 +635,25 @@ - - - - - - - - - - - - - + + + + + + + + + + @@ -1007,15 +665,6 @@ - - - - - - - - - @@ -1029,26 +678,26 @@ - + + - + - + - + - @@ -1105,13 +754,16 @@ - - + + + + + @@ -1123,14 +775,14 @@ - - + + - - + + @@ -1144,45 +796,35 @@ - - - - - - - + - - + + - + - - - - - - + + + + - - + + - - + - - + - - + + @@ -1191,155 +833,41 @@ - - - + + - - - + + + + + + + + + + - + - + - + - + - - + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -1395,14 +923,14 @@ - + - - + + @@ -1427,71 +955,62 @@ + - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - + @@ -1499,7 +1018,7 @@ - + @@ -1541,38 +1060,39 @@ + - - - + + + - - - + - - + + - - - - + + + + + + - - - + + + - + @@ -1593,13 +1113,17 @@ - + + + + + @@ -1627,18 +1151,33 @@ + + + + + + + - - - - + + + + + + + + + + + + @@ -1648,120 +1187,62 @@ - - - - - - - - + - + - + - + - + - - + - + + + + + - + + + + + + + + + - + - - - - + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + @@ -1785,24 +1266,40 @@ - - + - + - + - + - - + + - - + + + + + + + + + + + + + + + + + + + @@ -1811,50 +1308,87 @@ - - + - + - + - + - + - - - - - - - - - - - - - - + - - - - - - + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1872,6 +1406,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1978,104 +1585,31 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - + - - - - - + + + + + + + + + + + + + + + + + + + @@ -2089,16 +1623,29 @@ - + - + - + + + + + + + + + + + + + + @@ -2110,17 +1657,10 @@ - - - - - - - - - - + + + @@ -2189,16 +1729,16 @@ - + - + - + - + @@ -2210,25 +1750,18 @@ - - - - - - - - - - - - - - + + + + + + + @@ -2250,10 +1783,6 @@ - - - - @@ -2261,55 +1790,72 @@ - - + + - - + + + + + + + + + + + + + - + - + - + + + - - - - + - - + + + + + + + - - + + - - + + + + + - - + + - - + + - - + + - - + + - - + + - @@ -2345,44 +1891,38 @@ - - + - + - + - - - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - + + + + + - @@ -2472,6 +2012,11 @@ + + + + + @@ -2492,11 +2037,6 @@ - - - - - @@ -2518,9 +2058,9 @@ - - + + @@ -2542,10 +2082,14 @@ - - - - + + + + + + + + @@ -2556,26 +2100,22 @@ - - - - - - - + + + - - - - - + + + + + @@ -2585,9 +2125,11 @@ - - + + + + @@ -2596,19 +2138,12 @@ - - - - - - - @@ -2616,12 +2151,23 @@ + + + + + - + + + + + + + @@ -2674,33 +2220,27 @@ - - - - + - + - + - - - - + - - - + + + @@ -2716,7 +2256,7 @@ - + @@ -2727,5 +2267,10 @@ + + + + + diff --git a/lib/libzfs/libzfs.abi b/lib/libzfs/libzfs.abi index 2af0bd6f6956..82f8b7dc87f8 100644 --- a/lib/libzfs/libzfs.abi +++ b/lib/libzfs/libzfs.abi @@ -1,16 +1,15 @@ - + - + - + - @@ -20,8 +19,6 @@ - - @@ -287,7 +284,7 @@ - + @@ -367,7 +364,7 @@ - + @@ -427,23 +424,25 @@ - - - + + - + + + + + + + - + - - - - + - + @@ -467,24 +466,22 @@ - - + + - + - + - + - - - - - + + + @@ -508,8 +505,6 @@ - - @@ -534,26 +529,16 @@ - - - - - - - - - - - - + + + - - - + + @@ -561,144 +546,20 @@ - + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - @@ -716,6 +577,7 @@ + @@ -742,84 +604,75 @@ - + - + - - - - - - - - - - - + + - + - + - + - + - + - + - + - - + - + - + - + - - + + - + - - + + - + - - + + - + - + + @@ -827,6 +680,10 @@ + + + + @@ -855,18 +712,8 @@ - - - - - - - - - - - + @@ -875,11 +722,25 @@ - + - + - + + + + + + + + + + + + + + + @@ -906,23 +767,11 @@ - - - - - - - - - - - - - - - + + + @@ -937,54 +786,18 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + @@ -1006,93 +819,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - - + + + + @@ -1106,17 +841,8 @@ - - - - - - - - - - - + + @@ -1151,6 +877,27 @@ + + + + + + + + + + + + + + + + + + + + + @@ -1166,165 +913,26 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - - - - - - - - - - - - - - + + + + + + @@ -1339,56 +947,64 @@ - - - - - - - - - - - - - - - - + + + + + + + - - + + - - + + - - + + - + - + - + - - + + + + + + + + + + + + + + + + + + + @@ -1397,6 +1013,15 @@ + + + + + + + + + @@ -1445,38 +1070,21 @@ - - - - - - - - - - - - + + + - - - - - - - - - - - - + + + + @@ -1503,9 +1111,7 @@ - - - + @@ -1532,20 +1138,21 @@ - + - + - + - + - + + @@ -1574,52 +1181,24 @@ - - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -1643,28 +1222,24 @@ - + - + + + - + - - - - - - @@ -1680,46 +1255,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -1743,75 +1311,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - + - + - + - + - + - + - + + + + + @@ -1820,9 +1349,8 @@ - - + @@ -1830,44 +1358,232 @@ - - + + + + - + + + + + + + + + + + + + - + - + - + - + - - - - + - - - - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + @@ -1968,123 +1684,139 @@ - - - - - - - - - - + + - - - + + + + + + - - + + - + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + + + + + + + + + + + - + - + - + - + - + - + + + + - + + + + - + - + - - + + + + - - + + - - + + - - + + + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + @@ -2153,16 +1885,16 @@ - + - + - + - + @@ -2174,160 +1906,17 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - + - + @@ -2341,102 +1930,37 @@ - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -2450,6 +1974,7 @@ + @@ -2463,49 +1988,93 @@ - - - + + + + + + + + + + + + + + - - - + + + - - - - + + + + + - - - - + + + + + + + + - - - - + + + - - - + + + + - - - + + + + + + - - + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -2518,85 +2087,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - + - + - + + + - + - - + + - + + - + + + + + @@ -2605,22 +2144,15 @@ - - - + + + + - - - - - - - - - - - - + + + + @@ -2628,103 +2160,108 @@ + + + + + + + + + + + - + - + - - - + + + - - - - - + + - + - + - - - - + + - - - + + + - - - + + + + + + + + + - - + + + + + + + + + + + + - - + + - - - - - - - + + + + + + - - + - - + - - - - - + + + - - - - - - + - - - - - - - + + - - - + - + @@ -2743,42 +2280,22 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - + @@ -2810,115 +2327,105 @@ - - + + - + - - + + - - + + - - + + - - + + - - + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - + + - - + + - - + + - - + + - + @@ -2933,87 +2440,115 @@ - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -3028,6 +2563,9 @@ + + + @@ -3037,74 +2575,39 @@ - - - - - - - - - - - - - - - - - + + + - - - + + + + - - - - - + + + + - - - - + + + + - - - - + + - - - - - - + - - - - - - - - - - - + + - - - - - @@ -3113,91 +2616,131 @@ - + - - + - - - - + + + + + + + - - + + - - + - + - + - - - + + + + + + + + - - - + + + - - - - + + + + - - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - + + + + + + + + + + + + - - - - - - - - + + + - - + + - - + - - + - + + @@ -3205,28 +2748,59 @@ - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + @@ -3238,17 +2812,63 @@ - - + + - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3258,37 +2878,40 @@ + + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + @@ -3296,9 +2919,7 @@ - - - + @@ -3306,19 +2927,10 @@ - + - - - - - - - - - - + @@ -3326,10 +2938,10 @@ - + - + @@ -3340,20 +2952,40 @@ - + - + - - - + + + + + + + + + + + + + + + + + + + + + + + - + @@ -3361,7 +2993,7 @@ - + @@ -3372,89 +3004,29 @@ - + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + @@ -3463,10 +3035,13 @@ + + + @@ -3474,6 +3049,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3497,17 +3166,17 @@ + + + + + - - - - - @@ -3518,28 +3187,31 @@ - - - + + - - + - + + + + + + - - - - + + + + + + - - - + + - - + @@ -3547,8 +3219,16 @@ - - + + + + + + + + + + @@ -3556,12 +3236,33 @@ + + + + + + + - + + + + + + + + + + + + + + + @@ -3569,6 +3270,25 @@ + + + + + + + + + + + + + + + + + + + @@ -3580,174 +3300,24 @@ + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -3761,37 +3331,10 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -3815,8 +3358,27 @@ - - + + + + + + + + + + + + + + + + + + + + + @@ -3832,46 +3394,100 @@ - - - - + + - - - + + + + + + + + + + + + + + + + + + + - + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + - + - + + + + - + @@ -3886,33 +3502,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -3933,50 +3522,33 @@ - + - - - - + - - - - + - + - + - - - - + - + - - - - + - - - - - - - + + @@ -3984,8 +3556,10 @@ + + @@ -3995,413 +3569,347 @@ + - - - - - - - - - - + + + + - - - - + + + + - - + + - - - - + + + - - - - + + + + + + + + - - - + + + - - - - - + + + - - - + + + + + + - - - + + + + + + + + - - - - + + + + + - - - - + + - - - - - + - - - - + + + + + - - - + + + + - - - - - + + + + + + + - - - - + + + + - - - - - - - + + + + - - - - + + + + - - - - - - + + + + - - - - + + + - - - - - - + + + + - - - + + + + - - - - - - + + + - - - - - - - - - - - - + + - - - - - + + + - - - - + + - - - + + + + + + + - - - + + + + - - - - + + + + + - - - - + + + + + - - - + + + + + + - - - - + + + + + + + + + - - - - - + + + + - - - - + + + + - - - - - - - - - - - + + + + + - - - - - + + + - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - - - - - - + + + + + + - - - - - - + + + + + - - - - + + + + - - - - - + + + + - - - - + + + - - - - - + + + + - - - - + + + - - - - - + + + - - - - - + + + - - - - - + + + - - - - - - + + + - - + - - + + - - + - - + - - - + - + - - + + + + + - - - + - - - - + + + + + - - - + + + + + - - + + + - + - + + + + + - - - + + + - - - - + - - - - + @@ -4409,86 +3917,81 @@ - - - - - - - - - - - - - + + - - - + + + - + + - + + - + + - - - - - + - + - + + - - + + - + + + - + + - - + + - - - - + + - - - + + + - - - - + + + - - - - + + + - + + + + + + - + - + - + + - + + @@ -4497,43 +4000,42 @@ - + - - - - - + - - - - + + + + - - - - - - + + + - - - - + + + - - - + + + + + - - + + - - - + + + + + + + + @@ -4541,368 +4043,457 @@ - - - - - - - - - - - - - + + + + + + + + + - - + + + - - - + + - - - + + + + - - - - + + + + - - - - + + - - - + + + + + - - - + + + - - - - + + + - - - - - + + + + + + + + + - - - - + + + + + - - - + + + + + + + + - - - + + + + + - - - + + + - - - - + + + + - - - - - + + + + + + + + + + + + - - - + + + + + + + + + + + - - - - + + + + - - - + + + + + + + - - - - - - - - - + + + + - - - + + + + + + + - - - + + + - - - - + + + - - + + + + - - - - - + + + + - - - - - + + + + - - - - - + + + + + + + + + + - - - - + + + + + - - - - - - + + + + + - - - + + + + + - - - - - - - + + - - - - + + + + - - + + + + + - - - - + + + + + - - - - - - + + + + - - + + + + + + + + + + + + + + + + + - + + + - - - + + + + + + - - - + + + + + - - - - + + + + - - + + + + + + - - - - - + + + + + - - - + + + + + + + - - - - + + + + - - - - + + + + + - - - - + + + - - - - + + + + - - - - + + + - - - + + + + + + + + + + + - - - - - + + + + + + + + + + + + - - - - + + - - - - - - + + - - + + + + + - - + + + + + + + + + + + + - - + + - - + + + + + + + + + + + - - + + - - + - + - - - + + - - - - - - - - - - - - - - - + - + - + - + - - + - - - - + + + + + + + + + + + + + + + + + + + + + @@ -4911,11 +4502,10 @@ - + - + - @@ -4972,69 +4562,72 @@ + - - + - + + + + - - - - - - - - - - - - - - - - + + - + + - - - + + + + + + - - + + - + - + + - + - + + + + + + + + + + @@ -5042,11 +4635,21 @@ - + - + - + + + + + + + + + + + @@ -5058,17 +4661,7 @@ - - - - - - - - - - - + @@ -5113,15 +4706,16 @@ - + - + + @@ -5130,12 +4724,24 @@ - + + + + + + + + + + + + + @@ -5148,15 +4754,13 @@ - - - - - - - - + + + + + + @@ -5175,12 +4779,6 @@ - - - - - - @@ -5194,8 +4792,22 @@ - + + + + + + + + + + + + + + + @@ -5211,47 +4823,25 @@ - - - - - - - - - - - - - - - + - + - + - + - + - + - - - - - - - - @@ -5263,8 +4853,15 @@ - - + + + + + + + + + @@ -5274,61 +4871,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - + + @@ -5384,15 +4932,65 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5400,10 +4998,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5441,6 +5121,10 @@ + + + + @@ -5461,10 +5145,6 @@ - - - - @@ -5477,10 +5157,6 @@ - - - - @@ -5512,95 +5188,22 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + @@ -5609,29 +5212,110 @@ - - - - - - - - - - + + + + - - - + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5643,7 +5327,7 @@ - + @@ -5668,7 +5352,7 @@ - + @@ -5676,37 +5360,23 @@ - + - - + + - - - - + + + + + - - - - - - - - - - - - - - - - + @@ -5714,8 +5384,16 @@ - - + + + + + + + + + + @@ -5727,28 +5405,7 @@ - - - - - - - - - - - - - - - - - - - - - - + @@ -5788,390 +5445,323 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - + + + - - + + - - - + + + + + - - + + - - - - - + + + - - - + + + + + + - - - + + + + + + + - - + + + + - - + + + - - - + + - - - - + + - - - + + + + - - - - - - - - - - - - - - - + + + + + - - - - - - - + + + + - - - - - - - + + + + - - - - - + + + + - - - - + + + + + - - - - + + + + - - - - + + + + - - - - + + + - - - - - - + + + - - - - + + + + - - - - + + + + + + - - - - - + + + - - - - + + + - - - - + + + - - - + + + - - - - + + + + - - - - + + + + + - - - + + + + + - - - + + + + + - - - - + + + + + - - - - + + + + - - - - - - + + + - - - - - - - + + + + + + + - - - + + + + + + + + + + + + + + - + + + + + + + + - - - - - - - + + + + - - - - + + + - + - - - + + + + + + - - - - - - + + + + - - - + + - + + + + + - - + + + + - - - - - - - - - + - - - - - + + - + - - - - + - - + - + - + - + + - - - - - - - - + - - + - + - - - - + + + + + + + + + + + + + + @@ -6180,305 +5770,311 @@ - - - - - + + + + - + - - - - + + - - - - - + + + + + - - - - + + + + - - - + + + + + + + - - - + + + + + + + - - - + + + + + - - + + + - - - + + + + + - - - - - - - - + + + + - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - + + + + - - - - + + + + + + + - - + + + - - + + + + + + - - - - - + + + + - - - - + + + - - - - - + + + + - - - - - - - + + + + - - - - - + + + - - - - + + - - - - + + + - - - - + + + + - - - + + + + + + - - - + + + - - - - + + + + + + + + + + - - - - + + + - - - - - - - - - + + + + + - - - + + + + + + + - - - + + + + - - - + + + + - - - + + + + + + + - - - - - - - + + + + + + + - - - - - + + + - - - - + + + + + - - - + + + - - - + + + - + + + + + + + + - - - + + + + + + + + + + + + + - - - - - + + + + + - + - - - - - - - - - + + + - - + + + + - - - - - + + + - + - + - + - + - + - + - + - + - @@ -6532,8 +6128,8 @@ + - @@ -6575,6 +6171,7 @@ + @@ -6583,18 +6180,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + @@ -6609,41 +6300,41 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + @@ -6655,12 +6346,6 @@ - - - - - - @@ -6711,85 +6396,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -6848,15 +6454,6 @@ - - - - - - - - - @@ -7018,10 +6615,10 @@ - - + + @@ -7034,6 +6631,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7088,96 +6817,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + - - + - - - - - - - - - - - @@ -7185,63 +6832,28 @@ - - - - - - - + - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - + + + + + + @@ -7250,33 +6862,13 @@ - - - - - - - - - - - - - - - - - - - - - + @@ -7284,7 +6876,7 @@ - + @@ -7301,12 +6893,21 @@ - + - + - + + + + + + + + + + @@ -7333,40 +6934,27 @@ - - + + + - - - - - - + + + + + - - - + + - + - - - - - - - - - - - - - + - - + + @@ -7410,22 +6998,25 @@ - - - - - - - - - - - + + - + - + + + + + + + + + + + + + @@ -7440,8 +7031,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7490,6 +7164,9 @@ + + + @@ -7510,9 +7187,6 @@ - - - @@ -7553,192 +7227,126 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + + + - + + + + + + + + + + + + - + - + + + + - - + + + + - - + + + + - + + - - + + + + - + + + - - - - + - + - - + + - - - - - - + + + + - - - + + + - - + - + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + @@ -7758,36 +7366,46 @@ - - - - - - - - - - - - - - - - - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7849,65 +7467,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - + + - - - - - - - + + + - + + + - - - - + - @@ -7920,43 +7502,34 @@ - - - - + + + - - + - - - - - - + - - + - + + + + + + - - - + + + - - - - - - - + @@ -7964,12 +7537,18 @@ - + + + + + + + diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 2accfff28a6e..8251c434f81e 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -1363,10 +1363,9 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl, (void) zfs_error(hdl, EZFS_BADPROP, errbuf); goto error; } + fallthrough; } - /*FALLTHRU*/ - case ZFS_PROP_SHARESMB: case ZFS_PROP_SHARENFS: /* @@ -3765,8 +3764,8 @@ zfs_create(libzfs_handle_t *hdl, const char *path, zfs_type_t type, if (type == ZFS_TYPE_VOLUME) return (zfs_error(hdl, EZFS_VOLTOOBIG, errbuf)); + fallthrough; #endif - /* FALLTHROUGH */ default: return (zfs_standard_error(hdl, errno, errbuf)); } diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index 58056ac70377..c6884538df1d 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -314,7 +314,7 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, len); break; } - /* FALLTHROUGH */ + fallthrough; default: (void) strlcpy(buf, "-", len); break; @@ -405,7 +405,7 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, (void) snprintf(buf, len, "-"); break; } - /* FALLTHROUGH */ + fallthrough; default: (void) snprintf(buf, len, "%llu", (u_longlong_t)intval); } diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index 4340ff9552ef..86ff8c91a91e 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -4878,7 +4878,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, (void) zfs_error(hdl, EZFS_BUSY, errbuf); break; } - /* fallthru */ + fallthrough; default: (void) zfs_standard_error(hdl, ioctl_errno, errbuf); } diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index 4170cf019f7e..6e57d8e42563 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -598,7 +598,7 @@ zfs_setprop_error(libzfs_handle_t *hdl, zfs_prop_t prop, int err, break; } #endif - /* FALLTHROUGH */ + fallthrough; default: (void) zfs_standard_error(hdl, err, errbuf); } diff --git a/lib/libzfs_core/libzfs_core.abi b/lib/libzfs_core/libzfs_core.abi index ce9cc89f019b..c15cb3afbfca 100644 --- a/lib/libzfs_core/libzfs_core.abi +++ b/lib/libzfs_core/libzfs_core.abi @@ -1,19 +1,16 @@ - + - - + - - @@ -162,6 +159,8 @@ + + @@ -256,6 +255,7 @@ + @@ -294,7 +294,7 @@ - + @@ -350,57 +350,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + @@ -410,15 +363,17 @@ - - + + + + @@ -428,13 +383,13 @@ - + - - + + @@ -450,8 +405,6 @@ - - @@ -468,420 +421,92 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -892,41 +517,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - @@ -937,185 +537,93 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1126,41 +634,21 @@ - - - - - - - - - - - - - - - - - - - - @@ -1171,129 +659,65 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1305,41 +729,21 @@ - - - - - - - - - - - - - - - - - - - - @@ -1358,25 +762,24 @@ - - - - - - - - - - - + + + + + + + + + + @@ -1388,15 +791,6 @@ - - - - - - - - - @@ -1410,26 +804,26 @@ - + + - + - + - + - @@ -1486,26 +880,28 @@ - + + + - - + + - - + + @@ -1514,36 +910,20 @@ - - - - - - - + - + - - - - - - - - - - - + - + @@ -1601,115 +981,56 @@ + - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - + - + + + + + + + + + @@ -1751,128 +1072,165 @@ + - - - - - - - - - - + + + - - - + + + + + + + + + + - - - + + + - + - + - - + + + + - + - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + + + - - - - + - + - + - + - + - - + + - - + + - - - + + + - - + + - - - - + + - - - - + - - + + - - - + + + + + + + + + - - + + - - - - + - + @@ -1880,42 +1238,52 @@ - - - + - + - - - - - + + - - + + + + + + + + + + + + + + + + + @@ -1936,82 +1304,32 @@ - - - + + + - - + + - - + + - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - @@ -2034,39 +1352,39 @@ - - - + + + - - - + + + - - - + + + - + - + - - - + + + - + - - + + @@ -2075,9 +1393,9 @@ - - - + + + @@ -2086,56 +1404,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + + + + + + + + + + + + - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2189,101 +1525,54 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + - + - + - + - + - - + - + - + - + - + - + - + - + - + @@ -2296,7 +1585,226 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2314,38 +1822,51 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + @@ -2360,81 +1881,44 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2443,12 +1927,6 @@ - - - - - - @@ -2499,85 +1977,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2636,15 +2035,6 @@ - - - - - - - - - @@ -2766,82 +2156,116 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + - + + + + + + + - + - - + + + + + + + + + + + + + + + + + + + + - + + - + - + - + - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -2949,103 +2373,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -3060,18 +2387,32 @@ - - - + + + + + + + + + + + - + - + + + + + + + @@ -3098,70 +2439,23 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -3182,6 +2476,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3261,38 +2697,38 @@ - + - - - - + + - + - + + - + + @@ -3511,98 +2947,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -3612,67 +2958,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - + + - - + - - + + - - - - + + + + + + @@ -3682,43 +2991,47 @@ - - - - - - + - + - + - + - + - + - + - + - + - - + + - - + + + + + + + + + + + @@ -3762,8 +3075,6 @@ - - @@ -3784,39 +3095,84 @@ - - + + + + - + - + - - - - - - - - - - + - - + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3845,87 +3201,38 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + - - - - + - - - - - - - - - - - - - - - - - - - + + + + + + + - - + + @@ -3933,9 +3240,9 @@ - - - + + + @@ -3943,8 +3250,8 @@ - - + + @@ -3952,29 +3259,25 @@ - - - - - + - + - - - + + + - - - + + + @@ -3982,56 +3285,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + - - - - + + + + - - - - - - - - - - + + + + - - - + + + - - + + + + + + + + + + + + + + + + + + @@ -4044,10 +3372,6 @@ - - - - @@ -4055,65 +3379,68 @@ - + + + + + - + + - + - + + - + - - + + - - - - - - - + - - + + - + - + - + - + - + - + - + - + - + + + + @@ -4170,188 +3497,73 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - - + + - - + + - - + + + + + + + + + + + + - - + + - - + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + + + + + - - - - + - + - - - - @@ -4369,18 +3581,70 @@ - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - @@ -4398,23 +3662,30 @@ - - - + + + + + + + + + - + - + - + + - + @@ -4441,7 +3712,7 @@ - + @@ -4453,70 +3724,84 @@ - - - - - - - - - - - - - - - - + - - - + - - - - + - + - + - + + + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -4525,111 +3810,148 @@ - + - - - - - - - - - - - + + - + - - + + - - + - + - - - - - - - - - - + + - + - + - + - - - - + - - - - + - + - + - + - + - + + + + - + + + + - + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + @@ -4637,6 +3959,7 @@ + @@ -4645,114 +3968,36 @@ + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - + + + - + + + - - - - - - - + @@ -4766,36 +4011,24 @@ - - - - - - - - - - - - + + + - - - + + + + - - - + + + - - - + + + - - - - - + @@ -4803,16 +4036,42 @@ + + + + + + - + + + + + + + + + + + + + + + + + + + + + - + @@ -4821,6 +4080,12 @@ + + + + + + @@ -4828,29 +4093,30 @@ - + - - + + - + - + + + + - - + - - + - - - + + + @@ -4859,78 +4125,113 @@ - - - - - - - - - - - + - + - - - + + + + + + - - - + + + + - - - - + + + + - - - - + + + - - - - - - + + + + + + - - + + + + + - - - - + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + - - + - + + + + + + + + + + + + + + + + + + + + + + + @@ -4941,37 +4242,90 @@ - - - + + + + + - + - + + + + - - - - + + + + - - - + + + + + - - + + + + - - - + + + + - + + + + + + + + + + - + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4980,9 +4334,15 @@ + + + + + + - - + + @@ -4990,16 +4350,12 @@ - - - - - - + + - + @@ -5048,9 +4404,6 @@ - - - @@ -5060,12 +4413,14 @@ + + + - + - + - @@ -5092,12 +4447,13 @@ - + + diff --git a/lib/libzfsbootenv/libzfsbootenv.abi b/lib/libzfsbootenv/libzfsbootenv.abi index 805223708ec7..0ddd41d0630e 100644 --- a/lib/libzfsbootenv/libzfsbootenv.abi +++ b/lib/libzfsbootenv/libzfsbootenv.abi @@ -1,22 +1,19 @@ - + - - + - + - - @@ -26,35 +23,36 @@ - + - + - + + + + - - + + - - - + @@ -72,16 +70,23 @@ - - - - - + + + + + + + + + + + + @@ -150,16 +155,16 @@ - + - + - + - + @@ -171,29 +176,20 @@ - - - - - - - - - - - - - - + + + + + @@ -202,61 +198,74 @@ - - - - - - - - - - - + + + + + + + + + + + + + - - + + + - + + + + + + + + + + + - - - + - + + - - - + + + + - + - + + - - - + + - - + + - - + + - - + + @@ -264,65 +273,68 @@ - - + + + - - - + + + + - - - - + + + - - - - - - + + - - - + + + + + + + + - + - - - - - + - - - - - + + + + + - + - - - - - - + + + + + + + + + + + @@ -335,137 +347,122 @@ - - - - - - - - - - + + + + - - - - - - - - - - + + + + - - - + + + + - + - + - + - - + + - - - - + + + + - + - + - + - - + - + - - + - + - - + - + - + - + - + - + - + - + - - + - + - + - + - + - + - + - + - + - + - + @@ -476,85 +473,105 @@ - + - + - + - + - + - + + - + - + + - + - + + - + - + + - + - - + - + - - - - + + + + - - - - + + + + - - + + + + + + + + + + + + + + + + + + + - + + + + + + - - - - - diff --git a/lib/libzfsbootenv/lzbe_device.c b/lib/libzfsbootenv/lzbe_device.c index 2d8833b4fff2..2d9c7b749ef2 100644 --- a/lib/libzfsbootenv/lzbe_device.c +++ b/lib/libzfsbootenv/lzbe_device.c @@ -63,7 +63,7 @@ lzbe_set_boot_device(const char *pool, lzbe_flags_t flag, const char *device) /* Drop this nvlist */ fnvlist_free(nv); } - /* FALLTHROUGH */ + fallthrough; case lzbe_replace: nv = fnvlist_alloc(); break; diff --git a/lib/libzutil/os/freebsd/zutil_import_os.c b/lib/libzutil/os/freebsd/zutil_import_os.c index 36c4d90aa4b9..7c48e06f9315 100644 --- a/lib/libzutil/os/freebsd/zutil_import_os.c +++ b/lib/libzutil/os/freebsd/zutil_import_os.c @@ -247,3 +247,8 @@ zfs_dev_flush(int fd __unused) { return (0); } + +void +update_vdevs_config_dev_sysfs_path(nvlist_t *config) +{ +} diff --git a/lib/libzutil/os/linux/zutil_device_path_os.c b/lib/libzutil/os/linux/zutil_device_path_os.c index 2a6f4ae2a222..13f8bd031612 100644 --- a/lib/libzutil/os/linux/zutil_device_path_os.c +++ b/lib/libzutil/os/linux/zutil_device_path_os.c @@ -154,18 +154,148 @@ zfs_strip_path(char *path) return (strrchr(path, '/') + 1); } +/* + * Read the contents of a sysfs file into an allocated buffer and remove the + * last newline. + * + * This is useful for reading sysfs files that return a single string. Return + * an allocated string pointer on success, NULL otherwise. Returned buffer + * must be freed by the user. + */ +static char * +zfs_read_sysfs_file(char *filepath) +{ + char buf[4096]; /* all sysfs files report 4k size */ + char *str = NULL; + + FILE *fp = fopen(filepath, "r"); + if (fp == NULL) { + return (NULL); + } + if (fgets(buf, sizeof (buf), fp) == buf) { + /* success */ + + /* Remove the last newline (if any) */ + size_t len = strlen(buf); + if (buf[len - 1] == '\n') { + buf[len - 1] = '\0'; + } + str = strdup(buf); + } + + fclose(fp); + + return (str); +} + +/* + * Given a dev name like "nvme0n1", return the full PCI slot sysfs path to + * the drive (in /sys/bus/pci/slots). + * + * For example: + * dev: "nvme0n1" + * returns: "/sys/bus/pci/slots/0" + * + * 'dev' must be an NVMe device. + * + * Returned string must be freed. Returns NULL on error or no sysfs path. + */ +static char * +zfs_get_pci_slots_sys_path(const char *dev_name) +{ + DIR *dp = NULL; + struct dirent *ep; + char *address1 = NULL; + char *address2 = NULL; + char *path = NULL; + char buf[MAXPATHLEN]; + char *tmp; + + /* If they preface 'dev' with a path (like "/dev") then strip it off */ + tmp = strrchr(dev_name, '/'); + if (tmp != NULL) + dev_name = tmp + 1; /* +1 since we want the chr after '/' */ + + if (strncmp("nvme", dev_name, 4) != 0) + return (NULL); + + (void) snprintf(buf, sizeof (buf), "/sys/block/%s/device/address", + dev_name); + + address1 = zfs_read_sysfs_file(buf); + if (!address1) + return (NULL); + + /* + * /sys/block/nvme0n1/device/address format will + * be "0000:01:00.0" while /sys/bus/pci/slots/0/address will be + * "0000:01:00". Just NULL terminate at the '.' so they match. + */ + tmp = strrchr(address1, '.'); + if (tmp != NULL) + *tmp = '\0'; + + dp = opendir("/sys/bus/pci/slots/"); + if (dp == NULL) { + free(address1); + return (NULL); + } + + /* + * Look through all the /sys/bus/pci/slots/ subdirs + */ + while ((ep = readdir(dp))) { + /* + * We only care about directory names that are a single number. + * Sometimes there's other directories like + * "/sys/bus/pci/slots/0-3/" in there - skip those. + */ + if (!zfs_isnumber(ep->d_name)) + continue; + + (void) snprintf(buf, sizeof (buf), + "/sys/bus/pci/slots/%s/address", ep->d_name); + + address2 = zfs_read_sysfs_file(buf); + if (!address2) + continue; + + if (strcmp(address1, address2) == 0) { + /* Addresses match, we're all done */ + free(address2); + if (asprintf(&path, "/sys/bus/pci/slots/%s", + ep->d_name) == -1) { + free(tmp); + continue; + } + break; + } + free(address2); + } + + closedir(dp); + free(address1); + + return (path); +} + /* * Given a dev name like "sda", return the full enclosure sysfs path to * the disk. You can also pass in the name with "/dev" prepended - * to it (like /dev/sda). + * to it (like /dev/sda). This works for both JBODs and NVMe PCI devices. * * For example, disk "sda" in enclosure slot 1: - * dev: "sda" + * dev_name: "sda" * returns: "/sys/class/enclosure/1:0:3:0/Slot 1" * + * Or: + * + * dev_name: "nvme0n1" + * returns: "/sys/bus/pci/slots/0" + * * 'dev' must be a non-devicemapper device. * - * Returned string must be freed. + * Returned string must be freed. Returns NULL on error. */ char * zfs_get_enclosure_sysfs_path(const char *dev_name) @@ -252,6 +382,16 @@ zfs_get_enclosure_sysfs_path(const char *dev_name) if (dp != NULL) closedir(dp); + if (!path) { + /* + * This particular disk isn't in a JBOD. It could be an NVMe + * drive. If so, look up the NVMe device's path in + * /sys/bus/pci/slots/. Within that directory is a 'attention' + * file which controls the NVMe fault LED. + */ + path = zfs_get_pci_slots_sys_path(dev_name); + } + return (path); } diff --git a/lib/libzutil/os/linux/zutil_import_os.c b/lib/libzutil/os/linux/zutil_import_os.c index 61c42cf2e3a2..6c406d373a0c 100644 --- a/lib/libzutil/os/linux/zutil_import_os.c +++ b/lib/libzutil/os/linux/zutil_import_os.c @@ -65,6 +65,7 @@ #include #include #include +#include #include "zutil_import.h" @@ -776,6 +777,58 @@ encode_device_strings(const char *path, vdev_dev_strs_t *ds, #endif } +/* + * Rescan the enclosure sysfs path for turning on enclosure LEDs and store it + * in the nvlist * (if applicable). Like: + * vdev_enc_sysfs_path: '/sys/class/enclosure/11:0:1:0/SLOT 4' + */ +static void +update_vdev_config_dev_sysfs_path(nvlist_t *nv, char *path) +{ + char *upath, *spath; + + /* Add enclosure sysfs path (if disk is in an enclosure). */ + upath = zfs_get_underlying_path(path); + spath = zfs_get_enclosure_sysfs_path(upath); + + if (spath) { + nvlist_add_string(nv, ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH, spath); + } else { + nvlist_remove_all(nv, ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH); + } + + free(upath); + free(spath); +} + +/* + * This will get called for each leaf vdev. + */ +static int +sysfs_path_pool_vdev_iter_f(void *hdl_data, nvlist_t *nv, void *data) +{ + char *path = NULL; + if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) != 0) + return (1); + + /* Rescan our enclosure sysfs path for this vdev */ + update_vdev_config_dev_sysfs_path(nv, path); + return (0); +} + +/* + * Given an nvlist for our pool (with vdev tree), iterate over all the + * leaf vdevs and update their ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH. + */ +void +update_vdevs_config_dev_sysfs_path(nvlist_t *config) +{ + nvlist_t *nvroot = NULL; + verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, + &nvroot) == 0); + for_each_vdev_in_nvlist(nvroot, sysfs_path_pool_vdev_iter_f, NULL); +} + /* * Update a leaf vdev's persistent device strings * @@ -802,7 +855,6 @@ update_vdev_config_dev_strs(nvlist_t *nv) vdev_dev_strs_t vds; char *env, *type, *path; uint64_t wholedisk = 0; - char *upath, *spath; /* * For the benefit of legacy ZFS implementations, allow @@ -849,18 +901,7 @@ update_vdev_config_dev_strs(nvlist_t *nv) (void) nvlist_add_string(nv, ZPOOL_CONFIG_PHYS_PATH, vds.vds_devphys); } - - /* Add enclosure sysfs path (if disk is in an enclosure). */ - upath = zfs_get_underlying_path(path); - spath = zfs_get_enclosure_sysfs_path(upath); - if (spath) - nvlist_add_string(nv, ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH, - spath); - else - nvlist_remove_all(nv, ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH); - - free(upath); - free(spath); + update_vdev_config_dev_sysfs_path(nv, path); } else { /* Clear out any stale entries. */ (void) nvlist_remove_all(nv, ZPOOL_CONFIG_DEVID); diff --git a/lib/libzutil/zutil_import.c b/lib/libzutil/zutil_import.c index 0e59ec8c88c8..d91953813d8c 100644 --- a/lib/libzutil/zutil_import.c +++ b/lib/libzutil/zutil_import.c @@ -1023,9 +1023,11 @@ zpool_read_label(int fd, nvlist_t **config, int *num_labels) // This shouldn't be possible to // encounter, die if we do. ASSERT(B_FALSE); + fallthrough; case EOPNOTSUPP: case ENOSYS: do_slow = B_TRUE; + fallthrough; case 0: default: (void) aio_return(&aiocbs[l]); @@ -1676,6 +1678,8 @@ zpool_find_import_cached(libpc_handle_t *hdl, importargs_t *iarg) return (NULL); } + update_vdevs_config_dev_sysfs_path(src); + if ((dst = zutil_refresh_config(hdl, src)) == NULL) { nvlist_free(raw); nvlist_free(pools); @@ -1833,3 +1837,69 @@ zpool_find_config(void *hdl, const char *target, nvlist_t **configp, return (0); } + +/* + * Internal function for iterating over the vdevs. + * + * For each vdev, func() will be called and will be passed 'zhp' (which is + * typically the zpool_handle_t cast as a void pointer), the vdev's nvlist, and + * a user-defined data pointer). + * + * The return values from all the func() calls will be OR'd together and + * returned. + */ +int +for_each_vdev_cb(void *zhp, nvlist_t *nv, pool_vdev_iter_f func, + void *data) +{ + nvlist_t **child; + uint_t c, children; + int ret = 0; + int i; + char *type; + + const char *list[] = { + ZPOOL_CONFIG_SPARES, + ZPOOL_CONFIG_L2CACHE, + ZPOOL_CONFIG_CHILDREN + }; + + for (i = 0; i < ARRAY_SIZE(list); i++) { + if (nvlist_lookup_nvlist_array(nv, list[i], &child, + &children) == 0) { + for (c = 0; c < children; c++) { + uint64_t ishole = 0; + + (void) nvlist_lookup_uint64(child[c], + ZPOOL_CONFIG_IS_HOLE, &ishole); + + if (ishole) + continue; + + ret |= for_each_vdev_cb(zhp, child[c], + func, data); + } + } + } + + if (nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &type) != 0) + return (ret); + + /* Don't run our function on root vdevs */ + if (strcmp(type, VDEV_TYPE_ROOT) != 0) { + ret |= func(zhp, nv, data); + } + + return (ret); +} + +/* + * Given an ZPOOL_CONFIG_VDEV_TREE nvpair, iterate over all the vdevs, calling + * func() for each one. func() is passed the vdev's nvlist and an optional + * user-defined 'data' pointer. + */ +int +for_each_vdev_in_nvlist(nvlist_t *nvroot, pool_vdev_iter_f func, void *data) +{ + return (for_each_vdev_cb(NULL, nvroot, func, data)); +} diff --git a/lib/libzutil/zutil_nicenum.c b/lib/libzutil/zutil_nicenum.c index 1a19db0dfebc..4dcac1f855ff 100644 --- a/lib/libzutil/zutil_nicenum.c +++ b/lib/libzutil/zutil_nicenum.c @@ -27,6 +27,7 @@ #include #include #include +#include /* * Return B_TRUE if "str" is a number string, B_FALSE otherwise. @@ -42,6 +43,14 @@ zfs_isnumber(const char *str) if (!(isdigit(*str) || (*str == '.'))) return (B_FALSE); + /* + * Numbers should not end with a period ("." ".." or "5." are + * not valid) + */ + if (str[strlen(str) - 1] == '.') { + return (B_FALSE); + } + return (B_TRUE); } diff --git a/man/man4/zfs.4 b/man/man4/zfs.4 index 2aed6895754a..20b24d898d84 100644 --- a/man/man4/zfs.4 +++ b/man/man4/zfs.4 @@ -1574,7 +1574,7 @@ Allow no-operation writes. The occurrence of nopwrites will further depend on other pool properties .Pq i.a. the checksumming and compression algorithms . . -.It Sy zfs_dmu_offset_next_sync Ns = Ns Sy 0 Ns | ns 1 Pq int +.It Sy zfs_dmu_offset_next_sync Ns = Ns Sy 0 Ns | Ns 1 Pq int Enable forcing TXG sync to find holes. When enabled forces ZFS to act like prior versions when .Sy SEEK_HOLE No or Sy SEEK_DATA diff --git a/module/Makefile.in b/module/Makefile.in index 089b3ff88490..05c673231cc5 100644 --- a/module/Makefile.in +++ b/module/Makefile.in @@ -114,7 +114,9 @@ modules_uninstall: modules_uninstall-@ac_system@ cppcheck-Linux: @CPPCHECK@ -j@CPU_COUNT@ --std=c99 --quiet --force --error-exitcode=2 \ - --inline-suppr --suppress=noValidConfiguration \ + --inline-suppr \ + --suppress=unmatchedSuppression \ + --suppress=noValidConfiguration \ --enable=warning,information -D_KERNEL \ --include=@LINUX_OBJ@/include/generated/autoconf.h \ --include=@top_srcdir@/zfs_config.h \ diff --git a/module/icp/core/kcf_prov_tabs.c b/module/icp/core/kcf_prov_tabs.c index 94e6937bcd76..9d303d022517 100644 --- a/module/icp/core/kcf_prov_tabs.c +++ b/module/icp/core/kcf_prov_tabs.c @@ -377,7 +377,7 @@ kcf_provider_zero_refcnt(kcf_provider_desc_t *desc) mutex_exit(&desc->pd_lock); break; } - /* FALLTHRU */ + fallthrough; case CRYPTO_HW_PROVIDER: case CRYPTO_LOGICAL_PROVIDER: diff --git a/module/icp/io/aes.c b/module/icp/io/aes.c index e540af4473f7..c47c7567b900 100644 --- a/module/icp/io/aes.c +++ b/module/icp/io/aes.c @@ -976,7 +976,7 @@ aes_encrypt_atomic(crypto_provider_handle_t provider, case AES_GMAC_MECH_INFO_TYPE: if (plaintext->cd_length != 0) return (CRYPTO_ARGUMENTS_BAD); - /* FALLTHRU */ + fallthrough; case AES_GCM_MECH_INFO_TYPE: length_needed = plaintext->cd_length + aes_ctx.ac_tag_len; break; diff --git a/module/lua/lcode.c b/module/lua/lcode.c index ae9a3d91d810..4d88c792a281 100644 --- a/module/lua/lcode.c +++ b/module/lua/lcode.c @@ -8,6 +8,10 @@ #define lcode_c #define LUA_CORE +#if defined(HAVE_IMPLICIT_FALLTHROUGH) +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" +#endif + #include #include "lcode.h" diff --git a/module/lua/lgc.c b/module/lua/lgc.c index 55feb24119d3..227ad723a0b8 100644 --- a/module/lua/lgc.c +++ b/module/lua/lgc.c @@ -676,7 +676,7 @@ static void freeobj (lua_State *L, GCObject *o) { case LUA_TUSERDATA: luaM_freemem(L, o, sizeudata(gco2u(o))); break; case LUA_TSHRSTR: G(L)->strt.nuse--; - /* FALLTHROUGH */ + fallthrough; case LUA_TLNGSTR: { luaM_freemem(L, o, sizestring(gco2ts(o))); break; diff --git a/module/lua/llex.c b/module/lua/llex.c index 50c301f599f1..f2c9bf826c82 100644 --- a/module/lua/llex.c +++ b/module/lua/llex.c @@ -477,7 +477,7 @@ static int llex (LexState *ls, SemInfo *seminfo) { else if (!lisdigit(ls->current)) return '.'; /* else go through */ } - /* FALLTHROUGH */ + fallthrough; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { read_numeral(ls, seminfo); diff --git a/module/lua/lstrlib.c b/module/lua/lstrlib.c index 12027757bf53..46e3d8fb35bb 100644 --- a/module/lua/lstrlib.c +++ b/module/lua/lstrlib.c @@ -501,7 +501,7 @@ static const char *match (MatchState *ms, const char *s, const char *p) { } case '+': /* 1 or more repetitions */ s++; /* 1 match already done */ - /* FALLTHROUGH */ + fallthrough; case '*': /* 0 or more repetitions */ s = max_expand(ms, s, p, ep); break; diff --git a/module/lua/ltable.c b/module/lua/ltable.c index f60418721bef..f6872babc6e7 100644 --- a/module/lua/ltable.c +++ b/module/lua/ltable.c @@ -492,7 +492,7 @@ const TValue *luaH_get (Table *t, const TValue *key) { return luaH_getint(t, k); /* use specialized version */ /* else go through */ } - /* FALLTHROUGH */ + fallthrough; default: { Node *n = mainposition(t, key); do { /* check whether `key' is somewhere in the chain */ diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c index 5f427c8cf2e7..9834dedd859d 100644 --- a/module/nvpair/nvpair.c +++ b/module/nvpair/nvpair.c @@ -533,12 +533,14 @@ nvt_add_nvpair(nvlist_t *nvl, nvpair_t *nvp) uint64_t index = hash & (priv->nvp_nbuckets - 1); ASSERT3U(index, <, priv->nvp_nbuckets); + // cppcheck-suppress nullPointerRedundantCheck i_nvp_t *bucket = tab[index]; /* insert link at the beginning of the bucket */ i_nvp_t *new_entry = NVPAIR2I_NVP(nvp); ASSERT3P(new_entry->nvi_hashtable_next, ==, NULL); new_entry->nvi_hashtable_next = bucket; + // cppcheck-suppress nullPointerRedundantCheck tab[index] = new_entry; priv->nvp_nentries++; @@ -3270,6 +3272,8 @@ NVS_BUILD_XDRPROC_T(u_longlong_t); static int nvs_xdr_nvp_op(nvstream_t *nvs, nvpair_t *nvp) { + ASSERT(nvs != NULL && nvp != NULL); + data_type_t type; char *buf; char *buf_end = (char *)nvp + nvp->nvp_size; @@ -3278,7 +3282,7 @@ nvs_xdr_nvp_op(nvstream_t *nvs, nvpair_t *nvp) bool_t ret = FALSE; XDR *xdr = nvs->nvs_private; - ASSERT(xdr != NULL && nvp != NULL); + ASSERT(xdr != NULL); /* name string */ if ((buf = NVP_NAME(nvp)) >= buf_end) diff --git a/module/os/freebsd/zfs/vdev_geom.c b/module/os/freebsd/zfs/vdev_geom.c index 4ffa21495e74..2ef4811a8a4e 100644 --- a/module/os/freebsd/zfs/vdev_geom.c +++ b/module/os/freebsd/zfs/vdev_geom.c @@ -199,7 +199,6 @@ vdev_geom_orphan(struct g_consumer *cp) * async removal support to invoke a close on this * vdev once it is safe to do so. */ - // cppcheck-suppress All SLIST_FOREACH(elem, priv, elems) { // cppcheck-suppress uninitvar vdev_t *vd = elem->vd; diff --git a/module/os/freebsd/zfs/zfs_acl.c b/module/os/freebsd/zfs/zfs_acl.c index 9b410863019e..ae758bcefe21 100644 --- a/module/os/freebsd/zfs/zfs_acl.c +++ b/module/os/freebsd/zfs/zfs_acl.c @@ -269,7 +269,7 @@ zfs_ace_fuid_size(void *acep) entry_type == OWNING_GROUP || entry_type == ACE_EVERYONE) return (sizeof (zfs_ace_hdr_t)); - /*FALLTHROUGH*/ + fallthrough; default: return (sizeof (zfs_ace_t)); } @@ -2153,7 +2153,7 @@ zfs_zaccess_aces_check(znode_t *zp, uint32_t *working_mode, break; case OWNING_GROUP: who = gowner; - /*FALLTHROUGH*/ + fallthrough; case ACE_IDENTIFIER_GROUP: checkit = zfs_groupmember(zfsvfs, who, cr); break; diff --git a/module/os/freebsd/zfs/zfs_ctldir.c b/module/os/freebsd/zfs/zfs_ctldir.c index a9fe1b647238..cde40e87698b 100644 --- a/module/os/freebsd/zfs/zfs_ctldir.c +++ b/module/os/freebsd/zfs/zfs_ctldir.c @@ -815,6 +815,9 @@ static struct vop_vector zfsctl_ops_root = { .vop_vptocnp = zfsctl_root_vptocnp, .vop_pathconf = zfsctl_common_pathconf, .vop_getacl = zfsctl_common_getacl, +#if __FreeBSD_version >= 1400043 + .vop_add_writecount = vop_stdadd_writecount_nomsync, +#endif }; VFS_VOP_VECTOR_REGISTER(zfsctl_ops_root); @@ -1134,6 +1137,9 @@ static struct vop_vector zfsctl_ops_snapdir = { .vop_print = zfsctl_common_print, .vop_pathconf = zfsctl_common_pathconf, .vop_getacl = zfsctl_common_getacl, +#if __FreeBSD_version >= 1400043 + .vop_add_writecount = vop_stdadd_writecount_nomsync, +#endif }; VFS_VOP_VECTOR_REGISTER(zfsctl_ops_snapdir); @@ -1238,6 +1244,9 @@ static struct vop_vector zfsctl_ops_snapshot = { .vop_islocked = vop_stdislocked, .vop_advlockpurge = vop_stdadvlockpurge, /* called by vgone */ .vop_print = zfsctl_common_print, +#if __FreeBSD_version >= 1400043 + .vop_add_writecount = vop_stdadd_writecount_nomsync, +#endif }; VFS_VOP_VECTOR_REGISTER(zfsctl_ops_snapshot); diff --git a/module/os/freebsd/zfs/zfs_file_os.c b/module/os/freebsd/zfs/zfs_file_os.c index a3d67aaa11ba..fd86a75416e6 100644 --- a/module/os/freebsd/zfs/zfs_file_os.c +++ b/module/os/freebsd/zfs/zfs_file_os.c @@ -207,7 +207,11 @@ zfs_file_getattr(zfs_file_t *fp, zfs_file_attr_t *zfattr) td = curthread; +#if __FreeBSD_version < 1400037 rc = fo_stat(fp, &sb, td->td_ucred, td); +#else + rc = fo_stat(fp, &sb, td->td_ucred); +#endif if (rc) return (SET_ERROR(rc)); zfattr->zfa_size = sb.st_size; diff --git a/module/os/freebsd/zfs/zfs_vnops_os.c b/module/os/freebsd/zfs/zfs_vnops_os.c index 4672b9c2b8b3..8e48f78b7311 100644 --- a/module/os/freebsd/zfs/zfs_vnops_os.c +++ b/module/os/freebsd/zfs/zfs_vnops_os.c @@ -775,8 +775,8 @@ zfs_lookup_lock(vnode_t *dvp, vnode_t *vp, const char *name, int lkflags) /* ARGSUSED */ static int zfs_lookup(vnode_t *dvp, const char *nm, vnode_t **vpp, - struct componentname *cnp, int nameiop, cred_t *cr, kthread_t *td, - int flags, boolean_t cached) + struct componentname *cnp, int nameiop, cred_t *cr, int flags, + boolean_t cached) { znode_t *zdp = VTOZ(dvp); znode_t *zp; @@ -974,7 +974,7 @@ zfs_lookup(vnode_t *dvp, const char *nm, vnode_t **vpp, cnp->cn_flags |= SAVENAME; break; } - /* FALLTHROUGH */ + fallthrough; case DELETE: if (error == 0) cnp->cn_flags |= SAVENAME; @@ -1338,7 +1338,9 @@ zfs_lookup_internal(znode_t *dzp, const char *name, vnode_t **vpp, cnp->cn_flags = ISLASTCN | SAVENAME; cnp->cn_lkflags = LK_EXCLUSIVE | LK_RETRY; cnp->cn_cred = kcred; +#if __FreeBSD_version < 1400037 cnp->cn_thread = curthread; +#endif if (zfsvfs->z_use_namecache && !zfsvfs->z_replay) { struct vop_lookup_args a; @@ -1349,8 +1351,8 @@ zfs_lookup_internal(znode_t *dzp, const char *name, vnode_t **vpp, a.a_cnp = cnp; error = vfs_cache_lookup(&a); } else { - error = zfs_lookup(ZTOV(dzp), name, vpp, cnp, nameiop, kcred, - curthread, 0, B_FALSE); + error = zfs_lookup(ZTOV(dzp), name, vpp, cnp, nameiop, kcred, 0, + B_FALSE); } #ifdef ZFS_DEBUG if (error) { @@ -2220,7 +2222,7 @@ zfs_setattr(znode_t *zp, vattr_t *vap, int flags, cred_t *cr) { vnode_t *vp = ZTOV(zp); zfsvfs_t *zfsvfs = zp->z_zfsvfs; - objset_t *os = zfsvfs->z_os; + objset_t *os; zilog_t *zilog; dmu_tx_t *tx; vattr_t oldva; @@ -2255,6 +2257,7 @@ zfs_setattr(znode_t *zp, vattr_t *vap, int flags, cred_t *cr) ZFS_ENTER(zfsvfs); ZFS_VERIFY_ZP(zp); + os = zfsvfs->z_os; zilog = zfsvfs->z_log; /* @@ -2931,6 +2934,66 @@ zfs_setattr(znode_t *zp, vattr_t *vap, int flags, cred_t *cr) return (err); } +/* + * Look up the directory entries corresponding to the source and target + * directory/name pairs. + */ +static int +zfs_rename_relock_lookup(znode_t *sdzp, const struct componentname *scnp, + znode_t **szpp, znode_t *tdzp, const struct componentname *tcnp, + znode_t **tzpp) +{ + zfsvfs_t *zfsvfs; + znode_t *szp, *tzp; + int error; + + /* + * Before using sdzp and tdzp we must ensure that they are live. + * As a porting legacy from illumos we have two things to worry + * about. One is typical for FreeBSD and it is that the vnode is + * not reclaimed (doomed). The other is that the znode is live. + * The current code can invalidate the znode without acquiring the + * corresponding vnode lock if the object represented by the znode + * and vnode is no longer valid after a rollback or receive operation. + * z_teardown_lock hidden behind ZFS_ENTER and ZFS_EXIT is the lock + * that protects the znodes from the invalidation. + */ + zfsvfs = sdzp->z_zfsvfs; + ASSERT3P(zfsvfs, ==, tdzp->z_zfsvfs); + ZFS_ENTER(zfsvfs); + ZFS_VERIFY_ZP(sdzp); + ZFS_VERIFY_ZP(tdzp); + + /* + * Re-resolve svp to be certain it still exists and fetch the + * correct vnode. + */ + error = zfs_dirent_lookup(sdzp, scnp->cn_nameptr, &szp, ZEXISTS); + if (error != 0) { + /* Source entry invalid or not there. */ + if ((scnp->cn_flags & ISDOTDOT) != 0 || + (scnp->cn_namelen == 1 && scnp->cn_nameptr[0] == '.')) + error = SET_ERROR(EINVAL); + goto out; + } + *szpp = szp; + + /* + * Re-resolve tvp, if it disappeared we just carry on. + */ + error = zfs_dirent_lookup(tdzp, tcnp->cn_nameptr, &tzp, 0); + if (error != 0) { + vrele(ZTOV(szp)); + if ((tcnp->cn_flags & ISDOTDOT) != 0) + error = SET_ERROR(EINVAL); + goto out; + } + *tzpp = tzp; +out: + ZFS_EXIT(zfsvfs); + return (error); +} + /* * We acquire all but fdvp locks using non-blocking acquisitions. If we * fail to acquire any lock in the path we will drop all held locks, @@ -2944,12 +3007,9 @@ zfs_rename_relock(struct vnode *sdvp, struct vnode **svpp, struct vnode *tdvp, struct vnode **tvpp, const struct componentname *scnp, const struct componentname *tcnp) { - zfsvfs_t *zfsvfs; struct vnode *nvp, *svp, *tvp; znode_t *sdzp, *tdzp, *szp, *tzp; - const char *snm = scnp->cn_nameptr; - const char *tnm = tcnp->cn_nameptr; - int error; + int error; VOP_UNLOCK1(tdvp); if (*tvpp != NULL && *tvpp != tdvp) @@ -2959,8 +3019,6 @@ zfs_rename_relock(struct vnode *sdvp, struct vnode **svpp, error = vn_lock(sdvp, LK_EXCLUSIVE); if (error) goto out; - sdzp = VTOZ(sdvp); - error = vn_lock(tdvp, LK_EXCLUSIVE | LK_NOWAIT); if (error != 0) { VOP_UNLOCK1(sdvp); @@ -2973,74 +3031,16 @@ zfs_rename_relock(struct vnode *sdvp, struct vnode **svpp, goto relock; } tdzp = VTOZ(tdvp); + sdzp = VTOZ(sdvp); - /* - * Before using sdzp and tdzp we must ensure that they are live. - * As a porting legacy from illumos we have two things to worry - * about. One is typical for FreeBSD and it is that the vnode is - * not reclaimed (doomed). The other is that the znode is live. - * The current code can invalidate the znode without acquiring the - * corresponding vnode lock if the object represented by the znode - * and vnode is no longer valid after a rollback or receive operation. - * z_teardown_lock hidden behind ZFS_ENTER and ZFS_EXIT is the lock - * that protects the znodes from the invalidation. - */ - zfsvfs = sdzp->z_zfsvfs; - ASSERT3P(zfsvfs, ==, tdzp->z_zfsvfs); - ZFS_ENTER(zfsvfs); - - /* - * We can not use ZFS_VERIFY_ZP() here because it could directly return - * bypassing the cleanup code in the case of an error. - */ - if (tdzp->z_sa_hdl == NULL || sdzp->z_sa_hdl == NULL) { - ZFS_EXIT(zfsvfs); - VOP_UNLOCK1(sdvp); - VOP_UNLOCK1(tdvp); - error = SET_ERROR(EIO); - goto out; - } - - /* - * Re-resolve svp to be certain it still exists and fetch the - * correct vnode. - */ - error = zfs_dirent_lookup(sdzp, snm, &szp, ZEXISTS); + error = zfs_rename_relock_lookup(sdzp, scnp, &szp, tdzp, tcnp, &tzp); if (error != 0) { - /* Source entry invalid or not there. */ - ZFS_EXIT(zfsvfs); VOP_UNLOCK1(sdvp); VOP_UNLOCK1(tdvp); - if ((scnp->cn_flags & ISDOTDOT) != 0 || - (scnp->cn_namelen == 1 && scnp->cn_nameptr[0] == '.')) - error = SET_ERROR(EINVAL); goto out; } svp = ZTOV(szp); - - /* - * Re-resolve tvp, if it disappeared we just carry on. - */ - error = zfs_dirent_lookup(tdzp, tnm, &tzp, 0); - if (error != 0) { - ZFS_EXIT(zfsvfs); - VOP_UNLOCK1(sdvp); - VOP_UNLOCK1(tdvp); - vrele(svp); - if ((tcnp->cn_flags & ISDOTDOT) != 0) - error = SET_ERROR(EINVAL); - goto out; - } - if (tzp != NULL) - tvp = ZTOV(tzp); - else - tvp = NULL; - - /* - * At present the vnode locks must be acquired before z_teardown_lock, - * although it would be more logical to use the opposite order. - */ - ZFS_EXIT(zfsvfs); + tvp = tzp != NULL ? ZTOV(tzp) : NULL; /* * Now try acquire locks on svp and tvp. @@ -3177,17 +3177,22 @@ cache_vop_rename(struct vnode *fdvp, struct vnode *fvp, struct vnode *tdvp, } #endif +static int +zfs_do_rename_impl(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, + vnode_t *tdvp, vnode_t **tvpp, struct componentname *tcnp, + cred_t *cr); + /* * Move an entry from the provided source directory to the target * directory. Change the entry name as indicated. * * IN: sdvp - Source directory containing the "old entry". - * snm - Old entry name. + * scnp - Old entry name. * tdvp - Target directory to contain the "new entry". - * tnm - New entry name. + * tcnp - New entry name. * cr - credentials of caller. - * ct - caller context - * flags - case flags + * INOUT: svpp - Source file + * tvpp - Target file, may point to NULL initially * * RETURN: 0 on success, error code on failure. * @@ -3196,18 +3201,15 @@ cache_vop_rename(struct vnode *fdvp, struct vnode *fvp, struct vnode *tdvp, */ /*ARGSUSED*/ static int -zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, +zfs_do_rename(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, vnode_t *tdvp, vnode_t **tvpp, struct componentname *tcnp, - cred_t *cr, int log) + cred_t *cr) { - zfsvfs_t *zfsvfs; - znode_t *sdzp, *tdzp, *szp, *tzp; - zilog_t *zilog = NULL; - dmu_tx_t *tx; - const char *snm = scnp->cn_nameptr; - const char *tnm = tcnp->cn_nameptr; - int error = 0; - bool want_seqc_end __maybe_unused = false; + int error; + + ASSERT_VOP_ELOCKED(tdvp, __func__); + if (*tvpp != NULL) + ASSERT_VOP_ELOCKED(*tvpp, __func__); /* Reject renames across filesystems. */ if ((*svpp)->v_mount != tdvp->v_mount || @@ -3230,51 +3232,64 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, return (error); } + error = zfs_do_rename_impl(sdvp, svpp, scnp, tdvp, tvpp, tcnp, cr); + VOP_UNLOCK1(sdvp); + VOP_UNLOCK1(*svpp); +out: + if (*tvpp != NULL) + VOP_UNLOCK1(*tvpp); + if (tdvp != *tvpp) + VOP_UNLOCK1(tdvp); + + return (error); +} + +static int +zfs_do_rename_impl(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, + vnode_t *tdvp, vnode_t **tvpp, struct componentname *tcnp, + cred_t *cr) +{ + dmu_tx_t *tx; + zfsvfs_t *zfsvfs; + zilog_t *zilog; + znode_t *tdzp, *sdzp, *tzp, *szp; + const char *snm = scnp->cn_nameptr; + const char *tnm = tcnp->cn_nameptr; + int error; + tdzp = VTOZ(tdvp); sdzp = VTOZ(sdvp); zfsvfs = tdzp->z_zfsvfs; - zilog = zfsvfs->z_log; - /* - * After we re-enter ZFS_ENTER() we will have to revalidate all - * znodes involved. - */ ZFS_ENTER(zfsvfs); + ZFS_VERIFY_ZP(tdzp); + ZFS_VERIFY_ZP(sdzp); + zilog = zfsvfs->z_log; if (zfsvfs->z_utf8 && u8_validate(tnm, strlen(tnm), NULL, U8_VALIDATE_ENTIRE, &error) < 0) { error = SET_ERROR(EILSEQ); - goto unlockout; + goto out; } /* If source and target are the same file, there is nothing to do. */ if ((*svpp) == (*tvpp)) { error = 0; - goto unlockout; + goto out; } if (((*svpp)->v_type == VDIR && (*svpp)->v_mountedhere != NULL) || ((*tvpp) != NULL && (*tvpp)->v_type == VDIR && (*tvpp)->v_mountedhere != NULL)) { error = SET_ERROR(EXDEV); - goto unlockout; - } - - /* - * We can not use ZFS_VERIFY_ZP() here because it could directly return - * bypassing the cleanup code in the case of an error. - */ - if (tdzp->z_sa_hdl == NULL || sdzp->z_sa_hdl == NULL) { - error = SET_ERROR(EIO); - goto unlockout; + goto out; } szp = VTOZ(*svpp); + ZFS_VERIFY_ZP(szp); tzp = *tvpp == NULL ? NULL : VTOZ(*tvpp); - if (szp->z_sa_hdl == NULL || (tzp != NULL && tzp->z_sa_hdl == NULL)) { - error = SET_ERROR(EIO); - goto unlockout; - } + if (tzp != NULL) + ZFS_VERIFY_ZP(tzp); /* * This is to prevent the creation of links into attribute space @@ -3283,7 +3298,7 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, */ if ((tdzp->z_pflags & ZFS_XATTR) != (sdzp->z_pflags & ZFS_XATTR)) { error = SET_ERROR(EINVAL); - goto unlockout; + goto out; } /* @@ -3296,7 +3311,7 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, if (tdzp->z_pflags & ZFS_PROJINHERIT && tdzp->z_projid != szp->z_projid) { error = SET_ERROR(EXDEV); - goto unlockout; + goto out; } /* @@ -3306,7 +3321,7 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, * done in a single check. */ if ((error = zfs_zaccess_rename(sdzp, szp, tdzp, tzp, cr))) - goto unlockout; + goto out; if ((*svpp)->v_type == VDIR) { /* @@ -3316,7 +3331,7 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, sdzp == szp || (scnp->cn_flags | tcnp->cn_flags) & ISDOTDOT) { error = EINVAL; - goto unlockout; + goto out; } /* @@ -3324,7 +3339,7 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, * Can't do a move like this: /usr/a/b to /usr/a/b/c/d */ if ((error = zfs_rename_check(szp, sdzp, tdzp))) - goto unlockout; + goto out; } /* @@ -3337,7 +3352,7 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, if ((*svpp)->v_type == VDIR) { if ((*tvpp)->v_type != VDIR) { error = SET_ERROR(ENOTDIR); - goto unlockout; + goto out; } else { cache_purge(tdvp); if (sdvp != tdvp) @@ -3346,7 +3361,7 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, } else { if ((*tvpp)->v_type == VDIR) { error = SET_ERROR(EISDIR); - goto unlockout; + goto out; } } } @@ -3357,9 +3372,7 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, vn_seqc_write_begin(*tvpp); if (tdvp != *tvpp) vn_seqc_write_begin(tdvp); -#if __FreeBSD_version >= 1300102 - want_seqc_end = true; -#endif + vnevent_rename_src(*svpp, sdvp, scnp->cn_nameptr, ct); if (tzp) vnevent_rename_dest(*tvpp, tdvp, tnm, ct); @@ -3391,10 +3404,9 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, error = dmu_tx_assign(tx, TXG_WAIT); if (error) { dmu_tx_abort(tx); - goto unlockout; + goto out_seq; } - if (tzp) /* Attempt to remove the existing target */ error = zfs_link_destroy(tdzp, tnm, tzp, tx, 0, NULL); @@ -3441,29 +3453,19 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp, dmu_tx_commit(tx); -unlockout: /* all 4 vnodes are locked, ZFS_ENTER called */ - ZFS_EXIT(zfsvfs); - if (want_seqc_end) { - vn_seqc_write_end(*svpp); - vn_seqc_write_end(sdvp); - if (*tvpp != NULL) - vn_seqc_write_end(*tvpp); - if (tdvp != *tvpp) - vn_seqc_write_end(tdvp); - want_seqc_end = false; - } - VOP_UNLOCK1(*svpp); - VOP_UNLOCK1(sdvp); +out_seq: + vn_seqc_write_end(*svpp); + vn_seqc_write_end(sdvp); + if (*tvpp != NULL) + vn_seqc_write_end(*tvpp); + if (tdvp != *tvpp) + vn_seqc_write_end(tdvp); -out: /* original two vnodes are locked */ - MPASS(!want_seqc_end); +out: if (error == 0 && zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS) zil_commit(zilog, 0); + ZFS_EXIT(zfsvfs); - if (*tvpp != NULL) - VOP_UNLOCK1(*tvpp); - if (tdvp != *tvpp) - VOP_UNLOCK1(tdvp); return (error); } @@ -3495,7 +3497,7 @@ zfs_rename(znode_t *sdzp, const char *sname, znode_t *tdzp, const char *tname, goto fail; } - error = zfs_rename_(sdvp, &svp, &scn, tdvp, &tvp, &tcn, cr, 0); + error = zfs_do_rename(sdvp, &svp, &scn, tdvp, &tvp, &tcn, cr); fail: if (svp != NULL) vrele(svp); @@ -4058,7 +4060,6 @@ zfs_getpages(struct vnode *vp, vm_page_t *ma, int count, int *rbehind, { znode_t *zp = VTOZ(vp); zfsvfs_t *zfsvfs = zp->z_zfsvfs; - objset_t *os = zp->z_zfsvfs->z_os; zfs_locked_range_t *lr; vm_object_t object; off_t start, end, obj_size; @@ -4128,8 +4129,8 @@ zfs_getpages(struct vnode *vp, vm_page_t *ma, int count, int *rbehind, * ZFS will panic if we request DMU to read beyond the end of the last * allocated block. */ - error = dmu_read_pages(os, zp->z_id, ma, count, &pgsin_b, &pgsin_a, - MIN(end, obj_size) - (end - PAGE_SIZE)); + error = dmu_read_pages(zfsvfs->z_os, zp->z_id, ma, count, &pgsin_b, + &pgsin_a, MIN(end, obj_size) - (end - PAGE_SIZE)); if (lr != NULL) zfs_rangelock_exit(lr); @@ -4593,7 +4594,7 @@ zfs_freebsd_lookup(struct vop_lookup_args *ap, boolean_t cached) strlcpy(nm, cnp->cn_nameptr, MIN(cnp->cn_namelen + 1, sizeof (nm))); return (zfs_lookup(ap->a_dvp, nm, ap->a_vpp, cnp, cnp->cn_nameiop, - cnp->cn_cred, cnp->cn_thread, 0, cached)); + cnp->cn_cred, 0, cached)); } static int @@ -4976,8 +4977,8 @@ zfs_freebsd_rename(struct vop_rename_args *ap) ASSERT(ap->a_fcnp->cn_flags & (SAVENAME|SAVESTART)); ASSERT(ap->a_tcnp->cn_flags & (SAVENAME|SAVESTART)); - error = zfs_rename_(fdvp, &fvp, ap->a_fcnp, tdvp, &tvp, - ap->a_tcnp, ap->a_fcnp->cn_cred, 1); + error = zfs_do_rename(fdvp, &fvp, ap->a_fcnp, tdvp, &tvp, + ap->a_tcnp, ap->a_fcnp->cn_cred); vrele(fdvp); vrele(fvp); @@ -5345,14 +5346,18 @@ zfs_getextattr_dir(struct vop_getextattr_args *ap, const char *attrname) vnode_t *xvp = NULL, *vp; int error, flags; - error = zfs_lookup(ap->a_vp, NULL, &xvp, NULL, 0, ap->a_cred, td, + error = zfs_lookup(ap->a_vp, NULL, &xvp, NULL, 0, ap->a_cred, LOOKUP_XATTR, B_FALSE); if (error != 0) return (error); flags = FREAD; +#if __FreeBSD_version < 1400043 NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, attrname, xvp, td); +#else + NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, attrname, xvp); +#endif error = vn_open_cred(&nd, &flags, 0, VN_OPEN_INVFS, ap->a_cred, NULL); vp = nd.ni_vp; NDFREE(&nd, NDF_ONLY_PNBUF); @@ -5454,18 +5459,22 @@ struct vop_deleteextattr { static int zfs_deleteextattr_dir(struct vop_deleteextattr_args *ap, const char *attrname) { - struct thread *td = ap->a_td; struct nameidata nd; vnode_t *xvp = NULL, *vp; int error; - error = zfs_lookup(ap->a_vp, NULL, &xvp, NULL, 0, ap->a_cred, td, + error = zfs_lookup(ap->a_vp, NULL, &xvp, NULL, 0, ap->a_cred, LOOKUP_XATTR, B_FALSE); if (error != 0) return (error); +#if __FreeBSD_version < 1400043 + NDINIT_ATVP(&nd, DELETE, NOFOLLOW | LOCKPARENT | LOCKLEAF, + UIO_SYSSPACE, attrname, xvp, ap->a_td); +#else NDINIT_ATVP(&nd, DELETE, NOFOLLOW | LOCKPARENT | LOCKLEAF, - UIO_SYSSPACE, attrname, xvp, td); + UIO_SYSSPACE, attrname, xvp); +#endif error = namei(&nd); vp = nd.ni_vp; if (error != 0) { @@ -5585,13 +5594,17 @@ zfs_setextattr_dir(struct vop_setextattr_args *ap, const char *attrname) vnode_t *xvp = NULL, *vp; int error, flags; - error = zfs_lookup(ap->a_vp, NULL, &xvp, NULL, 0, ap->a_cred, td, + error = zfs_lookup(ap->a_vp, NULL, &xvp, NULL, 0, ap->a_cred, LOOKUP_XATTR | CREATE_XATTR_DIR, B_FALSE); if (error != 0) return (error); flags = FFLAGS(O_WRONLY | O_CREAT); +#if __FreeBSD_version < 1400043 NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, attrname, xvp, td); +#else + NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, attrname, xvp); +#endif error = vn_open_cred(&nd, &flags, 0600, VN_OPEN_INVFS, ap->a_cred, NULL); vp = nd.ni_vp; @@ -5729,7 +5742,7 @@ zfs_listextattr_dir(struct vop_listextattr_args *ap, const char *attrprefix) vnode_t *xvp = NULL, *vp; int error, eof; - error = zfs_lookup(ap->a_vp, NULL, &xvp, NULL, 0, ap->a_cred, td, + error = zfs_lookup(ap->a_vp, NULL, &xvp, NULL, 0, ap->a_cred, LOOKUP_XATTR, B_FALSE); if (error != 0) { /* @@ -5741,8 +5754,13 @@ zfs_listextattr_dir(struct vop_listextattr_args *ap, const char *attrprefix) return (error); } +#if __FreeBSD_version < 1400043 NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKSHARED, UIO_SYSSPACE, ".", xvp, td); +#else + NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKSHARED, + UIO_SYSSPACE, ".", xvp); +#endif error = namei(&nd); vp = nd.ni_vp; NDFREE(&nd, NDF_ONLY_PNBUF); @@ -6115,6 +6133,9 @@ struct vop_vector zfs_vnodeops = { .vop_unlock = vop_unlock, .vop_islocked = vop_islocked, #endif +#if __FreeBSD_version >= 1400043 + .vop_add_writecount = vop_stdadd_writecount_nomsync, +#endif }; VFS_VOP_VECTOR_REGISTER(zfs_vnodeops); @@ -6139,6 +6160,9 @@ struct vop_vector zfs_fifoops = { .vop_getacl = zfs_freebsd_getacl, .vop_setacl = zfs_freebsd_setacl, .vop_aclcheck = zfs_freebsd_aclcheck, +#if __FreeBSD_version >= 1400043 + .vop_add_writecount = vop_stdadd_writecount_nomsync, +#endif }; VFS_VOP_VECTOR_REGISTER(zfs_fifoops); @@ -6158,5 +6182,8 @@ struct vop_vector zfs_shareops = { .vop_reclaim = zfs_freebsd_reclaim, .vop_fid = zfs_freebsd_fid, .vop_pathconf = zfs_freebsd_pathconf, +#if __FreeBSD_version >= 1400043 + .vop_add_writecount = vop_stdadd_writecount_nomsync, +#endif }; VFS_VOP_VECTOR_REGISTER(zfs_shareops); diff --git a/module/os/linux/spl/spl-generic.c b/module/os/linux/spl/spl-generic.c index 91eeaccfdc47..5ea4fc635165 100644 --- a/module/os/linux/spl/spl-generic.c +++ b/module/os/linux/spl/spl-generic.c @@ -657,6 +657,7 @@ hostid_read(uint32_t *hostid) return (error); } size = stat.size; + // cppcheck-suppress sizeofwithnumericparameter if (size < sizeof (HW_HOSTID_MASK)) { filp_close(filp, 0); return (EINVAL); diff --git a/module/os/linux/zfs/vdev_disk.c b/module/os/linux/zfs/vdev_disk.c index c56fd3a6ff21..a432a736453c 100644 --- a/module/os/linux/zfs/vdev_disk.c +++ b/module/os/linux/zfs/vdev_disk.c @@ -37,6 +37,9 @@ #include #include #include +#ifdef HAVE_LINUX_BLK_CGROUP_HEADER +#include +#endif typedef struct vdev_disk { struct block_device *vd_bdev; @@ -265,6 +268,11 @@ vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *max_psize, * a ENOENT failure at this point is highly likely to be transient * and it is reasonable to sleep and retry before giving up. In * practice delays have been observed to be on the order of 100ms. + * + * When ERESTARTSYS is returned it indicates the block device is + * a zvol which could not be opened due to the deadlock detection + * logic in zvol_open(). Extend the timeout and retry the open + * subsequent attempts are expected to eventually succeed. */ hrtime_t start = gethrtime(); bdev = ERR_PTR(-ENXIO); @@ -273,6 +281,9 @@ vdev_disk_open(vdev_t *v, uint64_t *psize, uint64_t *max_psize, zfs_vdev_holder); if (unlikely(PTR_ERR(bdev) == -ENOENT)) { schedule_timeout(MSEC_TO_TICK(10)); + } else if (unlikely(PTR_ERR(bdev) == -ERESTARTSYS)) { + timeout = MSEC2NSEC(zfs_vdev_open_timeout_ms * 10); + continue; } else if (IS_ERR(bdev)) { break; } @@ -433,9 +444,9 @@ static inline void vdev_submit_bio_impl(struct bio *bio) { #ifdef HAVE_1ARG_SUBMIT_BIO - submit_bio(bio); + (void) submit_bio(bio); #else - submit_bio(0, bio); + (void) submit_bio(0, bio); #endif } @@ -485,6 +496,7 @@ vdev_blkg_tryget(struct blkcg_gq *blkg) #elif defined(HAVE_BLKG_TRYGET) #define vdev_blkg_tryget(bg) blkg_tryget(bg) #endif +#ifdef HAVE_BIO_SET_DEV_MACRO /* * The Linux 5.0 kernel updated the bio_set_dev() macro so it calls the * GPL-only bio_associate_blkg() symbol thus inadvertently converting @@ -506,7 +518,30 @@ vdev_bio_associate_blkg(struct bio *bio) if (q->root_blkg && vdev_blkg_tryget(q->root_blkg)) bio->bi_blkg = q->root_blkg; } + #define bio_associate_blkg vdev_bio_associate_blkg +#else +static inline void +vdev_bio_set_dev(struct bio *bio, struct block_device *bdev) +{ +#if defined(HAVE_BIO_BDEV_DISK) + struct request_queue *q = bdev->bd_disk->queue; +#else + struct request_queue *q = bio->bi_disk->queue; +#endif + bio_clear_flag(bio, BIO_REMAPPED); + if (bio->bi_bdev != bdev) + bio_clear_flag(bio, BIO_THROTTLED); + bio->bi_bdev = bdev; + + ASSERT3P(q, !=, NULL); + ASSERT3P(bio->bi_blkg, ==, NULL); + + if (q->root_blkg && vdev_blkg_tryget(q->root_blkg)) + bio->bi_blkg = q->root_blkg; +} +#define bio_set_dev vdev_bio_set_dev +#endif #endif #else /* diff --git a/module/os/linux/zfs/zfs_acl.c b/module/os/linux/zfs/zfs_acl.c index f8bf55f75e97..cf37aecf8a22 100644 --- a/module/os/linux/zfs/zfs_acl.c +++ b/module/os/linux/zfs/zfs_acl.c @@ -269,7 +269,7 @@ zfs_ace_fuid_size(void *acep) entry_type == OWNING_GROUP || entry_type == ACE_EVERYONE) return (sizeof (zfs_ace_hdr_t)); - /*FALLTHROUGH*/ + fallthrough; default: return (sizeof (zfs_ace_t)); } @@ -2317,7 +2317,7 @@ zfs_zaccess_aces_check(znode_t *zp, uint32_t *working_mode, break; case OWNING_GROUP: who = gowner; - /*FALLTHROUGH*/ + fallthrough; case ACE_IDENTIFIER_GROUP: checkit = zfs_groupmember(zfsvfs, who, cr); break; diff --git a/module/os/linux/zfs/zfs_vnops_os.c b/module/os/linux/zfs/zfs_vnops_os.c index ef99c4864d3c..a1a0e44bb31f 100644 --- a/module/os/linux/zfs/zfs_vnops_os.c +++ b/module/os/linux/zfs/zfs_vnops_os.c @@ -3556,7 +3556,11 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc) if (wbc->sync_mode != WB_SYNC_NONE) { if (PageWriteback(pp)) +#ifdef HAVE_PAGEMAP_FOLIO_WAIT_BIT + folio_wait_bit(page_folio(pp), PG_writeback); +#else wait_on_page_bit(pp, PG_writeback); +#endif } ZFS_EXIT(zfsvfs); diff --git a/module/os/linux/zfs/zfs_znode.c b/module/os/linux/zfs/zfs_znode.c index c841cc0fc8b5..cd80049df142 100644 --- a/module/os/linux/zfs/zfs_znode.c +++ b/module/os/linux/zfs/zfs_znode.c @@ -430,7 +430,7 @@ zfs_inode_set_ops(zfsvfs_t *zfsvfs, struct inode *ip) case S_IFBLK: (void) sa_lookup(ITOZ(ip)->z_sa_hdl, SA_ZPL_RDEV(zfsvfs), &rdev, sizeof (rdev)); - /*FALLTHROUGH*/ + fallthrough; case S_IFIFO: case S_IFSOCK: init_special_inode(ip, ip->i_mode, rdev); diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c index 63002fe3b932..7e88eae33711 100644 --- a/module/os/linux/zfs/zpl_file.c +++ b/module/os/linux/zfs/zpl_file.c @@ -250,11 +250,17 @@ zpl_uio_init(zfs_uio_t *uio, struct kiocb *kiocb, struct iov_iter *to, { #if defined(HAVE_VFS_IOV_ITER) zfs_uio_iov_iter_init(uio, to, pos, count, skip); +#else +#ifdef HAVE_IOV_ITER_TYPE + zfs_uio_iovec_init(uio, to->iov, to->nr_segs, pos, + iov_iter_type(to) & ITER_KVEC ? UIO_SYSSPACE : UIO_USERSPACE, + count, skip); #else zfs_uio_iovec_init(uio, to->iov, to->nr_segs, pos, to->type & ITER_KVEC ? UIO_SYSSPACE : UIO_USERSPACE, count, skip); #endif +#endif } static ssize_t diff --git a/module/os/linux/zfs/zvol_os.c b/module/os/linux/zfs/zvol_os.c index c17423426319..44caadd587f7 100644 --- a/module/os/linux/zfs/zvol_os.c +++ b/module/os/linux/zfs/zvol_os.c @@ -46,6 +46,7 @@ unsigned int zvol_request_sync = 0; unsigned int zvol_prefetch_bytes = (128 * 1024); unsigned long zvol_max_discard_blocks = 16384; unsigned int zvol_threads = 32; +unsigned int zvol_open_timeout_ms = 1000; struct zvol_state_os { struct gendisk *zvo_disk; /* generic disk */ @@ -336,8 +337,13 @@ zvol_read_task(void *arg) } #ifdef HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS +#ifdef HAVE_BDEV_SUBMIT_BIO_RETURNS_VOID +static void +zvol_submit_bio(struct bio *bio) +#else static blk_qc_t zvol_submit_bio(struct bio *bio) +#endif #else static MAKE_REQUEST_FN_RET zvol_request(struct request_queue *q, struct bio *bio) @@ -478,8 +484,9 @@ zvol_request(struct request_queue *q, struct bio *bio) out: spl_fstrans_unmark(cookie); -#if defined(HAVE_MAKE_REQUEST_FN_RET_QC) || \ - defined(HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS) +#if (defined(HAVE_MAKE_REQUEST_FN_RET_QC) || \ + defined(HAVE_SUBMIT_BIO_IN_BLOCK_DEVICE_OPERATIONS)) && \ + !defined(HAVE_BDEV_SUBMIT_BIO_RETURNS_VOID) return (BLK_QC_T_NONE); #endif } @@ -490,7 +497,13 @@ zvol_open(struct block_device *bdev, fmode_t flag) zvol_state_t *zv; int error = 0; boolean_t drop_suspend = B_TRUE; + boolean_t drop_namespace = B_FALSE; +#ifndef HAVE_BLKDEV_GET_ERESTARTSYS + hrtime_t timeout = MSEC2NSEC(zvol_open_timeout_ms); + hrtime_t start = gethrtime(); +retry: +#endif rw_enter(&zvol_state_lock, RW_READER); /* * Obtain a copy of private_data under the zvol_state_lock to make @@ -504,6 +517,49 @@ zvol_open(struct block_device *bdev, fmode_t flag) return (SET_ERROR(-ENXIO)); } + if (zv->zv_open_count == 0 && !mutex_owned(&spa_namespace_lock)) { + /* + * In all other call paths the spa_namespace_lock is taken + * before the bdev->bd_mutex lock. However, on open(2) + * the __blkdev_get() function calls fops->open() with the + * bdev->bd_mutex lock held. This can result in a deadlock + * when zvols from one pool are used as vdevs in another. + * + * To prevent a lock inversion deadlock we preemptively + * take the spa_namespace_lock. Normally the lock will not + * be contended and this is safe because spa_open_common() + * handles the case where the caller already holds the + * spa_namespace_lock. + * + * When the lock cannot be aquired after multiple retries + * this must be the vdev on zvol deadlock case and we have + * no choice but to return an error. For 5.12 and older + * kernels returning -ERESTARTSYS will result in the + * bdev->bd_mutex being dropped, then reacquired, and + * fops->open() being called again. This process can be + * repeated safely until both locks are acquired. For 5.13 + * and newer the -ERESTARTSYS retry logic was removed from + * the kernel so the only option is to return the error for + * the caller to handle it. + */ + if (!mutex_tryenter(&spa_namespace_lock)) { + rw_exit(&zvol_state_lock); + +#ifdef HAVE_BLKDEV_GET_ERESTARTSYS + schedule(); + return (SET_ERROR(-ERESTARTSYS)); +#else + if ((gethrtime() - start) > timeout) + return (SET_ERROR(-ERESTARTSYS)); + + schedule_timeout(MSEC_TO_TICK(10)); + goto retry; +#endif + } else { + drop_namespace = B_TRUE; + } + } + mutex_enter(&zv->zv_state_lock); /* * make sure zvol is not suspended during first open @@ -543,6 +599,8 @@ zvol_open(struct block_device *bdev, fmode_t flag) zv->zv_open_count++; mutex_exit(&zv->zv_state_lock); + if (drop_namespace) + mutex_exit(&spa_namespace_lock); if (drop_suspend) rw_exit(&zv->zv_suspend_lock); @@ -556,12 +614,11 @@ zvol_open(struct block_device *bdev, fmode_t flag) out_mutex: mutex_exit(&zv->zv_state_lock); + if (drop_namespace) + mutex_exit(&spa_namespace_lock); if (drop_suspend) rw_exit(&zv->zv_suspend_lock); - if (error == -EINTR) { - error = -ERESTARTSYS; - schedule(); - } + return (SET_ERROR(error)); } diff --git a/module/unicode/u8_textprep.c b/module/unicode/u8_textprep.c index c1d9a325f511..bce5f19625cb 100644 --- a/module/unicode/u8_textprep.c +++ b/module/unicode/u8_textprep.c @@ -865,7 +865,9 @@ do_decomp(size_t uv, uchar_t *u8s, uchar_t *s, int sz, start_id = u8_decomp_b4_16bit_tbl[uv][b3_tbl][b4]; end_id = u8_decomp_b4_16bit_tbl[uv][b3_tbl][b4 + 1]; } else { + // cppcheck-suppress arrayIndexOutOfBoundsCond start_id = u8_decomp_b4_tbl[uv][b3_tbl][b4]; + // cppcheck-suppress arrayIndexOutOfBoundsCond end_id = u8_decomp_b4_tbl[uv][b3_tbl][b4 + 1]; } @@ -1012,7 +1014,9 @@ find_composition_start(size_t uv, uchar_t *s, size_t sz) start_id = u8_composition_b4_16bit_tbl[uv][b3_tbl][b4]; end_id = u8_composition_b4_16bit_tbl[uv][b3_tbl][b4 + 1]; } else { + // cppcheck-suppress arrayIndexOutOfBoundsCond start_id = u8_composition_b4_tbl[uv][b3_tbl][b4]; + // cppcheck-suppress arrayIndexOutOfBoundsCond end_id = u8_composition_b4_tbl[uv][b3_tbl][b4 + 1]; } diff --git a/module/zfs/abd.c b/module/zfs/abd.c index cc2d3575db63..03a7b1e033b3 100644 --- a/module/zfs/abd.c +++ b/module/zfs/abd.c @@ -1066,10 +1066,10 @@ abd_raidz_gen_iterate(abd_t **cabds, abd_t *dabd, switch (parity) { case 3: len = MIN(caiters[2].iter_mapsize, len); - /* falls through */ + fallthrough; case 2: len = MIN(caiters[1].iter_mapsize, len); - /* falls through */ + fallthrough; case 1: len = MIN(caiters[0].iter_mapsize, len); } @@ -1179,11 +1179,11 @@ abd_raidz_rec_iterate(abd_t **cabds, abd_t **tabds, case 3: len = MIN(xiters[2].iter_mapsize, len); len = MIN(citers[2].iter_mapsize, len); - /* falls through */ + fallthrough; case 2: len = MIN(xiters[1].iter_mapsize, len); len = MIN(citers[1].iter_mapsize, len); - /* falls through */ + fallthrough; case 1: len = MIN(xiters[0].iter_mapsize, len); len = MIN(citers[0].iter_mapsize, len); diff --git a/module/zfs/arc.c b/module/zfs/arc.c index b864394b42a0..875986de99f0 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -2063,7 +2063,6 @@ arc_buf_fill(arc_buf_t *buf, spa_t *spa, const zbookmark_phys_t *zb, } else { ASSERT(hdr_compressed); ASSERT(!compressed); - ASSERT3U(HDR_GET_LSIZE(hdr), !=, HDR_GET_PSIZE(hdr)); /* * If the buf is sharing its data with the hdr, unlink it and diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index 1c47430953b1..8302d506146f 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -2095,42 +2095,41 @@ int dmu_offset_next(objset_t *os, uint64_t object, boolean_t hole, uint64_t *off) { dnode_t *dn; - int i, err; - boolean_t clean = B_TRUE; + int err; +restart: err = dnode_hold(os, object, FTAG, &dn); if (err) return (err); - /* - * Check if dnode is dirty - */ - for (i = 0; i < TXG_SIZE; i++) { - if (multilist_link_active(&dn->dn_dirty_link[i])) { - clean = B_FALSE; - break; - } - } + rw_enter(&dn->dn_struct_rwlock, RW_READER); - /* - * If compatibility option is on, sync any current changes before - * we go trundling through the block pointers. - */ - if (!clean && zfs_dmu_offset_next_sync) { - clean = B_TRUE; - dnode_rele(dn, FTAG); - txg_wait_synced(dmu_objset_pool(os), 0); - err = dnode_hold(os, object, FTAG, &dn); - if (err) - return (err); - } + if (dnode_is_dirty(dn)) { + /* + * If the zfs_dmu_offset_next_sync module option is enabled + * then strict hole reporting has been requested. Dirty + * dnodes must be synced to disk to accurately report all + * holes. When disabled (the default) dirty dnodes are + * reported to not have any holes which is always safe. + * + * When called by zfs_holey_common() the zp->z_rangelock + * is held to prevent zfs_write() and mmap writeback from + * re-dirtying the dnode after txg_wait_synced(). + */ + if (zfs_dmu_offset_next_sync) { + rw_exit(&dn->dn_struct_rwlock); + dnode_rele(dn, FTAG); + txg_wait_synced(dmu_objset_pool(os), 0); + goto restart; + } - if (clean) - err = dnode_next_offset(dn, - (hole ? DNODE_FIND_HOLE : 0), off, 1, 1, 0); - else err = SET_ERROR(EBUSY); + } else { + err = dnode_next_offset(dn, DNODE_FIND_HAVELOCK | + (hole ? DNODE_FIND_HOLE : 0), off, 1, 1, 0); + } + rw_exit(&dn->dn_struct_rwlock); dnode_rele(dn, FTAG); return (err); diff --git a/module/zfs/dmu_send.c b/module/zfs/dmu_send.c index 0658e13c2d25..2f2fd4c3d6c8 100644 --- a/module/zfs/dmu_send.c +++ b/module/zfs/dmu_send.c @@ -165,6 +165,7 @@ struct send_range { kmutex_t lock; kcondvar_t cv; boolean_t io_outstanding; + boolean_t io_compressed; int io_err; } data; struct srh { @@ -450,7 +451,8 @@ dump_redact(dmu_send_cookie_t *dscp, uint64_t object, uint64_t offset, static int dmu_dump_write(dmu_send_cookie_t *dscp, dmu_object_type_t type, uint64_t object, - uint64_t offset, int lsize, int psize, const blkptr_t *bp, void *data) + uint64_t offset, int lsize, int psize, const blkptr_t *bp, + boolean_t io_compressed, void *data) { uint64_t payload_size; boolean_t raw = (dscp->dsc_featureflags & DMU_BACKUP_FEATURE_RAW); @@ -487,7 +489,10 @@ dmu_dump_write(dmu_send_cookie_t *dscp, dmu_object_type_t type, uint64_t object, drrw->drr_logical_size = lsize; /* only set the compression fields if the buf is compressed or raw */ - if (raw || lsize != psize) { + boolean_t compressed = + (bp != NULL ? BP_GET_COMPRESS(bp) != ZIO_COMPRESS_OFF && + io_compressed : lsize != psize); + if (raw || compressed) { ASSERT(raw || dscp->dsc_featureflags & DMU_BACKUP_FEATURE_COMPRESSED); ASSERT(!BP_IS_EMBEDDED(bp)); @@ -1014,7 +1019,8 @@ do_dump(dmu_send_cookie_t *dscp, struct send_range *range) int n = MIN(srdp->datablksz, SPA_OLD_MAXBLOCKSIZE); err = dmu_dump_write(dscp, srdp->obj_type, - range->object, offset, n, n, NULL, data); + range->object, offset, n, n, NULL, B_FALSE, + data); offset += n; /* * When doing dry run, data==NULL is used as a @@ -1028,7 +1034,8 @@ do_dump(dmu_send_cookie_t *dscp, struct send_range *range) } else { err = dmu_dump_write(dscp, srdp->obj_type, range->object, offset, - srdp->datablksz, srdp->datasz, bp, data); + srdp->datablksz, srdp->datasz, bp, + srdp->io_compressed, data); } return (err); } @@ -1081,6 +1088,7 @@ range_alloc(enum type type, uint64_t object, uint64_t start_blkid, cv_init(&range->sru.data.cv, NULL, CV_DEFAULT, NULL); range->sru.data.io_outstanding = 0; range->sru.data.io_err = 0; + range->sru.data.io_compressed = B_FALSE; } return (range); } @@ -1646,10 +1654,13 @@ issue_data_read(struct send_reader_thread_arg *srta, struct send_range *range) enum zio_flag zioflags = ZIO_FLAG_CANFAIL; - if (srta->featureflags & DMU_BACKUP_FEATURE_RAW) + if (srta->featureflags & DMU_BACKUP_FEATURE_RAW) { zioflags |= ZIO_FLAG_RAW; - else if (request_compressed) + srdp->io_compressed = B_TRUE; + } else if (request_compressed) { zioflags |= ZIO_FLAG_RAW_COMPRESS; + srdp->io_compressed = B_TRUE; + } srdp->datasz = (zioflags & ZIO_FLAG_RAW_COMPRESS) ? BP_GET_PSIZE(bp) : BP_GET_LSIZE(bp); diff --git a/module/zfs/dnode.c b/module/zfs/dnode.c index 7f741542ce02..7044c1fc6342 100644 --- a/module/zfs/dnode.c +++ b/module/zfs/dnode.c @@ -1648,6 +1648,26 @@ dnode_try_claim(objset_t *os, uint64_t object, int slots) slots, NULL, NULL)); } +/* + * Checks if the dnode contains any uncommitted dirty records. + */ +boolean_t +dnode_is_dirty(dnode_t *dn) +{ + mutex_enter(&dn->dn_mtx); + + for (int i = 0; i < TXG_SIZE; i++) { + if (multilist_link_active(&dn->dn_dirty_link[i])) { + mutex_exit(&dn->dn_mtx); + return (B_TRUE); + } + } + + mutex_exit(&dn->dn_mtx); + + return (B_FALSE); +} + void dnode_setdirty(dnode_t *dn, dmu_tx_t *tx) { diff --git a/module/zfs/dsl_prop.c b/module/zfs/dsl_prop.c index f6ff9ae47192..dfa04d7681be 100644 --- a/module/zfs/dsl_prop.c +++ b/module/zfs/dsl_prop.c @@ -749,7 +749,7 @@ dsl_prop_set_sync_impl(dsl_dataset_t *ds, const char *propname, ASSERT(err == 0 || err == ENOENT); err = zap_remove(mos, zapobj, inheritstr, tx); ASSERT(err == 0 || err == ENOENT); - /* FALLTHRU */ + fallthrough; case (ZPROP_SRC_NONE | ZPROP_SRC_RECEIVED): /* * remove propname$recvd diff --git a/module/zfs/spa.c b/module/zfs/spa.c index 55870bee47fb..a02fd198bed0 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -9710,7 +9710,7 @@ spa_activity_in_progress(spa_t *spa, zpool_wait_activity_t activity, case ZPOOL_WAIT_RESILVER: if ((*in_progress = vdev_rebuild_active(spa->spa_root_vdev))) break; - /* fall through */ + fallthrough; case ZPOOL_WAIT_SCRUB: { boolean_t scanning, paused, is_scrub; diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index 4e316d8135ee..d659ec5bf333 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -2374,6 +2374,7 @@ vdev_validate(vdev_t *vd) static void vdev_copy_path_impl(vdev_t *svd, vdev_t *dvd) { + char *old, *new; if (svd->vdev_path != NULL && dvd->vdev_path != NULL) { if (strcmp(svd->vdev_path, dvd->vdev_path) != 0) { zfs_dbgmsg("vdev_copy_path: vdev %llu: path changed " @@ -2387,6 +2388,29 @@ vdev_copy_path_impl(vdev_t *svd, vdev_t *dvd) zfs_dbgmsg("vdev_copy_path: vdev %llu: path set to '%s'", (u_longlong_t)dvd->vdev_guid, dvd->vdev_path); } + + /* + * Our enclosure sysfs path may have changed between imports + */ + old = dvd->vdev_enc_sysfs_path; + new = svd->vdev_enc_sysfs_path; + if ((old != NULL && new == NULL) || + (old == NULL && new != NULL) || + ((old != NULL && new != NULL) && strcmp(new, old) != 0)) { + zfs_dbgmsg("vdev_copy_path: vdev %llu: vdev_enc_sysfs_path " + "changed from '%s' to '%s'", (u_longlong_t)dvd->vdev_guid, + old, new); + + if (dvd->vdev_enc_sysfs_path) + spa_strfree(dvd->vdev_enc_sysfs_path); + + if (svd->vdev_enc_sysfs_path) { + dvd->vdev_enc_sysfs_path = spa_strdup( + svd->vdev_enc_sysfs_path); + } else { + dvd->vdev_enc_sysfs_path = NULL; + } + } } /* diff --git a/module/zfs/vdev_label.c b/module/zfs/vdev_label.c index 04202a9f8960..ec6bbc6fc610 100644 --- a/module/zfs/vdev_label.c +++ b/module/zfs/vdev_label.c @@ -1287,7 +1287,7 @@ vdev_label_read_bootenv(vdev_t *rvd, nvlist_t *bootenv) nvlist_free(config); break; } - /* FALLTHROUGH */ + fallthrough; default: /* Check for FreeBSD zfs bootonce command string */ buf = abd_to_buf(abd); diff --git a/module/zfs/vdev_raidz_math_scalar.c b/module/zfs/vdev_raidz_math_scalar.c index cd742e146ca6..9e9c15ff4ba2 100644 --- a/module/zfs/vdev_raidz_math_scalar.c +++ b/module/zfs/vdev_raidz_math_scalar.c @@ -142,7 +142,7 @@ static const struct { a.b[6] = mul_lt[a.b[6]]; \ a.b[5] = mul_lt[a.b[5]]; \ a.b[4] = mul_lt[a.b[4]]; \ - /* falls through */ \ + fallthrough; \ case 4: \ a.b[3] = mul_lt[a.b[3]]; \ a.b[2] = mul_lt[a.b[2]]; \ diff --git a/module/zfs/zfs_replay.c b/module/zfs/zfs_replay.c index cba5e8c9cd0b..f3d209f1fbdb 100644 --- a/module/zfs/zfs_replay.c +++ b/module/zfs/zfs_replay.c @@ -362,7 +362,7 @@ zfs_replay_create_acl(void *arg1, void *arg2, boolean_t byteswap) zfsvfs->z_fuid_replay = zfs_replay_fuids(fuidstart, (void *)&name, lracl->lr_fuidcnt, lracl->lr_domcnt, lr->lr_uid, lr->lr_gid); - /*FALLTHROUGH*/ + fallthrough; case TX_CREATE_ACL_ATTR: if (name == NULL) { lrattr = (lr_attr_t *)(caddr_t)(lracl + 1); @@ -394,7 +394,7 @@ zfs_replay_create_acl(void *arg1, void *arg2, boolean_t byteswap) zfsvfs->z_fuid_replay = zfs_replay_fuids(fuidstart, (void *)&name, lracl->lr_fuidcnt, lracl->lr_domcnt, lr->lr_uid, lr->lr_gid); - /*FALLTHROUGH*/ + fallthrough; case TX_MKDIR_ACL_ATTR: if (name == NULL) { lrattr = (lr_attr_t *)(caddr_t)(lracl + 1); @@ -519,8 +519,7 @@ zfs_replay_create(void *arg1, void *arg2, boolean_t byteswap) zfs_replay_fuid_domain(start, &start, lr->lr_uid, lr->lr_gid); name = (char *)start; - - /*FALLTHROUGH*/ + fallthrough; case TX_CREATE: if (name == NULL) name = (char *)start; @@ -537,8 +536,7 @@ zfs_replay_create(void *arg1, void *arg2, boolean_t byteswap) zfs_replay_fuid_domain(start, &start, lr->lr_uid, lr->lr_gid); name = (char *)start; - - /*FALLTHROUGH*/ + fallthrough; case TX_MKDIR: if (name == NULL) name = (char *)(lr + 1); diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index 8229bc9a93e5..170e392abe93 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -85,6 +85,7 @@ zfs_fsync(znode_t *zp, int syncflag, cred_t *cr) static int zfs_holey_common(znode_t *zp, ulong_t cmd, loff_t *off) { + zfs_locked_range_t *lr; uint64_t noff = (uint64_t)*off; /* new offset */ uint64_t file_sz; int error; @@ -100,12 +101,18 @@ zfs_holey_common(znode_t *zp, ulong_t cmd, loff_t *off) else hole = B_FALSE; + /* Flush any mmap()'d data to disk */ + if (zn_has_cached_data(zp)) + zn_flush_cached_data(zp, B_FALSE); + + lr = zfs_rangelock_enter(&zp->z_rangelock, 0, file_sz, RL_READER); error = dmu_offset_next(ZTOZSB(zp)->z_os, zp->z_id, hole, &noff); + zfs_rangelock_exit(lr); if (error == ESRCH) return (SET_ERROR(ENXIO)); - /* file was dirty, so fall back to using generic logic */ + /* File was dirty, so fall back to using generic logic */ if (error == EBUSY) { if (hole) *off = file_sz; diff --git a/module/zfs/zio_compress.c b/module/zfs/zio_compress.c index 33602bd471f3..1ff1e76d7f22 100644 --- a/module/zfs/zio_compress.c +++ b/module/zfs/zio_compress.c @@ -214,7 +214,7 @@ zio_compress_to_feature(enum zio_compress comp) case ZIO_COMPRESS_ZSTD: return (SPA_FEATURE_ZSTD_COMPRESS); default: - /* fallthru */; + break; } return (SPA_FEATURE_NONE); } diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c index 88450aabb469..721a7b4b878e 100644 --- a/module/zfs/zvol.c +++ b/module/zfs/zvol.c @@ -909,54 +909,26 @@ int zvol_first_open(zvol_state_t *zv, boolean_t readonly) { objset_t *os; - int error, locked = 0; - boolean_t ro; + int error; ASSERT(RW_READ_HELD(&zv->zv_suspend_lock)); ASSERT(MUTEX_HELD(&zv->zv_state_lock)); + ASSERT(mutex_owned(&spa_namespace_lock)); - /* - * In all other cases the spa_namespace_lock is taken before the - * bdev->bd_mutex lock. But in this case the Linux __blkdev_get() - * function calls fops->open() with the bdev->bd_mutex lock held. - * This deadlock can be easily observed with zvols used as vdevs. - * - * To avoid a potential lock inversion deadlock we preemptively - * try to take the spa_namespace_lock(). Normally it will not - * be contended and this is safe because spa_open_common() handles - * the case where the caller already holds the spa_namespace_lock. - * - * When it is contended we risk a lock inversion if we were to - * block waiting for the lock. Luckily, the __blkdev_get() - * function allows us to return -ERESTARTSYS which will result in - * bdev->bd_mutex being dropped, reacquired, and fops->open() being - * called again. This process can be repeated safely until both - * locks are acquired. - */ - if (!mutex_owned(&spa_namespace_lock)) { - locked = mutex_tryenter(&spa_namespace_lock); - if (!locked) - return (SET_ERROR(EINTR)); - } - - ro = (readonly || (strchr(zv->zv_name, '@') != NULL)); + boolean_t ro = (readonly || (strchr(zv->zv_name, '@') != NULL)); error = dmu_objset_own(zv->zv_name, DMU_OST_ZVOL, ro, B_TRUE, zv, &os); if (error) - goto out_mutex; + return (SET_ERROR(error)); zv->zv_objset = os; error = zvol_setup_zv(zv); - if (error) { dmu_objset_disown(os, 1, zv); zv->zv_objset = NULL; } -out_mutex: - if (locked) - mutex_exit(&spa_namespace_lock); - return (SET_ERROR(error)); + return (error); } void @@ -1037,6 +1009,68 @@ zvol_create_snap_minor_cb(const char *dsname, void *arg) return (0); } +/* + * If spa_keystore_load_wkey() is called for an encrypted zvol, + * we need to look for any clones also using the key. This function + * is "best effort" - so we just skip over it if there are failures. + */ +static void +zvol_add_clones(const char *dsname, list_t *minors_list) +{ + /* Also check if it has clones */ + dsl_dir_t *dd = NULL; + dsl_pool_t *dp = NULL; + + if (dsl_pool_hold(dsname, FTAG, &dp) != 0) + return; + + if (!spa_feature_is_enabled(dp->dp_spa, + SPA_FEATURE_ENCRYPTION)) + goto out; + + if (dsl_dir_hold(dp, dsname, FTAG, &dd, NULL) != 0) + goto out; + + if (dsl_dir_phys(dd)->dd_clones == 0) + goto out; + + zap_cursor_t *zc = kmem_alloc(sizeof (zap_cursor_t), KM_SLEEP); + zap_attribute_t *za = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP); + objset_t *mos = dd->dd_pool->dp_meta_objset; + + for (zap_cursor_init(zc, mos, dsl_dir_phys(dd)->dd_clones); + zap_cursor_retrieve(zc, za) == 0; + zap_cursor_advance(zc)) { + dsl_dataset_t *clone; + minors_job_t *job; + + if (dsl_dataset_hold_obj(dd->dd_pool, + za->za_first_integer, FTAG, &clone) == 0) { + + char name[ZFS_MAX_DATASET_NAME_LEN]; + dsl_dataset_name(clone, name); + + char *n = kmem_strdup(name); + job = kmem_alloc(sizeof (minors_job_t), KM_SLEEP); + job->name = n; + job->list = minors_list; + job->error = 0; + list_insert_tail(minors_list, job); + + dsl_dataset_rele(clone, FTAG); + } + } + zap_cursor_fini(zc); + kmem_free(za, sizeof (zap_attribute_t)); + kmem_free(zc, sizeof (zap_cursor_t)); + +out: + if (dd != NULL) + dsl_dir_rele(dd, FTAG); + if (dp != NULL) + dsl_pool_rele(dp, FTAG); +} + /* * Mask errors to continue dmu_objset_find() traversal */ @@ -1075,6 +1109,8 @@ zvol_create_minors_cb(const char *dsname, void *arg) taskq_dispatch(system_taskq, zvol_prefetch_minors_impl, job, TQ_SLEEP); + zvol_add_clones(dsname, minors_list); + if (snapdev == ZFS_SNAPDEV_VISIBLE) { /* * traverse snapshots only, do not traverse children, diff --git a/module/zstd/include/zstd_compat_wrapper.h b/module/zstd/include/zstd_compat_wrapper.h index 71adc78040fb..339713590f96 100644 --- a/module/zstd/include/zstd_compat_wrapper.h +++ b/module/zstd/include/zstd_compat_wrapper.h @@ -406,6 +406,7 @@ zfs_ZSTD_insertAndFindFirstIndex_internal #define ZSTD_insertBlock zfs_ZSTD_insertBlock #define ZSTD_invalidateRepCodes zfs_ZSTD_invalidateRepCodes +#define ZSTD_isError zfs_ZSTD_isError #define ZSTD_isFrame zfs_ZSTD_isFrame #define ZSTD_ldm_adjustParameters zfs_ZSTD_ldm_adjustParameters #define ZSTD_ldm_blockCompress zfs_ZSTD_ldm_blockCompress diff --git a/module/zstd/lib/zstd.c b/module/zstd/lib/zstd.c index acdd4d9dac9d..2766e5b74f55 100644 --- a/module/zstd/lib/zstd.c +++ b/module/zstd/lib/zstd.c @@ -6340,7 +6340,6 @@ extern "C" { /* ---- static assert (debug) --- */ #define ZSTD_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c) -#define ZSTD_isError ERR_isError /* for inlining */ #define FSE_isError ERR_isError #define HUF_isError ERR_isError @@ -7347,7 +7346,6 @@ const char* ZSTD_versionString(void) { return ZSTD_VERSION_STRING; } /*-**************************************** * ZSTD Error Management ******************************************/ -#undef ZSTD_isError /* defined within zstd_internal.h */ /*! ZSTD_isError() : * tells if a return value is an error code * symbol is required for external callers */ diff --git a/rpm/generic/zfs-dkms.spec.in b/rpm/generic/zfs-dkms.spec.in index e0c410c680c2..aab1d9399077 100644 --- a/rpm/generic/zfs-dkms.spec.in +++ b/rpm/generic/zfs-dkms.spec.in @@ -24,9 +24,13 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch Requires: dkms >= 2.2.0.3 +Requires(post): dkms >= 2.2.0.3 +Requires(preun): dkms >= 2.2.0.3 Requires: gcc, make, perl, diffutils +Requires(post): gcc, make, perl, diffutils %if 0%{?rhel}%{?fedora}%{?mageia}%{?suse_version} Requires: kernel-devel >= @ZFS_META_KVER_MIN@, kernel-devel <= @ZFS_META_KVER_MAX@.999 +Requires(post): kernel-devel >= @ZFS_META_KVER_MIN@, kernel-devel <= @ZFS_META_KVER_MAX@.999 Obsoletes: spl-dkms %endif Provides: %{module}-kmod = %{version} diff --git a/rpm/generic/zfs.spec.in b/rpm/generic/zfs.spec.in index 7fa28ac723eb..4a37ae8ce1d5 100644 --- a/rpm/generic/zfs.spec.in +++ b/rpm/generic/zfs.spec.in @@ -311,6 +311,11 @@ Requires: libffi Requires: python%{__python_pkg_version} Requires: %{__python_cffi_pkg} %if 0%{?rhel}%{?fedora}%{?suse_version} +%if 0%{?rhel} >= 8 || 0%{?centos} >= 8 || 0%{?fedora} >= 28 +BuildRequires: python3-packaging +%else +BuildRequires: python-packaging +%endif BuildRequires: python%{__python_pkg_version}-devel BuildRequires: %{__python_cffi_pkg} BuildRequires: %{__python_setuptools_pkg} diff --git a/scripts/mancheck.sh b/scripts/mancheck.sh index 6ae1fc5becff..0793cc48fa97 100755 --- a/scripts/mancheck.sh +++ b/scripts/mancheck.sh @@ -11,7 +11,9 @@ # AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # -# shellcheck disable=SC2086 +# shellcheck disable=SC2086,SC2250 + +trap 'rm -f "$stdout_file" "$stderr_file" "$result_file"' EXIT if [ "$#" -eq 0 ]; then echo "Usage: $0 manpage-directory..." @@ -25,7 +27,6 @@ fi IFS=" " - files="$(find "$@" -type f -name '*[1-9]*')" || exit 1 add_excl="$(awk ' @@ -38,6 +39,15 @@ add_excl="$(awk ' # Redirect to file instead of 2>&1ing because mandoc flushes inconsistently(?) which tears lines # https://github.com/openzfs/zfs/pull/12129/checks?check_run_id=2701608671#step:5:3 -etmp="$(mktemp)" -! { mandoc -Tlint $files 2>"$etmp"; cat "$etmp"; rm -f "$etmp"; } | - grep -vE -e 'mandoc: outdated mandoc.db' -e 'STYLE: referenced manual not found' $add_excl >&2 +stdout_file="$(mktemp)" +stderr_file="$(mktemp)" +mandoc -Tlint $files 1>"$stdout_file" 2>"$stderr_file" +result_file="$(mktemp)" +grep -vhE -e 'mandoc: outdated mandoc.db' -e 'STYLE: referenced manual not found' $add_excl "$stdout_file" "$stderr_file" > "$result_file" + +if [ -s "$result_file" ]; then + cat "$result_file" + exit 1 +else + echo "no errors found" +fi diff --git a/scripts/zfs-tests.sh b/scripts/zfs-tests.sh index ac28788582f9..60499e09e249 100755 --- a/scripts/zfs-tests.sh +++ b/scripts/zfs-tests.sh @@ -21,6 +21,10 @@ # CDDL HEADER END # +# +# Copyright 2020 OmniOS Community Edition (OmniOSce) Association. +# + BASE_DIR=$(dirname "$0") SCRIPT_COMMON=common.sh if [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then @@ -48,6 +52,7 @@ ITERATIONS=1 ZFS_DBGMSG="$STF_SUITE/callbacks/zfs_dbgmsg.ksh" ZFS_DMESG="$STF_SUITE/callbacks/zfs_dmesg.ksh" UNAME=$(uname -s) +RERUN="" # Override some defaults if on FreeBSD if [ "$UNAME" = "FreeBSD" ] ; then @@ -322,6 +327,7 @@ OPTIONS: -f Use files only, disables block device tests -S Enable stack tracer (negative performance impact) -c Only create and populate constrained path + -R Automatically rerun failing tests -n NFSFILE Use the nfsfile to determine the NFS configuration -I NUM Number of iterations -d DIR Use DIR for files and loopback devices @@ -348,7 +354,7 @@ $0 -x EOF } -while getopts 'hvqxkfScn:d:s:r:?t:T:u:I:' OPTION; do +while getopts 'hvqxkfScRn:d:s:r:?t:T:u:I:' OPTION; do case $OPTION in h) usage @@ -376,6 +382,9 @@ while getopts 'hvqxkfScn:d:s:r:?t:T:u:I:' OPTION; do constrain_path exit ;; + R) + RERUN="yes" + ;; n) nfsfile=$OPTARG [ -f "$nfsfile" ] || fail "Cannot read file: $nfsfile" @@ -694,12 +703,35 @@ ${TEST_RUNNER} ${QUIET:+-q} \ -i "${STF_SUITE}" \ -I "${ITERATIONS}" \ 2>&1 | tee "$RESULTS_FILE" - # # Analyze the results. # -${ZTS_REPORT} "$RESULTS_FILE" >"$REPORT_FILE" +${ZTS_REPORT} ${RERUN:+--no-maybes} "$RESULTS_FILE" >"$REPORT_FILE" RESULT=$? + +if [ "$RESULT" -eq "2" ] && [ -n "$RERUN" ]; then + MAYBES="$($ZTS_REPORT --list-maybes)" + TEMP_RESULTS_FILE=$(mktemp -u -t zts-results-tmp.XXXXX -p "$FILEDIR") + TEST_LIST=$(mktemp -u -t test-list.XXXXX -p "$FILEDIR") + grep "^Test:.*\[FAIL\]" "$RESULTS_FILE" >"$TEMP_RESULTS_FILE" + for test_name in $MAYBES; do + grep "$test_name " "$TEMP_RESULTS_FILE" >>"$TEST_LIST" + done + ${TEST_RUNNER} ${QUIET:+-q} \ + -c "${RUNFILES}" \ + -T "${TAGS}" \ + -i "${STF_SUITE}" \ + -I "${ITERATIONS}" \ + -l "${TEST_LIST}" \ + 2>&1 | tee "$RESULTS_FILE" + # + # Analyze the results. + # + ${ZTS_REPORT} --no-maybes "$RESULTS_FILE" >"$REPORT_FILE" + RESULT=$? +fi + + cat "$REPORT_FILE" RESULTS_DIR=$(awk '/^Log directory/ { print $3 }' "$RESULTS_FILE") diff --git a/tests/runfiles/common.run b/tests/runfiles/common.run index a62cd6ad39f5..97ee7b8ae241 100644 --- a/tests/runfiles/common.run +++ b/tests/runfiles/common.run @@ -669,7 +669,7 @@ tests = ['migration_001_pos', 'migration_002_pos', 'migration_003_pos', tags = ['functional', 'migration'] [tests/functional/mmap] -tests = ['mmap_write_001_pos', 'mmap_read_001_pos'] +tests = ['mmap_write_001_pos', 'mmap_read_001_pos', 'mmap_seek_001_pos'] tags = ['functional', 'mmap'] [tests/functional/mount] diff --git a/tests/runfiles/sanity.run b/tests/runfiles/sanity.run index b1d2c73de959..3f4eb302f1e0 100644 --- a/tests/runfiles/sanity.run +++ b/tests/runfiles/sanity.run @@ -432,8 +432,8 @@ tests = ['grow_pool_001_pos', 'grow_replicas_001_pos'] tags = ['functional', 'grow'] [tests/functional/history] -tests = ['history_004_pos', 'history_005_neg', 'history_006_neg', - 'history_007_pos', 'history_008_pos', 'history_009_pos'] +tests = ['history_004_pos', 'history_005_neg', 'history_007_pos', + 'history_009_pos'] tags = ['functional', 'history'] [tests/functional/hkdf] @@ -561,12 +561,11 @@ tags = ['functional', 'slog'] [tests/functional/snapshot] tests = ['clone_001_pos', 'rollback_001_pos', 'rollback_002_pos', - 'rollback_003_pos', 'snapshot_001_pos', 'snapshot_002_pos', - 'snapshot_003_pos', 'snapshot_004_pos', 'snapshot_005_pos', - 'snapshot_006_pos', 'snapshot_007_pos', 'snapshot_008_pos', - 'snapshot_009_pos', 'snapshot_010_pos', 'snapshot_011_pos', - 'snapshot_012_pos', 'snapshot_013_pos', 'snapshot_014_pos', - 'snapshot_017_pos'] + 'snapshot_001_pos', 'snapshot_002_pos', 'snapshot_003_pos', + 'snapshot_004_pos', 'snapshot_005_pos', 'snapshot_006_pos', + 'snapshot_007_pos', 'snapshot_008_pos', 'snapshot_009_pos', + 'snapshot_010_pos', 'snapshot_011_pos', 'snapshot_012_pos', + 'snapshot_013_pos', 'snapshot_014_pos', 'snapshot_017_pos'] tags = ['functional', 'snapshot'] [tests/functional/snapused] diff --git a/tests/test-runner/bin/test-runner.py.in b/tests/test-runner/bin/test-runner.py.in index bbabf247c1dc..d32e05c45392 100755 --- a/tests/test-runner/bin/test-runner.py.in +++ b/tests/test-runner/bin/test-runner.py.in @@ -27,6 +27,7 @@ except ImportError: import os import sys import ctypes +import re from datetime import datetime from optparse import OptionParser @@ -495,6 +496,9 @@ Tags: %s self.timeout, self.user, self.pre, pre_user, self.post, post_user, self.failsafe, failsafe_user, self.tags) + def filter(self, keeplist): + self.tests = [x for x in self.tests if x in keeplist] + def verify(self): """ Check the pre/post/failsafe scripts, user and tests in this TestGroup. @@ -656,6 +660,24 @@ class TestRun(object): testgroup.verify() + def filter(self, keeplist): + for group in list(self.testgroups.keys()): + if group not in keeplist: + del self.testgroups[group] + continue + + g = self.testgroups[group] + + if g.pre and os.path.basename(g.pre) in keeplist[group]: + continue + + g.filter(keeplist[group]) + + for test in list(self.tests.keys()): + directory, base = os.path.split(test) + if directory not in keeplist or base not in keeplist[directory]: + del self.tests[test] + def read(self, options): """ Read in the specified runfiles, and apply the TestRun properties @@ -743,10 +765,18 @@ class TestRun(object): for test in sorted(self.tests.keys()): config.add_section(test) + for prop in Test.props: + if prop not in self.props: + config.set(test, prop, + getattr(self.tests[test], prop)) for testgroup in sorted(self.testgroups.keys()): config.add_section(testgroup) config.set(testgroup, 'tests', self.testgroups[testgroup].tests) + for prop in TestGroup.props: + if prop not in self.props: + config.set(testgroup, prop, + getattr(self.testgroups[testgroup], prop)) try: with open(options.template, 'w') as f: @@ -796,7 +826,7 @@ class TestRun(object): return global LOG_FILE_OBJ - if options.cmd != 'wrconfig': + if not options.template: try: old = os.umask(0) os.makedirs(self.outputdir, mode=0o777) @@ -939,17 +969,37 @@ def find_tests(testrun, options): testrun.addtest(p, options) +def filter_tests(testrun, options): + try: + fh = open(options.logfile, "r") + except Exception as e: + fail('%s' % e) + + failed = {} + while True: + line = fh.readline() + if not line: + break + m = re.match(r'Test: .*(tests/.*)/(\S+).*\[FAIL\]', line) + if not m: + continue + group, test = m.group(1, 2) + try: + failed[group].append(test) + except KeyError: + failed[group] = [test] + fh.close() + + testrun.filter(failed) + + def fail(retstr, ret=1): print('%s: %s' % (sys.argv[0], retstr)) exit(ret) def options_cb(option, opt_str, value, parser): - path_options = ['outputdir', 'template', 'testdir'] - - if option.dest == 'runfiles' and '-w' in parser.rargs or \ - option.dest == 'template' and '-c' in parser.rargs: - fail('-c and -w are mutually exclusive.') + path_options = ['outputdir', 'template', 'testdir', 'logfile'] if opt_str in parser.rargs: fail('%s may only be specified once.' % opt_str) @@ -957,8 +1007,6 @@ def options_cb(option, opt_str, value, parser): if option.dest == 'runfiles': parser.values.cmd = 'rdconfig' value = set(os.path.abspath(p) for p in value.split(',')) - if option.dest == 'template': - parser.values.cmd = 'wrconfig' if option.dest == 'tags': value = [x.strip() for x in value.split(',')] @@ -975,6 +1023,10 @@ def parse_args(): help='Specify tests to run via config files.') parser.add_option('-d', action='store_true', default=False, dest='dryrun', help='Dry run. Print tests, but take no other action.') + parser.add_option('-l', action='callback', callback=options_cb, + default=None, dest='logfile', metavar='logfile', + type='string', + help='Read logfile and re-run tests which failed.') parser.add_option('-g', action='store_true', default=False, dest='do_groups', help='Make directories TestGroups.') parser.add_option('-o', action='callback', callback=options_cb, @@ -1021,9 +1073,6 @@ def parse_args(): help='Number of times to run the test run.') (options, pathnames) = parser.parse_args() - if not options.runfiles and not options.template: - options.cmd = 'runtests' - if options.runfiles and len(pathnames): fail('Extraneous arguments.') @@ -1034,18 +1083,20 @@ def parse_args(): def main(): options = parse_args() + testrun = TestRun(options) - if options.cmd == 'runtests': - find_tests(testrun, options) - elif options.cmd == 'rdconfig': + if options.runfiles: testrun.read(options) - elif options.cmd == 'wrconfig': + else: find_tests(testrun, options) + + if options.logfile: + filter_tests(testrun, options) + + if options.template: testrun.write(options) exit(0) - else: - fail('Unknown command specified') testrun.complete_outputdirs() testrun.run(options) diff --git a/tests/test-runner/bin/zts-report.py.in b/tests/test-runner/bin/zts-report.py.in index cc1ee6db0913..c3a679675280 100755 --- a/tests/test-runner/bin/zts-report.py.in +++ b/tests/test-runner/bin/zts-report.py.in @@ -21,6 +21,7 @@ import os import re import sys +import argparse # # This script parses the stdout of zfstest, which has this format: @@ -160,6 +161,8 @@ known = { 'casenorm/mixed_formd_lookup_ci': ['FAIL', '7633'], 'cli_root/zfs_unshare/zfs_unshare_002_pos': ['SKIP', na_reason], 'cli_root/zfs_unshare/zfs_unshare_006_pos': ['SKIP', na_reason], + 'cli_root/zpool_import/import_rewind_device_replaced': + ['FAIL', rewind_reason], 'cli_user/misc/zfs_share_001_neg': ['SKIP', na_reason], 'cli_user/misc/zfs_unshare_001_neg': ['SKIP', na_reason], 'privilege/setup': ['SKIP', na_reason], @@ -212,8 +215,6 @@ maybe = { 'cli_root/zfs_unshare/setup': ['SKIP', share_reason], 'cli_root/zpool_add/zpool_add_004_pos': ['FAIL', known_reason], 'cli_root/zpool_destroy/zpool_destroy_001_pos': ['SKIP', '6145'], - 'cli_root/zpool_import/import_rewind_device_replaced': - ['FAIL', rewind_reason], 'cli_root/zpool_import/import_rewind_config_changed': ['FAIL', rewind_reason], 'cli_root/zpool_import/zpool_import_missing_003_pos': ['SKIP', '6839'], @@ -369,10 +370,33 @@ def process_results(pathname): return d +class ListMaybesAction(argparse.Action): + def __init__(self, + option_strings, + dest="SUPPRESS", + default="SUPPRESS", + help="list flaky tests and exit"): + super(ListMaybesAction, self).__init__( + option_strings=option_strings, + dest=dest, + default=default, + nargs=0, + help=help) + + def __call__(self, parser, namespace, values, option_string=None): + for test in maybe: + print(test) + sys.exit(0) + + if __name__ == "__main__": - if len(sys.argv) != 2: - usage('usage: %s ' % sys.argv[0]) - results = process_results(sys.argv[1]) + parser = argparse.ArgumentParser(description='Analyze ZTS logs') + parser.add_argument('logfile') + parser.add_argument('--list-maybes', action=ListMaybesAction) + parser.add_argument('--no-maybes', action='store_false', dest='maybes') + args = parser.parse_args() + + results = process_results(args.logfile) if summary['total'] == 0: print("\n\nNo test results were found.") @@ -381,6 +405,7 @@ if __name__ == "__main__": expected = [] unexpected = [] + all_maybes = True for test in list(results.keys()): if results[test] == "PASS": @@ -393,11 +418,16 @@ if __name__ == "__main__": if setup in maybe and maybe[setup][0] == "SKIP": continue - if ((test not in known or results[test] not in known[test][0]) and - (test not in maybe or results[test] not in maybe[test][0])): - unexpected.append(test) - else: + if (test in known and results[test] in known[test][0]): expected.append(test) + elif test in maybe and results[test] in maybe[test][0]: + if results[test] == 'SKIP' or args.maybes: + expected.append(test) + elif not args.maybes: + unexpected.append(test) + else: + unexpected.append(test) + all_maybes = False print("\nTests with results other than PASS that are expected:") for test in sorted(expected): @@ -443,5 +473,7 @@ if __name__ == "__main__": if len(unexpected) == 0: sys.exit(0) + elif not args.maybes and all_maybes: + sys.exit(2) else: sys.exit(1) diff --git a/tests/zfs-tests/cmd/Makefile.am b/tests/zfs-tests/cmd/Makefile.am index 2b965ca70009..d1c29fcd1c62 100644 --- a/tests/zfs-tests/cmd/Makefile.am +++ b/tests/zfs-tests/cmd/Makefile.am @@ -19,6 +19,7 @@ SUBDIRS = \ mktree \ mmap_exec \ mmap_libaio \ + mmap_seek \ mmapwrite \ nvlist_to_lua \ randwritecomp \ diff --git a/tests/zfs-tests/cmd/file_check/file_check.c b/tests/zfs-tests/cmd/file_check/file_check.c index 5df0ea735bfd..3d3db753f3d7 100644 --- a/tests/zfs-tests/cmd/file_check/file_check.c +++ b/tests/zfs-tests/cmd/file_check/file_check.c @@ -40,7 +40,6 @@ main(int argc, char **argv) long i, n; unsigned char fillchar = DATA; int bigbuffersize = BIGBUFFERSIZE; - int64_t read_count = 0; /* * Validate arguments @@ -78,8 +77,6 @@ main(int argc, char **argv) exit(1); } } - - read_count += n; } while (n == bigbuffersize); return (0); diff --git a/tests/zfs-tests/cmd/mmap_seek/.gitignore b/tests/zfs-tests/cmd/mmap_seek/.gitignore new file mode 100644 index 000000000000..6b05a7917500 --- /dev/null +++ b/tests/zfs-tests/cmd/mmap_seek/.gitignore @@ -0,0 +1 @@ +/mmap_seek diff --git a/tests/zfs-tests/cmd/mmap_seek/Makefile.am b/tests/zfs-tests/cmd/mmap_seek/Makefile.am new file mode 100644 index 000000000000..b938931125f5 --- /dev/null +++ b/tests/zfs-tests/cmd/mmap_seek/Makefile.am @@ -0,0 +1,6 @@ +include $(top_srcdir)/config/Rules.am + +pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin + +pkgexec_PROGRAMS = mmap_seek +mmap_seek_SOURCES = mmap_seek.c diff --git a/tests/zfs-tests/cmd/mmap_seek/mmap_seek.c b/tests/zfs-tests/cmd/mmap_seek/mmap_seek.c new file mode 100644 index 000000000000..f476e1dba9a4 --- /dev/null +++ b/tests/zfs-tests/cmd/mmap_seek/mmap_seek.c @@ -0,0 +1,147 @@ +/* + * 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) 2021 by Lawrence Livermore National Security, LLC. + */ + +#include +#include +#include +#include +#include +#include +#include + +static void +seek_data(int fd, off_t offset, off_t expected) +{ + off_t data_offset = lseek(fd, offset, SEEK_DATA); + if (data_offset != expected) { + fprintf(stderr, "lseek(fd, %d, SEEK_DATA) = %d (expected %d)\n", + (int)offset, (int)data_offset, (int)expected); + exit(2); + } +} + +static void +seek_hole(int fd, off_t offset, off_t expected) +{ + off_t hole_offset = lseek(fd, offset, SEEK_HOLE); + if (hole_offset != expected) { + fprintf(stderr, "lseek(fd, %d, SEEK_HOLE) = %d (expected %d)\n", + (int)offset, (int)hole_offset, (int)expected); + exit(2); + } +} + +int +main(int argc, char **argv) +{ + char *execname = argv[0]; + char *file_path = argv[1]; + char *buf = NULL; + int err; + + if (argc != 4) { + (void) printf("usage: %s " + "\n", argv[0]); + exit(1); + } + + int fd = open(file_path, O_RDWR | O_CREAT, 0666); + if (fd == -1) { + (void) fprintf(stderr, "%s: %s: ", execname, file_path); + perror("open"); + exit(2); + } + + off_t file_size = atoi(argv[2]); + off_t block_size = atoi(argv[3]); + + if (block_size * 2 > file_size) { + (void) fprintf(stderr, "file size must be at least " + "double the block size\n"); + exit(2); + } + + err = ftruncate(fd, file_size); + if (err == -1) { + perror("ftruncate"); + exit(2); + } + + if ((buf = mmap(NULL, file_size, PROT_READ | PROT_WRITE, + MAP_SHARED, fd, 0)) == MAP_FAILED) { + perror("mmap"); + exit(2); + } + + /* Verify the file is sparse and reports no data. */ + seek_data(fd, 0, -1); + + /* Verify the file is reported as a hole. */ + seek_hole(fd, 0, 0); + + /* Verify search beyond end of file is an error. */ + seek_data(fd, 2 * file_size, -1); + seek_hole(fd, 2 * file_size, -1); + + /* Dirty the first byte. */ + memset(buf, 'a', 1); + seek_data(fd, 0, 0); + seek_data(fd, block_size, -1); + seek_hole(fd, 0, block_size); + seek_hole(fd, block_size, block_size); + + /* Dirty the first half of the file. */ + memset(buf, 'b', file_size / 2); + seek_data(fd, 0, 0); + seek_data(fd, block_size, block_size); + seek_hole(fd, 0, P2ROUNDUP(file_size / 2, block_size)); + seek_hole(fd, block_size, P2ROUNDUP(file_size / 2, block_size)); + + /* Dirty the whole file. */ + memset(buf, 'c', file_size); + seek_data(fd, 0, 0); + seek_data(fd, file_size * 3 / 4, + P2ROUNDUP(file_size * 3 / 4, block_size)); + seek_hole(fd, 0, file_size); + seek_hole(fd, file_size / 2, file_size); + + /* Punch a hole (required compression be enabled). */ + memset(buf + block_size, 0, block_size); + seek_data(fd, 0, 0); + seek_data(fd, block_size, 2 * block_size); + seek_hole(fd, 0, block_size); + seek_hole(fd, block_size, block_size); + seek_hole(fd, 2 * block_size, file_size); + + err = munmap(buf, file_size); + if (err == -1) { + perror("munmap"); + exit(2); + } + + close(fd); + + return (0); +} diff --git a/tests/zfs-tests/include/commands.cfg b/tests/zfs-tests/include/commands.cfg index 1ec73f25bae7..4497a6248b4b 100644 --- a/tests/zfs-tests/include/commands.cfg +++ b/tests/zfs-tests/include/commands.cfg @@ -209,6 +209,7 @@ export ZFSTEST_FILES='badsend mktree mmap_exec mmap_libaio + mmap_seek mmapwrite nvlist_to_lua randfree_file diff --git a/tests/zfs-tests/include/tunables.cfg b/tests/zfs-tests/include/tunables.cfg index 56d430a39875..fff43e469165 100644 --- a/tests/zfs-tests/include/tunables.cfg +++ b/tests/zfs-tests/include/tunables.cfg @@ -33,6 +33,7 @@ DEADMAN_FAILMODE deadman.failmode zfs_deadman_failmode DEADMAN_SYNCTIME_MS deadman.synctime_ms zfs_deadman_synctime_ms DEADMAN_ZIOTIME_MS deadman.ziotime_ms zfs_deadman_ziotime_ms DISABLE_IVSET_GUID_CHECK disable_ivset_guid_check zfs_disable_ivset_guid_check +DMU_OFFSET_NEXT_SYNC dmu_offset_next_sync zfs_dmu_offset_next_sync INITIALIZE_CHUNK_SIZE initialize_chunk_size zfs_initialize_chunk_size INITIALIZE_VALUE initialize_value zfs_initialize_value KEEP_LOG_SPACEMAPS_AT_EXPORT keep_log_spacemaps_at_export zfs_keep_log_spacemaps_at_export diff --git a/tests/zfs-tests/tests/functional/bootfs/bootfs_002_neg.ksh b/tests/zfs-tests/tests/functional/bootfs/bootfs_002_neg.ksh index 6a72bfcdc40c..a5bc7753e96e 100755 --- a/tests/zfs-tests/tests/functional/bootfs/bootfs_002_neg.ksh +++ b/tests/zfs-tests/tests/functional/bootfs/bootfs_002_neg.ksh @@ -51,14 +51,9 @@ verify_runnable "global" function cleanup { - if datasetexists $TESTPOOL/vol - then - log_must zfs destroy $TESTPOOL/vol - fi - if poolexists $TESTPOOL - then - log_must zpool destroy $TESTPOOL - fi + datasetexists $TESTPOOL/vol && destroy_dataset $TESTPOOL/vol + poolexists $TESTPOOL && log_must zpool destroy $TESTPOOL + if [[ -f $VDEV ]]; then log_must rm -f $VDEV fi diff --git a/tests/zfs-tests/tests/functional/casenorm/casenorm.kshlib b/tests/zfs-tests/tests/functional/casenorm/casenorm.kshlib index cb61798d7be7..f0fe1bbaa886 100644 --- a/tests/zfs-tests/tests/functional/casenorm/casenorm.kshlib +++ b/tests/zfs-tests/tests/functional/casenorm/casenorm.kshlib @@ -34,7 +34,7 @@ function create_testfs function destroy_testfs { if datasetexists $TESTPOOL/$TESTFS ; then - log_must zfs destroy -f $TESTPOOL/$TESTFS + destroy_dataset $TESTPOOL/$TESTFS -f rm -rf $TESTDIR || log_unresolved Could not remove $TESTDIR fi } diff --git a/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.exists.ksh b/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.exists.ksh index d486c25f4487..eba01b17c80e 100755 --- a/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.exists.ksh +++ b/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.exists.ksh @@ -30,7 +30,7 @@ create_clone function cleanup { datasetexists $TESTPOOL/$TESTFS@$TESTSNAP && \ - log_must zfs destroy -R $TESTPOOL/$TESTFS@$TESTSNAP + destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP -R } log_must_program $TESTPOOL $ZCP_ROOT/lua_core/tst.exists.zcp \ diff --git a/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.return_large.ksh b/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.return_large.ksh index ba9c40739471..bbaeb54f59a5 100755 --- a/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.return_large.ksh +++ b/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.return_large.ksh @@ -27,7 +27,7 @@ fs=$TESTPOOL/$TESTFS/testchild function cleanup { - datasetexists $fs && log_must zfs destroy -R $fs + datasetexists $fs && destroy_dataset $fs -R } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.get_string_props.ksh b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.get_string_props.ksh index b7d784489ac8..31ae4a5717f5 100755 --- a/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.get_string_props.ksh +++ b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.get_string_props.ksh @@ -30,8 +30,8 @@ clone=$TESTPOOL/$TESTCLONE function cleanup { - datasetexists $clone && log_must zfs destroy $clone - datasetexists $fs && log_must zfs destroy -R $fs + datasetexists $clone && destroy_dataset $clone + datasetexists $fs && destroy_dataset $fs -R } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.terminate_by_signal.ksh b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.terminate_by_signal.ksh index 0a5fb804ac39..2c9014a08483 100755 --- a/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.terminate_by_signal.ksh +++ b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.terminate_by_signal.ksh @@ -28,7 +28,7 @@ limit=50000000 function cleanup { - datasetexists $rootfs && log_must zfs destroy -R $rootfs + datasetexists $rootfs && destroy_dataset $rootfs -R } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_002_pos.ksh index b475960c9dea..1290d888a947 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_002_pos.ksh @@ -56,9 +56,7 @@ function cleanup rm -rf $corepath fi for ds in $fs1 $fs $ctr; do - if datasetexists $ds; then - log_must zfs destroy -rRf $ds - fi + datasetexists $ds && destroy_dataset $ds -rRf done } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh index 10e93337abf8..3a1cddb5c64a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh @@ -54,15 +54,14 @@ verify_runnable "both" function cleanup { - if snapexists "$DATASET@$TESTSNAP"; then - log_must zfs destroy "$DATASET@$TESTSNAP" - fi - if bkmarkexists "$DATASET#$TESTBM"; then - log_must zfs destroy "$DATASET#$TESTBM" - fi - if bkmarkexists "$DATASET#$TESTBMCOPY"; then - log_must zfs destroy "$DATASET#$TESTBMCOPY" - fi + snapexists "$DATASET@$TESTSNAP" && \ + destroy_dataset "$DATASET@$TESTSNAP" + + bkmarkexists "$DATASET#$TESTBM" && \ + destroy_dataset "$DATASET#$TESTBM" + + bkmarkexists "$DATASET#$TESTBMCOPY" && \ + destroy_dataset "$DATASET#$TESTBMCOPY" } log_assert "'zfs bookmark' should work only when passed valid arguments." diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key.ksh index 781caae5b5c0..821abdeb32f7 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key.ksh @@ -40,7 +40,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -f $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -f } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_child.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_child.ksh index a886ab8a7793..592f1eccca93 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_child.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_child.ksh @@ -44,7 +44,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_clones.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_clones.ksh index 497fb99c8102..70a9df618e1f 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_clones.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_clones.ksh @@ -40,7 +40,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -Rf $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -Rf } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_format.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_format.ksh index 6344b8d05a20..22212d72d1d6 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_format.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_format.ksh @@ -43,7 +43,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -f $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -f } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_inherit.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_inherit.ksh index 94820c37ecc0..e9b010e912fc 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_inherit.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_inherit.ksh @@ -42,7 +42,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_load.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_load.ksh index 4ed4aadfe0fa..a5a9976196e9 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_load.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_load.ksh @@ -38,7 +38,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -f $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -f } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_location.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_location.ksh index 5cbe34b269ba..607e2208cef4 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_location.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_location.ksh @@ -40,7 +40,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -f $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -f } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_pbkdf2iters.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_pbkdf2iters.ksh index b1672248be12..224fabf22620 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_pbkdf2iters.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/zfs_change-key_pbkdf2iters.ksh @@ -52,7 +52,7 @@ function verify_pbkdf2iters function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -f $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -f } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_001_neg.ksh index b83ccdf48c79..e6ffa26c0208 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_001_neg.ksh @@ -100,11 +100,11 @@ function setup_all function cleanup_all { for fs in $targets; do - datasetexists $fs && log_must zfs destroy -f $fs + datasetexists $fs && destroy_dataset $fs -f done for snap in $SNAPFS $SNAPFS1 ; do - snapexists $snap && log_must zfs destroy -Rf $snap + snapexists $snap && destroy_dataset $snap -Rf done return 0 diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_002_pos.ksh index 8e69a7adcc3d..96eb3ea48d64 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_002_pos.ksh @@ -60,14 +60,10 @@ function setup_all function cleanup_all { - if datasetexists $TESTPOOL/notexist ; then - log_must zfs destroy -rRf $TESTPOOL/notexist - fi + datasetexists $TESTPOOL/notexist && destroy_dataset $TESTPOOL/notexist -rRf for snap in $SNAPFS $SNAPFS1 ; do - if snapexists $snap ; then - log_must zfs destroy -Rf $snap - fi + snapexists $snap && destroy_dataset $snap -Rf done return 0 diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_003_pos.ksh index 522275759880..6484de9c91a8 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_003_pos.ksh @@ -48,9 +48,7 @@ verify_runnable "both" function cleanup { - if snapexists $SNAPFS ; then - log_must zfs destroy -Rf $SNAPFS - fi + snapexists $SNAPFS && destroy_dataset $SNAPFS -Rf } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_004_pos.ksh index 8d86f5501863..1c4c579f26bd 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_004_pos.ksh @@ -48,9 +48,7 @@ verify_runnable "both" function cleanup { - if snapexists $SNAPFS ; then - log_must zfs destroy -Rf $SNAPFS - fi + snapexists $SNAPFS && destroy_dataset $SNAPFS -Rf } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_005_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_005_pos.ksh index afa8b46a6f7c..6f17b176734a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_005_pos.ksh @@ -48,9 +48,7 @@ verify_runnable "global" function cleanup { - if snapexists $SNAPFS1 ; then - log_must zfs destroy -Rf $SNAPFS1 - fi + snapexists $SNAPFS1 && destroy_dataset $SNAPFS1 -Rf } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_006_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_006_pos.ksh index 2127eb117bf5..f2f7a5bcd077 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_006_pos.ksh @@ -49,9 +49,7 @@ verify_runnable "global" function cleanup { - if snapexists $SNAPFS1 ; then - log_must_busy zfs destroy -Rf $SNAPFS1 - fi + snapexists $SNAPFS1 && destroy_dataset $SNAPFS1 -Rf } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh index 6fba72b58067..4bfb3d5f78ab 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh @@ -47,9 +47,7 @@ verify_runnable "both" function cleanup { - if snapexists $SNAPFS ; then - log_must zfs destroy -Rf $SNAPFS - fi + snapexists $SNAPFS && destroy_dataset $SNAPFS -Rf } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_008_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_008_neg.ksh index 8e306fd445ea..2f2b0ca18d64 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_008_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_008_neg.ksh @@ -48,9 +48,7 @@ verify_runnable "both" function cleanup { - if snapexists $SNAPFS ; then - log_must zfs destroy -Rf $SNAPFS - fi + snapexists $SNAPFS && destroy_dataset $SNAPFS -Rf } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_009_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_009_neg.ksh index 030c6af7ae68..6cdf5717fa92 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_009_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_009_neg.ksh @@ -48,9 +48,7 @@ verify_runnable "global" function cleanup { - if snapexists $SNAPFS1 ; then - log_must zfs destroy -Rf $SNAPFS1 - fi + snapexists $SNAPFS1 && destroy_dataset $SNAPFS1 -Rf } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh index dcf80095db28..13f5418d4bf5 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh @@ -39,8 +39,8 @@ function local_cleanup typeset -i i=1 for ds in $datasets; do datasetexists $ds/$TESTCLONE.$i && \ - log_must zfs destroy -rf $ds/$TESTCLONE.$i - datasetexists $ds && log_must zfs destroy -Rf $ds + destroy_dataset $ds/$TESTCLONE.$i -rf + datasetexists $ds && destroy_dataset $ds -Rf ((i=i+1)) done } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_encrypted.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_encrypted.ksh index 86f335bde2a0..1f07b9eb03bc 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_encrypted.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_encrypted.ksh @@ -44,9 +44,9 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS2 && \ - log_must zfs destroy -f $TESTPOOL/$TESTFS2 + destroy_dataset $TESTPOOL/$TESTFS2 -f datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_001_pos.ksh index 2ed881a36706..672692b59e42 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_001_pos.ksh @@ -49,9 +49,7 @@ function cleanup typeset ds for ds in $fs1 $fs2 $vol1 $vol2; do - if datasetexists $ds; then - log_must zfs destroy $ds - fi + datasetexists $ds && destroy_dataset $ds done } @@ -94,13 +92,13 @@ for val in 1 2 3; do fi for ds in $fs2 $vol2; do cmp_prop $ds $val2 - log_must zfs destroy $ds + destroy_dataset $ds block_device_wait done done for ds in $fs1 $vol1; do - log_must zfs destroy $ds + destroy_dataset $ds block_device_wait done diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh index 6e293ca63829..b644fcae3cf8 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh @@ -50,9 +50,8 @@ function cleanup typeset val for val in 1 2 3; do - if datasetexists $TESTPOOL/fs_$val; then - log_must zfs destroy $TESTPOOL/fs_$val - fi + datasetexists $TESTPOOL/fs_$val && \ + destroy_dataset $TESTPOOL/fs_$val done } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_003_pos.ksh index 98420cb7f2ab..94e72bce4e67 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_003_pos.ksh @@ -51,9 +51,7 @@ function cleanup destroy_pool $TESTPOOL1 fi - if datasetexists $vol; then - log_must zfs destroy $vol - fi + datasetexists $vol && destroy_dataset $vol } log_assert "Verify that ZFS volume space used by multiple copies is charged correctly." diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_006_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_006_pos.ksh index 4a3ef76de763..6dc9306b33ef 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_006_pos.ksh @@ -51,9 +51,7 @@ function cleanup log_must umount $mntp fi - if datasetexists $vol; then - log_must zfs destroy $vol - fi + datasetexists $vol && destroy_dataset $vol if [[ -d $mntp ]]; then rm -rf $mntp diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_001_pos.ksh index d0807ac8d176..f74b2c9816f3 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_001_pos.ksh @@ -48,7 +48,7 @@ function cleanup typeset -i i=0 while (( $i < ${#datasets[*]} )); do datasetexists ${datasets[$i]} && \ - log_must zfs destroy -f ${datasets[$i]} + destroy_dataset ${datasets[$i]} -f ((i = i + 1)) done diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_003_pos.ksh index 2906e32dab8c..120de10281db 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_003_pos.ksh @@ -46,8 +46,7 @@ verify_runnable "global" function cleanup { - datasetexists $vol && \ - log_must zfs destroy -f $vol + datasetexists $vol && destroy_dataset $vol -f } log_assert "Verify creating volume with specified blocksize works." diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_004_pos.ksh index 200b4a091567..9e69366c8793 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_004_pos.ksh @@ -48,8 +48,7 @@ verify_runnable "both" function cleanup { - datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -f $TESTPOOL/$TESTFS1 + datasetexists $TESTPOOL/$TESTFS1 && destroy_dataset $TESTPOOL/$TESTFS1 -f } log_onexit cleanup @@ -65,7 +64,7 @@ while (( $i < ${#RW_FS_PROP[*]} )); do log_fail "zfs create $TESTPOOL/$TESTFS1 fail." propertycheck $TESTPOOL/$TESTFS1 ${RW_FS_PROP[i]} || \ log_fail "${RW_FS_PROP[i]} is failed to set." - log_must zfs destroy -f $TESTPOOL/$TESTFS1 + log_must_busy zfs destroy -f $TESTPOOL/$TESTFS1 (( i = i + 1 )) done diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_005_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_005_pos.ksh index e953c65ded95..98cf70938e87 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_005_pos.ksh @@ -49,7 +49,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -f $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -f } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_006_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_006_pos.ksh index 2a664a424619..551ae78cd239 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_006_pos.ksh @@ -50,7 +50,7 @@ verify_runnable "global" function cleanup { datasetexists $TESTPOOL/$TESTVOL1 && \ - log_must zfs destroy -f $TESTPOOL/$TESTVOL1 + destroy_dataset $TESTPOOL/$TESTVOL1 -f } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_008_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_008_neg.ksh index 43c3ab0de338..a905e50dfaa2 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_008_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_008_neg.ksh @@ -46,9 +46,8 @@ verify_runnable "both" function cleanup { - if datasetexists $TESTPOOL/$TESTFS1 ; then - log_must zfs destroy -f $TESTPOOL/$TESTFS1 - fi + datasetexists $TESTPOOL/$TESTFS1 && \ + destroy_dataset $TESTPOOL/$TESTFS1 -f } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_011_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_011_pos.ksh index 982a4ea16b5e..c5012d4f34a8 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_011_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_011_pos.ksh @@ -48,9 +48,8 @@ verify_runnable "both" function cleanup { - if datasetexists $TESTPOOL/$TESTFS1 ; then - log_must zfs destroy -rf $TESTPOOL/$TESTFS1 - fi + datasetexists $TESTPOOL/$TESTFS1 && \ + destroy_dataset $TESTPOOL/$TESTFS1 -rf } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos.ksh index d8aa06407755..a0b8d52f0c43 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos.ksh @@ -48,9 +48,8 @@ verify_runnable "both" function cleanup { - if datasetexists $TESTPOOL/$TESTFS1 ; then - log_must zfs destroy -rf $TESTPOOL/$TESTFS1 - fi + datasetexists $TESTPOOL/$TESTFS1 && \ + destroy_dataset $TESTPOOL/$TESTFS1 -rf } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_014_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_014_pos.ksh index d1a8153d60e5..2482a68dc089 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_014_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_014_pos.ksh @@ -43,8 +43,7 @@ TESTFS2=$(for i in $(seq $((255 - ${#TESTPOOL}))); do echo z ; done | tr -d '\n' function cleanup { - datasetexists $TESTPOOL/$TESTFS1 && - log_must zfs destroy $TESTPOOL/$TESTFS1 + datasetexists $TESTPOOL/$TESTFS1 && destroy_dataset $TESTPOOL/$TESTFS1 } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_crypt_combos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_crypt_combos.ksh index 141b2557d622..758b800c2fe8 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_crypt_combos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_crypt_combos.ksh @@ -38,7 +38,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -f $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -f } log_onexit cleanup @@ -89,7 +89,7 @@ while (( i < ${#ENCRYPTION_ALGS[*]} )); do propertycheck $TESTPOOL/$TESTFS1 ${KEYFORMATS[j]} || \ log_fail "failed to set ${KEYFORMATS[j]}" - log_must zfs destroy -f $TESTPOOL/$TESTFS1 + log_must_busy zfs destroy -f $TESTPOOL/$TESTFS1 (( j = j + 1 )) done (( i = i + 1 )) diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_dryrun.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_dryrun.ksh index 64b8296f46bf..703ae8043d48 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_dryrun.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_dryrun.ksh @@ -126,9 +126,8 @@ function dry_create_parseable function cleanup { - if datasetexists "$TESTPOOL/$TESTFS1"; then - log_must zfs destroy -r "$TESTPOOL/$TESTFS1" - fi + datasetexists "$TESTPOOL/$TESTFS1" && \ + destroy_dataset "$TESTPOOL/$TESTFS1" -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_encrypted.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_encrypted.ksh index 7e5072f0d5fd..e32545c689fe 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_encrypted.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_encrypted.ksh @@ -70,9 +70,9 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -r datasetexists $TESTPOOL/$TESTFS2 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS2 + destroy_dataset $TESTPOOL/$TESTFS2 -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_verbose.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_verbose.ksh index a07ccc7e9ace..acab500062ca 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_verbose.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_verbose.ksh @@ -131,9 +131,8 @@ function dry_create_parseable function cleanup { - if datasetexists "$TESTPOOL/$TESTFS1"; then - log_must_busy zfs destroy -r "$TESTPOOL/$TESTFS1" - fi + datasetexists "$TESTPOOL/$TESTFS1" && \ + destroy_dataset "$TESTPOOL/$TESTFS1" -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_001_pos.ksh index 26857d48d48b..11157e93c78d 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_001_pos.ksh @@ -77,9 +77,7 @@ function test_n_check fi # Clean the test environment and make it clear. - if datasetexists $CTR; then - log_must zfs destroy -Rf $CTR - fi + datasetexists $CTR && destroy_dataset $CTR -Rf # According to option create test compatible environment. case $opt in diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_003_pos.ksh index 04e9713124b1..8b7e59b412b4 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_003_pos.ksh @@ -50,8 +50,7 @@ verify_runnable "both" function cleanup { for obj in $ctr2 $ctr1 $ctr; do - datasetexists $obj && \ - log_must zfs destroy -Rf $obj + datasetexists $obj && destroy_dataset $obj -Rf done for mntp in $TESTDIR1 $TESTDIR2; do @@ -142,14 +141,14 @@ done log_note "Verify that 'zfs destroy -R' succeeds to destroy dataset " \ "with dependent clone outside it." -log_must zfs destroy -R $ctr1 +log_must_busy zfs destroy -R $ctr1 datasetexists $ctr1 && \ log_fail "'zfs destroy -R' fails to destroy dataset with clone outside it." log_note "Verify that 'zfs destroy -r' succeeds to destroy dataset " \ "without dependent clone outside it." -log_must zfs destroy -r $ctr +log_must_busy zfs destroy -r $ctr datasetexists $ctr && \ log_fail "'zfs destroy -r' fails to destroy dataset with clone outside it." diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh index 3db1331ff57e..9a2ff6bea36d 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh @@ -49,15 +49,11 @@ function cleanup { cd $olddir - datasetexists $clone && \ - log_must zfs destroy -f $clone - - snapexists $snap && \ - log_must zfs destroy -f $snap + datasetexists $clone && destroy_dataset $clone -f + snapexists $snap && destroy_dataset $snap -f for fs in $fs1 $fs2; do - datasetexists $fs && \ - log_must zfs destroy -f $fs + datasetexists $fs && destroy_dataset $fs -f done for dir in $TESTDIR1 $TESTDIR2; do diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_007_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_007_neg.ksh index 70ad45af0488..57eb736fd88b 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_007_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_007_neg.ksh @@ -51,8 +51,8 @@ function cleanup if datasetexists $clonesnap; then log_must zfs promote $fs fi - datasetexists $clone && log_must zfs destroy $clone - datasetexists $fssnap && log_must zfs destroy $fssnap + datasetexists $clone && destroy_dataset $clone + datasetexists $fssnap && destroy_dataset $fssnap } log_assert "Destroy dataset which is namespace-parent of origin should failed." diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_014_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_014_pos.ksh index 58c4cfb5646d..e150cddfa1a5 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_014_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_014_pos.ksh @@ -45,7 +45,7 @@ datasets="$TESTPOOL/$TESTFS1 $TESTPOOL/$TESTFS1/$TESTFS2 function cleanup { for ds in $datasets; do - datasetexists $ds && zfs destroy -rf $ds + datasetexists $ds && destroy_dataset $ds -rf done } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_015_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_015_pos.ksh index fb29e4acda14..f1868f522c84 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_015_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_015_pos.ksh @@ -30,8 +30,8 @@ function cleanup { - datasetexists $TESTPOOL/$TESTFS1 && zfs destroy -R $TESTPOOL/$TESTFS1 - datasetexists $TESTPOOL/$TESTFS2 && zfs destroy -R $TESTPOOL/$TESTFS2 + datasetexists $TESTPOOL/$TESTFS1 && destroy_dataset $TESTPOOL/$TESTFS1 -R + datasetexists $TESTPOOL/$TESTFS2 && destroy_dataset $TESTPOOL/$TESTFS2 -R poolexists $TESTPOOL2 && zpool destroy $TESTPOOL2 rm -rf $VIRTUAL_DISK } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_016_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_016_pos.ksh index 1e129ddd3bc9..93c8c63fd23f 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_016_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_016_pos.ksh @@ -30,18 +30,18 @@ function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -R $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -R datasetexists $TESTPOOL/$TESTVOL && \ - log_must zfs destroy -Rf $TESTPOOL/$TESTVOL + destroy_dataset $TESTPOOL/$TESTVOL -Rf } function setup_snapshots { for i in $snaps; do datasetexists $TESTPOOL/$TESTFS1@snap$i && \ - log_must zfs destroy $TESTPOOL/$TESTFS1@snap$i + destroy_dataset $TESTPOOL/$TESTFS1@snap$i datasetexists $TESTPOOL/$TESTVOL@snap$i && \ - log_must zfs destroy $TESTPOOL/$TESTVOL@snap$i + destroy_dataset $TESTPOOL/$TESTVOL@snap$i log_must zfs snapshot $TESTPOOL/$TESTFS1@snap$i log_must zfs snapshot $TESTPOOL/$TESTVOL@snap$i done diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_clone_livelist.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_clone_livelist.ksh index 2da58ec96cac..e7663ef7973c 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_clone_livelist.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_clone_livelist.ksh @@ -39,7 +39,7 @@ function cleanup { - datasetexists $TESTPOOL/$TESTFS1 && zfs destroy -R $TESTPOOL/$TESTFS1 + datasetexists $TESTPOOL/$TESTFS1 && destroy_dataset $TESTPOOL/$TESTFS1 -R # reset the livelist sublist size to its original value set_tunable64 LIVELIST_MAX_ENTRIES $ORIGINAL_MAX } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib index 096c18f069ff..1a20b7a33131 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib @@ -102,9 +102,7 @@ function cleanup_testenv pkill mkbusy - if datasetexists $CTR; then - log_must zfs destroy -Rf $CTR - fi + datasetexists $CTR && destroy_dataset $CTR -Rf } # diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_cliargs.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_cliargs.ksh index c4b42afee472..7063bbe9ce6a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_cliargs.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_cliargs.ksh @@ -32,9 +32,7 @@ verify_runnable "both" function cleanup { for snap in $TESTSNAP1 $TESTSNAP2; do - if snapexists "$snap"; then - log_must zfs destroy "$snap" - fi + snapexists "$snap" && destroy_dataset "$snap" done } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh index 62c4e768c0a1..0d08cf629572 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh @@ -31,9 +31,7 @@ verify_runnable "both" function cleanup { for snap in $TESTSNAP1 $TESTSNAP2; do - if snapexists "$snap"; then - log_must zfs destroy "$snap" - fi + snapexists "$snap" && destroy_dataset "$snap" done find "$MNTPOINT" -type f -delete rm -f "$FILEDIFF" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh index 4bd61137c7be..3bc4c6240ed3 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh @@ -47,11 +47,9 @@ function cleanup { [[ -e $propfile ]] && rm -f $propfile - datasetexists $clone && \ - log_must zfs destroy $clone + datasetexists $clone && destroy_dataset $clone for snap in $fssnap $volsnap ; do - snapexists $snap && \ - log_must zfs destroy $snap + snapexists $snap && destroy_dataset $snap done if [[ -n $globalzone ]] ; then @@ -64,8 +62,7 @@ function cleanup done else for fs in $TESTPOOL/$TESTFS1 $TESTPOOL/$TESTFS2 $TESTPOOL/$TESTFS3; do - datasetexists $fs && \ - log_must zfs destroy -rf $fs + datasetexists $fs && destroy_dataset $fs -rf done fi } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_list_d.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_list_d.kshlib index 48b3268f7813..d5388e6ef2ae 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_list_d.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_list_d.kshlib @@ -78,7 +78,5 @@ function depth_fs_setup # function depth_fs_cleanup { - log_must zfs destroy -rR $DEPTH_FS + datasetexists $DEPTH_FS && destroy_dataset $DEPTH_FS -rR } - - diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/zfs_inherit_002_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/zfs_inherit_002_neg.ksh index 61f22ea091d1..8e37e8dbcae0 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/zfs_inherit_002_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/zfs_inherit_002_neg.ksh @@ -45,9 +45,8 @@ verify_runnable "both" function cleanup { - if snapexists $TESTPOOL/$TESTFS@$TESTSNAP; then - log_must zfs destroy $TESTPOOL/$TESTFS@$TESTSNAP - fi + snapexists $TESTPOOL/$TESTFS@$TESTSNAP && \ + destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP } log_assert "'zfs inherit' should return an error with bad parameters in" \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/zfs_inherit_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/zfs_inherit_003_pos.ksh index 3317b09e2b5b..3f7e4ff972ed 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/zfs_inherit_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/zfs_inherit_003_pos.ksh @@ -47,9 +47,7 @@ verify_runnable "both" function cleanup { for ds in $TESTPOOL $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL ; do - if snapexists $ds@$TESTSNAP; then - log_must zfs destroy $ds@$TESTSNAP - fi + snapexists $ds@$TESTSNAP && destroy_dataset $ds@$TESTSNAP done cleanup_user_prop $TESTPOOL } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key.ksh index 847a6aabd3c8..8af9f80cfbd7 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key.ksh @@ -46,7 +46,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 poolexists $TESTPOOL1 && log_must destroy_pool $TESTPOOL1 } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_all.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_all.ksh index 5e331fd1200d..5e330eb0deb9 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_all.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_all.ksh @@ -37,9 +37,8 @@ verify_runnable "both" function cleanup { - datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy $TESTPOOL/$TESTFS1 - datasetexists $TESTPOOL/zvol && log_must zfs destroy $TESTPOOL/zvol + datasetexists $TESTPOOL/$TESTFS1 && destroy_dataset $TESTPOOL/$TESTFS1 + datasetexists $TESTPOOL/zvol && destroy_dataset $TESTPOOL/zvol poolexists $TESTPOOL1 && log_must destroy_pool $TESTPOOL1 } log_onexit cleanup @@ -58,12 +57,12 @@ log_must zpool create -O encryption=on -O keyformat=passphrase \ -O keylocation=file:///$TESTPOOL/pkey $TESTPOOL1 $DISK2 log_must zfs unmount $TESTPOOL/$TESTFS1 -log_must zfs unload-key $TESTPOOL/$TESTFS1 +log_must_busy zfs unload-key $TESTPOOL/$TESTFS1 -log_must zfs unload-key $TESTPOOL/zvol +log_must_busy zfs unload-key $TESTPOOL/zvol log_must zfs unmount $TESTPOOL1 -log_must zfs unload-key $TESTPOOL1 +log_must_busy zfs unload-key $TESTPOOL1 log_must zfs load-key -a diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_file.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_file.ksh index 7cbda43ff241..73c461fd6b39 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_file.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_file.ksh @@ -38,7 +38,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_location.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_location.ksh index d0b1cdb20ec7..8538143cb62e 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_location.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_location.ksh @@ -44,7 +44,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_noop.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_noop.ksh index bfce786448d9..2ee17834696f 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_noop.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_noop.ksh @@ -37,7 +37,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_recursive.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_recursive.ksh index 7385b69cf5fe..54c390f2737f 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_recursive.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_recursive.ksh @@ -39,7 +39,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_008_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_008_pos.ksh index 4b3bf40bc3be..6a251330f62d 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_008_pos.ksh @@ -47,9 +47,7 @@ function cleanup { ! ismounted $fs && log_must zfs mount $fs - if datasetexists $fs1; then - log_must zfs destroy $fs1 - fi + datasetexists $fs1 && destroy_dataset $fs1 if [[ -f $testfile ]]; then log_must rm -f $testfile diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_011_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_011_neg.ksh index a116b4647c09..95e2bc39727a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_011_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_011_neg.ksh @@ -45,12 +45,11 @@ verify_runnable "both" function cleanup { - if snapexists $TESTPOOL/$TESTFS@$TESTSNAP; then - log_must_busy zfs destroy $TESTPOOL/$TESTFS@$TESTSNAP - fi + snapexists $TESTPOOL/$TESTFS@$TESTSNAP && \ + destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP if is_global_zone && datasetexists $TESTPOOL/$TESTVOL; then - log_must_busy zfs destroy $TESTPOOL/$TESTVOL + destroy_dataset $TESTPOOL/$TESTVOL fi } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_encrypted.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_encrypted.ksh index 9749a9b3aa8a..a95e7507b4d0 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_encrypted.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_encrypted.ksh @@ -42,7 +42,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -f $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -f } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_remount.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_remount.ksh index 9712c793a919..ac6103ebc7bf 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_remount.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_remount.ksh @@ -48,7 +48,7 @@ function cleanup { log_must_busy zpool export $TESTPOOL log_must zpool import $TESTPOOL - snapexists $TESTSNAP && log_must zfs destroy $TESTSNAP + snapexists $TESTSNAP && destroy_dataset $TESTSNAP [[ -d $MNTPSNAP ]] && log_must rmdir $MNTPSNAP return 0 } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_001_pos.ksh index 0bf7c5b6a176..dc3ffd65ed38 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_001_pos.ksh @@ -50,8 +50,7 @@ function cleanup if snapexists $csnap; then log_must zfs promote $fs fi - snapexists $snap && \ - log_must zfs destroy -rR $snap + snapexists $snap && destroy_dataset $snap -rR typeset data for data in $file0 $file1; do diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_003_pos.ksh index e0d0e8457a26..7dedaf91bed6 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_003_pos.ksh @@ -54,8 +54,7 @@ function cleanup typeset ds typeset data for ds in ${snap[*]}; do - snapexists $ds && \ - log_must zfs destroy -rR $ds + snapexists $ds && destroy_dataset $ds -rR done for data in ${file[*]}; do [[ -e $data ]] && rm -f $data diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_004_pos.ksh index 23b5991084f8..b8a5ab9c1707 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_004_pos.ksh @@ -53,8 +53,7 @@ function cleanup typeset ds typeset data for ds in ${snap[*]}; do - snapexists $ds && \ - log_must zfs destroy -rR $ds + snapexists $ds && destroy_dataset $ds -rR done for data in ${file[*]}; do [[ -e $data ]] && rm -f $data diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_005_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_005_pos.ksh index c669a44eb096..289ddc6713bc 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_005_pos.ksh @@ -46,8 +46,8 @@ verify_runnable "both" function cleanup { if datasetexists $fssnap ; then - datasetexists $clone && log_must zfs destroy $clone - log_must zfs destroy $fssnap + datasetexists $clone && destroy_dataset $clone + destroy_dataset $fssnap fi if datasetexists $clone ; then log_must zfs promote $fs diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_006_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_006_neg.ksh index 286c14ac12d9..7f08f28a9379 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_006_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_006_neg.ksh @@ -62,13 +62,9 @@ set -A args "" \ function cleanup { - if datasetexists $clone; then - log_must zfs destroy $clone - fi + datasetexists $clone && destroy_dataset $clone - if datasetexists $recvfs; then - log_must zfs destroy -r $recvfs - fi + datasetexists $recvfs && destroy_dataset $recvfs -r if snapexists $snap; then destroy_snapshot $snap diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_007_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_007_neg.ksh index 3f8ee1941dde..95db7d9e6b4e 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_007_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_007_neg.ksh @@ -47,8 +47,7 @@ verify_runnable "both" function cleanup { - snapexists $snap && \ - log_must zfs destroy -rR $snap + snapexists $snap && destroy_dataset $snap -rR typeset data for data in $TESTDIR/$TESTFILE0 $TESTDIR/$TESTFILE1; do diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_encryptionroot.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_encryptionroot.ksh index 2c7584d3541d..fd6ed7e58e3a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_encryptionroot.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_encryptionroot.ksh @@ -42,11 +42,11 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -Rf $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -Rf datasetexists $TESTPOOL/clone1 && \ - log_must zfs destroy -Rf $TESTPOOL/clone1 + destroy_dataset $TESTPOOL/clone1 -Rf datasetexists $TESTPOOL/clone2 && \ - log_must zfs destroy -Rf $TESTPOOL/clone2 + destroy_dataset $TESTPOOL/clone2 -Rf } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh index cbbacace1ec6..f31ff48099e9 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh @@ -36,7 +36,7 @@ function cleanup { for ds in $datasets; do - datasetexists $ds && log_must zfs destroy -R $TESTPOOL/$TESTFS1 + datasetexists $ds && destroy_dataset $TESTPOOL/$TESTFS1 -R done } function get_prop_mb diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_001_pos.ksh index f8439dcbbebd..8a6cd8c409be 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_001_pos.ksh @@ -48,11 +48,9 @@ function cleanup { typeset -i i=0 - datasetexists $rst_root && \ - log_must zfs destroy -Rf $rst_root + datasetexists $rst_root && destroy_dataset $rst_root -Rf while (( i < 2 )); do - snapexists ${orig_snap[$i]} && \ - log_must zfs destroy -f ${orig_snap[$i]} + snapexists ${orig_snap[$i]} && destroy_dataset ${orig_snap[$i]} -f log_must rm -f ${bkup[$i]} (( i = i + 1 )) @@ -63,8 +61,7 @@ function cleanup function recreate_root { - datasetexists $rst_root && \ - log_must zfs destroy -Rf $rst_root + datasetexists $rst_root && destroy_dataset $rst_root -Rf if [[ -d $TESTDIR1 ]] ; then log_must rm -rf $TESTDIR1 fi diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_002_pos.ksh index 36af37a7576d..ba3fc49bd84c 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_002_pos.ksh @@ -50,10 +50,8 @@ function cleanup typeset ds while (( i < ${#orig_snap[*]} )); do - snapexists ${rst_snap[$i]} && \ - log_must zfs destroy -f ${rst_snap[$i]} - snapexists ${orig_snap[$i]} && \ - log_must zfs destroy -f ${orig_snap[$i]} + snapexists ${rst_snap[$i]} && destroy_dataset ${rst_snap[$i]} -f + snapexists ${orig_snap[$i]} && destroy_dataset ${orig_snap[$i]} -f [[ -e ${bkup[$i]} ]] && \ log_must rm -rf ${bkup[$i]} @@ -61,8 +59,7 @@ function cleanup done for ds in $rst_vol $rst_root; do - datasetexists $ds && \ - log_must zfs destroy -Rf $ds + datasetexists $ds && destroy_dataset $ds -Rf done } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh index d5f6e0984df5..cce387615315 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh @@ -49,7 +49,7 @@ verify_runnable "both" function cleanup { for snap in $snap2 $snap1; do - datasetexists $snap && log_must zfs destroy -rf $snap + datasetexists $snap && destroy_dataset $snap -rf done for file in $ibackup $mntpnt/file1 $mntpnt/file2; do [[ -f $file ]] && log_must rm -f $file diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_004_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_004_neg.ksh index 56f536225d74..7c115ee33b96 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_004_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_004_neg.ksh @@ -49,8 +49,7 @@ function cleanup typeset bkup for snap in $init_snap $inc_snap $init_topsnap $inc_topsnap ; do - snapexists $snap && \ - log_must zfs destroy -Rf $snap + snapexists $snap && destroy_dataset $snap -Rf done for bkup in $full_bkup $inc_bkup $full_topbkup $inc_topbkup; do diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_005_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_005_neg.ksh index ce89c6835775..d8c71f2c2877 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_005_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_005_neg.ksh @@ -53,12 +53,10 @@ function cleanup typeset bkup for snap in $init_snap $inc_snap; do - snapexists $snap && \ - log_must zfs destroy -f $snap + snapexists $snap && destroy_dataset $snap -f done - datasetexists $rst_root && \ - log_must zfs destroy -Rf $rst_root + datasetexists $rst_root && destroy_dataset $rst_root -Rf for bkup in $full_bkup $inc_bkup; do [[ -e $bkup ]] && \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_006_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_006_pos.ksh index 7338fd2b9fb2..79f34bd3ff8c 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_006_pos.ksh @@ -51,7 +51,7 @@ verify_runnable "both" function cleanup { for snap in $snap2 $snap1; do - datasetexists $snap && log_must zfs destroy -rf $snap + datasetexists $snap && destroy_dataset $snap -rf done for file in $fbackup1 $fbackup2 $mntpnt/file1 $mntpnt/file2; do [[ -f $file ]] && log_must rm -f $file @@ -59,10 +59,10 @@ function cleanup if is_global_zone; then datasetexists $TESTPOOL/$TESTFS/$TESTFS1 && \ - log_must zfs destroy -rf $TESTPOOL/$TESTFS/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS/$TESTFS1 -rf else datasetexists $TESTPOOL/${ZONE_CTR}0 && \ - log_must zfs destroy -rf $TESTPOOL/${ZONE_CTR}0 + destroy_dataset $TESTPOOL/${ZONE_CTR}0 -rf fi } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_007_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_007_neg.ksh index 57454dcbc6f2..fbf0654e4f23 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_007_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_007_neg.ksh @@ -47,7 +47,7 @@ verify_runnable "both" function cleanup { for snap in $snap2 $snap1; do - datasetexists $snap && log_must zfs destroy -rf $snap + datasetexists $snap && destroy_dataset $snap -rf done for file in $ibackup $mntpnt/file1 $mntpnt/file2; do [[ -f $file ]] && log_must rm -f $file diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_008_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_008_pos.ksh index 1729b59b2bfd..dc4892b5d50e 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_008_pos.ksh @@ -47,9 +47,7 @@ function cleanup { for dset in $rst_snap $rst_fs $orig_snap; do - if datasetexists $dset; then - log_must zfs destroy -fr $dset - fi + datasetexists $dset && destroy_dataset $dset -fr done for file in $fbackup $mnt_file $tmp_out; do @@ -59,7 +57,7 @@ function cleanup done if datasetexists $TESTPOOL/$TESTFS; then - log_must zfs destroy -Rf $TESTPOOL/$TESTFS + destroy_dataset $TESTPOOL/$TESTFS -Rf log_must zfs create $TESTPOOL/$TESTFS log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS fi @@ -99,9 +97,7 @@ for orig_fs in $datasets ; do log_must eval "zfs send $orig_snap > $fbackup" for opt in "-v" "-vn"; do - if datasetexists $rst_fs; then - log_must zfs destroy -fr $rst_fs - fi + datasetexists $rst_fs && destroy_dataset $rst_fs -fr log_note "Check ZFS receive $opt []" log_must eval "zfs receive $opt $rst_fs < $fbackup > $tmp_out 2>&1" if [[ $opt == "-v" ]]; then diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_009_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_009_neg.ksh index d028acafada0..37fe515e23f7 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_009_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_009_neg.ksh @@ -48,13 +48,10 @@ function cleanup { typeset ds - if snapexists $snap; then - log_must zfs destroy $snap - fi + snapexists $snap && destroy_dataset $snap + for ds in $ctr1 $ctr2 $fs1; do - if datasetexists $ds; then - log_must zfs destroy -rf $ds - fi + datasetexists $ds && destroy_dataset $ds -rf done if [[ -d $TESTDIR2 ]]; then rm -rf $TESTDIR2 diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh index be8f49809d47..e1e93e9d2a3b 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh @@ -39,7 +39,7 @@ tpoolfile=$TEST_BASE_DIR/temptank.$$ function cleanup { for fs in $src_fs $dst_fs; do - datasetexists $fs && log_must zfs destroy -rf $fs + datasetexists $fs && log_must destroy_dataset $fs -rf done zpool destroy $temppool [[ -f $streamfile ]] && log_must rm -f $streamfile diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_encrypted.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_encrypted.ksh index a1d094bdb4ba..891432685287 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_encrypted.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_encrypted.ksh @@ -41,10 +41,10 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -r datasetexists $TESTPOOL/$TESTFS2 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS2 + destroy_dataset $TESTPOOL/$TESTFS2 -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh index 14a175912bb2..72eebb4f9321 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh @@ -40,10 +40,10 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -r datasetexists $TESTPOOL/$TESTFS2 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS2 + destroy_dataset $TESTPOOL/$TESTFS2 -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw.ksh index 9740caf72508..32b05e527ad3 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw.ksh @@ -44,10 +44,10 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -r datasetexists $TESTPOOL/$TESTFS2 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS2 + destroy_dataset $TESTPOOL/$TESTFS2 -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw_-d.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw_-d.ksh index a909f2788ba1..662f9386ebee 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw_-d.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw_-d.ksh @@ -38,7 +38,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -r rm -f $sendfile } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw_incremental.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw_incremental.ksh index 964c80657da3..7826ec9a4890 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw_incremental.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_raw_incremental.ksh @@ -43,10 +43,10 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -r datasetexists $TESTPOOL/$TESTFS2 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS2 + destroy_dataset $TESTPOOL/$TESTFS2 -r [[ -f $ibackup ]] && log_must rm -f $ibackup [[ -f $ibackup_trunc ]] && log_must rm -f $ibackup_trunc diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_to_encrypted.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_to_encrypted.ksh index f8e53f02c23d..526497401f28 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_to_encrypted.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_to_encrypted.ksh @@ -38,10 +38,10 @@ verify_runnable "both" function cleanup { - snapexists $snap && log_must_busy zfs destroy -f $snap + snapexists $snap && destroy_dataset $snap -f datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib index 9b8fb6b0edc1..af1c2f7bedaf 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib @@ -108,13 +108,11 @@ function cleanup ((i = i + 1)) done - if snapexists $TESTPOOL/$TESTFS@snapshot; then - log_must zfs destroy -fR $TESTPOOL/$TESTFS@snapshot - fi + snapexists $TESTPOOL/$TESTFS@snapshot && \ + destroy_dataset $TESTPOOL/$TESTFS@snapshot -fR - if datasetexists $TESTPOOL/$RECVFS; then - log_must zfs destroy -r $TESTPOOL/$RECVFS - fi + datasetexists $TESTPOOL/$RECVFS && \ + destroy_dataset $TESTPOOL/$RECVFS -r } function cmp_data #<$1 src data, $2 tgt data> diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_003_pos.ksh index 56c06cfe857d..0bd4aca3a7fd 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_003_pos.ksh @@ -44,7 +44,7 @@ verify_runnable "both" function cleanup { - datasetexists $snap && log_must zfs destroy $snap + datasetexists $snap && destroy_dataset $snap } log_assert "'zfs rename' can address the abbreviated snapshot name." diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_007_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_007_pos.ksh index 0cacb7a98fa2..2a3f8a8ccd7b 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_007_pos.ksh @@ -46,9 +46,8 @@ verify_runnable "both" function cleanup { - if datasetexists $TESTPOOL/$TESTFS ; then - log_must zfs destroy -Rf $TESTPOOL/$TESTFS - fi + datasetexists $TESTPOOL/$TESTFS && \ + destroy_dataset $TESTPOOL/$TESTFS -Rf log_must zfs create $TESTPOOL/$TESTFS log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_008_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_008_pos.ksh index 3fc099d79f8a..229163839058 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_008_pos.ksh @@ -47,12 +47,11 @@ function cleanup { typeset -i i=0 while ((i < ${#datasets[@]})); do - if datasetexists ${datasets[$i]}@snap ; then - log_must zfs destroy ${datasets[$i]}@snap - fi - if datasetexists ${datasets[$i]}@snap-new ; then - log_must zfs destroy ${datasets[$i]}@snap-new - fi + datasetexists ${datasets[$i]}@snap && \ + destroy_dataset ${datasets[$i]}@snap + + datasetexists ${datasets[$i]}@snap-new && \ + destroy_dataset ${datasets[$i]}@snap-new ((i += 1)) done diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_011_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_011_pos.ksh index 2d1220e334c9..71d72619d646 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_011_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_011_pos.ksh @@ -46,19 +46,18 @@ verify_runnable "both" function additional_cleanup { - if datasetexists $TESTPOOL/notexist ; then - log_must zfs destroy -Rf $TESTPOOL/notexist - fi + datasetexists $TESTPOOL/notexist && \ + destroy_dataset $TESTPOOL/notexist -Rf + + datasetexists $TESTPOOL/$TESTFS && \ + destroy_dataset $TESTPOOL/$TESTFS -Rf - if datasetexists $TESTPOOL/$TESTFS ; then - log_must zfs destroy -Rf $TESTPOOL/$TESTFS - fi log_must zfs create $TESTPOOL/$TESTFS if is_global_zone ; then - if datasetexists $TESTPOOL/$TESTVOL ; then - log_must zfs destroy -Rf $TESTPOOL/$TESTVOL - fi + datasetexists $TESTPOOL/$TESTVOL && \ + destroy_dataset $TESTPOOL/$TESTVOL -Rf + log_must zfs create -V $VOLSIZE $TESTPOOL/$TESTVOL fi } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_013_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_013_pos.ksh index b2e01006fdd1..73790f58cd45 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_013_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_013_pos.ksh @@ -46,21 +46,17 @@ verify_runnable "both" function cleanup { - if datasetexists $TESTPOOL/$TESTCTR@snap-new ; then - log_must zfs destroy -f $TESTPOOL/$TESTCTR@snap-new - fi + datasetexists $TESTPOOL/$TESTCTR@snap-new && \ + destroy_dataset $TESTPOOL/$TESTCTR@snap-new -f - if datasetexists $TESTPOOL/$TESTCTR@snap ; then - log_must zfs destroy -f $TESTPOOL/$TESTCTR@snap - fi + datasetexists $TESTPOOL/$TESTCTR@snap && \ + destroy_dataset $TESTPOOL/$TESTCTR@snap -f - if datasetexists $TESTPOOL@snap-new ; then - log_must zfs destroy -f $TESTPOOL@snap-new - fi + datasetexists $TESTPOOL@snap-new && \ + destroy_dataset $TESTPOOL@snap-new -f - if datasetexists $TESTPOOL@snap ; then - log_must zfs destroy -f $TESTPOOL@snap - fi + datasetexists $TESTPOOL@snap && \ + destroy_dataset $TESTPOOL@snap -f } log_assert "zfs rename -r can rename snapshot when child datasets" \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_encrypted_child.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_encrypted_child.ksh index fa57658f185b..2366cf67655c 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_encrypted_child.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_encrypted_child.ksh @@ -42,9 +42,9 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS2 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS2 + destroy_dataset $TESTPOOL/$TESTFS2 -r datasetexists $TESTPOOL/$TESTFS3 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS3 + destroy_dataset $TESTPOOL/$TESTFS3 -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_to_encrypted.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_to_encrypted.ksh index 1b9c6e3c704f..ab8e1c89ae86 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_to_encrypted.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_to_encrypted.ksh @@ -37,7 +37,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS2 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS2 + destroy_dataset $TESTPOOL/$TESTFS2 -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_001_pos.ksh index 342c72e166a9..607bbf06eafd 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_001_pos.ksh @@ -76,14 +76,14 @@ function test_n_check #opt num_snap_clone num_rollback pkill -x dd fi - datasetexists $FS && log_must zfs destroy -Rf $FS + datasetexists $FS && destroy_dataset $FS -Rf if datasetexists $VOL; then if ismounted $TESTDIR1 $NEWFS_DEFAULT_FS; then log_must umount -f $TESTDIR1 sleep 0.1 fi - log_must zfs destroy -Rf $VOL + destroy_dataset $VOL -Rf fi # Create specified test environment diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_003_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_003_neg.ksh index 0ae13d3a9bad..1e3109108bae 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_003_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_003_neg.ksh @@ -51,9 +51,7 @@ function cleanup { pkill ${DD##*/} for snap in $FSSNAP0 $FSSNAP1 $FSSNAP2; do - if snapexists $snap; then - log_must zfs destroy -Rf $snap - fi + snapexists $snap && destroy_dataset $snap -Rf done } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_004_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_004_neg.ksh index 0c1bb730e77c..9537d5077b1a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_004_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_004_neg.ksh @@ -51,9 +51,8 @@ function cleanup typeset ds for ds in $TESTPOOL $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL; do - if snapexists ${ds}@$TESTSNAP; then - log_must zfs destroy ${ds}@$TESTSNAP - fi + snapexists ${ds}@$TESTSNAP && \ + destroy_dataset ${ds}@$TESTSNAP done } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib index b2f4b2b8a3ca..433f240675f3 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib @@ -181,9 +181,7 @@ function cleanup_env for dtst in $FS $VOL; do for snap in $TESTSNAP $TESTSNAP1 $TESTSNAP2; do - if snapexists $dtst@$snap; then - log_must zfs destroy -Rf $dtst@$snap - fi + snapexists $dtst@$snap && destroy_dataset $dtst@$snap -Rf done done diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send-b.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send-b.ksh index 2105bc4d23e4..f019c2215ecd 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send-b.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send-b.ksh @@ -35,7 +35,7 @@ verify_runnable "both" function cleanup { for ds in "$SENDFS" "$BACKUP" "$RESTORE"; do - datasetexists $ds && log_must zfs destroy -r $ds + datasetexists $ds && destroy_dataset $ds -r done } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_001_pos.ksh index 2c6e3fdd6d2f..b18433085ed5 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_001_pos.ksh @@ -50,12 +50,10 @@ verify_runnable "both" function cleanup { for snap in $init_snap $inc_snap $rst_snap $rst_inc_snap; do - snapexists $snap && \ - log_must zfs destroy -f $snap + snapexists $snap && destroy_dataset $snap -f done - datasetexists $rst_root && \ - log_must zfs destroy -Rf $rst_root + datasetexists $rst_root && destroy_dataset $rst_root -Rf for file in $full_bkup $inc_bkup \ $init_data $inc_data diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_002_pos.ksh index 6359bb4f7f22..42bdddd2cc18 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_002_pos.ksh @@ -48,11 +48,8 @@ verify_runnable "both" function cleanup { - snapexists $snap && \ - log_must zfs destroy $snap - - datasetexists $ctr && \ - log_must zfs destroy -r $ctr + snapexists $snap && destroy_dataset $snap + datasetexists $ctr && destroy_dataset $ctr -r [[ -e $origfile ]] && \ log_must rm -f $origfile diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_003_pos.ksh index 0b55254f75d6..caa84886fa12 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_003_pos.ksh @@ -44,8 +44,8 @@ verify_runnable "both" function cleanup { - datasetexists $snap1 && log_must zfs destroy $snap1 - datasetexists $snap2 && log_must zfs destroy $snap2 + datasetexists $snap1 && destroy_dataset $snap1 + datasetexists $snap2 && destroy_dataset $snap2 } log_assert "'zfs send -i' can deal with abbreviated snapshot name." diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_004_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_004_neg.ksh index dfa9fc251d6b..af10e3a11faf 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_004_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_004_neg.ksh @@ -48,8 +48,7 @@ function cleanup typeset snap f for snap in $snap1 $snap2 $snap3; do - snapexists $snap && \ - log_must zfs destroy -f $snap + snapexists $snap && destroy_dataset $snap -f done for f in $tmpfile1 $tmpfile2; do diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_005_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_005_pos.ksh index c9e37cbbad8e..c4ab7a6212bc 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_005_pos.ksh @@ -50,7 +50,7 @@ function cleanup log_must zpool import $TESTPOOL datasetexists $TESTPOOL@snap && \ - log_must zfs destroy -r $TESTPOOL@snap + destroy_dataset $TESTPOOL@snap -r } log_assert "'zfs send -R' can send from read-only pools" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_encrypted.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_encrypted.ksh index 1e63b29ade1f..a4c332d47dfc 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_encrypted.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_encrypted.ksh @@ -42,7 +42,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_encrypted_unloaded.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_encrypted_unloaded.ksh index 9d59494fc635..f268f7b38d4d 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_encrypted_unloaded.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_encrypted_unloaded.ksh @@ -37,7 +37,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_raw.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_raw.ksh index 065eea3ebd86..03c2e78673d8 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_raw.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_raw.ksh @@ -38,11 +38,9 @@ verify_runnable "both" function cleanup { - snapexists $snap && \ - log_must zfs destroy $snap - + snapexists $snap && destroy_dataset $snap datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_skip_missing.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_skip_missing.ksh index b367cef9c4a4..2e12d2534412 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_skip_missing.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_skip_missing.ksh @@ -44,9 +44,9 @@ verify_runnable "both" function cleanup { - snapexists $SNAP && log_must zfs destroy -f $SNAP + snapexists $SNAP && destroy_dataset $SNAP -f - datasetexists $PARENT && log_must zfs destroy -rf $PARENT + datasetexists $PARENT && destroy_dataset $PARENT -rf [[ -e $WARNF ]] && log_must rm -f $WARNF rm -f $TEST_BASE_DIR/devnull diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_sparse.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_sparse.ksh index 4878c06108e4..aeb49afd7fc8 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_sparse.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_sparse.ksh @@ -31,8 +31,8 @@ verify_runnable "both" function cleanup { - datasetexists $SENDFS && log_must zfs destroy -r $SENDFS - datasetexists $RECVFS && log_must zfs destroy -r $RECVFS + datasetexists $SENDFS && destroy_dataset $SENDFS -r + datasetexists $RECVFS && destroy_dataset $RECVFS -r } # @@ -63,8 +63,8 @@ function write_compare_files # log_fail "$sendfile ($sendsz) and $recvfile ($recvsz) differ." fi # cleanup - log_must zfs destroy -r $sendfs - log_must zfs destroy -r $recvfs + destroy_dataset $sendfs -r + destroy_dataset $recvfs -r } log_assert "'zfs send' should be able to send (big) sparse files correctly." diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh index dd3397f01579..ac5fc8188f5a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh @@ -63,12 +63,11 @@ set -A values "on" "off" function cleanup { - if snapexists $TESTPOOL/$TESTFS@$TESTSNAP ; then - log_must zfs destroy -R $TESTPOOL/$TESTFS@$TESTSNAP - fi - if snapexists $TESTPOOL/$TESTVOL@$TESTSNAP ; then - log_must zfs destroy -R $TESTPOOL/$TESTVOL@$TESTSNAP - fi + snapexists $TESTPOOL/$TESTFS@$TESTSNAP && \ + destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP -R + + snapexists $TESTPOOL/$TESTVOL@$TESTSNAP && \ + destroy_dataset $TESTPOOL/$TESTVOL@$TESTSNAP -R [[ -n $old_ctr_canmount ]] && \ log_must zfs set canmount=$old_ctr_canmount $TESTPOOL/$TESTCTR diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh index 1aeee44e044e..55c71f6ca33a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh @@ -76,18 +76,17 @@ function cleanup ds=$TESTPOOL/$TESTCLONE if datasetexists $ds; then mntp=$(get_prop mountpoint $ds) - log_must zfs destroy $ds + destroy_dataset $ds if [[ -d $mntp ]]; then rm -fr $mntp fi fi - if snapexists $TESTPOOL/$TESTFS@$TESTSNAP ; then - log_must zfs destroy -R $TESTPOOL/$TESTFS@$TESTSNAP - fi - if snapexists $TESTPOOL/$TESTVOL@$TESTSNAP ; then - log_must zfs destroy -R $TESTPOOL/$TESTVOL@$TESTSNAP - fi + snapexists $TESTPOOL/$TESTFS@$TESTSNAP && \ + destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP -R + + snapexists $TESTPOOL/$TESTVOL@$TESTSNAP && \ + destroy_dataset $TESTPOOL/$TESTVOL@$TESTSNAP -R zfs unmount -a > /dev/null 2>&1 log_must zfs mount -a diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_003_pos.ksh index a11cfb40884b..e4664d03b43c 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_003_pos.ksh @@ -63,15 +63,14 @@ function cleanup ds=$TESTPOOL/$TESTCLONE if datasetexists $ds; then mntp=$(get_prop mountpoint $ds) - log_must zfs destroy $ds + destroy_dataset $ds if [[ -d $mntp ]]; then log_must rm -fr $mntp fi fi - if snapexists $TESTPOOL/$TESTFS@$TESTSNAP ; then - log_must zfs destroy -R $TESTPOOL/$TESTFS@$TESTSNAP - fi + snapexists $TESTPOOL/$TESTFS@$TESTSNAP && \ + destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP -R zfs unmount -a > /dev/null 2>&1 log_must zfs mount -a diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/readonly_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/readonly_001_pos.ksh index 22fb0a77c9ab..4adac420f748 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/readonly_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/readonly_001_pos.ksh @@ -48,7 +48,7 @@ function cleanup { for dataset in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL ; do snapexists ${dataset}@$TESTSNAP && \ - log_must zfs destroy -R ${dataset}@$TESTSNAP + destroy_dataset ${dataset}@$TESTSNAP -R done } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/snapdir_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/snapdir_001_pos.ksh index 079fc770a6fe..083a6b1f464f 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/snapdir_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/snapdir_001_pos.ksh @@ -48,8 +48,7 @@ verify_runnable "both" function cleanup { for dataset in $all_datasets; do - snapexists ${dataset}@snap && \ - log_must zfs destroy ${dataset}@snap + snapexists ${dataset}@snap && destroy_dataset ${dataset}@snap done } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/user_property_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/user_property_004_pos.ksh index 1d197fa25fbd..bd11ea088333 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/user_property_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/user_property_004_pos.ksh @@ -46,9 +46,7 @@ function cleanup { for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL ; do typeset fssnap=$fs@snap - if datasetexists $fssnap ; then - log_must zfs destroy -f $fssnap - fi + datasetexists $fssnap && destroy_dataset $fssnap -f done cleanup_user_prop $TESTPOOL } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_003_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_003_neg.ksh index 102e8874294f..fd5f7f285f5b 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_003_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_003_neg.ksh @@ -48,9 +48,8 @@ function cleanup if [ -e $badpath ]; then rm -f $badpath fi - if datasetexists $TESTPOOL/foo; then - log_must zfs destroy $TESTPOOL/foo - fi + + datasetexists $TESTPOOL/foo && destroy_dataset $TESTPOOL/foo } log_assert "'zfs set mountpoint/sharenfs' fails with invalid scenarios" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_keylocation.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_keylocation.ksh index 0d2e7ab8f298..d8a2fcbdf9b3 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_keylocation.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_keylocation.ksh @@ -45,7 +45,8 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -r + cleanup_https } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_001_pos.ksh index fefeb1b1cbd5..6d4396aa1912 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_001_pos.ksh @@ -66,11 +66,10 @@ function cleanup fi datasetexists $TESTPOOL/$TESTFS-clone && \ - log_must zfs destroy -f $TESTPOOL/$TESTFS-clone + destroy_dataset $TESTPOOL/$TESTFS-clone -f - if snapexists "$TESTPOOL/$TESTFS@snapshot"; then - log_must zfs destroy -f $TESTPOOL/$TESTFS@snapshot - fi + snapexists "$TESTPOOL/$TESTFS@snapshot" && \ + destroy_dataset $TESTPOOL/$TESTFS@snapshot -f log_must zfs share -a } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_004_pos.ksh index baa5f4e41695..6c48875f5268 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_004_pos.ksh @@ -47,9 +47,8 @@ verify_runnable "global" function cleanup { - if snapexists $TESTPOOL/$TESTFS@snapshot; then - log_must zfs destroy $TESTPOOL/$TESTFS@snapshot - fi + snapexists $TESTPOOL/$TESTFS@snapshot && \ + destroy_dataset $TESTPOOL/$TESTFS@snapshot log_must zfs set sharenfs=off $TESTPOOL/$TESTFS log_must unshare_fs $TESTPOOL/$TESTFS diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_006_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_006_pos.ksh index 6b06589b69e2..d5394017d780 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_006_pos.ksh @@ -53,7 +53,7 @@ function cleanup fi datasetexists $TESTPOOL/$TESTCTR/$TESTFS2 && \ - log_must zfs destroy $TESTPOOL/$TESTCTR/$TESTFS2 + destroy_dataset $TESTPOOL/$TESTCTR/$TESTFS2 typeset fs="" for fs in $mntp $TESTDIR1 $TESTDIR2 diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_011_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_011_pos.ksh index f75877ee89db..131b039e1cd2 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_011_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_011_pos.ksh @@ -51,13 +51,11 @@ function cleanup log_must zfs set sharenfs=off $TESTPOOL/$TESTFS unshare_fs $TESTPOOL/$TESTFS - if snapexists "$TESTPOOL/$TESTFS@snapshot"; then - log_must zfs destroy -f $TESTPOOL/$TESTFS@snapshot - fi + snapexists "$TESTPOOL/$TESTFS@snapshot" && \ + destroy_dataset $TESTPOOL/$TESTFS@snapshot -f - if datasetexists $TESTPOOL/$TESTFS/fs2 ; then - log_must zfs destroy -f $TESTPOOL/$TESTFS/fs2 - fi + datasetexists $TESTPOOL/$TESTFS/fs2 && \ + destroy_dataset $TESTPOOL/$TESTFS/fs2 -f } log_assert "Verify that umount and destroy fail, and do not unshare the shared" \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_concurrent_shares.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_concurrent_shares.ksh index 762436678dcb..dbaaf39b65d4 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_concurrent_shares.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_concurrent_shares.ksh @@ -67,11 +67,11 @@ function cleanup fi datasetexists $TESTPOOL/$TESTFS1/$fs && \ - log_must zfs destroy -f $TESTPOOL/$TESTFS1/$fs + destroy_dataset $TESTPOOL/$TESTFS1/$fs -f datasetexists $TESTPOOL/$TESTFS2/$fs && \ - log_must zfs destroy -f $TESTPOOL/$TESTFS2/$fs + destroy_dataset $TESTPOOL/$TESTFS2/$fs -f datasetexists $TESTPOOL/$TESTFS3/$fs && \ - log_must zfs destroy -f $TESTPOOL/$TESTFS3/$fs + destroy_dataset $TESTPOOL/$TESTFS3/$fs -f done log_must zfs share -a diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_001_neg.ksh index 8708d8b62432..2b89af9e5a43 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_001_neg.ksh @@ -89,7 +89,7 @@ function cleanup_all while (( i < ${#args[*]} )); do for snap in ${args[i]}; do - snapexists $snap && log_must zfs destroy -f $snap + snapexists $snap && destroy_dataset $snap -f done (( i = i + 1 )) done diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_002_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_002_neg.ksh index 5d8b6e2750f5..4ae68d411dd0 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_002_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_002_neg.ksh @@ -53,12 +53,11 @@ function cleanup for snap in $TESTPOOL/$TESTCTR/$TESTFS1@$TESTSNAP \ $TESTPOOL/$TESTCTR/$TESTVOL@$TESTSNAP; do - snapexists $snap && \ - log_must zfs destroy $snap + snapexists $snap && destroy_dataset $snap done datasetexists $TESTPOOL/$TESTCTR/$TESTVOL && \ - log_must zfs destroy -rf $TESTPOOL/$TESTCTR/$TESTVOL + destroy_dataset $TESTPOOL/$TESTCTR/$TESTVOL -rf } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_004_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_004_neg.ksh index 96121f1c136d..16926a48ddc4 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_004_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_004_neg.ksh @@ -44,9 +44,7 @@ verify_runnable "both" function cleanup { - if datasetexists $initfs ; then - log_must zfs destroy -rf $initfs - fi + datasetexists $initfs && destroy_dataset $initfs -rf } log_assert "Verify recursive snapshotting could not break ZFS." @@ -70,9 +68,7 @@ while ((ret == 0)); do # is incorrect # if ((len >= 255)); then - if datasetexists $basefs; then - log_must zfs destroy -r $basefs - fi + datasetexists $basefs && destroy_dataset $basefs -r basefs=${basefs%/*} len=$(echo $basefs| wc -c) fi diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_005_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_005_neg.ksh index d97dc0f82265..c133403ac84a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_005_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_005_neg.ksh @@ -45,9 +45,7 @@ verify_runnable "both" function cleanup { - if datasetexists $initfs ; then - log_must zfs destroy -rf $initfs - fi + datasetexists $initfs && destroy_dataset $initfs -rf } log_assert "Verify long name filesystem with snapshot should not break ZFS." @@ -71,9 +69,7 @@ while ((ret == 0)); do # is incorrect # if ((len >= 255)); then - if datasetexists $basefs; then - log_must zfs destroy -r $basefs - fi + datasetexists $basefs && destroy_dataset $basefs -r basefs=${basefs%/*} len=$(echo $basefs| wc -c) fi diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_006_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_006_pos.ksh index 089ebdb97924..6b711286c68d 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_006_pos.ksh @@ -46,9 +46,7 @@ function cleanup { for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL ; do typeset fssnap=$fs@snap - if datasetexists $fssnap ; then - log_must zfs destroy -rf $fssnap - fi + datasetexists $fssnap && destroy_dataset $fssnap -rf done cleanup_user_prop $TESTPOOL } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_007_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_007_neg.ksh index 9d8c1373f91e..9499dca21e78 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_007_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_007_neg.ksh @@ -46,9 +46,7 @@ function cleanup { for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do typeset fssnap=$fs@snap - if datasetexists $fssnap ; then - log_must zfs destroy -rf $fssnap - fi + datasetexists $fssnap && destroy_dataset $fssnap -rf done cleanup_user_prop $TESTPOOL } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh index a20fcc4ce224..6fedba9e5b27 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh @@ -34,10 +34,10 @@ ZFS_MAX_DATASET_NAME_LEN=256 function cleanup { for ds in $datasets; do - datasetexists $ds && log_must zfs destroy -r $ds + datasetexists $ds && destroy_dataset $ds -r done - zfs destroy -r $TESTPOOL/TESTFS4 - zfs destroy -r $TESTPOOL/TESTFS5 + destroy_dataset $TESTPOOL/TESTFS4 -r + destroy_dataset $TESTPOOL/TESTFS5 -r } datasets="$TESTPOOL/$TESTFS1 $TESTPOOL/$TESTFS2 $TESTPOOL/$TESTFS3" @@ -70,8 +70,7 @@ i=0 while (( i < ${#valid_args[*]} )); do log_must zfs snapshot ${valid_args[i]} for token in ${valid_args[i]}; do - log_must snapexists $token && \ - log_must zfs destroy $token + snapexists $token && destroy_dataset $token done ((i = i + 1)) done diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key.ksh index 9e08ac69d4de..55cfb5cade03 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key.ksh @@ -43,7 +43,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh index ecb98d189424..55da68262019 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh @@ -38,9 +38,8 @@ verify_runnable "both" function cleanup { - datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 - datasetexists $TESTPOOL/zvol && log_must zfs destroy $TESTPOOL/zvol + datasetexists $TESTPOOL/$TESTFS1 && destroy_dataset $TESTPOOL/$TESTFS1 -r + datasetexists $TESTPOOL/zvol && destroy_dataset $TESTPOOL/zvol poolexists $TESTPOOL1 && log_must destroy_pool $TESTPOOL1 } log_onexit cleanup @@ -62,7 +61,7 @@ log_must zpool create -O encryption=on -O keyformat=passphrase \ log_must zfs unmount $TESTPOOL/$TESTFS1 log_must zfs unmount $TESTPOOL1 -log_must zfs unload-key -a +log_must_busy zfs unload-key -a log_must key_unavailable $TESTPOOL/$TESTFS1 log_must key_unavailable $TESTPOOL/$TESTFS1/child diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_recursive.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_recursive.ksh index 9766b590587f..01c720c04b58 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_recursive.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_recursive.ksh @@ -41,7 +41,7 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_001_pos.ksh index fb4d1d937895..6036eb27a062 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_001_pos.ksh @@ -55,7 +55,7 @@ function cleanup log_must zfs umount -f $TESTDIR2 datasetexists $TESTPOOL/$TESTFS2 && \ - log_must zfs destroy $TESTPOOL/$TESTFS2 + destroy_dataset $TESTPOOL/$TESTFS2 [[ -d $TESTDIR2 ]] && \ log_must rm -rf $TESTDIR2 diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_008_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_008_neg.ksh index 209497d9c454..e85a0f3cbf68 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_008_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_008_neg.ksh @@ -53,14 +53,10 @@ verify_runnable "both" function cleanup { for ds in $vol $fs1; do - if datasetexists $ds; then - log_must zfs destroy -f $ds - fi + datasetexists $ds && destroy_dataset $ds -f done - if snapexists $snap; then - log_must zfs destroy $snap - fi + snapexists $snap && destroy_dataset $snap if [[ -e /tmp/$file ]]; then rm -f /tmp/$file diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_009_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_009_pos.ksh index 3575875c2767..814d603db5e0 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_009_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_009_pos.ksh @@ -55,9 +55,7 @@ function cleanup for fs in $TESTPOOL/$TESTFS $TESTPOOL ; do typeset snap=$fs@$TESTSNAP - if snapexists $snap; then - log_must zfs destroy $snap - fi + snapexists $snap && destroy_dataset $snap done if ! poolexists $TESTPOOL && is_global_zone; then diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_unload_keys.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_unload_keys.ksh index d6d0a7e9a1b6..c92287ad75e4 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_unload_keys.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_unload_keys.ksh @@ -46,11 +46,11 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS2 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS2 + destroy_dataset $TESTPOOL/$TESTFS2 -r datasetexists $TESTPOOL/$TESTFS2/newroot && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS2/newroot + destroy_dataset $TESTPOOL/$TESTFS2/newroot -r datasetexists $TESTPOOL/$TESTFS2/child && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS2/child + destroy_dataset $TESTPOOL/$TESTFS2/child -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_001_pos.ksh index ca625bd2278a..ac16fe97b928 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_001_pos.ksh @@ -62,17 +62,14 @@ function cleanup [[ -d $TESTDIR2 ]] && \ log_must rm -rf $TESTDIR2 - if datasetexists "$TESTPOOL/$TESTCLONE"; then - log_must zfs destroy -f $TESTPOOL/$TESTCLONE - fi + datasetexists "$TESTPOOL/$TESTCLONE" && \ + destroy_dataset $TESTPOOL/$TESTCLONE -f - if snapexists "$TESTPOOL/$TESTFS2@snapshot"; then - log_must zfs destroy -f $TESTPOOL/$TESTFS2@snapshot - fi + snapexists "$TESTPOOL/$TESTFS2@snapshot" && \ + destroy_dataset $TESTPOOL/$TESTFS2@snapshot -f - if datasetexists "$TESTPOOL/$TESTFS2"; then - log_must zfs destroy -f $TESTPOOL/$TESTFS2 - fi + datasetexists "$TESTPOOL/$TESTFS2" && \ + destroy_dataset $TESTPOOL/$TESTFS2 -f } # diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh index 6a9c72311c74..1ded1b42c7ec 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh @@ -65,17 +65,14 @@ function cleanup [[ -d $TESTDIR2 ]] && \ log_must rm -rf $TESTDIR2 - if datasetexists "$TESTPOOL/$TESTCLONE"; then - log_must zfs destroy -f $TESTPOOL/$TESTCLONE - fi + datasetexists "$TESTPOOL/$TESTCLONE" && \ + destroy_dataset $TESTPOOL/$TESTCLONE -f - if snapexists "$TESTPOOL/$TESTFS2@snapshot"; then - log_must zfs destroy -f $TESTPOOL/$TESTFS2@snapshot - fi + snapexists "$TESTPOOL/$TESTFS2@snapshot" && \ + destroy_dataset $TESTPOOL/$TESTFS2@snapshot -f - if datasetexists "$TESTPOOL/$TESTFS2"; then - log_must zfs destroy -f $TESTPOOL/$TESTFS2 - fi + datasetexists "$TESTPOOL/$TESTFS2" && \ + destroy_dataset $TESTPOOL/$TESTFS2 -f } # diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_003_pos.ksh index 66a7e80eb783..6e66deda9bee 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_003_pos.ksh @@ -49,9 +49,8 @@ verify_runnable "global" function cleanup { - if snapexists $TESTPOOL/$TESTFS@snapshot; then - log_must zfs destroy $TESTPOOL/$TESTFS@snapshot - fi + snapexists $TESTPOOL/$TESTFS@snapshot && \ + destroy_dataset $TESTPOOL/$TESTFS@snapshot log_must zfs set sharenfs=off $TESTPOOL/$TESTFS } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_007_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_007_pos.ksh index a5b29a89618a..36817a092099 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_007_pos.ksh @@ -42,9 +42,8 @@ verify_runnable "global" function cleanup { - if datasetexists "$TESTPOOL/$TESTFS/shared1"; then - log_must zfs destroy -f $TESTPOOL/$TESTFS/shared1 - fi + datasetexists "$TESTPOOL/$TESTFS/shared1" && \ + destroy_dataset $TESTPOOL/$TESTFS/shared1 -f } log_assert "Verify 'zfs destroy' will unshare the dataset" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh index d3ed4a736cc9..ab76461638b9 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh @@ -50,9 +50,7 @@ verify_runnable "both" function cleanup { - if datasetexists $rootfs ; then - log_must zfs destroy -Rf $rootfs - fi + datasetexists $rootfs && destroy_dataset $rootfs -Rf log_must zfs create $rootfs for file in $output $oldoutput ; do @@ -116,9 +114,7 @@ if (( i != COUNT - OLDCOUNT )); then fi for fs in $old_datasets ; do - if datasetexists $fs ; then - log_must zfs destroy -Rf $fs - fi + datasetexists $fs && destroy_dataset $fs -Rf done log_must eval 'zfs upgrade > $output 2>&1' diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_003_pos.ksh index 6df47b450d00..57f74ca28513 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_003_pos.ksh @@ -47,9 +47,7 @@ verify_runnable "both" function cleanup { - if datasetexists $rootfs ; then - log_must zfs destroy -Rf $rootfs - fi + datasetexists $rootfs && destroy_dataset $rootfs -Rf log_must zfs create $rootfs } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_004_pos.ksh index e3ff4f4b9073..0b8fef5cd043 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_004_pos.ksh @@ -47,9 +47,7 @@ verify_runnable "both" function cleanup { - if datasetexists $rootfs ; then - log_must zfs destroy -Rf $rootfs - fi + datasetexists $rootfs && destroy_dataset $rootfs -Rf log_must zfs create $rootfs } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_005_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_005_pos.ksh index 1a929918bf10..5fcdc6e26852 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_005_pos.ksh @@ -47,9 +47,7 @@ verify_runnable "both" function cleanup { - if datasetexists $rootfs ; then - log_must zfs destroy -Rf $rootfs - fi + datasetexists $rootfs && destroy_dataset $rootfs -Rf log_must zfs create $rootfs } diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy_001_pos.ksh index 3323f1db0caf..c25b6c9230a7 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy_001_pos.ksh @@ -48,8 +48,7 @@ verify_runnable "global" function cleanup { poolexists $TESTPOOL2 && destroy_pool $TESTPOOL2 - datasetexists $TESTPOOL1/$TESTVOL && \ - log_must zfs destroy -f $TESTPOOL1/$TESTVOL + datasetexists $TESTPOOL1/$TESTVOL && destroy_dataset $TESTPOOL1/$TESTVOL -f typeset pool for pool in $TESTPOOL1 $TESTPOOL; do diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy_002_pos.ksh index 794a6c37c37a..a634f10f1114 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy_002_pos.ksh @@ -59,7 +59,7 @@ function cleanup typeset -i i=0 while (( $i < ${#datasets[*]} )); do datasetexists ${datasets[i]} && \ - log_must zfs destroy ${datasets[i]} + destroy_dataset ${datasets[i]} (( i = i + 1 )) done diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_history/zpool_history_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_history/zpool_history_001_neg.ksh index a2b73182bf4c..b5cd8d529ed0 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_history/zpool_history_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_history/zpool_history_001_neg.ksh @@ -51,8 +51,8 @@ set -A neg_opt "$TESTPOOL/$TESTCTR" "$TESTPOOL/$TESTVOL" "-t $TESTPOOL" \ function cleanup { - datasetexists $clone && log_must zfs destroy $clone - datasetexists $snap && log_must zfs destroy $snap + datasetexists $clone && destroy_dataset $clone + datasetexists $snap && destroy_dataset $snap } log_assert "Verify 'zpool history' can deal with non-existent pools and " \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/cleanup.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/cleanup.ksh index d5717ee1561e..bee0e11a4ff4 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/cleanup.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/cleanup.ksh @@ -37,8 +37,7 @@ verify_runnable "global" log_must set_tunable32 SCAN_SUSPEND_PROGRESS 0 for pool in "$TESTPOOL" "$TESTPOOL1"; do - datasetexists $pool/$TESTFS && \ - log_must zfs destroy -Rf $pool/$TESTFS + datasetexists $pool/$TESTFS && destroy_dataset $pool/$TESTFS -Rf destroy_pool "$pool" done diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_012_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_012_pos.ksh index a568948e37c4..ec387b225665 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_012_pos.ksh @@ -84,9 +84,9 @@ function cleanup destroy_pool $TESTPOOL1 - if datasetexists $TESTPOOL/$TESTFS; then - log_must zfs destroy -Rf $TESTPOOL/$TESTFS - fi + datasetexists $TESTPOOL/$TESTFS && \ + destroy_dataset $TESTPOOL/$TESTFS -Rf + log_must zfs create $TESTPOOL/$TESTFS log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_encrypted_unloaded.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_encrypted_unloaded.ksh index a8c15424db27..b1f7c6264b01 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_encrypted_unloaded.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub_encrypted_unloaded.ksh @@ -39,7 +39,7 @@ verify_runnable "global" function cleanup { datasetexists $TESTPOOL/$TESTFS2 && \ - log_must zfs destroy $TESTPOOL/$TESTFS2 + destroy_dataset $TESTPOOL/$TESTFS2 } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/features/async_destroy/async_destroy_001_pos.ksh b/tests/zfs-tests/tests/functional/features/async_destroy/async_destroy_001_pos.ksh index 23fb16d6ed5a..ad0e49f8fb40 100755 --- a/tests/zfs-tests/tests/functional/features/async_destroy/async_destroy_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/features/async_destroy/async_destroy_001_pos.ksh @@ -48,7 +48,7 @@ verify_runnable "both" function cleanup { - datasetexists $TEST_FS && log_must zfs destroy $TEST_FS + datasetexists $TEST_FS && destroy_dataset $TEST_FS log_must set_tunable64 ASYNC_BLOCK_MAX_BLOCKS 100000 } diff --git a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh index d3530292e81a..cb1e940a7d73 100755 --- a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh @@ -47,7 +47,7 @@ verify_runnable "both" function cleanup { - datasetexists $TEST_FS && log_must zfs destroy $TEST_FS + datasetexists $TEST_FS && destroy_dataset $TEST_FS } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_002_pos.ksh b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_002_pos.ksh index c2b32ad66217..9a00ceeb3cef 100755 --- a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_002_pos.ksh @@ -48,7 +48,7 @@ verify_runnable "both" function cleanup { - datasetexists $TEST_FS && log_must zfs destroy $TEST_FS + datasetexists $TEST_FS && destroy_dataset $TEST_FS } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_004_neg.ksh b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_004_neg.ksh index 3fa1cabe063a..2cc587b47879 100755 --- a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_004_neg.ksh +++ b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_004_neg.ksh @@ -44,9 +44,7 @@ TEST_STREAM=$TESTDIR/ldnsnap function cleanup { - if datasetexists $TEST_FS ; then - log_must zfs destroy -r $TEST_FS - fi + datasetexists $TEST_FS && destroy_dataset $TEST_FS -r if datasetexists $LGCYPOOL ; then log_must zpool destroy -f $LGCYPOOL diff --git a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_005_pos.ksh b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_005_pos.ksh index a2d92673b180..2be98942634f 100755 --- a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_005_pos.ksh @@ -40,13 +40,8 @@ TEST_FILEINCR=bar function cleanup { - if datasetexists $TEST_SEND_FS ; then - log_must zfs destroy -r $TEST_SEND_FS - fi - - if datasetexists $TEST_RECV_FS ; then - log_must zfs destroy -r $TEST_RECV_FS - fi + datasetexists $TEST_SEND_FS && destroy_dataset $TEST_SEND_FS -r + datasetexists $TEST_RECV_FS && destroy_dataset $TEST_RECV_FS -r rm -f $TEST_STREAM rm -f $TEST_STREAMINCR diff --git a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_006_pos.ksh b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_006_pos.ksh index 38b4ac52e5d6..3727bd5c11d2 100755 --- a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_006_pos.ksh @@ -49,7 +49,7 @@ verify_runnable "both" function cleanup { - datasetexists $TEST_FS && log_must zfs destroy $TEST_FS + datasetexists $TEST_FS && destroy_dataset $TEST_FS } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_009_pos.ksh b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_009_pos.ksh index fa746c52e5c5..1e42202069eb 100755 --- a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_009_pos.ksh +++ b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_009_pos.ksh @@ -39,7 +39,7 @@ verify_runnable "both" function cleanup { - datasetexists $TEST_FS && log_must zfs destroy $TEST_FS + datasetexists $TEST_FS && destroy_dataset $TEST_FS } log_onexit cleanup @@ -64,7 +64,7 @@ done log_must wait -log_must zpool export $TESTPOOL +log_must_busy zpool export $TESTPOOL log_must zpool import $TESTPOOL log_must ls -lR "/$TEST_FS/" >/dev/null 2>&1 log_must zdb -d $TESTPOOL diff --git a/tests/zfs-tests/tests/functional/history/history_002_pos.ksh b/tests/zfs-tests/tests/functional/history/history_002_pos.ksh index a53bcaf4ec64..b431cdc5f144 100755 --- a/tests/zfs-tests/tests/functional/history/history_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/history/history_002_pos.ksh @@ -49,7 +49,7 @@ function cleanup [[ -f $tmpfile ]] && rm -f $tmpfile [[ -f $tmpfile2 ]] && rm -f $tmpfile2 for dataset in $fs $newfs $fsclone $vol $newvol $volclone; do - datasetexists $dataset && zfs destroy -Rf $dataset + datasetexists $dataset && destroy_dataset $dataset -Rf done rm -rf /history.$$ } diff --git a/tests/zfs-tests/tests/functional/history/history_006_neg.ksh b/tests/zfs-tests/tests/functional/history/history_006_neg.ksh index e97adc4e3ce0..19b7114faf5b 100755 --- a/tests/zfs-tests/tests/functional/history/history_006_neg.ksh +++ b/tests/zfs-tests/tests/functional/history/history_006_neg.ksh @@ -47,9 +47,7 @@ verify_runnable "global" function cleanup { - if datasetexists $fs ; then - log_must zfs destroy -rf $fs - fi + datasetexists $fs && destroy_dataset $fs -rf log_must zfs create $fs } diff --git a/tests/zfs-tests/tests/functional/history/history_007_pos.ksh b/tests/zfs-tests/tests/functional/history/history_007_pos.ksh index 0504e1765c63..591d5b85e885 100755 --- a/tests/zfs-tests/tests/functional/history/history_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/history/history_007_pos.ksh @@ -62,7 +62,7 @@ migratedpoolname=$MIGRATEDPOOLNAME typeset -i RET=1 typeset -i linenum=0 -[[ ! -d $import_dir ]] && log_must mkdir $import_dir +[[ ! -d $import_dir ]] && log_must mkdir -p $import_dir # We test the migrations on both uniform platform and cross platform for arch in "i386" "sparc"; do diff --git a/tests/zfs-tests/tests/functional/history/history_008_pos.ksh b/tests/zfs-tests/tests/functional/history/history_008_pos.ksh index 996c7658c32c..8e174dcb7ebf 100755 --- a/tests/zfs-tests/tests/functional/history/history_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/history/history_008_pos.ksh @@ -47,9 +47,7 @@ verify_runnable "global" function cleanup { - if datasetexists $root_testfs; then - log_must zfs destroy -rf $root_testfs - fi + datasetexists $root_testfs && destroy_dataset $root_testfs -rf log_must zfs create $root_testfs } diff --git a/tests/zfs-tests/tests/functional/history/history_010_pos.ksh b/tests/zfs-tests/tests/functional/history/history_010_pos.ksh index 31fe8ec54d0e..2c32b1b6cefa 100755 --- a/tests/zfs-tests/tests/functional/history/history_010_pos.ksh +++ b/tests/zfs-tests/tests/functional/history/history_010_pos.ksh @@ -47,7 +47,7 @@ function cleanup { del_user $HIST_USER del_group $HIST_GROUP - datasetexists $root_testfs && log_must zfs destroy -rf $root_testfs + datasetexists $root_testfs && destroy_dataset $root_testfs -rf } log_assert "Verify internal long history information are correct." diff --git a/tests/zfs-tests/tests/functional/history/history_common.kshlib b/tests/zfs-tests/tests/functional/history/history_common.kshlib index 8ac34b2de909..ff3260f3c0f2 100644 --- a/tests/zfs-tests/tests/functional/history/history_common.kshlib +++ b/tests/zfs-tests/tests/functional/history/history_common.kshlib @@ -72,9 +72,9 @@ function run_and_verify # Run the command as the specified user, and find the new history. zpool history $flags $pool > $OLD_HISTORY 2>/dev/null if [[ $user == "root" ]]; then - log_must eval "$fullcmd" + log_must_busy eval "$fullcmd" else - log_must user_run $user "$fullcmd" + log_must_busy user_run $user "$fullcmd" fi zpool history $flags $pool > $TMP_HISTORY 2>/dev/null diff $OLD_HISTORY $TMP_HISTORY | grep "^> " | sed 's/^> //g' \ diff --git a/tests/zfs-tests/tests/functional/largest_pool/largest_pool_001_pos.ksh b/tests/zfs-tests/tests/functional/largest_pool/largest_pool_001_pos.ksh index a8934159b244..6b51598d7cca 100755 --- a/tests/zfs-tests/tests/functional/largest_pool/largest_pool_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/largest_pool/largest_pool_001_pos.ksh @@ -91,13 +91,13 @@ function cleanup if ismounted $TESTPOOL/$TESTFS ; then log_must zfs unmount $TESTPOOL/$TESTFS fi - log_must zfs destroy $TESTPOOL/$TESTFS + destroy_dataset $TESTPOOL/$TESTFS fi destroy_pool $TESTPOOL datasetexists $TESTPOOL2/$TESTVOL && \ - log_must zfs destroy $TESTPOOL2/$TESTVOL + destroy_dataset $TESTPOOL2/$TESTVOL destroy_pool $TESTPOOL2 @@ -154,7 +154,7 @@ for volsize in $VOLSIZES; do log_note "Destroy zfs, volume & zpool" log_must zfs destroy $TESTPOOL/$TESTFS destroy_pool $TESTPOOL - log_must zfs destroy $TESTPOOL2/$TESTVOL + log_must_busy zfs destroy $TESTPOOL2/$TESTVOL destroy_pool $TESTPOOL2 done diff --git a/tests/zfs-tests/tests/functional/mmap/Makefile.am b/tests/zfs-tests/tests/functional/mmap/Makefile.am index 2adc398b8c09..b26791ee7ce0 100644 --- a/tests/zfs-tests/tests/functional/mmap/Makefile.am +++ b/tests/zfs-tests/tests/functional/mmap/Makefile.am @@ -4,7 +4,8 @@ dist_pkgdata_SCRIPTS = \ cleanup.ksh \ mmap_read_001_pos.ksh \ mmap_write_001_pos.ksh \ - mmap_libaio_001_pos.ksh + mmap_libaio_001_pos.ksh \ + mmap_seek_001_pos.ksh dist_pkgdata_DATA = \ mmap.cfg diff --git a/tests/zfs-tests/tests/functional/mmap/mmap_seek_001_pos.ksh b/tests/zfs-tests/tests/functional/mmap/mmap_seek_001_pos.ksh new file mode 100755 index 000000000000..6188549ad8d2 --- /dev/null +++ b/tests/zfs-tests/tests/functional/mmap/mmap_seek_001_pos.ksh @@ -0,0 +1,67 @@ +#!/bin/ksh -p +# +# 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) 2021 by Lawrence Livermore National Security, LLC. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/mmap/mmap.cfg + +# +# DESCRIPTION: +# lseek() data/holes for an mmap()'d file. +# +# STRATEGY: +# 1. Enable compression and hole reporting for dirty files. +# 2. Call mmap_seek binary test case for various record sizes. +# + +verify_runnable "global" + +function cleanup +{ + log_must zfs set compression=off $TESTPOOL/$TESTFS + log_must zfs set recordsize=128k $TESTPOOL/$TESTFS + log_must rm -f $TESTDIR/test-mmap-file + log_must set_tunable64 DMU_OFFSET_NEXT_SYNC $dmu_offset_next_sync +} + +log_assert "lseek() data/holes for an mmap()'d file." + +log_onexit cleanup + +# Enable hole reporting for dirty files. +typeset dmu_offset_next_sync=$(get_tunable DMU_OFFSET_NEXT_SYNC) +log_must set_tunable64 DMU_OFFSET_NEXT_SYNC 1 + +# Compression must be enabled to convert zero'd blocks to holes. +# This behavior is checked by the mmap_seek test. +log_must zfs set compression=on $TESTPOOL/$TESTFS + +for bs in 4096 8192 16384 32768 65536 131072; do + log_must zfs set recordsize=$bs $TESTPOOL/$TESTFS + log_must mmap_seek $TESTDIR/test-mmap-file $((1024*1024)) $bs + log_must rm $TESTDIR/test-mmap-file +done + +log_pass "lseek() data/holes for an mmap()'d file succeeded." diff --git a/tests/zfs-tests/tests/functional/nopwrite/nopwrite_copies.ksh b/tests/zfs-tests/tests/functional/nopwrite/nopwrite_copies.ksh index 3971820966f1..2a61f605b21d 100755 --- a/tests/zfs-tests/tests/functional/nopwrite/nopwrite_copies.ksh +++ b/tests/zfs-tests/tests/functional/nopwrite/nopwrite_copies.ksh @@ -34,7 +34,7 @@ log_onexit cleanup function cleanup { - datasetexists $origin && log_must zfs destroy -R $origin + datasetexists $origin && destroy_dataset $origin -R log_must zfs create -o mountpoint=$TESTDIR $origin } diff --git a/tests/zfs-tests/tests/functional/nopwrite/nopwrite_mtime.ksh b/tests/zfs-tests/tests/functional/nopwrite/nopwrite_mtime.ksh index 039b661e2fb9..0422bbaca1c8 100755 --- a/tests/zfs-tests/tests/functional/nopwrite/nopwrite_mtime.ksh +++ b/tests/zfs-tests/tests/functional/nopwrite/nopwrite_mtime.ksh @@ -34,7 +34,7 @@ log_onexit cleanup function cleanup { - datasetexists $origin && log_must zfs destroy -R $origin + datasetexists $origin && destroy_dataset $origin -R log_must zfs create -o mountpoint=$TESTDIR $origin } diff --git a/tests/zfs-tests/tests/functional/nopwrite/nopwrite_negative.ksh b/tests/zfs-tests/tests/functional/nopwrite/nopwrite_negative.ksh index 8b0b9b549920..617c34602beb 100755 --- a/tests/zfs-tests/tests/functional/nopwrite/nopwrite_negative.ksh +++ b/tests/zfs-tests/tests/functional/nopwrite/nopwrite_negative.ksh @@ -36,7 +36,7 @@ log_onexit cleanup function cleanup { - datasetexists $origin && log_must zfs destroy -R $origin + datasetexists $origin && destroy_dataset $origin -R log_must zfs create -o mountpoint=$TESTDIR $origin } diff --git a/tests/zfs-tests/tests/functional/nopwrite/nopwrite_promoted_clone.ksh b/tests/zfs-tests/tests/functional/nopwrite/nopwrite_promoted_clone.ksh index f9e6e83b7a8d..057c59a3801c 100755 --- a/tests/zfs-tests/tests/functional/nopwrite/nopwrite_promoted_clone.ksh +++ b/tests/zfs-tests/tests/functional/nopwrite/nopwrite_promoted_clone.ksh @@ -36,7 +36,7 @@ log_onexit cleanup function cleanup { - datasetexists $origin && log_must zfs destroy -R $TESTPOOL/clone + datasetexists $origin && destroy_dataset $TESTPOOL/clone -R log_must zfs create -o mountpoint=$TESTDIR $origin } diff --git a/tests/zfs-tests/tests/functional/nopwrite/nopwrite_recsize.ksh b/tests/zfs-tests/tests/functional/nopwrite/nopwrite_recsize.ksh index 205b3357d8d0..38e7ec1ff219 100755 --- a/tests/zfs-tests/tests/functional/nopwrite/nopwrite_recsize.ksh +++ b/tests/zfs-tests/tests/functional/nopwrite/nopwrite_recsize.ksh @@ -34,7 +34,7 @@ log_onexit cleanup function cleanup { - datasetexists $origin && log_must zfs destroy -R $origin + datasetexists $origin && destroy_dataset $origin -R log_must zfs create -o mountpoint=$TESTDIR $origin } diff --git a/tests/zfs-tests/tests/functional/nopwrite/nopwrite_sync.ksh b/tests/zfs-tests/tests/functional/nopwrite/nopwrite_sync.ksh index bd38883d7578..e0721cac198c 100755 --- a/tests/zfs-tests/tests/functional/nopwrite/nopwrite_sync.ksh +++ b/tests/zfs-tests/tests/functional/nopwrite/nopwrite_sync.ksh @@ -34,7 +34,7 @@ log_onexit cleanup function cleanup { - datasetexists $origin && log_must zfs destroy -R $origin + datasetexists $origin && destroy_dataset $origin -R log_must zfs create -o mountpoint=$TESTDIR $origin } diff --git a/tests/zfs-tests/tests/functional/nopwrite/nopwrite_varying_compression.ksh b/tests/zfs-tests/tests/functional/nopwrite/nopwrite_varying_compression.ksh index d256876a9c45..190bdbd6c6db 100755 --- a/tests/zfs-tests/tests/functional/nopwrite/nopwrite_varying_compression.ksh +++ b/tests/zfs-tests/tests/functional/nopwrite/nopwrite_varying_compression.ksh @@ -41,7 +41,7 @@ log_onexit cleanup function cleanup { - datasetexists $origin && log_must zfs destroy -R $origin + datasetexists $origin && destroy_dataset $origin -R log_must zfs create -o mountpoint=$TESTDIR $origin } diff --git a/tests/zfs-tests/tests/functional/nopwrite/nopwrite_volume.ksh b/tests/zfs-tests/tests/functional/nopwrite/nopwrite_volume.ksh index a118b982240c..1efe0b772868 100755 --- a/tests/zfs-tests/tests/functional/nopwrite/nopwrite_volume.ksh +++ b/tests/zfs-tests/tests/functional/nopwrite/nopwrite_volume.ksh @@ -37,7 +37,7 @@ log_onexit cleanup function cleanup { - datasetexists $origin && log_must zfs destroy -R $origin + datasetexists $origin && destroy_dataset $origin -R # No need to recreate the volume as no other tests expect it. } diff --git a/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh b/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh index 88911aac6e8e..dfc1f1ee0497 100755 --- a/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh +++ b/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh @@ -42,7 +42,7 @@ function cleanup { - datasetexists $FS && log_must zfs destroy -r $FS + datasetexists $FS && destroy_dataset $FS -r } function count_snap_cmds diff --git a/tests/zfs-tests/tests/functional/procfs/procfs_list_concurrent_readers.ksh b/tests/zfs-tests/tests/functional/procfs/procfs_list_concurrent_readers.ksh index 6ca7fd7d6f42..1af1c2c07089 100755 --- a/tests/zfs-tests/tests/functional/procfs/procfs_list_concurrent_readers.ksh +++ b/tests/zfs-tests/tests/functional/procfs/procfs_list_concurrent_readers.ksh @@ -43,7 +43,7 @@ function cleanup { [[ -z $msgs1 ]] || log_must rm $msgs1 [[ -z $msgs2 ]] || log_must rm $msgs2 - datasetexists $FS && log_must zfs destroy -r $FS + datasetexists $FS && destroy_dataset $FS -r } typeset -r ZFS_DBGMSG=/proc/spl/kstat/zfs/dbgmsg diff --git a/tests/zfs-tests/tests/functional/projectquota/projectquota_004_neg.ksh b/tests/zfs-tests/tests/functional/projectquota/projectquota_004_neg.ksh index a975d2a19f0c..7ca81c3fbc81 100755 --- a/tests/zfs-tests/tests/functional/projectquota/projectquota_004_neg.ksh +++ b/tests/zfs-tests/tests/functional/projectquota/projectquota_004_neg.ksh @@ -43,9 +43,7 @@ function cleanup { - if datasetexists $snap_fs; then - log_must zfs destroy $snap_fs - fi + datasetexists $snap_fs && destroy_dataset $snap_fs log_must cleanup_projectquota } diff --git a/tests/zfs-tests/tests/functional/projectquota/projectquota_005_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/projectquota_005_pos.ksh index b52f302f7892..0736648f1ed6 100755 --- a/tests/zfs-tests/tests/functional/projectquota/projectquota_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/projectquota/projectquota_005_pos.ksh @@ -43,9 +43,7 @@ function cleanup { - if datasetexists $snap_fs; then - log_must zfs destroy $snap_fs - fi + datasetexists $snap_fs && destroy_dataset $snap_fs log_must cleanup_projectquota } diff --git a/tests/zfs-tests/tests/functional/projectquota/projectquota_008_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/projectquota_008_pos.ksh index 365b5627e801..b045b2c5fce3 100755 --- a/tests/zfs-tests/tests/functional/projectquota/projectquota_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/projectquota/projectquota_008_pos.ksh @@ -48,9 +48,7 @@ function cleanup { - if datasetexists $snap_fs; then - log_must zfs destroy $snap_fs - fi + datasetexists $snap_fs && destroy_dataset $snap_fs log_must cleanup_projectquota } diff --git a/tests/zfs-tests/tests/functional/projectquota/projectquota_009_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/projectquota_009_pos.ksh index a867b538c120..da44e731a92d 100755 --- a/tests/zfs-tests/tests/functional/projectquota/projectquota_009_pos.ksh +++ b/tests/zfs-tests/tests/functional/projectquota/projectquota_009_pos.ksh @@ -49,9 +49,7 @@ function cleanup { for ds in $TESTPOOL/fs $TESTPOOL/fs-rename $TESTPOOL/fs-clone; do - if datasetexists $ds; then - log_must zfs destroy -rRf $ds - fi + datasetexists $ds && destroy_dataset $ds -rRf done } diff --git a/tests/zfs-tests/tests/functional/projectquota/projectspace_001_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/projectspace_001_pos.ksh index a84ff9f89a0d..b7707ea522c4 100755 --- a/tests/zfs-tests/tests/functional/projectquota/projectspace_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/projectquota/projectspace_001_pos.ksh @@ -45,9 +45,7 @@ function cleanup { - if datasetexists $snap_fs; then - log_must zfs destroy $snap_fs - fi + datasetexists $snap_fs && destroy_dataset $snap_fs log_must cleanup_projectquota } diff --git a/tests/zfs-tests/tests/functional/projectquota/projectspace_002_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/projectspace_002_pos.ksh index 216855e94dc9..10edae771e99 100755 --- a/tests/zfs-tests/tests/functional/projectquota/projectspace_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/projectquota/projectspace_002_pos.ksh @@ -44,9 +44,7 @@ function cleanup { - if datasetexists $snapfs; then - log_must zfs destroy $snapfs - fi + datasetexists $snapfs && destroy_dataset $snapfs log_must cleanup_projectquota } diff --git a/tests/zfs-tests/tests/functional/projectquota/projectspace_003_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/projectspace_003_pos.ksh index 629b3b3e57e2..8db5d0d89970 100755 --- a/tests/zfs-tests/tests/functional/projectquota/projectspace_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/projectquota/projectspace_003_pos.ksh @@ -45,9 +45,7 @@ function cleanup { - if datasetexists $snapfs; then - log_must zfs destroy $snapfs - fi + datasetexists $snapfs && destroy_dataset $snapfs log_must cleanup_projectquota } diff --git a/tests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh index ec299e0e7f93..fc4a93f04463 100755 --- a/tests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh @@ -44,9 +44,7 @@ function cleanup { - if datasetexists $snap_fs; then - log_must zfs destroy $snap_fs - fi + datasetexists $snap_fs && destroy_dataset $snap_fs log_must cleanup_projectquota } diff --git a/tests/zfs-tests/tests/functional/quota/quota_005_pos.ksh b/tests/zfs-tests/tests/functional/quota/quota_005_pos.ksh index ed28cc1f0c9b..e87139a58f69 100755 --- a/tests/zfs-tests/tests/functional/quota/quota_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/quota/quota_005_pos.ksh @@ -48,8 +48,7 @@ verify_runnable "both" function cleanup { - datasetexists $fs_child && \ - log_must zfs destroy $fs_child + datasetexists $fs_child && destroy_dataset $fs_child log_must zfs set quota=$quota_val $fs } diff --git a/tests/zfs-tests/tests/functional/refreserv/refreserv_002_pos.ksh b/tests/zfs-tests/tests/functional/refreserv/refreserv_002_pos.ksh index d4c0a4faebdc..a8f58631f7b6 100755 --- a/tests/zfs-tests/tests/functional/refreserv/refreserv_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/refreserv/refreserv_002_pos.ksh @@ -50,11 +50,9 @@ function cleanup if is_global_zone ; then log_must zfs set refreservation=none $TESTPOOL - if datasetexists $TESTPOOL@snap ; then - log_must zfs destroy -f $TESTPOOL@snap - fi + datasetexists $TESTPOOL@snap && destroy_dataset $TESTPOOL@snap -f fi - log_must zfs destroy -rf $TESTPOOL/$TESTFS + destroy_dataset $TESTPOOL/$TESTFS -rf log_must zfs create $TESTPOOL/$TESTFS log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS } diff --git a/tests/zfs-tests/tests/functional/reservation/reservation_002_pos.ksh b/tests/zfs-tests/tests/functional/reservation/reservation_002_pos.ksh index 8ae3593613f0..e0fed6389c35 100755 --- a/tests/zfs-tests/tests/functional/reservation/reservation_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/reservation/reservation_002_pos.ksh @@ -54,7 +54,7 @@ verify_runnable "both" function cleanup { for obj in $OBJ_LIST; do - datasetexists $obj && log_must_busy zfs destroy -f $obj + datasetexists $obj && destroy_dataset $obj -f done log_must zero_reservation $TESTPOOL/$TESTFS diff --git a/tests/zfs-tests/tests/functional/reservation/reservation_003_pos.ksh b/tests/zfs-tests/tests/functional/reservation/reservation_003_pos.ksh index 48adabe72ffd..ee303b53bedd 100755 --- a/tests/zfs-tests/tests/functional/reservation/reservation_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/reservation/reservation_003_pos.ksh @@ -59,7 +59,7 @@ function cleanup log_must zero_reservation $TESTPOOL/$TESTFS for obj in $OBJ_LIST; do - datasetexists $obj && log_must zfs destroy -f $obj + datasetexists $obj && destroy_dataset $obj -f done } diff --git a/tests/zfs-tests/tests/functional/reservation/reservation_004_pos.ksh b/tests/zfs-tests/tests/functional/reservation/reservation_004_pos.ksh index f8342ff29488..eb606a762432 100755 --- a/tests/zfs-tests/tests/functional/reservation/reservation_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/reservation/reservation_004_pos.ksh @@ -56,7 +56,7 @@ verify_runnable "both" function cleanup { for obj in $OBJ_LIST; do - datasetexists $obj && log_must_busy zfs destroy -f $obj + datasetexists $obj && destroy_dataset $obj -f done } diff --git a/tests/zfs-tests/tests/functional/reservation/reservation_005_pos.ksh b/tests/zfs-tests/tests/functional/reservation/reservation_005_pos.ksh index 4047fab0d7f9..535d652dafab 100755 --- a/tests/zfs-tests/tests/functional/reservation/reservation_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/reservation/reservation_005_pos.ksh @@ -59,7 +59,7 @@ log_assert "Verify space released when reservation on a dataset is set "\ function cleanup { for obj in $OBJ_LIST; do - datasetexists $obj && log_must zfs destroy -f $obj + datasetexists $obj && destroy_dataset $obj -f done } diff --git a/tests/zfs-tests/tests/functional/reservation/reservation_007_pos.ksh b/tests/zfs-tests/tests/functional/reservation/reservation_007_pos.ksh index 48d6b40ad05a..a1fffd362427 100755 --- a/tests/zfs-tests/tests/functional/reservation/reservation_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/reservation/reservation_007_pos.ksh @@ -56,10 +56,10 @@ log_assert "Verify reservations on data sets doesn't affect other data sets " \ function cleanup { datasetexists $TESTPOOL/$TESTFS2 && \ - log_must zfs destroy -f $TESTPOOL/$TESTFS2 + destroy_dataset $TESTPOOL/$TESTFS2 -f datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -f $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -f } log_onexit cleanup @@ -100,7 +100,7 @@ function create_resv_destroy { # args1 dataset1 args2 dataset2 # available totals should revert back to the values they # had after creating the first dataset. # - log_must zfs destroy -f $dataset2 + log_must_busy zfs destroy -f $dataset2 avail_dest_dset2=`get_prop available $TESTPOOL` used_dest_dset2=`get_prop used $TESTPOOL` @@ -112,7 +112,7 @@ function create_resv_destroy { # args1 dataset1 args2 dataset2 # After destroying the first dataset the space used and # space available totals should revert back to the values # they had when the pool was first created. - log_must zfs destroy -f $dataset1 + log_must_busy zfs destroy -f $dataset1 avail_dest_dset1=`get_prop available $TESTPOOL` used_dest_dset1=`get_prop used $TESTPOOL` diff --git a/tests/zfs-tests/tests/functional/reservation/reservation_008_pos.ksh b/tests/zfs-tests/tests/functional/reservation/reservation_008_pos.ksh index a0cd039b1839..cfc30f47421b 100755 --- a/tests/zfs-tests/tests/functional/reservation/reservation_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/reservation/reservation_008_pos.ksh @@ -57,7 +57,7 @@ function cleanup typeset -i loop=0 while (($loop < $RESV_NUM_FS)); do datasetexists $TESTPOOL/${TESTFS}$loop && \ - log_must zfs destroy -f $TESTPOOL/${TESTFS}$loop + destroy_dataset $TESTPOOL/${TESTFS}$loop -f [[ -d ${TESTDIR}$loop ]] && log_must rm -r ${TESTDIR}$loop diff --git a/tests/zfs-tests/tests/functional/reservation/reservation_009_pos.ksh b/tests/zfs-tests/tests/functional/reservation/reservation_009_pos.ksh index 171577def5ef..a639abf8960a 100755 --- a/tests/zfs-tests/tests/functional/reservation/reservation_009_pos.ksh +++ b/tests/zfs-tests/tests/functional/reservation/reservation_009_pos.ksh @@ -58,7 +58,9 @@ function cleanup { log_must rm -rf $TESTDIR/$TESTFILE1 log_must rm -rf $TESTDIR/$TESTFILE2 - log_must zfs destroy -f $TESTPOOL/$TESTFS1 + + datasetexists $TESTPOOL/$TESTFS1 && \ + destroy_dataset $TESTPOOL/$TESTFS1 -f } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/reservation/reservation_010_pos.ksh b/tests/zfs-tests/tests/functional/reservation/reservation_010_pos.ksh index 2ca279a4a437..f3a64a0bea8c 100755 --- a/tests/zfs-tests/tests/functional/reservation/reservation_010_pos.ksh +++ b/tests/zfs-tests/tests/functional/reservation/reservation_010_pos.ksh @@ -57,7 +57,7 @@ log_assert "Destroying top level filesystem with reservation allows more " \ function cleanup { datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 [[ -e $TESTDIR/$TESTFILE1 ]] && log_must rm -rf $TESTDIR/$TESTFILE1 [[ -e $TESTDIR/$TESTFILE2 ]] && log_must rm -rf $TESTDIR/$TESTFILE2 diff --git a/tests/zfs-tests/tests/functional/reservation/reservation_013_pos.ksh b/tests/zfs-tests/tests/functional/reservation/reservation_013_pos.ksh index 6a80bb575dc4..bf0955223490 100755 --- a/tests/zfs-tests/tests/functional/reservation/reservation_013_pos.ksh +++ b/tests/zfs-tests/tests/functional/reservation/reservation_013_pos.ksh @@ -58,7 +58,7 @@ log_assert "Reservation properties preserved across exports and imports" function cleanup { for obj in $OBJ_LIST; do - datasetexists $obj && log_must zfs destroy -f $obj + datasetexists $obj && destroy_dataset $obj -f done log_must zero_reservation $TESTPOOL/$TESTFS @@ -91,7 +91,7 @@ log_must zfs set reservation=$resv_set $TESTPOOL/$TESTFS1 log_must zfs set reservation=$resv_set $TESTPOOL/$TESTFS1/$TESTFS2 log_must zfs set reservation=$resv_set $TESTPOOL/$TESTVOL2 -log_must zpool export $TESTPOOL +log_must_busy zpool export $TESTPOOL log_must zpool import $TESTPOOL for obj in $TESTPOOL/$TESTFS $OBJ_LIST; do diff --git a/tests/zfs-tests/tests/functional/reservation/reservation_014_pos.ksh b/tests/zfs-tests/tests/functional/reservation/reservation_014_pos.ksh index e8bd91d00e68..3b7f384da365 100755 --- a/tests/zfs-tests/tests/functional/reservation/reservation_014_pos.ksh +++ b/tests/zfs-tests/tests/functional/reservation/reservation_014_pos.ksh @@ -54,7 +54,7 @@ function cleanup # # Note we don't destroy $TESTFS as it's used by other tests for obj in $OBJ_LIST ; do - datasetexists $obj && log_must zfs destroy -f $obj + datasetexists $obj && destroy_dataset $obj -f done log_must zero_reservation $TESTPOOL/$TESTFS diff --git a/tests/zfs-tests/tests/functional/reservation/reservation_015_pos.ksh b/tests/zfs-tests/tests/functional/reservation/reservation_015_pos.ksh index d67f8c7ec2f6..7067a7810590 100755 --- a/tests/zfs-tests/tests/functional/reservation/reservation_015_pos.ksh +++ b/tests/zfs-tests/tests/functional/reservation/reservation_015_pos.ksh @@ -57,7 +57,7 @@ log_assert "Setting volume reservation to 'none' allows more data to be " \ function cleanup { datasetexists $TESTPOOL/$TESTVOL && \ - log_must zfs destroy $TESTPOOL/$TESTVOL + destroy_dataset $TESTPOOL/$TESTVOL [[ -e $TESTDIR/$TESTFILE1 ]] && log_must rm -rf $TESTDIR/$TESTFILE1 [[ -e $TESTDIR/$TESTFILE2 ]] && log_must rm -rf $TESTDIR/$TESTFILE2 @@ -76,6 +76,7 @@ space_avail=$(largest_volsize_from_pool $TESTPOOL) resv_size_set=$(floor_volsize $resv_size_set) log_must zfs create -V $resv_size_set $TESTPOOL/$TESTVOL +block_device_wait $TESTPOOL/$TESTVOL space_avail_still=`get_prop available $TESTPOOL` diff --git a/tests/zfs-tests/tests/functional/reservation/reservation_016_pos.ksh b/tests/zfs-tests/tests/functional/reservation/reservation_016_pos.ksh index cbb1db658b33..82bbcde4a3b7 100755 --- a/tests/zfs-tests/tests/functional/reservation/reservation_016_pos.ksh +++ b/tests/zfs-tests/tests/functional/reservation/reservation_016_pos.ksh @@ -56,7 +56,7 @@ log_assert "Destroying a regular volume with reservation allows more data to" \ function cleanup { datasetexists $TESTPOOL/$TESTVOL && \ - log_must zfs destroy $TESTPOOL/$TESTVOL + destroy_dataset $TESTPOOL/$TESTVOL [[ -e $TESTDIR/$TESTFILE1 ]] && log_must rm -rf $TESTDIR/$TESTFILE1 [[ -e $TESTDIR/$TESTFILE2 ]] && log_must rm -rf $TESTDIR/$TESTFILE2 @@ -76,6 +76,7 @@ vol_set_size=$(floor_volsize $vol_set_size) # Creating a regular volume implicitly sets its reservation # property to the same value. log_must zfs create -V $vol_set_size $TESTPOOL/$TESTVOL +block_device_wait $TESTPOOL/$TESTVOL space_avail_still=$(get_prop available $TESTPOOL) fill_size=$((space_avail_still + $RESV_TOLERANCE)) diff --git a/tests/zfs-tests/tests/functional/reservation/reservation_018_pos.ksh b/tests/zfs-tests/tests/functional/reservation/reservation_018_pos.ksh index 0969a6877316..1f92c8898562 100755 --- a/tests/zfs-tests/tests/functional/reservation/reservation_018_pos.ksh +++ b/tests/zfs-tests/tests/functional/reservation/reservation_018_pos.ksh @@ -47,7 +47,7 @@ verify_runnable "both" function cleanup { - datasetexists $fs_child && log_must zfs destroy $fs_child + datasetexists $fs_child && destroy_dataset $fs_child log_must zfs set reservation=$reserv_val $fs } diff --git a/tests/zfs-tests/tests/functional/rsend/send-c_lz4_disabled.ksh b/tests/zfs-tests/tests/functional/rsend/send-c_lz4_disabled.ksh index 666e11f702f8..bc706bab25b8 100755 --- a/tests/zfs-tests/tests/functional/rsend/send-c_lz4_disabled.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send-c_lz4_disabled.ksh @@ -52,8 +52,8 @@ for compress in off gzip; do poolexists $POOL3 && destroy_pool $POOL3 log_must zpool create $pool_opt $POOL3 $DISK3 - datasetexists $send_ds && log_must_busy zfs destroy -r $send_ds - datasetexists $recv_ds && log_must_busy zfs destroy -r $recv_ds + datasetexists $send_ds && destroy_dataset $send_ds -r + datasetexists $recv_ds && destroy_dataset $recv_ds -r log_must zfs create -o compress=$compress $send_ds typeset dir=$(get_prop mountpoint $send_ds) diff --git a/tests/zfs-tests/tests/functional/rsend/send-c_recv_lz4_disabled.ksh b/tests/zfs-tests/tests/functional/rsend/send-c_recv_lz4_disabled.ksh index 20a8c5481224..15873ed12f1e 100755 --- a/tests/zfs-tests/tests/functional/rsend/send-c_recv_lz4_disabled.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send-c_recv_lz4_disabled.ksh @@ -50,8 +50,8 @@ datasetexists $POOL3 && log_must zpool destroy $POOL3 log_must zpool create -d $POOL3 $DISK3 for compress in "${compress_prop_vals[@]}"; do - datasetexists $send_ds && log_must_busy zfs destroy -r $send_ds - datasetexists $recv_ds && log_must_busy zfs destroy -r $recv_ds + datasetexists $send_ds && destroy_dataset $send_ds -r + datasetexists $recv_ds && destroy_dataset $recv_ds -r log_must zfs create -o compress=$compress $send_ds typeset dir=$(get_prop mountpoint $send_ds) diff --git a/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh b/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh index b3edb1c45788..056fc2cc2584 100755 --- a/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh @@ -61,8 +61,8 @@ log_onexit cleanup_pool $POOL2 write_compressible $BACKDIR ${megs}m for compress in "${compress_prop_vals[@]}"; do - datasetexists $send_ds && log_must_busy zfs destroy -r $send_ds - datasetexists $send_vol && log_must_busy zfs destroy -r $send_vol + datasetexists $send_ds && destroy_dataset $send_ds -r + datasetexists $send_vol && destroy_dataset $send_vol -r log_must zfs create -o compress=$compress $send_ds log_must zfs create -V 1g -o compress=$compress $send_vol block_device_wait $send_voldev diff --git a/tests/zfs-tests/tests/functional/rsend/send-cpL_varied_recsize.ksh b/tests/zfs-tests/tests/functional/rsend/send-cpL_varied_recsize.ksh index e2810651a60e..25ad8e0820d1 100755 --- a/tests/zfs-tests/tests/functional/rsend/send-cpL_varied_recsize.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send-cpL_varied_recsize.ksh @@ -55,8 +55,8 @@ verify_runnable "both" function cleanup { - datasetexists $TESTPOOL/128k && log_must_busy zfs destroy $TESTPOOL/128k - datasetexists $TESTPOOL/1m && log_must_busy zfs destroy $TESTPOOL/1m + datasetexists $TESTPOOL/128k && destroy_dataset $TESTPOOL/128k + datasetexists $TESTPOOL/1m && destroy_dataset $TESTPOOL/1m cleanup_pool $POOL2 destroy_pool $POOL3 } diff --git a/tests/zfs-tests/tests/functional/rsend/send_encrypted_files.ksh b/tests/zfs-tests/tests/functional/rsend/send_encrypted_files.ksh index 1fd21cbf7eff..370f5382ebae 100755 --- a/tests/zfs-tests/tests/functional/rsend/send_encrypted_files.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send_encrypted_files.ksh @@ -46,9 +46,9 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS2 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS2 + destroy_dataset $TESTPOOL/$TESTFS2 -r datasetexists $TESTPOOL/recv && \ - log_must zfs destroy -r $TESTPOOL/recv + destroy_dataset $TESTPOOL/recv -r [[ -f $keyfile ]] && log_must rm $keyfile [[ -f $sendfile ]] && log_must rm $sendfile } diff --git a/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh b/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh index c710b3d911e7..5760bf9b902a 100755 --- a/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh @@ -42,9 +42,9 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS2 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS2 + destroy_dataset $TESTPOOL/$TESTFS2 -r datasetexists $TESTPOOL/recv && \ - log_must zfs destroy -r $TESTPOOL/recv + destroy_dataset $TESTPOOL/recv -r [[ -f $keyfile ]] && log_must rm $keyfile [[ -f $sendfile ]] && log_must rm $sendfile } diff --git a/tests/zfs-tests/tests/functional/rsend/send_mixed_raw.ksh b/tests/zfs-tests/tests/functional/rsend/send_mixed_raw.ksh index eea535af1100..59b08ccf723b 100755 --- a/tests/zfs-tests/tests/functional/rsend/send_mixed_raw.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send_mixed_raw.ksh @@ -49,11 +49,11 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS3 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS3 + destroy_dataset $TESTPOOL/$TESTFS3 -r datasetexists $TESTPOOL/$TESTFS2 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS2 + destroy_dataset $TESTPOOL/$TESTFS2 -r datasetexists $TESTPOOL/$TESTFS1 && \ - log_must zfs destroy -r $TESTPOOL/$TESTFS1 + destroy_dataset $TESTPOOL/$TESTFS1 -r } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/rsend/send_realloc_dnode_size.ksh b/tests/zfs-tests/tests/functional/rsend/send_realloc_dnode_size.ksh index 394fe95bb9b7..551ed15db254 100755 --- a/tests/zfs-tests/tests/functional/rsend/send_realloc_dnode_size.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send_realloc_dnode_size.ksh @@ -49,13 +49,8 @@ function cleanup rm -f $BACKDIR/fs-dn-2k rm -f $BACKDIR/fs-attr - if datasetexists $POOL/fs ; then - log_must zfs destroy -rR $POOL/fs - fi - - if datasetexists $POOL/newfs ; then - log_must zfs destroy -rR $POOL/newfs - fi + datasetexists $POOL/fs && destroy_dataset $POOL/fs -rR + datasetexists $POOL/newfs && destroy_dataset $POOL/newfs -rR } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh index 3abdff8c3bc7..1c8a3b2a6c20 100755 --- a/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh @@ -96,8 +96,8 @@ function cleanup_all (( i = i + 4 )) done - datasetexists $TESTPOOL1/$TESTFS && \ - log_must zfs destroy -f $TESTPOOL1/$TESTFS + datasetexists $TESTPOOL1/$TESTFS && \ + destroy_dataset $TESTPOOL1/$TESTFS -f destroy_pool $TESTPOOL1 diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh index 44e5943bcd2f..7e0a7f4ce1d8 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh @@ -51,8 +51,7 @@ verify_runnable "both" function cleanup { - snapexists $SNAPPOOL && \ - log_must zfs destroy -r $SNAPPOOL + snapexists $SNAPPOOL && destroy_dataset $SNAPPOOL -r [[ -e $TESTDIR ]] && \ log_must rm -rf $TESTDIR/* > /dev/null 2>&1 diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_012_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_012_pos.ksh index c5717e452686..92db9b53a7b8 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_012_pos.ksh @@ -55,15 +55,14 @@ function cleanup { if datasetexists $clone1; then log_must zfs promote $ctrfs - log_must zfs destroy $clone1 + destroy_dataset $clone1 fi - snapexists $snapctr && \ - log_must zfs destroy -r $snapctr + snapexists $snapctr && destroy_dataset $snapctr -r if snapexists $clone@$TESTSNAP1; then log_must zfs promote $ctrfs - log_must zfs destroy -rR $ctrfs@$TESTSNAP1 + destroy_dataset $ctrfs@$TESTSNAP1 -rR fi } diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh index 31aedb224515..e02f6eb30042 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh @@ -48,11 +48,8 @@ verify_runnable "both" function cleanup { - datasetexists $ctrfs && \ - zfs destroy -r $ctrfs - - snapexists $snappool && \ - log_must zfs destroy -r $snappool + datasetexists $ctrfs && destroy_dataset $ctrfs -r + snapexists $snappool && destroy_dataset $snappool -r [[ -e $TESTDIR ]] && \ log_must rm -rf $TESTDIR/* > /dev/null 2>&1 diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_014_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_014_pos.ksh index 3579fbebb4b8..d48d404b6d14 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_014_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_014_pos.ksh @@ -51,8 +51,7 @@ function cleanup [[ -e $TESTDIR1 ]] && \ log_must rm -rf $TESTDIR1/* > /dev/null 2>&1 - snapexists $SNAPCTR && \ - log_must zfs destroy $SNAPCTR + snapexists $SNAPCTR && destroy_dataset $SNAPCTR datasetexists $TESTPOOL/$TESTCTR/$TESTFS1 && \ log_must zfs set quota=none $TESTPOOL/$TESTCTR/$TESTFS1 diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_015_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_015_pos.ksh index 1091bcb13ea7..5a4d2ccaf62e 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_015_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_015_pos.ksh @@ -54,7 +54,7 @@ function cleanup typeset -i i=0 while ((i < snap_cnt)); do typeset snap=$fs@snap.$i - datasetexists $snap && log_must zfs destroy -f $snap + datasetexists $snap && destroy_dataset $snap -f ((i += 1)) done diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_016_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_016_pos.ksh index b460c2b0c5dc..b66023cc85e6 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_016_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_016_pos.ksh @@ -47,19 +47,12 @@ verify_runnable "both" function cleanup { - datasetexists $SNAPFS && \ - log_must zfs destroy -Rf $SNAPFS - datasetexists $TESTPOOL/$TESTFS@snap_a && \ - log_must zfs destroy -Rf $TESTPOOL/$TESTFS@snap_a - datasetexists $TESTPOOL/$TESTFS@snap_b && \ - log_must zfs destroy -Rf $TESTPOOL/$TESTFS@snap_b - datasetexists $TESTPOOL/$TESTCLONE@snap_a && \ - log_must zfs destroy -Rf $TESTPOOL/$TESTCLONE@snap_a - - datasetexists $TESTPOOL/$TESTCLONE && \ - log_must zfs destroy $TESTPOOL/$TESTCLONE - datasetexists $TESTPOOL/$TESTFS && \ - log_must zfs destroy $TESTPOOL/$TESTFS + datasetexists $SNAPFS && destroy_dataset $SNAPFS -Rf + datasetexists $TESTPOOL/$TESTFS@snap_a && destroy_dataset $TESTPOOL/$TESTFS@snap_a -Rf + datasetexists $TESTPOOL/$TESTFS@snap_b && destroy_dataset $TESTPOOL/$TESTFS@snap_b -Rf + datasetexists $TESTPOOL/$TESTCLONE@snap_a && destroy_dataset $TESTPOOL/$TESTCLONE@snap_a -Rf + datasetexists $TESTPOOL/$TESTCLONE && destroy_dataset $TESTPOOL/$TESTCLONE + datasetexists $TESTPOOL/$TESTFS && destroy_dataset $TESTPOOL/$TESTFS log_must zfs create $TESTPOOL/$TESTFS log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_017_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_017_pos.ksh index a21f8750d697..6e5b8973cf4f 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_017_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_017_pos.ksh @@ -56,9 +56,8 @@ function cleanup { cd $SAVED_DIR - if datasetexists $TESTPOOL/$TESTFS ; then - log_must zfs destroy -Rf $TESTPOOL/$TESTFS - fi + datasetexists $TESTPOOL/$TESTFS && \ + destroy_dataset $TESTPOOL/$TESTFS -Rf log_must zfs create $TESTPOOL/$TESTFS log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS diff --git a/tests/zfs-tests/tests/functional/snapused/snapused_001_pos.ksh b/tests/zfs-tests/tests/functional/snapused/snapused_001_pos.ksh index 302ba40c38a3..c1277f2b4e2f 100755 --- a/tests/zfs-tests/tests/functional/snapused/snapused_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapused/snapused_001_pos.ksh @@ -51,7 +51,7 @@ verify_runnable "both" function cleanup { - log_must zfs destroy -rR $USEDTEST + datasetexists $USEDTEST && destroy_dataset $USEDTEST -rR } log_assert "Verify used is correct." diff --git a/tests/zfs-tests/tests/functional/snapused/snapused_002_pos.ksh b/tests/zfs-tests/tests/functional/snapused/snapused_002_pos.ksh index 96d2df6c6522..a41ca1d70f19 100755 --- a/tests/zfs-tests/tests/functional/snapused/snapused_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapused/snapused_002_pos.ksh @@ -49,7 +49,7 @@ verify_runnable "both" function cleanup { - log_must zfs destroy -rR $USEDTEST + datasetexists $USEDTEST && destroy_dataset $USEDTEST -rR } log_assert "Verify usedbychildren is correct." diff --git a/tests/zfs-tests/tests/functional/snapused/snapused_003_pos.ksh b/tests/zfs-tests/tests/functional/snapused/snapused_003_pos.ksh index d4726ff40cbd..ff54cbaa1aec 100755 --- a/tests/zfs-tests/tests/functional/snapused/snapused_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapused/snapused_003_pos.ksh @@ -48,7 +48,7 @@ verify_runnable "both" function cleanup { - log_must zfs destroy -rR $USEDTEST + datasetexists $USEDTEST && destroy_dataset $USEDTEST -rR } log_assert "Verify usedbydataset is correct." diff --git a/tests/zfs-tests/tests/functional/snapused/snapused_004_pos.ksh b/tests/zfs-tests/tests/functional/snapused/snapused_004_pos.ksh index 64ca3e2b3508..8fb8b6be5b47 100755 --- a/tests/zfs-tests/tests/functional/snapused/snapused_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapused/snapused_004_pos.ksh @@ -53,7 +53,7 @@ verify_runnable "both" function cleanup { - log_must zfs destroy -rR $USEDTEST + datasetexists $USEDTEST && destroy_dataset $USEDTEST -rR } log_assert "Verify usedbyrefreservation is correct." diff --git a/tests/zfs-tests/tests/functional/snapused/snapused_005_pos.ksh b/tests/zfs-tests/tests/functional/snapused/snapused_005_pos.ksh index ac5224caf6dc..9d21e1d23d87 100755 --- a/tests/zfs-tests/tests/functional/snapused/snapused_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapused/snapused_005_pos.ksh @@ -47,7 +47,7 @@ verify_runnable "both" function cleanup { - log_must zfs destroy -rR $USEDTEST + datasetexists $USEDTEST && destroy_dataset $USEDTEST -rR } log_assert "Verify usedbysnapshots is correct." diff --git a/tests/zfs-tests/tests/functional/userquota/groupspace_001_pos.ksh b/tests/zfs-tests/tests/functional/userquota/groupspace_001_pos.ksh index fb7a19057acf..762f561b834f 100755 --- a/tests/zfs-tests/tests/functional/userquota/groupspace_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/userquota/groupspace_001_pos.ksh @@ -45,9 +45,7 @@ function cleanup { - if datasetexists $snap_fs; then - log_must zfs destroy $snap_fs - fi + datasetexists $snap_fs && destroy_dataset $snap_fs log_must cleanup_quota } diff --git a/tests/zfs-tests/tests/functional/userquota/groupspace_002_pos.ksh b/tests/zfs-tests/tests/functional/userquota/groupspace_002_pos.ksh index 20d0f7319df1..27feafa2b6a2 100755 --- a/tests/zfs-tests/tests/functional/userquota/groupspace_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/userquota/groupspace_002_pos.ksh @@ -45,9 +45,7 @@ function cleanup { - if datasetexists $snapfs; then - log_must zfs destroy $snapfs - fi + datasetexists $snapfs && destroy_dataset $snapfs log_must cleanup_quota } diff --git a/tests/zfs-tests/tests/functional/userquota/groupspace_003_pos.ksh b/tests/zfs-tests/tests/functional/userquota/groupspace_003_pos.ksh index 56b7af031550..37fd389377ec 100755 --- a/tests/zfs-tests/tests/functional/userquota/groupspace_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/userquota/groupspace_003_pos.ksh @@ -46,9 +46,7 @@ function cleanup { - if datasetexists $snapfs; then - log_must zfs destroy $snapfs - fi + datasetexists $snapfs && destroy_dataset $snapfs log_must rm -f ${QFILE}_* log_must cleanup_quota diff --git a/tests/zfs-tests/tests/functional/userquota/userquota_005_neg.ksh b/tests/zfs-tests/tests/functional/userquota/userquota_005_neg.ksh index 5684b05b7e4b..b8e956164f73 100755 --- a/tests/zfs-tests/tests/functional/userquota/userquota_005_neg.ksh +++ b/tests/zfs-tests/tests/functional/userquota/userquota_005_neg.ksh @@ -44,9 +44,7 @@ function cleanup { - if datasetexists $snap_fs; then - log_must zfs destroy $snap_fs - fi + datasetexists $snap_fs && destroy_dataset $snap_fs log_must cleanup_quota } diff --git a/tests/zfs-tests/tests/functional/userquota/userquota_006_pos.ksh b/tests/zfs-tests/tests/functional/userquota/userquota_006_pos.ksh index 7848a924bde8..1c2509c83705 100755 --- a/tests/zfs-tests/tests/functional/userquota/userquota_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/userquota/userquota_006_pos.ksh @@ -44,9 +44,7 @@ function cleanup { - if datasetexists $snap_fs; then - log_must zfs destroy $snap_fs - fi + datasetexists $snap_fs && destroy_dataset $snap_fs log_must cleanup_quota } diff --git a/tests/zfs-tests/tests/functional/userquota/userquota_009_pos.ksh b/tests/zfs-tests/tests/functional/userquota/userquota_009_pos.ksh index 1c0fdde3fa46..b6f2727806c4 100755 --- a/tests/zfs-tests/tests/functional/userquota/userquota_009_pos.ksh +++ b/tests/zfs-tests/tests/functional/userquota/userquota_009_pos.ksh @@ -49,9 +49,7 @@ function cleanup { - if datasetexists $snap_fs; then - log_must zfs destroy $snap_fs - fi + datasetexists $snap_fs && destroy_dataset $snap_fs log_must cleanup_quota } diff --git a/tests/zfs-tests/tests/functional/userquota/userquota_011_pos.ksh b/tests/zfs-tests/tests/functional/userquota/userquota_011_pos.ksh index 93020ae8ded6..8917b3be2865 100755 --- a/tests/zfs-tests/tests/functional/userquota/userquota_011_pos.ksh +++ b/tests/zfs-tests/tests/functional/userquota/userquota_011_pos.ksh @@ -49,9 +49,7 @@ function cleanup { for ds in $TESTPOOL/fs $TESTPOOL/fs-rename $TESTPOOL/fs-clone; do - if datasetexists $ds; then - log_must zfs destroy -rRf $ds - fi + datasetexists $ds && destroy_dataset $ds -rRf done } diff --git a/tests/zfs-tests/tests/functional/userquota/userquota_012_neg.ksh b/tests/zfs-tests/tests/functional/userquota/userquota_012_neg.ksh index b553f91d40da..12e023134d81 100755 --- a/tests/zfs-tests/tests/functional/userquota/userquota_012_neg.ksh +++ b/tests/zfs-tests/tests/functional/userquota/userquota_012_neg.ksh @@ -46,9 +46,7 @@ function cleanup { cleanup_quota - if datasetexists $snap_fs; then - log_must zfs destroy $snap_fs - fi + datasetexists $snap_fs && destroy_dataset $snap_fs } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/userquota/userspace_001_pos.ksh b/tests/zfs-tests/tests/functional/userquota/userspace_001_pos.ksh index ef05338af41d..9b8919344582 100755 --- a/tests/zfs-tests/tests/functional/userquota/userspace_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/userquota/userspace_001_pos.ksh @@ -45,9 +45,7 @@ function cleanup { - if datasetexists $snap_fs; then - log_must zfs destroy $snap_fs - fi + datasetexists $snap_fs && destroy_dataset $snap_fs log_must cleanup_quota } diff --git a/tests/zfs-tests/tests/functional/userquota/userspace_002_pos.ksh b/tests/zfs-tests/tests/functional/userquota/userspace_002_pos.ksh index 8161cc152037..94593ed21ae1 100755 --- a/tests/zfs-tests/tests/functional/userquota/userspace_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/userquota/userspace_002_pos.ksh @@ -45,9 +45,7 @@ function cleanup { - if datasetexists $snapfs; then - log_must zfs destroy $snapfs - fi + datasetexists $snapfs && destroy_dataset $snapfs log_must cleanup_quota } diff --git a/tests/zfs-tests/tests/functional/userquota/userspace_003_pos.ksh b/tests/zfs-tests/tests/functional/userquota/userspace_003_pos.ksh index 96c3b1930c40..70ef78e7ddbb 100755 --- a/tests/zfs-tests/tests/functional/userquota/userspace_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/userquota/userspace_003_pos.ksh @@ -47,9 +47,7 @@ function cleanup { - if datasetexists $snapfs; then - log_must zfs destroy $snapfs - fi + datasetexists $snapfs && destroy_dataset $snapfs log_must rm -f ${QFILE}_* log_must cleanup_quota diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_cli/zvol_cli_002_pos.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_cli/zvol_cli_002_pos.ksh index e5b69239f566..7b8749751b05 100755 --- a/tests/zfs-tests/tests/functional/zvol/zvol_cli/zvol_cli_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/zvol/zvol_cli/zvol_cli_002_pos.ksh @@ -45,7 +45,7 @@ verify_runnable "global" function cleanup { datasetexists $TESTPOOL/$LONGVOLNAME && \ - zfs destroy $TESTPOOL/$LONGVOLNAME + destroy_dataset $TESTPOOL/$LONGVOLNAME } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_common.shlib b/tests/zfs-tests/tests/functional/zvol/zvol_common.shlib index 342700228764..4f74c9b92613 100644 --- a/tests/zfs-tests/tests/functional/zvol/zvol_common.shlib +++ b/tests/zfs-tests/tests/functional/zvol/zvol_common.shlib @@ -63,9 +63,8 @@ function default_zvol_setup # disk_device volume_size block_size # function default_zvol_cleanup { - if datasetexists $TESTPOOL/$TESTVOL ; then - log_must zfs destroy $TESTPOOL/$TESTVOL - fi + datasetexists $TESTPOOL/$TESTVOL && \ + destroy_dataset $TESTPOOL/$TESTVOL destroy_pool $TESTPOOL } diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_002_pos.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_002_pos.ksh index 72446ee986fe..2ecb00da92e1 100755 --- a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_002_pos.ksh @@ -49,7 +49,7 @@ volsize=$(zfs get -H -o value volsize $TESTPOOL/$TESTVOL) function cleanup { snapexists $TESTPOOL/$TESTVOL@snap && \ - zfs destroy $TESTPOOL/$TESTVOL@snap + destroy_dataset $TESTPOOL/$TESTVOL@snap ismounted $TESTDIR $NEWFS_DEFAULT_FS (( $? == 0 )) && log_must umount $TESTDIR diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_004_pos.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_004_pos.ksh index 697887368377..e0dce0c2c34a 100755 --- a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_004_pos.ksh @@ -65,9 +65,8 @@ function cleanup typeset snap for snap in snap0 snap1 ; do - if datasetexists $TESTPOOL/$TESTVOL@$snap ; then - log_must zfs destroy $TESTPOOL/$TESTVOL@$snap - fi + datasetexists $TESTPOOL/$TESTVOL@$snap && \ + destroy_dataset $TESTPOOL/$TESTVOL@$snap done zfs set volsize=$volsize $TESTPOOL/$TESTVOL } diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_snapdev.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_snapdev.ksh index 8d95bfa39374..1fd87aefdffc 100755 --- a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_snapdev.ksh +++ b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_snapdev.ksh @@ -43,8 +43,8 @@ verify_runnable "global" function cleanup { - datasetexists $VOLFS && log_must zfs destroy -r $VOLFS - datasetexists $ZVOL && log_must zfs destroy -r $ZVOL + datasetexists $VOLFS && destroy_dataset $VOLFS -r + datasetexists $ZVOL && destroy_dataset $ZVOL -r log_must zfs inherit snapdev $TESTPOOL block_device_wait udev_cleanup diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_004_pos.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_004_pos.ksh index cf1e6359bdb6..83bf465b633a 100755 --- a/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_004_pos.ksh @@ -47,7 +47,7 @@ verify_runnable "global" function cleanup { is_swap_inuse $swapname && log_must swap_cleanup $swapname - datasetexists $vol && log_must zfs destroy $vol + datasetexists $vol && destroy_dataset $vol } log_assert "For an added swap zvol, (2G <= volsize <= 16G)"