diff --git a/cddl/usr.bin/ztest/Makefile b/cddl/usr.bin/ztest/Makefile index 0945bb962c63..91118d13775d 100644 --- a/cddl/usr.bin/ztest/Makefile +++ b/cddl/usr.bin/ztest/Makefile @@ -4,7 +4,7 @@ ZFSTOP= ${SRCTOP}/sys/contrib/openzfs -.PATH: ${ZFSTOP}/cmd/ztest +.PATH: ${ZFSTOP}/cmd .PATH: ${ZFSTOP}/man/man1 PROG= ztest @@ -16,7 +16,6 @@ CFLAGS+= \ -I${ZFSTOP}/include \ -I${ZFSTOP}/lib/libspl/include \ -I${ZFSTOP}/lib/libspl/include/os/freebsd \ - -I${SRCTOP}/sys \ -I${SRCTOP}/cddl/compat/opensolaris/include \ -I${ZFSTOP}/module/icp/include \ -include ${ZFSTOP}/include/os/freebsd/spl/sys/ccompile.h \ diff --git a/cddl/usr.sbin/zhack/Makefile b/cddl/usr.sbin/zhack/Makefile index 24800c693cf3..ffac0785d18d 100644 --- a/cddl/usr.sbin/zhack/Makefile +++ b/cddl/usr.sbin/zhack/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.PATH: ${SRCTOP}/sys/contrib/openzfs/cmd/zhack +.PATH: ${SRCTOP}/sys/contrib/openzfs/cmd PROG= zhack MAN= diff --git a/sys/contrib/openzfs/.github/workflows/checkstyle.yaml b/sys/contrib/openzfs/.github/workflows/checkstyle.yaml index abc0ff11916a..8dafdcf07fed 100644 --- a/sys/contrib/openzfs/.github/workflows/checkstyle.yaml +++ b/sys/contrib/openzfs/.github/workflows/checkstyle.yaml @@ -40,11 +40,11 @@ jobs: - name: CheckABI id: CheckABI run: | - docker run -v $(pwd):/source ghcr.io/openzfs/libabigail make -j$(nproc) --no-print-directory --silent checkabi + docker run -v $PWD:/source ghcr.io/openzfs/libabigail make -j$(nproc) --no-print-directory --silent checkabi - name: StoreABI if: failure() && steps.CheckABI.outcome == 'failure' run: | - docker run -v $(pwd):/source ghcr.io/openzfs/libabigail make -j$(nproc) --no-print-directory --silent storeabi + docker run -v $PWD:/source ghcr.io/openzfs/libabigail make -j$(nproc) --no-print-directory --silent storeabi - name: Prepare artifacts if: failure() && steps.CheckABI.outcome == 'failure' run: | diff --git a/sys/contrib/openzfs/.github/workflows/zloop.yml b/sys/contrib/openzfs/.github/workflows/zloop.yml index 8eb2a1d9bb0f..d49eeae1653c 100644 --- a/sys/contrib/openzfs/.github/workflows/zloop.yml +++ b/sys/contrib/openzfs/.github/workflows/zloop.yml @@ -38,8 +38,9 @@ jobs: - name: Tests run: | sudo mkdir -p $TEST_DIR - # run for 20 minutes to have a total runner time of 30 minutes - sudo /usr/share/zfs/zloop.sh -t 1200 -l -m1 -- -T 120 -P 60 + # run for 10 minutes or at most 2 iterations for a maximum runner + # time of 20 minutes. + sudo /usr/share/zfs/zloop.sh -t 600 -I 2 -l -m1 -- -T 120 -P 60 - name: Prepare artifacts if: failure() run: | diff --git a/sys/contrib/openzfs/.gitignore b/sys/contrib/openzfs/.gitignore index 056bbb8f08c9..8d91dd9466c5 100644 --- a/sys/contrib/openzfs/.gitignore +++ b/sys/contrib/openzfs/.gitignore @@ -1,6 +1,7 @@ # -# N.B. -# This is the toplevel .gitignore file. +# This is the top-level .gitignore file: +# ignore everything except a list of allowed files. +# # This is not the place for entries that are specific to # a subdirectory. Instead add those files to the # .gitignore file in that subdirectory. @@ -10,6 +11,56 @@ # command after changing this file, to see if there are # any tracked files which get ignored after the change. +* + +!.github +!cmd +!config +!contrib +!etc +!include +!lib +!man +!module +!rpm +!scripts +!tests +!udev + +!.github/** +!cmd/** +!config/** +!contrib/** +!etc/** +!include/** +!lib/** +!man/** +!module/** +!rpm/** +!scripts/** +!tests/** +!udev/** + +!.editorconfig +!.gitignore +!.gitmodules +!AUTHORS +!autogen.sh +!CODE_OF_CONDUCT.md +!configure.ac +!copy-builtin +!COPYRIGHT +!LICENSE +!Makefile.am +!META +!NEWS +!NOTICE +!README.md +!RELEASES.md +!TEST +!zfs.release.in + + # # Normal rules # @@ -31,40 +82,7 @@ modules.order Makefile Makefile.in - -# -# Top level generated files specific to this top level dir -# -/bin -/build -/configure -/config.log -/config.status -/libtool -/zfs_config.h -/zfs_config.h.in -/zfs.release -/stamp-h1 -/aclocal.m4 -/autom4te.cache - -# -# Top level generic files -# -!.gitignore -tags -TAGS -current -cscope.* -*.rpm -*.deb -*.tar.gz *.patch *.orig -*.log *.tmp -venv - -*.so -*.so.debug -*.so.full +*.log diff --git a/sys/contrib/openzfs/Makefile.am b/sys/contrib/openzfs/Makefile.am index 098357902916..ebb385fabc06 100644 --- a/sys/contrib/openzfs/Makefile.am +++ b/sys/contrib/openzfs/Makefile.am @@ -1,33 +1,43 @@ +CLEANFILES = +EXTRA_DIST = +INSTALL_DATA_HOOKS = +ALL_LOCAL = +CLEAN_LOCAL = +CHECKS = shellcheck checkbashisms + +include $(top_srcdir)/config/Rules.am +include $(top_srcdir)/config/CppCheck.am include $(top_srcdir)/config/Shellcheck.am +include $(top_srcdir)/config/Substfiles.am ACLOCAL_AMFLAGS = -I config SUBDIRS = include if BUILD_LINUX -SUBDIRS += rpm +include $(srcdir)/%D%/rpm/Makefile.am endif if CONFIG_USER -SUBDIRS += man scripts lib tests cmd etc contrib +include $(srcdir)/%D%/cmd/Makefile.am +include $(srcdir)/%D%/contrib/Makefile.am +include $(srcdir)/%D%/etc/Makefile.am +include $(srcdir)/%D%/lib/Makefile.am +include $(srcdir)/%D%/man/Makefile.am +include $(srcdir)/%D%/scripts/Makefile.am +include $(srcdir)/%D%/tests/Makefile.am if BUILD_LINUX -SUBDIRS += udev +include $(srcdir)/%D%/udev/Makefile.am endif endif +CPPCHECKDIRS += module if CONFIG_KERNEL SUBDIRS += module extradir = $(prefix)/src/zfs-$(VERSION) extra_HEADERS = zfs.release.in zfs_config.h.in - -if BUILD_LINUX -kerneldir = $(prefix)/src/zfs-$(VERSION)/$(LINUX_VERSION) -nodist_kernel_HEADERS = zfs.release zfs_config.h module/$(LINUX_SYMBOLS) -endif endif -AUTOMAKE_OPTIONS = foreign -EXTRA_DIST = autogen.sh copy-builtin -EXTRA_DIST += config/config.awk config/rpm.am config/deb.am config/tgz.am +EXTRA_DIST += autogen.sh copy-builtin EXTRA_DIST += AUTHORS CODE_OF_CONDUCT.md COPYRIGHT LICENSE META NEWS NOTICE EXTRA_DIST += README.md RELEASES.md EXTRA_DIST += module/lua/README.zfs module/os/linux/spl/README.md @@ -51,18 +61,22 @@ EXTRA_DIST += module/zfs/THIRDPARTYLICENSE.cityhash.descrip @CODE_COVERAGE_RULES@ GITREV = include/zfs_gitrev.h - -PHONY = gitrev +CLEANFILES += $(GITREV) +PHONY += gitrev gitrev: $(AM_V_GEN)$(top_srcdir)/scripts/make_gitrev.sh $(GITREV) all: gitrev -# Double-colon rules are allowed; there are multiple independent definitions. -maintainer-clean-local:: +PHONY += install-data-hook $(INSTALL_DATA_HOOKS) +install-data-hook: $(INSTALL_DATA_HOOKS) + +PHONY += maintainer-clean-local +maintainer-clean-local: -$(RM) $(GITREV) -distclean-local:: +PHONY += distclean-local +distclean-local: -$(RM) -R autom4te*.cache build -find . \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \ -o -name .pc -o -name .hg -o -name .git \) -prune -o \ @@ -74,43 +88,27 @@ distclean-local:: -o -name '*.gcno' \) \ -type f -delete -all-local: - -[ -x ${top_builddir}/scripts/zfs-tests.sh ] && \ - ${top_builddir}/scripts/zfs-tests.sh -c +PHONY += $(CLEAN_LOCAL) +clean-local: $(CLEAN_LOCAL) + +PHONY += $(ALL_LOCAL) +all-local: $(ALL_LOCAL) dist-hook: - $(AM_V_GEN)$(top_srcdir)/scripts/make_gitrev.sh -D $(distdir) $(GITREV) - $(SED) ${ac_inplace} -e 's/Release:[[:print:]]*/Release: $(RELEASE)/' \ - $(distdir)/META + $(top_srcdir)/scripts/make_gitrev.sh -D $(distdir) $(GITREV) + $(SED) $(ac_inplace) 's/\(Release:[[:space:]]*\).*/\1$(RELEASE)/' $(distdir)/META -if BUILD_LINUX -# For compatibility, create a matching spl-x.y.z directly which contains -# symlinks to the updated header and object file locations. These -# compatibility links will be removed in the next major release. -if CONFIG_KERNEL -install-data-hook: - rm -rf $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \ - mkdir $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \ - cd $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \ - ln -s ../zfs-$(VERSION)/include/spl include && \ - ln -s ../zfs-$(VERSION)/$(LINUX_VERSION) $(LINUX_VERSION) && \ - ln -s ../zfs-$(VERSION)/zfs_config.h.in spl_config.h.in && \ - ln -s ../zfs-$(VERSION)/zfs.release.in spl.release.in && \ - cd $(DESTDIR)$(prefix)/src/zfs-$(VERSION)/$(LINUX_VERSION) && \ - ln -fs zfs_config.h spl_config.h && \ - ln -fs zfs.release spl.release -endif -endif +PHONY += codecheck $(CHECKS) +codecheck: $(CHECKS) -PHONY += codecheck -codecheck: cstyle shellcheck checkbashisms flake8 mancheck testscheck vcscheck zstdcheck +SHELLCHECKSCRIPTS += autogen.sh PHONY += checkstyle checkstyle: codecheck commitcheck PHONY += commitcheck commitcheck: - @if git rev-parse --git-dir > /dev/null 2>&1; then \ + $(AM_V_at)if git rev-parse --git-dir > /dev/null 2>&1; then \ ${top_srcdir}/scripts/commitcheck.sh; \ fi @@ -119,9 +117,9 @@ cstyle_line = -print0 | parallel -X0 ${top_srcdir}/scripts/cstyle.pl -cpP {} else cstyle_line = -exec ${top_srcdir}/scripts/cstyle.pl -cpP {} + endif -PHONY += cstyle +CHECKS += cstyle cstyle: - @find ${top_srcdir} -name build -prune \ + $(AM_V_at)find $(top_srcdir) -name build -prune \ -o -type f -name '*.[hc]' \ ! -name 'zfs_config.*' ! -name '*.mod.c' \ ! -name 'opt_global.h' ! -name '*_if*.h' \ @@ -133,68 +131,41 @@ cstyle: $(cstyle_line) filter_executable = -exec test -x '{}' \; -print - -SHELLCHECKDIRS = cmd contrib etc scripts tests -SHELLCHECKSCRIPTS = autogen.sh - -PHONY += checkabi storeabi - -checkabi: lib - $(MAKE) -C lib checkabi - -storeabi: lib - $(MAKE) -C lib storeabi - -PHONY += mancheck -mancheck: - ${top_srcdir}/scripts/mancheck.sh ${top_srcdir}/man ${top_srcdir}/tests/test-runner/man - -PHONY += testscheck +CHECKS += testscheck testscheck: - @[ $$(find ${top_srcdir}/tests/zfs-tests -type f \ - \( -name '*.ksh' -not ${filter_executable} \) -o \ - \( -name '*.kshlib' ${filter_executable} \) -o \ - \( -name '*.shlib' ${filter_executable} \) -o \ - \( -name '*.cfg' ${filter_executable} \) | \ + $(AM_V_at)[ $$(find $(top_srcdir)/tests/zfs-tests -type f \ + \( -name '*.ksh' -not $(filter_executable) \) -o \ + \( -name '*.kshlib' $(filter_executable) \) -o \ + \( -name '*.shlib' $(filter_executable) \) -o \ + \( -name '*.cfg' $(filter_executable) \) | \ tee /dev/stderr | wc -l) -eq 0 ] -PHONY += vcscheck +CHECKS += vcscheck vcscheck: - @if git rev-parse --git-dir > /dev/null 2>&1; then \ + $(AM_V_at)if git rev-parse --git-dir > /dev/null 2>&1; then \ git ls-files . --exclude-standard --others | \ awk '{c++; print} END {if(c>0) exit 1}' ; \ fi -PHONY += zstdcheck +CHECKS += zstdcheck zstdcheck: - @$(MAKE) -C module/zstd checksymbols + @$(MAKE) -C module check-zstd-symbols PHONY += lint lint: cppcheck paxcheck -CPPCHECKDIRS = cmd lib module -PHONY += cppcheck -cppcheck: $(CPPCHECKDIRS) - @if test -n "$(CPPCHECK)"; then \ - set -e ; for dir in $(CPPCHECKDIRS) ; do \ - $(MAKE) -C $$dir cppcheck ; \ - done \ - else \ - echo "skipping cppcheck because cppcheck is not installed"; \ - fi - PHONY += paxcheck paxcheck: - @if type scanelf > /dev/null 2>&1; then \ - ${top_srcdir}/scripts/paxcheck.sh ${top_builddir}; \ + $(AM_V_at)if type scanelf > /dev/null 2>&1; then \ + $(top_srcdir)/scripts/paxcheck.sh $(top_builddir); \ else \ echo "skipping paxcheck because scanelf is not installed"; \ fi -PHONY += flake8 +CHECKS += flake8 flake8: - @if type flake8 > /dev/null 2>&1; then \ - flake8 ${top_srcdir}; \ + $(AM_V_at)if type flake8 > /dev/null 2>&1; then \ + flake8 $(top_srcdir); \ else \ echo "skipping flake8 because flake8 is not installed"; \ fi diff --git a/sys/contrib/openzfs/autogen.sh b/sys/contrib/openzfs/autogen.sh index 488e913b2bf4..c817090183f1 100755 --- a/sys/contrib/openzfs/autogen.sh +++ b/sys/contrib/openzfs/autogen.sh @@ -1,4 +1,62 @@ #!/bin/sh +[ "${0%/*}" = "$0" ] || cd "${0%/*}" || exit -autoreconf -fiv || exit 1 -rm -Rf autom4te.cache +# %reldir%/%canon_reldir% (%D%/%C%) only appeared in automake 1.14, but RHEL/CentOS 7 has 1.13.4 +# This is an (overly) simplistic preprocessor that papers around this for the duration of the generation step, +# and can be removed once support for CentOS 7 is dropped +automake --version | awk '{print $NF; exit}' | ( + IFS=. read -r AM_MAJ AM_MIN _ + [ "$AM_MAJ" -gt 1 ] || [ "$AM_MIN" -ge 14 ] +) || { + process_root() { + root="$1"; shift + + grep -q '%[CD]%' "$root/Makefile.am" || return + find "$root" -name Makefile.am "$@" | while read -r dir; do + dir="${dir%/Makefile.am}" + grep -q '%[CD]%' "$dir/Makefile.am" || continue + + reldir="${dir#$root}" + reldir="${reldir#/}" + + canon_reldir="$(printf '%s' "$reldir" | tr -C 'a-zA-Z0-9@_' '_')" + + reldir_slash="$reldir/" + canon_reldir_slash="${canon_reldir}_" + [ -z "$reldir" ] && reldir_slash= + [ -z "$reldir" ] && canon_reldir_slash= + + echo "$dir/Makefile.am" >&3 + sed -i~ -e "s:%D%/:$reldir_slash:g" -e "s:%D%:$reldir:g" \ + -e "s:%C%_:$canon_reldir_slash:g" -e "s:%C%:$canon_reldir:g" "$dir/Makefile.am" + done 3>>"$substituted_files" + } + + rollback() { + while read -r f; do + mv "$f~" "$f" + done < "$substituted_files" + rm -f "$substituted_files" + } + + + echo "Automake <1.14; papering over missing %reldir%/%canon_reldir% support" >&2 + + substituted_files="$(mktemp)" + trap rollback EXIT + + roots="$(sed '/Makefile$/!d;/module/d;s:^\s*:./:;s:/Makefile::;/^\.$/d' configure.ac)" + + IFS=" +" + for root in $roots; do + root="${root#./}" + process_root "$root" + done + + set -f + # shellcheck disable=SC2086,SC2046 + process_root . $(printf '!\n-path\n%s/*\n' $roots) +} + +autoreconf -fiv && rm -rf autom4te.cache diff --git a/sys/contrib/openzfs/cmd/Makefile.am b/sys/contrib/openzfs/cmd/Makefile.am index 68f1e892d3f4..9959760b523e 100644 --- a/sys/contrib/openzfs/cmd/Makefile.am +++ b/sys/contrib/openzfs/cmd/Makefile.am @@ -1,27 +1,115 @@ -include $(top_srcdir)/config/Shellcheck.am +bin_SCRIPTS = +bin_PROGRAMS = +sbin_SCRIPTS = +sbin_PROGRAMS = +dist_bin_SCRIPTS = +zfsexec_PROGRAMS = +mounthelper_PROGRAMS = -SUBDIRS = zfs zpool zdb zhack zinject zstream ztest -SUBDIRS += fsck_zfs vdev_id raidz_test zfs_ids_to_path -SUBDIRS += zpool_influxdb -CPPCHECKDIRS = zfs zpool zdb zhack zinject zstream ztest -CPPCHECKDIRS += raidz_test zfs_ids_to_path zpool_influxdb +sbin_SCRIPTS += fsck.zfs +SHELLCHECKSCRIPTS += fsck.zfs +CLEANFILES += fsck.zfs +EXTRA_DIST += %D%/fsck.zfs.in +$(call SUBST,fsck.zfs,%D%/) -# TODO: #12084: SHELLCHECKDIRS += vdev_id -SHELLCHECKDIRS = fsck_zfs zed zpool zvol_wait -if USING_PYTHON -SUBDIRS += arcstat arc_summary dbufstat -endif +sbin_PROGRAMS += zfs_ids_to_path +CPPCHECKTARGETS += zfs_ids_to_path + +zfs_ids_to_path_SOURCES = \ + %D%/zfs_ids_to_path.c + +zfs_ids_to_path_LDADD = \ + libzfs.la + + +zhack_CPPFLAGS = $(AM_CPPFLAGS) $(FORCEDEBUG_CPPFLAGS) + +sbin_PROGRAMS += zhack +CPPCHECKTARGETS += zhack + +zhack_SOURCES = \ + %D%/zhack.c + +zhack_LDADD = \ + libzpool.la \ + libzfs_core.la \ + libnvpair.la + + +ztest_CFLAGS = $(AM_CFLAGS) $(KERNEL_CFLAGS) +# Get rid of compiler warning for unchecked truncating snprintfs on gcc 7.1.1 +ztest_CFLAGS += $(NO_FORMAT_TRUNCATION) +ztest_CPPFLAGS = $(AM_CPPFLAGS) $(FORCEDEBUG_CPPFLAGS) + +sbin_PROGRAMS += ztest +CPPCHECKTARGETS += ztest + +ztest_SOURCES = \ + %D%/ztest.c + +ztest_LDADD = \ + libzpool.la \ + libzfs_core.la \ + libnvpair.la + +ztest_LDADD += -lm +ztest_LDFLAGS = -pthread + + +include $(srcdir)/%D%/raidz_test/Makefile.am +include $(srcdir)/%D%/zdb/Makefile.am +include $(srcdir)/%D%/zfs/Makefile.am +include $(srcdir)/%D%/zinject/Makefile.am +include $(srcdir)/%D%/zpool/Makefile.am +include $(srcdir)/%D%/zpool_influxdb/Makefile.am +include $(srcdir)/%D%/zstream/Makefile.am + if BUILD_LINUX -SUBDIRS += mount_zfs zed zgenhostid zvol_id zvol_wait -CPPCHECKDIRS += mount_zfs zed zgenhostid zvol_id -SHELLCHECKDIRS += zed +mounthelper_PROGRAMS += mount.zfs +CPPCHECKTARGETS += mount.zfs + +mount_zfs_SOURCES = \ + %D%/mount_zfs.c + +mount_zfs_LDADD = \ + libzfs.la \ + libzfs_core.la \ + libnvpair.la + +mount_zfs_LDADD += $(LTLIBINTL) + +CPPCHECKTARGETS += raidz_test + + +sbin_PROGRAMS += zgenhostid +CPPCHECKTARGETS += zgenhostid + +zgenhostid_SOURCES = \ + %D%/zgenhostid.c + + +dist_bin_SCRIPTS += %D%/zvol_wait +SHELLCHECKSCRIPTS += %D%/zvol_wait + + +include $(srcdir)/%D%/zed/Makefile.am endif -PHONY = cppcheck -cppcheck: $(CPPCHECKDIRS) - set -e ; for dir in $(CPPCHECKDIRS) ; do \ - $(MAKE) -C $$dir cppcheck ; \ - done + +if USING_PYTHON +bin_SCRIPTS += arc_summary arcstat dbufstat +CLEANFILES += arc_summary arcstat dbufstat +EXTRA_DIST += %D%/arc_summary %D%/arcstat.in %D%/dbufstat.in + +$(call SUBST,arcstat,%D%/) +$(call SUBST,dbufstat,%D%/) +arc_summary: %D%/arc_summary + $(AM_V_at)cp $< $@ +endif + + +PHONY += cmd +cmd: $(bin_SCRIPTS) $(bin_PROGRAMS) $(sbin_SCRIPTS) $(sbin_PROGRAMS) $(dist_bin_SCRIPTS) $(zfsexec_PROGRAMS) $(mounthelper_PROGRAMS) diff --git a/sys/contrib/openzfs/cmd/arc_summary/arc_summary3 b/sys/contrib/openzfs/cmd/arc_summary similarity index 100% rename from sys/contrib/openzfs/cmd/arc_summary/arc_summary3 rename to sys/contrib/openzfs/cmd/arc_summary diff --git a/sys/contrib/openzfs/cmd/arc_summary/.gitignore b/sys/contrib/openzfs/cmd/arc_summary/.gitignore deleted file mode 100644 index 50ba15f034e2..000000000000 --- a/sys/contrib/openzfs/cmd/arc_summary/.gitignore +++ /dev/null @@ -1 +0,0 @@ -arc_summary diff --git a/sys/contrib/openzfs/cmd/arc_summary/Makefile.am b/sys/contrib/openzfs/cmd/arc_summary/Makefile.am deleted file mode 100644 index f419f07e0eda..000000000000 --- a/sys/contrib/openzfs/cmd/arc_summary/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -bin_SCRIPTS = arc_summary - -CLEANFILES = arc_summary -EXTRA_DIST = arc_summary3 -SCRIPT = arc_summary3 - -arc_summary: $(SCRIPT) - cp $< $@ diff --git a/sys/contrib/openzfs/cmd/arcstat/arcstat.in b/sys/contrib/openzfs/cmd/arcstat.in similarity index 100% rename from sys/contrib/openzfs/cmd/arcstat/arcstat.in rename to sys/contrib/openzfs/cmd/arcstat.in diff --git a/sys/contrib/openzfs/cmd/arcstat/.gitignore b/sys/contrib/openzfs/cmd/arcstat/.gitignore deleted file mode 100644 index 6d6cd1ab75fc..000000000000 --- a/sys/contrib/openzfs/cmd/arcstat/.gitignore +++ /dev/null @@ -1 +0,0 @@ -arcstat diff --git a/sys/contrib/openzfs/cmd/arcstat/Makefile.am b/sys/contrib/openzfs/cmd/arcstat/Makefile.am deleted file mode 100644 index d1ba989a0cd8..000000000000 --- a/sys/contrib/openzfs/cmd/arcstat/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am - -bin_SCRIPTS = arcstat - -SUBSTFILES += $(bin_SCRIPTS) diff --git a/sys/contrib/openzfs/cmd/dbufstat/dbufstat.in b/sys/contrib/openzfs/cmd/dbufstat.in similarity index 100% rename from sys/contrib/openzfs/cmd/dbufstat/dbufstat.in rename to sys/contrib/openzfs/cmd/dbufstat.in diff --git a/sys/contrib/openzfs/cmd/dbufstat/.gitignore b/sys/contrib/openzfs/cmd/dbufstat/.gitignore deleted file mode 100644 index 2c2e913cef70..000000000000 --- a/sys/contrib/openzfs/cmd/dbufstat/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dbufstat diff --git a/sys/contrib/openzfs/cmd/dbufstat/Makefile.am b/sys/contrib/openzfs/cmd/dbufstat/Makefile.am deleted file mode 100644 index e672a01a4227..000000000000 --- a/sys/contrib/openzfs/cmd/dbufstat/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am - -bin_SCRIPTS = dbufstat - -SUBSTFILES += $(bin_SCRIPTS) diff --git a/sys/contrib/openzfs/cmd/fsck_zfs/fsck.zfs.in b/sys/contrib/openzfs/cmd/fsck.zfs.in similarity index 93% rename from sys/contrib/openzfs/cmd/fsck_zfs/fsck.zfs.in rename to sys/contrib/openzfs/cmd/fsck.zfs.in index 37096902cb94..f0d4d2ec38ca 100755 --- a/sys/contrib/openzfs/cmd/fsck_zfs/fsck.zfs.in +++ b/sys/contrib/openzfs/cmd/fsck.zfs.in @@ -7,13 +7,13 @@ # see fsck.zfs(8) # -if [ "$#" = "0" ]; then +if [ $# -eq 0 ]; then echo "Usage: $0 [options] dataset…" >&2 exit 16 fi ret=0 -for dataset in "$@"; do +for dataset; do case "$dataset" in -*) continue diff --git a/sys/contrib/openzfs/cmd/fsck_zfs/.gitignore b/sys/contrib/openzfs/cmd/fsck_zfs/.gitignore deleted file mode 100644 index 0edf0309e94a..000000000000 --- a/sys/contrib/openzfs/cmd/fsck_zfs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/fsck.zfs diff --git a/sys/contrib/openzfs/cmd/fsck_zfs/Makefile.am b/sys/contrib/openzfs/cmd/fsck_zfs/Makefile.am deleted file mode 100644 index ec955c7c7ff9..000000000000 --- a/sys/contrib/openzfs/cmd/fsck_zfs/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -dist_sbin_SCRIPTS = fsck.zfs - -SUBSTFILES += $(dist_sbin_SCRIPTS) - diff --git a/sys/contrib/openzfs/cmd/mount_zfs/mount_zfs.c b/sys/contrib/openzfs/cmd/mount_zfs.c similarity index 100% rename from sys/contrib/openzfs/cmd/mount_zfs/mount_zfs.c rename to sys/contrib/openzfs/cmd/mount_zfs.c diff --git a/sys/contrib/openzfs/cmd/mount_zfs/.gitignore b/sys/contrib/openzfs/cmd/mount_zfs/.gitignore deleted file mode 100644 index cd9254bde3da..000000000000 --- a/sys/contrib/openzfs/cmd/mount_zfs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -mount.zfs diff --git a/sys/contrib/openzfs/cmd/mount_zfs/Makefile.am b/sys/contrib/openzfs/cmd/mount_zfs/Makefile.am deleted file mode 100644 index 3957602d27ad..000000000000 --- a/sys/contrib/openzfs/cmd/mount_zfs/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -# -# Ignore the prefix for the mount helper. It must be installed in /sbin/ -# because this path is hardcoded in the mount(8) for security reasons. -# However, if needed, the configure option --with-mounthelperdir= can be used -# to override the default install location. -# -sbindir=$(mounthelperdir) -sbin_PROGRAMS = mount.zfs - -mount_zfs_SOURCES = \ - mount_zfs.c - -mount_zfs_LDADD = \ - $(abs_top_builddir)/lib/libzfs/libzfs.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la - -mount_zfs_LDADD += $(LTLIBINTL) - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/cmd/raidz_test/.gitignore b/sys/contrib/openzfs/cmd/raidz_test/.gitignore deleted file mode 100644 index f8b83d9cce03..000000000000 --- a/sys/contrib/openzfs/cmd/raidz_test/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/raidz_test diff --git a/sys/contrib/openzfs/cmd/raidz_test/Makefile.am b/sys/contrib/openzfs/cmd/raidz_test/Makefile.am index 983ff25dc92a..3b8b60568323 100644 --- a/sys/contrib/openzfs/cmd/raidz_test/Makefile.am +++ b/sys/contrib/openzfs/cmd/raidz_test/Makefile.am @@ -1,22 +1,16 @@ -include $(top_srcdir)/config/Rules.am +raidz_test_CFLAGS = $(AM_CFLAGS) $(KERNEL_CFLAGS) +raidz_test_CPPFLAGS = $(AM_CPPFLAGS) $(FORCEDEBUG_CPPFLAGS) -# Includes kernel code, generate warnings for large stack frames -AM_CFLAGS += $(FRAME_LARGER_THAN) - -# Unconditionally enable ASSERTs -AM_CPPFLAGS += -DDEBUG -UNDEBUG -DZFS_DEBUG - -bin_PROGRAMS = raidz_test +bin_PROGRAMS += raidz_test +CPPCHECKTARGETS += raidz_test raidz_test_SOURCES = \ - raidz_test.h \ - raidz_test.c \ - raidz_bench.c + %D%/raidz_bench.c \ + %D%/raidz_test.c \ + %D%/raidz_test.h raidz_test_LDADD = \ - $(abs_top_builddir)/lib/libzpool/libzpool.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la + libzpool.la \ + libzfs_core.la raidz_test_LDADD += -lm - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/cmd/vdev_id/Makefile.am b/sys/contrib/openzfs/cmd/vdev_id/Makefile.am deleted file mode 100644 index 4071c6d5ed6b..000000000000 --- a/sys/contrib/openzfs/cmd/vdev_id/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -include $(top_srcdir)/config/Shellcheck.am - -dist_udev_SCRIPTS = vdev_id diff --git a/sys/contrib/openzfs/cmd/zdb/.gitignore b/sys/contrib/openzfs/cmd/zdb/.gitignore deleted file mode 100644 index f64a3fc5a160..000000000000 --- a/sys/contrib/openzfs/cmd/zdb/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zdb diff --git a/sys/contrib/openzfs/cmd/zdb/Makefile.am b/sys/contrib/openzfs/cmd/zdb/Makefile.am index c5858c298053..b80f38b3fd57 100644 --- a/sys/contrib/openzfs/cmd/zdb/Makefile.am +++ b/sys/contrib/openzfs/cmd/zdb/Makefile.am @@ -1,18 +1,14 @@ -include $(top_srcdir)/config/Rules.am +zdb_CPPFLAGS = $(AM_CPPFLAGS) $(FORCEDEBUG_CPPFLAGS) -# Unconditionally enable debugging for zdb -AM_CPPFLAGS += -DDEBUG -UNDEBUG -DZFS_DEBUG - -sbin_PROGRAMS = zdb +sbin_PROGRAMS += zdb +CPPCHECKTARGETS += zdb zdb_SOURCES = \ - zdb.c \ - zdb_il.c \ - zdb.h + %D%/zdb.c \ + %D%/zdb.h \ + %D%/zdb_il.c zdb_LDADD = \ - $(abs_top_builddir)/lib/libzpool/libzpool.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la - -include $(top_srcdir)/config/CppCheck.am + libzpool.la \ + libzfs_core.la \ + libnvpair.la diff --git a/sys/contrib/openzfs/cmd/zdb/zdb.c b/sys/contrib/openzfs/cmd/zdb/zdb.c index f18c9fd6b930..3d4d956e5698 100644 --- a/sys/contrib/openzfs/cmd/zdb/zdb.c +++ b/sys/contrib/openzfs/cmd/zdb/zdb.c @@ -3926,7 +3926,7 @@ dump_uberblock(uberblock_t *ub, const char *header, const char *footer) (void) printf("\ttxg = %llu\n", (u_longlong_t)ub->ub_txg); (void) printf("\tguid_sum = %llu\n", (u_longlong_t)ub->ub_guid_sum); (void) printf("\ttimestamp = %llu UTC = %s", - (u_longlong_t)ub->ub_timestamp, asctime(localtime(×tamp))); + (u_longlong_t)ub->ub_timestamp, ctime(×tamp)); (void) printf("\tmmp_magic = %016llx\n", (u_longlong_t)ub->ub_mmp_magic); @@ -8405,7 +8405,6 @@ int main(int argc, char **argv) { int c; - struct rlimit rl = { 1024, 1024 }; spa_t *spa = NULL; objset_t *os = NULL; int dump_all = 1; @@ -8424,9 +8423,6 @@ main(int argc, char **argv) boolean_t target_is_spa = B_TRUE, dataset_lookup = B_FALSE; nvlist_t *cfg = NULL; - (void) setrlimit(RLIMIT_NOFILE, &rl); - (void) enable_extended_FILE_stdio(-1, -1); - dprintf_setup(&argc, argv); /* diff --git a/sys/contrib/openzfs/cmd/zed/Makefile.am b/sys/contrib/openzfs/cmd/zed/Makefile.am index 7b662994d1c6..6eea1a135f56 100644 --- a/sys/contrib/openzfs/cmd/zed/Makefile.am +++ b/sys/contrib/openzfs/cmd/zed/Makefile.am @@ -1,53 +1,46 @@ -include $(top_srcdir)/config/Rules.am -include $(top_srcdir)/config/Shellcheck.am +include $(srcdir)/%D%/zed.d/Makefile.am -AM_CFLAGS += $(LIBUDEV_CFLAGS) $(LIBUUID_CFLAGS) +zed_CFLAGS = $(AM_CFLAGS) +zed_CFLAGS += $(LIBUDEV_CFLAGS) $(LIBUUID_CFLAGS) -SUBDIRS = zed.d -SHELLCHECKDIRS = $(SUBDIRS) +sbin_PROGRAMS += zed +CPPCHECKTARGETS += zed -sbin_PROGRAMS = zed - -ZED_SRC = \ - zed.c \ - zed.h \ - zed_conf.c \ - zed_conf.h \ - zed_disk_event.c \ - zed_disk_event.h \ - zed_event.c \ - zed_event.h \ - zed_exec.c \ - zed_exec.h \ - zed_file.c \ - zed_file.h \ - zed_log.c \ - zed_log.h \ - zed_strings.c \ - zed_strings.h - -FMA_SRC = \ - agents/zfs_agents.c \ - agents/zfs_agents.h \ - agents/zfs_diagnosis.c \ - agents/zfs_mod.c \ - agents/zfs_retire.c \ - agents/fmd_api.c \ - agents/fmd_api.h \ - agents/fmd_serd.c \ - agents/fmd_serd.h - -zed_SOURCES = $(ZED_SRC) $(FMA_SRC) +zed_SOURCES = \ + %D%/zed.c \ + %D%/zed.h \ + %D%/zed_conf.c \ + %D%/zed_conf.h \ + %D%/zed_disk_event.c \ + %D%/zed_disk_event.h \ + %D%/zed_event.c \ + %D%/zed_event.h \ + %D%/zed_exec.c \ + %D%/zed_exec.h \ + %D%/zed_file.c \ + %D%/zed_file.h \ + %D%/zed_log.c \ + %D%/zed_log.h \ + %D%/zed_strings.c \ + %D%/zed_strings.h \ + \ + %D%/agents/fmd_api.c \ + %D%/agents/fmd_api.h \ + %D%/agents/fmd_serd.c \ + %D%/agents/fmd_serd.h \ + %D%/agents/zfs_agents.c \ + %D%/agents/zfs_agents.h \ + %D%/agents/zfs_diagnosis.c \ + %D%/agents/zfs_mod.c \ + %D%/agents/zfs_retire.c zed_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 + libzfs.la \ + libzfs_core.la \ + libnvpair.la \ + libuutil.la zed_LDADD += -lrt $(LIBATOMIC_LIBS) $(LIBUDEV_LIBS) $(LIBUUID_LIBS) zed_LDFLAGS = -pthread -EXTRA_DIST = agents/README.md - -include $(top_srcdir)/config/CppCheck.am +EXTRA_DIST += $(addprefix %D%/,agents/README.md) diff --git a/sys/contrib/openzfs/cmd/zed/zed.d/Makefile.am b/sys/contrib/openzfs/cmd/zed/zed.d/Makefile.am index 3c0f5c3dd1b2..122d2c0c51bc 100644 --- a/sys/contrib/openzfs/cmd/zed/zed.d/Makefile.am +++ b/sys/contrib/openzfs/cmd/zed/zed.d/Makefile.am @@ -1,36 +1,27 @@ -include $(top_srcdir)/config/Rules.am -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -EXTRA_DIST += README - zedconfdir = $(sysconfdir)/zfs/zed.d - dist_zedconf_DATA = \ - zed-functions.sh \ - zed.rc - -SHELLCHECKSCRIPTS = zed-functions.sh zed.rc -SHELLCHECK_SHELL = sh + %D%/zed-functions.sh \ + %D%/zed.rc zedexecdir = $(zfsexecdir)/zed.d dist_zedexec_SCRIPTS = \ - all-debug.sh \ - all-syslog.sh \ - data-notify.sh \ - generic-notify.sh \ - resilver_finish-notify.sh \ - scrub_finish-notify.sh \ - statechange-led.sh \ - statechange-notify.sh \ - vdev_clear-led.sh \ - vdev_attach-led.sh \ - pool_import-led.sh \ - resilver_finish-start-scrub.sh \ - trim_finish-notify.sh + %D%/all-debug.sh \ + %D%/all-syslog.sh \ + %D%/data-notify.sh \ + %D%/generic-notify.sh \ + %D%/pool_import-led.sh \ + %D%/resilver_finish-notify.sh \ + %D%/resilver_finish-start-scrub.sh \ + %D%/scrub_finish-notify.sh \ + %D%/statechange-led.sh \ + %D%/statechange-notify.sh \ + %D%/trim_finish-notify.sh \ + %D%/vdev_attach-led.sh \ + %D%/vdev_clear-led.sh -nodist_zedexec_SCRIPTS = history_event-zfs-list-cacher.sh +nodist_zedexec_SCRIPTS = \ + %D%/history_event-zfs-list-cacher.sh SUBSTFILES += $(nodist_zedexec_SCRIPTS) @@ -38,23 +29,27 @@ zedconfdefaults = \ all-syslog.sh \ data-notify.sh \ history_event-zfs-list-cacher.sh \ + pool_import-led.sh \ resilver_finish-notify.sh \ + resilver_finish-start-scrub.sh \ scrub_finish-notify.sh \ statechange-led.sh \ statechange-notify.sh \ - vdev_clear-led.sh \ vdev_attach-led.sh \ - pool_import-led.sh \ - resilver_finish-start-scrub.sh + vdev_clear-led.sh -install-data-hook: +EXTRA_DIST += $(addprefix %D%/,README) + +INSTALL_DATA_HOOKS += zed-install-data-hook +zed-install-data-hook: $(MKDIR_P) "$(DESTDIR)$(zedconfdir)" - for f in $(zedconfdefaults); do \ - test -f "$(DESTDIR)$(zedconfdir)/$${f}" -o \ - -L "$(DESTDIR)$(zedconfdir)/$${f}" || \ - ln -s "$(zedexecdir)/$${f}" "$(DESTDIR)$(zedconfdir)"; \ + set -x; for f in $(zedconfdefaults); do \ + [ -f "$(DESTDIR)$(zedconfdir)/$${f}" ] ||\ + [ -L "$(DESTDIR)$(zedconfdir)/$${f}" ] || \ + $(LN_S) "$(zedexecdir)/$${f}" "$(DESTDIR)$(zedconfdir)"; \ done - chmod 0600 "$(DESTDIR)$(zedconfdir)/zed.rc" +SHELLCHECKSCRIPTS += $(dist_zedconf_DATA) $(dist_zedexec_SCRIPTS) $(nodist_zedexec_SCRIPTS) +$(call SHELLCHECK_OPTS,$(dist_zedconf_DATA) $(dist_zedexec_SCRIPTS) $(nodist_zedexec_SCRIPTS)): SHELLCHECK_SHELL = sh # False positive: 1>&"${ZED_FLOCK_FD}" looks suspiciously similar to a >&filename bash extension -CHECKBASHISMS_IGNORE = -e 'should be >word 2>&1' -e '&"$${ZED_FLOCK_FD}"' +$(call SHELLCHECK_OPTS,$(dist_zedconf_DATA) $(dist_zedexec_SCRIPTS) $(nodist_zedexec_SCRIPTS)): CHECKBASHISMS_IGNORE = -e 'should be >word 2>&1' -e '&"$${ZED_FLOCK_FD}"' diff --git a/sys/contrib/openzfs/cmd/zed/zed.d/all-debug.sh b/sys/contrib/openzfs/cmd/zed/zed.d/all-debug.sh index ba19b96b082f..9794cf26ce76 100755 --- a/sys/contrib/openzfs/cmd/zed/zed.d/all-debug.sh +++ b/sys/contrib/openzfs/cmd/zed/zed.d/all-debug.sh @@ -15,7 +15,7 @@ zed_exit_if_ignoring_this_event zed_lock "${ZED_DEBUG_LOG}" { - printenv | sort + env | sort echo } 1>&"${ZED_FLOCK_FD}" zed_unlock "${ZED_DEBUG_LOG}" diff --git a/sys/contrib/openzfs/cmd/zed/zed.d/zed-functions.sh b/sys/contrib/openzfs/cmd/zed/zed.d/zed-functions.sh index e6d3ce9ecc49..70a7113c6580 100644 --- a/sys/contrib/openzfs/cmd/zed/zed.d/zed-functions.sh +++ b/sys/contrib/openzfs/cmd/zed/zed.d/zed-functions.sh @@ -76,8 +76,7 @@ zed_log_msg() # zed_log_err() { - logger -p "${ZED_SYSLOG_PRIORITY}" -t "${ZED_SYSLOG_TAG}" -- "error:" \ - "${0##*/}:""${ZEVENT_EID:+" eid=${ZEVENT_EID}:"}" "$@" + zed_log_msg "error: ${0##*/}:""${ZEVENT_EID:+" eid=${ZEVENT_EID}:"}" "$@" } diff --git a/sys/contrib/openzfs/cmd/zed/zed.d/zed.rc b/sys/contrib/openzfs/cmd/zed/zed.d/zed.rc index a8fdc86c3431..3c58a2c281f5 100644 --- a/sys/contrib/openzfs/cmd/zed/zed.d/zed.rc +++ b/sys/contrib/openzfs/cmd/zed/zed.d/zed.rc @@ -1,7 +1,5 @@ ## -# zed.rc -# -# This file should be owned by root and permissioned 0600. +# zed.rc – ZEDLET configuration. ## # shellcheck disable=SC2034 diff --git a/sys/contrib/openzfs/cmd/zed/zed_event.c b/sys/contrib/openzfs/cmd/zed/zed_event.c index 9eaad0e92fbb..d5cafdaff061 100644 --- a/sys/contrib/openzfs/cmd/zed/zed_event.c +++ b/sys/contrib/openzfs/cmd/zed/zed_event.c @@ -884,21 +884,21 @@ _zed_event_get_subclass(const char *class) static void _zed_event_add_time_strings(uint64_t eid, zed_strings_t *zsp, int64_t etime[]) { - struct tm *stp; + struct tm stp; char buf[32]; assert(zsp != NULL); assert(etime != NULL); _zed_event_add_var(eid, zsp, ZEVENT_VAR_PREFIX, "TIME_SECS", - "%lld", (long long int) etime[0]); + "%" PRId64, etime[0]); _zed_event_add_var(eid, zsp, ZEVENT_VAR_PREFIX, "TIME_NSECS", - "%lld", (long long int) etime[1]); + "%" PRId64, etime[1]); - if (!(stp = localtime((const time_t *) &etime[0]))) { + if (!localtime_r((const time_t *) &etime[0], &stp)) { zed_log_msg(LOG_WARNING, "Failed to add %s%s for eid=%llu: %s", ZEVENT_VAR_PREFIX, "TIME_STRING", eid, "localtime error"); - } else if (!strftime(buf, sizeof (buf), "%Y-%m-%d %H:%M:%S%z", stp)) { + } else if (!strftime(buf, sizeof (buf), "%Y-%m-%d %H:%M:%S%z", &stp)) { zed_log_msg(LOG_WARNING, "Failed to add %s%s for eid=%llu: %s", ZEVENT_VAR_PREFIX, "TIME_STRING", eid, "strftime error"); } else { diff --git a/sys/contrib/openzfs/cmd/zfs/.gitignore b/sys/contrib/openzfs/cmd/zfs/.gitignore deleted file mode 100644 index 0fd9cc63af2a..000000000000 --- a/sys/contrib/openzfs/cmd/zfs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zfs diff --git a/sys/contrib/openzfs/cmd/zfs/Makefile.am b/sys/contrib/openzfs/cmd/zfs/Makefile.am index 1ead457f0f29..8a3c13a1fcfe 100644 --- a/sys/contrib/openzfs/cmd/zfs/Makefile.am +++ b/sys/contrib/openzfs/cmd/zfs/Makefile.am @@ -1,25 +1,22 @@ -include $(top_srcdir)/config/Rules.am - -sbin_PROGRAMS = zfs +sbin_PROGRAMS += zfs +CPPCHECKTARGETS += zfs zfs_SOURCES = \ - zfs_iter.c \ - zfs_iter.h \ - zfs_main.c \ - zfs_util.h \ - zfs_project.c \ - zfs_projectutil.h + %D%/zfs_iter.c \ + %D%/zfs_iter.h \ + %D%/zfs_main.c \ + %D%/zfs_project.c \ + %D%/zfs_projectutil.h \ + %D%/zfs_util.h zfs_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 + libzfs.la \ + libzfs_core.la \ + libnvpair.la \ + libuutil.la zfs_LDADD += $(LTLIBINTL) if BUILD_FREEBSD zfs_LDADD += -lgeom -ljail endif - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/cmd/zfs/zfs_main.c b/sys/contrib/openzfs/cmd/zfs/zfs_main.c index b153d217df1a..69f5bdf4d494 100644 --- a/sys/contrib/openzfs/cmd/zfs/zfs_main.c +++ b/sys/contrib/openzfs/cmd/zfs/zfs_main.c @@ -315,9 +315,9 @@ get_usage(zfs_help_t idx) case HELP_ROLLBACK: return (gettext("\trollback [-rRf] \n")); case HELP_SEND: - return (gettext("\tsend [-DnPpRvLecwhb] " - "[-X dataset[,dataset]...] " - "[-[i|I] snapshot] \n" + return (gettext("\tsend [-DLPbcehnpsvw] " + "[-i|-I snapshot]\n" + "\t [-R [-X dataset[,dataset]...]] \n" "\tsend [-DnvPLecw] [-i snapshot|bookmark] " "\n" "\tsend [-DnPpvLec] [-i bookmark|snapshot] " @@ -486,10 +486,7 @@ usage_prop_cb(int prop, void *cb) else (void) fprintf(fp, " NO "); - if (zfs_prop_values(prop) == NULL) - (void) fprintf(fp, "-\n"); - else - (void) fprintf(fp, "%s\n", zfs_prop_values(prop)); + (void) fprintf(fp, "%s\n", zfs_prop_values(prop) ?: "-"); return (ZPROP_CONT); } @@ -767,12 +764,12 @@ zfs_mount_and_share(libzfs_handle_t *hdl, const char *dataset, zfs_type_t type) (void) fprintf(stderr, gettext("filesystem " "successfully created, but not mounted\n")); ret = 1; - } else if (zfs_share(zhp) != 0) { + } else if (zfs_share(zhp, NULL) != 0) { (void) fprintf(stderr, gettext("filesystem " "successfully created, but not shared\n")); ret = 1; } - zfs_commit_all_shares(); + zfs_commit_shares(NULL); } zfs_close(zhp); @@ -4318,73 +4315,27 @@ zfs_do_snapshot(int argc, char **argv) return (-1); } +/* + * Array of prefixes to exclude – + * a linear search, even if executed for each dataset, + * is plenty good enough. + */ typedef struct zfs_send_exclude_arg { size_t count; - char **list; + const char **list; } zfs_send_exclude_arg_t; -/* - * This function creates the zfs_send_exclude_arg_t - * object described above; it can be called multiple - * times, and the input can be comma-separated. - * This is NOT the most efficient data layout; however, - * I couldn't think of a non-pathological case where - * it should have more than a couple dozen instances - * of excludes. If that turns out to be used in - * practice, we might want to instead use a tree. - */ -static void -add_dataset_excludes(char *exclude, zfs_send_exclude_arg_t *context) -{ - char *tok; - while ((tok = strsep(&exclude, ",")) != NULL) { - if (!zfs_name_valid(tok, ZFS_TYPE_DATASET) || - strchr(tok, '/') == NULL) { - (void) fprintf(stderr, gettext("-X %s: " - "not a valid non-root dataset name.\n"), tok); - usage(B_FALSE); - } - context->list = safe_realloc(context->list, - (sizeof (char *)) * (context->count + 1)); - context->list[context->count++] = tok; - } -} - -static void -free_dataset_excludes(zfs_send_exclude_arg_t *exclude_list) -{ - free(exclude_list->list); -} - -/* - * This is the call back used by zfs_send to - * determine if a dataset should be skipped. - * As stated above, this is not the most efficient - * data structure to use, but as long as the - * number of excluded datasets is relatively - * small (a couple of dozen or so), it won't - * have a big impact on performance on modern - * processors. Since it's excluding hierarchies, - * we'd probably want to move to a more complex - * tree structure in that case. - */ static boolean_t zfs_do_send_exclude(zfs_handle_t *zhp, void *context) { - zfs_send_exclude_arg_t *exclude = context; + zfs_send_exclude_arg_t *excludes = context; const char *name = zfs_get_name(zhp); - for (size_t indx = 0; indx < exclude->count; indx++) { - char *exclude_name = exclude->list[indx]; - size_t len = strlen(exclude_name); - /* If it's shorter, it can't possibly match */ - if (strlen(name) < len) - continue; - if (strncmp(name, exclude_name, len) == 0 && - (name[len] == '/' || name[len] == '\0' || - name[len] == '@')) { + for (size_t i = 0; i < excludes->count; ++i) { + size_t len = strlen(excludes->list[i]); + if (strncmp(name, excludes->list[i], len) == 0 && + memchr("/@", name[len], sizeof ("/@"))) return (B_FALSE); - } } return (B_TRUE); @@ -4405,11 +4356,11 @@ zfs_do_send(int argc, char **argv) int c, err; nvlist_t *dbgnv = NULL; char *redactbook = NULL; - zfs_send_exclude_arg_t exclude_context = { 0 }; + zfs_send_exclude_arg_t excludes = { 0 }; struct option long_options[] = { {"replicate", no_argument, NULL, 'R'}, - {"skip-missing", no_argument, NULL, 's'}, + {"skip-missing", no_argument, NULL, 's'}, {"redact", required_argument, NULL, 'd'}, {"props", no_argument, NULL, 'p'}, {"parsable", no_argument, NULL, 'P'}, @@ -4433,7 +4384,18 @@ zfs_do_send(int argc, char **argv) long_options, NULL)) != -1) { switch (c) { case 'X': - add_dataset_excludes(optarg, &exclude_context); + for (char *ds; (ds = strsep(&optarg, ",")) != NULL; ) { + if (!zfs_name_valid(ds, ZFS_TYPE_DATASET) || + strchr(ds, '/') == NULL) { + (void) fprintf(stderr, gettext("-X %s: " + "not a valid non-root dataset name" + ".\n"), ds); + usage(B_FALSE); + } + excludes.list = safe_realloc(excludes.list, + sizeof (char *) * (excludes.count + 1)); + excludes.list[excludes.count++] = ds; + } break; case 'i': if (fromname) @@ -4544,7 +4506,7 @@ zfs_do_send(int argc, char **argv) if (flags.parsable && flags.verbosity == 0) flags.verbosity = 1; - if (exclude_context.count > 0 && !flags.replicate) { + if (excludes.count > 0 && !flags.replicate) { (void) fprintf(stderr, gettext("Cannot specify " "dataset exclusion (-X) on a non-recursive " "send.\n")); @@ -4733,10 +4695,8 @@ zfs_do_send(int argc, char **argv) flags.doall = B_TRUE; err = zfs_send(zhp, fromname, toname, &flags, STDOUT_FILENO, - exclude_context.count > 0 ? zfs_do_send_exclude : NULL, - &exclude_context, flags.verbosity >= 3 ? &dbgnv : NULL); - - free_dataset_excludes(&exclude_context); + excludes.count > 0 ? zfs_do_send_exclude : NULL, + &excludes, flags.verbosity >= 3 ? &dbgnv : NULL); if (flags.verbosity >= 3 && dbgnv != NULL) { /* @@ -4748,8 +4708,9 @@ zfs_do_send(int argc, char **argv) dump_nvlist(dbgnv, 0); nvlist_free(dbgnv); } - zfs_close(zhp); + zfs_close(zhp); + free(excludes.list); return (err != 0); } @@ -5473,8 +5434,6 @@ parse_fs_perm_set(fs_perm_set_t *fspset, nvlist_t *nvl) data_type_t type = nvpair_type(nvp); fs_perm_t *fsperm = NULL; fs_perm_node_t *node = safe_malloc(sizeof (fs_perm_node_t)); - if (node == NULL) - nomem(); fsperm = &node->fspn_fsperm; @@ -6536,13 +6495,10 @@ holds_callback(zfs_handle_t *zhp, void *data) static int zfs_do_holds(int argc, char **argv) { - int errors = 0; int c; - int i; + boolean_t errors = B_FALSE; boolean_t scripted = B_FALSE; boolean_t recursive = B_FALSE; - const char *opts = "rH"; - nvlist_t *nvl; int types = ZFS_TYPE_SNAPSHOT; holds_cbdata_t cb = { 0 }; @@ -6552,7 +6508,7 @@ zfs_do_holds(int argc, char **argv) int flags = 0; /* check options */ - while ((c = getopt(argc, argv, opts)) != -1) { + while ((c = getopt(argc, argv, "rH")) != -1) { switch (c) { case 'r': recursive = B_TRUE; @@ -6579,10 +6535,9 @@ zfs_do_holds(int argc, char **argv) if (argc < 1) usage(B_FALSE); - if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0) != 0) - nomem(); + nvlist_t *nvl = fnvlist_alloc(); - for (i = 0; i < argc; ++i) { + for (int i = 0; i < argc; ++i) { char *snapshot = argv[i]; const char *delim; const char *snapname; @@ -6591,7 +6546,7 @@ zfs_do_holds(int argc, char **argv) if (delim == NULL) { (void) fprintf(stderr, gettext("'%s' is not a snapshot\n"), snapshot); - ++errors; + errors = B_TRUE; continue; } snapname = delim + 1; @@ -6605,10 +6560,10 @@ zfs_do_holds(int argc, char **argv) /* * 1. collect holds data, set format options */ - ret = zfs_for_each(argc, argv, flags, types, NULL, NULL, limit, + ret = zfs_for_each(1, argv + i, flags, types, NULL, NULL, limit, holds_callback, &cb); if (ret != 0) - ++errors; + errors = B_TRUE; } /* @@ -6621,7 +6576,7 @@ zfs_do_holds(int argc, char **argv) nvlist_free(nvl); - return (0 != errors); + return (errors); } #define CHECK_SPINNER 30 @@ -6703,7 +6658,7 @@ typedef struct share_mount_state { boolean_t sm_verbose; int sm_flags; char *sm_options; - char *sm_proto; /* only valid for OP_SHARE */ + enum sa_protocol sm_proto; /* only valid for OP_SHARE */ pthread_mutex_t sm_lock; /* protects the remaining fields */ uint_t sm_total; /* number of filesystems to process */ uint_t sm_done; /* number of filesystems processed */ @@ -6714,7 +6669,7 @@ typedef struct share_mount_state { * Share or mount a dataset. */ static int -share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol, +share_mount_one(zfs_handle_t *zhp, int op, int flags, enum sa_protocol protocol, boolean_t explicit, const char *options) { char mountpoint[ZFS_MAXPROPLEN]; @@ -6832,7 +6787,7 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol, return (0); if (op == OP_SHARE && !zfs_is_mounted(zhp, NULL)) { /* also purge it from existing exports */ - zfs_unshareall_bypath(zhp, mountpoint); + zfs_unshare(zhp, mountpoint, NULL); return (0); } } @@ -6890,10 +6845,11 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol, * filesystem. */ switch (op) { - case OP_SHARE: - - shared_nfs = zfs_is_shared_nfs(zhp, NULL); - shared_smb = zfs_is_shared_smb(zhp, NULL); + case OP_SHARE: { + enum sa_protocol prot[] = {SA_PROTOCOL_NFS, SA_NO_PROTOCOL}; + shared_nfs = zfs_is_shared(zhp, NULL, prot); + *prot = SA_PROTOCOL_SMB; + shared_smb = zfs_is_shared(zhp, NULL, prot); if ((shared_nfs && shared_smb) || (shared_nfs && strcmp(shareopts, "on") == 0 && @@ -6913,23 +6869,11 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol, zfs_mount(zhp, NULL, flags) != 0) return (1); - if (protocol == NULL) { - if (zfs_shareall(zhp) != 0) - return (1); - } else if (strcmp(protocol, "nfs") == 0) { - if (zfs_share_nfs(zhp)) - return (1); - } else if (strcmp(protocol, "smb") == 0) { - if (zfs_share_smb(zhp)) - return (1); - } else { - (void) fprintf(stderr, gettext("cannot share " - "'%s': invalid share type '%s' " - "specified\n"), - zfs_get_name(zhp), protocol); + *prot = protocol; + if (zfs_share(zhp, protocol == SA_NO_PROTOCOL ? NULL : prot)) return (1); - } + } break; case OP_MOUNT: @@ -7027,6 +6971,22 @@ append_options(char *mntopts, char *newopts) (void) strcpy(&mntopts[len], newopts); } +static enum sa_protocol +sa_protocol_decode(const char *protocol) +{ + for (enum sa_protocol i = 0; i < ARRAY_SIZE(sa_protocol_names); ++i) + if (strcmp(protocol, sa_protocol_names[i]) == 0) + return (i); + + (void) fputs(gettext("share type must be one of: "), stderr); + for (enum sa_protocol i = 0; + i < ARRAY_SIZE(sa_protocol_names); ++i) + (void) fprintf(stderr, "%s%s", + i != 0 ? ", " : "", sa_protocol_names[i]); + (void) fputc('\n', stderr); + usage(B_FALSE); +} + static int share_mount(int op, int argc, char **argv) { @@ -7085,16 +7045,10 @@ share_mount(int op, int argc, char **argv) /* check number of arguments */ if (do_all) { - char *protocol = NULL; + enum sa_protocol protocol = SA_NO_PROTOCOL; if (op == OP_SHARE && argc > 0) { - if (strcmp(argv[0], "nfs") != 0 && - strcmp(argv[0], "smb") != 0) { - (void) fprintf(stderr, gettext("share type " - "must be 'nfs' or 'smb'\n")); - usage(B_FALSE); - } - protocol = argv[0]; + protocol = sa_protocol_decode(argv[0]); argc--; argv++; } @@ -7131,7 +7085,7 @@ share_mount(int op, int argc, char **argv) zfs_foreach_mountpoint(g_zfs, cb.cb_handles, cb.cb_used, share_mount_one_cb, &share_mount_state, op == OP_MOUNT && !(flags & MS_CRYPT)); - zfs_commit_all_shares(); + zfs_commit_shares(NULL); ret = share_mount_state.sm_status; @@ -7183,9 +7137,9 @@ share_mount(int op, int argc, char **argv) ZFS_TYPE_FILESYSTEM)) == NULL) { ret = 1; } else { - ret = share_mount_one(zhp, op, flags, NULL, B_TRUE, - options); - zfs_commit_all_shares(); + ret = share_mount_one(zhp, op, flags, SA_NO_PROTOCOL, + B_TRUE, options); + zfs_commit_shares(NULL); zfs_close(zhp); } } @@ -7195,7 +7149,7 @@ share_mount(int op, int argc, char **argv) } /* - * zfs mount -a [nfs] + * zfs mount -a * zfs mount filesystem * * Mount all filesystems, or mount the given filesystem. @@ -7304,12 +7258,12 @@ unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual) "'%s': legacy share\n"), path); (void) fprintf(stderr, gettext("use exportfs(8) " "or smbcontrol(1) to unshare this filesystem\n")); - } else if (!zfs_is_shared(zhp)) { + } else if (!zfs_is_shared(zhp, NULL, NULL)) { (void) fprintf(stderr, gettext("cannot unshare '%s': " "not currently shared\n"), path); } else { - ret = zfs_unshareall_bypath(zhp, path); - zfs_commit_all_shares(); + ret = zfs_unshare(zhp, path, NULL); + zfs_commit_shares(NULL); } } else { char mtpt_prop[ZFS_MAXPROPLEN]; @@ -7399,16 +7353,12 @@ unshare_unmount(int op, int argc, char **argv) unshare_unmount_node_t *node; uu_avl_index_t idx; uu_avl_walk_t *walk; - char *protocol = NULL; + enum sa_protocol *protocol = NULL, + single_protocol[] = {SA_NO_PROTOCOL, SA_NO_PROTOCOL}; if (op == OP_SHARE && argc > 0) { - if (strcmp(argv[0], "nfs") != 0 && - strcmp(argv[0], "smb") != 0) { - (void) fprintf(stderr, gettext("share type " - "must be 'nfs' or 'smb'\n")); - usage(B_FALSE); - } - protocol = argv[0]; + *single_protocol = sa_protocol_decode(argv[0]); + protocol = single_protocol; argc--; argv++; } @@ -7515,7 +7465,7 @@ unshare_unmount(int op, int argc, char **argv) uu_avl_remove(tree, node); switch (op) { case OP_SHARE: - if (zfs_unshareall_bytype(node->un_zhp, + if (zfs_unshare(node->un_zhp, node->un_mountp, protocol) != 0) ret = 1; break; @@ -7588,12 +7538,12 @@ unshare_unmount(int op, int argc, char **argv) "exports(5) or smb.conf(5) to unshare " "this filesystem\n")); ret = 1; - } else if (!zfs_is_shared(zhp)) { + } else if (!zfs_is_shared(zhp, NULL, NULL)) { (void) fprintf(stderr, gettext("cannot " "unshare '%s': not currently " "shared\n"), zfs_get_name(zhp)); ret = 1; - } else if (zfs_unshareall(zhp) != 0) { + } else if (zfs_unshareall(zhp, NULL) != 0) { ret = 1; } break; @@ -8702,7 +8652,7 @@ main(int argc, char **argv) * Many commands modify input strings for string parsing reasons. * We create a copy to protect the original argv. */ - newargv = malloc((argc + 1) * sizeof (newargv[0])); + newargv = safe_malloc((argc + 1) * sizeof (newargv[0])); for (i = 0; i < argc; i++) newargv[i] = strdup(argv[i]); newargv[argc] = NULL; diff --git a/sys/contrib/openzfs/cmd/zfs/zfs_util.h b/sys/contrib/openzfs/cmd/zfs/zfs_util.h index a56af59adb15..cd0dc3ed04cc 100644 --- a/sys/contrib/openzfs/cmd/zfs/zfs_util.h +++ b/sys/contrib/openzfs/cmd/zfs/zfs_util.h @@ -31,7 +31,7 @@ extern "C" { #endif -void * safe_malloc(size_t size); +void *safe_malloc(size_t size); void nomem(void); extern libzfs_handle_t *g_zfs; diff --git a/sys/contrib/openzfs/cmd/zfs_ids_to_path/zfs_ids_to_path.c b/sys/contrib/openzfs/cmd/zfs_ids_to_path.c similarity index 100% rename from sys/contrib/openzfs/cmd/zfs_ids_to_path/zfs_ids_to_path.c rename to sys/contrib/openzfs/cmd/zfs_ids_to_path.c diff --git a/sys/contrib/openzfs/cmd/zfs_ids_to_path/.gitignore b/sys/contrib/openzfs/cmd/zfs_ids_to_path/.gitignore deleted file mode 100644 index f95f853e48c2..000000000000 --- a/sys/contrib/openzfs/cmd/zfs_ids_to_path/.gitignore +++ /dev/null @@ -1 +0,0 @@ -zfs_ids_to_path diff --git a/sys/contrib/openzfs/cmd/zfs_ids_to_path/Makefile.am b/sys/contrib/openzfs/cmd/zfs_ids_to_path/Makefile.am deleted file mode 100644 index 549426764026..000000000000 --- a/sys/contrib/openzfs/cmd/zfs_ids_to_path/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -sbin_PROGRAMS = zfs_ids_to_path - -zfs_ids_to_path_SOURCES = \ - zfs_ids_to_path.c - -zfs_ids_to_path_LDADD = \ - $(abs_top_builddir)/lib/libzfs/libzfs.la - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/cmd/zgenhostid/zgenhostid.c b/sys/contrib/openzfs/cmd/zgenhostid.c similarity index 100% rename from sys/contrib/openzfs/cmd/zgenhostid/zgenhostid.c rename to sys/contrib/openzfs/cmd/zgenhostid.c diff --git a/sys/contrib/openzfs/cmd/zgenhostid/.gitignore b/sys/contrib/openzfs/cmd/zgenhostid/.gitignore deleted file mode 100644 index 072246c735ba..000000000000 --- a/sys/contrib/openzfs/cmd/zgenhostid/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zgenhostid diff --git a/sys/contrib/openzfs/cmd/zgenhostid/Makefile.am b/sys/contrib/openzfs/cmd/zgenhostid/Makefile.am deleted file mode 100644 index 4526a90a1d51..000000000000 --- a/sys/contrib/openzfs/cmd/zgenhostid/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -sbin_PROGRAMS = zgenhostid - -zgenhostid_SOURCES = zgenhostid.c - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/cmd/zhack/zhack.c b/sys/contrib/openzfs/cmd/zhack.c similarity index 100% rename from sys/contrib/openzfs/cmd/zhack/zhack.c rename to sys/contrib/openzfs/cmd/zhack.c diff --git a/sys/contrib/openzfs/cmd/zhack/.gitignore b/sys/contrib/openzfs/cmd/zhack/.gitignore deleted file mode 100644 index 763a18898b88..000000000000 --- a/sys/contrib/openzfs/cmd/zhack/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zhack diff --git a/sys/contrib/openzfs/cmd/zhack/Makefile.am b/sys/contrib/openzfs/cmd/zhack/Makefile.am deleted file mode 100644 index 23f03ffd8243..000000000000 --- a/sys/contrib/openzfs/cmd/zhack/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -# Unconditionally enable debugging for zhack -AM_CPPFLAGS += -DDEBUG -UNDEBUG -DZFS_DEBUG - -sbin_PROGRAMS = zhack - -zhack_SOURCES = \ - zhack.c - -zhack_LDADD = \ - $(abs_top_builddir)/lib/libzpool/libzpool.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/cmd/zinject/.gitignore b/sys/contrib/openzfs/cmd/zinject/.gitignore deleted file mode 100644 index bded8400996c..000000000000 --- a/sys/contrib/openzfs/cmd/zinject/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zinject diff --git a/sys/contrib/openzfs/cmd/zinject/Makefile.am b/sys/contrib/openzfs/cmd/zinject/Makefile.am index 40f382c66191..c90f73fc0165 100644 --- a/sys/contrib/openzfs/cmd/zinject/Makefile.am +++ b/sys/contrib/openzfs/cmd/zinject/Makefile.am @@ -1,15 +1,12 @@ -include $(top_srcdir)/config/Rules.am - -sbin_PROGRAMS = zinject +sbin_PROGRAMS += zinject +CPPCHECKTARGETS += zinject zinject_SOURCES = \ - translate.c \ - zinject.c \ - zinject.h + %D%/translate.c \ + %D%/zinject.c \ + %D%/zinject.h zinject_LDADD = \ - $(abs_top_builddir)/lib/libzfs/libzfs.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la - -include $(top_srcdir)/config/CppCheck.am + libzfs.la \ + libzfs_core.la \ + libnvpair.la diff --git a/sys/contrib/openzfs/cmd/zpool/.gitignore b/sys/contrib/openzfs/cmd/zpool/.gitignore deleted file mode 100644 index 8ea518af78e5..000000000000 --- a/sys/contrib/openzfs/cmd/zpool/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zpool diff --git a/sys/contrib/openzfs/cmd/zpool/Makefile.am b/sys/contrib/openzfs/cmd/zpool/Makefile.am index 7ea7c5fc3f3e..9ba72eadf3a7 100644 --- a/sys/contrib/openzfs/cmd/zpool/Makefile.am +++ b/sys/contrib/openzfs/cmd/zpool/Makefile.am @@ -1,34 +1,35 @@ -include $(top_srcdir)/config/Rules.am -include $(top_srcdir)/config/Shellcheck.am +zpool_CFLAGS = $(AM_CFLAGS) +zpool_CFLAGS += $(LIBBLKID_CFLAGS) $(LIBUUID_CFLAGS) -AM_CFLAGS += $(LIBBLKID_CFLAGS) $(LIBUUID_CFLAGS) +zpool_CPPFLAGS = $(AM_CPPFLAGS) +zpool_CPPFLAGS += -I$(srcdir)/%D% -DEFAULT_INCLUDES += -I$(srcdir) - - -sbin_PROGRAMS = zpool +sbin_PROGRAMS += zpool +CPPCHECKTARGETS += zpool zpool_SOURCES = \ - zpool_iter.c \ - zpool_main.c \ - zpool_util.c \ - zpool_util.h \ - zpool_vdev.c + %D%/zpool_iter.c \ + %D%/zpool_main.c \ + %D%/zpool_util.c \ + %D%/zpool_util.h \ + %D%/zpool_vdev.c if BUILD_FREEBSD -zpool_SOURCES += os/freebsd/zpool_vdev_os.c +zpool_SOURCES += \ + %D%/os/freebsd/zpool_vdev_os.c endif if BUILD_LINUX -zpool_SOURCES += os/linux/zpool_vdev_os.c +zpool_SOURCES += \ + %D%/os/linux/zpool_vdev_os.c endif 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/libzutil/libzutil.la + libzfs.la \ + libzfs_core.la \ + libnvpair.la \ + libuutil.la \ + libzutil.la zpool_LDADD += $(LTLIBINTL) @@ -37,56 +38,53 @@ zpool_LDADD += -lgeom endif zpool_LDADD += -lm $(LIBBLKID_LIBS) $(LIBUUID_LIBS) -include $(top_srcdir)/config/CppCheck.am +EXTRA_DIST += $(addprefix %D%/,zpool.d/README compatibility.d) -zpoolconfdir = $(sysconfdir)/zfs/zpool.d +SHELLCHECKSCRIPTS += $(dist_zpoolexec_SCRIPTS) zpoolexecdir = $(zfsexecdir)/zpool.d - -EXTRA_DIST = zpool.d/README compatibility.d - dist_zpoolexec_SCRIPTS = \ - zpool.d/dm-deps \ - zpool.d/enc \ - zpool.d/encdev \ - zpool.d/fault_led \ - zpool.d/iostat \ - zpool.d/iostat-1s \ - zpool.d/iostat-10s \ - zpool.d/label \ - zpool.d/locate_led \ - zpool.d/lsblk \ - zpool.d/media \ - zpool.d/model \ - zpool.d/serial \ - zpool.d/ses \ - zpool.d/size \ - zpool.d/slot \ - zpool.d/smart \ - zpool.d/smartx \ - zpool.d/temp \ - zpool.d/health \ - zpool.d/r_proc \ - zpool.d/w_proc \ - zpool.d/r_ucor \ - zpool.d/w_ucor \ - zpool.d/nonmed \ - zpool.d/defect \ - zpool.d/hours_on \ - zpool.d/realloc \ - zpool.d/rep_ucor \ - zpool.d/cmd_to \ - zpool.d/pend_sec \ - zpool.d/off_ucor \ - zpool.d/ata_err \ - zpool.d/nvme_err \ - zpool.d/pwr_cyc \ - zpool.d/upath \ - zpool.d/vendor \ - zpool.d/smart_test \ - zpool.d/test_type \ - zpool.d/test_status \ - zpool.d/test_progress \ - zpool.d/test_ended + %D%/zpool.d/ata_err \ + %D%/zpool.d/cmd_to \ + %D%/zpool.d/defect \ + %D%/zpool.d/dm-deps \ + %D%/zpool.d/enc \ + %D%/zpool.d/encdev \ + %D%/zpool.d/fault_led \ + %D%/zpool.d/health \ + %D%/zpool.d/hours_on \ + %D%/zpool.d/iostat \ + %D%/zpool.d/iostat-10s \ + %D%/zpool.d/iostat-1s \ + %D%/zpool.d/label \ + %D%/zpool.d/locate_led \ + %D%/zpool.d/lsblk \ + %D%/zpool.d/media \ + %D%/zpool.d/model \ + %D%/zpool.d/nonmed \ + %D%/zpool.d/nvme_err \ + %D%/zpool.d/off_ucor \ + %D%/zpool.d/pend_sec \ + %D%/zpool.d/pwr_cyc \ + %D%/zpool.d/r_proc \ + %D%/zpool.d/r_ucor \ + %D%/zpool.d/realloc \ + %D%/zpool.d/rep_ucor \ + %D%/zpool.d/serial \ + %D%/zpool.d/ses \ + %D%/zpool.d/size \ + %D%/zpool.d/slot \ + %D%/zpool.d/smart \ + %D%/zpool.d/smart_test \ + %D%/zpool.d/smartx \ + %D%/zpool.d/temp \ + %D%/zpool.d/test_ended \ + %D%/zpool.d/test_progress \ + %D%/zpool.d/test_status \ + %D%/zpool.d/test_type \ + %D%/zpool.d/upath \ + %D%/zpool.d/vendor \ + %D%/zpool.d/w_proc \ + %D%/zpool.d/w_ucor zpoolconfdefaults = \ dm-deps \ @@ -133,29 +131,28 @@ zpoolconfdefaults = \ test_ended zpoolcompatdir = $(pkgdatadir)/compatibility.d - dist_zpoolcompat_DATA = \ - compatibility.d/compat-2018 \ - compatibility.d/compat-2019 \ - compatibility.d/compat-2020 \ - compatibility.d/compat-2021 \ - compatibility.d/freebsd-11.0 \ - compatibility.d/freebsd-11.2 \ - compatibility.d/freebsd-11.3 \ - compatibility.d/freenas-9.10.2 \ - compatibility.d/grub2 \ - compatibility.d/openzfsonosx-1.7.0 \ - compatibility.d/openzfsonosx-1.8.1 \ - compatibility.d/openzfsonosx-1.9.3 \ - compatibility.d/openzfs-2.0-freebsd \ - compatibility.d/openzfs-2.0-linux \ - compatibility.d/openzfs-2.1-freebsd \ - compatibility.d/openzfs-2.1-linux \ - compatibility.d/zol-0.6.1 \ - compatibility.d/zol-0.6.4 \ - compatibility.d/zol-0.6.5 \ - compatibility.d/zol-0.7 \ - compatibility.d/zol-0.8 + %D%/compatibility.d/compat-2018 \ + %D%/compatibility.d/compat-2019 \ + %D%/compatibility.d/compat-2020 \ + %D%/compatibility.d/compat-2021 \ + %D%/compatibility.d/freebsd-11.0 \ + %D%/compatibility.d/freebsd-11.2 \ + %D%/compatibility.d/freebsd-11.3 \ + %D%/compatibility.d/freenas-9.10.2 \ + %D%/compatibility.d/grub2 \ + %D%/compatibility.d/openzfs-2.0-freebsd \ + %D%/compatibility.d/openzfs-2.0-linux \ + %D%/compatibility.d/openzfs-2.1-freebsd \ + %D%/compatibility.d/openzfs-2.1-linux \ + %D%/compatibility.d/openzfsonosx-1.7.0 \ + %D%/compatibility.d/openzfsonosx-1.8.1 \ + %D%/compatibility.d/openzfsonosx-1.9.3 \ + %D%/compatibility.d/zol-0.6.1 \ + %D%/compatibility.d/zol-0.6.4 \ + %D%/compatibility.d/zol-0.6.5 \ + %D%/compatibility.d/zol-0.7 \ + %D%/compatibility.d/zol-0.8 # canonical <- alias symbolic link pairs # eg: "2018" is a link to "compat-2018" @@ -178,13 +175,16 @@ zpoolcompatlinks = \ "zol-0.7 ubuntu-18.04" \ "zol-0.8 ubuntu-20.04" -install-data-hook: +zpoolconfdir = $(sysconfdir)/zfs/zpool.d +INSTALL_DATA_HOOKS += zpool-install-data-hook +zpool-install-data-hook: $(MKDIR_P) "$(DESTDIR)$(zpoolconfdir)" - for f in $(zpoolconfdefaults); do \ - test -f "$(DESTDIR)$(zpoolconfdir)/$${f}" -o \ - -L "$(DESTDIR)$(zpoolconfdir)/$${f}" || \ - ln -s "$(zpoolexecdir)/$${f}" "$(DESTDIR)$(zpoolconfdir)"; \ + set -x; for f in $(zpoolconfdefaults); do \ + [ -f "$(DESTDIR)$(zpoolconfdir)/$${f}" ] || \ + [ -L "$(DESTDIR)$(zpoolconfdir)/$${f}" ] || \ + $(LN_S) "$(zpoolexecdir)/$${f}" "$(DESTDIR)$(zpoolconfdir)"; \ done - for l in $(zpoolcompatlinks); do \ - (cd "$(DESTDIR)$(zpoolcompatdir)"; ln -sf $${l} ); \ + set -x; printf '%s\n' $(zpoolcompatlinks) | \ + while read -r canon alias; do \ + $(LN_S) -f "$${canon}" "$(DESTDIR)$(zpoolcompatdir)/$${alias}"; \ done diff --git a/sys/contrib/openzfs/cmd/zpool/zpool.d/iostat b/sys/contrib/openzfs/cmd/zpool/zpool.d/iostat index 95c459a3f0bf..2f8d79af8926 100755 --- a/sys/contrib/openzfs/cmd/zpool/zpool.d/iostat +++ b/sys/contrib/openzfs/cmd/zpool/zpool.d/iostat @@ -15,6 +15,15 @@ if [ "$1" = "-h" ] ; then exit fi +# Sometimes, UPATH ends up /dev/(null). +# That should be corrected, but for now... +# shellcheck disable=SC2154 +if [ ! -b "$VDEV_UPATH" ]; then + somepath="${VDEV_PATH}" +else + somepath="${VDEV_UPATH}" +fi + if [ "$script" = "iostat-1s" ] ; then # Do a single one-second sample interval=1 @@ -27,8 +36,7 @@ elif [ "$script" = "iostat-10s" ] ; then brief="yes" fi -# shellcheck disable=SC2154 -if [ -f "$VDEV_UPATH" ] ; then +if [ -f "$somepath" ] ; then # We're a file-based vdev, iostat doesn't work on us. Do nothing. exit fi @@ -37,13 +45,13 @@ if [ "$(uname)" = "FreeBSD" ]; then out=$(iostat -dKx \ ${interval:+"-w $interval"} \ ${interval:+"-c 1"} \ - "$VDEV_UPATH" | tail -n 2) + "$somepath" | tail -n 2) else out=$(iostat -kx \ ${brief:+"-y"} \ ${interval:+"$interval"} \ ${interval:+"1"} \ - "$VDEV_UPATH" | grep -v '^$' | tail -n 2) + "$somepath" | grep -v '^$' | tail -n 2) fi diff --git a/sys/contrib/openzfs/cmd/zpool/zpool.d/lsblk b/sys/contrib/openzfs/cmd/zpool/zpool.d/lsblk index 1ed1464431aa..293effd48ac5 100755 --- a/sys/contrib/openzfs/cmd/zpool/zpool.d/lsblk +++ b/sys/contrib/openzfs/cmd/zpool/zpool.d/lsblk @@ -61,21 +61,29 @@ else list=$(echo "$script" | tr '[:upper:]' '[:lower:]') fi +# Sometimes, UPATH ends up /dev/(null). +# That should be corrected, but for now... +# shellcheck disable=SC2154 +if [ ! -b "$VDEV_UPATH" ]; then + somepath="${VDEV_PATH}" +else + somepath="${VDEV_UPATH}" +fi + # Older versions of lsblk don't support all these values (like SERIAL). for i in $list ; do # Special case: Looking up the size of a file-based vdev can't # be done with lsblk. - # shellcheck disable=SC2154 - if [ "$i" = "size" ] && [ -f "$VDEV_UPATH" ] ; then - size=$(du -h --apparent-size "$VDEV_UPATH" | cut -f 1) + if [ "$i" = "size" ] && [ -f "$somepath" ] ; then + size=$(du -h --apparent-size "$somepath" | cut -f 1) echo "size=$size" continue fi val="" - if val=$(eval "lsblk -dl -n -o $i $VDEV_UPATH 2>/dev/null") ; then + if val=$(eval "lsblk -dl -n -o $i $somepath 2>/dev/null") ; then # Remove leading/trailing whitespace from value val=$(echo "$val" | sed -e 's/^[[:space:]]*//' \ -e 's/[[:space:]]*$//') diff --git a/sys/contrib/openzfs/cmd/zpool/zpool.d/smart b/sys/contrib/openzfs/cmd/zpool/zpool.d/smart index 032491988c18..8ad3e107f091 100755 --- a/sys/contrib/openzfs/cmd/zpool/zpool.d/smart +++ b/sys/contrib/openzfs/cmd/zpool/zpool.d/smart @@ -69,8 +69,16 @@ if [ "$1" = "-h" ] ; then exit fi +# Sometimes, UPATH ends up /dev/(null). +# That should be corrected, but for now... # shellcheck disable=SC2154 -if [ -b "$VDEV_UPATH" ] && PATH="/usr/sbin:$PATH" command -v smartctl > /dev/null || [ -n "$samples" ] ; then +if [ ! -b "$VDEV_UPATH" ]; then + somepath="${VDEV_PATH}" +else + somepath="${VDEV_UPATH}" +fi + +if [ -b "$somepath" ] && PATH="/usr/sbin:$PATH" command -v smartctl > /dev/null || [ -n "$samples" ] ; then if [ -n "$samples" ] ; then # cat a smartctl output text file instead of running smartctl # on a vdev (only used for developer testing). @@ -78,7 +86,7 @@ if [ -b "$VDEV_UPATH" ] && PATH="/usr/sbin:$PATH" command -v smartctl > /dev/nul echo "file=$file" raw_out=$(cat "$samples/$file") else - raw_out=$(sudo smartctl -a "$VDEV_UPATH") + raw_out=$(sudo smartctl -a "$somepath") fi # What kind of drive are we? Look for the right line in smartctl: diff --git a/sys/contrib/openzfs/cmd/zpool/zpool_main.c b/sys/contrib/openzfs/cmd/zpool/zpool_main.c index 5d1cae3e9552..ac4a0b23adad 100644 --- a/sys/contrib/openzfs/cmd/zpool/zpool_main.c +++ b/sys/contrib/openzfs/cmd/zpool/zpool_main.c @@ -1790,8 +1790,8 @@ zpool_do_create(int argc, char **argv) tname ? tname : poolname, ZFS_TYPE_FILESYSTEM); if (pool != NULL) { if (zfs_mount(pool, NULL, 0) == 0) { - ret = zfs_shareall(pool); - zfs_commit_all_shares(); + ret = zfs_share(pool, NULL); + zfs_commit_shares(NULL); } zfs_close(pool); } @@ -1987,40 +1987,21 @@ static int max_width(zpool_handle_t *zhp, nvlist_t *nv, int depth, int max, int name_flags) { - char *name; - nvlist_t **child; - uint_t c, children; - int ret; - - name = zpool_vdev_name(g_zfs, zhp, nv, name_flags); - if (strlen(name) + depth > max) - max = strlen(name) + depth; + static const char *const subtypes[] = + {ZPOOL_CONFIG_SPARES, ZPOOL_CONFIG_L2CACHE, ZPOOL_CONFIG_CHILDREN}; + char *name = zpool_vdev_name(g_zfs, zhp, nv, name_flags); + max = MAX(strlen(name) + depth, max); free(name); - if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_SPARES, - &child, &children) == 0) { - for (c = 0; c < children; c++) - if ((ret = max_width(zhp, child[c], depth + 2, - max, name_flags)) > max) - max = ret; - } - - if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_L2CACHE, - &child, &children) == 0) { - for (c = 0; c < children; c++) - if ((ret = max_width(zhp, child[c], depth + 2, - max, name_flags)) > max) - max = ret; - } - - if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN, - &child, &children) == 0) { - for (c = 0; c < children; c++) - if ((ret = max_width(zhp, child[c], depth + 2, - max, name_flags)) > max) - max = ret; - } + nvlist_t **child; + uint_t children; + for (size_t i = 0; i < ARRAY_SIZE(subtypes); ++i) + if (nvlist_lookup_nvlist_array(nv, subtypes[i], + &child, &children) == 0) + for (uint_t c = 0; c < children; ++c) + max = MAX(max_width(zhp, child[c], depth + 2, + max, name_flags), max); return (max); } @@ -2472,7 +2453,7 @@ print_status_config(zpool_handle_t *zhp, status_cbdata_t *cb, const char *name, if (vs->vs_scan_removing != 0) { (void) printf(gettext(" (removing)")); - } else if (vs->vs_noalloc != 0) { + } else if (VDEV_STAT_VALID(vs_noalloc, vsc) && vs->vs_noalloc != 0) { (void) printf(gettext(" (non-allocating)")); } @@ -6162,7 +6143,7 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv, * 'toplevel' boolean value is passed to the print_one_column() * to indicate that the value is valid. */ - if (vs->vs_pspace) + if (VDEV_STAT_VALID(vs_pspace, c) && vs->vs_pspace) print_one_column(ZPOOL_PROP_SIZE, vs->vs_pspace, NULL, scripted, B_TRUE, format); else @@ -10924,7 +10905,7 @@ main(int argc, char **argv) * Many commands modify input strings for string parsing reasons. * We create a copy to protect the original argv. */ - newargv = malloc((argc + 1) * sizeof (newargv[0])); + newargv = safe_malloc((argc + 1) * sizeof (newargv[0])); for (i = 0; i < argc; i++) newargv[i] = strdup(argv[i]); newargv[argc] = NULL; diff --git a/sys/contrib/openzfs/cmd/zpool_influxdb/.gitignore b/sys/contrib/openzfs/cmd/zpool_influxdb/.gitignore deleted file mode 100644 index bd765d188278..000000000000 --- a/sys/contrib/openzfs/cmd/zpool_influxdb/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zpool_influxdb diff --git a/sys/contrib/openzfs/cmd/zpool_influxdb/Makefile.am b/sys/contrib/openzfs/cmd/zpool_influxdb/Makefile.am index a59217570b9d..b237532ce24e 100644 --- a/sys/contrib/openzfs/cmd/zpool_influxdb/Makefile.am +++ b/sys/contrib/openzfs/cmd/zpool_influxdb/Makefile.am @@ -1,13 +1,10 @@ -include $(top_srcdir)/config/Rules.am - -zfsexec_PROGRAMS = zpool_influxdb +zfsexec_PROGRAMS += zpool_influxdb +CPPCHECKTARGETS += zpool_influxdb zpool_influxdb_SOURCES = \ - zpool_influxdb.c + %D%/zpool_influxdb.c zpool_influxdb_LDADD = \ - $(top_builddir)/lib/libspl/libspl.la \ - $(top_builddir)/lib/libnvpair/libnvpair.la \ - $(top_builddir)/lib/libzfs/libzfs.la - -include $(top_srcdir)/config/CppCheck.am + libspl.la \ + libnvpair.la \ + libzfs.la diff --git a/sys/contrib/openzfs/cmd/zstream/.gitignore b/sys/contrib/openzfs/cmd/zstream/.gitignore deleted file mode 100644 index fd1240d55c4b..000000000000 --- a/sys/contrib/openzfs/cmd/zstream/.gitignore +++ /dev/null @@ -1 +0,0 @@ -zstream diff --git a/sys/contrib/openzfs/cmd/zstream/Makefile.am b/sys/contrib/openzfs/cmd/zstream/Makefile.am index 8e813027fa3d..9b2716ae0391 100644 --- a/sys/contrib/openzfs/cmd/zstream/Makefile.am +++ b/sys/contrib/openzfs/cmd/zstream/Makefile.am @@ -1,20 +1,18 @@ -include $(top_srcdir)/config/Rules.am - -sbin_PROGRAMS = zstream +sbin_PROGRAMS += zstream +CPPCHECKTARGETS += zstream zstream_SOURCES = \ - zstream.c \ - zstream.h \ - zstream_dump.c \ - zstream_redup.c \ - zstream_token.c + %D%/zstream.c \ + %D%/zstream.h \ + %D%/zstream_dump.c \ + %D%/zstream_redup.c \ + %D%/zstream_token.c zstream_LDADD = \ - $(abs_top_builddir)/lib/libzfs/libzfs.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la - -include $(top_srcdir)/config/CppCheck.am + libzfs.la \ + libzfs_core.la \ + libnvpair.la +PHONY += install-exec-hook install-exec-hook: cd $(DESTDIR)$(sbindir) && $(LN_S) -f zstream zstreamdump diff --git a/sys/contrib/openzfs/cmd/ztest/ztest.c b/sys/contrib/openzfs/cmd/ztest.c similarity index 98% rename from sys/contrib/openzfs/cmd/ztest/ztest.c rename to sys/contrib/openzfs/cmd/ztest.c index d60422279ad7..ca05cf26511e 100644 --- a/sys/contrib/openzfs/cmd/ztest/ztest.c +++ b/sys/contrib/openzfs/cmd/ztest.c @@ -929,8 +929,7 @@ process_options(int argc, char **argv) int opt; uint64_t value; - char altdir[MAXNAMELEN] = { 0 }; - char raid_kind[8] = "random"; + const char *raid_kind = "random"; memcpy(zo, &ztest_opts_defaults, sizeof (*zo)); @@ -978,7 +977,7 @@ process_options(int argc, char **argv) zo->zo_raid_parity = MIN(MAX(value, 1), 3); break; case 'K': - (void) strlcpy(raid_kind, optarg, sizeof (raid_kind)); + raid_kind = optarg; break; case 'D': zo->zo_draid_data = MAX(1, value); @@ -1037,7 +1036,8 @@ process_options(int argc, char **argv) zo->zo_maxloops = MAX(1, value); break; case 'B': - (void) strlcpy(altdir, optarg, sizeof (altdir)); + (void) strlcpy(zo->zo_alt_ztest, optarg, + sizeof (zo->zo_alt_ztest)); break; case 'C': ztest_parse_name_value(optarg, zo); @@ -1076,8 +1076,7 @@ process_options(int argc, char **argv) /* When raid choice is 'random' add a draid pool 50% of the time */ if (strcmp(raid_kind, "random") == 0) { - (void) strlcpy(raid_kind, (ztest_random(2) == 0) ? - "draid" : "raidz", sizeof (raid_kind)); + raid_kind = (ztest_random(2) == 0) ? "draid" : "raidz"; if (ztest_opts.zo_verbose >= 3) (void) printf("choosing RAID type '%s'\n", raid_kind); @@ -1127,51 +1126,28 @@ process_options(int argc, char **argv) (zo->zo_vdevs > 0 ? zo->zo_time * NANOSEC / zo->zo_vdevs : UINT64_MAX >> 2); - if (strlen(altdir) > 0) { - char *cmd; - char *realaltdir; - char *bin; - char *ztest; - char *isa; - int isalen; + if (*zo->zo_alt_ztest) { + const char *invalid_what = "ztest"; + char *val = zo->zo_alt_ztest; + if (0 != access(val, X_OK) || + (strrchr(val, '/') == NULL && (errno = EINVAL))) + goto invalid; - cmd = umem_alloc(MAXPATHLEN, UMEM_NOFAIL); - realaltdir = umem_alloc(MAXPATHLEN, UMEM_NOFAIL); + int dirlen = strrchr(val, '/') - val; + strncpy(zo->zo_alt_libpath, val, dirlen); + invalid_what = "library path", val = zo->zo_alt_libpath; + if (strrchr(val, '/') == NULL && (errno = EINVAL)) + goto invalid; + *strrchr(val, '/') = '\0'; + strlcat(val, "/lib", sizeof (zo->zo_alt_libpath)); - VERIFY3P(NULL, !=, realpath(getexecname(), cmd)); - if (0 != access(altdir, F_OK)) { - ztest_dump_core = B_FALSE; - fatal(B_TRUE, "invalid alternate ztest path: %s", - altdir); - } - VERIFY3P(NULL, !=, realpath(altdir, realaltdir)); + if (0 != access(zo->zo_alt_libpath, X_OK)) + goto invalid; + return; - /* - * 'cmd' should be of the form "/usr/bin//ztest". - * We want to extract to determine if we should use - * 32 or 64 bit binaries. - */ - bin = strstr(cmd, "/usr/bin/"); - ztest = strstr(bin, "/ztest"); - isa = bin + 9; - isalen = ztest - isa; - (void) snprintf(zo->zo_alt_ztest, sizeof (zo->zo_alt_ztest), - "%s/usr/bin/%.*s/ztest", realaltdir, isalen, isa); - (void) snprintf(zo->zo_alt_libpath, sizeof (zo->zo_alt_libpath), - "%s/usr/lib/%.*s", realaltdir, isalen, isa); - - if (0 != access(zo->zo_alt_ztest, X_OK)) { - ztest_dump_core = B_FALSE; - fatal(B_TRUE, "invalid alternate ztest: %s", - zo->zo_alt_ztest); - } else if (0 != access(zo->zo_alt_libpath, X_OK)) { - ztest_dump_core = B_FALSE; - fatal(B_TRUE, "invalid alternate lib directory %s", - zo->zo_alt_libpath); - } - - umem_free(cmd, MAXPATHLEN); - umem_free(realaltdir, MAXPATHLEN); +invalid: + ztest_dump_core = B_FALSE; + fatal(B_TRUE, "invalid alternate %s %s", invalid_what, val); } } @@ -1182,14 +1158,14 @@ ztest_kill(ztest_shared_t *zs) zs->zs_space = metaslab_class_get_space(spa_normal_class(ztest_spa)); /* - * Before we kill off ztest, make sure that the config is updated. + * Before we kill ourselves, make sure that the config is updated. * See comment above spa_write_cachefile(). */ mutex_enter(&spa_namespace_lock); spa_write_cachefile(ztest_spa, B_FALSE, B_FALSE); mutex_exit(&spa_namespace_lock); - (void) kill(getpid(), SIGKILL); + (void) raise(SIGKILL); } static void @@ -6626,22 +6602,22 @@ ztest_get_zdb_bin(char *bin, int len) { char *zdb_path; /* - * Try to use ZDB_PATH and in-tree zdb path. If not successful, just + * Try to use $ZDB and in-tree zdb path. If not successful, just * let popen to search through PATH. */ - if ((zdb_path = getenv("ZDB_PATH"))) { + if ((zdb_path = getenv("ZDB"))) { strlcpy(bin, zdb_path, len); /* In env */ if (!ztest_check_path(bin)) { ztest_dump_core = 0; - fatal(B_TRUE, "invalid ZDB_PATH '%s'", bin); + fatal(B_TRUE, "invalid ZDB '%s'", bin); } return; } VERIFY3P(realpath(getexecname(), bin), !=, NULL); - if (strstr(bin, "/ztest/")) { - strstr(bin, "/ztest/")[0] = '\0'; /* In-tree */ - strcat(bin, "/zdb/zdb"); + if (strstr(bin, ".libs/ztest")) { + strstr(bin, ".libs/ztest")[0] = '\0'; /* In-tree */ + strcat(bin, "zdb"); if (ztest_check_path(bin)) return; } @@ -6858,7 +6834,7 @@ ztest_run_zdb(char *pool) free(set_gvars_args_joined); if (ztest_opts.zo_verbose >= 5) - (void) printf("Executing %s\n", strstr(zdb, "zdb ")); + (void) printf("Executing %s\n", zdb); fp = popen(zdb, "r"); @@ -7888,21 +7864,24 @@ exec_child(char *cmd, char *libpath, boolean_t ignorekill, int *statusp) fatal(B_TRUE, "fork failed"); if (pid == 0) { /* child */ - char *emptyargv[2] = { cmd, NULL }; char fd_data_str[12]; - struct rlimit rl = { 1024, 1024 }; - (void) setrlimit(RLIMIT_NOFILE, &rl); - - (void) close(ztest_fd_rand); VERIFY3S(11, >=, snprintf(fd_data_str, 12, "%d", ztest_fd_data)); VERIFY0(setenv("ZTEST_FD_DATA", fd_data_str, 1)); - (void) enable_extended_FILE_stdio(-1, -1); - if (libpath != NULL) - VERIFY0(setenv("LD_LIBRARY_PATH", libpath, 1)); - (void) execv(cmd, emptyargv); + if (libpath != NULL) { + const char *curlp = getenv("LD_LIBRARY_PATH"); + if (curlp == NULL) + VERIFY0(setenv("LD_LIBRARY_PATH", libpath, 1)); + else { + char *newlp = NULL; + VERIFY3S(-1, !=, + asprintf(&newlp, "%s:%s", libpath, curlp)); + VERIFY0(setenv("LD_LIBRARY_PATH", newlp, 1)); + } + } + (void) execl(cmd, cmd, (char *)NULL); ztest_dump_core = B_FALSE; fatal(B_TRUE, "exec failed: %s", cmd); } @@ -8033,7 +8012,7 @@ main(int argc, char **argv) * ztest from needlessly depleting the system entropy pool. */ random_path = "/dev/urandom"; - ztest_fd_rand = open(random_path, O_RDONLY); + ztest_fd_rand = open(random_path, O_RDONLY | O_CLOEXEC); ASSERT3S(ztest_fd_rand, >=, 0); if (!fd_data_str) { diff --git a/sys/contrib/openzfs/cmd/ztest/.gitignore b/sys/contrib/openzfs/cmd/ztest/.gitignore deleted file mode 100644 index d3d498dae693..000000000000 --- a/sys/contrib/openzfs/cmd/ztest/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/ztest diff --git a/sys/contrib/openzfs/cmd/ztest/Makefile.am b/sys/contrib/openzfs/cmd/ztest/Makefile.am deleted file mode 100644 index d5e335e6d27e..000000000000 --- a/sys/contrib/openzfs/cmd/ztest/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -# Get rid of compiler warning for unchecked truncating snprintfs on gcc 7.1.1 -AM_CFLAGS += $(NO_FORMAT_TRUNCATION) - -# Includes kernel code, generate warnings for large stack frames -AM_CFLAGS += $(FRAME_LARGER_THAN) - -# Unconditionally enable ASSERTs -AM_CPPFLAGS += -DDEBUG -UNDEBUG -DZFS_DEBUG - -sbin_PROGRAMS = ztest - -ztest_SOURCES = \ - ztest.c - -ztest_LDADD = \ - $(abs_top_builddir)/lib/libzpool/libzpool.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la - -ztest_LDADD += -lm -ztest_LDFLAGS = -pthread - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/cmd/zvol_id/.gitignore b/sys/contrib/openzfs/cmd/zvol_id/.gitignore deleted file mode 100644 index 8b757a2d6781..000000000000 --- a/sys/contrib/openzfs/cmd/zvol_id/.gitignore +++ /dev/null @@ -1 +0,0 @@ -zvol_id diff --git a/sys/contrib/openzfs/cmd/zvol_id/Makefile.am b/sys/contrib/openzfs/cmd/zvol_id/Makefile.am deleted file mode 100644 index bb7e31a0590f..000000000000 --- a/sys/contrib/openzfs/cmd/zvol_id/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -# Disable GCC stack protection for zvol_id. This is a kludge and should be -# removed once https://github.com/openzfs/zfs/issues/569 is resolved. -AM_CFLAGS += -fno-stack-protector - -udev_PROGRAMS = zvol_id - -zvol_id_SOURCES = \ - zvol_id_main.c - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/cmd/zvol_id/zvol_id_main.c b/sys/contrib/openzfs/cmd/zvol_id/zvol_id_main.c deleted file mode 100644 index 929a1a6e794d..000000000000 --- a/sys/contrib/openzfs/cmd/zvol_id/zvol_id_main.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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) 2011, Fajar A. Nugraha. All rights reserved. - * Use is subject to license terms. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(ZFS_ASAN_ENABLED) -/* - * zvol_id is invoked by udev with the help of ptrace() - * making sanitized binary with leak detection croak - * because of tracing mechanisms collision - */ -extern const char *__asan_default_options(void); - -const char *__asan_default_options(void) { - return ("abort_on_error=true:halt_on_error=true:" - "allocator_may_return_null=true:disable_coredump=false:" - "detect_stack_use_after_return=true:detect_leaks=false"); -} -#endif - -static int -ioctl_get_msg(char *var, int fd) -{ - int ret; - char msg[ZFS_MAX_DATASET_NAME_LEN]; - - ret = ioctl(fd, BLKZNAME, msg); - if (ret < 0) { - return (ret); - } - - snprintf(var, ZFS_MAX_DATASET_NAME_LEN, "%s", msg); - return (ret); -} - -int -main(int argc, char **argv) -{ - int fd = -1, ret = 0, status = EXIT_FAILURE; - char zvol_name[ZFS_MAX_DATASET_NAME_LEN]; - char *zvol_name_part = NULL; - char *dev_name; - struct stat64 statbuf; - int dev_minor, dev_part; - int i; - - if (argc < 2) { - fprintf(stderr, "Usage: %s /dev/zvol_device_node\n", argv[0]); - goto fail; - } - - dev_name = argv[1]; - ret = stat64(dev_name, &statbuf); - if (ret != 0) { - fprintf(stderr, "Unable to access device file: %s\n", dev_name); - goto fail; - } - - dev_minor = minor(statbuf.st_rdev); - dev_part = dev_minor % ZVOL_MINORS; - - fd = open(dev_name, O_RDONLY); - if (fd < 0) { - fprintf(stderr, "Unable to open device file: %s\n", dev_name); - goto fail; - } - - ret = ioctl_get_msg(zvol_name, fd); - if (ret < 0) { - fprintf(stderr, "ioctl_get_msg failed: %s\n", strerror(errno)); - goto fail; - } - if (dev_part > 0) - ret = asprintf(&zvol_name_part, "%s-part%d", zvol_name, - dev_part); - else - ret = asprintf(&zvol_name_part, "%s", zvol_name); - - if (ret == -1 || zvol_name_part == NULL) - goto fail; - - for (i = 0; i < strlen(zvol_name_part); i++) { - if (isblank(zvol_name_part[i])) - zvol_name_part[i] = '+'; - } - - printf("%s\n", zvol_name_part); - status = EXIT_SUCCESS; - -fail: - if (zvol_name_part) - free(zvol_name_part); - if (fd >= 0) - close(fd); - - return (status); -} diff --git a/sys/contrib/openzfs/cmd/zvol_wait/zvol_wait b/sys/contrib/openzfs/cmd/zvol_wait similarity index 87% rename from sys/contrib/openzfs/cmd/zvol_wait/zvol_wait rename to sys/contrib/openzfs/cmd/zvol_wait index 2aa929b0ca2b..f1fa42e27dc9 100755 --- a/sys/contrib/openzfs/cmd/zvol_wait/zvol_wait +++ b/sys/contrib/openzfs/cmd/zvol_wait @@ -28,15 +28,17 @@ filter_out_deleted_zvols() { list_zvols() { read -r default_volmode < /sys/module/zfs/parameters/zvol_volmode zfs list -t volume -H -o \ - name,volmode,receive_resume_token,redact_snaps | - while IFS=" " read -r name volmode token redacted; do # IFS=\t here! + name,volmode,receive_resume_token,redact_snaps,keystatus | + while IFS=" " read -r name volmode token redacted keystatus; do # IFS=\t here! - # /dev links are not created for zvols with volmode = "none" - # or for redacted zvols. + # /dev links are not created for zvols with volmode = "none", + # redacted zvols, or encrypted zvols for which the key has not + # been loaded. [ "$volmode" = "none" ] && continue [ "$volmode" = "default" ] && [ "$default_volmode" = "3" ] && continue [ "$redacted" = "-" ] || continue + [ "$keystatus" = "unavailable" ] && continue # We also ignore partially received zvols if it is # not an incremental receive, as those won't even have a block diff --git a/sys/contrib/openzfs/cmd/zvol_wait/Makefile.am b/sys/contrib/openzfs/cmd/zvol_wait/Makefile.am deleted file mode 100644 index e8b546a60659..000000000000 --- a/sys/contrib/openzfs/cmd/zvol_wait/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -include $(top_srcdir)/config/Shellcheck.am - -dist_bin_SCRIPTS = zvol_wait - diff --git a/sys/contrib/openzfs/config/Abigail.am b/sys/contrib/openzfs/config/Abigail.am deleted file mode 100644 index d1038f093373..000000000000 --- a/sys/contrib/openzfs/config/Abigail.am +++ /dev/null @@ -1,52 +0,0 @@ -# -# When performing an ABI check the following options are applied: -# -# --no-unreferenced-symbols: Exclude symbols which are not referenced by -# any debug information. Without this _init() and _fini() are incorrectly -# reported on CentOS7 for libuutil.so. -# -# --headers-dir1: Limit ABI checks to public OpenZFS headers, otherwise -# changes in public system headers are also reported. -# -# --suppressions: Honor a suppressions file for each library to provide -# a mechanism for suppressing harmless warnings. -# - -PHONY += checkabi storeabi check_libabi_version allow_libabi_only_for_x86_64 - -check_libabi_version: - libabiversion=`abidw -v | $(SED) 's/[^0-9]//g'`; \ - if test $$libabiversion -lt "200"; then \ - /bin/echo -e "\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; - -allow_libabi_only_for_x86_64: - echo '*** ABI definitions provided apply only to x86_64 architecture' - echo '*** Skipping `checkabi`/`storeabi` target and assuming success.' - -if TARGET_CPU_X86_64 -checkabi: check_libabi_version - for lib in $(lib_LTLIBRARIES) ; do \ - abidiff --no-unreferenced-symbols \ - --headers-dir1 ../../include \ - --suppressions $${lib%.la}.suppr \ - $${lib%.la}.abi .libs/$${lib%.la}.so ; \ - done - -storeabi: check_libabi_version - cd .libs ; \ - for lib in $(lib_LTLIBRARIES) ; do \ - abidw --no-show-locs \ - --no-corpus-path \ - --no-comp-dir-path \ - --type-id-style hash \ - $${lib%.la}.so > ../$${lib%.la}.abi ; \ - done -else -checkabi: allow_libabi_only_for_x86_64 -storeabi: allow_libabi_only_for_x86_64 -endif diff --git a/sys/contrib/openzfs/config/CppCheck.am b/sys/contrib/openzfs/config/CppCheck.am index e53013bd01cc..89a067d814ff 100644 --- a/sys/contrib/openzfs/config/CppCheck.am +++ b/sys/contrib/openzfs/config/CppCheck.am @@ -1,5 +1,5 @@ # -# Default rules for running cppcheck against the user space components. +# cppcheck for userspace – nodist_*_SOURCES are kernel code and cppcheck goes crazy on them. # PHONY += cppcheck @@ -7,5 +7,15 @@ PHONY += cppcheck CPPCHECKFLAGS = --std=c99 --quiet --max-configs=1 --error-exitcode=2 CPPCHECKFLAGS += --inline-suppr -U_KERNEL -cppcheck: - $(CPPCHECK) -j$(CPU_COUNT) $(CPPCHECKFLAGS) $(DEFAULT_INCLUDES) $(SOURCES) +CPPCHECKDIRS = +CPPCHECKTARGETS = + +cppcheck-recursive-%: + $(MAKE) -C $(subst cppcheck-recursive-,,$@) cppcheck + +_CTGT = $(subst cppcheck-for-,,$@) +cppcheck-for-%: + @[ -n "$($(_CTGT)_SOURCES)$(dist_$(_CTGT)_SOURCES)" ] + $(CPPCHECK) -j$(CPU_COUNT) $(CPPCHECKFLAGS) $(patsubst -U%,,$(patsubst -D%,,$(filter-out $(AM_CPPFLAGS_NOCHECK),$(or $($(_CTGT)_CPPFLAGS),$(AM_CPPFLAGS))))) $($(_CTGT)_SOURCES) $(dist_$(_CTGT)_SOURCES) + +cppcheck: $(addprefix cppcheck-for-,$(subst -,_,$(subst .,_,$(subst /,_,$(CPPCHECKTARGETS))))) $(addprefix cppcheck-recursive-,$(CPPCHECKDIRS)) diff --git a/sys/contrib/openzfs/config/Rules.am b/sys/contrib/openzfs/config/Rules.am index 1540738482ca..07e72d33fde7 100644 --- a/sys/contrib/openzfs/config/Rules.am +++ b/sys/contrib/openzfs/config/Rules.am @@ -4,22 +4,13 @@ # PHONY = -DEFAULT_INCLUDES = \ +AM_CPPFLAGS = \ -include $(top_builddir)/zfs_config.h \ -I$(top_builddir)/include \ -I$(top_srcdir)/include \ -I$(top_srcdir)/module/icp/include \ - -I$(top_srcdir)/lib/libspl/include - -if BUILD_LINUX -DEFAULT_INCLUDES += \ - -I$(top_srcdir)/lib/libspl/include/os/linux -endif - -if BUILD_FREEBSD -DEFAULT_INCLUDES += \ - -I$(top_srcdir)/lib/libspl/include/os/freebsd -endif + -I$(top_srcdir)/lib/libspl/include \ + -I$(top_srcdir)/lib/libspl/include/os/@ac_system_l@ AM_LIBTOOLFLAGS = --silent @@ -37,7 +28,7 @@ AM_CFLAGS += -include $(top_srcdir)/include/os/freebsd/spl/sys/ccompile.h AM_CFLAGS += -I/usr/include -I/usr/local/include endif -AM_CPPFLAGS = -D_GNU_SOURCE +AM_CPPFLAGS += -D_GNU_SOURCE AM_CPPFLAGS += -D_REENTRANT AM_CPPFLAGS += -D_FILE_OFFSET_BITS=64 AM_CPPFLAGS += -D_LARGEFILE64_SOURCE @@ -48,19 +39,20 @@ AM_CPPFLAGS += -DSYSCONFDIR=\"$(sysconfdir)\" AM_CPPFLAGS += -DPKGDATADIR=\"$(pkgdatadir)\" AM_CPPFLAGS += $(DEBUG_CPPFLAGS) AM_CPPFLAGS += $(CODE_COVERAGE_CPPFLAGS) -if BUILD_LINUX -AM_CPPFLAGS += -DTEXT_DOMAIN=\"zfs-linux-user\" -endif -if BUILD_FREEBSD -AM_CPPFLAGS += -DTEXT_DOMAIN=\"zfs-freebsd-user\" -endif -AM_CPPFLAGS += -D"strtok(...)=strtok(__VA_ARGS__) __attribute__((deprecated(\"Use strtok_r(3) instead!\")))" -AM_CPPFLAGS += -D"__xpg_basename(...)=__xpg_basename(__VA_ARGS__) __attribute__((deprecated(\"basename(3) is underspecified. Use zfs_basename() instead!\")))" -AM_CPPFLAGS += -D"basename(...)=basename(__VA_ARGS__) __attribute__((deprecated(\"basename(3) is underspecified. Use zfs_basename() instead!\")))" -AM_CPPFLAGS += -D"dirname(...)=dirname(__VA_ARGS__) __attribute__((deprecated(\"dirname(3) is underspecified. Use zfs_dirnamelen() instead!\")))" -AM_CPPFLAGS += -D"bcopy(...)=__attribute__((deprecated(\"bcopy(3) is deprecated. Use memcpy(3)/memmove(3) instead!\"))) bcopy(__VA_ARGS__)" -AM_CPPFLAGS += -D"bcmp(...)=__attribute__((deprecated(\"bcmp(3) is deprecated. Use memcmp(3) instead!\"))) bcmp(__VA_ARGS__)" -AM_CPPFLAGS += -D"bzero(...)=__attribute__((deprecated(\"bzero(3) is deprecated. Use memset(3) instead!\"))) bzero(__VA_ARGS__)" +AM_CPPFLAGS += -DTEXT_DOMAIN=\"zfs-@ac_system_l@-user\" + +AM_CPPFLAGS_NOCHECK = -D"strtok(...)=strtok(__VA_ARGS__) __attribute__((deprecated(\"Use strtok_r(3) instead!\")))" +AM_CPPFLAGS_NOCHECK += -D"__xpg_basename(...)=__xpg_basename(__VA_ARGS__) __attribute__((deprecated(\"basename(3) is underspecified. Use zfs_basename() instead!\")))" +AM_CPPFLAGS_NOCHECK += -D"basename(...)=basename(__VA_ARGS__) __attribute__((deprecated(\"basename(3) is underspecified. Use zfs_basename() instead!\")))" +AM_CPPFLAGS_NOCHECK += -D"dirname(...)=dirname(__VA_ARGS__) __attribute__((deprecated(\"dirname(3) is underspecified. Use zfs_dirnamelen() instead!\")))" +AM_CPPFLAGS_NOCHECK += -D"bcopy(...)=__attribute__((deprecated(\"bcopy(3) is deprecated. Use memcpy(3)/memmove(3) instead!\"))) bcopy(__VA_ARGS__)" +AM_CPPFLAGS_NOCHECK += -D"bcmp(...)=__attribute__((deprecated(\"bcmp(3) is deprecated. Use memcmp(3) instead!\"))) bcmp(__VA_ARGS__)" +AM_CPPFLAGS_NOCHECK += -D"bzero(...)=__attribute__((deprecated(\"bzero(3) is deprecated. Use memset(3) instead!\"))) bzero(__VA_ARGS__)" +AM_CPPFLAGS_NOCHECK += -D"asctime(...)=__attribute__((deprecated(\"Use strftime(3) instead!\"))) asctime(__VA_ARGS__)" +AM_CPPFLAGS_NOCHECK += -D"asctime_r(...)=__attribute__((deprecated(\"Use strftime(3) instead!\"))) asctime_r(__VA_ARGS__)" +AM_CPPFLAGS_NOCHECK += -D"gmtime(...)=__attribute__((deprecated(\"gmtime(3) isn't thread-safe. Use gmtime_r(3) instead!\"))) gmtime(__VA_ARGS__)" +AM_CPPFLAGS_NOCHECK += -D"localtime(...)=__attribute__((deprecated(\"localtime(3) isn't thread-safe. Use localtime_r(3) instead!\"))) localtime(__VA_ARGS__)" +AM_CPPFLAGS += $(AM_CPPFLAGS_NOCHECK) if ASAN_ENABLED AM_CPPFLAGS += -DZFS_ASAN_ENABLED @@ -79,3 +71,13 @@ AM_LDFLAGS += -fstack-protector-strong -shared AM_LDFLAGS += -Wl,-x -Wl,--fatal-warnings -Wl,--warn-shared-textrel AM_LDFLAGS += -lm endif + + +# If a target includes kernel code, generate warnings for large stack frames +KERNEL_CFLAGS = $(FRAME_LARGER_THAN) + +# See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54020 +LIBRARY_CFLAGS = -no-suppress + +# Forcibly enable asserts/debugging for libzpool &al. +FORCEDEBUG_CPPFLAGS = -DDEBUG -UNDEBUG -DZFS_DEBUG diff --git a/sys/contrib/openzfs/config/Shellcheck.am b/sys/contrib/openzfs/config/Shellcheck.am index fb0bdedd3be3..878919575321 100644 --- a/sys/contrib/openzfs/config/Shellcheck.am +++ b/sys/contrib/openzfs/config/Shellcheck.am @@ -1,30 +1,40 @@ -.PHONY: shellcheck -shellcheck: $(SCRIPTS) $(SHELLCHECKSCRIPTS) - -# ShellCheck exclusions +# Global ShellCheck exclusions: # # ShellCheck can't follow non-constant source. Use a directive to specify location. [SC1090] # Not following: a was not specified as input (see shellcheck -x). [SC1091] # Prefer putting braces around variable references even when not strictly required. [SC2250] # In POSIX sh, 'local' is undefined. [SC2039] # older ShellCheck versions # In POSIX sh, 'local' is undefined. [SC3043] # newer ShellCheck versions -if HAVE_SHELLCHECK - [ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; shellcheck --format=gcc --enable=all --exclude=SC1090,SC1091,SC2039,SC2250,SC3043 $$([ -n "$(SHELLCHECK_SHELL)" ] && echo "--shell=$(SHELLCHECK_SHELL)") $(SHELLCHECK_OPTS) $(SCRIPTS) $(SHELLCHECKSCRIPTS) -else - @[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; echo "skipping shellcheck of" $(SCRIPTS) $(SHELLCHECKSCRIPTS) "because shellcheck is not installed" -endif - @set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir shellcheck; done +SHELLCHECKSCRIPTS = + +JUST_SHELLCHECK_OPTS = $(addprefix shellcheck-here-,$(subst /,^,$(1))) +JUST_CHECKBASHISMS_OPTS = $(addprefix checkbashisms-here-,$(subst /,^,$(1))) +SHELLCHECK_OPTS = $(call JUST_SHELLCHECK_OPTS,$(1)) $(call JUST_CHECKBASHISMS_OPTS,$(1)) + +PHONY += shellcheck + +_STGT = $(subst ^,/,$(subst shellcheck-here-,,$@)) +shellcheck-here-%: +if HAVE_SHELLCHECK + shellcheck --format=gcc --enable=all --exclude=SC1090,SC1091,SC2039,SC2250,SC3043 $$([ -n "$(SHELLCHECK_SHELL)" ] && echo "--shell=$(SHELLCHECK_SHELL)") "$$([ -e "$(_STGT)" ] || echo "$(srcdir)/")$(_STGT)" +else + @echo "skipping shellcheck of" $(_STGT) "because shellcheck is not installed" +endif + +shellcheck: $(SHELLCHECKSCRIPTS) $(call JUST_SHELLCHECK_OPTS,$(SHELLCHECKSCRIPTS)) + + +PHONY += checkbashisms # command -v *is* specified by POSIX and every shell in existence supports it -.PHONY: checkbashisms -checkbashisms: $(SCRIPTS) $(SHELLCHECKSCRIPTS) +_BTGT = $(subst ^,/,$(subst checkbashisms-here-,,$@)) +checkbashisms-here-%: if HAVE_CHECKBASHISMS - [ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; ! if [ -z "$(SHELLCHECK_SHELL)" ]; then \ - checkbashisms -npx $(SCRIPTS) $(SHELLCHECKSCRIPTS); else \ - for f in $(SCRIPTS) $(SHELLCHECKSCRIPTS); do echo $$f >&3; { echo '#!/bin/$(SHELLCHECK_SHELL)'; cat $$f; } | checkbashisms -npx; done; \ - fi 3>&2 2>&1 | grep -vFe "'command' with option other than -p" -e 'command -v' $(CHECKBASHISMS_IGNORE) >&2 + ! { [ -n "$(SHELLCHECK_SHELL)" ] && echo '#!/bin/$(SHELLCHECK_SHELL)'; cat "$$([ -e "$(_BTGT)" ] || echo "$(srcdir)/")$(_BTGT)"; } | \ + checkbashisms -npx 2>&1 | grep -vFe "'command' with option other than -p" -e 'command -v' -e 'any possible bashisms' $(CHECKBASHISMS_IGNORE) >&2 else - @[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; echo "skipping checkbashisms of" $(SCRIPTS) $(SHELLCHECKSCRIPTS) "because checkbashisms is not installed" + @echo "skipping checkbashisms of" $(_BTGT) "because checkbashisms is not installed" endif - @set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir checkbashisms; done + +checkbashisms: $(SHELLCHECKSCRIPTS) $(call JUST_CHECKBASHISMS_OPTS,$(SHELLCHECKSCRIPTS)) diff --git a/sys/contrib/openzfs/config/Substfiles.am b/sys/contrib/openzfs/config/Substfiles.am index b051438fb9e3..733073dd20ca 100644 --- a/sys/contrib/openzfs/config/Substfiles.am +++ b/sys/contrib/openzfs/config/Substfiles.am @@ -1,38 +1,46 @@ subst_sed_cmd = \ + -e 's|@abs_top_srcdir[@]|$(abs_top_srcdir)|g' \ -e 's|@bindir[@]|$(bindir)|g' \ - -e 's|@sbindir[@]|$(sbindir)|g' \ -e 's|@datadir[@]|$(datadir)|g' \ - -e 's|@sysconfdir[@]|$(sysconfdir)|g' \ - -e 's|@runstatedir[@]|$(runstatedir)|g' \ -e 's|@initconfdir[@]|$(initconfdir)|g' \ -e 's|@initdir[@]|$(initdir)|g' \ -e 's|@mounthelperdir[@]|$(mounthelperdir)|g' \ + -e 's|@pammoduledir[@]|$(pammoduledir)|g' \ + -e 's|@runstatedir[@]|$(runstatedir)|g' \ + -e 's|@sbindir[@]|$(sbindir)|g' \ + -e 's|@sysconfdir[@]|$(sysconfdir)|g' \ -e 's|@systemdgeneratordir[@]|$(systemdgeneratordir)|g' \ -e 's|@systemdunitdir[@]|$(systemdunitdir)|g' \ -e 's|@udevdir[@]|$(udevdir)|g' \ -e 's|@udevruledir[@]|$(udevruledir)|g' \ -e 's|@zfsexecdir[@]|$(zfsexecdir)|g' \ - -e 's|@PYTHON[@]|$(PYTHON)|g' \ - -e 's|@PYTHON_SHEBANG[@]|$(PYTHON_SHEBANG)|g' \ + \ + -e 's|@ASAN_ENABLED[@]|$(ASAN_ENABLED)|g' \ -e 's|@DEFAULT_INIT_NFS_SERVER[@]|$(DEFAULT_INIT_NFS_SERVER)|g' \ -e 's|@DEFAULT_INIT_SHELL[@]|$(DEFAULT_INIT_SHELL)|g' \ -e 's|@LIBFETCH_DYNAMIC[@]|$(LIBFETCH_DYNAMIC)|g' \ -e 's|@LIBFETCH_SONAME[@]|$(LIBFETCH_SONAME)|g' \ - -e 's|@ASAN_ENABLED[@]|$(ASAN_ENABLED)|g' \ - -e 's|@UBSAN_ENABLED[@]|$(UBSAN_ENABLED)|g' + -e 's|@PYTHON[@]|$(PYTHON)|g' \ + -e 's|@PYTHON_SHEBANG[@]|$(PYTHON_SHEBANG)|g' \ + -e 's|@UBSAN_ENABLED[@]|$(UBSAN_ENABLED)|g' \ + -e 's|@VERSION[@]|$(VERSION)|g' -SUBSTFILES = -CLEANFILES = $(SUBSTFILES) -EXTRA_DIST = $(SUBSTFILES:=.in) - -$(SUBSTFILES):%:%.in Makefile - $(AM_V_GEN)set -e; \ - $(MKDIR_P) $$(dirname $@); \ - $(RM) $@~; \ - $(SED) $(subst_sed_cmd) $< >$@~; \ - if grep -E '@[a-zA-Z0-9_]+@' $@~ >&2; then \ +define SUBST +$(1) : $(2)$(1).in Makefile; + $$(AM_V_GEN)set -e; \ + $$(MKDIR_P) $$(@D); \ + $$(RM) $$@~; \ + $$(SED) $$(subst_sed_cmd) $$< >$$@~; \ + if grep -E '@[a-zA-Z0-9_]+@' $$@~ >&2; then \ echo "Undefined substitution" >&2; \ exit 1; \ - else test $$? -eq 1; fi; \ - test -x $< && chmod +x $@~; \ - mv -f $@~ $@ + fi; \ + [ -x $$< ] && chmod +x $$@~; \ + mv -f $$@~ $$@ +endef + +SUBSTFILES = +CLEANFILES += $(SUBSTFILES) +EXTRA_DIST += $(SUBSTFILES:=.in) + +$(call SUBST,%,) diff --git a/sys/contrib/openzfs/config/always-cppcheck.m4 b/sys/contrib/openzfs/config/always-cppcheck.m4 index c7c134a3e8cd..fa5a3398d923 100644 --- a/sys/contrib/openzfs/config/always-cppcheck.m4 +++ b/sys/contrib/openzfs/config/always-cppcheck.m4 @@ -3,4 +3,7 @@ dnl # Check if cppcheck is available. dnl # AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CPPCHECK], [ AC_CHECK_PROG([CPPCHECK], [cppcheck], [cppcheck]) + if test -z "$CPPCHECK"; then + CPPCHECK='@printf "skipping cppcheck because cppcheck is not installed\n"' + fi ]) diff --git a/sys/contrib/openzfs/config/always-system.m4 b/sys/contrib/openzfs/config/always-system.m4 index 3225a52af8ae..3a3d4212f8b0 100644 --- a/sys/contrib/openzfs/config/always-system.m4 +++ b/sys/contrib/openzfs/config/always-system.m4 @@ -8,18 +8,22 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_SYSTEM], [ AC_DEFINE([SYSTEM_LINUX], [1], [True if ZFS is to be compiled for a Linux system]) ac_system="Linux" + ac_system_l="linux" ;; *freebsd*) AC_DEFINE([SYSTEM_FREEBSD], [1], [True if ZFS is to be compiled for a FreeBSD system]) ac_system="FreeBSD" + ac_system_l="freebsd" ;; *) ac_system="unknown" + ac_system_l="unknown" ;; esac AC_MSG_RESULT([$ac_system]) AC_SUBST([ac_system]) + AC_SUBST([ac_system_l]) AM_CONDITIONAL([BUILD_LINUX], [test "x$ac_system" = "xLinux"]) AM_CONDITIONAL([BUILD_FREEBSD], [test "x$ac_system" = "xFreeBSD"]) diff --git a/sys/contrib/openzfs/config/config.awk b/sys/contrib/openzfs/config/config.awk deleted file mode 100644 index cc4b7cc265cd..000000000000 --- a/sys/contrib/openzfs/config/config.awk +++ /dev/null @@ -1,15 +0,0 @@ -# Remove default preprocessor define's from config.h -# PACKAGE -# PACKAGE_BUGREPORT -# PACKAGE_NAME -# PACKAGE_STRING -# PACKAGE_TARNAME -# PACKAGE_VERSION -# STDC_HEADERS -# VERSION - -BEGIN { RS = "" ; FS = "\n" } \ - !/.#define PACKAGE./ && \ - !/.#define VERSION./ && \ - !/.#define STDC_HEADERS./ \ - { print $0"\n" } diff --git a/sys/contrib/openzfs/config/deb.am b/sys/contrib/openzfs/config/deb.am index 65aa70687ba5..0033dd7591ff 100644 --- a/sys/contrib/openzfs/config/deb.am +++ b/sys/contrib/openzfs/config/deb.am @@ -61,8 +61,8 @@ deb-utils: deb-local rpm-utils-initramfs pkg7=$${name}-test-$${version}.$${arch}.rpm; \ pkg8=$${name}-dracut-$${version}.noarch.rpm; \ pkg9=$${name}-initramfs-$${version}.$${arch}.rpm; \ - pkg10=`ls python*-pyzfs-$${version}* | tail -1`; \ - pkg11=pam_zfs_key-$${version}.$${arch}.rpm; \ + pkg10=`ls python3-pyzfs-$${version}.noarch.rpm 2>/dev/null`; \ + pkg11=`ls pam_zfs_key-$${version}.$${arch}.rpm 2>/dev/null`; \ ## Arguments need to be passed to dh_shlibdeps. Alien provides no mechanism ## to do this, so we install a shim onto the path which calls the real ## dh_shlibdeps with the required arguments. diff --git a/sys/contrib/openzfs/config/kernel-blk-queue.m4 b/sys/contrib/openzfs/config/kernel-blk-queue.m4 index 559ae9800e8f..2472c49dda4b 100644 --- a/sys/contrib/openzfs/config/kernel-blk-queue.m4 +++ b/sys/contrib/openzfs/config/kernel-blk-queue.m4 @@ -93,8 +93,10 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_DISCARD], [ ZFS_LINUX_TEST_SRC([blk_queue_discard], [ #include ],[ - struct request_queue *q __attribute__ ((unused)) = NULL; + struct request_queue r; + struct request_queue *q = &r; int value __attribute__ ((unused)); + memset(q, 0, sizeof(r)); value = blk_queue_discard(q); ]) ]) @@ -119,16 +121,20 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_BLK_QUEUE_SECURE_ERASE], [ ZFS_LINUX_TEST_SRC([blk_queue_secure_erase], [ #include ],[ - struct request_queue *q __attribute__ ((unused)) = NULL; + struct request_queue r; + struct request_queue *q = &r; int value __attribute__ ((unused)); + memset(q, 0, sizeof(r)); value = blk_queue_secure_erase(q); ]) ZFS_LINUX_TEST_SRC([blk_queue_secdiscard], [ #include ],[ - struct request_queue *q __attribute__ ((unused)) = NULL; + struct request_queue r; + struct request_queue *q = &r; int value __attribute__ ((unused)); + memset(q, 0, sizeof(r)); value = blk_queue_secdiscard(q); ]) ]) diff --git a/sys/contrib/openzfs/config/kernel-config-defined.m4 b/sys/contrib/openzfs/config/kernel-config-defined.m4 index c7d18b49b14e..54837d728341 100644 --- a/sys/contrib/openzfs/config/kernel-config-defined.m4 +++ b/sys/contrib/openzfs/config/kernel-config-defined.m4 @@ -19,19 +19,48 @@ AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEFINED], [ ]) ]) + ZFS_AC_KERNEL_SRC_CONFIG_MODULES + ZFS_AC_KERNEL_SRC_CONFIG_BLOCK ZFS_AC_KERNEL_SRC_CONFIG_DEBUG_LOCK_ALLOC ZFS_AC_KERNEL_SRC_CONFIG_TRIM_UNUSED_KSYMS - ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_INFLATE ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_DEFLATE + ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_INFLATE AC_MSG_CHECKING([for kernel config option compatibility]) ZFS_LINUX_TEST_COMPILE_ALL([config]) AC_MSG_RESULT([done]) + ZFS_AC_KERNEL_CONFIG_MODULES + ZFS_AC_KERNEL_CONFIG_BLOCK 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 + ZFS_AC_KERNEL_CONFIG_ZLIB_INFLATE +]) + +dnl # +dnl # Check CONFIG_BLOCK +dnl # +dnl # Verify the kernel has CONFIG_BLOCK support enabled. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_BLOCK], [ + ZFS_LINUX_TEST_SRC([config_block], [ + #if !defined(CONFIG_BLOCK) + #error CONFIG_BLOCK not defined + #endif + ],[]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_CONFIG_BLOCK], [ + AC_MSG_CHECKING([whether CONFIG_BLOCK is defined]) + ZFS_LINUX_TEST_RESULT([config_block], [ + AC_MSG_RESULT([yes]) + ],[ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([ + *** This kernel does not include the required block device support. + *** Rebuild the kernel with CONFIG_BLOCK=y set.]) + ]) ]) dnl # @@ -72,6 +101,61 @@ AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC], [ ]) ]) +dnl # +dnl # Check CONFIG_MODULES +dnl # +dnl # Verify the kernel has CONFIG_MODULES support enabled. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_MODULES], [ + ZFS_LINUX_TEST_SRC([config_modules], [ + #if !defined(CONFIG_MODULES) + #error CONFIG_MODULES not defined + #endif + ],[]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_CONFIG_MODULES], [ + AC_MSG_CHECKING([whether CONFIG_MODULES is defined]) + AS_IF([test "x$enable_linux_builtin" != xyes], [ + ZFS_LINUX_TEST_RESULT([config_modules], [ + AC_MSG_RESULT([yes]) + ],[ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([ + *** This kernel does not include the required loadable module + *** support! + *** + *** To build OpenZFS as a loadable Linux kernel module + *** enable loadable module support by setting + *** `CONFIG_MODULES=y` in the kernel configuration and run + *** `make modules_prepare` in the Linux source tree. + *** + *** If you don't intend to enable loadable kernel module + *** support, please compile OpenZFS as a Linux kernel built-in. + *** + *** Prepare the Linux source tree by running `make prepare`, + *** use the OpenZFS `--enable-linux-builtin` configure option, + *** copy the OpenZFS sources into the Linux source tree using + *** `./copy-builtin `, + *** set `CONFIG_ZFS=y` in the kernel configuration and compile + *** kernel as usual. + ]) + ]) + ], [ + ZFS_LINUX_TRY_COMPILE([], [], [ + AC_MSG_RESULT([not needed]) + ],[ + AC_MSG_RESULT([error]) + AC_MSG_ERROR([ + *** This kernel is unable to compile object files. + *** + *** Please make sure you prepared the Linux source tree + *** by running `make prepare` there. + ]) + ]) + ]) +]) + dnl # dnl # Check CONFIG_TRIM_UNUSED_KSYMS dnl # diff --git a/sys/contrib/openzfs/config/kernel-copy-from-user-inatomic.m4 b/sys/contrib/openzfs/config/kernel-copy-from-user-inatomic.m4 new file mode 100644 index 000000000000..fec354b2f38e --- /dev/null +++ b/sys/contrib/openzfs/config/kernel-copy-from-user-inatomic.m4 @@ -0,0 +1,29 @@ +dnl # +dnl # On certain architectures `__copy_from_user_inatomic` +dnl # is a GPL exported variable and cannot be used by OpenZFS. +dnl # + +dnl # +dnl # Checking if `__copy_from_user_inatomic` is available. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC___COPY_FROM_USER_INATOMIC], [ + ZFS_LINUX_TEST_SRC([__copy_from_user_inatomic], [ + #include + ], [ + int result __attribute__ ((unused)) = __copy_from_user_inatomic(NULL, NULL, 0); + ], [], [ZFS_META_LICENSE]) +]) + +AC_DEFUN([ZFS_AC_KERNEL___COPY_FROM_USER_INATOMIC], [ + AC_MSG_CHECKING([whether __copy_from_user_inatomic is available]) + ZFS_LINUX_TEST_RESULT([__copy_from_user_inatomic_license], [ + AC_MSG_RESULT(yes) + ], [ + AC_MSG_RESULT(no) + AC_MSG_ERROR([ + *** The `__copy_from_user_inatomic()` Linux kernel function is + *** incompatible with the CDDL license and will prevent the module + *** linking stage from succeeding. OpenZFS cannot be compiled. + ]) + ]) +]) diff --git a/sys/contrib/openzfs/config/kernel-genhd-flags.m4 b/sys/contrib/openzfs/config/kernel-genhd-flags.m4 new file mode 100644 index 000000000000..af6a8a086bc9 --- /dev/null +++ b/sys/contrib/openzfs/config/kernel-genhd-flags.m4 @@ -0,0 +1,58 @@ +dnl # +dnl # 5.17 API change, +dnl # +dnl # GENHD_FL_EXT_DEVT flag removed +dnl # GENHD_FL_NO_PART_SCAN renamed GENHD_FL_NO_PART +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_GENHD_FLAGS], [ + + ZFS_LINUX_TEST_SRC([genhd_fl_ext_devt], [ + #include + ], [ + int flags __attribute__ ((unused)) = GENHD_FL_EXT_DEVT; + ]) + + ZFS_LINUX_TEST_SRC([genhd_fl_no_part], [ + #include + ], [ + int flags __attribute__ ((unused)) = GENHD_FL_NO_PART; + ]) + + ZFS_LINUX_TEST_SRC([genhd_fl_no_part_scan], [ + #include + ], [ + int flags __attribute__ ((unused)) = GENHD_FL_NO_PART_SCAN; + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_GENHD_FLAGS], [ + + AC_MSG_CHECKING([whether GENHD_FL_EXT_DEVT flag is available]) + ZFS_LINUX_TEST_RESULT([genhd_fl_ext_devt], [ + AC_MSG_RESULT(yes) + AC_DEFINE(ZFS_GENHD_FL_EXT_DEVT, GENHD_FL_EXT_DEVT, + [GENHD_FL_EXT_DEVT flag is available]) + ], [ + AC_MSG_RESULT(no) + AC_DEFINE(ZFS_GENHD_FL_EXT_DEVT, 0, + [GENHD_FL_EXT_DEVT flag is not available]) + ]) + + AC_MSG_CHECKING([whether GENHD_FL_NO_PART flag is available]) + ZFS_LINUX_TEST_RESULT([genhd_fl_no_part], [ + AC_MSG_RESULT(yes) + AC_DEFINE(ZFS_GENHD_FL_NO_PART, GENHD_FL_NO_PART, + [GENHD_FL_NO_PART flag is available]) + ], [ + AC_MSG_RESULT(no) + + AC_MSG_CHECKING([whether GENHD_FL_NO_PART_SCAN flag is available]) + ZFS_LINUX_TEST_RESULT([genhd_fl_no_part_scan], [ + AC_MSG_RESULT(yes) + AC_DEFINE(ZFS_GENHD_FL_NO_PART, GENHD_FL_NO_PART_SCAN, + [GENHD_FL_NO_PART_SCAN flag is available]) + ], [ + ZFS_LINUX_TEST_ERROR([GENHD_FL_NO_PART|GENHD_FL_NO_PART_SCAN]) + ]) + ]) +]) diff --git a/sys/contrib/openzfs/config/kernel-global_page_state.m4 b/sys/contrib/openzfs/config/kernel-global_page_state.m4 index badb5e5d2e23..76f2bba202a1 100644 --- a/sys/contrib/openzfs/config/kernel-global_page_state.m4 +++ b/sys/contrib/openzfs/config/kernel-global_page_state.m4 @@ -55,7 +55,7 @@ dnl # AC_DEFUN([ZFS_AC_KERNEL_ENUM_MEMBER], [ AC_MSG_CHECKING([whether enum $2 contains $1]) AS_IF([AC_TRY_COMMAND( - "${srcdir}/scripts/enum-extract.pl" "$2" "$3" | egrep -qx $1)],[ + "${srcdir}/scripts/enum-extract.pl" "$2" "$3" | grep -Eqx $1)],[ AC_MSG_RESULT([yes]) AC_DEFINE(m4_join([_], [ZFS_ENUM], m4_toupper($2), $1), 1, [enum $2 contains $1]) diff --git a/sys/contrib/openzfs/config/kernel-group-info.m4 b/sys/contrib/openzfs/config/kernel-group-info.m4 index 0fee1d36d50d..6941d62da017 100644 --- a/sys/contrib/openzfs/config/kernel-group-info.m4 +++ b/sys/contrib/openzfs/config/kernel-group-info.m4 @@ -6,8 +6,8 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_GROUP_INFO_GID], [ ZFS_LINUX_TEST_SRC([group_info_gid], [ #include ],[ - struct group_info *gi = groups_alloc(1); - gi->gid[0] = KGIDT_INIT(0); + struct group_info gi __attribute__ ((unused)) = {}; + gi.gid[0] = KGIDT_INIT(0); ]) ]) diff --git a/sys/contrib/openzfs/config/kernel-inode-permission.m4 b/sys/contrib/openzfs/config/kernel-inode-permission.m4 new file mode 100644 index 000000000000..ba9ff5d43d4d --- /dev/null +++ b/sys/contrib/openzfs/config/kernel-inode-permission.m4 @@ -0,0 +1,29 @@ +AC_DEFUN([ZFS_AC_KERNEL_SRC_PERMISSION], [ + dnl # + dnl # 5.12 API change that added the struct user_namespace* arg + dnl # to the front of this function type's arg list. + dnl # + ZFS_LINUX_TEST_SRC([permission_userns], [ + #include + #include + + int inode_permission(struct user_namespace *userns, + struct inode *inode, int mask) { return 0; } + + static const struct inode_operations + iops __attribute__ ((unused)) = { + .permission = inode_permission, + }; + ],[]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_PERMISSION], [ + AC_MSG_CHECKING([whether iops->permission() takes struct user_namespace*]) + ZFS_LINUX_TEST_RESULT([permission_userns], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_IOPS_PERMISSION_USERNS, 1, + [iops->permission() takes struct user_namespace*]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/sys/contrib/openzfs/config/kernel-mkdir.m4 b/sys/contrib/openzfs/config/kernel-mkdir.m4 index a162bcd880ff..6667ed04fa4c 100644 --- a/sys/contrib/openzfs/config/kernel-mkdir.m4 +++ b/sys/contrib/openzfs/config/kernel-mkdir.m4 @@ -53,6 +53,8 @@ AC_DEFUN([ZFS_AC_KERNEL_MKDIR], [ AC_DEFINE(HAVE_IOPS_MKDIR_USERNS, 1, [iops->mkdir() takes struct user_namespace*]) ],[ + AC_MSG_RESULT(no) + AC_MSG_CHECKING([whether iops->mkdir() takes umode_t]) ZFS_LINUX_TEST_RESULT([inode_operations_mkdir], [ AC_MSG_RESULT(yes) diff --git a/sys/contrib/openzfs/config/kernel-readpages.m4 b/sys/contrib/openzfs/config/kernel-readpages.m4 new file mode 100644 index 000000000000..0bf67ffd933d --- /dev/null +++ b/sys/contrib/openzfs/config/kernel-readpages.m4 @@ -0,0 +1,25 @@ +dnl # +dnl # Linux 5.18 removes address_space_operations ->readpages in favour of +dnl # ->readahead +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_READPAGES], [ + ZFS_LINUX_TEST_SRC([vfs_has_readpages], [ + #include + + static const struct address_space_operations + aops __attribute__ ((unused)) = { + .readpages = NULL, + }; + ],[]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_VFS_READPAGES], [ + AC_MSG_CHECKING([address_space_operations->readpages exists]) + ZFS_LINUX_TEST_RESULT([vfs_has_readpages], [ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_VFS_READPAGES, 1, + [address_space_operations->readpages exists]) + ],[ + AC_MSG_RESULT([no]) + ]) +]) diff --git a/sys/contrib/openzfs/config/kernel-sysfs.m4 b/sys/contrib/openzfs/config/kernel-sysfs.m4 new file mode 100644 index 000000000000..668def5fe6bf --- /dev/null +++ b/sys/contrib/openzfs/config/kernel-sysfs.m4 @@ -0,0 +1,37 @@ +dnl # +dnl # Linux 5.2/5.18 API +dnl # +dnl # In cdb4f26a63c391317e335e6e683a614358e70aeb ("kobject: kobj_type: remove default_attrs") +dnl # struct kobj_type.default_attrs +dnl # was finally removed in favour of +dnl # struct kobj_type.default_groups +dnl # +dnl # This was added in aa30f47cf666111f6bbfd15f290a27e8a7b9d854 ("kobject: Add support for default attribute groups to kobj_type"), +dnl # if both are present (5.2-5.17), we prefer default_groups; they're otherwise equivalent +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_SYSFS_DEFAULT_GROUPS], [ + ZFS_LINUX_TEST_SRC([sysfs_default_groups], [ + #include + ],[ + struct kobj_type __attribute__ ((unused)) kt = { + .default_groups = (const struct attribute_group **)NULL }; + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_SYSFS_DEFAULT_GROUPS], [ + AC_MSG_CHECKING([for struct kobj_type.default_groups]) + ZFS_LINUX_TEST_RESULT([sysfs_default_groups],[ + AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_SYSFS_DEFAULT_GROUPS], 1, [struct kobj_type has default_groups]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_SRC_SYSFS], [ + ZFS_AC_KERNEL_SRC_SYSFS_DEFAULT_GROUPS +]) + +AC_DEFUN([ZFS_AC_KERNEL_SYSFS], [ + ZFS_AC_KERNEL_SYSFS_DEFAULT_GROUPS +]) diff --git a/sys/contrib/openzfs/config/kernel-vfs-filemap_dirty_folio.m4 b/sys/contrib/openzfs/config/kernel-vfs-filemap_dirty_folio.m4 new file mode 100644 index 000000000000..872879002928 --- /dev/null +++ b/sys/contrib/openzfs/config/kernel-vfs-filemap_dirty_folio.m4 @@ -0,0 +1,30 @@ +dnl # +dnl # Linux 5.18 uses filemap_dirty_folio in lieu of +dnl # ___set_page_dirty_nobuffers +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_FILEMAP_DIRTY_FOLIO], [ + ZFS_LINUX_TEST_SRC([vfs_has_filemap_dirty_folio], [ + #include + #include + + static const struct address_space_operations + aops __attribute__ ((unused)) = { + .dirty_folio = filemap_dirty_folio, + }; + ],[]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_VFS_FILEMAP_DIRTY_FOLIO], [ + dnl # + dnl # Linux 5.18 uses filemap_dirty_folio in lieu of + dnl # ___set_page_dirty_nobuffers + dnl # + AC_MSG_CHECKING([filemap_dirty_folio exists]) + ZFS_LINUX_TEST_RESULT([vfs_has_filemap_dirty_folio], [ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_VFS_FILEMAP_DIRTY_FOLIO, 1, + [filemap_dirty_folio exists]) + ],[ + AC_MSG_RESULT([no]) + ]) +]) diff --git a/sys/contrib/openzfs/config/kernel.m4 b/sys/contrib/openzfs/config/kernel.m4 index d1d3dede175b..a70db91a8364 100644 --- a/sys/contrib/openzfs/config/kernel.m4 +++ b/sys/contrib/openzfs/config/kernel.m4 @@ -8,8 +8,8 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ ZFS_AC_QAT dnl # Sanity checks for module building and CONFIG_* defines - ZFS_AC_KERNEL_TEST_MODULE ZFS_AC_KERNEL_CONFIG_DEFINED + ZFS_AC_MODULE_SYMVERS dnl # Sequential ZFS_LINUX_TRY_COMPILE tests ZFS_AC_KERNEL_FPU_HEADER @@ -61,6 +61,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_BIO ZFS_AC_KERNEL_SRC_BLKDEV ZFS_AC_KERNEL_SRC_BLK_QUEUE + ZFS_AC_KERNEL_SRC_GENHD_FLAGS ZFS_AC_KERNEL_SRC_REVALIDATE_DISK ZFS_AC_KERNEL_SRC_GET_DISK_RO ZFS_AC_KERNEL_SRC_GENERIC_READLINK_GLOBAL @@ -82,6 +83,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_MKDIR ZFS_AC_KERNEL_SRC_LOOKUP_FLAGS ZFS_AC_KERNEL_SRC_CREATE + ZFS_AC_KERNEL_SRC_PERMISSION ZFS_AC_KERNEL_SRC_GET_LINK ZFS_AC_KERNEL_SRC_PUT_LINK ZFS_AC_KERNEL_SRC_TMPFILE @@ -99,6 +101,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_SET_NLINK ZFS_AC_KERNEL_SRC_SGET ZFS_AC_KERNEL_SRC_LSEEK_EXECUTE + ZFS_AC_KERNEL_SRC_VFS_FILEMAP_DIRTY_FOLIO ZFS_AC_KERNEL_SRC_VFS_GETATTR ZFS_AC_KERNEL_SRC_VFS_FSYNC_2ARGS ZFS_AC_KERNEL_SRC_VFS_ITERATE @@ -131,13 +134,16 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_BIO_MAX_SEGS ZFS_AC_KERNEL_SRC_SIGNAL_STOP ZFS_AC_KERNEL_SRC_SIGINFO + ZFS_AC_KERNEL_SRC_SYSFS ZFS_AC_KERNEL_SRC_SET_SPECIAL_STATE + ZFS_AC_KERNEL_SRC_VFS_READPAGES ZFS_AC_KERNEL_SRC_VFS_SET_PAGE_DIRTY_NOBUFFERS ZFS_AC_KERNEL_SRC_STANDALONE_LINUX_STDARG ZFS_AC_KERNEL_SRC_PAGEMAP_FOLIO_WAIT_BIT ZFS_AC_KERNEL_SRC_ADD_DISK ZFS_AC_KERNEL_SRC_KTHREAD ZFS_AC_KERNEL_SRC_ZERO_PAGE + ZFS_AC_KERNEL_SRC___COPY_FROM_USER_INATOMIC AC_MSG_CHECKING([for available kernel interfaces]) ZFS_LINUX_TEST_COMPILE_ALL([kabi]) @@ -172,6 +178,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_BIO ZFS_AC_KERNEL_BLKDEV ZFS_AC_KERNEL_BLK_QUEUE + ZFS_AC_KERNEL_GENHD_FLAGS ZFS_AC_KERNEL_REVALIDATE_DISK ZFS_AC_KERNEL_GET_DISK_RO ZFS_AC_KERNEL_GENERIC_READLINK_GLOBAL @@ -193,6 +200,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_MKDIR ZFS_AC_KERNEL_LOOKUP_FLAGS ZFS_AC_KERNEL_CREATE + ZFS_AC_KERNEL_PERMISSION ZFS_AC_KERNEL_GET_LINK ZFS_AC_KERNEL_PUT_LINK ZFS_AC_KERNEL_TMPFILE @@ -210,6 +218,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_SET_NLINK ZFS_AC_KERNEL_SGET ZFS_AC_KERNEL_LSEEK_EXECUTE + ZFS_AC_KERNEL_VFS_FILEMAP_DIRTY_FOLIO ZFS_AC_KERNEL_VFS_GETATTR ZFS_AC_KERNEL_VFS_FSYNC_2ARGS ZFS_AC_KERNEL_VFS_ITERATE @@ -242,13 +251,16 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_BIO_MAX_SEGS ZFS_AC_KERNEL_SIGNAL_STOP ZFS_AC_KERNEL_SIGINFO + ZFS_AC_KERNEL_SYSFS ZFS_AC_KERNEL_SET_SPECIAL_STATE + ZFS_AC_KERNEL_VFS_READPAGES ZFS_AC_KERNEL_VFS_SET_PAGE_DIRTY_NOBUFFERS ZFS_AC_KERNEL_STANDALONE_LINUX_STDARG ZFS_AC_KERNEL_PAGEMAP_FOLIO_WAIT_BIT ZFS_AC_KERNEL_ADD_DISK ZFS_AC_KERNEL_KTHREAD ZFS_AC_KERNEL_ZERO_PAGE + ZFS_AC_KERNEL___COPY_FROM_USER_INATOMIC ]) dnl # @@ -392,11 +404,11 @@ AC_DEFUN([ZFS_AC_KERNEL], [ utsrelease1=$kernelbuild/include/linux/version.h utsrelease2=$kernelbuild/include/linux/utsrelease.h utsrelease3=$kernelbuild/include/generated/utsrelease.h - AS_IF([test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1], [ + AS_IF([test -r $utsrelease1 && grep -qF UTS_RELEASE $utsrelease1], [ utsrelease=$utsrelease1 - ], [test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2], [ + ], [test -r $utsrelease2 && grep -qF UTS_RELEASE $utsrelease2], [ utsrelease=$utsrelease2 - ], [test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3], [ + ], [test -r $utsrelease3 && grep -qF UTS_RELEASE $utsrelease3], [ utsrelease=$utsrelease3 ]) @@ -437,8 +449,6 @@ AC_DEFUN([ZFS_AC_KERNEL], [ AC_SUBST(LINUX) AC_SUBST(LINUX_OBJ) AC_SUBST(LINUX_VERSION) - - ZFS_AC_MODULE_SYMVERS ]) dnl # @@ -533,27 +543,6 @@ AC_DEFUN([ZFS_AC_QAT], [ ]) ]) -dnl # -dnl # Basic toolchain sanity check. -dnl # -AC_DEFUN([ZFS_AC_KERNEL_TEST_MODULE], [ - AC_MSG_CHECKING([whether modules can be built]) - ZFS_LINUX_TRY_COMPILE([], [], [ - AC_MSG_RESULT([yes]) - ],[ - AC_MSG_RESULT([no]) - if test "x$enable_linux_builtin" != xyes; then - AC_MSG_ERROR([ - *** Unable to build an empty module. - ]) - else - AC_MSG_ERROR([ - *** Unable to build an empty module. - *** Please run 'make scripts' inside the kernel source tree.]) - fi - ]) -]) - dnl # dnl # ZFS_LINUX_CONFTEST_H dnl # @@ -656,8 +645,10 @@ AC_DEFUN([ZFS_LINUX_COMPILE], [ build kernel modules with LLVM/CLANG toolchain]) AC_TRY_COMMAND([ KBUILD_MODPOST_NOFINAL="$5" KBUILD_MODPOST_WARN="$6" - make modules -k -j$TEST_JOBS ${KERNEL_CC:+CC=$KERNEL_CC} ${KERNEL_LD:+LD=$KERNEL_LD} ${KERNEL_LLVM:+LLVM=$KERNEL_LLVM} -C $LINUX_OBJ $ARCH_UM - M=$PWD/$1 >$1/build.log 2>&1]) + make modules -k -j$TEST_JOBS ${KERNEL_CC:+CC=$KERNEL_CC} + ${KERNEL_LD:+LD=$KERNEL_LD} ${KERNEL_LLVM:+LLVM=$KERNEL_LLVM} + CONFIG_MODULES=y CFLAGS_MODULE=-DCONFIG_MODULES + -C $LINUX_OBJ $ARCH_UM M=$PWD/$1 >$1/build.log 2>&1]) AS_IF([AC_TRY_COMMAND([$2])], [$3], [$4]) ]) diff --git a/sys/contrib/openzfs/config/user-systemd.m4 b/sys/contrib/openzfs/config/user-systemd.m4 index 63f02ad2a82b..e4fd0b57c2b7 100644 --- a/sys/contrib/openzfs/config/user-systemd.m4 +++ b/sys/contrib/openzfs/config/user-systemd.m4 @@ -35,16 +35,15 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_SYSTEMD], [ AC_MSG_RESULT([$enable_systemd]) AS_IF([test "x$enable_systemd" = xyes], [ - ZFS_INIT_SYSTEMD=systemd - ZFS_MODULE_LOAD=modules-load.d DEFINE_SYSTEMD='--with systemd --define "_unitdir $(systemdunitdir)" --define "_presetdir $(systemdpresetdir)" --define "_generatordir $(systemdgeneratordir)"' modulesloaddir=$systemdmodulesloaddir ],[ DEFINE_SYSTEMD='--without systemd' ]) - AC_SUBST(ZFS_INIT_SYSTEMD) - AC_SUBST(ZFS_MODULE_LOAD) + ZFS_INIT_SYSTEMD=$enable_systemd + ZFS_WANT_MODULES_LOAD_D=$enable_systemd + AC_SUBST(DEFINE_SYSTEMD) AC_SUBST(systemdunitdir) AC_SUBST(systemdpresetdir) diff --git a/sys/contrib/openzfs/config/user-sysvinit.m4 b/sys/contrib/openzfs/config/user-sysvinit.m4 index b6b63f1cfa36..cf3c8129f0d2 100644 --- a/sys/contrib/openzfs/config/user-sysvinit.m4 +++ b/sys/contrib/openzfs/config/user-sysvinit.m4 @@ -2,10 +2,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_SYSVINIT], [ AC_ARG_ENABLE(sysvinit, AS_HELP_STRING([--enable-sysvinit], [install SysV init scripts [default: yes]]), - [],enable_sysvinit=yes) + [], enable_sysvinit=yes) - AS_IF([test "x$enable_sysvinit" = xyes], - [ZFS_INIT_SYSV=init.d]) - - AC_SUBST(ZFS_INIT_SYSV) + ZFS_INIT_SYSV=$enable_sysvinit ]) diff --git a/sys/contrib/openzfs/config/user.m4 b/sys/contrib/openzfs/config/user.m4 index f450af47e04d..a7241f44f1fd 100644 --- a/sys/contrib/openzfs/config/user.m4 +++ b/sys/contrib/openzfs/config/user.m4 @@ -30,19 +30,8 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [ ZFS_AC_CONFIG_USER_MAKEDEV_IN_SYSMACROS ZFS_AC_CONFIG_USER_MAKEDEV_IN_MKDEV ZFS_AC_CONFIG_USER_ZFSEXEC - ZFS_AC_TEST_FRAMEWORK AC_CHECK_FUNCS([issetugid mlockall strlcat strlcpy]) -]) - -dnl # -dnl # Setup the environment for the ZFS Test Suite. Currently only -dnl # Linux style systems are supported but this infrastructure can -dnl # be extended to support other platforms if needed. -dnl # -AC_DEFUN([ZFS_AC_TEST_FRAMEWORK], [ - ZONENAME="echo global" - AC_SUBST(ZONENAME) AC_SUBST(RM) ]) diff --git a/sys/contrib/openzfs/config/zfs-build.m4 b/sys/contrib/openzfs/config/zfs-build.m4 index d516f3d2969f..59bca5579252 100644 --- a/sys/contrib/openzfs/config/zfs-build.m4 +++ b/sys/contrib/openzfs/config/zfs-build.m4 @@ -173,7 +173,7 @@ AC_DEFUN([ZFS_AC_DEBUG_KMEM_TRACKING], [ ]) AC_DEFUN([ZFS_AC_DEBUG_INVARIANTS_DETECT_FREEBSD], [ - AS_IF([sysctl -n kern.conftxt | fgrep -qx $'options\tINVARIANTS'], + AS_IF([sysctl -n kern.conftxt | grep -Fqx $'options\tINVARIANTS'], [enable_invariants="yes"], [enable_invariants="no"]) ]) @@ -259,6 +259,10 @@ AC_DEFUN([ZFS_AC_CONFIG], [ AC_SUBST(TEST_JOBS) ]) + ZFS_INIT_SYSV= + ZFS_INIT_SYSTEMD= + ZFS_WANT_MODULES_LOAD_D= + case "$ZFS_CONFIG" in kernel) ZFS_AC_CONFIG_KERNEL ;; user) ZFS_AC_CONFIG_USER ;; @@ -271,6 +275,10 @@ AC_DEFUN([ZFS_AC_CONFIG], [ user kernel|user|all|srpm]) ;; esac + AM_CONDITIONAL([INIT_SYSV], [test "x$ZFS_INIT_SYSV" = "xyes"]) + AM_CONDITIONAL([INIT_SYSTEMD], [test "x$ZFS_INIT_SYSTEMD" = "xyes"]) + AM_CONDITIONAL([WANT_MODULES_LOAD_D], [test "x$ZFS_WANT_MODULES_LOAD_D" = "xyes"]) + AM_CONDITIONAL([CONFIG_USER], [test "$ZFS_CONFIG" = user -o "$ZFS_CONFIG" = all]) AM_CONDITIONAL([CONFIG_KERNEL], diff --git a/sys/contrib/openzfs/configure.ac b/sys/contrib/openzfs/configure.ac index 990958bafa1e..7e356cbd20b2 100644 --- a/sys/contrib/openzfs/configure.ac +++ b/sys/contrib/openzfs/configure.ac @@ -1,5 +1,5 @@ /* - * This file is part of the ZFS Linux port. + * This file is part of OpenZFS. * * Copyright (c) 2009 Lawrence Livermore National Security, LLC. * Produced at Lawrence Livermore National Laboratory @@ -30,8 +30,8 @@ * CDDL HEADER END */ -AC_INIT(m4_esyscmd(grep ^Name: META | cut -d ':' -f 2 | tr -d ' \n'), - m4_esyscmd(grep ^Version: META | cut -d ':' -f 2 | tr -d ' \n')) +AC_INIT(m4_esyscmd(awk '/^Name:/ {printf $2}' META), + m4_esyscmd(awk '/^Version:/ {printf $2}' META)) AC_LANG(C) ZFS_AC_META AC_CONFIG_AUX_DIR([config]) @@ -39,11 +39,11 @@ AC_CONFIG_MACRO_DIR([config]) AC_CANONICAL_TARGET AM_MAINTAINER_MODE m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) -AM_INIT_AUTOMAKE([subdir-objects]) +AM_INIT_AUTOMAKE([subdir-objects foreign]) +# Remove default macros from config.h: +# PACKAGE, PACKAGE_{BUGREPORT,NAME,STRING,TARNAME,VERSION}, STDC_HEADERS, VERSION AC_CONFIG_HEADERS([zfs_config.h], [ - (mv zfs_config.h zfs_config.h.tmp && - awk -f ${ac_srcdir}/config/config.awk zfs_config.h.tmp >zfs_config.h && - rm zfs_config.h.tmp) || exit 1]) + sed -nEi~ -e '/^$/be' -e 'N;N;/#define (PACKAGE|VERSION|STDC_HEADERS)/d' -e ':e' -e 'p' zfs_config.h && rm zfs_config.h~ || exit]) LT_INIT AC_PROG_INSTALL @@ -66,356 +66,19 @@ ZFS_AC_DEBUG_INVARIANTS AC_CONFIG_FILES([ Makefile - cmd/Makefile - cmd/arc_summary/Makefile - cmd/arcstat/Makefile - cmd/dbufstat/Makefile - cmd/fsck_zfs/Makefile - cmd/mount_zfs/Makefile - cmd/raidz_test/Makefile - cmd/vdev_id/Makefile - cmd/zdb/Makefile - cmd/zed/Makefile - cmd/zed/zed.d/Makefile - cmd/zfs/Makefile - cmd/zfs_ids_to_path/Makefile - cmd/zgenhostid/Makefile - cmd/zhack/Makefile - cmd/zinject/Makefile - cmd/zpool/Makefile - cmd/zstream/Makefile - cmd/ztest/Makefile - cmd/zvol_id/Makefile - cmd/zvol_wait/Makefile - cmd/zpool_influxdb/Makefile - contrib/Makefile - contrib/bash_completion.d/Makefile - contrib/bpftrace/Makefile - contrib/dracut/02zfsexpandknowledge/Makefile - contrib/dracut/90zfs/Makefile - contrib/dracut/Makefile - contrib/initramfs/Makefile - contrib/initramfs/conf.d/Makefile - contrib/initramfs/conf-hooks.d/Makefile - contrib/initramfs/hooks/Makefile - contrib/initramfs/scripts/Makefile - contrib/initramfs/scripts/local-top/Makefile - contrib/pam_zfs_key/Makefile - contrib/pyzfs/Makefile - contrib/pyzfs/setup.py - contrib/zcp/Makefile - etc/Makefile - etc/default/Makefile - etc/init.d/Makefile - etc/modules-load.d/Makefile - etc/sudoers.d/Makefile - etc/systemd/Makefile - etc/systemd/system-generators/Makefile - etc/systemd/system/Makefile - etc/zfs/Makefile include/Makefile - include/os/Makefile - include/os/freebsd/Makefile - include/os/freebsd/linux/Makefile - include/os/freebsd/spl/Makefile - include/os/freebsd/spl/acl/Makefile - include/os/freebsd/spl/rpc/Makefile - include/os/freebsd/spl/sys/Makefile - include/os/freebsd/zfs/Makefile - include/os/freebsd/zfs/sys/Makefile - include/os/linux/Makefile - include/os/linux/kernel/Makefile - include/os/linux/kernel/linux/Makefile - include/os/linux/spl/Makefile - include/os/linux/spl/rpc/Makefile - include/os/linux/spl/sys/Makefile - include/os/linux/zfs/Makefile - include/os/linux/zfs/sys/Makefile - include/sys/Makefile - include/sys/crypto/Makefile - include/sys/fm/Makefile - include/sys/fm/fs/Makefile - include/sys/fs/Makefile - include/sys/lua/Makefile - include/sys/sysevent/Makefile - include/sys/zstd/Makefile - lib/Makefile - lib/libavl/Makefile - lib/libefi/Makefile - lib/libicp/Makefile - lib/libnvpair/Makefile - lib/libshare/Makefile - lib/libspl/Makefile - lib/libspl/include/Makefile - lib/libspl/include/os/Makefile - lib/libspl/include/os/freebsd/Makefile - lib/libspl/include/os/freebsd/sys/Makefile - lib/libspl/include/os/linux/Makefile - lib/libspl/include/os/linux/sys/Makefile - lib/libspl/include/rpc/Makefile - lib/libspl/include/sys/Makefile - lib/libspl/include/sys/dktp/Makefile - lib/libspl/include/util/Makefile - lib/libtpool/Makefile - lib/libunicode/Makefile - lib/libuutil/Makefile - lib/libzfs/Makefile lib/libzfs/libzfs.pc - lib/libzfsbootenv/Makefile - lib/libzfsbootenv/libzfsbootenv.pc - lib/libzfs_core/Makefile lib/libzfs_core/libzfs_core.pc - lib/libzpool/Makefile - lib/libzstd/Makefile - lib/libzutil/Makefile - man/Makefile + lib/libzfsbootenv/libzfsbootenv.pc module/Kbuild module/Makefile - module/avl/Makefile - module/icp/Makefile - module/lua/Makefile - module/nvpair/Makefile - module/os/linux/spl/Makefile - module/os/linux/zfs/Makefile - module/spl/Makefile - module/unicode/Makefile - module/zcommon/Makefile - module/zfs/Makefile - module/zstd/Makefile - rpm/Makefile - rpm/generic/Makefile rpm/generic/zfs-dkms.spec rpm/generic/zfs-kmod.spec rpm/generic/zfs.spec - rpm/redhat/Makefile rpm/redhat/zfs-dkms.spec rpm/redhat/zfs-kmod.spec rpm/redhat/zfs.spec - scripts/Makefile - tests/Makefile - tests/runfiles/Makefile - tests/test-runner/Makefile - tests/test-runner/bin/Makefile - tests/test-runner/include/Makefile - tests/test-runner/man/Makefile - tests/zfs-tests/Makefile - tests/zfs-tests/callbacks/Makefile - tests/zfs-tests/cmd/Makefile - tests/zfs-tests/cmd/badsend/Makefile - tests/zfs-tests/cmd/btree_test/Makefile - tests/zfs-tests/cmd/chg_usr_exec/Makefile - tests/zfs-tests/cmd/devname2devid/Makefile - tests/zfs-tests/cmd/draid/Makefile - tests/zfs-tests/cmd/dir_rd_update/Makefile - tests/zfs-tests/cmd/file_check/Makefile - tests/zfs-tests/cmd/file_trunc/Makefile - tests/zfs-tests/cmd/file_write/Makefile - tests/zfs-tests/cmd/get_diff/Makefile - tests/zfs-tests/cmd/getversion/Makefile - tests/zfs-tests/cmd/largest_file/Makefile - tests/zfs-tests/cmd/libzfs_input_check/Makefile - tests/zfs-tests/cmd/mkbusy/Makefile - tests/zfs-tests/cmd/mkfile/Makefile - tests/zfs-tests/cmd/mkfiles/Makefile - 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 - tests/zfs-tests/cmd/randwritecomp/Makefile - tests/zfs-tests/cmd/readmmap/Makefile - tests/zfs-tests/cmd/read_dos_attributes/Makefile - tests/zfs-tests/cmd/rename_dir/Makefile - tests/zfs-tests/cmd/rm_lnkcnt_zero_file/Makefile - tests/zfs-tests/cmd/send_doall/Makefile - tests/zfs-tests/cmd/stride_dd/Makefile - tests/zfs-tests/cmd/threadsappend/Makefile - tests/zfs-tests/cmd/user_ns_exec/Makefile - tests/zfs-tests/cmd/write_dos_attributes/Makefile - tests/zfs-tests/cmd/xattrtest/Makefile - tests/zfs-tests/include/Makefile tests/zfs-tests/tests/Makefile - tests/zfs-tests/tests/functional/Makefile - tests/zfs-tests/tests/functional/acl/Makefile - tests/zfs-tests/tests/functional/acl/off/Makefile - tests/zfs-tests/tests/functional/acl/posix/Makefile - tests/zfs-tests/tests/functional/acl/posix-sa/Makefile - tests/zfs-tests/tests/functional/alloc_class/Makefile - tests/zfs-tests/tests/functional/arc/Makefile - tests/zfs-tests/tests/functional/atime/Makefile - tests/zfs-tests/tests/functional/bootfs/Makefile - tests/zfs-tests/tests/functional/btree/Makefile - tests/zfs-tests/tests/functional/cache/Makefile - tests/zfs-tests/tests/functional/cachefile/Makefile - tests/zfs-tests/tests/functional/casenorm/Makefile - tests/zfs-tests/tests/functional/channel_program/Makefile - tests/zfs-tests/tests/functional/channel_program/lua_core/Makefile - tests/zfs-tests/tests/functional/channel_program/synctask_core/Makefile - tests/zfs-tests/tests/functional/chattr/Makefile - tests/zfs-tests/tests/functional/checksum/Makefile - tests/zfs-tests/tests/functional/clean_mirror/Makefile - tests/zfs-tests/tests/functional/cli_root/Makefile - tests/zfs-tests/tests/functional/cli_root/zdb/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_bookmark/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_change-key/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_clone/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_copies/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_create/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_destroy/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_diff/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_get/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_ids_to_path/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_inherit/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_jail/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_load-key/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_mount/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_program/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_promote/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_property/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_receive/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_rename/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_reservation/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_rollback/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_send/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_set/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_share/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_unmount/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_unshare/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/Makefile - tests/zfs-tests/tests/functional/cli_root/zfs_wait/Makefile - tests/zfs-tests/tests/functional/cli_root/zhack/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_add/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_attach/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_clear/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_destroy/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_detach/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_events/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_expand/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_export/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_get/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_history/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_import/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_import/blockfiles/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_initialize/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_offline/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_online/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_remove/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_reopen/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_replace/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_resilver/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_scrub/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_set/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_split/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_status/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_sync/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_trim/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/blockfiles/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_wait/Makefile - tests/zfs-tests/tests/functional/cli_root/zpool_wait/scan/Makefile - tests/zfs-tests/tests/functional/cli_user/Makefile - tests/zfs-tests/tests/functional/cli_user/misc/Makefile - tests/zfs-tests/tests/functional/cli_user/zfs_list/Makefile - tests/zfs-tests/tests/functional/cli_user/zpool_iostat/Makefile - tests/zfs-tests/tests/functional/cli_user/zpool_list/Makefile - tests/zfs-tests/tests/functional/cli_user/zpool_status/Makefile - tests/zfs-tests/tests/functional/compression/Makefile - tests/zfs-tests/tests/functional/cp_files/Makefile - tests/zfs-tests/tests/functional/crtime/Makefile - tests/zfs-tests/tests/functional/ctime/Makefile - tests/zfs-tests/tests/functional/deadman/Makefile - tests/zfs-tests/tests/functional/delegate/Makefile - tests/zfs-tests/tests/functional/devices/Makefile - tests/zfs-tests/tests/functional/dos_attributes/Makefile - tests/zfs-tests/tests/functional/events/Makefile - tests/zfs-tests/tests/functional/exec/Makefile - tests/zfs-tests/tests/functional/fallocate/Makefile - tests/zfs-tests/tests/functional/fault/Makefile - tests/zfs-tests/tests/functional/features/Makefile - tests/zfs-tests/tests/functional/features/async_destroy/Makefile - tests/zfs-tests/tests/functional/features/large_dnode/Makefile - tests/zfs-tests/tests/functional/grow/Makefile - tests/zfs-tests/tests/functional/history/Makefile - tests/zfs-tests/tests/functional/hkdf/Makefile - tests/zfs-tests/tests/functional/inheritance/Makefile - tests/zfs-tests/tests/functional/inuse/Makefile - tests/zfs-tests/tests/functional/io/Makefile - tests/zfs-tests/tests/functional/l2arc/Makefile - tests/zfs-tests/tests/functional/large_files/Makefile - tests/zfs-tests/tests/functional/largest_pool/Makefile - tests/zfs-tests/tests/functional/libzfs/Makefile - tests/zfs-tests/tests/functional/limits/Makefile - tests/zfs-tests/tests/functional/link_count/Makefile - tests/zfs-tests/tests/functional/log_spacemap/Makefile - tests/zfs-tests/tests/functional/migration/Makefile - tests/zfs-tests/tests/functional/mmap/Makefile - tests/zfs-tests/tests/functional/mmp/Makefile - tests/zfs-tests/tests/functional/mount/Makefile - tests/zfs-tests/tests/functional/mv_files/Makefile - tests/zfs-tests/tests/functional/nestedfs/Makefile - tests/zfs-tests/tests/functional/no_space/Makefile - tests/zfs-tests/tests/functional/nopwrite/Makefile - tests/zfs-tests/tests/functional/online_offline/Makefile - tests/zfs-tests/tests/functional/pam/Makefile - tests/zfs-tests/tests/functional/pool_checkpoint/Makefile - tests/zfs-tests/tests/functional/pool_names/Makefile - tests/zfs-tests/tests/functional/poolversion/Makefile - tests/zfs-tests/tests/functional/privilege/Makefile - tests/zfs-tests/tests/functional/procfs/Makefile - tests/zfs-tests/tests/functional/projectquota/Makefile - tests/zfs-tests/tests/functional/pyzfs/Makefile - tests/zfs-tests/tests/functional/quota/Makefile - tests/zfs-tests/tests/functional/raidz/Makefile - tests/zfs-tests/tests/functional/redacted_send/Makefile - tests/zfs-tests/tests/functional/redundancy/Makefile - tests/zfs-tests/tests/functional/refquota/Makefile - tests/zfs-tests/tests/functional/refreserv/Makefile - tests/zfs-tests/tests/functional/removal/Makefile - tests/zfs-tests/tests/functional/rename_dirs/Makefile - tests/zfs-tests/tests/functional/replacement/Makefile - tests/zfs-tests/tests/functional/reservation/Makefile - tests/zfs-tests/tests/functional/rootpool/Makefile - tests/zfs-tests/tests/functional/rsend/Makefile - tests/zfs-tests/tests/functional/scrub_mirror/Makefile - tests/zfs-tests/tests/functional/simd/Makefile - tests/zfs-tests/tests/functional/slog/Makefile - tests/zfs-tests/tests/functional/snapshot/Makefile - tests/zfs-tests/tests/functional/snapused/Makefile - tests/zfs-tests/tests/functional/sparse/Makefile - tests/zfs-tests/tests/functional/stat/Makefile - tests/zfs-tests/tests/functional/suid/Makefile - tests/zfs-tests/tests/functional/threadsappend/Makefile - tests/zfs-tests/tests/functional/tmpfile/Makefile - tests/zfs-tests/tests/functional/trim/Makefile - tests/zfs-tests/tests/functional/truncate/Makefile - tests/zfs-tests/tests/functional/upgrade/Makefile - tests/zfs-tests/tests/functional/user_namespace/Makefile - tests/zfs-tests/tests/functional/userquota/Makefile - tests/zfs-tests/tests/functional/vdev_zaps/Makefile - tests/zfs-tests/tests/functional/write_dirs/Makefile - tests/zfs-tests/tests/functional/xattr/Makefile - tests/zfs-tests/tests/functional/zpool_influxdb/Makefile - tests/zfs-tests/tests/functional/zvol/Makefile - tests/zfs-tests/tests/functional/zvol/zvol_ENOSPC/Makefile - tests/zfs-tests/tests/functional/zvol/zvol_cli/Makefile - tests/zfs-tests/tests/functional/zvol/zvol_misc/Makefile - tests/zfs-tests/tests/functional/zvol/zvol_swap/Makefile - tests/zfs-tests/tests/perf/Makefile - tests/zfs-tests/tests/perf/fio/Makefile - tests/zfs-tests/tests/perf/regression/Makefile - tests/zfs-tests/tests/perf/scripts/Makefile - tests/zfs-tests/tests/stress/Makefile - udev/Makefile - udev/rules.d/Makefile zfs.release ]) diff --git a/sys/contrib/openzfs/contrib/Makefile.am b/sys/contrib/openzfs/contrib/Makefile.am index 5ec13ece5327..fa51bd941d27 100644 --- a/sys/contrib/openzfs/contrib/Makefile.am +++ b/sys/contrib/openzfs/contrib/Makefile.am @@ -1,12 +1,13 @@ -include $(top_srcdir)/config/Shellcheck.am +include $(srcdir)/%D%/bash_completion.d/Makefile.am +include $(srcdir)/%D%/pyzfs/Makefile.am +include $(srcdir)/%D%/zcp/Makefile.am -SUBDIRS = bash_completion.d pyzfs zcp if BUILD_LINUX -SUBDIRS += bpftrace dracut initramfs +include $(srcdir)/%D%/bpftrace/Makefile.am +include $(srcdir)/%D%/dracut/Makefile.am +include $(srcdir)/%D%/initramfs/Makefile.am endif -if PAM_ZFS_ENABLED -SUBDIRS += pam_zfs_key -endif -DIST_SUBDIRS = bash_completion.d bpftrace dracut initramfs pam_zfs_key pyzfs zcp -SHELLCHECKDIRS = bash_completion.d bpftrace dracut initramfs +if PAM_ZFS_ENABLED +include $(srcdir)/%D%/pam_zfs_key/Makefile.am +endif diff --git a/sys/contrib/openzfs/contrib/bash_completion.d/Makefile.am b/sys/contrib/openzfs/contrib/bash_completion.d/Makefile.am index eee617802bbe..dc4b610c42b8 100644 --- a/sys/contrib/openzfs/contrib/bash_completion.d/Makefile.am +++ b/sys/contrib/openzfs/contrib/bash_completion.d/Makefile.am @@ -1,12 +1,7 @@ -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - bashcompletiondir = $(sysconfdir)/bash_completion.d -noinst_DATA = zfs +nodist_bashcompletion_DATA = %D%/zfs +SUBSTFILES += $(nodist_bashcompletion_DATA) -EXTRA_DIST += $(noinst_DATA) -SUBSTFILES += $(noinst_DATA) - -SHELLCHECKSCRIPTS = $(noinst_DATA) -SHELLCHECK_SHELL = bash +SHELLCHECKSCRIPTS += $(nodist_bashcompletion_DATA) +$(call SHELLCHECK_OPTS,$(nodist_bashcompletion_DATA)): SHELLCHECK_SHELL = bash diff --git a/sys/contrib/openzfs/contrib/bpftrace/Makefile.am b/sys/contrib/openzfs/contrib/bpftrace/Makefile.am index 05e4f1c507ce..5382f1e1de42 100644 --- a/sys/contrib/openzfs/contrib/bpftrace/Makefile.am +++ b/sys/contrib/openzfs/contrib/bpftrace/Makefile.am @@ -1,7 +1,5 @@ -include $(top_srcdir)/config/Shellcheck.am - -EXTRA_DIST = \ +EXTRA_DIST += $(addprefix %D%/, \ taskqlatency.bt \ - zfs-trace.sh + zfs-trace.sh) -SHELLCHECKSCRIPTS = zfs-trace.sh +SHELLCHECKSCRIPTS += %D%/zfs-trace.sh diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/.gitignore b/sys/contrib/openzfs/contrib/dracut/.gitignore similarity index 100% rename from sys/contrib/openzfs/contrib/dracut/90zfs/.gitignore rename to sys/contrib/openzfs/contrib/dracut/.gitignore diff --git a/sys/contrib/openzfs/contrib/dracut/02zfsexpandknowledge/.gitignore b/sys/contrib/openzfs/contrib/dracut/02zfsexpandknowledge/.gitignore deleted file mode 100644 index 7fb6b964f058..000000000000 --- a/sys/contrib/openzfs/contrib/dracut/02zfsexpandknowledge/.gitignore +++ /dev/null @@ -1 +0,0 @@ -module-setup.sh diff --git a/sys/contrib/openzfs/contrib/dracut/02zfsexpandknowledge/Makefile.am b/sys/contrib/openzfs/contrib/dracut/02zfsexpandknowledge/Makefile.am deleted file mode 100644 index b1bbb6bd3aac..000000000000 --- a/sys/contrib/openzfs/contrib/dracut/02zfsexpandknowledge/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -pkgdracutdir = $(dracutdir)/modules.d/02zfsexpandknowledge -pkgdracut_SCRIPTS = \ - module-setup.sh - -SUBSTFILES += $(pkgdracut_SCRIPTS) diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/Makefile.am b/sys/contrib/openzfs/contrib/dracut/90zfs/Makefile.am deleted file mode 100644 index 3f7050300994..000000000000 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -pkgdracutdir = $(dracutdir)/modules.d/90zfs -pkgdracut_SCRIPTS = \ - export-zfs.sh \ - module-setup.sh \ - mount-zfs.sh \ - parse-zfs.sh \ - zfs-generator.sh \ - zfs-load-key.sh \ - zfs-needshutdown.sh \ - zfs-lib.sh \ - import-opts-generator.sh - -pkgdracut_DATA = \ - zfs-env-bootfs.service \ - zfs-snapshot-bootfs.service \ - zfs-rollback-bootfs.service - -SUBSTFILES += $(pkgdracut_SCRIPTS) $(pkgdracut_DATA) - -# Provided by /bin/sleep, and, again, every implementation of that supports this -CHECKBASHISMS_IGNORE = -e 'sleep only takes one integer' -e 'sleep 0.' diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/module-setup.sh.in b/sys/contrib/openzfs/contrib/dracut/90zfs/module-setup.sh.in index c79323a3e613..f2145861d497 100755 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/module-setup.sh.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/module-setup.sh.in @@ -9,13 +9,10 @@ check() { for tool in "zgenhostid" "zpool" "zfs" "mount.zfs"; do command -v "${tool}" >/dev/null || return 1 done - - return 0 } depends() { echo udev-rules - return 0 } installkernel() { @@ -39,7 +36,6 @@ install() { { dfatal "Failed to install essential binaries"; exit 1; } # Adapted from https://github.com/zbm-dev/zfsbootmenu - if ! ldd "$(command -v zpool)" | grep -qF 'libgcc_s.so'; then # On systems with gcc-config (Gentoo, Funtoo, etc.), use it to find libgcc_s if command -v gcc-config >/dev/null; then @@ -79,7 +75,6 @@ install() { fi if dracut_module_included "systemd"; then - inst_simple "${systemdsystemunitdir}/zfs-import.target" systemctl -q --root "${initdir}" add-wants initrd.target zfs-import.target diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/mount-zfs.sh.in b/sys/contrib/openzfs/contrib/dracut/90zfs/mount-zfs.sh.in index 7e11c9afdaee..fa9f1bb767b8 100755 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/mount-zfs.sh.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/mount-zfs.sh.in @@ -3,46 +3,71 @@ . /lib/dracut-zfs-lib.sh -ZFS_DATASET="" -ZFS_POOL="" - -case "${root}" in - zfs:*) ;; - *) return ;; -esac +decode_root_args || return 0 GENERATOR_FILE=/run/systemd/generator/sysroot.mount GENERATOR_EXTENSION=/run/systemd/generator/sysroot.mount.d/zfs-enhancement.conf -if [ -e "$GENERATOR_FILE" ] && [ -e "$GENERATOR_EXTENSION" ] ; then - # If the ZFS sysroot.mount flag exists, the initial RAM disk configured - # it to mount ZFS on root. In that case, we bail early. This flag - # file gets created by the zfs-generator program upon successful run. - info "ZFS: There is a sysroot.mount and zfs-generator has extended it." - info "ZFS: Delegating root mount to sysroot.mount." - # Let us tell the initrd to run on shutdown. - # We have a shutdown hook to run - # because we imported the pool. +if [ -e "$GENERATOR_FILE" ] && [ -e "$GENERATOR_EXTENSION" ]; then + # We're under systemd and dracut-zfs-generator ran to completion. + info "ZFS: Delegating root mount to sysroot.mount at al." + # We now prevent Dracut from running this thing again. - for zfsmounthook in "$hookdir"/mount/*zfs* ; do - if [ -f "$zfsmounthook" ] ; then - rm -f "$zfsmounthook" - fi - done + rm -f "$hookdir"/mount/*zfs* return fi + info "ZFS: No sysroot.mount exists or zfs-generator did not extend it." info "ZFS: Mounting root with the traditional mount-zfs.sh instead." +# ask_for_password tries prompt cmd +# +# Wraps around plymouth ask-for-password and adds fallback to tty password ask +# if plymouth is not present. +ask_for_password() { + tries="$1" + prompt="$2" + cmd="$3" + + { + flock -s 9 + + # Prompt for password with plymouth, if installed and running. + if plymouth --ping 2>/dev/null; then + plymouth ask-for-password \ + --prompt "$prompt" --number-of-tries="$tries" | \ + eval "$cmd" + ret=$? + else + i=1 + while [ "$i" -le "$tries" ]; do + printf "%s [%i/%i]:" "$prompt" "$i" "$tries" >&2 + eval "$cmd" && ret=0 && break + ret=$? + i=$((i+1)) + printf '\n' >&2 + done + unset i + fi + } 9>/.console_lock + + [ "$ret" -ne 0 ] && echo "Wrong password" >&2 + return "$ret" +} + + # Delay until all required block devices are present. modprobe zfs 2>/dev/null udevadm settle +ZFS_DATASET= +ZFS_POOL= + if [ "${root}" = "zfs:AUTO" ] ; then - if ! ZFS_DATASET="$(find_bootfs)" ; then + if ! ZFS_DATASET="$(zpool get -Ho value bootfs | grep -m1 -vFx -)"; then # shellcheck disable=SC2086 zpool import -N -a ${ZPOOL_IMPORT_OPTS} - if ! ZFS_DATASET="$(find_bootfs)" ; then + if ! ZFS_DATASET="$(zpool get -Ho value bootfs | grep -m1 -vFx -)"; then warn "ZFS: No bootfs attribute found in importable pools." zpool export -aF @@ -53,34 +78,43 @@ if [ "${root}" = "zfs:AUTO" ] ; then info "ZFS: Using ${ZFS_DATASET} as root." fi -ZFS_DATASET="${ZFS_DATASET:-${root#zfs:}}" +ZFS_DATASET="${ZFS_DATASET:-${root}}" ZFS_POOL="${ZFS_DATASET%%/*}" -if import_pool "${ZFS_POOL}" ; then - # Load keys if we can or if we need to - if [ "$(zpool list -H -o feature@encryption "${ZFS_POOL}")" = 'active' ]; then - # if the root dataset has encryption enabled - ENCRYPTIONROOT="$(zfs get -H -o value encryptionroot "${ZFS_DATASET}")" - if ! [ "${ENCRYPTIONROOT}" = "-" ]; then - KEYSTATUS="$(zfs get -H -o value keystatus "${ENCRYPTIONROOT}")" - # if the key needs to be loaded - if [ "$KEYSTATUS" = "unavailable" ]; then - # decrypt them - ask_for_password \ - --tries 5 \ - --prompt "Encrypted ZFS password for ${ENCRYPTIONROOT}: " \ - --cmd "zfs load-key '${ENCRYPTIONROOT}'" - fi + +if ! zpool get -Ho name "${ZFS_POOL}" > /dev/null 2>&1; then + info "ZFS: Importing pool ${ZFS_POOL}..." + # shellcheck disable=SC2086 + if ! zpool import -N ${ZPOOL_IMPORT_OPTS} "${ZFS_POOL}"; then + warn "ZFS: Unable to import pool ${ZFS_POOL}" + rootok=0 + return 1 + fi +fi + +# Load keys if we can or if we need to +# TODO: for_relevant_root_children like in zfs-load-key.sh.in +if [ "$(zpool get -Ho value feature@encryption "${ZFS_POOL}")" = 'active' ]; then + # if the root dataset has encryption enabled + ENCRYPTIONROOT="$(zfs get -Ho value encryptionroot "${ZFS_DATASET}")" + if ! [ "${ENCRYPTIONROOT}" = "-" ]; then + KEYSTATUS="$(zfs get -Ho value keystatus "${ENCRYPTIONROOT}")" + # if the key needs to be loaded + if [ "$KEYSTATUS" = "unavailable" ]; then + # decrypt them + ask_for_password \ + 5 \ + "Encrypted ZFS password for ${ENCRYPTIONROOT}: " \ + "zfs load-key '${ENCRYPTIONROOT}'" fi fi - # Let us tell the initrd to run on shutdown. - # We have a shutdown hook to run - # because we imported the pool. - info "ZFS: Mounting dataset ${ZFS_DATASET}..." - if mount_dataset "${ZFS_DATASET}" ; then - ROOTFS_MOUNTED=yes - return 0 - fi fi -rootok=0 +# Let us tell the initrd to run on shutdown. +# We have a shutdown hook to run +# because we imported the pool. +info "ZFS: Mounting dataset ${ZFS_DATASET}..." +if ! mount_dataset "${ZFS_DATASET}"; then + rootok=0 + return 1 +fi diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/parse-zfs.sh.in b/sys/contrib/openzfs/contrib/dracut/90zfs/parse-zfs.sh.in index 724c5e2c6dff..f7d1f1c5da9f 100755 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/parse-zfs.sh.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/parse-zfs.sh.in @@ -1,7 +1,8 @@ #!/bin/sh # shellcheck disable=SC2034,SC2154 -. /lib/dracut-lib.sh +# shellcheck source=zfs-lib.sh.in +. /lib/dracut-zfs-lib.sh # Let the command line override our host id. spl_hostid=$(getarg spl_hostid=) @@ -15,52 +16,20 @@ else warn "ZFS: Pools may not import correctly." fi -wait_for_zfs=0 -case "${root}" in - ""|zfs|zfs:) - # We'll take root unset, root=zfs, or root=zfs: - # No root set, so we want to read the bootfs attribute. We - # can't do that until udev settles so we'll set dummy values - # and hope for the best later on. - root="zfs:AUTO" - rootok=1 - wait_for_zfs=1 +if decode_root_args; then + if [ "$root" = "zfs:AUTO" ]; then + info "ZFS: Boot dataset autodetected from bootfs=." + else + info "ZFS: Boot dataset is ${root}." + fi - info "ZFS: Enabling autodetection of bootfs after udev settles." - ;; - - ZFS=*|zfs:*|FILESYSTEM=*) - # root is explicit ZFS root. Parse it now. We can handle - # a root=... param in any of the following formats: - # root=ZFS=rpool/ROOT - # root=zfs:rpool/ROOT - # root=zfs:FILESYSTEM=rpool/ROOT - # root=FILESYSTEM=rpool/ROOT - # root=ZFS=pool+with+space/ROOT+WITH+SPACE (translates to root=ZFS=pool with space/ROOT WITH SPACE) - - # Strip down to just the pool/fs - root="${root#zfs:}" - root="${root#FILESYSTEM=}" - root="zfs:${root#ZFS=}" - # switch + with spaces because kernel cmdline does not allow us to quote parameters - root=$(echo "$root" | tr '+' ' ') - rootok=1 - wait_for_zfs=1 - - info "ZFS: Set ${root} as bootfs." - ;; - - *) - info "ZFS: no ZFS-on-root" -esac - -# Make sure Dracut is happy that we have a root and will wait for ZFS -# modules to settle before mounting. -if [ "${wait_for_zfs}" -eq 1 ]; then - ln -s /dev/null /dev/root 2>/dev/null - initqueuedir="${hookdir}/initqueue/finished" - test -d "${initqueuedir}" || { - initqueuedir="${hookdir}/initqueue-finished" - } - echo '[ -e /dev/zfs ]' > "${initqueuedir}/zfs.sh" + rootok=1 + # Make sure Dracut is happy that we have a root and will wait for ZFS + # modules to settle before mounting. + if [ -n "${wait_for_zfs}" ]; then + ln -s null /dev/root + echo '[ -e /dev/zfs ]' > "${hookdir}/initqueue/finished/zfs.sh" + fi +else + info "ZFS: no ZFS-on-root." fi diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-env-bootfs.service.in b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-env-bootfs.service.in index e143cb5ec1ed..34c88037cac2 100644 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-env-bootfs.service.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-env-bootfs.service.in @@ -8,7 +8,7 @@ Before=zfs-import.target [Service] Type=oneshot -ExecStart=/bin/sh -c "exec systemctl set-environment BOOTFS=$(@sbindir@/zpool list -H -o bootfs | grep -m1 -v '^-$')" +ExecStart=/bin/sh -c "exec systemctl set-environment BOOTFS=$(@sbindir@/zpool list -H -o bootfs | grep -m1 -vFx -)" [Install] WantedBy=zfs-import.target diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-generator.sh.in b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-generator.sh.in index e50b9530c4f0..56f7ca9785ba 100755 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-generator.sh.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-generator.sh.in @@ -1,5 +1,5 @@ #!/bin/sh -# shellcheck disable=SC2016,SC1004 +# shellcheck disable=SC2016,SC1004,SC2154 grep -wq debug /proc/cmdline && debug=1 [ -n "$debug" ] && echo "zfs-generator: starting" >> /dev/kmsg @@ -10,37 +10,17 @@ GENERATOR_DIR="$1" exit 1 } -[ -f /lib/dracut-lib.sh ] && dracutlib=/lib/dracut-lib.sh -[ -f /usr/lib/dracut/modules.d/99base/dracut-lib.sh ] && dracutlib=/usr/lib/dracut/modules.d/99base/dracut-lib.sh -command -v getarg >/dev/null 2>&1 || { - [ -n "$debug" ] && echo "zfs-generator: loading Dracut library from $dracutlib" >> /dev/kmsg - . "$dracutlib" -} - +# shellcheck source=zfs-lib.sh.in . /lib/dracut-zfs-lib.sh +decode_root_args || exit 0 -[ -z "$root" ] && root=$(getarg root=) -[ -z "$rootfstype" ] && rootfstype=$(getarg rootfstype=) -[ -z "$rootflags" ] && rootflags=$(getarg rootflags=) - -# If root is not ZFS= or zfs: or rootfstype is not zfs -# then we are not supposed to handle it. -[ "${root##zfs:}" = "${root}" ] && - [ "${root##ZFS=}" = "${root}" ] && - [ "$rootfstype" != "zfs" ] && - exit 0 - +[ -z "${rootflags}" ] && rootflags=$(getarg rootflags=) case ",${rootflags}," in *,zfsutil,*) ;; ,,) rootflags=zfsutil ;; *) rootflags="zfsutil,${rootflags}" ;; esac -if [ "${root}" != "zfs:AUTO" ]; then - root="${root##zfs:}" - root="${root##ZFS=}" -fi - [ -n "$debug" ] && echo "zfs-generator: writing extension for sysroot.mount to $GENERATOR_DIR/sysroot.mount.d/zfs-enhancement.conf" >> /dev/kmsg @@ -89,7 +69,7 @@ else _zfs_generator_cb() { dset="${1}" mpnt="${2}" - unit="sysroot$(echo "$mpnt" | tr '/' '-').mount" + unit="$(systemd-escape --suffix=mount -p "/sysroot${mpnt}")" { echo "[Unit]" diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-lib.sh.in b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-lib.sh.in index afd872d69d58..e44673c2d75b 100755 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-lib.sh.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-lib.sh.in @@ -1,74 +1,16 @@ #!/bin/sh +# shellcheck disable=SC2034 -command -v getarg >/dev/null || . /lib/dracut-lib.sh -command -v getargbool >/dev/null || { - # Compatibility with older Dracut versions. - # With apologies to the Dracut developers. - getargbool() { - _default="$1"; shift - ! _b=$(getarg "$@") && [ -z "$_b" ] && _b="$_default" - if [ -n "$_b" ]; then - [ "$_b" = "0" ] && return 1 - [ "$_b" = "no" ] && return 1 - [ "$_b" = "off" ] && return 1 - fi - return 0 - } -} +command -v getarg >/dev/null || . /lib/dracut-lib.sh || . /usr/lib/dracut/modules.d/99base/dracut-lib.sh -OLDIFS="${IFS}" -NEWLINE=" -" TAB=" " -ZPOOL_IMPORT_OPTS="" -if getargbool 0 zfs_force -y zfs.force -y zfsforce ; then +ZPOOL_IMPORT_OPTS= +if getargbool 0 zfs_force -y zfs.force -y zfsforce; then warn "ZFS: Will force-import pools if necessary." - ZPOOL_IMPORT_OPTS="${ZPOOL_IMPORT_OPTS} -f" + ZPOOL_IMPORT_OPTS=-f fi -# find_bootfs -# returns the first dataset with the bootfs attribute. -find_bootfs() { - IFS="${NEWLINE}" - for dataset in $(zpool list -H -o bootfs); do - case "${dataset}" in - "" | "-") - continue - ;; - "no pools available") - IFS="${OLDIFS}" - return 1 - ;; - *) - IFS="${OLDIFS}" - echo "${dataset}" - return 0 - ;; - esac - done - - IFS="${OLDIFS}" - return 1 -} - -# import_pool POOL -# imports the given zfs pool if it isn't imported already. -import_pool() { - pool="${1}" - - if ! zpool list -H "${pool}" > /dev/null 2>&1; then - info "ZFS: Importing pool ${pool}..." - # shellcheck disable=SC2086 - if ! zpool import -N ${ZPOOL_IMPORT_OPTS} "${pool}" ; then - warn "ZFS: Unable to import pool ${pool}" - return 1 - fi - fi - - return 0 -} - _mount_dataset_cb() { # shellcheck disable=SC2154 mount -o zfsutil -t zfs "${1}" "${NEWROOT}${2}" @@ -122,72 +64,57 @@ for_relevant_root_children() { ) } -# ask_for_password +# Parse root=, rootfstype=, return them decoded and normalised to zfs:AUTO for auto, plain dset for explicit # -# Wraps around plymouth ask-for-password and adds fallback to tty password ask -# if plymouth is not present. +# True if ZFS-on-root, false if we shouldn't # -# --cmd command -# Command to execute. Required. -# --prompt prompt -# Password prompt. Note that function already adds ':' at the end. -# Recommended. -# --tries n -# How many times repeat command on its failure. Default is 3. -# --ply-[cmd|prompt|tries] -# Command/prompt/tries specific for plymouth password ask only. -# --tty-[cmd|prompt|tries] -# Command/prompt/tries specific for tty password ask only. -# --tty-echo-off -# Turn off input echo before tty command is executed and turn on after. -# It's useful when password is read from stdin. -ask_for_password() { - ply_tries=3 - tty_tries=3 - while [ "$#" -gt 0 ]; do - case "$1" in - --cmd) ply_cmd="$2"; tty_cmd="$2"; shift;; - --ply-cmd) ply_cmd="$2"; shift;; - --tty-cmd) tty_cmd="$2"; shift;; - --prompt) ply_prompt="$2"; tty_prompt="$2"; shift;; - --ply-prompt) ply_prompt="$2"; shift;; - --tty-prompt) tty_prompt="$2"; shift;; - --tries) ply_tries="$2"; tty_tries="$2"; shift;; - --ply-tries) ply_tries="$2"; shift;; - --tty-tries) tty_tries="$2"; shift;; - --tty-echo-off) tty_echo_off=yes;; - *) echo "ask_for_password(): wrong opt '$1'" >&2;; +# Supported values: +# root= +# root=zfs +# root=zfs: +# root=zfs:AUTO +# +# root=ZFS=data/set +# root=zfs:data/set +# root=zfs:ZFS=data/set (as a side-effect; allowed but undocumented) +# +# rootfstype=zfs AND root=data/set <=> root=data/set +# rootfstype=zfs AND root= <=> root=zfs:AUTO +# +# '+'es in explicit dataset decoded to ' 's. +decode_root_args() { + if [ -n "$rootfstype" ]; then + [ "$rootfstype" = zfs ] + return + fi + + root=$(getarg root=) + rootfstype=$(getarg rootfstype=) + + # shellcheck disable=SC2249 + case "$root" in + ""|zfs|zfs:|zfs:AUTO) + root=zfs:AUTO + rootfstype=zfs + return 0 + ;; + + ZFS=*|zfs:*) + root="${root#zfs:}" + root="${root#ZFS=}" + root=$(echo "$root" | tr '+' ' ') + rootfstype=zfs + return 0 + ;; + esac + + if [ "$rootfstype" = "zfs" ]; then + case "$root" in + "") root=zfs:AUTO ;; + *) root=$(echo "$root" | tr '+' ' ') ;; esac - shift - done + return 0 + fi - { flock -s 9; - # Prompt for password with plymouth, if installed and running. - if plymouth --ping 2>/dev/null; then - plymouth ask-for-password \ - --prompt "$ply_prompt" --number-of-tries="$ply_tries" | \ - eval "$ply_cmd" - ret=$? - else - if [ "$tty_echo_off" = yes ]; then - stty_orig="$(stty -g)" - stty -echo - fi - - i=1 - while [ "$i" -le "$tty_tries" ]; do - [ -n "$tty_prompt" ] && \ - printf "%s [%i/%i]:" "$tty_prompt" "$i" "$tty_tries" >&2 - eval "$tty_cmd" && ret=0 && break - ret=$? - i=$((i+1)) - [ -n "$tty_prompt" ] && printf '\n' >&2 - done - unset i - [ "$tty_echo_off" = yes ] && stty "$stty_orig" - fi - } 9>/.console_lock - - [ "$ret" -ne 0 ] && echo "Wrong password" >&2 - return "$ret" + return 1 } diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-load-key.sh.in b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-load-key.sh.in index c974b3d9ec4c..d916f43b4e95 100755 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-load-key.sh.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-load-key.sh.in @@ -4,70 +4,61 @@ # only run this on systemd systems, we handle the decrypt in mount-zfs.sh in the mount hook otherwise [ -e /bin/systemctl ] || [ -e /usr/bin/systemctl ] || return 0 -# This script only gets executed on systemd systems, see mount-zfs.sh for non-systemd systems +# shellcheck source=zfs-lib.sh.in +. /lib/dracut-zfs-lib.sh -# import the libs now that we know the pool imported -[ -f /lib/dracut-lib.sh ] && dracutlib=/lib/dracut-lib.sh -[ -f /usr/lib/dracut/modules.d/99base/dracut-lib.sh ] && dracutlib=/usr/lib/dracut/modules.d/99base/dracut-lib.sh -# shellcheck source=./lib-zfs.sh.in -. "$dracutlib" - -# load the kernel command line vars -[ -z "$root" ] && root="$(getarg root=)" -# If root is not ZFS= or zfs: or rootfstype is not zfs then we are not supposed to handle it. -[ "${root##zfs:}" = "${root}" ] && [ "${root##ZFS=}" = "${root}" ] && [ "$rootfstype" != "zfs" ] && exit 0 +decode_root_args || return 0 # There is a race between the zpool import and the pre-mount hooks, so we wait for a pool to be imported -while [ "$(zpool list -H)" = "" ]; do - systemctl is-failed --quiet zfs-import-cache.service zfs-import-scan.service && exit 1 +while ! systemctl is-active --quiet zfs-import.target; do + systemctl is-failed --quiet zfs-import-cache.service zfs-import-scan.service && return 1 sleep 0.1s done -# run this after import as zfs-import-cache/scan service is confirmed good -# we do not overwrite the ${root} variable, but create a new one, BOOTFS, to hold the dataset -if [ "${root}" = "zfs:AUTO" ] ; then - BOOTFS="$(zpool list -H -o bootfs | awk '$1 != "-" {print; exit}')" -else - BOOTFS="${root##zfs:}" - BOOTFS="${BOOTFS##ZFS=}" +BOOTFS="$root" +if [ "$BOOTFS" = "zfs:AUTO" ]; then + BOOTFS="$(zpool get -Ho value bootfs | grep -m1 -vFx -)" fi -# if pool encryption is active and the zfs command understands '-o encryption' -if [ "$(zpool list -H -o feature@encryption "${BOOTFS%%/*}")" = 'active' ]; then - # if the root dataset has encryption enabled - ENCRYPTIONROOT="$(zfs get -H -o value encryptionroot "${BOOTFS}")" - if ! [ "${ENCRYPTIONROOT}" = "-" ]; then - KEYSTATUS="$(zfs get -H -o value keystatus "${ENCRYPTIONROOT}")" - # continue only if the key needs to be loaded - [ "$KEYSTATUS" = "unavailable" ] || exit 0 +[ "$(zpool get -Ho value feature@encryption "${BOOTFS%%/*}")" = 'active' ] || return 0 - KEYLOCATION="$(zfs get -H -o value keylocation "${ENCRYPTIONROOT}")" - case "${KEYLOCATION%%://*}" in - prompt) - for _ in 1 2 3; do - systemd-ask-password --no-tty "Encrypted ZFS password for ${BOOTFS}" | zfs load-key "${ENCRYPTIONROOT}" && break +_load_key_cb() { + dataset="$1" + + ENCRYPTIONROOT="$(zfs get -Ho value encryptionroot "${dataset}")" + [ "${ENCRYPTIONROOT}" = "-" ] && return 0 + + [ "$(zfs get -Ho value keystatus "${ENCRYPTIONROOT}")" = "unavailable" ] || return 0 + + KEYLOCATION="$(zfs get -Ho value keylocation "${ENCRYPTIONROOT}")" + case "${KEYLOCATION%%://*}" in + prompt) + for _ in 1 2 3; do + systemd-ask-password --no-tty "Encrypted ZFS password for ${dataset}" | zfs load-key "${ENCRYPTIONROOT}" && break + done + ;; + http*) + systemctl start network-online.target + zfs load-key "${ENCRYPTIONROOT}" + ;; + file) + KEYFILE="${KEYLOCATION#file://}" + [ -r "${KEYFILE}" ] || udevadm settle + [ -r "${KEYFILE}" ] || { + info "ZFS: Waiting for key ${KEYFILE} for ${ENCRYPTIONROOT}..." + for _ in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do + sleep 0.5s + [ -r "${KEYFILE}" ] && break done - ;; - http*) - systemctl start network-online.target - zfs load-key "${ENCRYPTIONROOT}" - ;; - file) - KEYFILE="${KEYLOCATION#file://}" - [ -r "${KEYFILE}" ] || udevadm settle - [ -r "${KEYFILE}" ] || { - info "Waiting for key ${KEYFILE} for ${ENCRYPTIONROOT}..." - for _ in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do - sleep 0.5s - [ -r "${KEYFILE}" ] && break - done - } - [ -r "${KEYFILE}" ] || warn "Key ${KEYFILE} for ${ENCRYPTIONROOT} hasn't appeared. Trying anyway." - zfs load-key "${ENCRYPTIONROOT}" - ;; - *) - zfs load-key "${ENCRYPTIONROOT}" - ;; - esac - fi -fi + } + [ -r "${KEYFILE}" ] || warn "ZFS: Key ${KEYFILE} for ${ENCRYPTIONROOT} hasn't appeared. Trying anyway." + zfs load-key "${ENCRYPTIONROOT}" + ;; + *) + zfs load-key "${ENCRYPTIONROOT}" + ;; + esac +} + +_load_key_cb "$BOOTFS" +for_relevant_root_children "$BOOTFS" _load_key_cb diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-needshutdown.sh.in b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-needshutdown.sh.in index dd6de30c2704..7fb825bc95a2 100755 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-needshutdown.sh.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-needshutdown.sh.in @@ -2,7 +2,7 @@ command -v getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh -if zpool list 2>&1 | grep -q 'no pools available' ; then +if [ -z "$(zpool get -Ho value name)" ]; then info "ZFS: No active pools, no need to export anything." else info "ZFS: There is an active pool, will export it." diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-rollback-bootfs.service.in b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-rollback-bootfs.service.in index 477b64f2b750..b4f5707516ce 100644 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-rollback-bootfs.service.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-rollback-bootfs.service.in @@ -1,14 +1,12 @@ [Unit] Description=Rollback bootfs just before it is mounted Requisite=zfs-import.target -After=zfs-import.target zfs-snapshot-bootfs.service +After=zfs-import.target dracut-pre-mount.service zfs-snapshot-bootfs.service Before=dracut-mount.service DefaultDependencies=no ConditionKernelCommandLine=bootfs.rollback [Service] -# ${BOOTFS} should have been set by zfs-env-bootfs.service Type=oneshot -ExecStartPre=/bin/test -n ${BOOTFS} -ExecStart=/bin/sh -c '. /lib/dracut-lib.sh; SNAPNAME="$(getarg bootfs.rollback)"; exec @sbindir@/zfs rollback -Rf "${BOOTFS}@${SNAPNAME:-%v}"' +ExecStart=/bin/sh -c '. /lib/dracut-zfs-lib.sh; decode_root_args || exit; [ "$root" = "zfs:AUTO" ] && root="$BOOTFS" SNAPNAME="$(getarg bootfs.rollback)"; exec @sbindir@/zfs rollback -Rf "$root@${SNAPNAME:-%v}"' RemainAfterExit=yes diff --git a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-snapshot-bootfs.service.in b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-snapshot-bootfs.service.in index 8eae04adfb99..afdba2c9d194 100644 --- a/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-snapshot-bootfs.service.in +++ b/sys/contrib/openzfs/contrib/dracut/90zfs/zfs-snapshot-bootfs.service.in @@ -1,14 +1,12 @@ [Unit] Description=Snapshot bootfs just before it is mounted Requisite=zfs-import.target -After=zfs-import.target +After=zfs-import.target dracut-pre-mount.service Before=dracut-mount.service DefaultDependencies=no ConditionKernelCommandLine=bootfs.snapshot [Service] -# ${BOOTFS} should have been set by zfs-env-bootfs.service Type=oneshot -ExecStartPre=/bin/test -n ${BOOTFS} -ExecStart=-/bin/sh -c '. /lib/dracut-lib.sh; SNAPNAME="$(getarg bootfs.snapshot)"; exec @sbindir@/zfs snapshot "${BOOTFS}@${SNAPNAME:-%v}"' +ExecStart=/bin/sh -c '. /lib/dracut-zfs-lib.sh; decode_root_args || exit; [ "$root" = "zfs:AUTO" ] && root="$BOOTFS" SNAPNAME="$(getarg bootfs.snapshot)"; exec @sbindir@/zfs snapshot "$root@${SNAPNAME:-%v}"' RemainAfterExit=yes diff --git a/sys/contrib/openzfs/contrib/dracut/Makefile.am b/sys/contrib/openzfs/contrib/dracut/Makefile.am index 09805277ffb0..f0c103b0a4da 100644 --- a/sys/contrib/openzfs/contrib/dracut/Makefile.am +++ b/sys/contrib/openzfs/contrib/dracut/Makefile.am @@ -1,6 +1,27 @@ -include $(top_srcdir)/config/Shellcheck.am +pkgdracut_02dir = $(dracutdir)/modules.d/02zfsexpandknowledge +pkgdracut_02_SCRIPTS = \ + %D%/02zfsexpandknowledge/module-setup.sh -SUBDIRS = 02zfsexpandknowledge 90zfs -SHELLCHECKDIRS = $(SUBDIRS) +pkgdracut_90dir = $(dracutdir)/modules.d/90zfs +pkgdracut_90_SCRIPTS = \ + %D%/90zfs/export-zfs.sh \ + %D%/90zfs/import-opts-generator.sh \ + %D%/90zfs/module-setup.sh \ + %D%/90zfs/mount-zfs.sh \ + %D%/90zfs/parse-zfs.sh \ + %D%/90zfs/zfs-generator.sh \ + %D%/90zfs/zfs-lib.sh \ + %D%/90zfs/zfs-load-key.sh \ + %D%/90zfs/zfs-needshutdown.sh -EXTRA_DIST = README.md +pkgdracut_90_DATA = \ + %D%/90zfs/zfs-env-bootfs.service \ + %D%/90zfs/zfs-rollback-bootfs.service \ + %D%/90zfs/zfs-snapshot-bootfs.service + +SUBSTFILES += $(pkgdracut_02_SCRIPTS) $(pkgdracut_90_SCRIPTS) $(pkgdracut_90_DATA) +SHELLCHECKSCRIPTS += $(pkgdracut_02_SCRIPTS) $(pkgdracut_90_SCRIPTS) +# Provided by /bin/sleep, and, again, every implementation of that supports this +$(call SHELLCHECK_OPTS,$(pkgdracut_90_SCRIPTS)): CHECKBASHISMS_IGNORE = -e 'sleep only takes one integer' -e 'sleep 0.' + +EXTRA_DIST += $(addprefix %D%/,README.md) diff --git a/sys/contrib/openzfs/contrib/dracut/README.md b/sys/contrib/openzfs/contrib/dracut/README.md index fc3d504ef705..b7cd8c8125eb 100644 --- a/sys/contrib/openzfs/contrib/dracut/README.md +++ b/sys/contrib/openzfs/contrib/dracut/README.md @@ -15,19 +15,21 @@ Encrypted datasets have keys loaded automatically or prompted for. If the root dataset contains children with `mountpoint=`s of `/etc`, `/bin`, `/lib*`, or `/usr`, they're mounted too. +For complete documentation, see `dracut.zfs(7)`. + ## cmdline -1. `root=` | Root dataset is… | Pools imported | - -------------------|----------------------------------------------------------|----------------| - *(empty)* | the first `bootfs=` after `zpool import -aN` | all | - `zfs:AUTO` | *(as above, but overriding other autoselection methods)* | all | - `ZFS=pool/dataset` | `pool/dataset` | `pool` | - `zfs:pool/dataset` | *(as above)* | `pool` | +1. `root=` | Root dataset is… | + ---------------------------|----------------------------------------------------------| + *(empty)* | the first `bootfs=` after `zpool import -aN` | + `zfs:AUTO`, `zfs:`, `zfs` | *(as above, but overriding other autoselection methods)* | + `ZFS=pool/dataset` | `pool/dataset` | + `zfs:pool/dataset` | *(as above)* | All `+`es are replaced with spaces (i.e. to boot from `root pool/data set`, pass `root=zfs:root+pool/data+set`). The dataset can be at any depth, including being the pool's root dataset (i.e. `root=zfs:pool`). - `rootfstype=zfs` is mostly equivalent to `root=zfs:AUTO`. + `rootfstype=zfs` is equivalent to `root=zfs:AUTO`, `rootfstype=zfs root=pool/dataset` is equivalent to `root=zfs:pool/dataset`. 2. `spl_hostid`: passed to `zgenhostid -f`, useful to override the `/etc/hostid` file baked into the initrd. diff --git a/sys/contrib/openzfs/contrib/initramfs/Makefile.am b/sys/contrib/openzfs/contrib/initramfs/Makefile.am index 57e8f5c3a485..6917b517f330 100644 --- a/sys/contrib/openzfs/contrib/initramfs/Makefile.am +++ b/sys/contrib/openzfs/contrib/initramfs/Makefile.am @@ -1,11 +1,39 @@ -include $(top_srcdir)/config/Shellcheck.am +i_tdir = /usr/share/initramfs-tools +dist_i_t_SCRIPTS = \ + %D%/zfsunlock -initrddir = /usr/share/initramfs-tools -dist_initrd_SCRIPTS = \ - zfsunlock +i_t_confhooks_ddir = $(i_tdir)/conf-hooks.d +dist_i_t_confhooks_d_DATA = \ + %D%/conf-hooks.d/zfs -SUBDIRS = conf.d conf-hooks.d hooks scripts -SHELLCHECKDIRS = hooks scripts -EXTRA_DIST = README.md +i_t_conf_ddir = $(i_tdir)/conf.d +dist_i_t_conf_d_DATA = \ + %D%/conf.d/zfs + + +i_t_hooksdir = $(i_tdir)/hooks +i_t_hooks_SCRIPTS = \ + %D%/hooks/zfs \ + %D%/hooks/zfsunlock + +SUBSTFILES += $(i_t_hooks_SCRIPTS) + + +i_t_scriptsdir = $(i_tdir)/scripts +dist_i_t_scripts_SCRIPTS = \ + %D%/scripts/zfs + + +i_t_scripts_localtopdir = $(i_t_scriptsdir)/local-top +dist_i_t_scripts_localtop_SCRIPTS = \ + %D%/scripts/local-top/zfs + + +i_t_check_scripts = $(dist_i_t_SCRIPTS) $(i_t_hooks_SCRIPTS) $(dist_i_t_scripts_SCRIPTS) $(dist_i_t_scripts_localtop_SCRIPTS) +SHELLCHECKSCRIPTS += $(i_t_check_scripts) +$(call SHELLCHECK_OPTS,$(i_t_check_scripts)): SHELLCHECK_SHELL = sh + + +EXTRA_DIST += $(addprefix %D%/,README.md) diff --git a/sys/contrib/openzfs/contrib/initramfs/conf-hooks.d/Makefile.am b/sys/contrib/openzfs/contrib/initramfs/conf-hooks.d/Makefile.am deleted file mode 100644 index f84ba5cc7e37..000000000000 --- a/sys/contrib/openzfs/contrib/initramfs/conf-hooks.d/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -confhooksddir = /usr/share/initramfs-tools/conf-hooks.d - -dist_confhooksd_DATA = \ - zfs diff --git a/sys/contrib/openzfs/contrib/initramfs/conf.d/Makefile.am b/sys/contrib/openzfs/contrib/initramfs/conf.d/Makefile.am deleted file mode 100644 index 5ef27e0aa1ce..000000000000 --- a/sys/contrib/openzfs/contrib/initramfs/conf.d/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -confddir = /usr/share/initramfs-tools/conf.d - -dist_confd_DATA = \ - zfs diff --git a/sys/contrib/openzfs/contrib/initramfs/hooks/Makefile.am b/sys/contrib/openzfs/contrib/initramfs/hooks/Makefile.am deleted file mode 100644 index 0cd1aafcd359..000000000000 --- a/sys/contrib/openzfs/contrib/initramfs/hooks/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -hooksdir = /usr/share/initramfs-tools/hooks - -hooks_SCRIPTS = \ - zfs \ - zfsunlock - -SUBSTFILES += $(hooks_SCRIPTS) diff --git a/sys/contrib/openzfs/contrib/initramfs/scripts/Makefile.am b/sys/contrib/openzfs/contrib/initramfs/scripts/Makefile.am deleted file mode 100644 index 444a5f374bfe..000000000000 --- a/sys/contrib/openzfs/contrib/initramfs/scripts/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -include $(top_srcdir)/config/Shellcheck.am - -scriptsdir = /usr/share/initramfs-tools/scripts - -dist_scripts_SCRIPTS = \ - zfs - -SUBDIRS = local-top - -SHELLCHECKDIRS = $(SUBDIRS) -SHELLCHECK_SHELL = sh diff --git a/sys/contrib/openzfs/contrib/initramfs/scripts/local-top/Makefile.am b/sys/contrib/openzfs/contrib/initramfs/scripts/local-top/Makefile.am deleted file mode 100644 index f3dc23129f09..000000000000 --- a/sys/contrib/openzfs/contrib/initramfs/scripts/local-top/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -include $(top_srcdir)/config/Shellcheck.am - -localtopdir = /usr/share/initramfs-tools/scripts/local-top - -dist_localtop_SCRIPTS = \ - zfs - diff --git a/sys/contrib/openzfs/contrib/initramfs/scripts/zfs b/sys/contrib/openzfs/contrib/initramfs/scripts/zfs index 85b00f9da86d..1c8c496a7ff4 100644 --- a/sys/contrib/openzfs/contrib/initramfs/scripts/zfs +++ b/sys/contrib/openzfs/contrib/initramfs/scripts/zfs @@ -328,7 +328,7 @@ mount_fs() # Need the _original_ datasets mountpoint! mountpoint=$(get_fs_value "$fs" mountpoint) - ZFS_CMD="mount -o zfsutil -t zfs" + ZFS_CMD="mount.zfs -o zfsutil" if [ "$mountpoint" = "legacy" ] || [ "$mountpoint" = "none" ]; then # Can't use the mountpoint property. Might be one of our # clones. Check the 'org.zol:mountpoint' property set in @@ -351,7 +351,7 @@ mount_fs() # If it's not a legacy filesystem, it can only be a # native one... if [ "$mountpoint" = "legacy" ]; then - ZFS_CMD="mount -t zfs" + ZFS_CMD="mount.zfs" fi fi @@ -919,7 +919,7 @@ mountroot() echo " not specified on the kernel command line." echo "" echo "Manually mount the root filesystem on $rootmnt and then exit." - echo "Hint: Try: mount -o zfsutil -t zfs ${ZFS_RPOOL-rpool}/ROOT/system $rootmnt" + echo "Hint: Try: mount.zfs -o zfsutil ${ZFS_RPOOL-rpool}/ROOT/system $rootmnt" shell fi diff --git a/sys/contrib/openzfs/contrib/pam_zfs_key/Makefile.am b/sys/contrib/openzfs/contrib/pam_zfs_key/Makefile.am index f0f2550afccb..aaa608b7da2b 100644 --- a/sys/contrib/openzfs/contrib/pam_zfs_key/Makefile.am +++ b/sys/contrib/openzfs/contrib/pam_zfs_key/Makefile.am @@ -1,19 +1,18 @@ -include $(top_srcdir)/config/Rules.am +%C%_pam_zfs_key_la_CFLAGS = $(AM_CFLAGS) +%C%_pam_zfs_key_la_CFLAGS += $(LIBCRYPTO_CFLAGS) -AM_CFLAGS += $(LIBCRYPTO_CFLAGS) +pammodule_LTLIBRARIES = %D%/pam_zfs_key.la -pammodule_LTLIBRARIES=pam_zfs_key.la +%C%_pam_zfs_key_la_SOURCES = %D%/pam_zfs_key.c -pam_zfs_key_la_SOURCES = pam_zfs_key.c +%C%_pam_zfs_key_la_LIBADD = \ + libnvpair.la \ + libuutil.la \ + libzfs.la \ + libzfs_core.la -pam_zfs_key_la_LIBADD = \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la \ - $(abs_top_builddir)/lib/libuutil/libuutil.la \ - $(abs_top_builddir)/lib/libzfs/libzfs.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la +%C%_pam_zfs_key_la_LIBADD += -lpam $(LIBCRYPTO_LIBS) -pam_zfs_key_la_LDFLAGS = -version-info 1:0:0 -avoid-version -module -shared +%C%_pam_zfs_key_la_LDFLAGS = -version-info 1:0:0 -avoid-version -module -shared -pam_zfs_key_la_LIBADD += -lpam $(LIBCRYPTO_LIBS) - -dist_pamconfigs_DATA = zfs_key +dist_pamconfigs_DATA = %D%/zfs_key diff --git a/sys/contrib/openzfs/contrib/pyzfs/Makefile.am b/sys/contrib/openzfs/contrib/pyzfs/Makefile.am index fa1bb32ce2eb..505cd3c8b355 100644 --- a/sys/contrib/openzfs/contrib/pyzfs/Makefile.am +++ b/sys/contrib/openzfs/contrib/pyzfs/Makefile.am @@ -1,10 +1,11 @@ -EXTRA_DIST = libzfs_core setup.py.in README LICENSE docs +EXTRA_DIST += $(addprefix %D%/,libzfs_core README LICENSE docs) +SUBSTFILES += %D%/setup.py if PYZFS_ENABLED -all: - -all-local: - $(PYTHON) setup.py build +ALL_LOCAL += pyzfs-all-local +pyzfs_V_1 = -v +pyzfs-all-local: %D%/setup.py + cd %D% && $(PYTHON) setup.py -q $(pyzfs_V_$(V)) egg_info -e . build # # On Debian (Ubuntu, and other downstream distros) the install location of @@ -24,17 +25,14 @@ all-local: # files are later created by manually loading the Python modules. # install-exec-local: - $(PYTHON) $(builddir)/setup.py install \ - --prefix $(prefix) \ - --root $(DESTDIR)/ \ - --install-lib $(pythonsitedir) \ - --single-version-externally-managed \ - --verbose + cd %D% && $(PYTHON) setup.py egg_info -e . install \ + --prefix $(prefix) \ + --root $(DESTDIR)/ \ + --install-lib $(pythonsitedir) \ + --single-version-externally-managed \ + --verbose -clean: clean-local - rm -rf build/ pyzfs.egg-info/ - -clean-local: - -check-local: all +CLEAN_LOCAL += pyzfs-clean-local +pyzfs-clean-local: + -$(RM) -r %D%/build/ %D%/pyzfs.egg-info/ endif diff --git a/sys/contrib/openzfs/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py b/sys/contrib/openzfs/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py index 2567f7ebf83d..9b1aea193f44 100644 --- a/sys/contrib/openzfs/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py +++ b/sys/contrib/openzfs/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py @@ -1903,6 +1903,8 @@ def test_send_to_ro_file(self): with self.assertRaises(lzc_exc.StreamIOError) as ctx: lzc.lzc_send(snap, None, fd) os.close(fd) + os.unlink(output.name) + self.assertEqual(ctx.exception.errno, errno.EBADF) def test_recv_full(self): diff --git a/sys/contrib/openzfs/contrib/pyzfs/setup.py.in b/sys/contrib/openzfs/contrib/pyzfs/setup.py.in index 934b3189ebe1..43a1accfaf02 100644 --- a/sys/contrib/openzfs/contrib/pyzfs/setup.py.in +++ b/sys/contrib/openzfs/contrib/pyzfs/setup.py.in @@ -13,9 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from __future__ import absolute_import, division, print_function - from setuptools import setup, find_packages +import os.path + +srcdir = "@abs_top_srcdir@/contrib/pyzfs" setup( name="pyzfs", @@ -44,7 +45,8 @@ setup( "libzfs_core", ], - packages=find_packages(), + packages=find_packages(where=srcdir), + package_dir={"": os.path.relpath(srcdir)}, include_package_data=True, install_requires=[ "cffi", diff --git a/sys/contrib/openzfs/contrib/zcp/Makefile.am b/sys/contrib/openzfs/contrib/zcp/Makefile.am index e6a777ad7ba7..759a9d529dc8 100644 --- a/sys/contrib/openzfs/contrib/zcp/Makefile.am +++ b/sys/contrib/openzfs/contrib/zcp/Makefile.am @@ -1 +1 @@ -EXTRA_DIST = autosnap.lua +EXTRA_DIST += $(addprefix %D%/,autosnap.lua) diff --git a/sys/contrib/openzfs/copy-builtin b/sys/contrib/openzfs/copy-builtin index cd6f259092ed..18cc741b58e7 100755 --- a/sys/contrib/openzfs/copy-builtin +++ b/sys/contrib/openzfs/copy-builtin @@ -43,32 +43,8 @@ config ZFS If unsure, say N. EOF -add_after() -{ - FILE="$1" - MARKER="$2" - NEW="$3" - - while IFS='' read -r LINE - do - printf "%s\n" "$LINE" - - if [ -n "$MARKER" ] && [ "$LINE" = "$MARKER" ] - then - printf "%s\n" "$NEW" - MARKER='' - if IFS='' read -r LINE - then - [ "$LINE" != "$NEW" ] && printf "%s\n" "$LINE" - fi - fi - done < "$FILE" > "$FILE.new" - - mv "$FILE.new" "$FILE" -} - -add_after "$KERNEL_DIR/fs/Kconfig" 'if BLOCK' 'source "fs/zfs/Kconfig"' -add_after "$KERNEL_DIR/fs/Makefile" 'endif' 'obj-$(CONFIG_ZFS) += zfs/' +sed -i '/source "fs\/ext2\/Kconfig\"/i\source "fs/zfs/Kconfig"' "$KERNEL_DIR/fs/Kconfig" +echo 'obj-$(CONFIG_ZFS) += zfs/' >> "$KERNEL_DIR/fs/Makefile" echo "$0: done. now you can build the kernel with ZFS support." >&2 echo "$0: make sure you enable ZFS support (CONFIG_ZFS) before building." >&2 diff --git a/sys/contrib/openzfs/etc/Makefile.am b/sys/contrib/openzfs/etc/Makefile.am index 179c2400978c..ffe5fad2b4a9 100644 --- a/sys/contrib/openzfs/etc/Makefile.am +++ b/sys/contrib/openzfs/etc/Makefile.am @@ -1,9 +1,95 @@ -include $(top_srcdir)/config/Shellcheck.am +sudoersddir = $(sysconfdir)/sudoers.d +sudoersd_DATA = \ + %D%/sudoers.d/zfs + +EXTRA_DIST += $(sudoersd_DATA) + + +sysconf_zfsdir = $(sysconfdir)/zfs + +dist_sysconf_zfs_DATA = \ + %D%/zfs/vdev_id.conf.alias.example \ + %D%/zfs/vdev_id.conf.multipath.example \ + %D%/zfs/vdev_id.conf.sas_direct.example \ + %D%/zfs/vdev_id.conf.sas_switch.example \ + %D%/zfs/vdev_id.conf.scsi.example + +sysconf_zfs_SCRIPTS = \ + %D%/zfs/zfs-functions + +SUBSTFILES += $(sysconf_zfs_SCRIPTS) +SHELLCHECKSCRIPTS += $(sysconf_zfs_SCRIPTS) +$(call SHELLCHECK_OPTS,$(sysconf_zfs_SCRIPTS)): SHELLCHECK_SHELL = sh -SUBDIRS = zfs sudoers.d -SHELLCHECKDIRS = default $(ZFS_INIT_SYSV) zfs if BUILD_LINUX -SUBDIRS += default $(ZFS_INIT_SYSTEMD) $(ZFS_INIT_SYSV) $(ZFS_MODULE_LOAD) +initconf_SCRIPTS = \ + %D%/default/zfs + +SUBSTFILES += $(initconf_SCRIPTS) +SHELLCHECKSCRIPTS += $(initconf_SCRIPTS) +$(call SHELLCHECK_OPTS,$(initconf_SCRIPTS)): SHELLCHECK_SHELL = sh + + +if INIT_SYSV +EXTRA_DIST += $(addprefix %D%/,init.d/README.md) + +init_SCRIPTS = \ + %D%/init.d/zfs-import \ + %D%/init.d/zfs-load-key \ + %D%/init.d/zfs-mount \ + %D%/init.d/zfs-share \ + %D%/init.d/zfs-zed + +SUBSTFILES += $(init_SCRIPTS) +SHELLCHECKSCRIPTS += $(init_SCRIPTS) +$(call SHELLCHECK_OPTS,$(init_SCRIPTS)): SHELLCHECK_SHELL = sh +endif + + +if INIT_SYSTEMD +dist_systemdpreset_DATA = \ + %D%/systemd/system/50-zfs.preset + +systemdunit_DATA = \ + %D%/systemd/system/zfs-import-cache.service \ + %D%/systemd/system/zfs-import-scan.service \ + %D%/systemd/system/zfs-import.target \ + %D%/systemd/system/zfs-mount.service \ + %D%/systemd/system/zfs-scrub-monthly@.timer \ + %D%/systemd/system/zfs-scrub-weekly@.timer \ + %D%/systemd/system/zfs-scrub@.service \ + %D%/systemd/system/zfs-share.service \ + %D%/systemd/system/zfs-volume-wait.service \ + %D%/systemd/system/zfs-volumes.target \ + %D%/systemd/system/zfs-zed.service \ + %D%/systemd/system/zfs.target + +SUBSTFILES += $(systemdunit_DATA) + +INSTALL_DATA_HOOKS += systemd-install-data-hook +systemd-install-data-hook: + $(MKDIR_P) "$(DESTDIR)$(systemdunitdir)" + ln -sf /dev/null "$(DESTDIR)$(systemdunitdir)/zfs-import.service" + + +systemdgenerator_PROGRAMS = \ + %D%/systemd/system-generators/zfs-mount-generator + +%C%_systemd_system_generators_zfs_mount_generator_SOURCES = \ + %D%/systemd/system-generators/zfs-mount-generator.c + +%C%_systemd_system_generators_zfs_mount_generator_LDADD = \ + libzfs.la + +%C%_systemd_system_generators_zfs_mount_generator_LDFLAGS = -pthread + +CPPCHECKTARGETS += $(systemdgenerator_PROGRAMS) +endif + + +if WANT_MODULES_LOAD_D +dist_modulesload_DATA = \ + %D%/modules-load.d/zfs.conf +endif endif -DIST_SUBDIRS = default init.d zfs systemd modules-load.d sudoers.d diff --git a/sys/contrib/openzfs/etc/default/Makefile.am b/sys/contrib/openzfs/etc/default/Makefile.am deleted file mode 100644 index 0f7c96698d45..000000000000 --- a/sys/contrib/openzfs/etc/default/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -initconf_SCRIPTS = zfs - -SUBSTFILES += $(initconf_SCRIPTS) - -SHELLCHECK_SHELL = sh diff --git a/sys/contrib/openzfs/etc/init.d/Makefile.am b/sys/contrib/openzfs/etc/init.d/Makefile.am deleted file mode 100644 index 625d0b91fd11..000000000000 --- a/sys/contrib/openzfs/etc/init.d/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -EXTRA_DIST += README.md - -init_SCRIPTS = zfs-import zfs-load-key zfs-mount zfs-share zfs-zed - -SUBSTFILES += $(init_SCRIPTS) - -SHELLCHECK_SHELL = sh diff --git a/sys/contrib/openzfs/etc/init.d/zfs-mount.in b/sys/contrib/openzfs/etc/init.d/zfs-mount.in index d196d1555a45..df28c6c951c5 100755 --- a/sys/contrib/openzfs/etc/init.d/zfs-mount.in +++ b/sys/contrib/openzfs/etc/init.d/zfs-mount.in @@ -63,7 +63,7 @@ do_depend() # Mount all datasets/filesystems do_mount() { - local verbose overlay i mntpt + local verbose overlay check_boolean "$VERBOSE_MOUNT" && verbose=v check_boolean "$DO_OVERLAY_MOUNTS" && overlay=O @@ -71,102 +71,18 @@ do_mount() zfs_action "Mounting ZFS filesystem(s)" \ "$ZFS" mount "-a$verbose$overlay" "$MOUNT_EXTRA_OPTIONS" - # Require each volume/filesystem to have 'noauto' and no fsck - # option. This shouldn't really be necessary, as long as one - # can get zfs-import to run sufficiently early on in the boot - # process - before local mounts. This is just here in case/if - # this isn't possible. - check_boolean "$VERBOSE_MOUNT" && \ - zfs_log_begin_msg "Mounting volumes and filesystems registered in fstab" - - read_mtab "^/dev/(zd|zvol)" - read_fstab "^/dev/(zd|zvol)" - i=0; var="FSTAB_0" - while [ -n "$(eval echo "\$$var")" ] - do - mntpt=$(eval echo "\$$var") - dev=$(eval echo "\$FSTAB_dev_$i") - if ! in_mtab "$mntpt" && ! is_mounted "$mntpt" && [ -e "$dev" ] - then - check_boolean "$VERBOSE_MOUNT" && \ - zfs_log_progress_msg "$mntpt " - fsck "$dev" && mount "$mntpt" - fi - - i=$((i + 1)) - var=$(eval echo "FSTAB_$i") - done - - read_mtab "[[:space:]]zfs[[:space:]]" - read_fstab "[[:space:]]zfs[[:space:]]" - i=0; var=$(eval echo "FSTAB_$i") - while [ -n "$(eval echo "\$$var")" ] - do - mntpt=$(eval echo "\$$var") - if ! in_mtab "$mntpt" && ! is_mounted "$mntpt" - then - check_boolean "$VERBOSE_MOUNT" && \ - zfs_log_progress_msg "$mntpt " - mount "$mntpt" - fi - - i=$((i + 1)) - var=$(eval echo "FSTAB_$i") - done - check_boolean "$VERBOSE_MOUNT" && zfs_log_end_msg 0 - return 0 } # Unmount all filesystems do_unmount() { - local i var mntpt - # This shouldn't really be necessary, as long as one can get # zfs-import to run sufficiently late in the shutdown/reboot process # - after unmounting local filesystems. This is just here in case/if # this isn't possible. zfs_action "Unmounting ZFS filesystems" "$ZFS" unmount -a - check_boolean "$VERBOSE_MOUNT" && \ - zfs_log_begin_msg "Unmounting volumes and filesystems registered in fstab" - - read_mtab "^/dev/(zd|zvol)" - read_fstab "^/dev/(zd|zvol)" - i=0; var="FSTAB_0" - while [ -n "$(eval echo "\$$var")" ] - do - mntpt=$(eval echo "\$$var") - dev=$(eval echo "\$FSTAB_dev_$i") - if in_mtab "$mntpt" - then - check_boolean "$VERBOSE_MOUNT" && \ - zfs_log_progress_msg "$mntpt " - umount "$mntpt" - fi - - i=$((i + 1)) - var=$(eval echo "FSTAB_$i") - done - - read_mtab "[[:space:]]zfs[[:space:]]" - read_fstab "[[:space:]]zfs[[:space:]]" - i=0; var="FSTAB_0" - while [ -n "$(eval echo "\$$var")" ] - do - mntpt=$(eval echo "\$$var") - if in_mtab "$mntpt"; then - check_boolean "$VERBOSE_MOUNT" && \ - zfs_log_progress_msg "$mntpt " - umount "$mntpt" - fi - - i=$((i + 1)) - var=$(eval echo "FSTAB_$i") - done - check_boolean "$VERBOSE_MOUNT" && zfs_log_end_msg 0 - return 0 } diff --git a/sys/contrib/openzfs/etc/init.d/zfs-zed.in b/sys/contrib/openzfs/etc/init.d/zfs-zed.in index 47f742259b27..e9cf8867403c 100755 --- a/sys/contrib/openzfs/etc/init.d/zfs-zed.in +++ b/sys/contrib/openzfs/etc/init.d/zfs-zed.in @@ -69,8 +69,7 @@ do_stop() then # No pools imported, it is/should be safe/possible to # unload modules. - zfs_action "Unloading modules" rmmod zfs zunicode \ - zavl zcommon znvpair zlua spl + zfs_action "Unloading modules" rmmod zfs spl return "$?" fi } diff --git a/sys/contrib/openzfs/etc/modules-load.d/.gitignore b/sys/contrib/openzfs/etc/modules-load.d/.gitignore deleted file mode 100644 index fee921708337..000000000000 --- a/sys/contrib/openzfs/etc/modules-load.d/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.conf diff --git a/sys/contrib/openzfs/etc/modules-load.d/Makefile.am b/sys/contrib/openzfs/etc/modules-load.d/Makefile.am deleted file mode 100644 index 8a2955767b1e..000000000000 --- a/sys/contrib/openzfs/etc/modules-load.d/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -dist_modulesload_DATA = \ - zfs.conf diff --git a/sys/contrib/openzfs/etc/sudoers.d/Makefile.am b/sys/contrib/openzfs/etc/sudoers.d/Makefile.am deleted file mode 100644 index 6f7ac8dbfd61..000000000000 --- a/sys/contrib/openzfs/etc/sudoers.d/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -sudoersddir = $(sysconfdir)/sudoers.d -sudoersd_DATA = zfs - -EXTRA_DIST = \ - zfs diff --git a/sys/contrib/openzfs/etc/systemd/Makefile.am b/sys/contrib/openzfs/etc/systemd/Makefile.am deleted file mode 100644 index 66232a5ff197..000000000000 --- a/sys/contrib/openzfs/etc/systemd/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -include $(top_srcdir)/config/Shellcheck.am - -SUBDIRS = system system-generators -SHELLCHECKDIRS = system-generators diff --git a/sys/contrib/openzfs/etc/systemd/system-generators/Makefile.am b/sys/contrib/openzfs/etc/systemd/system-generators/Makefile.am deleted file mode 100644 index e5920bf39203..000000000000 --- a/sys/contrib/openzfs/etc/systemd/system-generators/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -systemdgenerator_PROGRAMS = \ - zfs-mount-generator - -zfs_mount_generator_SOURCES = \ - zfs-mount-generator.c - -zfs_mount_generator_LDADD = \ - $(abs_top_builddir)/lib/libzfs/libzfs.la - -zfs_mount_generator_LDFLAGS = -pthread - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/etc/systemd/system/.gitignore b/sys/contrib/openzfs/etc/systemd/system/.gitignore index 4813c65a25a8..95d33fdd436d 100644 --- a/sys/contrib/openzfs/etc/systemd/system/.gitignore +++ b/sys/contrib/openzfs/etc/systemd/system/.gitignore @@ -1,4 +1,3 @@ *.service *.target -*.preset *.timer diff --git a/sys/contrib/openzfs/etc/systemd/system/50-zfs.preset.in b/sys/contrib/openzfs/etc/systemd/system/50-zfs.preset similarity index 100% rename from sys/contrib/openzfs/etc/systemd/system/50-zfs.preset.in rename to sys/contrib/openzfs/etc/systemd/system/50-zfs.preset diff --git a/sys/contrib/openzfs/etc/systemd/system/Makefile.am b/sys/contrib/openzfs/etc/systemd/system/Makefile.am deleted file mode 100644 index 5e65e1db420c..000000000000 --- a/sys/contrib/openzfs/etc/systemd/system/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am - -systemdpreset_DATA = \ - 50-zfs.preset - -systemdunit_DATA = \ - zfs-zed.service \ - zfs-import-cache.service \ - zfs-import-scan.service \ - zfs-mount.service \ - zfs-share.service \ - zfs-volume-wait.service \ - zfs-import.target \ - zfs-volumes.target \ - zfs.target \ - zfs-scrub-monthly@.timer \ - zfs-scrub-weekly@.timer \ - zfs-scrub@.service - -SUBSTFILES += $(systemdpreset_DATA) $(systemdunit_DATA) - -install-data-hook: - $(MKDIR_P) "$(DESTDIR)$(systemdunitdir)" - ln -sf /dev/null "$(DESTDIR)$(systemdunitdir)/zfs-import.service" diff --git a/sys/contrib/openzfs/etc/zfs/Makefile.am b/sys/contrib/openzfs/etc/zfs/Makefile.am deleted file mode 100644 index 8a67d548bf7e..000000000000 --- a/sys/contrib/openzfs/etc/zfs/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am -include $(top_srcdir)/config/Shellcheck.am - -pkgsysconfdir = $(sysconfdir)/zfs - -dist_pkgsysconf_DATA = \ - vdev_id.conf.alias.example \ - vdev_id.conf.sas_direct.example \ - vdev_id.conf.sas_switch.example \ - vdev_id.conf.multipath.example \ - vdev_id.conf.scsi.example - -pkgsysconf_SCRIPTS = \ - zfs-functions - -SUBSTFILES += $(pkgsysconf_SCRIPTS) - -SHELLCHECK_SHELL = sh diff --git a/sys/contrib/openzfs/include/Makefile.am b/sys/contrib/openzfs/include/Makefile.am index 4da43afd850d..eee989d4a150 100644 --- a/sys/contrib/openzfs/include/Makefile.am +++ b/sys/contrib/openzfs/include/Makefile.am @@ -1,4 +1,10 @@ -SUBDIRS = sys os +if BUILD_LINUX +include $(srcdir)/%D%/os/linux/Makefile.am +endif +if BUILD_FREEBSD +include $(srcdir)/%D%/os/freebsd/Makefile.am +endif + COMMON_H = \ cityhash.h \ @@ -7,27 +13,187 @@ COMMON_H = \ zfs_deleg.h \ zfs_fletcher.h \ zfs_namecheck.h \ - zfs_prop.h + zfs_prop.h \ + \ + sys/abd.h \ + sys/abd_impl.h \ + sys/aggsum.h \ + sys/arc.h \ + sys/arc_impl.h \ + sys/avl.h \ + sys/avl_impl.h \ + sys/bitops.h \ + sys/blkptr.h \ + sys/bplist.h \ + sys/bpobj.h \ + sys/bptree.h \ + sys/bqueue.h \ + sys/btree.h \ + sys/dataset_kstats.h \ + sys/dbuf.h \ + sys/ddt.h \ + sys/dmu.h \ + sys/dmu_impl.h \ + sys/dmu_objset.h \ + sys/dmu_recv.h \ + sys/dmu_redact.h \ + sys/dmu_send.h \ + sys/dmu_traverse.h \ + sys/dmu_tx.h \ + sys/dmu_zfetch.h \ + sys/dnode.h \ + sys/dsl_bookmark.h \ + sys/dsl_crypt.h \ + sys/dsl_dataset.h \ + sys/dsl_deadlist.h \ + sys/dsl_deleg.h \ + sys/dsl_destroy.h \ + sys/dsl_dir.h \ + sys/dsl_pool.h \ + sys/dsl_prop.h \ + sys/dsl_scan.h \ + sys/dsl_synctask.h \ + sys/dsl_userhold.h \ + sys/edonr.h \ + sys/efi_partition.h \ + sys/frame.h \ + sys/hkdf.h \ + sys/metaslab.h \ + sys/metaslab_impl.h \ + sys/mmp.h \ + sys/mntent.h \ + sys/mod.h \ + sys/multilist.h \ + sys/nvpair.h \ + sys/nvpair_impl.h \ + sys/objlist.h \ + sys/pathname.h \ + sys/qat.h \ + sys/range_tree.h \ + sys/rrwlock.h \ + sys/sa.h \ + sys/sa_impl.h \ + sys/skein.h \ + sys/spa.h \ + sys/spa_boot.h \ + sys/spa_checkpoint.h \ + sys/spa_checksum.h \ + sys/spa_impl.h \ + sys/spa_log_spacemap.h \ + sys/space_map.h \ + sys/space_reftree.h \ + sys/sysevent.h \ + sys/txg.h \ + sys/txg_impl.h \ + sys/u8_textprep.h \ + sys/u8_textprep_data.h \ + sys/uberblock.h \ + sys/uberblock_impl.h \ + sys/uio_impl.h \ + sys/unique.h \ + sys/uuid.h \ + sys/vdev.h \ + sys/vdev_disk.h \ + sys/vdev_draid.h \ + sys/vdev_file.h \ + sys/vdev_impl.h \ + sys/vdev_indirect_births.h \ + sys/vdev_indirect_mapping.h \ + sys/vdev_initialize.h \ + sys/vdev_raidz.h \ + sys/vdev_raidz_impl.h \ + sys/vdev_rebuild.h \ + sys/vdev_removal.h \ + sys/vdev_trim.h \ + sys/xvattr.h \ + sys/zap.h \ + sys/zap_impl.h \ + sys/zap_leaf.h \ + sys/zcp.h \ + sys/zcp_global.h \ + sys/zcp_iter.h \ + sys/zcp_prop.h \ + sys/zcp_set.h \ + sys/zfeature.h \ + sys/zfs_acl.h \ + sys/zfs_bootenv.h \ + sys/zfs_context.h \ + sys/zfs_debug.h \ + sys/zfs_delay.h \ + sys/zfs_file.h \ + sys/zfs_fuid.h \ + sys/zfs_project.h \ + sys/zfs_quota.h \ + sys/zfs_racct.h \ + sys/zfs_ratelimit.h \ + sys/zfs_refcount.h \ + sys/zfs_rlock.h \ + sys/zfs_sa.h \ + sys/zfs_stat.h \ + sys/zfs_sysfs.h \ + sys/zfs_vfsops.h \ + sys/zfs_vnops.h \ + sys/zfs_znode.h \ + sys/zil.h \ + sys/zil_impl.h \ + sys/zio.h \ + sys/zio_checksum.h \ + sys/zio_compress.h \ + sys/zio_crypt.h \ + sys/zio_impl.h \ + sys/zio_priority.h \ + sys/zrlock.h \ + sys/zthr.h \ + \ + sys/crypto/api.h \ + sys/crypto/common.h \ + sys/crypto/icp.h \ + \ + sys/fm/protocol.h \ + sys/fm/util.h \ + sys/fm/fs/zfs.h \ + \ + sys/fs/zfs.h \ + \ + sys/lua/lauxlib.h \ + sys/lua/lua.h \ + sys/lua/luaconf.h \ + sys/lua/lualib.h \ + \ + sys/sysevent/dev.h \ + sys/sysevent/eventdefs.h \ + \ + sys/zstd/zstd.h + + +KERNEL_H = \ + sys/zfs_ioctl.h \ + sys/zfs_ioctl_impl.h \ + sys/zfs_onexit.h \ + sys/zvol.h \ + sys/zvol_impl.h + USER_H = \ libnvpair.h \ - libuutil_common.h \ libuutil.h \ + libuutil_common.h \ libuutil_impl.h \ libzfs.h \ - libzfsbootenv.h \ libzfs_core.h \ + libzfsbootenv.h \ libzutil.h \ thread_pool.h + if CONFIG_USER libzfsdir = $(includedir)/libzfs -libzfs_HEADERS = $(COMMON_H) $(USER_H) +nobase_libzfs_HEADERS = $(COMMON_H) $(USER_H) endif +kerneldir = $(prefix)/src/zfs-$(VERSION)/include if CONFIG_KERNEL if BUILD_LINUX -kerneldir = @prefix@/src/zfs-$(VERSION)/include -kernel_HEADERS = $(COMMON_H) +nobase_kernel_HEADERS = $(COMMON_H) $(KERNEL_H) endif endif diff --git a/sys/contrib/openzfs/include/libzfs.h b/sys/contrib/openzfs/include/libzfs.h index c0e53b88a636..04f464d12faf 100644 --- a/sys/contrib/openzfs/include/libzfs.h +++ b/sys/contrib/openzfs/include/libzfs.h @@ -35,6 +35,7 @@ #define _LIBZFS_H extern __attribute__((visibility("default"))) #include +#include #include #include #include @@ -878,37 +879,25 @@ _LIBZFS_H void zfs_adjust_mount_options(zfs_handle_t *zhp, const char *mntpoint, /* * Share support functions. + * + * enum sa_protocol * lists are terminated with SA_NO_PROTOCOL, + * NULL means "all/any known to this libzfs". */ -_LIBZFS_H boolean_t zfs_is_shared(zfs_handle_t *); -_LIBZFS_H int zfs_share(zfs_handle_t *); -_LIBZFS_H int zfs_unshare(zfs_handle_t *); +#define SA_NO_PROTOCOL -1 -/* - * Protocol-specific share support functions. - */ -_LIBZFS_H boolean_t zfs_is_shared_nfs(zfs_handle_t *, char **); -_LIBZFS_H boolean_t zfs_is_shared_smb(zfs_handle_t *, char **); -_LIBZFS_H int zfs_share_nfs(zfs_handle_t *); -_LIBZFS_H int zfs_share_smb(zfs_handle_t *); -_LIBZFS_H int zfs_shareall(zfs_handle_t *); -_LIBZFS_H int zfs_unshare_nfs(zfs_handle_t *, const char *); -_LIBZFS_H int zfs_unshare_smb(zfs_handle_t *, const char *); -_LIBZFS_H int zfs_unshareall_nfs(zfs_handle_t *); -_LIBZFS_H int zfs_unshareall_smb(zfs_handle_t *); -_LIBZFS_H int zfs_unshareall_bypath(zfs_handle_t *, const char *); -_LIBZFS_H int zfs_unshareall_bytype(zfs_handle_t *, const char *, const char *); -_LIBZFS_H int zfs_unshareall(zfs_handle_t *); -_LIBZFS_H int zfs_deleg_share_nfs(libzfs_handle_t *, char *, char *, char *, - void *, void *, int, zfs_share_op_t); -_LIBZFS_H void zfs_commit_nfs_shares(void); -_LIBZFS_H void zfs_commit_smb_shares(void); -_LIBZFS_H void zfs_commit_all_shares(void); -_LIBZFS_H void zfs_commit_shares(const char *); +_LIBZFS_H boolean_t zfs_is_shared(zfs_handle_t *zhp, char **where, + const enum sa_protocol *proto); +_LIBZFS_H int zfs_share(zfs_handle_t *zhp, const enum sa_protocol *proto); +_LIBZFS_H int zfs_unshare(zfs_handle_t *zhp, const char *mountpoint, + const enum sa_protocol *proto); +_LIBZFS_H int zfs_unshareall(zfs_handle_t *zhp, + const enum sa_protocol *proto); +_LIBZFS_H void zfs_commit_shares(const enum sa_protocol *proto); _LIBZFS_H int zfs_nicestrtonum(libzfs_handle_t *, const char *, uint64_t *); /* - * Utility functions to run an _LIBZFS_Hal process. + * Utility functions to run an external process. */ #define STDOUT_VERBOSE 0x01 #define STDERR_VERBOSE 0x02 diff --git a/sys/contrib/openzfs/include/libzutil.h b/sys/contrib/openzfs/include/libzutil.h index c0a660ea7067..d0d5632c027a 100644 --- a/sys/contrib/openzfs/include/libzutil.h +++ b/sys/contrib/openzfs/include/libzutil.h @@ -97,8 +97,8 @@ _LIBZUTIL_H int zfs_append_partition(char *path, size_t max_len); _LIBZUTIL_H int zfs_resolve_shortname(const char *name, char *path, size_t pathlen); -_LIBZUTIL_H char *zfs_strip_partition(char *); -_LIBZUTIL_H char *zfs_strip_path(char *); +_LIBZUTIL_H char *zfs_strip_partition(const char *); +_LIBZUTIL_H const char *zfs_strip_path(const char *); _LIBZUTIL_H int zfs_strcmp_pathname(const char *, const char *, int); diff --git a/sys/contrib/openzfs/include/os/Makefile.am b/sys/contrib/openzfs/include/os/Makefile.am deleted file mode 100644 index 7eab1abde984..000000000000 --- a/sys/contrib/openzfs/include/os/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -if BUILD_LINUX -SUBDIRS = linux -endif -if BUILD_FREEBSD -SUBDIRS = freebsd -endif diff --git a/sys/contrib/openzfs/include/os/freebsd/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/Makefile.am index 3c87d4a0e791..5ddb7cd710b8 100644 --- a/sys/contrib/openzfs/include/os/freebsd/Makefile.am +++ b/sys/contrib/openzfs/include/os/freebsd/Makefile.am @@ -1 +1,90 @@ -SUBDIRS = linux spl zfs +noinst_HEADERS = \ + %D%/linux/compiler.h \ + %D%/linux/types.h \ + \ + %D%/spl/acl/acl_common.h \ + \ + %D%/spl/rpc/xdr.h \ + \ + %D%/spl/sys/acl.h \ + %D%/spl/sys/acl_impl.h \ + %D%/spl/sys/atomic.h \ + %D%/spl/sys/byteorder.h \ + %D%/spl/sys/callb.h \ + %D%/spl/sys/ccompat.h \ + %D%/spl/sys/ccompile.h \ + %D%/spl/sys/cmn_err.h \ + %D%/spl/sys/condvar.h \ + %D%/spl/sys/cred.h \ + %D%/spl/sys/ctype.h \ + %D%/spl/sys/debug.h \ + %D%/spl/sys/dirent.h \ + %D%/spl/sys/disp.h \ + %D%/spl/sys/dkio.h \ + %D%/spl/sys/extdirent.h \ + %D%/spl/sys/fcntl.h \ + %D%/spl/sys/file.h \ + %D%/spl/sys/freebsd_rwlock.h \ + %D%/spl/sys/idmap.h \ + %D%/spl/sys/inttypes.h \ + %D%/spl/sys/isa_defs.h \ + %D%/spl/sys/kmem.h \ + %D%/spl/sys/kmem_cache.h \ + %D%/spl/sys/kstat.h \ + %D%/spl/sys/list.h \ + %D%/spl/sys/list_impl.h \ + %D%/spl/sys/lock.h \ + %D%/spl/sys/misc.h \ + %D%/spl/sys/mod_os.h \ + %D%/spl/sys/mode.h \ + %D%/spl/sys/mount.h \ + %D%/spl/sys/mutex.h \ + %D%/spl/sys/param.h \ + %D%/spl/sys/policy.h \ + %D%/spl/sys/proc.h \ + %D%/spl/sys/processor.h \ + %D%/spl/sys/procfs_list.h \ + %D%/spl/sys/random.h \ + %D%/spl/sys/rwlock.h \ + %D%/spl/sys/sdt.h \ + %D%/spl/sys/sid.h \ + %D%/spl/sys/sig.h \ + %D%/spl/sys/simd.h \ + %D%/spl/sys/simd_x86.h \ + %D%/spl/sys/spl_condvar.h \ + %D%/spl/sys/string.h \ + %D%/spl/sys/sunddi.h \ + %D%/spl/sys/sysmacros.h \ + %D%/spl/sys/systeminfo.h \ + %D%/spl/sys/systm.h \ + %D%/spl/sys/taskq.h \ + %D%/spl/sys/thread.h \ + %D%/spl/sys/time.h \ + %D%/spl/sys/timer.h \ + %D%/spl/sys/trace.h \ + %D%/spl/sys/trace_zfs.h \ + %D%/spl/sys/types.h \ + %D%/spl/sys/types32.h \ + %D%/spl/sys/uio.h \ + %D%/spl/sys/uuid.h \ + %D%/spl/sys/vfs.h \ + %D%/spl/sys/vm.h \ + %D%/spl/sys/vmsystm.h \ + %D%/spl/sys/vnode.h \ + %D%/spl/sys/vnode_impl.h \ + %D%/spl/sys/wmsum.h \ + %D%/spl/sys/zmod.h \ + %D%/spl/sys/zone.h \ + \ + %D%/zfs/sys/freebsd_crypto.h \ + %D%/zfs/sys/sha2.h \ + %D%/zfs/sys/vdev_os.h \ + %D%/zfs/sys/zfs_bootenv_os.h \ + %D%/zfs/sys/zfs_context_os.h \ + %D%/zfs/sys/zfs_ctldir.h \ + %D%/zfs/sys/zfs_dir.h \ + %D%/zfs/sys/zfs_ioctl_compat.h \ + %D%/zfs/sys/zfs_vfsops_os.h \ + %D%/zfs/sys/zfs_vnops_os.h \ + %D%/zfs/sys/zfs_znode_impl.h \ + %D%/zfs/sys/zpl.h diff --git a/sys/contrib/openzfs/include/os/freebsd/linux/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/linux/Makefile.am deleted file mode 100644 index 00cff7f5dc65..000000000000 --- a/sys/contrib/openzfs/include/os/freebsd/linux/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -KERNEL_H = \ - compiler.h \ - types.h - -noinst_HEADERS = $(KERNEL_H) diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/spl/Makefile.am deleted file mode 100644 index b321825cb77e..000000000000 --- a/sys/contrib/openzfs/include/os/freebsd/spl/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = acl rpc sys diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/acl/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/spl/acl/Makefile.am deleted file mode 100644 index 5c0698d02ea6..000000000000 --- a/sys/contrib/openzfs/include/os/freebsd/spl/acl/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -KERNEL_H = \ - acl_common.h - -noinst_HEADERS = $(KERNEL_H) diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/rpc/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/spl/rpc/Makefile.am deleted file mode 100644 index f6faf4b188be..000000000000 --- a/sys/contrib/openzfs/include/os/freebsd/spl/rpc/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -KERNEL_H = \ - xdr.h - -noinst_HEADERS = $(KERNEL_H) diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/spl/sys/Makefile.am deleted file mode 100644 index 7d5081a4c25f..000000000000 --- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/Makefile.am +++ /dev/null @@ -1,73 +0,0 @@ -KERNEL_H = \ - acl_impl.h \ - acl.h \ - atomic.h \ - byteorder.h \ - callb.h \ - ccompat.h \ - ccompile.h \ - cmn_err.h \ - condvar.h \ - cred.h \ - ctype.h \ - debug.h \ - dirent.h \ - disp.h \ - dkio.h \ - extdirent.h \ - fcntl.h \ - file.h \ - freebsd_rwlock.h \ - idmap.h \ - inttypes.h \ - isa_defs.h \ - kmem_cache.h \ - kmem.h \ - kstat.h \ - list_impl.h \ - list.h \ - lock.h \ - Makefile.am \ - misc.h \ - mod_os.h \ - mode.h \ - mount.h \ - mutex.h \ - param.h \ - policy.h \ - proc.h \ - processor.h \ - procfs_list.h \ - random.h \ - rwlock.h \ - sdt.h \ - sid.h \ - sig.h \ - simd_x86.h \ - simd.h \ - spl_condvar.h \ - string.h \ - sunddi.h \ - sysmacros.h \ - systeminfo.h \ - systm.h \ - taskq.h \ - thread.h \ - time.h \ - timer.h \ - trace_zfs.h \ - trace.h \ - types.h \ - types32.h \ - uio.h \ - uuid.h \ - vfs.h \ - vm.h \ - vmsystm.h \ - vnode_impl.h \ - vnode.h \ - wmsum.h \ - zmod.h \ - zone.h - -noinst_HEADERS = $(KERNEL_H) diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h index 23e637983475..a46a3a18be14 100644 --- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h +++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h @@ -42,9 +42,6 @@ extern "C" { #endif #define EXPORT_SYMBOL(x) -#define MODULE_AUTHOR(s) -#define MODULE_DESCRIPTION(s) -#define MODULE_LICENSE(s) #define module_param(a, b, c) #define module_param_call(a, b, c, d, e) #define module_param_named(a, b, c, d) diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/misc.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/misc.h index 3481507d2c33..2e4efc60544a 100644 --- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/misc.h +++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/misc.h @@ -52,8 +52,6 @@ struct opensolaris_utsname { char *machine; }; -extern char hw_serial[11]; - #define task_io_account_read(n) #define task_io_account_write(n) diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/mod_os.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/mod_os.h index 293bd7d2b983..3a9ebbfc3bc4 100644 --- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/mod_os.h +++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/mod_os.h @@ -31,11 +31,6 @@ #include -#define ZFS_MODULE_DESCRIPTION(s) -#define ZFS_MODULE_AUTHOR(s) -#define ZFS_MODULE_LICENSE(s) -#define ZFS_MODULE_VERSION(s) - #define EXPORT_SYMBOL(x) #define module_param(a, b, c) #define MODULE_PARM_DESC(a, b) diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/sunddi.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/sunddi.h index bfbc3e10a1d2..28d40121d92e 100644 --- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/sunddi.h +++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/sunddi.h @@ -48,7 +48,6 @@ typedef int ddi_devid_t; #define ddi_prop_free(x) (void)0 #define ddi_root_node() (void)0 -extern int ddi_strtoul(const char *, char **, int, unsigned long *); extern int ddi_strtol(const char *, char **, int, long *); extern int ddi_strtoull(const char *, char **, int, unsigned long long *); extern int ddi_strtoll(const char *, char **, int, long long *); diff --git a/sys/contrib/openzfs/include/os/freebsd/spl/sys/vnode.h b/sys/contrib/openzfs/include/os/freebsd/spl/sys/vnode.h index d2c900854acb..e0f79a1116b2 100644 --- a/sys/contrib/openzfs/include/os/freebsd/spl/sys/vnode.h +++ b/sys/contrib/openzfs/include/os/freebsd/spl/sys/vnode.h @@ -136,17 +136,7 @@ vn_flush_cached_data(vnode_t *vp, boolean_t sync) #define va_blksize va_blocksize #define MAXOFFSET_T OFF_MAX -#define EXCL 0 -#define FCREAT O_CREAT -#define FTRUNC O_TRUNC -#define FEXCL O_EXCL -#ifndef FDSYNC -#define FDSYNC FFSYNC -#endif -#define FRSYNC FFSYNC -#define FSYNC FFSYNC -#define FOFFMAX 0x00 #define FIGNORECASE 0x00 /* diff --git a/sys/contrib/openzfs/include/os/freebsd/zfs/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/zfs/Makefile.am deleted file mode 100644 index 081839c48c8f..000000000000 --- a/sys/contrib/openzfs/include/os/freebsd/zfs/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = sys diff --git a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/Makefile.am b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/Makefile.am deleted file mode 100644 index 392bb4ae3477..000000000000 --- a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -KERNEL_H = \ - freebsd_crypto.h \ - sha2.h \ - vdev_os.h \ - zfs_bootenv_os.h \ - zfs_context_os.h \ - zfs_ctldir.h \ - zfs_dir.h \ - zfs_ioctl_compat.h \ - zfs_vfsops_os.h \ - zfs_vnops_os.h \ - zfs_znode_impl.h \ - zpl.h - -noinst_HEADERS = $(KERNEL_H) diff --git a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h index 096c9e16d347..5d64c3fccd3f 100644 --- a/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h +++ b/sys/contrib/openzfs/include/os/freebsd/zfs/sys/zfs_znode_impl.h @@ -121,25 +121,29 @@ typedef struct zfs_soft_state { #define zn_rlimit_fsize(zp, uio) \ vn_rlimit_fsize(ZTOV(zp), GET_UIO_STRUCT(uio), zfs_uio_td(uio)) +#define ZFS_ENTER_ERROR(zfsvfs, error) do { \ + ZFS_TEARDOWN_ENTER_READ((zfsvfs), FTAG); \ + if (__predict_false((zfsvfs)->z_unmounted)) { \ + ZFS_TEARDOWN_EXIT_READ(zfsvfs, FTAG); \ + return (error); \ + } \ +} while (0) + /* Called on entry to each ZFS vnode and vfs operation */ -#define ZFS_ENTER(zfsvfs) \ - { \ - ZFS_TEARDOWN_ENTER_READ((zfsvfs), FTAG); \ - if (__predict_false((zfsvfs)->z_unmounted)) { \ - ZFS_TEARDOWN_EXIT_READ(zfsvfs, FTAG); \ - return (EIO); \ - } \ - } +#define ZFS_ENTER(zfsvfs) ZFS_ENTER_ERROR(zfsvfs, EIO) /* Must be called before exiting the vop */ -#define ZFS_EXIT(zfsvfs) ZFS_TEARDOWN_EXIT_READ(zfsvfs, FTAG) +#define ZFS_EXIT(zfsvfs) ZFS_TEARDOWN_EXIT_READ(zfsvfs, FTAG) + +#define ZFS_VERIFY_ZP_ERROR(zp, error) do { \ + if (__predict_false((zp)->z_sa_hdl == NULL)) { \ + ZFS_EXIT((zp)->z_zfsvfs); \ + return (error); \ + } \ +} while (0) /* Verifies the znode is valid */ -#define ZFS_VERIFY_ZP(zp) \ - if (__predict_false((zp)->z_sa_hdl == NULL)) { \ - ZFS_EXIT((zp)->z_zfsvfs); \ - return (EIO); \ - } \ +#define ZFS_VERIFY_ZP(zp) ZFS_VERIFY_ZP_ERROR(zp, EIO) /* * Macros for dealing with dmu_buf_hold diff --git a/sys/contrib/openzfs/include/os/linux/Makefile.am b/sys/contrib/openzfs/include/os/linux/Makefile.am index 605a1fcb7506..4d6901c694c8 100644 --- a/sys/contrib/openzfs/include/os/linux/Makefile.am +++ b/sys/contrib/openzfs/include/os/linux/Makefile.am @@ -1 +1,111 @@ -SUBDIRS = kernel spl zfs +if CONFIG_KERNEL +kernel_linuxdir = $(kerneldir)/linux +kernel_linux_HEADERS = \ + %D%/kernel/linux/blkdev_compat.h \ + %D%/kernel/linux/compiler_compat.h \ + %D%/kernel/linux/dcache_compat.h \ + %D%/kernel/linux/kmap_compat.h \ + %D%/kernel/linux/mod_compat.h \ + %D%/kernel/linux/page_compat.h \ + %D%/kernel/linux/percpu_compat.h \ + %D%/kernel/linux/simd.h \ + %D%/kernel/linux/simd_aarch64.h \ + %D%/kernel/linux/simd_powerpc.h \ + %D%/kernel/linux/simd_x86.h \ + %D%/kernel/linux/utsname_compat.h \ + %D%/kernel/linux/vfs_compat.h \ + %D%/kernel/linux/xattr_compat.h + +kernel_sysdir = $(kerneldir)/sys +kernel_sys_HEADERS = \ + %D%/zfs/sys/policy.h \ + %D%/zfs/sys/sha2.h \ + %D%/zfs/sys/trace_acl.h \ + %D%/zfs/sys/trace_arc.h \ + %D%/zfs/sys/trace_common.h \ + %D%/zfs/sys/trace_dbgmsg.h \ + %D%/zfs/sys/trace_dbuf.h \ + %D%/zfs/sys/trace_dmu.h \ + %D%/zfs/sys/trace_dnode.h \ + %D%/zfs/sys/trace_multilist.h \ + %D%/zfs/sys/trace_rrwlock.h \ + %D%/zfs/sys/trace_txg.h \ + %D%/zfs/sys/trace_vdev.h \ + %D%/zfs/sys/trace_zfs.h \ + %D%/zfs/sys/trace_zil.h \ + %D%/zfs/sys/trace_zio.h \ + %D%/zfs/sys/trace_zrlock.h \ + %D%/zfs/sys/zfs_bootenv_os.h \ + %D%/zfs/sys/zfs_context_os.h \ + %D%/zfs/sys/zfs_ctldir.h \ + %D%/zfs/sys/zfs_dir.h \ + %D%/zfs/sys/zfs_vfsops_os.h \ + %D%/zfs/sys/zfs_vnops_os.h \ + %D%/zfs/sys/zfs_znode_impl.h \ + %D%/zfs/sys/zpl.h + +kernel_spl_rpcdir = $(kerneldir)/spl/rpc +kernel_spl_rpc_HEADERS = \ + %D%/spl/rpc/xdr.h + +kernel_spl_sysdir = $(kerneldir)/spl/sys +kernel_spl_sys_HEADERS = \ + %D%/spl/sys/acl.h \ + %D%/spl/sys/atomic.h \ + %D%/spl/sys/byteorder.h \ + %D%/spl/sys/callb.h \ + %D%/spl/sys/callo.h \ + %D%/spl/sys/cmn_err.h \ + %D%/spl/sys/condvar.h \ + %D%/spl/sys/cred.h \ + %D%/spl/sys/ctype.h \ + %D%/spl/sys/debug.h \ + %D%/spl/sys/disp.h \ + %D%/spl/sys/dkio.h \ + %D%/spl/sys/errno.h \ + %D%/spl/sys/fcntl.h \ + %D%/spl/sys/file.h \ + %D%/spl/sys/inttypes.h \ + %D%/spl/sys/isa_defs.h \ + %D%/spl/sys/kmem.h \ + %D%/spl/sys/kmem_cache.h \ + %D%/spl/sys/kstat.h \ + %D%/spl/sys/list.h \ + %D%/spl/sys/mod_os.h \ + %D%/spl/sys/mutex.h \ + %D%/spl/sys/param.h \ + %D%/spl/sys/proc.h \ + %D%/spl/sys/processor.h \ + %D%/spl/sys/procfs_list.h \ + %D%/spl/sys/random.h \ + %D%/spl/sys/rwlock.h \ + %D%/spl/sys/shrinker.h \ + %D%/spl/sys/sid.h \ + %D%/spl/sys/signal.h \ + %D%/spl/sys/simd.h \ + %D%/spl/sys/stat.h \ + %D%/spl/sys/string.h \ + %D%/spl/sys/sunddi.h \ + %D%/spl/sys/sysmacros.h \ + %D%/spl/sys/systeminfo.h \ + %D%/spl/sys/taskq.h \ + %D%/spl/sys/thread.h \ + %D%/spl/sys/time.h \ + %D%/spl/sys/timer.h \ + %D%/spl/sys/trace.h \ + %D%/spl/sys/trace_spl.h \ + %D%/spl/sys/trace_taskq.h \ + %D%/spl/sys/tsd.h \ + %D%/spl/sys/types.h \ + %D%/spl/sys/types32.h \ + %D%/spl/sys/uio.h \ + %D%/spl/sys/user.h \ + %D%/spl/sys/vfs.h \ + %D%/spl/sys/vmem.h \ + %D%/spl/sys/vmsystm.h \ + %D%/spl/sys/vnode.h \ + %D%/spl/sys/wait.h \ + %D%/spl/sys/wmsum.h \ + %D%/spl/sys/zmod.h \ + %D%/spl/sys/zone.h +endif diff --git a/sys/contrib/openzfs/include/os/linux/kernel/Makefile.am b/sys/contrib/openzfs/include/os/linux/kernel/Makefile.am deleted file mode 100644 index 08b2f5fc5c99..000000000000 --- a/sys/contrib/openzfs/include/os/linux/kernel/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = linux diff --git a/sys/contrib/openzfs/include/os/linux/kernel/linux/Makefile.am b/sys/contrib/openzfs/include/os/linux/kernel/linux/Makefile.am deleted file mode 100644 index 6ff0df506d9c..000000000000 --- a/sys/contrib/openzfs/include/os/linux/kernel/linux/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -KERNEL_H = \ - dcache_compat.h \ - xattr_compat.h \ - vfs_compat.h \ - blkdev_compat.h \ - utsname_compat.h \ - kmap_compat.h \ - percpu_compat.h \ - simd.h \ - simd_x86.h \ - simd_aarch64.h \ - simd_powerpc.h \ - mod_compat.h \ - page_compat.h \ - compiler_compat.h - -if CONFIG_KERNEL -if BUILD_LINUX -kerneldir = @prefix@/src/zfs-$(VERSION)/include/linux -kernel_HEADERS = $(KERNEL_H) -endif -endif diff --git a/sys/contrib/openzfs/include/os/linux/kernel/linux/mod_compat.h b/sys/contrib/openzfs/include/os/linux/kernel/linux/mod_compat.h index a90bdf7cf2d2..78603e54f54c 100644 --- a/sys/contrib/openzfs/include/os/linux/kernel/linux/mod_compat.h +++ b/sys/contrib/openzfs/include/os/linux/kernel/linux/mod_compat.h @@ -160,11 +160,4 @@ enum scope_prefix_types { #define ZFS_MODULE_PARAM_ARGS const char *buf, zfs_kernel_param_t *kp -#define ZFS_MODULE_DESCRIPTION(s) MODULE_DESCRIPTION(s) -#define ZFS_MODULE_AUTHOR(s) MODULE_AUTHOR(s) -#define ZFS_MODULE_LICENSE(s) MODULE_LICENSE(s) -#define ZFS_MODULE_VERSION(s) MODULE_VERSION(s) - -#define module_init_early(fn) module_init(fn) - #endif /* _MOD_COMPAT_H */ diff --git a/sys/contrib/openzfs/include/os/linux/spl/Makefile.am b/sys/contrib/openzfs/include/os/linux/spl/Makefile.am deleted file mode 100644 index bd781c08f143..000000000000 --- a/sys/contrib/openzfs/include/os/linux/spl/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = rpc sys diff --git a/sys/contrib/openzfs/include/os/linux/spl/rpc/Makefile.am b/sys/contrib/openzfs/include/os/linux/spl/rpc/Makefile.am deleted file mode 100644 index 13d804fce9b6..000000000000 --- a/sys/contrib/openzfs/include/os/linux/spl/rpc/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -KERNEL_H = \ - xdr.h - -if CONFIG_KERNEL -kerneldir = @prefix@/src/zfs-$(VERSION)/include/spl/rpc -kernel_HEADERS = $(KERNEL_H) -endif diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/Makefile.am b/sys/contrib/openzfs/include/os/linux/spl/sys/Makefile.am deleted file mode 100644 index 0dc9b90c1097..000000000000 --- a/sys/contrib/openzfs/include/os/linux/spl/sys/Makefile.am +++ /dev/null @@ -1,64 +0,0 @@ -KERNEL_H = \ - acl.h \ - atomic.h \ - byteorder.h \ - callb.h \ - callo.h \ - cmn_err.h \ - condvar.h \ - cred.h \ - ctype.h \ - debug.h \ - disp.h \ - dkio.h \ - errno.h \ - fcntl.h \ - file.h \ - inttypes.h \ - isa_defs.h \ - kmem_cache.h \ - kmem.h \ - kstat.h \ - list.h \ - mod_os.h \ - mutex.h \ - param.h \ - processor.h \ - proc.h \ - procfs_list.h \ - random.h \ - rwlock.h \ - shrinker.h \ - sid.h \ - signal.h \ - simd.h \ - stat.h \ - string.h \ - sunddi.h \ - sysmacros.h \ - systeminfo.h \ - taskq.h \ - thread.h \ - time.h \ - timer.h \ - trace.h \ - trace_spl.h \ - trace_taskq.h \ - tsd.h \ - types32.h \ - types.h \ - uio.h \ - user.h \ - vfs.h \ - vmem.h \ - vmsystm.h \ - vnode.h \ - wait.h \ - wmsum.h \ - zmod.h \ - zone.h - -if CONFIG_KERNEL -kerneldir = @prefix@/src/zfs-$(VERSION)/include/spl/sys -kernel_HEADERS = $(KERNEL_H) -endif diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/sunddi.h b/sys/contrib/openzfs/include/os/linux/spl/sys/sunddi.h index 8524ec9c300e..df6a204d5cf9 100644 --- a/sys/contrib/openzfs/include/os/linux/spl/sys/sunddi.h +++ b/sys/contrib/openzfs/include/os/linux/spl/sys/sunddi.h @@ -46,7 +46,6 @@ typedef int ddi_devid_t; #define ddi_prop_free(x) (void)0 #define ddi_root_node() (void)0 -extern int ddi_strtoul(const char *, char **, int, unsigned long *); extern int ddi_strtol(const char *, char **, int, long *); extern int ddi_strtoull(const char *, char **, int, unsigned long long *); extern int ddi_strtoll(const char *, char **, int, long long *); diff --git a/sys/contrib/openzfs/include/os/linux/zfs/Makefile.am b/sys/contrib/openzfs/include/os/linux/zfs/Makefile.am deleted file mode 100644 index 081839c48c8f..000000000000 --- a/sys/contrib/openzfs/include/os/linux/zfs/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = sys diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am b/sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am deleted file mode 100644 index a075db476e40..000000000000 --- a/sys/contrib/openzfs/include/os/linux/zfs/sys/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -KERNEL_H = \ - policy.h \ - sha2.h \ - trace_acl.h \ - trace_arc.h \ - trace_common.h \ - trace_zfs.h \ - trace_dbgmsg.h \ - trace_dbuf.h \ - trace_dmu.h \ - trace_dnode.h \ - trace_multilist.h \ - trace_rrwlock.h \ - trace_txg.h \ - trace_vdev.h \ - trace_zil.h \ - trace_zio.h \ - trace_zrlock.h \ - zfs_bootenv_os.h \ - zfs_context_os.h \ - zfs_ctldir.h \ - zfs_dir.h \ - zfs_vfsops_os.h \ - zfs_vnops_os.h \ - zfs_znode_impl.h \ - zpl.h - -if CONFIG_KERNEL -kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys -kernel_HEADERS = $(KERNEL_H) -endif diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_acl.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_acl.h index f8e0aa8acaf8..35bf78bed94e 100644 --- a/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_acl.h +++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_acl.h @@ -58,6 +58,8 @@ DECLARE_EVENT_CLASS(zfs_ace_class, __field(uint64_t, z_size) __field(uint64_t, z_pflags) __field(uint32_t, z_sync_cnt) + __field(uint32_t, z_sync_writes_cnt) + __field(uint32_t, z_async_writes_cnt) __field(mode_t, z_mode) __field(boolean_t, z_is_sa) __field(boolean_t, z_is_mapped) @@ -91,6 +93,8 @@ DECLARE_EVENT_CLASS(zfs_ace_class, __entry->z_size = zn->z_size; __entry->z_pflags = zn->z_pflags; __entry->z_sync_cnt = zn->z_sync_cnt; + __entry->z_sync_writes_cnt = zn->z_sync_writes_cnt; + __entry->z_async_writes_cnt = zn->z_async_writes_cnt; __entry->z_mode = zn->z_mode; __entry->z_is_sa = zn->z_is_sa; __entry->z_is_mapped = zn->z_is_mapped; @@ -116,16 +120,18 @@ DECLARE_EVENT_CLASS(zfs_ace_class, TP_printk("zn { id %llu unlinked %u atime_dirty %u " "zn_prefetch %u blksz %u seq %u " "mapcnt %llu size %llu pflags %llu " - "sync_cnt %u mode 0x%x is_sa %d " - "is_mapped %d is_ctldir %d is_stale %d inode { " + "sync_cnt %u sync_writes_cnt %u async_writes_cnt %u " + "mode 0x%x is_sa %d is_mapped %d " + "is_ctldir %d is_stale %d inode { " "uid %u gid %u ino %lu nlink %u size %lli " "blkbits %u bytes %u mode 0x%x generation %x } } " "ace { type %u flags %u access_mask %u } mask_matched %u", __entry->z_id, __entry->z_unlinked, __entry->z_atime_dirty, __entry->z_zn_prefetch, __entry->z_blksz, __entry->z_seq, __entry->z_mapcnt, __entry->z_size, - __entry->z_pflags, __entry->z_sync_cnt, __entry->z_mode, - __entry->z_is_sa, __entry->z_is_mapped, + __entry->z_pflags, __entry->z_sync_cnt, + __entry->z_sync_writes_cnt, __entry->z_async_writes_cnt, + __entry->z_mode, __entry->z_is_sa, __entry->z_is_mapped, __entry->z_is_ctldir, __entry->z_is_stale, __entry->i_uid, __entry->i_gid, __entry->i_ino, __entry->i_nlink, __entry->i_size, __entry->i_blkbits, diff --git a/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vnops_os.h b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vnops_os.h index 47f91e4a6cf4..1d6a58d56b67 100644 --- a/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vnops_os.h +++ b/sys/contrib/openzfs/include/os/linux/zfs/sys/zfs_vnops_os.h @@ -70,7 +70,7 @@ extern int zfs_space(znode_t *zp, int cmd, flock64_t *bfp, int flag, extern int zfs_fid(struct inode *ip, fid_t *fidp); extern int zfs_getpage(struct inode *ip, struct page *pl[], int nr_pages); extern int zfs_putpage(struct inode *ip, struct page *pp, - struct writeback_control *wbc); + struct writeback_control *wbc, boolean_t for_sync); extern int zfs_dirty_inode(struct inode *ip, int flags); extern int zfs_map(struct inode *ip, offset_t off, caddr_t *addrp, size_t len, unsigned long vm_flags); diff --git a/sys/contrib/openzfs/include/sys/Makefile.am b/sys/contrib/openzfs/include/sys/Makefile.am deleted file mode 100644 index 54573fbe1b1c..000000000000 --- a/sys/contrib/openzfs/include/sys/Makefile.am +++ /dev/null @@ -1,151 +0,0 @@ -SUBDIRS = fm fs crypto lua sysevent zstd - -COMMON_H = \ - abd.h \ - abd_impl.h \ - aggsum.h \ - arc.h \ - arc_impl.h \ - avl.h \ - avl_impl.h \ - bitops.h \ - blkptr.h \ - bplist.h \ - bpobj.h \ - bptree.h \ - btree.h \ - bqueue.h \ - dataset_kstats.h \ - dbuf.h \ - ddt.h \ - dmu.h \ - dmu_impl.h \ - dmu_objset.h \ - dmu_recv.h \ - dmu_redact.h \ - dmu_send.h \ - dmu_traverse.h \ - dmu_tx.h \ - dmu_zfetch.h \ - dnode.h \ - dsl_bookmark.h \ - dsl_dataset.h \ - dsl_deadlist.h \ - dsl_deleg.h \ - dsl_destroy.h \ - dsl_dir.h \ - dsl_crypt.h \ - dsl_pool.h \ - dsl_prop.h \ - dsl_scan.h \ - dsl_synctask.h \ - dsl_userhold.h \ - edonr.h \ - efi_partition.h \ - frame.h \ - hkdf.h \ - metaslab.h \ - metaslab_impl.h \ - mmp.h \ - mntent.h \ - mod.h \ - multilist.h \ - nvpair.h \ - nvpair_impl.h \ - objlist.h \ - pathname.h \ - qat.h \ - range_tree.h \ - rrwlock.h \ - sa.h \ - sa_impl.h \ - skein.h \ - spa_boot.h \ - spa_checkpoint.h \ - spa_log_spacemap.h \ - space_map.h \ - space_reftree.h \ - spa.h \ - spa_impl.h \ - spa_checksum.h \ - sysevent.h \ - txg.h \ - txg_impl.h \ - u8_textprep_data.h \ - u8_textprep.h \ - uberblock.h \ - uberblock_impl.h \ - uio_impl.h \ - unique.h \ - uuid.h \ - vdev_disk.h \ - vdev_file.h \ - vdev.h \ - vdev_draid.h \ - vdev_impl.h \ - vdev_indirect_births.h \ - vdev_indirect_mapping.h \ - vdev_initialize.h \ - vdev_raidz.h \ - vdev_raidz_impl.h \ - vdev_rebuild.h \ - vdev_removal.h \ - vdev_trim.h \ - xvattr.h \ - zap.h \ - zap_impl.h \ - zap_leaf.h \ - zcp.h \ - zcp_global.h \ - zcp_iter.h \ - zcp_prop.h \ - zcp_set.h \ - zfeature.h \ - zfs_acl.h \ - zfs_bootenv.h \ - zfs_context.h \ - zfs_debug.h \ - zfs_delay.h \ - zfs_file.h \ - zfs_fuid.h \ - zfs_project.h \ - zfs_quota.h \ - zfs_racct.h \ - zfs_ratelimit.h \ - zfs_refcount.h \ - zfs_rlock.h \ - zfs_sa.h \ - zfs_stat.h \ - zfs_sysfs.h \ - zfs_vfsops.h \ - zfs_vnops.h \ - zfs_znode.h \ - zil.h \ - zil_impl.h \ - zio_checksum.h \ - zio_compress.h \ - zio_crypt.h \ - zio.h \ - zio_impl.h \ - zio_priority.h \ - zrlock.h \ - zthr.h - -KERNEL_H = \ - zfs_ioctl.h \ - zfs_ioctl_impl.h \ - zfs_onexit.h \ - zvol.h \ - zvol_impl.h - -if CONFIG_USER -libzfsdir = $(includedir)/libzfs/sys -libzfs_HEADERS = $(COMMON_H) -endif - -if CONFIG_KERNEL -if BUILD_LINUX -kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys -kernel_HEADERS = $(COMMON_H) $(KERNEL_H) -endif -endif diff --git a/sys/contrib/openzfs/include/sys/crypto/Makefile.am b/sys/contrib/openzfs/include/sys/crypto/Makefile.am deleted file mode 100644 index eb31f6a45743..000000000000 --- a/sys/contrib/openzfs/include/sys/crypto/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -COMMON_H = \ - api.h \ - common.h \ - icp.h - -if CONFIG_USER -libzfsdir = $(includedir)/libzfs/sys/crypto -libzfs_HEADERS = $(COMMON_H) -endif - -if CONFIG_KERNEL -if BUILD_LINUX -kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys/crypto -kernel_HEADERS = $(COMMON_H) -endif -endif diff --git a/sys/contrib/openzfs/include/sys/dbuf.h b/sys/contrib/openzfs/include/sys/dbuf.h index 9017cf345724..deaab82b797d 100644 --- a/sys/contrib/openzfs/include/sys/dbuf.h +++ b/sys/contrib/openzfs/include/sys/dbuf.h @@ -321,13 +321,12 @@ typedef struct dmu_buf_impl { uint8_t db_dirtycnt; } dmu_buf_impl_t; -/* Note: the dbuf hash table is exposed only for the mdb module */ -#define DBUF_MUTEXES 2048 -#define DBUF_HASH_MUTEX(h, idx) (&(h)->hash_mutexes[(idx) & (DBUF_MUTEXES-1)]) +#define DBUF_RWLOCKS 8192 +#define DBUF_HASH_RWLOCK(h, idx) (&(h)->hash_rwlocks[(idx) & (DBUF_RWLOCKS-1)]) typedef struct dbuf_hash_table { uint64_t hash_table_mask; dmu_buf_impl_t **hash_table; - kmutex_t hash_mutexes[DBUF_MUTEXES] ____cacheline_aligned; + krwlock_t hash_rwlocks[DBUF_RWLOCKS] ____cacheline_aligned; } dbuf_hash_table_t; typedef void (*dbuf_prefetch_fn)(void *, boolean_t); diff --git a/sys/contrib/openzfs/include/sys/dmu.h b/sys/contrib/openzfs/include/sys/dmu.h index 1ddff0d4e4e7..03513f9f2c6c 100644 --- a/sys/contrib/openzfs/include/sys/dmu.h +++ b/sys/contrib/openzfs/include/sys/dmu.h @@ -1067,6 +1067,8 @@ int dmu_diff(const char *tosnap_name, const char *fromsnap_name, #define ZFS_CRC64_POLY 0xC96C5795D7870F42ULL /* ECMA-182, reflected form */ extern uint64_t zfs_crc64_table[256]; +extern int dmu_prefetch_max; + #ifdef __cplusplus } #endif diff --git a/sys/contrib/openzfs/include/sys/dsl_dataset.h b/sys/contrib/openzfs/include/sys/dsl_dataset.h index 02147171ae14..a8ca7444a3f8 100644 --- a/sys/contrib/openzfs/include/sys/dsl_dataset.h +++ b/sys/contrib/openzfs/include/sys/dsl_dataset.h @@ -487,6 +487,9 @@ boolean_t dsl_dataset_get_uint64_array_feature(dsl_dataset_t *ds, void dsl_dataset_activate_redaction(dsl_dataset_t *ds, uint64_t *redact_snaps, uint64_t num_redact_snaps, dmu_tx_t *tx); +int dsl_dataset_oldest_snapshot(spa_t *spa, uint64_t head_ds, uint64_t min_txg, + uint64_t *oldest_dsobj); + #ifdef ZFS_DEBUG #define dprintf_ds(ds, fmt, ...) do { \ if (zfs_flags & ZFS_DEBUG_DPRINTF) { \ diff --git a/sys/contrib/openzfs/include/sys/fm/Makefile.am b/sys/contrib/openzfs/include/sys/fm/Makefile.am deleted file mode 100644 index 7c6c3d49b6e9..000000000000 --- a/sys/contrib/openzfs/include/sys/fm/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -SUBDIRS = fs - -COMMON_H = \ - protocol.h \ - util.h - -if CONFIG_USER -libzfsdir = $(includedir)/libzfs/sys/fm -libzfs_HEADERS = $(COMMON_H) -endif - -if CONFIG_KERNEL -if BUILD_LINUX -kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys/fm -kernel_HEADERS = $(COMMON_H) -endif -endif diff --git a/sys/contrib/openzfs/include/sys/fm/fs/Makefile.am b/sys/contrib/openzfs/include/sys/fm/fs/Makefile.am deleted file mode 100644 index a662753a9e97..000000000000 --- a/sys/contrib/openzfs/include/sys/fm/fs/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -COMMON_H = \ - zfs.h - -if CONFIG_USER -libzfsdir = $(includedir)/libzfs/sys/fm/fs -libzfs_HEADERS = $(COMMON_H) -endif - -if CONFIG_KERNEL -if BUILD_LINUX -kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys/fm/fs -kernel_HEADERS = $(COMMON_H) -endif -endif diff --git a/sys/contrib/openzfs/include/sys/fs/Makefile.am b/sys/contrib/openzfs/include/sys/fs/Makefile.am deleted file mode 100644 index 6a93053c8e2b..000000000000 --- a/sys/contrib/openzfs/include/sys/fs/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -COMMON_H = \ - zfs.h - -if CONFIG_USER -libzfsdir = $(includedir)/libzfs/sys/fs -libzfs_HEADERS = $(COMMON_H) -endif - -if CONFIG_KERNEL -if BUILD_LINUX -kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys/fs -kernel_HEADERS = $(COMMON_H) -endif -endif diff --git a/sys/contrib/openzfs/include/sys/lua/Makefile.am b/sys/contrib/openzfs/include/sys/lua/Makefile.am deleted file mode 100644 index 8b4dafaa8cf7..000000000000 --- a/sys/contrib/openzfs/include/sys/lua/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -COMMON_H = \ - lua.h \ - luaconf.h \ - lualib.h \ - lauxlib.h - -if CONFIG_USER -libzfsdir = $(includedir)/libzfs/sys/lua -libzfs_HEADERS = $(COMMON_H) -endif - -if CONFIG_KERNEL -if BUILD_LINUX -kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys/lua -kernel_HEADERS = $(COMMON_H) -endif -endif diff --git a/sys/contrib/openzfs/include/sys/metaslab.h b/sys/contrib/openzfs/include/sys/metaslab.h index 129a68be41c5..b777a3cae439 100644 --- a/sys/contrib/openzfs/include/sys/metaslab.h +++ b/sys/contrib/openzfs/include/sys/metaslab.h @@ -49,11 +49,14 @@ int metaslab_init(metaslab_group_t *, uint64_t, uint64_t, uint64_t, metaslab_t **); void metaslab_fini(metaslab_t *); +void metaslab_set_unflushed_dirty(metaslab_t *, boolean_t); void metaslab_set_unflushed_txg(metaslab_t *, uint64_t, dmu_tx_t *); void metaslab_set_estimated_condensed_size(metaslab_t *, uint64_t, dmu_tx_t *); +boolean_t metaslab_unflushed_dirty(metaslab_t *); uint64_t metaslab_unflushed_txg(metaslab_t *); uint64_t metaslab_estimated_condensed_size(metaslab_t *); int metaslab_sort_by_flushed(const void *, const void *); +void metaslab_unflushed_bump(metaslab_t *, dmu_tx_t *, boolean_t); uint64_t metaslab_unflushed_changes_memused(metaslab_t *); int metaslab_load(metaslab_t *); diff --git a/sys/contrib/openzfs/include/sys/metaslab_impl.h b/sys/contrib/openzfs/include/sys/metaslab_impl.h index 3dbee4c17fef..820c61a252e2 100644 --- a/sys/contrib/openzfs/include/sys/metaslab_impl.h +++ b/sys/contrib/openzfs/include/sys/metaslab_impl.h @@ -553,6 +553,7 @@ struct metaslab { * log space maps. */ uint64_t ms_unflushed_txg; + boolean_t ms_unflushed_dirty; /* updated every time we are done syncing the metaslab's space map */ uint64_t ms_synced_length; diff --git a/sys/contrib/openzfs/include/sys/mod.h b/sys/contrib/openzfs/include/sys/mod.h index a5a73ed0ee00..aba211423773 100644 --- a/sys/contrib/openzfs/include/sys/mod.h +++ b/sys/contrib/openzfs/include/sys/mod.h @@ -30,11 +30,6 @@ * Exported symbols */ #define EXPORT_SYMBOL(x) - -#define ZFS_MODULE_DESCRIPTION(s) -#define ZFS_MODULE_AUTHOR(s) -#define ZFS_MODULE_LICENSE(s) -#define ZFS_MODULE_VERSION(s) #endif #endif /* SYS_MOD_H */ diff --git a/sys/contrib/openzfs/include/sys/spa.h b/sys/contrib/openzfs/include/sys/spa.h index 2ce84c21cbdb..232855449c17 100644 --- a/sys/contrib/openzfs/include/sys/spa.h +++ b/sys/contrib/openzfs/include/sys/spa.h @@ -1144,11 +1144,17 @@ extern void zfs_post_remove(spa_t *spa, vdev_t *vd); extern void zfs_post_state_change(spa_t *spa, vdev_t *vd, uint64_t laststate); extern void zfs_post_autoreplace(spa_t *spa, vdev_t *vd); extern uint64_t spa_get_errlog_size(spa_t *spa); -extern int spa_get_errlog(spa_t *spa, void *uaddr, size_t *count); +extern int spa_get_errlog(spa_t *spa, void *uaddr, uint64_t *count); extern void spa_errlog_rotate(spa_t *spa); extern void spa_errlog_drain(spa_t *spa); extern void spa_errlog_sync(spa_t *spa, uint64_t txg); extern void spa_get_errlists(spa_t *spa, avl_tree_t *last, avl_tree_t *scrub); +extern void spa_delete_dataset_errlog(spa_t *spa, uint64_t ds, dmu_tx_t *tx); +extern void spa_swap_errlog(spa_t *spa, uint64_t new_head_ds, + uint64_t old_head_ds, dmu_tx_t *tx); +extern void sync_error_list(spa_t *spa, avl_tree_t *t, uint64_t *obj, + dmu_tx_t *tx); +extern void spa_upgrade_errlog(spa_t *spa, dmu_tx_t *tx); /* vdev cache */ extern void vdev_cache_stat_init(void); diff --git a/sys/contrib/openzfs/include/sys/spa_log_spacemap.h b/sys/contrib/openzfs/include/sys/spa_log_spacemap.h index b2ed77fac3e4..72229df6cd16 100644 --- a/sys/contrib/openzfs/include/sys/spa_log_spacemap.h +++ b/sys/contrib/openzfs/include/sys/spa_log_spacemap.h @@ -30,7 +30,10 @@ typedef struct log_summary_entry { uint64_t lse_start; /* start TXG */ + uint64_t lse_end; /* last TXG */ + uint64_t lse_txgcount; /* # of TXGs */ uint64_t lse_mscount; /* # of metaslabs needed to be flushed */ + uint64_t lse_msdcount; /* # of dirty metaslabs needed to be flushed */ uint64_t lse_blkcount; /* blocks held by this entry */ list_node_t lse_node; } log_summary_entry_t; @@ -50,6 +53,7 @@ typedef struct spa_log_sm { uint64_t sls_nblocks; /* number of blocks in this log */ uint64_t sls_mscount; /* # of metaslabs flushed in the log's txg */ avl_node_t sls_node; /* node in spa_sm_logs_by_txg */ + space_map_t *sls_sm; /* space map pointer, if open */ } spa_log_sm_t; int spa_ld_log_spacemaps(spa_t *); @@ -68,8 +72,9 @@ uint64_t spa_log_sm_memused(spa_t *); void spa_log_sm_decrement_mscount(spa_t *, uint64_t); void spa_log_sm_increment_current_mscount(spa_t *); -void spa_log_summary_add_flushed_metaslab(spa_t *); -void spa_log_summary_decrement_mscount(spa_t *, uint64_t); +void spa_log_summary_add_flushed_metaslab(spa_t *, boolean_t); +void spa_log_summary_dirty_flushed_metaslab(spa_t *, uint64_t); +void spa_log_summary_decrement_mscount(spa_t *, uint64_t, boolean_t); void spa_log_summary_decrement_blkcount(spa_t *, uint64_t); boolean_t spa_flush_all_logs_requested(spa_t *); diff --git a/sys/contrib/openzfs/include/sys/sysevent/Makefile.am b/sys/contrib/openzfs/include/sys/sysevent/Makefile.am deleted file mode 100644 index 64e53763951a..000000000000 --- a/sys/contrib/openzfs/include/sys/sysevent/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -COMMON_H = \ - eventdefs.h \ - dev.h - -if CONFIG_USER -libzfsdir = $(includedir)/libzfs/sys/sysevent -libzfs_HEADERS = $(COMMON_H) -endif - -if CONFIG_KERNEL -if BUILD_LINUX -kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys/sysevent -kernel_HEADERS = $(COMMON_H) -endif -endif diff --git a/sys/contrib/openzfs/include/sys/zfs_context.h b/sys/contrib/openzfs/include/sys/zfs_context.h index 944acdcfbe56..50257f1d6fdd 100644 --- a/sys/contrib/openzfs/include/sys/zfs_context.h +++ b/sys/contrib/openzfs/include/sys/zfs_context.h @@ -692,10 +692,6 @@ extern char *kmem_asprintf(const char *fmt, ...); /* * Hostname information */ -extern char hw_serial[]; /* for userland-emulated hostid access */ -extern int ddi_strtoul(const char *str, char **nptr, int base, - unsigned long *result); - extern int ddi_strtoull(const char *str, char **nptr, int base, u_longlong_t *result); diff --git a/sys/contrib/openzfs/include/sys/zfs_znode.h b/sys/contrib/openzfs/include/sys/zfs_znode.h index 127fd8736ffc..098cf9dbc16f 100644 --- a/sys/contrib/openzfs/include/sys/zfs_znode.h +++ b/sys/contrib/openzfs/include/sys/zfs_znode.h @@ -199,6 +199,8 @@ typedef struct znode { uint64_t z_size; /* file size (cached) */ uint64_t z_pflags; /* pflags (cached) */ uint32_t z_sync_cnt; /* synchronous open count */ + uint32_t z_sync_writes_cnt; /* synchronous write count */ + uint32_t z_async_writes_cnt; /* asynchronous write count */ mode_t z_mode; /* mode (cached) */ kmutex_t z_acl_lock; /* acl data lock */ zfs_acl_t *z_acl_cached; /* cached acl */ diff --git a/sys/contrib/openzfs/include/sys/zio.h b/sys/contrib/openzfs/include/sys/zio.h index 2cf10f30974b..7b78f08787bf 100644 --- a/sys/contrib/openzfs/include/sys/zio.h +++ b/sys/contrib/openzfs/include/sys/zio.h @@ -283,6 +283,13 @@ extern const char *const zio_type_name[ZIO_TYPES]; * Note: this structure is passed between userland and the kernel, and is * stored on disk (by virtue of being incorporated into other on-disk * structures, e.g. dsl_scan_phys_t). + * + * If the head_errlog feature is enabled a different on-disk format for error + * logs is used. This introduces the use of an error bookmark, a four-tuple + * that uniquely identifies any error block + * in the pool. The birth transaction group is used to track whether the block + * has been overwritten by newer data or added to a snapshot since its marking + * as an error. */ struct zbookmark_phys { uint64_t zb_objset; @@ -291,6 +298,13 @@ struct zbookmark_phys { uint64_t zb_blkid; }; +typedef struct zbookmark_err_phys { + uint64_t zb_object; + int64_t zb_level; + uint64_t zb_blkid; + uint64_t zb_birth; +} zbookmark_err_phys_t; + #define SET_BOOKMARK(zb, objset, object, level, blkid) \ { \ (zb)->zb_objset = objset; \ diff --git a/sys/contrib/openzfs/include/sys/zstd/Makefile.am b/sys/contrib/openzfs/include/sys/zstd/Makefile.am deleted file mode 100644 index 16666fe63355..000000000000 --- a/sys/contrib/openzfs/include/sys/zstd/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -COMMON_H = \ - $(top_srcdir)/include/sys/zstd/zstd.h - -KERNEL_H = - -USER_H = - -EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H) - -if CONFIG_USER -libzfsdir = $(includedir)/libzfs/sys/zstd -libzfs_HEADERS = $(COMMON_H) $(USER_H) -endif - -if CONFIG_KERNEL -kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys/zstd -kernel_HEADERS = $(COMMON_H) $(KERNEL_H) -endif diff --git a/sys/contrib/openzfs/include/zfeature_common.h b/sys/contrib/openzfs/include/zfeature_common.h index 580f5ff3e0ee..d4d636f9c266 100644 --- a/sys/contrib/openzfs/include/zfeature_common.h +++ b/sys/contrib/openzfs/include/zfeature_common.h @@ -76,6 +76,7 @@ typedef enum spa_feature { SPA_FEATURE_ZSTD_COMPRESS, SPA_FEATURE_DRAID, SPA_FEATURE_ZILSAXATTR, + SPA_FEATURE_HEAD_ERRLOG, SPA_FEATURES } spa_feature_t; diff --git a/sys/contrib/openzfs/lib/Makefile.am b/sys/contrib/openzfs/lib/Makefile.am index f07975cc03fc..499ebdaeba9b 100644 --- a/sys/contrib/openzfs/lib/Makefile.am +++ b/sys/contrib/openzfs/lib/Makefile.am @@ -33,50 +33,91 @@ # | | | # \-------- libspl ----+------/ # -# * - A stable ABI is provided for these libraries -# # # NB: GNU Automake Manual, Chapter 8.3.5: Libtool Convenience Libraries # These nine libraries are intermediary build components. # -SUBDIRS = libavl libicp libshare libspl libtpool libzstd -CPPCHECKDIRS = libavl libicp libnvpair libshare libspl libtpool libunicode -CPPCHECKDIRS += libuutil libzfs libzfs_core libzfsbootenv libzpool libzutil +# * - A stable ABI is provided for these libraries; +# when performing an ABI check the following options are applied: +# +# --no-unreferenced-symbols: Exclude symbols which are not referenced by +# any debug information. Without this _init() and _fini() are incorrectly +# reported on CentOS7 for libuutil.so. +# +# --headers-dir1: Limit ABI checks to public OpenZFS headers, otherwise +# changes in public system headers are also reported. +# +# --suppressions: Honor a suppressions file for each library to provide +# a mechanism for suppressing harmless warnings. +# +noinst_LTLIBRARIES = +lib_LTLIBRARIES = +pkgconfig_DATA = +include $(srcdir)/%D%/libavl/Makefile.am +include $(srcdir)/%D%/libicp/Makefile.am +include $(srcdir)/%D%/libnvpair/Makefile.am +include $(srcdir)/%D%/libshare/Makefile.am +include $(srcdir)/%D%/libspl/Makefile.am +include $(srcdir)/%D%/libtpool/Makefile.am +include $(srcdir)/%D%/libunicode/Makefile.am +include $(srcdir)/%D%/libuutil/Makefile.am +include $(srcdir)/%D%/libzfs_core/Makefile.am +include $(srcdir)/%D%/libzfs/Makefile.am +include $(srcdir)/%D%/libzfsbootenv/Makefile.am +include $(srcdir)/%D%/libzpool/Makefile.am +include $(srcdir)/%D%/libzstd/Makefile.am +include $(srcdir)/%D%/libzutil/Makefile.am if BUILD_LINUX -SUBDIRS += libefi -CPPCHECKDIRS += libefi +include $(srcdir)/%D%/libefi/Makefile.am endif -# libnvpair is installed as part of the final build product -# libzutil depends on it, so it must be compiled before libzutil -SUBDIRS += libnvpair -# libzutil depends on libefi if present -SUBDIRS += libzutil libunicode +PHONY += lib +lib: $(noinst_LTLIBRARIES) $(lib_LTLIBRARIES) -# These five libraries, which are installed as the final build product, -# incorporate the eight convenience libraries given above. -DISTLIBS = libuutil libzfs_core libzfs libzpool libzfsbootenv -SUBDIRS += $(DISTLIBS) -DISTLIBS += libnvpair -# An ABI is stored for each of these libraries. Note that libzpool.so -# is only linked against by ztest and zdb and no stable ABI is provided. -ABILIBS = libnvpair libuutil libzfs_core libzfs libzfsbootenv +PHONY += checkabi storeabi check_libabi_version allow_libabi_only_for_x86_64 -PHONY = checkabi storeabi cppcheck -checkabi: $(ABILIBS) - set -e ; for dir in $(ABILIBS) ; do \ - $(MAKE) -C $$dir checkabi ; \ - done - -storeabi: $(ABILIBS) - set -e ; for dir in $(ABILIBS) ; do \ - $(MAKE) -C $$dir storeabi ; \ - done - -cppcheck: $(CPPCHECKDIRS) - set -e ; for dir in $(CPPCHECKDIRS) ; do \ - $(MAKE) -C $$dir cppcheck ; \ +check_libabi_version: + if [ $$(abidw -v | $(SED) 's/[^0-9]//g') -lt 200 ]; then \ + printf '%s\n' "" \ + "*** Please use libabigail 2.0.0 version or newer;" \ + "*** otherwise results are not consistent!" \ + "(or see https://github.com/openzfs/libabigail-docker)"; \ + exit 1; \ + fi + +allow_libabi_only_for_x86_64: + echo '*** ABI definitions provided apply only to x86_64:' + echo '*** not checking or storing ABI and assuming success.' + +if TARGET_CPU_X86_64 +# These should depend on $(lib_LTLIBRARIES), but this breaks on CI when bound into Docker +checkabi: check_libabi_version + err=0; \ + for lib in $(lib_LTLIBRARIES); do \ + lib=$${lib%.la}; \ + [ -f $(srcdir)/lib/$$lib/$$lib.suppr ] || continue; \ + echo $$lib:; \ + abidiff --no-unreferenced-symbols \ + --headers-dir1 include \ + --suppressions $(srcdir)/lib/$$lib/$$lib.suppr \ + $(srcdir)/lib/$$lib/$$lib.abi .libs/$$lib.so || err=$$((err + 1)); \ + done; \ + exit $$err + +storeabi: check_libabi_version + for lib in $(lib_LTLIBRARIES); do \ + lib=$${lib%.la}; \ + [ -f $(srcdir)/lib/$$lib/$$lib.suppr ] || continue; \ + abidw --no-show-locs \ + --no-corpus-path \ + --no-comp-dir-path \ + --type-id-style hash \ + .libs/$$lib.so > $(srcdir)/lib/$$lib/$$lib.abi; \ done +else +checkabi: allow_libabi_only_for_x86_64 +storeabi: allow_libabi_only_for_x86_64 +endif diff --git a/sys/contrib/openzfs/lib/libavl/Makefile.am b/sys/contrib/openzfs/lib/libavl/Makefile.am index 3166febd02c5..3b302ee9deae 100644 --- a/sys/contrib/openzfs/lib/libavl/Makefile.am +++ b/sys/contrib/openzfs/lib/libavl/Makefile.am @@ -1,17 +1,7 @@ -include $(top_srcdir)/config/Rules.am +libavl_la_CFLAGS = $(AM_CFLAGS) $(KERNEL_CFLAGS) $(LIBRARY_CFLAGS) +libavl_la_CFLAGS += -fvisibility=hidden -VPATH = $(top_srcdir)/module/avl/ - -# Includes kernel code, generate warnings for large stack frames -AM_CFLAGS += $(FRAME_LARGER_THAN) -AM_CFLAGS += -fvisibility=hidden - -noinst_LTLIBRARIES = libavl.la - -KERNEL_C = \ - avl.c +noinst_LTLIBRARIES += libavl.la nodist_libavl_la_SOURCES = \ - $(KERNEL_C) - -include $(top_srcdir)/config/CppCheck.am + module/avl/avl.c diff --git a/sys/contrib/openzfs/lib/libefi/Makefile.am b/sys/contrib/openzfs/lib/libefi/Makefile.am index 580319a31495..5c3e57346c86 100644 --- a/sys/contrib/openzfs/lib/libefi/Makefile.am +++ b/sys/contrib/openzfs/lib/libefi/Makefile.am @@ -1,15 +1,11 @@ -include $(top_srcdir)/config/Rules.am +libefi_la_CFLAGS = $(AM_CFLAGS) $(LIBRARY_CFLAGS) +libefi_la_CFLAGS += $(LIBUUID_CFLAGS) $(ZLIB_CFLAGS) +libefi_la_CFLAGS += -fvisibility=hidden -AM_CFLAGS += $(LIBUUID_CFLAGS) $(ZLIB_CFLAGS) -AM_CFLAGS += -fvisibility=hidden +noinst_LTLIBRARIES += libefi.la +CPPCHECKTARGETS += libefi.la -noinst_LTLIBRARIES = libefi.la - -USER_C = \ - rdwr_efi.c - -libefi_la_SOURCES = $(USER_C) +libefi_la_SOURCES = \ + %D%/rdwr_efi.c libefi_la_LIBADD = $(LIBUUID_LIBS) $(ZLIB_LIBS) - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/lib/libicp/Makefile.am b/sys/contrib/openzfs/lib/libicp/Makefile.am index 382253f6fa48..304f49e39005 100644 --- a/sys/contrib/openzfs/lib/libicp/Makefile.am +++ b/sys/contrib/openzfs/lib/libicp/Makefile.am @@ -1,67 +1,50 @@ -include $(top_srcdir)/config/Rules.am +libicp_la_CCASFLAGS = $(AM_CCASFLAGS) +libicp_la_CFLAGS = $(AM_CFLAGS) $(KERNEL_CFLAGS) $(LIBRARY_CFLAGS) -VPATH = \ - $(top_srcdir)/module/icp \ - $(top_srcdir)/lib/libicp - -# Includes kernel code, generate warnings for large stack frames -AM_CFLAGS += $(FRAME_LARGER_THAN) - -noinst_LTLIBRARIES = libicp.la - -if TARGET_CPU_X86_64 -ASM_SOURCES_C = asm-x86_64/aes/aeskey.c -ASM_SOURCES_AS = \ - asm-x86_64/aes/aes_amd64.S \ - asm-x86_64/aes/aes_aesni.S \ - asm-x86_64/modes/gcm_pclmulqdq.S \ - asm-x86_64/modes/aesni-gcm-x86_64.S \ - asm-x86_64/modes/ghash-x86_64.S \ - asm-x86_64/sha2/sha256_impl.S \ - asm-x86_64/sha2/sha512_impl.S -else -ASM_SOURCES_C = -ASM_SOURCES_AS = -endif - -KERNEL_C = \ - spi/kcf_spi.c \ - api/kcf_ctxops.c \ - api/kcf_cipher.c \ - api/kcf_mac.c \ - algs/aes/aes_impl_aesni.c \ - algs/aes/aes_impl_generic.c \ - algs/aes/aes_impl_x86-64.c \ - algs/aes/aes_impl.c \ - algs/aes/aes_modes.c \ - algs/edonr/edonr.c \ - algs/modes/modes.c \ - algs/modes/cbc.c \ - algs/modes/gcm_generic.c \ - algs/modes/gcm_pclmulqdq.c \ - algs/modes/gcm.c \ - algs/modes/ctr.c \ - algs/modes/ccm.c \ - algs/modes/ecb.c \ - algs/sha2/sha2.c \ - algs/skein/skein.c \ - algs/skein/skein_block.c \ - algs/skein/skein_iv.c \ - illumos-crypto.c \ - io/aes.c \ - io/sha2_mod.c \ - io/skein_mod.c \ - core/kcf_sched.c \ - core/kcf_prov_lib.c \ - core/kcf_callprov.c \ - core/kcf_mech_tabs.c \ - core/kcf_prov_tabs.c \ - $(ASM_SOURCES_C) - -KERNEL_ASM = $(ASM_SOURCES_AS) +noinst_LTLIBRARIES += libicp.la nodist_libicp_la_SOURCES = \ - $(KERNEL_C) \ - $(KERNEL_ASM) + module/icp/spi/kcf_spi.c \ + module/icp/api/kcf_ctxops.c \ + module/icp/api/kcf_cipher.c \ + module/icp/api/kcf_mac.c \ + module/icp/algs/aes/aes_impl_aesni.c \ + module/icp/algs/aes/aes_impl_generic.c \ + module/icp/algs/aes/aes_impl_x86-64.c \ + module/icp/algs/aes/aes_impl.c \ + module/icp/algs/aes/aes_modes.c \ + module/icp/algs/edonr/edonr.c \ + module/icp/algs/modes/modes.c \ + module/icp/algs/modes/cbc.c \ + module/icp/algs/modes/gcm_generic.c \ + module/icp/algs/modes/gcm_pclmulqdq.c \ + module/icp/algs/modes/gcm.c \ + module/icp/algs/modes/ctr.c \ + module/icp/algs/modes/ccm.c \ + module/icp/algs/modes/ecb.c \ + module/icp/algs/sha2/sha2.c \ + module/icp/algs/skein/skein.c \ + module/icp/algs/skein/skein_block.c \ + module/icp/algs/skein/skein_iv.c \ + module/icp/illumos-crypto.c \ + module/icp/io/aes.c \ + module/icp/io/sha2_mod.c \ + module/icp/io/skein_mod.c \ + module/icp/core/kcf_sched.c \ + module/icp/core/kcf_prov_lib.c \ + module/icp/core/kcf_callprov.c \ + module/icp/core/kcf_mech_tabs.c \ + module/icp/core/kcf_prov_tabs.c -include $(top_srcdir)/config/CppCheck.am +if TARGET_CPU_X86_64 +nodist_libicp_la_SOURCES += \ + module/icp/asm-x86_64/aes/aeskey.c +nodist_libicp_la_SOURCES += \ + module/icp/asm-x86_64/aes/aes_amd64.S \ + module/icp/asm-x86_64/aes/aes_aesni.S \ + module/icp/asm-x86_64/modes/gcm_pclmulqdq.S \ + module/icp/asm-x86_64/modes/aesni-gcm-x86_64.S \ + module/icp/asm-x86_64/modes/ghash-x86_64.S \ + module/icp/asm-x86_64/sha2/sha256_impl.S \ + module/icp/asm-x86_64/sha2/sha512_impl.S +endif diff --git a/sys/contrib/openzfs/lib/libnvpair/Makefile.am b/sys/contrib/openzfs/lib/libnvpair/Makefile.am index 9a71a2ea6198..6d9345f5289e 100644 --- a/sys/contrib/openzfs/lib/libnvpair/Makefile.am +++ b/sys/contrib/openzfs/lib/libnvpair/Makefile.am @@ -1,40 +1,26 @@ -include $(top_srcdir)/config/Rules.am - -VPATH = \ - $(top_srcdir)/module/nvpair \ - $(top_srcdir)/lib/libnvpair - -# Includes kernel code, generate warnings for large stack frames -# and required CFLAGS for libtirpc -AM_CFLAGS += $(FRAME_LARGER_THAN) $(LIBTIRPC_CFLAGS) -AM_CFLAGS += -fvisibility=hidden +libnvpair_la_CFLAGS = $(AM_CFLAGS) $(KERNEL_CFLAGS) $(LIBRARY_CFLAGS) +libnvpair_la_CFLAGS += $(LIBTIRPC_CFLAGS) +libnvpair_la_CFLAGS += -fvisibility=hidden # wchar_t is undefined-signedness, but we compare to >=0; this warns with unsigned wchar_t -libnvpair_json.$(OBJEXT): CFLAGS += -Wno-type-limits -libnvpair_json.l$(OBJEXT): CFLAGS += -Wno-type-limits +%D%/libnvpair_la-libnvpair_json.$(OBJEXT) : CFLAGS += -Wno-type-limits +%D%/libnvpair_la-libnvpair_json.l$(OBJEXT): CFLAGS += -Wno-type-limits -lib_LTLIBRARIES = libnvpair.la - -include $(top_srcdir)/config/Abigail.am - -USER_C = \ - libnvpair.c \ - libnvpair_json.c \ - nvpair_alloc_system.c - -KERNEL_C = \ - nvpair_alloc_fixed.c \ - nvpair.c \ - fnvpair.c +lib_LTLIBRARIES += libnvpair.la +CPPCHECKTARGETS += libnvpair.la dist_libnvpair_la_SOURCES = \ - $(USER_C) + %D%/libnvpair.c \ + %D%/libnvpair_json.c \ + %D%/nvpair_alloc_system.c nodist_libnvpair_la_SOURCES = \ - $(KERNEL_C) + module/nvpair/nvpair_alloc_fixed.c \ + module/nvpair/nvpair.c \ + module/nvpair/fnvpair.c libnvpair_la_LIBADD = \ - $(abs_top_builddir)/lib/libspl/libspl_assert.la + libspl_assert.la libnvpair_la_LIBADD += $(LIBTIRPC_LIBS) $(LTLIBINTL) @@ -46,7 +32,4 @@ endif libnvpair_la_LDFLAGS += -version-info 3:0:0 -include $(top_srcdir)/config/CppCheck.am - -# Library ABI -EXTRA_DIST = libnvpair.abi libnvpair.suppr +EXTRA_DIST += $(addprefix %D%/,libnvpair.abi libnvpair.suppr) diff --git a/sys/contrib/openzfs/lib/libnvpair/libnvpair.abi b/sys/contrib/openzfs/lib/libnvpair/libnvpair.abi index f9874da81f82..de15237da583 100644 --- a/sys/contrib/openzfs/lib/libnvpair/libnvpair.abi +++ b/sys/contrib/openzfs/lib/libnvpair/libnvpair.abi @@ -2794,7 +2794,7 @@ - + diff --git a/sys/contrib/openzfs/lib/libshare/Makefile.am b/sys/contrib/openzfs/lib/libshare/Makefile.am index dff3e5382d6e..48d8cb832428 100644 --- a/sys/contrib/openzfs/lib/libshare/Makefile.am +++ b/sys/contrib/openzfs/lib/libshare/Makefile.am @@ -1,30 +1,27 @@ -include $(top_srcdir)/config/Rules.am +libshare_la_CFLAGS = $(AM_CFLAGS) $(LIBRARY_CFLAGS) +libshare_la_CFLAGS += -fvisibility=hidden -DEFAULT_INCLUDES += -I$(srcdir) +libshare_la_CPPFLAGS = $(AM_CPPFLAGS) +libshare_la_CPPFLAGS += -I$(srcdir)/%D% -AM_CFLAGS += -fvisibility=hidden +noinst_LTLIBRARIES += libshare.la +CPPCHECKTARGETS += libshare.la -noinst_LTLIBRARIES = libshare.la - -USER_C = \ - libshare_impl.h \ - libshare.c \ - nfs.c \ - nfs.h \ - smb.h +libshare_la_SOURCES = \ + %D%/libshare_impl.h \ + %D%/libshare.c \ + %D%/nfs.c \ + %D%/nfs.h \ + %D%/smb.h if BUILD_LINUX -USER_C += \ - os/linux/nfs.c \ - os/linux/smb.c +libshare_la_SOURCES += \ + %D%/os/linux/nfs.c \ + %D%/os/linux/smb.c endif if BUILD_FREEBSD -USER_C += \ - os/freebsd/nfs.c \ - os/freebsd/smb.c +libshare_la_SOURCES += \ + %D%/os/freebsd/nfs.c \ + %D%/os/freebsd/smb.c endif - -libshare_la_SOURCES = $(USER_C) - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/lib/libshare/libshare.c b/sys/contrib/openzfs/lib/libshare/libshare.c index 7bc31d7a6823..09529e5b4106 100644 --- a/sys/contrib/openzfs/lib/libshare/libshare.c +++ b/sys/contrib/openzfs/lib/libshare/libshare.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -37,139 +38,70 @@ #include #include #include "libshare_impl.h" -#include "nfs.h" -#include "smb.h" -static sa_share_impl_t alloc_share(const char *zfsname, const char *path); -static void free_share(sa_share_impl_t share); +#define init_share(zfsname, path, shareopts) \ + { \ + .sa_zfsname = zfsname, \ + .sa_mountpoint = path, \ + .sa_shareopts = shareopts, \ + } -static int fstypes_count; -static sa_fstype_t *fstypes; +#define VALIDATE_PROTOCOL(proto, ...) \ + if ((proto) < 0 || (proto) >= SA_PROTOCOL_COUNT) \ + return __VA_ARGS__ -sa_fstype_t * -register_fstype(const char *name, const sa_share_ops_t *ops) -{ - sa_fstype_t *fstype; +const char *const sa_protocol_names[SA_PROTOCOL_COUNT] = { + [SA_PROTOCOL_NFS] = "nfs", + [SA_PROTOCOL_SMB] = "smb", +}; - fstype = calloc(1, sizeof (sa_fstype_t)); - - if (fstype == NULL) - return (NULL); - - fstype->name = name; - fstype->ops = ops; - fstype->fsinfo_index = fstypes_count; - - fstypes_count++; - - fstype->next = fstypes; - fstypes = fstype; - - return (fstype); -} - -__attribute__((constructor)) static void -libshare_init(void) -{ - libshare_nfs_init(); - libshare_smb_init(); -} +static const sa_fstype_t *fstypes[SA_PROTOCOL_COUNT] = + {&libshare_nfs_type, &libshare_smb_type}; int sa_enable_share(const char *zfsname, const char *mountpoint, - const char *shareopts, char *protocol) + const char *shareopts, enum sa_protocol protocol) { - int rc, ret = SA_OK; - boolean_t found_protocol = B_FALSE; - sa_fstype_t *fstype; + VALIDATE_PROTOCOL(protocol, SA_INVALID_PROTOCOL); - sa_share_impl_t impl_share = alloc_share(zfsname, mountpoint); - if (impl_share == NULL) - return (SA_NO_MEMORY); - - fstype = fstypes; - while (fstype != NULL) { - if (strcmp(fstype->name, protocol) == 0) { - - rc = fstype->ops->update_shareopts(impl_share, - shareopts); - if (rc != SA_OK) - break; - - rc = fstype->ops->enable_share(impl_share); - if (rc != SA_OK) - ret = rc; - - found_protocol = B_TRUE; - } - - fstype = fstype->next; - } - free_share(impl_share); - - return (found_protocol ? ret : SA_INVALID_PROTOCOL); + const struct sa_share_impl args = + init_share(zfsname, mountpoint, shareopts); + return (fstypes[protocol]->enable_share(&args)); } int -sa_disable_share(const char *mountpoint, char *protocol) +sa_disable_share(const char *mountpoint, enum sa_protocol protocol) { - int rc, ret = SA_OK; - boolean_t found_protocol = B_FALSE; - sa_fstype_t *fstype; + VALIDATE_PROTOCOL(protocol, SA_INVALID_PROTOCOL); - sa_share_impl_t impl_share = alloc_share(NULL, mountpoint); - if (impl_share == NULL) - return (SA_NO_MEMORY); - - fstype = fstypes; - while (fstype != NULL) { - if (strcmp(fstype->name, protocol) == 0) { - - rc = fstype->ops->disable_share(impl_share); - if (rc != SA_OK) - ret = rc; - - found_protocol = B_TRUE; - } - - fstype = fstype->next; - } - free_share(impl_share); - - return (found_protocol ? ret : SA_INVALID_PROTOCOL); + const struct sa_share_impl args = init_share(NULL, mountpoint, NULL); + return (fstypes[protocol]->disable_share(&args)); } boolean_t -sa_is_shared(const char *mountpoint, char *protocol) +sa_is_shared(const char *mountpoint, enum sa_protocol protocol) { - sa_fstype_t *fstype; - boolean_t ret = B_FALSE; + VALIDATE_PROTOCOL(protocol, B_FALSE); - /* guid value is not used */ - sa_share_impl_t impl_share = alloc_share(NULL, mountpoint); - if (impl_share == NULL) - return (B_FALSE); - - fstype = fstypes; - while (fstype != NULL) { - if (strcmp(fstype->name, protocol) == 0) { - ret = fstype->ops->is_shared(impl_share); - } - fstype = fstype->next; - } - free_share(impl_share); - return (ret); + const struct sa_share_impl args = init_share(NULL, mountpoint, NULL); + return (fstypes[protocol]->is_shared(&args)); } void -sa_commit_shares(const char *protocol) +sa_commit_shares(enum sa_protocol protocol) { - sa_fstype_t *fstype = fstypes; - while (fstype != NULL) { - if (strcmp(fstype->name, protocol) == 0) - fstype->ops->commit_shares(); - fstype = fstype->next; - } + /* CSTYLED */ + VALIDATE_PROTOCOL(protocol, ); + + fstypes[protocol]->commit_shares(); +} + +int +sa_validate_shareopts(const char *options, enum sa_protocol protocol) +{ + VALIDATE_PROTOCOL(protocol, SA_INVALID_PROTOCOL); + + return (fstypes[protocol]->validate_shareopts(options)); } /* @@ -177,189 +109,85 @@ sa_commit_shares(const char *protocol) * * convert an error value to an error string */ -char * +const char * sa_errorstr(int err) { static char errstr[32]; - char *ret = NULL; switch (err) { case SA_OK: - ret = dgettext(TEXT_DOMAIN, "ok"); - break; + return (dgettext(TEXT_DOMAIN, "ok")); case SA_NO_SUCH_PATH: - ret = dgettext(TEXT_DOMAIN, "path doesn't exist"); - break; + return (dgettext(TEXT_DOMAIN, "path doesn't exist")); case SA_NO_MEMORY: - ret = dgettext(TEXT_DOMAIN, "no memory"); - break; + return (dgettext(TEXT_DOMAIN, "no memory")); case SA_DUPLICATE_NAME: - ret = dgettext(TEXT_DOMAIN, "name in use"); - break; + return (dgettext(TEXT_DOMAIN, "name in use")); case SA_BAD_PATH: - ret = dgettext(TEXT_DOMAIN, "bad path"); - break; + return (dgettext(TEXT_DOMAIN, "bad path")); case SA_NO_SUCH_GROUP: - ret = dgettext(TEXT_DOMAIN, "no such group"); - break; + return (dgettext(TEXT_DOMAIN, "no such group")); case SA_CONFIG_ERR: - ret = dgettext(TEXT_DOMAIN, "configuration error"); - break; + return (dgettext(TEXT_DOMAIN, "configuration error")); case SA_SYSTEM_ERR: - ret = dgettext(TEXT_DOMAIN, "system error"); - break; + return (dgettext(TEXT_DOMAIN, "system error")); case SA_SYNTAX_ERR: - ret = dgettext(TEXT_DOMAIN, "syntax error"); - break; + return (dgettext(TEXT_DOMAIN, "syntax error")); case SA_NO_PERMISSION: - ret = dgettext(TEXT_DOMAIN, "no permission"); - break; + return (dgettext(TEXT_DOMAIN, "no permission")); case SA_BUSY: - ret = dgettext(TEXT_DOMAIN, "busy"); - break; + return (dgettext(TEXT_DOMAIN, "busy")); case SA_NO_SUCH_PROP: - ret = dgettext(TEXT_DOMAIN, "no such property"); - break; + return (dgettext(TEXT_DOMAIN, "no such property")); case SA_INVALID_NAME: - ret = dgettext(TEXT_DOMAIN, "invalid name"); - break; + return (dgettext(TEXT_DOMAIN, "invalid name")); case SA_INVALID_PROTOCOL: - ret = dgettext(TEXT_DOMAIN, "invalid protocol"); - break; + return (dgettext(TEXT_DOMAIN, "invalid protocol")); case SA_NOT_ALLOWED: - ret = dgettext(TEXT_DOMAIN, "operation not allowed"); - break; + return (dgettext(TEXT_DOMAIN, "operation not allowed")); case SA_BAD_VALUE: - ret = dgettext(TEXT_DOMAIN, "bad property value"); - break; + return (dgettext(TEXT_DOMAIN, "bad property value")); case SA_INVALID_SECURITY: - ret = dgettext(TEXT_DOMAIN, "invalid security type"); - break; + return (dgettext(TEXT_DOMAIN, "invalid security type")); case SA_NO_SUCH_SECURITY: - ret = dgettext(TEXT_DOMAIN, "security type not found"); - break; + return (dgettext(TEXT_DOMAIN, "security type not found")); case SA_VALUE_CONFLICT: - ret = dgettext(TEXT_DOMAIN, "property value conflict"); - break; + return (dgettext(TEXT_DOMAIN, "property value conflict")); case SA_NOT_IMPLEMENTED: - ret = dgettext(TEXT_DOMAIN, "not implemented"); - break; + return (dgettext(TEXT_DOMAIN, "not implemented")); case SA_INVALID_PATH: - ret = dgettext(TEXT_DOMAIN, "invalid path"); - break; + return (dgettext(TEXT_DOMAIN, "invalid path")); case SA_NOT_SUPPORTED: - ret = dgettext(TEXT_DOMAIN, "operation not supported"); - break; + return (dgettext(TEXT_DOMAIN, "operation not supported")); case SA_PROP_SHARE_ONLY: - ret = dgettext(TEXT_DOMAIN, "property not valid for group"); - break; + return (dgettext(TEXT_DOMAIN, "property not valid for group")); case SA_NOT_SHARED: - ret = dgettext(TEXT_DOMAIN, "not shared"); - break; + return (dgettext(TEXT_DOMAIN, "not shared")); case SA_NO_SUCH_RESOURCE: - ret = dgettext(TEXT_DOMAIN, "no such resource"); - break; + return (dgettext(TEXT_DOMAIN, "no such resource")); case SA_RESOURCE_REQUIRED: - ret = dgettext(TEXT_DOMAIN, "resource name required"); - break; + return (dgettext(TEXT_DOMAIN, "resource name required")); case SA_MULTIPLE_ERROR: - ret = dgettext(TEXT_DOMAIN, "errors from multiple protocols"); - break; + return (dgettext(TEXT_DOMAIN, + "errors from multiple protocols")); case SA_PATH_IS_SUBDIR: - ret = dgettext(TEXT_DOMAIN, "path is a subpath of share"); - break; + return (dgettext(TEXT_DOMAIN, "path is a subpath of share")); case SA_PATH_IS_PARENTDIR: - ret = dgettext(TEXT_DOMAIN, "path is parent of a share"); - break; + return (dgettext(TEXT_DOMAIN, "path is parent of a share")); case SA_NO_SECTION: - ret = dgettext(TEXT_DOMAIN, "protocol requires a section"); - break; + return (dgettext(TEXT_DOMAIN, "protocol requires a section")); case SA_NO_PROPERTIES: - ret = dgettext(TEXT_DOMAIN, "properties not found"); - break; + return (dgettext(TEXT_DOMAIN, "properties not found")); case SA_NO_SUCH_SECTION: - ret = dgettext(TEXT_DOMAIN, "section not found"); - break; + return (dgettext(TEXT_DOMAIN, "section not found")); case SA_PASSWORD_ENC: - ret = dgettext(TEXT_DOMAIN, "passwords must be encrypted"); - break; + return (dgettext(TEXT_DOMAIN, "passwords must be encrypted")); case SA_SHARE_EXISTS: - ret = dgettext(TEXT_DOMAIN, "path or file is already shared"); - break; + return (dgettext(TEXT_DOMAIN, + "path or file is already shared")); default: (void) snprintf(errstr, sizeof (errstr), dgettext(TEXT_DOMAIN, "unknown %d"), err); - ret = errstr; + return (errstr); } - return (ret); -} - -int -sa_validate_shareopts(char *options, char *proto) -{ - sa_fstype_t *fstype; - - fstype = fstypes; - while (fstype != NULL) { - if (strcmp(fstype->name, proto) != 0) { - fstype = fstype->next; - continue; - } - - return (fstype->ops->validate_shareopts(options)); - } - - return (SA_INVALID_PROTOCOL); -} - -static sa_share_impl_t -alloc_share(const char *zfsname, const char *mountpoint) -{ - sa_share_impl_t impl_share; - - impl_share = calloc(1, sizeof (struct sa_share_impl)); - - if (impl_share == NULL) - return (NULL); - - if (mountpoint != NULL && - ((impl_share->sa_mountpoint = strdup(mountpoint)) == NULL)) { - free(impl_share); - return (NULL); - } - - if (zfsname != NULL && - ((impl_share->sa_zfsname = strdup(zfsname)) == NULL)) { - free(impl_share->sa_mountpoint); - free(impl_share); - return (NULL); - } - - impl_share->sa_fsinfo = calloc(fstypes_count, - sizeof (sa_share_fsinfo_t)); - if (impl_share->sa_fsinfo == NULL) { - free(impl_share->sa_mountpoint); - free(impl_share->sa_zfsname); - free(impl_share); - return (NULL); - } - - return (impl_share); -} - -static void -free_share(sa_share_impl_t impl_share) -{ - sa_fstype_t *fstype; - - fstype = fstypes; - while (fstype != NULL) { - fstype->ops->clear_shareopts(impl_share); - fstype = fstype->next; - } - - free(impl_share->sa_mountpoint); - free(impl_share->sa_zfsname); - free(impl_share->sa_fsinfo); - free(impl_share); } diff --git a/sys/contrib/openzfs/lib/libshare/libshare_impl.h b/sys/contrib/openzfs/lib/libshare/libshare_impl.h index 63a6907539e0..110fe93d250f 100644 --- a/sys/contrib/openzfs/lib/libshare/libshare_impl.h +++ b/sys/contrib/openzfs/lib/libshare/libshare_impl.h @@ -27,39 +27,20 @@ #ifndef _LIBSPL_LIBSHARE_IMPL_H #define _LIBSPL_LIBSHARE_IMPL_H -typedef struct sa_share_fsinfo { - char *shareopts; -} sa_share_fsinfo_t; - -typedef struct sa_share_impl { - char *sa_mountpoint; - char *sa_zfsname; - - sa_share_fsinfo_t *sa_fsinfo; /* per-fstype information */ +typedef const struct sa_share_impl { + const char *sa_zfsname; + const char *sa_mountpoint; + const char *sa_shareopts; } *sa_share_impl_t; -#define FSINFO(impl_share, fstype) \ - (&(impl_share->sa_fsinfo[fstype->fsinfo_index])) - -typedef struct sa_share_ops { - int (*enable_share)(sa_share_impl_t share); - int (*disable_share)(sa_share_impl_t share); - boolean_t (*is_shared)(sa_share_impl_t share); - int (*validate_shareopts)(const char *shareopts); - int (*update_shareopts)(sa_share_impl_t impl_share, - const char *shareopts); - void (*clear_shareopts)(sa_share_impl_t impl_share); - int (*commit_shares)(void); -} sa_share_ops_t; - -typedef struct sa_fstype { - struct sa_fstype *next; - - const char *name; - const sa_share_ops_t *ops; - int fsinfo_index; +typedef struct { + int (*const enable_share)(sa_share_impl_t share); + int (*const disable_share)(sa_share_impl_t share); + boolean_t (*const is_shared)(sa_share_impl_t share); + int (*const validate_shareopts)(const char *shareopts); + int (*const commit_shares)(void); } sa_fstype_t; -sa_fstype_t *register_fstype(const char *name, const sa_share_ops_t *ops); +extern const sa_fstype_t libshare_nfs_type, libshare_smb_type; #endif /* _LIBSPL_LIBSHARE_IMPL_H */ diff --git a/sys/contrib/openzfs/lib/libshare/nfs.c b/sys/contrib/openzfs/lib/libshare/nfs.c index 2a901bcec503..2146346cf08c 100644 --- a/sys/contrib/openzfs/lib/libshare/nfs.c +++ b/sys/contrib/openzfs/lib/libshare/nfs.c @@ -24,39 +24,37 @@ #include #include #include +#include #include #include #include #include "nfs.h" -static int nfs_lock_fd = -1; - - /* * nfs_exports_[lock|unlock] are used to guard against conconcurrent * updates to the exports file. Each protocol is responsible for * providing the necessary locking to ensure consistency. */ static int -nfs_exports_lock(const char *name) +nfs_exports_lock(const char *name, int *nfs_lock_fd) { int err; - nfs_lock_fd = open(name, O_RDWR | O_CREAT | O_CLOEXEC, 0600); - if (nfs_lock_fd == -1) { + *nfs_lock_fd = open(name, O_RDWR | O_CREAT | O_CLOEXEC, 0600); + if (*nfs_lock_fd == -1) { err = errno; fprintf(stderr, "failed to lock %s: %s\n", name, strerror(err)); return (err); } - while ((err = flock(nfs_lock_fd, LOCK_EX)) != 0 && errno == EINTR) + while ((err = flock(*nfs_lock_fd, LOCK_EX)) != 0 && errno == EINTR) ; if (err != 0) { err = errno; fprintf(stderr, "failed to lock %s: %s\n", name, strerror(err)); - (void) close(nfs_lock_fd); - nfs_lock_fd = -1; + (void) close(*nfs_lock_fd); + *nfs_lock_fd = -1; return (err); } @@ -64,17 +62,16 @@ nfs_exports_lock(const char *name) } static void -nfs_exports_unlock(const char *name) +nfs_exports_unlock(const char *name, int *nfs_lock_fd) { - verify(nfs_lock_fd > 0); + verify(*nfs_lock_fd > 0); - if (flock(nfs_lock_fd, LOCK_UN) != 0) { + if (flock(*nfs_lock_fd, LOCK_UN) != 0) fprintf(stderr, "failed to unlock %s: %s\n", name, strerror(errno)); - } - (void) close(nfs_lock_fd); - nfs_lock_fd = -1; + (void) close(*nfs_lock_fd); + *nfs_lock_fd = -1; } struct tmpfile { @@ -147,6 +144,34 @@ nfs_fini_tmpfile(const char *exports, struct tmpfile *tmpf) return (SA_OK); } +int +nfs_escape_mountpoint(const char *mp, char **out, boolean_t *need_free) +{ + if (strpbrk(mp, "\t\n\v\f\r \\") == NULL) { + *out = (char *)mp; + *need_free = B_FALSE; + return (SA_OK); + } else { + size_t len = strlen(mp); + *out = malloc(len * 4 + 1); + if (!*out) + return (SA_NO_MEMORY); + *need_free = B_TRUE; + + char *oc = *out; + for (const char *c = mp; c < mp + len; ++c) + if (memchr("\t\n\v\f\r \\", *c, + strlen("\t\n\v\f\r \\"))) { + sprintf(oc, "\\%03hho", *c); + oc += 4; + } else + *oc++ = *c; + *oc = '\0'; + } + + return (SA_OK); +} + static int nfs_process_exports(const char *exports, const char *mountpoint, boolean_t (*cbk)(void *userdata, char *line, boolean_t found_mountpoint), @@ -157,8 +182,16 @@ nfs_process_exports(const char *exports, const char *mountpoint, FILE *oldfp = fopen(exports, "re"); if (oldfp != NULL) { + boolean_t need_mp_free; + char *mp; + if ((error = nfs_escape_mountpoint(mountpoint, + &mp, &need_mp_free)) != SA_OK) { + (void) fclose(oldfp); + return (error); + } + char *buf = NULL, *sep; - size_t buflen = 0, mplen = strlen(mountpoint); + size_t buflen = 0, mplen = strlen(mp); while (cont && getline(&buf, &buflen, oldfp) != -1) { if (buf[0] == '\n' || buf[0] == '#') @@ -167,9 +200,11 @@ nfs_process_exports(const char *exports, const char *mountpoint, cont = cbk(userdata, buf, (sep = strpbrk(buf, "\t \n")) != NULL && sep - buf == mplen && - strncmp(buf, mountpoint, mplen) == 0); + strncmp(buf, mp, mplen) == 0); } free(buf); + if (need_mp_free) + free(mp); if (ferror(oldfp) != 0) error = ferror(oldfp); @@ -216,13 +251,13 @@ nfs_toggle_share(const char *lockfile, const char *exports, const char *expdir, sa_share_impl_t impl_share, int(*cbk)(sa_share_impl_t impl_share, FILE *tmpfile)) { - int error; + int error, nfs_lock_fd = -1; struct tmpfile tmpf; if (!nfs_init_tmpfile(exports, expdir, &tmpf)) return (SA_SYSTEM_ERR); - error = nfs_exports_lock(lockfile); + error = nfs_exports_lock(lockfile, &nfs_lock_fd); if (error != 0) { nfs_abort_tmpfile(&tmpf); return (error); @@ -237,12 +272,12 @@ nfs_toggle_share(const char *lockfile, const char *exports, goto fullerr; error = nfs_fini_tmpfile(exports, &tmpf); - nfs_exports_unlock(lockfile); + nfs_exports_unlock(lockfile, &nfs_lock_fd); return (error); fullerr: nfs_abort_tmpfile(&tmpf); - nfs_exports_unlock(lockfile); + nfs_exports_unlock(lockfile, &nfs_lock_fd); return (error); } diff --git a/sys/contrib/openzfs/lib/libshare/nfs.h b/sys/contrib/openzfs/lib/libshare/nfs.h index cfac274c3d26..24ae1f8adb85 100644 --- a/sys/contrib/openzfs/lib/libshare/nfs.h +++ b/sys/contrib/openzfs/lib/libshare/nfs.h @@ -28,8 +28,7 @@ #define FILE_HEADER "# !!! DO NOT EDIT THIS FILE MANUALLY !!!\n\n" -void libshare_nfs_init(void); - +int nfs_escape_mountpoint(const char *mp, char **out, boolean_t *need_free); boolean_t nfs_is_shared_impl(const char *exports, sa_share_impl_t impl_share); int nfs_toggle_share(const char *lockfile, const char *exports, const char *expdir, sa_share_impl_t impl_share, diff --git a/sys/contrib/openzfs/lib/libshare/os/freebsd/nfs.c b/sys/contrib/openzfs/lib/libshare/os/freebsd/nfs.c index ea02dc1bae3c..78977a25f4f5 100644 --- a/sys/contrib/openzfs/lib/libshare/os/freebsd/nfs.c +++ b/sys/contrib/openzfs/lib/libshare/os/freebsd/nfs.c @@ -52,10 +52,8 @@ __FBSDID("$FreeBSD$"); #define ZFS_EXPORTS_FILE "/etc/zfs/exports" #define ZFS_EXPORTS_LOCK ZFS_EXPORTS_FILE".lock" -static sa_fstype_t *nfs_fstype; - /* - * This function translate options to a format acceptable by exports(5), eg. + * This function translates options to a format acceptable by exports(5), eg. * * -ro -network=192.168.0.0 -mask=255.255.255.0 -maproot=0 \ * zfs.freebsd.org 69.147.83.54 @@ -72,17 +70,14 @@ static sa_fstype_t *nfs_fstype; * * ro, maproot, mapall, mask, network, sec, alldirs, public, webnfs, * index, quiet - * - * NOTE: This function returns a static buffer and thus is not thread-safe. */ -static char * -translate_opts(const char *shareopts) +static int +translate_opts(const char *shareopts, FILE *out) { - static const char *known_opts[] = { "ro", "maproot", "mapall", "mask", - "network", "sec", "alldirs", "public", "webnfs", "index", "quiet", - NULL }; - static char newopts[OPTSSIZE]; - char oldopts[OPTSSIZE]; + static const char *const known_opts[] = { "ro", "maproot", "mapall", + "mask", "network", "sec", "alldirs", "public", "webnfs", "index", + "quiet" }; + char oldopts[OPTSSIZE], newopts[OPTSSIZE]; char *o, *s = NULL; unsigned int i; size_t len; @@ -93,7 +88,7 @@ translate_opts(const char *shareopts) while ((o = strsep(&s, "-, ")) != NULL) { if (o[0] == '\0') continue; - for (i = 0; known_opts[i] != NULL; i++) { + for (i = 0; i < ARRAY_SIZE(known_opts); ++i) { len = strlen(known_opts[i]); if (strncmp(known_opts[i], o, len) == 0 && (o[len] == '\0' || o[len] == '=')) { @@ -104,23 +99,34 @@ translate_opts(const char *shareopts) strlcat(newopts, o, sizeof (newopts)); strlcat(newopts, " ", sizeof (newopts)); } - return (newopts); + return (fputs(newopts, out)); } static int nfs_enable_share_impl(sa_share_impl_t impl_share, FILE *tmpfile) { - char *shareopts = FSINFO(impl_share, nfs_fstype)->shareopts; + const char *shareopts = impl_share->sa_shareopts; if (strcmp(shareopts, "on") == 0) shareopts = ""; - if (fprintf(tmpfile, "%s\t%s\n", impl_share->sa_mountpoint, - translate_opts(shareopts)) < 0) { + boolean_t need_free; + char *mp; + int rc = nfs_escape_mountpoint(impl_share->sa_mountpoint, &mp, + &need_free); + if (rc != SA_OK) + return (rc); + + if (fputs(mp, tmpfile) == EOF || + fputc('\t', tmpfile) == EOF || + translate_opts(shareopts, tmpfile) == EOF || + fputc('\n', tmpfile) == EOF) { fprintf(stderr, "failed to write to temporary file\n"); - return (SA_SYSTEM_ERR); + rc = SA_SYSTEM_ERR; } - return (SA_OK); + if (need_free) + free(mp); + return (rc); } static int @@ -159,19 +165,6 @@ nfs_validate_shareopts(const char *shareopts) return (SA_OK); } -static int -nfs_update_shareopts(sa_share_impl_t impl_share, const char *shareopts) -{ - FSINFO(impl_share, nfs_fstype)->shareopts = (char *)shareopts; - return (SA_OK); -} - -static void -nfs_clear_shareopts(sa_share_impl_t impl_share) -{ - FSINFO(impl_share, nfs_fstype)->shareopts = NULL; -} - /* * Commit the shares by restarting mountd. */ @@ -202,22 +195,11 @@ nfs_commit_shares(void) return (SA_OK); } -static const sa_share_ops_t nfs_shareops = { +const sa_fstype_t libshare_nfs_type = { .enable_share = nfs_enable_share, .disable_share = nfs_disable_share, .is_shared = nfs_is_shared, .validate_shareopts = nfs_validate_shareopts, - .update_shareopts = nfs_update_shareopts, - .clear_shareopts = nfs_clear_shareopts, .commit_shares = nfs_commit_shares, }; - -/* - * Initializes the NFS functionality of libshare. - */ -void -libshare_nfs_init(void) -{ - nfs_fstype = register_fstype("nfs", &nfs_shareops); -} diff --git a/sys/contrib/openzfs/lib/libshare/os/freebsd/smb.c b/sys/contrib/openzfs/lib/libshare/os/freebsd/smb.c index 445784b756bc..0f546dc5543e 100644 --- a/sys/contrib/openzfs/lib/libshare/os/freebsd/smb.c +++ b/sys/contrib/openzfs/lib/libshare/os/freebsd/smb.c @@ -23,22 +23,9 @@ * Copyright (c) 2020 by Delphix. All rights reserved. */ -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include #include #include "libshare_impl.h" -#include "smb.h" - -static sa_fstype_t *smb_fstype; /* * Enables SMB sharing for the specified share. @@ -47,7 +34,7 @@ static int smb_enable_share(sa_share_impl_t impl_share) { (void) impl_share; - fprintf(stderr, "No SMB support in FreeBSD yet.\n"); + fputs("No SMB support in FreeBSD yet.\n", stderr); return (SA_NOT_SUPPORTED); } /* @@ -57,7 +44,7 @@ static int smb_disable_share(sa_share_impl_t impl_share) { (void) impl_share; - fprintf(stderr, "No SMB support in FreeBSD yet.\n"); + fputs("No SMB support in FreeBSD yet.\n", stderr); return (SA_NOT_SUPPORTED); } @@ -68,7 +55,7 @@ static int smb_validate_shareopts(const char *shareopts) { (void) shareopts; - fprintf(stderr, "No SMB support in FreeBSD yet.\n"); + fputs("No SMB support in FreeBSD yet.\n", stderr); return (SA_NOT_SUPPORTED); } @@ -82,51 +69,18 @@ smb_is_share_active(sa_share_impl_t impl_share) return (B_FALSE); } -/* - * Called to update a share's options. A share's options might be out of - * date if the share was loaded from disk and the "sharesmb" dataset - * property has changed in the meantime. This function also takes care - * of re-enabling the share if necessary. - */ -static int -smb_update_shareopts(sa_share_impl_t impl_share, const char *shareopts) -{ - (void) impl_share, (void) shareopts; - return (SA_OK); -} - static int smb_update_shares(void) { /* Not implemented */ return (0); } -/* - * Clears a share's SMB options. Used by libshare to - * clean up shares that are about to be free()'d. - */ -static void -smb_clear_shareopts(sa_share_impl_t impl_share) -{ - FSINFO(impl_share, smb_fstype)->shareopts = NULL; -} -static const sa_share_ops_t smb_shareops = { +const sa_fstype_t libshare_smb_type = { .enable_share = smb_enable_share, .disable_share = smb_disable_share, .is_shared = smb_is_share_active, .validate_shareopts = smb_validate_shareopts, - .update_shareopts = smb_update_shareopts, - .clear_shareopts = smb_clear_shareopts, .commit_shares = smb_update_shares, }; - -/* - * Initializes the SMB functionality of libshare. - */ -void -libshare_smb_init(void) -{ - smb_fstype = register_fstype("smb", &smb_shareops); -} diff --git a/sys/contrib/openzfs/lib/libshare/os/linux/nfs.c b/sys/contrib/openzfs/lib/libshare/os/linux/nfs.c index 5acfa3fb8545..1da6d1617247 100644 --- a/sys/contrib/openzfs/lib/libshare/os/linux/nfs.c +++ b/sys/contrib/openzfs/lib/libshare/os/linux/nfs.c @@ -45,7 +45,8 @@ #define ZFS_EXPORTS_FILE ZFS_EXPORTS_DIR"/zfs.exports" #define ZFS_EXPORTS_LOCK ZFS_EXPORTS_FILE".lock" -static sa_fstype_t *nfs_fstype; + +static boolean_t nfs_available(void); typedef int (*nfs_shareopt_callback_t)(const char *opt, const char *value, void *cookie); @@ -229,7 +230,6 @@ foreach_nfs_host(sa_share_impl_t impl_share, FILE *tmpfile, nfs_host_callback_t callback, void *cookie) { nfs_host_cookie_t udata; - char *shareopts; udata.callback = callback; udata.sharepath = impl_share->sa_mountpoint; @@ -237,10 +237,8 @@ foreach_nfs_host(sa_share_impl_t impl_share, FILE *tmpfile, udata.tmpfile = tmpfile; udata.security = "sys"; - shareopts = FSINFO(impl_share, nfs_fstype)->shareopts; - - return (foreach_nfs_shareopt(shareopts, foreach_nfs_host_cb, - &udata)); + return (foreach_nfs_shareopt(impl_share->sa_shareopts, + foreach_nfs_host_cb, &udata)); } /* @@ -299,6 +297,11 @@ add_linux_shareopt(char **plinux_opts, const char *key, const char *value) return (SA_OK); } +static int string_cmp(const void *lhs, const void *rhs) { + const char *const *l = lhs, *const *r = rhs; + return (strcmp(*l, *r)); +} + /* * Validates and converts a single Solaris share option to its Linux * equivalent. @@ -306,6 +309,15 @@ add_linux_shareopt(char **plinux_opts, const char *key, const char *value) static int get_linux_shareopts_cb(const char *key, const char *value, void *cookie) { + /* This list must remain sorted, since we bsearch() it */ + static const char *const valid_keys[] = { "all_squash", "anongid", + "anonuid", "async", "auth_nlm", "crossmnt", "fsid", "fsuid", "hide", + "insecure", "insecure_locks", "mountpoint", "mp", "no_acl", + "no_all_squash", "no_auth_nlm", "no_root_squash", + "no_subtree_check", "no_wdelay", "nohide", "refer", "replicas", + "root_squash", "secure", "secure_locks", "subtree_check", "sync", + "wdelay" }; + char **plinux_opts = (char **)cookie; /* host-specific options, these are taken care of elsewhere */ @@ -324,26 +336,9 @@ get_linux_shareopts_cb(const char *key, const char *value, void *cookie) if (strcmp(key, "nosub") == 0) key = "subtree_check"; - if (strcmp(key, "insecure") != 0 && strcmp(key, "secure") != 0 && - strcmp(key, "async") != 0 && strcmp(key, "sync") != 0 && - strcmp(key, "no_wdelay") != 0 && strcmp(key, "wdelay") != 0 && - strcmp(key, "nohide") != 0 && strcmp(key, "hide") != 0 && - strcmp(key, "crossmnt") != 0 && - strcmp(key, "no_subtree_check") != 0 && - strcmp(key, "subtree_check") != 0 && - strcmp(key, "insecure_locks") != 0 && - strcmp(key, "secure_locks") != 0 && - strcmp(key, "no_auth_nlm") != 0 && strcmp(key, "auth_nlm") != 0 && - strcmp(key, "no_acl") != 0 && strcmp(key, "mountpoint") != 0 && - strcmp(key, "mp") != 0 && strcmp(key, "fsuid") != 0 && - strcmp(key, "refer") != 0 && strcmp(key, "replicas") != 0 && - strcmp(key, "root_squash") != 0 && - strcmp(key, "no_root_squash") != 0 && - strcmp(key, "all_squash") != 0 && - strcmp(key, "no_all_squash") != 0 && strcmp(key, "fsid") != 0 && - strcmp(key, "anonuid") != 0 && strcmp(key, "anongid") != 0) { + if (bsearch(&key, valid_keys, ARRAY_SIZE(valid_keys), + sizeof (*valid_keys), string_cmp) == NULL) return (SA_SYNTAX_ERR); - } (void) add_linux_shareopt(plinux_opts, key, value); @@ -395,14 +390,21 @@ nfs_add_entry(FILE *tmpfile, const char *sharepath, if (linux_opts == NULL) linux_opts = ""; - if (fprintf(tmpfile, "%s %s(sec=%s,%s,%s)\n", sharepath, + boolean_t need_free; + char *mp; + int rc = nfs_escape_mountpoint(sharepath, &mp, &need_free); + if (rc != SA_OK) + return (rc); + if (fprintf(tmpfile, "%s %s(sec=%s,%s,%s)\n", mp, get_linux_hostspec(host), security, access_opts, linux_opts) < 0) { fprintf(stderr, "failed to write to temporary file\n"); - return (SA_SYSTEM_ERR); + rc = SA_SYSTEM_ERR; } - return (SA_OK); + if (need_free) + free(mp); + return (rc); } /* @@ -411,11 +413,8 @@ nfs_add_entry(FILE *tmpfile, const char *sharepath, static int nfs_enable_share_impl(sa_share_impl_t impl_share, FILE *tmpfile) { - char *shareopts, *linux_opts; - int error; - - shareopts = FSINFO(impl_share, nfs_fstype)->shareopts; - error = get_linux_shareopts(shareopts, &linux_opts); + char *linux_opts = NULL; + int error = get_linux_shareopts(impl_share->sa_shareopts, &linux_opts); if (error != SA_OK) return (error); @@ -428,6 +427,9 @@ nfs_enable_share_impl(sa_share_impl_t impl_share, FILE *tmpfile) static int nfs_enable_share(sa_share_impl_t impl_share) { + if (!nfs_available()) + return (SA_SYSTEM_ERR); + return (nfs_toggle_share( ZFS_EXPORTS_LOCK, ZFS_EXPORTS_FILE, ZFS_EXPORTS_DIR, impl_share, nfs_enable_share_impl)); @@ -446,6 +448,9 @@ nfs_disable_share_impl(sa_share_impl_t impl_share, FILE *tmpfile) static int nfs_disable_share(sa_share_impl_t impl_share) { + if (!nfs_available()) + return (SA_SYSTEM_ERR); + return (nfs_toggle_share( ZFS_EXPORTS_LOCK, ZFS_EXPORTS_FILE, ZFS_EXPORTS_DIR, impl_share, nfs_disable_share_impl)); @@ -454,6 +459,9 @@ nfs_disable_share(sa_share_impl_t impl_share) static boolean_t nfs_is_shared(sa_share_impl_t impl_share) { + if (!nfs_available()) + return (SA_SYSTEM_ERR); + return (nfs_is_shared_impl(ZFS_EXPORTS_FILE, impl_share)); } @@ -463,11 +471,8 @@ nfs_is_shared(sa_share_impl_t impl_share) static int nfs_validate_shareopts(const char *shareopts) { - char *linux_opts; - int error; - - error = get_linux_shareopts(shareopts, &linux_opts); - + char *linux_opts = NULL; + int error = get_linux_shareopts(shareopts, &linux_opts); if (error != SA_OK) return (error); @@ -475,51 +480,41 @@ nfs_validate_shareopts(const char *shareopts) return (SA_OK); } -static int -nfs_update_shareopts(sa_share_impl_t impl_share, const char *shareopts) -{ - FSINFO(impl_share, nfs_fstype)->shareopts = (char *)shareopts; - return (SA_OK); -} - -/* - * Clears a share's NFS options. Used by libshare to - * clean up shares that are about to be free()'d. - */ -static void -nfs_clear_shareopts(sa_share_impl_t impl_share) -{ - FSINFO(impl_share, nfs_fstype)->shareopts = NULL; -} - static int nfs_commit_shares(void) { + if (!nfs_available()) + return (SA_SYSTEM_ERR); + char *argv[] = { - "/usr/sbin/exportfs", - "-ra", + (char *)"/usr/sbin/exportfs", + (char *)"-ra", NULL }; return (libzfs_run_process(argv[0], argv, 0)); } -static const sa_share_ops_t nfs_shareops = { +const sa_fstype_t libshare_nfs_type = { .enable_share = nfs_enable_share, .disable_share = nfs_disable_share, .is_shared = nfs_is_shared, .validate_shareopts = nfs_validate_shareopts, - .update_shareopts = nfs_update_shareopts, - .clear_shareopts = nfs_clear_shareopts, .commit_shares = nfs_commit_shares, }; -/* - * Initializes the NFS functionality of libshare. - */ -void -libshare_nfs_init(void) +static boolean_t +nfs_available(void) { - nfs_fstype = register_fstype("nfs", &nfs_shareops); + static int avail; + + if (!avail) { + if (access("/usr/sbin/exportfs", F_OK) != 0) + avail = -1; + else + avail = 1; + } + + return (avail == 1); } diff --git a/sys/contrib/openzfs/lib/libshare/os/linux/smb.c b/sys/contrib/openzfs/lib/libshare/os/linux/smb.c index bcb9b427031f..2a2b32bc10e9 100644 --- a/sys/contrib/openzfs/lib/libshare/os/linux/smb.c +++ b/sys/contrib/openzfs/lib/libshare/os/linux/smb.c @@ -63,9 +63,7 @@ static boolean_t smb_available(void); -static sa_fstype_t *smb_fstype; - -smb_share_t *smb_shares; +static smb_share_t *smb_shares; static int smb_disable_share(sa_share_impl_t impl_share); static boolean_t smb_is_share_active(sa_share_impl_t impl_share); @@ -218,46 +216,39 @@ smb_retrieve_shares(void) static int smb_enable_share_one(const char *sharename, const char *sharepath) { - char *argv[10], *pos; char name[SMB_NAME_MAX], comment[SMB_COMMENT_MAX]; - int rc; /* Support ZFS share name regexp '[[:alnum:]_-.: ]' */ strlcpy(name, sharename, sizeof (name)); - name [sizeof (name)-1] = '\0'; - - pos = name; - while (*pos != '\0') { - switch (*pos) { + for (char *itr = name; *itr != '\0'; ++itr) + switch (*itr) { case '/': case '-': case ':': case ' ': - *pos = '_'; + *itr = '_'; } - ++pos; - } - /* * CMD: net -S NET_CMD_ARG_HOST usershare add Test1 /share/Test1 \ * "Comment" "Everyone:F" */ snprintf(comment, sizeof (comment), "Comment: %s", sharepath); - argv[0] = NET_CMD_PATH; - argv[1] = (char *)"-S"; - argv[2] = NET_CMD_ARG_HOST; - argv[3] = (char *)"usershare"; - argv[4] = (char *)"add"; - argv[5] = (char *)name; - argv[6] = (char *)sharepath; - argv[7] = (char *)comment; - argv[8] = (char *)"Everyone:F"; - argv[9] = NULL; + char *argv[] = { + (char *)NET_CMD_PATH, + (char *)"-S", + (char *)NET_CMD_ARG_HOST, + (char *)"usershare", + (char *)"add", + name, + (char *)sharepath, + comment, + (char *)"Everyone:F", + NULL, + }; - rc = libzfs_run_process(argv[0], argv, 0); - if (rc < 0) + if (libzfs_run_process(argv[0], argv, 0) < 0) return (SA_SYSTEM_ERR); /* Reload the share file */ @@ -272,19 +263,16 @@ smb_enable_share_one(const char *sharename, const char *sharepath) static int smb_enable_share(sa_share_impl_t impl_share) { - char *shareopts; - if (!smb_available()) return (SA_SYSTEM_ERR); if (smb_is_share_active(impl_share)) smb_disable_share(impl_share); - shareopts = FSINFO(impl_share, smb_fstype)->shareopts; - if (shareopts == NULL) /* on/off */ + if (impl_share->sa_shareopts == NULL) /* on/off */ return (SA_SYSTEM_ERR); - if (strcmp(shareopts, "off") == 0) + if (strcmp(impl_share->sa_shareopts, "off") == 0) return (SA_OK); /* Magic: Enable (i.e., 'create new') share */ @@ -298,20 +286,18 @@ smb_enable_share(sa_share_impl_t impl_share) static int smb_disable_share_one(const char *sharename) { - int rc; - char *argv[7]; - /* CMD: net -S NET_CMD_ARG_HOST usershare delete Test1 */ - argv[0] = NET_CMD_PATH; - argv[1] = (char *)"-S"; - argv[2] = NET_CMD_ARG_HOST; - argv[3] = (char *)"usershare"; - argv[4] = (char *)"delete"; - argv[5] = (char *)sharename; - argv[6] = NULL; + char *argv[] = { + (char *)NET_CMD_PATH, + (char *)"-S", + (char *)NET_CMD_ARG_HOST, + (char *)"usershare", + (char *)"delete", + (char *)sharename, + NULL, + }; - rc = libzfs_run_process(argv[0], argv, 0); - if (rc < 0) + if (libzfs_run_process(argv[0], argv, 0) < 0) return (SA_SYSTEM_ERR); else return (SA_OK); @@ -323,8 +309,6 @@ smb_disable_share_one(const char *sharename) static int smb_disable_share(sa_share_impl_t impl_share) { - smb_share_t *shares = smb_shares; - if (!smb_available()) { /* * The share can't possibly be active, so nothing @@ -333,12 +317,9 @@ smb_disable_share(sa_share_impl_t impl_share) return (SA_OK); } - while (shares != NULL) { - if (strcmp(impl_share->sa_mountpoint, shares->path) == 0) - return (smb_disable_share_one(shares->name)); - - shares = shares->next; - } + for (const smb_share_t *i = smb_shares; i != NULL; i = i->next) + if (strcmp(impl_share->sa_mountpoint, i->path) == 0) + return (smb_disable_share_one(i->name)); return (SA_OK); } @@ -362,40 +343,19 @@ smb_validate_shareopts(const char *shareopts) static boolean_t smb_is_share_active(sa_share_impl_t impl_share) { - smb_share_t *iter = smb_shares; - if (!smb_available()) return (B_FALSE); /* Retrieve the list of (possible) active shares */ smb_retrieve_shares(); - while (iter != NULL) { - if (strcmp(impl_share->sa_mountpoint, iter->path) == 0) + for (const smb_share_t *i = smb_shares; i != NULL; i = i->next) + if (strcmp(impl_share->sa_mountpoint, i->path) == 0) return (B_TRUE); - iter = iter->next; - } - return (B_FALSE); } -/* - * Called to update a share's options. A share's options might be out of - * date if the share was loaded from disk and the "sharesmb" dataset - * property has changed in the meantime. This function also takes care - * of re-enabling the share if necessary. - */ -static int -smb_update_shareopts(sa_share_impl_t impl_share, const char *shareopts) -{ - if (!impl_share) - return (SA_SYSTEM_ERR); - - FSINFO(impl_share, smb_fstype)->shareopts = (char *)shareopts; - return (SA_OK); -} - static int smb_update_shares(void) { @@ -403,24 +363,12 @@ smb_update_shares(void) return (0); } -/* - * Clears a share's SMB options. Used by libshare to - * clean up shares that are about to be free()'d. - */ -static void -smb_clear_shareopts(sa_share_impl_t impl_share) -{ - FSINFO(impl_share, smb_fstype)->shareopts = NULL; -} - -static const sa_share_ops_t smb_shareops = { +const sa_fstype_t libshare_smb_type = { .enable_share = smb_enable_share, .disable_share = smb_disable_share, .is_shared = smb_is_share_active, .validate_shareopts = smb_validate_shareopts, - .update_shareopts = smb_update_shareopts, - .clear_shareopts = smb_clear_shareopts, .commit_shares = smb_update_shares, }; @@ -430,23 +378,18 @@ static const sa_share_ops_t smb_shareops = { static boolean_t smb_available(void) { - struct stat statbuf; + static int avail; - if (lstat(SHARE_DIR, &statbuf) != 0 || - !S_ISDIR(statbuf.st_mode)) - return (B_FALSE); + if (!avail) { + struct stat statbuf; - if (access(NET_CMD_PATH, F_OK) != 0) - return (B_FALSE); + if (access(NET_CMD_PATH, F_OK) != 0 || + lstat(SHARE_DIR, &statbuf) != 0 || + !S_ISDIR(statbuf.st_mode)) + avail = -1; + else + avail = 1; + } - return (B_TRUE); -} - -/* - * Initializes the SMB functionality of libshare. - */ -void -libshare_smb_init(void) -{ - smb_fstype = register_fstype("smb", &smb_shareops); + return (avail == 1); } diff --git a/sys/contrib/openzfs/lib/libshare/smb.h b/sys/contrib/openzfs/lib/libshare/smb.h index 8ea44677f9ae..ca3577751923 100644 --- a/sys/contrib/openzfs/lib/libshare/smb.h +++ b/sys/contrib/openzfs/lib/libshare/smb.h @@ -43,7 +43,3 @@ typedef struct smb_share_s { struct smb_share_s *next; } smb_share_t; - -extern smb_share_t *smb_shares; - -void libshare_smb_init(void); diff --git a/sys/contrib/openzfs/lib/libspl/Makefile.am b/sys/contrib/openzfs/lib/libspl/Makefile.am index 8457df6dcdf4..822bef7e7a8d 100644 --- a/sys/contrib/openzfs/lib/libspl/Makefile.am +++ b/sys/contrib/openzfs/lib/libspl/Makefile.am @@ -1,47 +1,45 @@ -include $(top_srcdir)/config/Rules.am +include $(srcdir)/%D%/include/Makefile.am -SUBDIRS = include +libspl_assert_la_CFLAGS = $(AM_CFLAGS) $(LIBRARY_CFLAGS) +libspl_la_CFLAGS = $(libspl_assert_la_CFLAGS) -noinst_LTLIBRARIES = libspl_assert.la libspl.la +noinst_LTLIBRARIES += libspl_assert.la libspl.la +CPPCHECKTARGETS += libspl_assert.la libspl.la libspl_assert_la_SOURCES = \ - assert.c + %D%/assert.c -USER_C = \ - libspl_impl.h \ - atomic.c \ - getexecname.c \ - list.c \ - mkdirp.c \ - page.c \ - strlcat.c \ - strlcpy.c \ - timestamp.c \ - include/sys/list.h \ - include/sys/list_impl.h +libspl_la_SOURCES = \ + %D%/libspl_impl.h \ + %D%/atomic.c \ + %D%/getexecname.c \ + %D%/list.c \ + %D%/mkdirp.c \ + %D%/page.c \ + %D%/strlcat.c \ + %D%/strlcpy.c \ + %D%/timestamp.c \ + %D%/include/sys/list.h \ + %D%/include/sys/list_impl.h if BUILD_LINUX -USER_C += \ - os/linux/getexecname.c \ - os/linux/gethostid.c \ - os/linux/getmntany.c \ - os/linux/zone.c +libspl_la_SOURCES += \ + %D%/os/linux/getexecname.c \ + %D%/os/linux/gethostid.c \ + %D%/os/linux/getmntany.c \ + %D%/os/linux/zone.c endif if BUILD_FREEBSD -USER_C += \ - os/freebsd/getexecname.c \ - os/freebsd/gethostid.c \ - os/freebsd/getmntany.c \ - os/freebsd/mnttab.c \ - os/freebsd/zone.c +libspl_la_SOURCES += \ + %D%/os/freebsd/getexecname.c \ + %D%/os/freebsd/gethostid.c \ + %D%/os/freebsd/getmntany.c \ + %D%/os/freebsd/mnttab.c \ + %D%/os/freebsd/zone.c endif -libspl_la_SOURCES = $(USER_C) - libspl_la_LIBADD = \ libspl_assert.la libspl_la_LIBADD += $(LIBATOMIC_LIBS) $(LIBCLOCK_GETTIME) - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/lib/libspl/include/Makefile.am b/sys/contrib/openzfs/lib/libspl/include/Makefile.am index 20996366030c..2c0284310723 100644 --- a/sys/contrib/openzfs/lib/libspl/include/Makefile.am +++ b/sys/contrib/openzfs/lib/libspl/include/Makefile.am @@ -1,22 +1,107 @@ -SUBDIRS = rpc sys util os - libspldir = $(includedir)/libspl libspl_HEADERS = \ - assert.h \ - atomic.h \ - libdevinfo.h \ - libgen.h \ - libshare.h \ - limits.h \ - locale.h \ - statcommon.h \ - stdio.h \ - stdlib.h \ - string.h \ - stropts.h \ - thread.h \ - tzfile.h \ - ucred.h \ - umem.h \ - unistd.h \ - zone.h + %D%/assert.h \ + %D%/atomic.h \ + %D%/libdevinfo.h \ + %D%/libgen.h \ + %D%/libshare.h \ + %D%/limits.h \ + %D%/locale.h \ + %D%/statcommon.h \ + %D%/stdlib.h \ + %D%/string.h \ + %D%/stropts.h \ + %D%/thread.h \ + %D%/tzfile.h \ + %D%/ucred.h \ + %D%/umem.h \ + %D%/unistd.h \ + %D%/zone.h + +if BUILD_FREEBSD +libspl_HEADERS += \ + %D%/os/freebsd/fcntl.h +endif + + +libspl_rpcdir = $(libspldir)/rpc +libspl_rpc_HEADERS = \ + %D%/rpc/xdr.h + + +libspl_sysdir = $(libspldir)/sys +libspl_sys_HEADERS = \ + %D%/sys/acl.h \ + %D%/sys/acl_impl.h \ + %D%/sys/callb.h \ + %D%/sys/cmn_err.h \ + %D%/sys/cred.h \ + %D%/sys/debug.h \ + %D%/sys/dkio.h \ + %D%/sys/dklabel.h \ + %D%/sys/feature_tests.h \ + %D%/sys/int_limits.h \ + %D%/sys/int_types.h \ + %D%/sys/inttypes.h \ + %D%/sys/isa_defs.h \ + %D%/sys/kmem.h \ + %D%/sys/kstat.h \ + %D%/sys/list.h \ + %D%/sys/list_impl.h \ + %D%/sys/mhd.h \ + %D%/sys/mkdev.h \ + %D%/sys/policy.h \ + %D%/sys/poll.h \ + %D%/sys/priv.h \ + %D%/sys/processor.h \ + %D%/sys/sha2.h \ + %D%/sys/simd.h \ + %D%/sys/stack.h \ + %D%/sys/stdtypes.h \ + %D%/sys/string.h \ + %D%/sys/stropts.h \ + %D%/sys/sunddi.h \ + %D%/sys/systeminfo.h \ + %D%/sys/time.h \ + %D%/sys/trace_spl.h \ + %D%/sys/trace_zfs.h \ + %D%/sys/types.h \ + %D%/sys/types32.h \ + %D%/sys/tzfile.h \ + %D%/sys/uio.h \ + %D%/sys/va_list.h \ + %D%/sys/varargs.h \ + %D%/sys/vnode.h \ + %D%/sys/wmsum.h \ + %D%/sys/zone.h + +if BUILD_LINUX +libspl_sys_HEADERS += \ + %D%/os/linux/sys/byteorder.h \ + %D%/os/linux/sys/errno.h \ + %D%/os/linux/sys/mnttab.h \ + %D%/os/linux/sys/mount.h \ + %D%/os/linux/sys/param.h \ + %D%/os/linux/sys/stat.h \ + %D%/os/linux/sys/sysmacros.h \ + %D%/os/linux/sys/zfs_context_os.h +endif + +if BUILD_FREEBSD +libspl_sys_HEADERS += \ + %D%/os/freebsd/sys/byteorder.h \ + %D%/os/freebsd/sys/fcntl.h \ + %D%/os/freebsd/sys/file.h \ + %D%/os/freebsd/sys/mnttab.h \ + %D%/os/freebsd/sys/mount.h \ + %D%/os/freebsd/sys/param.h \ + %D%/os/freebsd/sys/stat.h \ + %D%/os/freebsd/sys/sysmacros.h \ + %D%/os/freebsd/sys/vfs.h \ + %D%/os/freebsd/sys/zfs_context_os.h +endif + + +libspl_sys_dktpdir = $(libspl_sysdir)/dktp +libspl_sys_dktp_HEADERS = \ + %D%/sys/dktp/fdisk.h diff --git a/sys/contrib/openzfs/lib/libspl/include/libshare.h b/sys/contrib/openzfs/lib/libspl/include/libshare.h index 5d06b163a3ba..ae0e2c39dc6d 100644 --- a/sys/contrib/openzfs/lib/libspl/include/libshare.h +++ b/sys/contrib/openzfs/lib/libspl/include/libshare.h @@ -27,28 +27,28 @@ #ifndef _LIBSPL_LIBSHARE_H #define _LIBSPL_LIBSHARE_H extern __attribute__((visibility("default"))) -/* API Initialization */ -#define SA_INIT_SHARE_API 0x0001 /* init share specific interface */ -#define SA_INIT_CONTROL_API 0x0002 /* init control specific interface */ +#include /* * defined error values */ - #define SA_OK 0 -#define SA_NO_SUCH_PATH 1 /* provided path doesn't exist */ +#define SA_SYSTEM_ERR 7 /* system error, use errno */ +#define SA_SYNTAX_ERR 8 /* syntax error on command line */ #define SA_NO_MEMORY 2 /* no memory for data structures */ +#define SA_INVALID_PROTOCOL 13 /* specified protocol not valid */ +#define SA_NOT_SUPPORTED 21 /* operation not supported for proto */ + +/* The following errors are never returned by libshare */ +#define SA_NO_SUCH_PATH 1 /* provided path doesn't exist */ #define SA_DUPLICATE_NAME 3 /* object name is already in use */ #define SA_BAD_PATH 4 /* not a full path */ #define SA_NO_SUCH_GROUP 5 /* group is not defined */ #define SA_CONFIG_ERR 6 /* system configuration error */ -#define SA_SYSTEM_ERR 7 /* system error, use errno */ -#define SA_SYNTAX_ERR 8 /* syntax error on command line */ #define SA_NO_PERMISSION 9 /* no permission for operation */ #define SA_BUSY 10 /* resource is busy */ #define SA_NO_SUCH_PROP 11 /* property doesn't exist */ #define SA_INVALID_NAME 12 /* name of object is invalid */ -#define SA_INVALID_PROTOCOL 13 /* specified protocol not valid */ #define SA_NOT_ALLOWED 14 /* operation not allowed */ #define SA_BAD_VALUE 15 /* bad value for property */ #define SA_INVALID_SECURITY 16 /* invalid security type */ @@ -56,7 +56,6 @@ #define SA_VALUE_CONFLICT 18 /* property value conflict */ #define SA_NOT_IMPLEMENTED 19 /* plugin interface not implemented */ #define SA_INVALID_PATH 20 /* path is sub-dir of existing share */ -#define SA_NOT_SUPPORTED 21 /* operation not supported for proto */ #define SA_PROP_SHARE_ONLY 22 /* property valid on share only */ #define SA_NOT_SHARED 23 /* path is not shared */ #define SA_NO_SUCH_RESOURCE 24 /* resource not found */ @@ -71,16 +70,26 @@ #define SA_SHARE_EXISTS 33 /* path or file is already shared */ /* initialization */ -_LIBSPL_LIBSHARE_H char *sa_errorstr(int); +_LIBSPL_LIBSHARE_H const char *sa_errorstr(int); + +/* available protocols */ +enum sa_protocol { + SA_PROTOCOL_NFS, + SA_PROTOCOL_SMB, /* ABI: add before _COUNT */ + SA_PROTOCOL_COUNT, +}; + +/* lower-case */ +_LIBSPL_LIBSHARE_H const char *const sa_protocol_names[SA_PROTOCOL_COUNT]; /* share control */ _LIBSPL_LIBSHARE_H int sa_enable_share(const char *, const char *, const char *, - char *); -_LIBSPL_LIBSHARE_H int sa_disable_share(const char *, char *); -_LIBSPL_LIBSHARE_H boolean_t sa_is_shared(const char *, char *); -_LIBSPL_LIBSHARE_H void sa_commit_shares(const char *); + enum sa_protocol); +_LIBSPL_LIBSHARE_H int sa_disable_share(const char *, enum sa_protocol); +_LIBSPL_LIBSHARE_H boolean_t sa_is_shared(const char *, enum sa_protocol); +_LIBSPL_LIBSHARE_H void sa_commit_shares(enum sa_protocol); /* protocol specific interfaces */ -_LIBSPL_LIBSHARE_H int sa_validate_shareopts(char *, char *); +_LIBSPL_LIBSHARE_H int sa_validate_shareopts(const char *, enum sa_protocol); #endif /* _LIBSPL_LIBSHARE_H */ diff --git a/sys/contrib/openzfs/lib/libspl/include/os/Makefile.am b/sys/contrib/openzfs/lib/libspl/include/os/Makefile.am deleted file mode 100644 index 7b362e02ad59..000000000000 --- a/sys/contrib/openzfs/lib/libspl/include/os/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -if BUILD_FREEBSD -SUBDIRS = freebsd -endif - -if BUILD_LINUX -SUBDIRS = linux -endif diff --git a/sys/contrib/openzfs/lib/libspl/include/os/freebsd/Makefile.am b/sys/contrib/openzfs/lib/libspl/include/os/freebsd/Makefile.am deleted file mode 100644 index f06325ee3e4e..000000000000 --- a/sys/contrib/openzfs/lib/libspl/include/os/freebsd/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -SUBDIRS = sys - -libspldir = $(includedir)/libspl -libspl_HEADERS = \ - fcntl.h diff --git a/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/Makefile.am b/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/Makefile.am deleted file mode 100644 index 7a854608079c..000000000000 --- a/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -libspldir = $(includedir)/libspl/sys -libspl_HEADERS = \ - byteorder.h \ - fcntl.h \ - file.h \ - mnttab.h \ - mount.h \ - param.h \ - stat.h \ - sysmacros.h \ - vfs.h \ - zfs_context_os.h diff --git a/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/file.h b/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/file.h index 27fd2888f326..5a20686dc069 100644 --- a/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/file.h +++ b/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/file.h @@ -29,14 +29,6 @@ #include_next -#define FCREAT O_CREAT -#define FTRUNC O_TRUNC -#define FSYNC O_SYNC -#define FDSYNC O_DSYNC -#define FEXCL O_EXCL - -#define FNODSYNC 0x10000 /* fsync pseudo flag */ -#define FNOFOLLOW 0x20000 /* don't follow symlinks */ #define FIGNORECASE 0x80000 /* request case-insensitive lookups */ #endif diff --git a/sys/contrib/openzfs/lib/libspl/include/os/linux/Makefile.am b/sys/contrib/openzfs/lib/libspl/include/os/linux/Makefile.am deleted file mode 100644 index 081839c48c8f..000000000000 --- a/sys/contrib/openzfs/lib/libspl/include/os/linux/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = sys diff --git a/sys/contrib/openzfs/lib/libspl/include/os/linux/sys/Makefile.am b/sys/contrib/openzfs/lib/libspl/include/os/linux/sys/Makefile.am deleted file mode 100644 index 1ec07a76d354..000000000000 --- a/sys/contrib/openzfs/lib/libspl/include/os/linux/sys/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -libspldir = $(includedir)/libspl/sys -libspl_HEADERS = \ - byteorder.h \ - errno.h \ - mnttab.h \ - mount.h \ - param.h \ - stat.h \ - sysmacros.h \ - zfs_context_os.h diff --git a/sys/contrib/openzfs/lib/libspl/include/rpc/Makefile.am b/sys/contrib/openzfs/lib/libspl/include/rpc/Makefile.am deleted file mode 100644 index 7fe1d7fea4d7..000000000000 --- a/sys/contrib/openzfs/lib/libspl/include/rpc/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -libspldir = $(includedir)/libspl/rpc -libspl_HEADERS = \ - xdr.h diff --git a/sys/contrib/openzfs/lib/libspl/include/stdio.h b/sys/contrib/openzfs/lib/libspl/include/stdio.h deleted file mode 100644 index 6152b09f1a97..000000000000 --- a/sys/contrib/openzfs/lib/libspl/include/stdio.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include_next - -#ifndef _LIBSPL_STDIO_H -#define _LIBSPL_STDIO_H - -#define enable_extended_FILE_stdio(fd, sig) ((void) 0) - -#endif diff --git a/sys/contrib/openzfs/lib/libspl/include/sys/Makefile.am b/sys/contrib/openzfs/lib/libspl/include/sys/Makefile.am deleted file mode 100644 index 4315470b59b2..000000000000 --- a/sys/contrib/openzfs/lib/libspl/include/sys/Makefile.am +++ /dev/null @@ -1,47 +0,0 @@ -SUBDIRS = dktp - -libspldir = $(includedir)/libspl/sys -libspl_HEADERS = \ - acl.h \ - acl_impl.h \ - callb.h \ - cmn_err.h \ - cred.h \ - debug.h \ - dkio.h \ - dklabel.h \ - feature_tests.h \ - int_limits.h \ - int_types.h \ - inttypes.h \ - isa_defs.h \ - kmem.h \ - kstat.h \ - list.h \ - list_impl.h \ - mhd.h \ - mkdev.h \ - policy.h \ - poll.h \ - priv.h \ - processor.h \ - sha2.h \ - simd.h \ - stack.h \ - stdtypes.h \ - string.h \ - stropts.h \ - sunddi.h \ - systeminfo.h \ - time.h \ - trace_spl.h \ - trace_zfs.h \ - types32.h \ - types.h \ - tzfile.h \ - uio.h \ - va_list.h \ - varargs.h \ - vnode.h \ - wmsum.h \ - zone.h diff --git a/sys/contrib/openzfs/lib/libspl/include/sys/dktp/Makefile.am b/sys/contrib/openzfs/lib/libspl/include/sys/dktp/Makefile.am deleted file mode 100644 index 4ad3695d8abc..000000000000 --- a/sys/contrib/openzfs/lib/libspl/include/sys/dktp/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -libspldir = $(includedir)/libspl/sys/dktp -libspl_HEADERS = \ - fdisk.h - diff --git a/sys/contrib/openzfs/lib/libspl/include/util/Makefile.am b/sys/contrib/openzfs/lib/libspl/include/util/Makefile.am deleted file mode 100644 index ab553bc80313..000000000000 --- a/sys/contrib/openzfs/lib/libspl/include/util/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -libspldir = $(includedir)/libspl -libspl_HEADERS = \ - sscanf.h diff --git a/sys/contrib/openzfs/lib/libspl/include/util/sscanf.h b/sys/contrib/openzfs/lib/libspl/include/util/sscanf.h deleted file mode 100644 index ead36acaba3e..000000000000 --- a/sys/contrib/openzfs/lib/libspl/include/util/sscanf.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _LIBSPL_UTIL_SSCANF_H -#define _LIBSPL_UTIL_SSCANF_H - -#endif diff --git a/sys/contrib/openzfs/lib/libspl/timestamp.c b/sys/contrib/openzfs/lib/libspl/timestamp.c index 22ecb3940739..8d14ae645734 100644 --- a/sys/contrib/openzfs/lib/libspl/timestamp.c +++ b/sys/contrib/openzfs/lib/libspl/timestamp.c @@ -44,7 +44,7 @@ void print_timestamp(uint_t timestamp_fmt) { time_t t = time(NULL); - static char *fmt = NULL; + static const char *fmt = NULL; /* We only need to retrieve this once per invocation */ if (fmt == NULL) @@ -54,9 +54,10 @@ print_timestamp(uint_t timestamp_fmt) (void) printf("%lld\n", (longlong_t)t); } else if (timestamp_fmt == DDATE) { char dstr[64]; + struct tm tm; int len; - len = strftime(dstr, sizeof (dstr), fmt, localtime(&t)); + len = strftime(dstr, sizeof (dstr), fmt, localtime_r(&t, &tm)); if (len > 0) (void) printf("%s\n", dstr); } diff --git a/sys/contrib/openzfs/lib/libtpool/Makefile.am b/sys/contrib/openzfs/lib/libtpool/Makefile.am index 638d427bdf1c..5a2b8a5701da 100644 --- a/sys/contrib/openzfs/lib/libtpool/Makefile.am +++ b/sys/contrib/openzfs/lib/libtpool/Makefile.am @@ -1,15 +1,11 @@ -include $(top_srcdir)/config/Rules.am - -AM_CFLAGS += -fvisibility=hidden +libtpool_la_CFLAGS = $(AM_CFLAGS) $(LIBRARY_CFLAGS) +libtpool_la_CFLAGS += -fvisibility=hidden # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61118 -AM_CFLAGS += $(NO_CLOBBERED) +libtpool_la_CFLAGS += $(NO_CLOBBERED) -noinst_LTLIBRARIES = libtpool.la +noinst_LTLIBRARIES += libtpool.la +CPPCHECKTARGETS += libtpool.la -USER_C = \ - thread_pool.c \ - thread_pool_impl.h - -libtpool_la_SOURCES = $(USER_C) - -include $(top_srcdir)/config/CppCheck.am +libtpool_la_SOURCES = \ + %D%/thread_pool.c \ + %D%/thread_pool_impl.h diff --git a/sys/contrib/openzfs/lib/libunicode/Makefile.am b/sys/contrib/openzfs/lib/libunicode/Makefile.am index b82975f68efd..906759471163 100644 --- a/sys/contrib/openzfs/lib/libunicode/Makefile.am +++ b/sys/contrib/openzfs/lib/libunicode/Makefile.am @@ -1,17 +1,7 @@ -include $(top_srcdir)/config/Rules.am +libunicode_la_CFLAGS = $(AM_CFLAGS) $(KERNEL_CFLAGS) $(LIBRARY_CFLAGS) -VPATH = $(top_srcdir)/module/unicode - -# Includes kernel code, generate warnings for large stack frames -AM_CFLAGS += $(FRAME_LARGER_THAN) - -noinst_LTLIBRARIES = libunicode.la - -KERNEL_C = \ - u8_textprep.c \ - uconv.c +noinst_LTLIBRARIES += libunicode.la nodist_libunicode_la_SOURCES = \ - $(KERNEL_C) - -include $(top_srcdir)/config/CppCheck.am + module/unicode/u8_textprep.c \ + module/unicode/uconv.c diff --git a/sys/contrib/openzfs/lib/libuutil/Makefile.am b/sys/contrib/openzfs/lib/libuutil/Makefile.am index 5a911f85f7de..cb89d423dc48 100644 --- a/sys/contrib/openzfs/lib/libuutil/Makefile.am +++ b/sys/contrib/openzfs/lib/libuutil/Makefile.am @@ -1,23 +1,20 @@ -include $(top_srcdir)/config/Rules.am +libuutil_la_CFLAGS = $(AM_CFLAGS) $(LIBRARY_CFLAGS) $(LIBRARY_CFLAGS) -lib_LTLIBRARIES = libuutil.la +lib_LTLIBRARIES += libuutil.la +CPPCHECKTARGETS += libuutil.la -include $(top_srcdir)/config/Abigail.am - -USER_C = \ - uu_alloc.c \ - uu_avl.c \ - uu_ident.c \ - uu_list.c \ - uu_misc.c \ - uu_pname.c \ - uu_string.c - -libuutil_la_SOURCES = $(USER_C) +libuutil_la_SOURCES = \ + %D%/uu_alloc.c \ + %D%/uu_avl.c \ + %D%/uu_ident.c \ + %D%/uu_list.c \ + %D%/uu_misc.c \ + %D%/uu_pname.c \ + %D%/uu_string.c libuutil_la_LIBADD = \ - $(abs_top_builddir)/lib/libavl/libavl.la \ - $(abs_top_builddir)/lib/libspl/libspl.la + libavl.la \ + libspl.la libuutil_la_LIBADD += $(LTLIBINTL) @@ -29,7 +26,4 @@ endif libuutil_la_LDFLAGS += -version-info 3:0:0 -include $(top_srcdir)/config/CppCheck.am - -# Library ABI -EXTRA_DIST = libuutil.abi libuutil.suppr +EXTRA_DIST += $(addprefix %D%/,libuutil.abi libuutil.suppr) diff --git a/sys/contrib/openzfs/lib/libuutil/libuutil.abi b/sys/contrib/openzfs/lib/libuutil/libuutil.abi index bf13d62e2f04..86220b44b229 100644 --- a/sys/contrib/openzfs/lib/libuutil/libuutil.abi +++ b/sys/contrib/openzfs/lib/libuutil/libuutil.abi @@ -5,8 +5,6 @@ - - @@ -366,7 +364,7 @@ - + @@ -430,6 +428,11 @@ + + + + + @@ -450,7 +453,7 @@ - + @@ -475,11 +478,6 @@ - - - - - @@ -552,6 +550,11 @@ + + + + + @@ -572,7 +575,7 @@ - + @@ -597,11 +600,6 @@ - - - - - @@ -642,6 +640,12 @@ + + + + + + @@ -666,12 +670,6 @@ - - - - - - @@ -858,6 +856,9 @@ + + + @@ -892,18 +893,66 @@ - - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -972,16 +1021,16 @@ - + - + - + - + @@ -993,65 +1042,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1062,11 +1052,16 @@ + + + + + @@ -1122,6 +1117,7 @@ + @@ -1154,7 +1150,6 @@ - @@ -1307,15 +1302,6 @@ - - - - - - - - - @@ -1342,6 +1328,15 @@ + + + + + + + + + diff --git a/sys/contrib/openzfs/lib/libzfs/Makefile.am b/sys/contrib/openzfs/lib/libzfs/Makefile.am index 332094469ccf..07414c4a308b 100644 --- a/sys/contrib/openzfs/lib/libzfs/Makefile.am +++ b/sys/contrib/openzfs/lib/libzfs/Makefile.am @@ -1,79 +1,64 @@ -include $(top_srcdir)/config/Rules.am +libzfs_la_CFLAGS = $(AM_CFLAGS) $(LIBRARY_CFLAGS) +libzfs_la_CFLAGS += $(LIBCRYPTO_CFLAGS) $(ZLIB_CFLAGS) +libzfs_la_CFLAGS += -fvisibility=hidden -VPATH = \ - $(top_srcdir)/module/icp \ - $(top_srcdir)/module/zcommon \ - $(top_srcdir)/lib/libzfs - -# Suppress unused but set variable warnings often due to ASSERTs -AM_CFLAGS += $(LIBCRYPTO_CFLAGS) $(ZLIB_CFLAGS) -AM_CFLAGS += -fvisibility=hidden - -pkgconfig_DATA = libzfs.pc - -lib_LTLIBRARIES = libzfs.la - -include $(top_srcdir)/config/Abigail.am - -USER_C = \ - libzfs_impl.h \ - libzfs_changelist.c \ - libzfs_config.c \ - libzfs_crypto.c \ - libzfs_dataset.c \ - libzfs_diff.c \ - libzfs_import.c \ - libzfs_iter.c \ - libzfs_mount.c \ - libzfs_pool.c \ - libzfs_sendrecv.c \ - libzfs_status.c \ - libzfs_util.c +lib_LTLIBRARIES += libzfs.la +CPPCHECKTARGETS += libzfs.la +dist_libzfs_la_SOURCES = \ + %D%/libzfs_impl.h \ + %D%/libzfs_changelist.c \ + %D%/libzfs_config.c \ + %D%/libzfs_crypto.c \ + %D%/libzfs_dataset.c \ + %D%/libzfs_diff.c \ + %D%/libzfs_import.c \ + %D%/libzfs_iter.c \ + %D%/libzfs_mount.c \ + %D%/libzfs_pool.c \ + %D%/libzfs_sendrecv.c \ + %D%/libzfs_status.c \ + %D%/libzfs_util.c if BUILD_FREEBSD -USER_C += \ - os/freebsd/libzfs_compat.c \ - os/freebsd/libzfs_zmount.c +dist_libzfs_la_SOURCES += \ + %D%/os/freebsd/libzfs_compat.c \ + %D%/os/freebsd/libzfs_zmount.c endif if BUILD_LINUX -USER_C += \ - os/linux/libzfs_mount_os.c \ - os/linux/libzfs_pool_os.c \ - os/linux/libzfs_util_os.c +dist_libzfs_la_SOURCES += \ + %D%/os/linux/libzfs_mount_os.c \ + %D%/os/linux/libzfs_pool_os.c \ + %D%/os/linux/libzfs_util_os.c endif -KERNEL_C = \ - algs/sha2/sha2.c \ - cityhash.c \ - zfeature_common.c \ - zfs_comutil.c \ - zfs_deleg.c \ - zfs_fletcher.c \ - zfs_fletcher_aarch64_neon.c \ - zfs_fletcher_avx512.c \ - zfs_fletcher_intel.c \ - zfs_fletcher_sse.c \ - zfs_fletcher_superscalar.c \ - zfs_fletcher_superscalar4.c \ - zfs_namecheck.c \ - zfs_prop.c \ - zpool_prop.c \ - zprop_common.c - -dist_libzfs_la_SOURCES = \ - $(USER_C) - nodist_libzfs_la_SOURCES = \ - $(KERNEL_C) + module/icp/algs/sha2/sha2.c \ + \ + module/zcommon/cityhash.c \ + module/zcommon/zfeature_common.c \ + module/zcommon/zfs_comutil.c \ + module/zcommon/zfs_deleg.c \ + module/zcommon/zfs_fletcher.c \ + module/zcommon/zfs_fletcher_aarch64_neon.c \ + module/zcommon/zfs_fletcher_avx512.c \ + module/zcommon/zfs_fletcher_intel.c \ + module/zcommon/zfs_fletcher_sse.c \ + module/zcommon/zfs_fletcher_superscalar.c \ + module/zcommon/zfs_fletcher_superscalar4.c \ + module/zcommon/zfs_namecheck.c \ + module/zcommon/zfs_prop.c \ + module/zcommon/zpool_prop.c \ + module/zcommon/zprop_common.c + libzfs_la_LIBADD = \ - $(abs_top_builddir)/lib/libshare/libshare.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la \ - $(abs_top_builddir)/lib/libzutil/libzutil.la \ - $(abs_top_builddir)/lib/libuutil/libuutil.la + libshare.la \ + libzfs_core.la \ + libnvpair.la \ + libzutil.la \ + libuutil.la libzfs_la_LIBADD += -lm $(LIBCRYPTO_LIBS) $(ZLIB_LIBS) $(LIBFETCH_LIBS) $(LTLIBINTL) @@ -89,10 +74,7 @@ endif libzfs_la_LDFLAGS += -version-info 5:0:1 -include $(top_srcdir)/config/CppCheck.am +pkgconfig_DATA += %D%/libzfs.pc -# Library ABI -EXTRA_DIST = libzfs.abi libzfs.suppr - -# Licensing data -EXTRA_DIST += THIRDPARTYLICENSE.openssl THIRDPARTYLICENSE.openssl.descrip +EXTRA_DIST += $(addprefix %D%/,libzfs.abi libzfs.suppr) +EXTRA_DIST += $(addprefix %D%/,THIRDPARTYLICENSE.openssl THIRDPARTYLICENSE.openssl.descrip) diff --git a/sys/contrib/openzfs/lib/libzfs/libzfs.abi b/sys/contrib/openzfs/lib/libzfs/libzfs.abi index 69931fda9770..1c7695275f56 100644 --- a/sys/contrib/openzfs/lib/libzfs/libzfs.abi +++ b/sys/contrib/openzfs/lib/libzfs/libzfs.abi @@ -288,10 +288,7 @@ - - - @@ -339,8 +336,6 @@ - - @@ -419,9 +414,6 @@ - - - @@ -440,13 +432,7 @@ - - - - - - @@ -596,7 +582,8 @@ - + + @@ -849,62 +836,108 @@ + + + + - + - + - + - + + + + + + - - - - - - + + + + + + + - - - - - + + - + - - + + - - - - - - - - + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1855,8 +1888,8 @@ - - + + @@ -1896,7 +1929,8 @@ - + + @@ -1954,7 +1988,7 @@ - + @@ -4101,6 +4135,14 @@ + + + + + + + + @@ -4138,80 +4180,30 @@ - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - + @@ -5596,12 +5588,12 @@ - + - - + + diff --git a/sys/contrib/openzfs/lib/libzfs/libzfs_changelist.c b/sys/contrib/openzfs/lib/libzfs/libzfs_changelist.c index f2282ee01177..d31bbc4a3b42 100644 --- a/sys/contrib/openzfs/lib/libzfs/libzfs_changelist.c +++ b/sys/contrib/openzfs/lib/libzfs/libzfs_changelist.c @@ -98,6 +98,7 @@ changelist_prefix(prop_changelist_t *clp) prop_changenode_t *cn; uu_avl_walk_t *walk; int ret = 0; + const enum sa_protocol smb[] = {SA_PROTOCOL_SMB, SA_NO_PROTOCOL}; boolean_t commit_smb_shares = B_FALSE; if (clp->cl_prop != ZFS_PROP_MOUNTPOINT && @@ -137,7 +138,8 @@ changelist_prefix(prop_changelist_t *clp) } break; case ZFS_PROP_SHARESMB: - (void) zfs_unshare_smb(cn->cn_handle, NULL); + (void) zfs_unshare(cn->cn_handle, NULL, + smb); commit_smb_shares = B_TRUE; break; @@ -148,7 +150,7 @@ changelist_prefix(prop_changelist_t *clp) } if (commit_smb_shares) - zfs_commit_smb_shares(); + zfs_commit_shares(smb); uu_avl_walk_end(walk); if (ret == -1) @@ -257,25 +259,33 @@ changelist_postfix(prop_changelist_t *clp) * if the filesystem is currently shared, so that we can * adopt any new options. */ + const enum sa_protocol nfs[] = + {SA_PROTOCOL_NFS, SA_NO_PROTOCOL}; if (sharenfs && mounted) { - errors += zfs_share_nfs(cn->cn_handle); + errors += zfs_share(cn->cn_handle, nfs); commit_nfs_shares = B_TRUE; } else if (cn->cn_shared || clp->cl_waslegacy) { - errors += zfs_unshare_nfs(cn->cn_handle, NULL); + errors += zfs_unshare(cn->cn_handle, NULL, nfs); commit_nfs_shares = B_TRUE; } + const enum sa_protocol smb[] = + {SA_PROTOCOL_SMB, SA_NO_PROTOCOL}; if (sharesmb && mounted) { - errors += zfs_share_smb(cn->cn_handle); + errors += zfs_share(cn->cn_handle, smb); commit_smb_shares = B_TRUE; } else if (cn->cn_shared || clp->cl_waslegacy) { - errors += zfs_unshare_smb(cn->cn_handle, NULL); + errors += zfs_unshare(cn->cn_handle, NULL, smb); commit_smb_shares = B_TRUE; } } + + enum sa_protocol proto[SA_PROTOCOL_COUNT + 1], *p = proto; if (commit_nfs_shares) - zfs_commit_nfs_shares(); + *p++ = SA_PROTOCOL_NFS; if (commit_smb_shares) - zfs_commit_smb_shares(); + *p++ = SA_PROTOCOL_SMB; + *p++ = SA_NO_PROTOCOL; + zfs_commit_shares(proto); uu_avl_walk_end(walk); return (errors ? -1 : 0); @@ -345,7 +355,7 @@ changelist_rename(prop_changelist_t *clp, const char *src, const char *dst) * unshare all the datasets in the list. */ int -changelist_unshare(prop_changelist_t *clp, const zfs_share_proto_t *proto) +changelist_unshare(prop_changelist_t *clp, const enum sa_protocol *proto) { prop_changenode_t *cn; uu_avl_walk_t *walk; @@ -359,11 +369,12 @@ changelist_unshare(prop_changelist_t *clp, const zfs_share_proto_t *proto) return (-1); while ((cn = uu_avl_walk_next(walk)) != NULL) { - if (zfs_unshare_proto(cn->cn_handle, NULL, proto) != 0) + if (zfs_unshare(cn->cn_handle, NULL, proto) != 0) ret = -1; } - zfs_commit_proto(proto); + for (const enum sa_protocol *p = proto; *p != SA_NO_PROTOCOL; ++p) + sa_commit_shares(*p); uu_avl_walk_end(walk); return (ret); @@ -447,16 +458,11 @@ changelist_add_mounted(zfs_handle_t *zhp, void *data) ASSERT3U(clp->cl_prop, ==, ZFS_PROP_MOUNTPOINT); - if ((cn = zfs_alloc(zfs_get_handle(zhp), - sizeof (prop_changenode_t))) == NULL) { - zfs_close(zhp); - return (ENOMEM); - } - + cn = zfs_alloc(zfs_get_handle(zhp), sizeof (prop_changenode_t)); cn->cn_handle = zhp; cn->cn_mounted = zfs_is_mounted(zhp, NULL); ASSERT3U(cn->cn_mounted, ==, B_TRUE); - cn->cn_shared = zfs_is_shared(zhp); + cn->cn_shared = zfs_is_shared(zhp, NULL, NULL); cn->cn_zoned = zfs_prop_get_int(zhp, ZFS_PROP_ZONED); cn->cn_needpost = B_TRUE; @@ -522,16 +528,11 @@ change_one(zfs_handle_t *zhp, void *data) (clp->cl_shareprop != ZPROP_INVAL && (share_sourcetype == ZPROP_SRC_DEFAULT || share_sourcetype == ZPROP_SRC_INHERITED))) { - if ((cn = zfs_alloc(zfs_get_handle(zhp), - sizeof (prop_changenode_t))) == NULL) { - ret = -1; - goto out; - } - + cn = zfs_alloc(zfs_get_handle(zhp), sizeof (prop_changenode_t)); cn->cn_handle = zhp; cn->cn_mounted = (clp->cl_gflags & CL_GATHER_MOUNT_ALWAYS) || zfs_is_mounted(zhp, NULL); - cn->cn_shared = zfs_is_shared(zhp); + cn->cn_shared = zfs_is_shared(zhp, NULL, NULL); cn->cn_zoned = zfs_prop_get_int(zhp, ZFS_PROP_ZONED); cn->cn_needpost = B_TRUE; @@ -630,8 +631,7 @@ changelist_gather(zfs_handle_t *zhp, zfs_prop_t prop, int gather_flags, char property[ZFS_MAXPROPLEN]; boolean_t legacy = B_FALSE; - if ((clp = zfs_alloc(zhp->zfs_hdl, sizeof (prop_changelist_t))) == NULL) - return (NULL); + clp = zfs_alloc(zhp->zfs_hdl, sizeof (prop_changelist_t)); /* * For mountpoint-related tasks, we want to sort everything by @@ -744,17 +744,11 @@ changelist_gather(zfs_handle_t *zhp, zfs_prop_t prop, int gather_flags, * Always add ourself to the list. We add ourselves to the end so that * we're the last to be unmounted. */ - if ((cn = zfs_alloc(zhp->zfs_hdl, - sizeof (prop_changenode_t))) == NULL) { - zfs_close(temp); - changelist_free(clp); - return (NULL); - } - + cn = zfs_alloc(zhp->zfs_hdl, sizeof (prop_changenode_t)); cn->cn_handle = temp; cn->cn_mounted = (clp->cl_gflags & CL_GATHER_MOUNT_ALWAYS) || zfs_is_mounted(temp, NULL); - cn->cn_shared = zfs_is_shared(temp); + cn->cn_shared = zfs_is_shared(temp, NULL, NULL); cn->cn_zoned = zfs_prop_get_int(zhp, ZFS_PROP_ZONED); cn->cn_needpost = B_TRUE; diff --git a/sys/contrib/openzfs/lib/libzfs/libzfs_config.c b/sys/contrib/openzfs/lib/libzfs/libzfs_config.c index 97b10bb761b5..e3c815cf58b2 100644 --- a/sys/contrib/openzfs/lib/libzfs/libzfs_config.c +++ b/sys/contrib/openzfs/lib/libzfs/libzfs_config.c @@ -126,8 +126,7 @@ namespace_reload(libzfs_handle_t *hdl) return (no_memory(hdl)); } - if (zcmd_alloc_dst_nvlist(hdl, &zc, 0) != 0) - return (-1); + zcmd_alloc_dst_nvlist(hdl, &zc, 0); for (;;) { zc.zc_cookie = hdl->libzfs_ns_gen; @@ -141,10 +140,7 @@ namespace_reload(libzfs_handle_t *hdl) return (0); case ENOMEM: - if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) { - zcmd_free_nvlists(&zc); - return (-1); - } + zcmd_expand_dst_nvlist(hdl, &zc); break; default: @@ -181,18 +177,8 @@ namespace_reload(libzfs_handle_t *hdl) nvlist_t *child; uu_avl_index_t where; - if ((cn = zfs_alloc(hdl, sizeof (config_node_t))) == NULL) { - nvlist_free(config); - return (-1); - } - - if ((cn->cn_name = zfs_strdup(hdl, - nvpair_name(elem))) == NULL) { - free(cn); - nvlist_free(config); - return (-1); - } - + cn = zfs_alloc(hdl, sizeof (config_node_t)); + cn->cn_name = zfs_strdup(hdl, nvpair_name(elem)); child = fnvpair_value_nvlist(elem); if (nvlist_dup(child, &cn->cn_config, 0) != 0) { free(cn->cn_name); @@ -273,8 +259,7 @@ zpool_refresh_stats(zpool_handle_t *zhp, boolean_t *missing) if (zhp->zpool_config_size == 0) zhp->zpool_config_size = 1 << 16; - if (zcmd_alloc_dst_nvlist(hdl, &zc, zhp->zpool_config_size) != 0) - return (-1); + zcmd_alloc_dst_nvlist(hdl, &zc, zhp->zpool_config_size); for (;;) { if (zfs_ioctl(zhp->zpool_hdl, ZFS_IOC_POOL_STATS, @@ -286,12 +271,9 @@ zpool_refresh_stats(zpool_handle_t *zhp, boolean_t *missing) break; } - if (errno == ENOMEM) { - if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) { - zcmd_free_nvlists(&zc); - return (-1); - } - } else { + if (errno == ENOMEM) + zcmd_expand_dst_nvlist(hdl, &zc); + else { zcmd_free_nvlists(&zc); if (errno == ENOENT || errno == EINVAL) *missing = B_TRUE; diff --git a/sys/contrib/openzfs/lib/libzfs/libzfs_crypto.c b/sys/contrib/openzfs/lib/libzfs/libzfs_crypto.c index 1428029a9d35..1effe74f33d6 100644 --- a/sys/contrib/openzfs/lib/libzfs/libzfs_crypto.c +++ b/sys/contrib/openzfs/lib/libzfs/libzfs_crypto.c @@ -783,8 +783,6 @@ derive_key(libzfs_handle_t *hdl, zfs_keyformat_t format, uint64_t iters, *key_out = NULL; key = zfs_alloc(hdl, WRAPPING_KEY_LEN); - if (!key) - return (ENOMEM); switch (format) { case ZFS_KEYFORMAT_RAW: diff --git a/sys/contrib/openzfs/lib/libzfs/libzfs_dataset.c b/sys/contrib/openzfs/lib/libzfs/libzfs_dataset.c index b973e09508f2..50053e35f0d5 100644 --- a/sys/contrib/openzfs/lib/libzfs/libzfs_dataset.c +++ b/sys/contrib/openzfs/lib/libzfs/libzfs_dataset.c @@ -331,13 +331,10 @@ get_stats_ioctl(zfs_handle_t *zhp, zfs_cmd_t *zc) (void) strlcpy(zc->zc_name, zhp->zfs_name, sizeof (zc->zc_name)); while (zfs_ioctl(hdl, ZFS_IOC_OBJSET_STATS, zc) != 0) { - if (errno == ENOMEM) { - if (zcmd_expand_dst_nvlist(hdl, zc) != 0) { - return (-1); - } - } else { + if (errno == ENOMEM) + zcmd_expand_dst_nvlist(hdl, zc); + else return (-1); - } } return (0); } @@ -353,17 +350,14 @@ get_recvd_props_ioctl(zfs_handle_t *zhp) zfs_cmd_t zc = {"\0"}; int err; - if (zcmd_alloc_dst_nvlist(hdl, &zc, 0) != 0) - return (-1); + zcmd_alloc_dst_nvlist(hdl, &zc, 0); (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name)); while (zfs_ioctl(hdl, ZFS_IOC_OBJSET_RECVD_PROPS, &zc) != 0) { - if (errno == ENOMEM) { - if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) { - return (-1); - } - } else { + if (errno == ENOMEM) + zcmd_expand_dst_nvlist(hdl, &zc); + else { zcmd_free_nvlists(&zc); return (-1); } @@ -415,8 +409,8 @@ get_stats(zfs_handle_t *zhp) int rc = 0; zfs_cmd_t zc = {"\0"}; - if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0) - return (-1); + zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0); + if (get_stats_ioctl(zhp, &zc) != 0) rc = -1; else if (put_stats_zhdl(zhp, &zc) != 0) @@ -489,10 +483,8 @@ make_dataset_handle(libzfs_handle_t *hdl, const char *path) zhp->zfs_hdl = hdl; (void) strlcpy(zhp->zfs_name, path, sizeof (zhp->zfs_name)); - if (zcmd_alloc_dst_nvlist(hdl, &zc, 0) != 0) { - free(zhp); - return (NULL); - } + zcmd_alloc_dst_nvlist(hdl, &zc, 0); + if (get_stats_ioctl(zhp, &zc) == -1) { zcmd_free_nvlists(&zc); free(zhp); @@ -1426,14 +1418,15 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl, prop == ZFS_PROP_SHARESMB) && strcmp(strval, "on") != 0 && strcmp(strval, "off") != 0) { - zfs_share_proto_t proto; + enum sa_protocol proto; if (prop == ZFS_PROP_SHARESMB) - proto = PROTO_SMB; + proto = SA_PROTOCOL_SMB; else - proto = PROTO_NFS; + proto = SA_PROTOCOL_NFS; - if (zfs_parse_options(strval, proto) != SA_OK) { + if (sa_validate_shareopts(strval, proto) != + SA_OK) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "'%s' cannot be set to invalid " "options"), propname); @@ -1847,9 +1840,8 @@ zfs_prop_set_list(zfs_handle_t *zhp, nvlist_t *props) */ (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name)); - if ((ret = zcmd_write_src_nvlist(hdl, &zc, nvl)) != 0 || - (ret = zcmd_alloc_dst_nvlist(hdl, &zc, 0)) != 0) - goto error; + zcmd_write_src_nvlist(hdl, &zc, nvl); + zcmd_alloc_dst_nvlist(hdl, &zc, 0); ret = zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc); @@ -1885,8 +1877,7 @@ zfs_prop_set_list(zfs_handle_t *zhp, nvlist_t *props) zfs_prop_to_name(ZFS_PROP_VOLSIZE), old_volsize) != 0) goto error; - if (zcmd_write_src_nvlist(hdl, &zc, nvl) != 0) - goto error; + zcmd_write_src_nvlist(hdl, &zc, nvl); (void) zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc); } } else { @@ -2195,12 +2186,9 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src, libzfs_handle_t *hdl = zhp->zfs_hdl; struct mnttab entry; - if (libzfs_mnttab_find(hdl, zhp->zfs_name, &entry) == 0) { + if (libzfs_mnttab_find(hdl, zhp->zfs_name, &entry) == 0) zhp->zfs_mntopts = zfs_strdup(hdl, entry.mnt_mntopts); - if (zhp->zfs_mntopts == NULL) - return (-1); - } zhp->zfs_mntcheck = B_TRUE; } @@ -2267,8 +2255,8 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src, case ZFS_PROP_NORMALIZE: case ZFS_PROP_UTF8ONLY: case ZFS_PROP_CASE: - if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0) - return (-1); + zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0); + (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name)); if (zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_OBJSET_ZPLPROPS, &zc)) { zcmd_free_nvlists(&zc); @@ -3568,14 +3556,14 @@ create_parents(libzfs_handle_t *hdl, char *target, int prefixlen) goto ancestorerr; } - if (zfs_share(h) != 0) { + if (zfs_share(h, NULL) != 0) { opname = dgettext(TEXT_DOMAIN, "share"); goto ancestorerr; } zfs_close(h); } - zfs_commit_all_shares(); + zfs_commit_shares(NULL); return (0); @@ -4505,10 +4493,6 @@ zfs_rename(zfs_handle_t *zhp, const char *target, renameflags_t flags) } if (flags.recursive) { char *parentname = zfs_strdup(zhp->zfs_hdl, zhp->zfs_name); - if (parentname == NULL) { - ret = -1; - goto error; - } delim = strchr(parentname, '@'); *delim = '\0'; zfs_handle_t *zhrp = zfs_open(zhp->zfs_hdl, parentname, @@ -4670,14 +4654,9 @@ zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp, boolean_t received, } if (*last == NULL) { - if ((entry = zfs_alloc(hdl, - sizeof (zprop_list_t))) == NULL || - ((entry->pl_user_prop = zfs_strdup(hdl, - nvpair_name(elem)))) == NULL) { - free(entry); - return (-1); - } - + entry = zfs_alloc(hdl, sizeof (zprop_list_t)); + entry->pl_user_prop = + zfs_strdup(hdl, nvpair_name(elem)); entry->pl_prop = ZPROP_INVAL; entry->pl_width = strlen(nvpair_name(elem)); entry->pl_all = B_TRUE; @@ -4790,10 +4769,7 @@ zfs_smb_acl_mgmt(libzfs_handle_t *hdl, char *dataset, char *path, (void) no_memory(hdl); return (-1); } - if (zcmd_write_src_nvlist(hdl, &zc, nvlist) != 0) { - nvlist_free(nvlist); - return (-1); - } + zcmd_write_src_nvlist(hdl, &zc, nvlist); break; case ZFS_SMB_ACL_PURGE: break; diff --git a/sys/contrib/openzfs/lib/libzfs/libzfs_diff.c b/sys/contrib/openzfs/lib/libzfs/libzfs_diff.c index 8884ac536a03..e8b8a1dfc398 100644 --- a/sys/contrib/openzfs/lib/libzfs/libzfs_diff.c +++ b/sys/contrib/openzfs/lib/libzfs/libzfs_diff.c @@ -602,11 +602,10 @@ get_snapshot_names(differ_info_t *di, const char *fromsnap, di->isclone = B_TRUE; di->fromsnap = zfs_strdup(hdl, fromsnap); - if (tsnlen) { + if (tsnlen) di->tosnap = zfs_strdup(hdl, tosnap); - } else { + else return (make_temp_snapshot(di)); - } } else { int dslen = fdslen ? fdslen : tdslen; diff --git a/sys/contrib/openzfs/lib/libzfs/libzfs_impl.h b/sys/contrib/openzfs/lib/libzfs/libzfs_impl.h index 6a18f6c328f4..926e14a3716c 100644 --- a/sys/contrib/openzfs/lib/libzfs/libzfs_impl.h +++ b/sys/contrib/openzfs/lib/libzfs/libzfs_impl.h @@ -105,22 +105,6 @@ struct zpool_handle { diskaddr_t zpool_start_block; }; -typedef enum { - PROTO_NFS = 0, - PROTO_SMB = 1, - PROTO_END = 2 -} zfs_share_proto_t; - -/* - * The following can be used as a bitmask and any new values - * added must preserve that capability. - */ -typedef enum { - SHARED_NOT_SHARED = 0x0, - SHARED_NFS = 0x2, - SHARED_SMB = 0x4 -} zfs_share_type_t; - typedef int (*zfs_uri_handler_fn_t)(struct libzfs_handle *, const char *, const char *, zfs_keyformat_t, boolean_t, uint8_t **, size_t *); @@ -175,10 +159,10 @@ extern int zprop_expand_list(libzfs_handle_t *hdl, zprop_list_t **plp, typedef struct prop_changelist prop_changelist_t; -extern int zcmd_alloc_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *, size_t); -extern int zcmd_write_src_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t *); -extern int zcmd_write_conf_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t *); -extern int zcmd_expand_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *); +extern void zcmd_alloc_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *, size_t); +extern void zcmd_write_src_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t *); +extern void zcmd_write_conf_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t *); +extern void zcmd_expand_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *); extern int zcmd_read_dst_nvlist(libzfs_handle_t *, zfs_cmd_t *, nvlist_t **); extern void zcmd_free_nvlists(zfs_cmd_t *); @@ -189,7 +173,7 @@ extern void changelist_remove(prop_changelist_t *, const char *); extern void changelist_free(prop_changelist_t *); extern prop_changelist_t *changelist_gather(zfs_handle_t *, zfs_prop_t, int, int); -extern int changelist_unshare(prop_changelist_t *, const zfs_share_proto_t *); +extern int changelist_unshare(prop_changelist_t *, const enum sa_protocol *); extern int changelist_haszonedchild(prop_changelist_t *); extern void remove_mountpoint(zfs_handle_t *); @@ -209,11 +193,8 @@ extern int zfs_validate_name(libzfs_handle_t *hdl, const char *path, int type, extern void namespace_clear(libzfs_handle_t *); -extern int zfs_parse_options(char *, zfs_share_proto_t); - typedef struct { zfs_prop_t p_prop; - char *p_name; int p_share_err; int p_unshare_err; } proto_table_t; @@ -243,21 +224,10 @@ typedef struct differ_info { extern int do_mount(zfs_handle_t *zhp, const char *mntpt, char *opts, int flags); extern int do_unmount(zfs_handle_t *zhp, const char *mntpt, int flags); -extern int zfs_mount_delegation_check(void); -extern int zfs_share_proto(zfs_handle_t *zhp, const zfs_share_proto_t *proto); -extern int zfs_unshare_proto(zfs_handle_t *, const char *, - const zfs_share_proto_t *); -extern int unshare_one(libzfs_handle_t *hdl, const char *name, - const char *mountpoint, zfs_share_proto_t proto); -extern boolean_t zfs_is_mountable(zfs_handle_t *zhp, char *buf, size_t buflen, - zprop_source_t *source, int flags); -extern zfs_share_type_t is_shared(const char *mountpoint, - zfs_share_proto_t proto); extern int libzfs_load_module(void); extern int zpool_relabel_disk(libzfs_handle_t *hdl, const char *path, const char *msg); extern int find_shares_object(differ_info_t *di); -extern void zfs_commit_proto(const zfs_share_proto_t *); #ifdef __cplusplus } diff --git a/sys/contrib/openzfs/lib/libzfs/libzfs_import.c b/sys/contrib/openzfs/lib/libzfs/libzfs_import.c index 004a684d5be8..ed3cfea56fa0 100644 --- a/sys/contrib/openzfs/lib/libzfs/libzfs_import.c +++ b/sys/contrib/openzfs/lib/libzfs/libzfs_import.c @@ -73,23 +73,15 @@ refresh_config(libzfs_handle_t *hdl, nvlist_t *config) zfs_cmd_t zc = {"\0"}; int err, dstbuf_size; - if (zcmd_write_conf_nvlist(hdl, &zc, config) != 0) - return (NULL); + zcmd_write_conf_nvlist(hdl, &zc, config); dstbuf_size = MAX(CONFIG_BUF_MINSIZE, zc.zc_nvlist_conf_size * 32); - if (zcmd_alloc_dst_nvlist(hdl, &zc, dstbuf_size) != 0) { - zcmd_free_nvlists(&zc); - return (NULL); - } + zcmd_alloc_dst_nvlist(hdl, &zc, dstbuf_size); while ((err = zfs_ioctl(hdl, ZFS_IOC_POOL_TRYIMPORT, - &zc)) != 0 && errno == ENOMEM) { - if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) { - zcmd_free_nvlists(&zc); - return (NULL); - } - } + &zc)) != 0 && errno == ENOMEM) + zcmd_expand_dst_nvlist(hdl, &zc); if (err) { zcmd_free_nvlists(&zc); @@ -145,10 +137,9 @@ zpool_clear_label(int fd) struct stat64 statbuf; int l; vdev_label_t *label; - l2arc_dev_hdr_phys_t *l2dhdr; uint64_t size; - int labels_cleared = 0, header_cleared = 0; - boolean_t clear_l2arc_header = B_FALSE; + boolean_t labels_cleared = B_FALSE, clear_l2arc_header = B_FALSE, + header_cleared = B_FALSE; if (fstat64_blk(fd, &statbuf) == -1) return (0); @@ -158,11 +149,6 @@ zpool_clear_label(int fd) if ((label = calloc(1, sizeof (vdev_label_t))) == NULL) return (-1); - if ((l2dhdr = calloc(1, sizeof (l2arc_dev_hdr_phys_t))) == NULL) { - free(label); - return (-1); - } - for (l = 0; l < VDEV_LABELS; l++) { uint64_t state, guid, l2cache; nvlist_t *config; @@ -212,24 +198,22 @@ zpool_clear_label(int fd) size_t label_size = sizeof (vdev_label_t) - (2 * VDEV_PAD_SIZE); if (pwrite64(fd, label, label_size, label_offset(size, l) + - (2 * VDEV_PAD_SIZE)) == label_size) { - labels_cleared++; - } + (2 * VDEV_PAD_SIZE)) == label_size) + labels_cleared = B_TRUE; } - /* Clear the L2ARC header. */ if (clear_l2arc_header) { - memset(l2dhdr, 0, sizeof (l2arc_dev_hdr_phys_t)); - if (pwrite64(fd, l2dhdr, sizeof (l2arc_dev_hdr_phys_t), - VDEV_LABEL_START_SIZE) == sizeof (l2arc_dev_hdr_phys_t)) { - header_cleared++; - } + _Static_assert(sizeof (*label) >= sizeof (l2arc_dev_hdr_phys_t), + "label < l2arc_dev_hdr_phys_t"); + memset(label, 0, sizeof (l2arc_dev_hdr_phys_t)); + if (pwrite64(fd, label, sizeof (l2arc_dev_hdr_phys_t), + VDEV_LABEL_START_SIZE) == sizeof (l2arc_dev_hdr_phys_t)) + header_cleared = B_TRUE; } free(label); - free(l2dhdr); - if (labels_cleared == 0) + if (!labels_cleared || (clear_l2arc_header && !header_cleared)) return (-1); return (0); @@ -442,12 +426,7 @@ zpool_in_use(libzfs_handle_t *hdl, int fd, pool_state_t *state, char **namestr, if (ret) { - if ((*namestr = zfs_strdup(hdl, name)) == NULL) { - if (cb.cb_zhp) - zpool_close(cb.cb_zhp); - nvlist_free(config); - return (-1); - } + *namestr = zfs_strdup(hdl, name); *state = (pool_state_t)stateval; } diff --git a/sys/contrib/openzfs/lib/libzfs/libzfs_iter.c b/sys/contrib/openzfs/lib/libzfs/libzfs_iter.c index 132454886cfe..db199c44ed30 100644 --- a/sys/contrib/openzfs/lib/libzfs/libzfs_iter.c +++ b/sys/contrib/openzfs/lib/libzfs/libzfs_iter.c @@ -75,10 +75,7 @@ zfs_do_list_ioctl(zfs_handle_t *zhp, int arg, zfs_cmd_t *zc) switch (errno) { case ENOMEM: /* expand nvlist memory and try again */ - if (zcmd_expand_dst_nvlist(zhp->zfs_hdl, zc) != 0) { - zcmd_free_nvlists(zc); - return (-1); - } + zcmd_expand_dst_nvlist(zhp->zfs_hdl, zc); zc->zc_cookie = orig_cookie; goto top; /* @@ -113,8 +110,7 @@ zfs_iter_filesystems(zfs_handle_t *zhp, zfs_iter_f func, void *data) if (zhp->zfs_type != ZFS_TYPE_FILESYSTEM) return (0); - if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0) - return (-1); + zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0); while ((ret = zfs_do_list_ioctl(zhp, ZFS_IOC_DATASET_LIST_NEXT, &zc)) == 0) { @@ -154,8 +150,7 @@ zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple, zfs_iter_f func, zc.zc_simple = simple; - if (zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0) != 0) - return (-1); + zcmd_alloc_dst_nvlist(zhp->zfs_hdl, &zc, 0); if (min_txg != 0) { range_nvl = fnvlist_alloc(); @@ -167,12 +162,8 @@ zfs_iter_snapshots(zfs_handle_t *zhp, boolean_t simple, zfs_iter_f func, fnvlist_add_uint64(range_nvl, SNAP_ITER_MAX_TXG, max_txg); } - if (range_nvl != NULL && - zcmd_write_src_nvlist(zhp->zfs_hdl, &zc, range_nvl) != 0) { - zcmd_free_nvlists(&zc); - fnvlist_free(range_nvl); - return (-1); - } + if (range_nvl != NULL) + zcmd_write_src_nvlist(zhp->zfs_hdl, &zc, range_nvl); while ((ret = zfs_do_list_ioctl(zhp, ZFS_IOC_SNAPSHOT_LIST_NEXT, &zc)) == 0) { diff --git a/sys/contrib/openzfs/lib/libzfs/libzfs_mount.c b/sys/contrib/openzfs/lib/libzfs/libzfs_mount.c index 794fd2f29628..a2f1c982c9f4 100644 --- a/sys/contrib/openzfs/lib/libzfs/libzfs_mount.c +++ b/sys/contrib/openzfs/lib/libzfs/libzfs_mount.c @@ -41,23 +41,13 @@ * zfs_unmount() * zfs_unmountall() * - * This file also contains the functions used to manage sharing filesystems via - * NFS and iSCSI: + * This file also contains the functions used to manage sharing filesystems: * * zfs_is_shared() * zfs_share() * zfs_unshare() - * - * zfs_is_shared_nfs() - * zfs_is_shared_smb() - * zfs_share_proto() - * zfs_shareall(); - * zfs_unshare_nfs() - * zfs_unshare_smb() - * zfs_unshareall_nfs() - * zfs_unshareall_smb() * zfs_unshareall() - * zfs_unshareall_bypath() + * zfs_commit_shares() * * The following functions are available for pool consumers, and will * mount/unmount and share/unshare all datasets within pool: @@ -95,31 +85,18 @@ static int mount_tp_nthr = 512; /* tpool threads for multi-threaded mounting */ static void zfs_mount_task(void *); -static zfs_share_type_t zfs_is_shared_proto(zfs_handle_t *, char **, - zfs_share_proto_t); -/* - * The share protocols table must be in the same order as the zfs_share_proto_t - * enum in libzfs_impl.h - */ -static const proto_table_t proto_table[PROTO_END] = { - {ZFS_PROP_SHARENFS, "nfs", EZFS_SHARENFSFAILED, EZFS_UNSHARENFSFAILED}, - {ZFS_PROP_SHARESMB, "smb", EZFS_SHARESMBFAILED, EZFS_UNSHARESMBFAILED}, +static const proto_table_t proto_table[SA_PROTOCOL_COUNT] = { + [SA_PROTOCOL_NFS] = + {ZFS_PROP_SHARENFS, EZFS_SHARENFSFAILED, EZFS_UNSHARENFSFAILED}, + [SA_PROTOCOL_SMB] = + {ZFS_PROP_SHARESMB, EZFS_SHARESMBFAILED, EZFS_UNSHARESMBFAILED}, }; -static const zfs_share_proto_t nfs_only[] = { - PROTO_NFS, - PROTO_END -}; - -static const zfs_share_proto_t smb_only[] = { - PROTO_SMB, - PROTO_END -}; -static const zfs_share_proto_t share_all_proto[] = { - PROTO_NFS, - PROTO_SMB, - PROTO_END +static const enum sa_protocol share_all_proto[SA_PROTOCOL_COUNT + 1] = { + SA_PROTOCOL_NFS, + SA_PROTOCOL_SMB, + SA_NO_PROTOCOL }; @@ -260,7 +237,7 @@ zfs_is_mountable_internal(zfs_handle_t *zhp) * Returns true if the given dataset is mountable, false otherwise. Returns the * mountpoint in 'buf'. */ -boolean_t +static boolean_t zfs_is_mountable(zfs_handle_t *zhp, char *buf, size_t buflen, zprop_source_t *source, int flags) { @@ -634,16 +611,16 @@ zfs_unmount(zfs_handle_t *zhp, const char *mountpoint, int flags) /* * Unshare and unmount the filesystem */ - if (zfs_unshare_proto(zhp, mntpt, share_all_proto) != 0) { + if (zfs_unshare(zhp, mntpt, share_all_proto) != 0) { free(mntpt); return (-1); } - zfs_commit_all_shares(); + zfs_commit_shares(NULL); if (unmount_one(zhp, mntpt, flags) != 0) { free(mntpt); - (void) zfs_shareall(zhp); - zfs_commit_all_shares(); + (void) zfs_share(zhp, NULL); + zfs_commit_shares(NULL); return (-1); } @@ -702,58 +679,20 @@ zfs_unmountall(zfs_handle_t *zhp, int flags) return (ret); } -boolean_t -zfs_is_shared(zfs_handle_t *zhp) -{ - zfs_share_type_t rc = 0; - const zfs_share_proto_t *curr_proto; - - if (ZFS_IS_VOLUME(zhp)) - return (B_FALSE); - - for (curr_proto = share_all_proto; *curr_proto != PROTO_END; - curr_proto++) - rc |= zfs_is_shared_proto(zhp, NULL, *curr_proto); - - return (rc ? B_TRUE : B_FALSE); -} - /* * Unshare a filesystem by mountpoint. */ -int +static int unshare_one(libzfs_handle_t *hdl, const char *name, const char *mountpoint, - zfs_share_proto_t proto) + enum sa_protocol proto) { - int err; - - err = sa_disable_share(mountpoint, proto_table[proto].p_name); - if (err != SA_OK) { + int err = sa_disable_share(mountpoint, proto); + if (err != SA_OK) return (zfs_error_fmt(hdl, proto_table[proto].p_unshare_err, dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"), name, sa_errorstr(err))); - } - return (0); -} -/* - * Query libshare for the given mountpoint and protocol, returning - * a zfs_share_type_t value. - */ -zfs_share_type_t -is_shared(const char *mountpoint, zfs_share_proto_t proto) -{ - if (sa_is_shared(mountpoint, proto_table[proto].p_name)) { - switch (proto) { - case PROTO_NFS: - return (SHARED_NFS); - case PROTO_SMB: - return (SHARED_SMB); - default: - return (SHARED_NOT_SHARED); - } - } - return (SHARED_NOT_SHARED); + return (0); } /* @@ -762,19 +701,22 @@ is_shared(const char *mountpoint, zfs_share_proto_t proto) * on "libshare" to do the dirty work for us. */ int -zfs_share_proto(zfs_handle_t *zhp, const zfs_share_proto_t *proto) +zfs_share(zfs_handle_t *zhp, const enum sa_protocol *proto) { char mountpoint[ZFS_MAXPROPLEN]; char shareopts[ZFS_MAXPROPLEN]; char sourcestr[ZFS_MAXPROPLEN]; - const zfs_share_proto_t *curr_proto; + const enum sa_protocol *curr_proto; zprop_source_t sourcetype; int err = 0; + if (proto == NULL) + proto = share_all_proto; + if (!zfs_is_mountable(zhp, mountpoint, sizeof (mountpoint), NULL, 0)) return (0); - for (curr_proto = proto; *curr_proto != PROTO_END; curr_proto++) { + for (curr_proto = proto; *curr_proto != SA_NO_PROTOCOL; curr_proto++) { /* * Return success if there are no share options. */ @@ -794,7 +736,7 @@ zfs_share_proto(zfs_handle_t *zhp, const zfs_share_proto_t *proto) continue; err = sa_enable_share(zfs_get_name(zhp), mountpoint, shareopts, - proto_table[*curr_proto].p_name); + *curr_proto); if (err != SA_OK) { return (zfs_error_fmt(zhp->zfs_hdl, proto_table[*curr_proto].p_share_err, @@ -806,188 +748,88 @@ zfs_share_proto(zfs_handle_t *zhp, const zfs_share_proto_t *proto) return (0); } -int -zfs_share(zfs_handle_t *zhp) -{ - assert(!ZFS_IS_VOLUME(zhp)); - return (zfs_share_proto(zhp, share_all_proto)); -} - -int -zfs_unshare(zfs_handle_t *zhp) -{ - assert(!ZFS_IS_VOLUME(zhp)); - return (zfs_unshareall(zhp)); -} - /* * Check to see if the filesystem is currently shared. */ -static zfs_share_type_t -zfs_is_shared_proto(zfs_handle_t *zhp, char **where, zfs_share_proto_t proto) +boolean_t +zfs_is_shared(zfs_handle_t *zhp, char **where, + const enum sa_protocol *proto) { char *mountpoint; - zfs_share_type_t rc; + if (proto == NULL) + proto = share_all_proto; + + if (ZFS_IS_VOLUME(zhp)) + return (B_FALSE); if (!zfs_is_mounted(zhp, &mountpoint)) - return (SHARED_NOT_SHARED); + return (B_FALSE); - if ((rc = is_shared(mountpoint, proto)) - != SHARED_NOT_SHARED) { - if (where != NULL) - *where = mountpoint; - else - free(mountpoint); - return (rc); - } else { - free(mountpoint); - return (SHARED_NOT_SHARED); - } -} + for (const enum sa_protocol *p = proto; *p != SA_NO_PROTOCOL; ++p) + if (sa_is_shared(mountpoint, *p)) { + if (where != NULL) + *where = mountpoint; + else + free(mountpoint); + return (B_TRUE); + } -boolean_t -zfs_is_shared_nfs(zfs_handle_t *zhp, char **where) -{ - return (zfs_is_shared_proto(zhp, where, - PROTO_NFS) != SHARED_NOT_SHARED); -} - -boolean_t -zfs_is_shared_smb(zfs_handle_t *zhp, char **where) -{ - return (zfs_is_shared_proto(zhp, where, - PROTO_SMB) != SHARED_NOT_SHARED); -} - -/* - * zfs_parse_options(options, proto) - * - * Call the legacy parse interface to get the protocol specific - * options using the NULL arg to indicate that this is a "parse" only. - */ -int -zfs_parse_options(char *options, zfs_share_proto_t proto) -{ - return (sa_validate_shareopts(options, proto_table[proto].p_name)); + free(mountpoint); + return (B_FALSE); } void -zfs_commit_proto(const zfs_share_proto_t *proto) -{ - const zfs_share_proto_t *curr_proto; - for (curr_proto = proto; *curr_proto != PROTO_END; curr_proto++) - sa_commit_shares(proto_table[*curr_proto].p_name); -} - -void -zfs_commit_nfs_shares(void) -{ - zfs_commit_proto(nfs_only); -} - -void -zfs_commit_smb_shares(void) -{ - zfs_commit_proto(smb_only); -} - -void -zfs_commit_all_shares(void) -{ - zfs_commit_proto(share_all_proto); -} - -void -zfs_commit_shares(const char *proto) +zfs_commit_shares(const enum sa_protocol *proto) { if (proto == NULL) - zfs_commit_proto(share_all_proto); - else if (strcmp(proto, "nfs") == 0) - zfs_commit_proto(nfs_only); - else if (strcmp(proto, "smb") == 0) - zfs_commit_proto(smb_only); -} + proto = share_all_proto; -int -zfs_share_nfs(zfs_handle_t *zhp) -{ - return (zfs_share_proto(zhp, nfs_only)); -} - -int -zfs_share_smb(zfs_handle_t *zhp) -{ - return (zfs_share_proto(zhp, smb_only)); -} - -int -zfs_shareall(zfs_handle_t *zhp) -{ - return (zfs_share_proto(zhp, share_all_proto)); + for (const enum sa_protocol *p = proto; *p != SA_NO_PROTOCOL; ++p) + sa_commit_shares(*p); } /* * Unshare the given filesystem. */ int -zfs_unshare_proto(zfs_handle_t *zhp, const char *mountpoint, - const zfs_share_proto_t *proto) +zfs_unshare(zfs_handle_t *zhp, const char *mountpoint, + const enum sa_protocol *proto) { libzfs_handle_t *hdl = zhp->zfs_hdl; struct mnttab entry; - char *mntpt = NULL; - /* check to see if need to unmount the filesystem */ - if (mountpoint != NULL) - mntpt = zfs_strdup(hdl, mountpoint); + if (proto == NULL) + proto = share_all_proto; if (mountpoint != NULL || ((zfs_get_type(zhp) == ZFS_TYPE_FILESYSTEM) && libzfs_mnttab_find(hdl, zfs_get_name(zhp), &entry) == 0)) { - const zfs_share_proto_t *curr_proto; - if (mountpoint == NULL) - mntpt = zfs_strdup(zhp->zfs_hdl, entry.mnt_mountp); + /* check to see if need to unmount the filesystem */ + const char *mntpt = mountpoint ?: entry.mnt_mountp; - for (curr_proto = proto; *curr_proto != PROTO_END; - curr_proto++) { - - if (is_shared(mntpt, *curr_proto)) { - if (unshare_one(hdl, zhp->zfs_name, - mntpt, *curr_proto) != 0) { - if (mntpt != NULL) - free(mntpt); + for (const enum sa_protocol *curr_proto = proto; + *curr_proto != SA_NO_PROTOCOL; curr_proto++) + if (sa_is_shared(mntpt, *curr_proto) && + unshare_one(hdl, zhp->zfs_name, + mntpt, *curr_proto) != 0) return (-1); - } - } - } } - if (mntpt != NULL) - free(mntpt); return (0); } -int -zfs_unshare_nfs(zfs_handle_t *zhp, const char *mountpoint) -{ - return (zfs_unshare_proto(zhp, mountpoint, nfs_only)); -} - -int -zfs_unshare_smb(zfs_handle_t *zhp, const char *mountpoint) -{ - return (zfs_unshare_proto(zhp, mountpoint, smb_only)); -} - /* * Same as zfs_unmountall(), but for NFS and SMB unshares. */ -static int -zfs_unshareall_proto(zfs_handle_t *zhp, const zfs_share_proto_t *proto) +int +zfs_unshareall(zfs_handle_t *zhp, const enum sa_protocol *proto) { prop_changelist_t *clp; int ret; + if (proto == NULL) + proto = share_all_proto; + clp = changelist_gather(zhp, ZFS_PROP_SHARENFS, 0, 0); if (clp == NULL) return (-1); @@ -998,44 +840,6 @@ zfs_unshareall_proto(zfs_handle_t *zhp, const zfs_share_proto_t *proto) return (ret); } -int -zfs_unshareall_nfs(zfs_handle_t *zhp) -{ - return (zfs_unshareall_proto(zhp, nfs_only)); -} - -int -zfs_unshareall_smb(zfs_handle_t *zhp) -{ - return (zfs_unshareall_proto(zhp, smb_only)); -} - -int -zfs_unshareall(zfs_handle_t *zhp) -{ - return (zfs_unshareall_proto(zhp, share_all_proto)); -} - -int -zfs_unshareall_bypath(zfs_handle_t *zhp, const char *mountpoint) -{ - return (zfs_unshare_proto(zhp, mountpoint, share_all_proto)); -} - -int -zfs_unshareall_bytype(zfs_handle_t *zhp, const char *mountpoint, - const char *proto) -{ - if (proto == NULL) - return (zfs_unshare_proto(zhp, mountpoint, share_all_proto)); - if (strcmp(proto, "nfs") == 0) - return (zfs_unshare_proto(zhp, mountpoint, nfs_only)); - else if (strcmp(proto, "smb") == 0) - return (zfs_unshare_proto(zhp, mountpoint, smb_only)); - else - return (1); -} - /* * Remove the mountpoint associated with the current dataset, if necessary. * We only remove the underlying directory if: @@ -1326,7 +1130,7 @@ zfs_share_one(zfs_handle_t *zhp, void *arg) mount_state_t *ms = arg; int ret = 0; - if (zfs_share(zhp) != 0) + if (zfs_share(zhp, NULL) != 0) ret = ms->ms_mntstatus = -1; return (ret); } @@ -1499,7 +1303,7 @@ zpool_enable_datasets(zpool_handle_t *zhp, const char *mntopts, int flags) if (ms.ms_mntstatus != 0) ret = ms.ms_mntstatus; else - zfs_commit_all_shares(); + zfs_commit_shares(NULL); out: for (int i = 0; i < cb.cb_used; i++) @@ -1572,29 +1376,19 @@ zpool_disable_datasets(zpool_handle_t *zhp, boolean_t force) */ if (used == alloc) { if (alloc == 0) { - - if ((sets = zfs_alloc(hdl, - 8 * sizeof (struct sets_s))) == NULL) - goto out; - + sets = zfs_alloc(hdl, + 8 * sizeof (struct sets_s)); alloc = 8; } else { - void *ptr; - - if ((ptr = zfs_realloc(hdl, sets, + sets = zfs_realloc(hdl, sets, alloc * sizeof (struct sets_s), - alloc * 2 * sizeof (struct sets_s))) - == NULL) - goto out; - sets = ptr; + alloc * 2 * sizeof (struct sets_s)); alloc *= 2; } } - if ((sets[used].mountpoint = zfs_strdup(hdl, - entry.mnt_mountp)) == NULL) - goto out; + sets[used].mountpoint = zfs_strdup(hdl, entry.mnt_mountp); /* * This is allowed to fail, in case there is some I/O error. It @@ -1618,16 +1412,14 @@ zpool_disable_datasets(zpool_handle_t *zhp, boolean_t force) * Walk through and first unshare everything. */ for (i = 0; i < used; i++) { - const zfs_share_proto_t *curr_proto; - for (curr_proto = share_all_proto; *curr_proto != PROTO_END; - curr_proto++) { - if (is_shared(sets[i].mountpoint, *curr_proto) && + for (enum sa_protocol i = 0; i < SA_PROTOCOL_COUNT; ++i) { + if (sa_is_shared(sets[i].mountpoint, i) && unshare_one(hdl, sets[i].mountpoint, - sets[i].mountpoint, *curr_proto) != 0) + sets[i].mountpoint, i) != 0) goto out; } } - zfs_commit_all_shares(); + zfs_commit_shares(NULL); /* * Now unmount everything, removing the underlying directories as diff --git a/sys/contrib/openzfs/lib/libzfs/libzfs_pool.c b/sys/contrib/openzfs/lib/libzfs/libzfs_pool.c index a65a9b645028..730e6db53f1b 100644 --- a/sys/contrib/openzfs/lib/libzfs/libzfs_pool.c +++ b/sys/contrib/openzfs/lib/libzfs/libzfs_pool.c @@ -79,16 +79,12 @@ zpool_get_all_props(zpool_handle_t *zhp) (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); - if (zcmd_alloc_dst_nvlist(hdl, &zc, 0) != 0) - return (-1); + zcmd_alloc_dst_nvlist(hdl, &zc, 0); while (zfs_ioctl(hdl, ZFS_IOC_POOL_GET_PROPS, &zc) != 0) { - if (errno == ENOMEM) { - if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) { - zcmd_free_nvlists(&zc); - return (-1); - } - } else { + if (errno == ENOMEM) + zcmd_expand_dst_nvlist(hdl, &zc); + else { zcmd_free_nvlists(&zc); return (-1); } @@ -813,10 +809,7 @@ zpool_set_prop(zpool_handle_t *zhp, const char *propname, const char *propval) */ (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); - if (zcmd_write_src_nvlist(zhp->zpool_hdl, &zc, nvl) != 0) { - nvlist_free(nvl); - return (-1); - } + zcmd_write_src_nvlist(zhp->zpool_hdl, &zc, nvl); ret = zfs_ioctl(zhp->zpool_hdl, ZFS_IOC_POOL_SET_PROPS, &zc); @@ -982,10 +975,8 @@ vdev_expand_proplist(zpool_handle_t *zhp, const char *vdevname, strval = fnvlist_lookup_string(propval, ZPROP_VALUE); - if ((entry = zfs_alloc(zhp->zpool_hdl, - sizeof (zprop_list_t))) == NULL) - return (ENOMEM); - + entry = zfs_alloc(zhp->zpool_hdl, + sizeof (zprop_list_t)); entry->pl_prop = prop; entry->pl_user_prop = zfs_strdup(zhp->zpool_hdl, propname); @@ -1179,8 +1170,7 @@ zpool_open_canfail(libzfs_handle_t *hdl, const char *pool) return (NULL); } - if ((zhp = zfs_alloc(hdl, sizeof (zpool_handle_t))) == NULL) - return (NULL); + zhp = zfs_alloc(hdl, sizeof (zpool_handle_t)); zhp->zpool_hdl = hdl; (void) strlcpy(zhp->zpool_name, pool, sizeof (zhp->zpool_name)); @@ -1211,8 +1201,7 @@ zpool_open_silent(libzfs_handle_t *hdl, const char *pool, zpool_handle_t **ret) zpool_handle_t *zhp; boolean_t missing; - if ((zhp = zfs_alloc(hdl, sizeof (zpool_handle_t))) == NULL) - return (-1); + zhp = zfs_alloc(hdl, sizeof (zpool_handle_t)); zhp->zpool_hdl = hdl; (void) strlcpy(zhp->zpool_name, pool, sizeof (zhp->zpool_name)); @@ -1388,8 +1377,7 @@ zpool_create(libzfs_handle_t *hdl, const char *pool, nvlist_t *nvroot, if (!zpool_name_valid(hdl, B_FALSE, pool)) return (zfs_error(hdl, EZFS_INVALIDNAME, msg)); - if (zcmd_write_conf_nvlist(hdl, &zc, nvroot) != 0) - return (-1); + zcmd_write_conf_nvlist(hdl, &zc, nvroot); if (props) { prop_flags_t flags = { .create = B_TRUE, .import = B_FALSE }; @@ -1450,8 +1438,8 @@ zpool_create(libzfs_handle_t *hdl, const char *pool, nvlist_t *nvroot, } } - if (zc_props && zcmd_write_src_nvlist(hdl, &zc, zc_props) != 0) - goto create_failed; + if (zc_props) + zcmd_write_src_nvlist(hdl, &zc, zc_props); (void) strlcpy(zc.zc_name, pool, sizeof (zc.zc_name)); @@ -1665,8 +1653,7 @@ zpool_add(zpool_handle_t *zhp, nvlist_t *nvroot) return (zfs_error(hdl, EZFS_BADVERSION, msg)); } - if (zcmd_write_conf_nvlist(hdl, &zc, nvroot) != 0) - return (-1); + zcmd_write_conf_nvlist(hdl, &zc, nvroot); (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); if (zfs_ioctl(hdl, ZFS_IOC_VDEV_ADD, &zc) != 0) { @@ -2048,10 +2035,7 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, if ((props = zpool_valid_proplist(hdl, origname, props, version, flags, errbuf)) == NULL) return (-1); - if (zcmd_write_src_nvlist(hdl, &zc, props) != 0) { - nvlist_free(props); - return (-1); - } + zcmd_write_src_nvlist(hdl, &zc, props); nvlist_free(props); } @@ -2059,23 +2043,13 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, zc.zc_guid = fnvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID); - if (zcmd_write_conf_nvlist(hdl, &zc, config) != 0) { - zcmd_free_nvlists(&zc); - return (-1); - } - if (zcmd_alloc_dst_nvlist(hdl, &zc, zc.zc_nvlist_conf_size * 2) != 0) { - zcmd_free_nvlists(&zc); - return (-1); - } + zcmd_write_conf_nvlist(hdl, &zc, config); + zcmd_alloc_dst_nvlist(hdl, &zc, zc.zc_nvlist_conf_size * 2); zc.zc_cookie = flags; while ((ret = zfs_ioctl(hdl, ZFS_IOC_POOL_IMPORT, &zc)) != 0 && - errno == ENOMEM) { - if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) { - zcmd_free_nvlists(&zc); - return (-1); - } - } + errno == ENOMEM) + zcmd_expand_dst_nvlist(hdl, &zc); if (ret != 0) error = errno; @@ -3408,8 +3382,7 @@ zpool_vdev_attach(zpool_handle_t *zhp, const char *old_disk, free(newname); - if (zcmd_write_conf_nvlist(hdl, &zc, nvroot) != 0) - return (-1); + zcmd_write_conf_nvlist(hdl, &zc, nvroot); ret = zfs_ioctl(hdl, ZFS_IOC_VDEV_ATTACH, &zc); @@ -3815,10 +3788,9 @@ zpool_vdev_split(zpool_handle_t *zhp, char *newname, nvlist_t **newroot, zc.zc_cookie = ZPOOL_EXPORT_AFTER_SPLIT; (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); (void) strlcpy(zc.zc_string, newname, sizeof (zc.zc_string)); - if (zcmd_write_conf_nvlist(hdl, &zc, newconfig) != 0) - goto out; - if (zc_props != NULL && zcmd_write_src_nvlist(hdl, &zc, zc_props) != 0) - goto out; + zcmd_write_conf_nvlist(hdl, &zc, newconfig); + if (zc_props != NULL) + zcmd_write_src_nvlist(hdl, &zc, zc_props); if (zfs_ioctl(hdl, ZFS_IOC_VDEV_SPLIT, &zc) != 0) { retval = zpool_standard_error(hdl, errno, msg); @@ -4020,19 +3992,12 @@ zpool_clear(zpool_handle_t *zhp, const char *path, nvlist_t *rewindnvl) zpool_get_load_policy(rewindnvl, &policy); zc.zc_cookie = policy.zlp_rewind; - if (zcmd_alloc_dst_nvlist(hdl, &zc, zhp->zpool_config_size * 2) != 0) - return (-1); - - if (zcmd_write_src_nvlist(hdl, &zc, rewindnvl) != 0) - return (-1); + zcmd_alloc_dst_nvlist(hdl, &zc, zhp->zpool_config_size * 2); + zcmd_write_src_nvlist(hdl, &zc, rewindnvl); while ((error = zfs_ioctl(hdl, ZFS_IOC_CLEAR, &zc)) != 0 && - errno == ENOMEM) { - if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) { - zcmd_free_nvlists(&zc); - return (-1); - } - } + errno == ENOMEM) + zcmd_expand_dst_nvlist(hdl, &zc); if (!error || ((policy.zlp_rewind & ZPOOL_TRY_REWIND) && errno != EPERM && errno != EACCES)) { @@ -4158,10 +4123,11 @@ char * zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv, int name_flags) { - char *path, *type, *env; + char *type, *tpath; + const char *path; uint64_t value; char buf[PATH_BUF_LEN]; - char tmpbuf[PATH_BUF_LEN]; + char tmpbuf[PATH_BUF_LEN * 2]; /* * vdev_name will be "root"/"root-0" for the root vdev, but it is the @@ -4171,19 +4137,11 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv, if (zhp != NULL && strcmp(type, "root") == 0) return (zfs_strdup(hdl, zpool_get_name(zhp))); - env = getenv("ZPOOL_VDEV_NAME_PATH"); - if (env && (strtoul(env, NULL, 0) > 0 || - !strncasecmp(env, "YES", 3) || !strncasecmp(env, "ON", 2))) + if (libzfs_envvar_is_set("ZPOOL_VDEV_NAME_PATH")) name_flags |= VDEV_NAME_PATH; - - env = getenv("ZPOOL_VDEV_NAME_GUID"); - if (env && (strtoul(env, NULL, 0) > 0 || - !strncasecmp(env, "YES", 3) || !strncasecmp(env, "ON", 2))) + if (libzfs_envvar_is_set("ZPOOL_VDEV_NAME_GUID")) name_flags |= VDEV_NAME_GUID; - - env = getenv("ZPOOL_VDEV_NAME_FOLLOW_LINKS"); - if (env && (strtoul(env, NULL, 0) > 0 || - !strncasecmp(env, "YES", 3) || !strncasecmp(env, "ON", 2))) + if (libzfs_envvar_is_set("ZPOOL_VDEV_NAME_FOLLOW_LINKS")) name_flags |= VDEV_NAME_FOLLOW_LINKS; if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_NOT_PRESENT, &value) == 0 || @@ -4191,7 +4149,9 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv, (void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID, &value); (void) snprintf(buf, sizeof (buf), "%llu", (u_longlong_t)value); path = buf; - } else if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) == 0) { + } else if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &tpath) == 0) { + path = tpath; + if (name_flags & VDEV_NAME_FOLLOW_LINKS) { char *rp = realpath(path, NULL); if (rp) { @@ -4408,13 +4368,11 @@ zpool_log_history(libzfs_handle_t *hdl, const char *message) { zfs_cmd_t zc = {"\0"}; nvlist_t *args; - int err; args = fnvlist_alloc(); fnvlist_add_string(args, "message", message); - err = zcmd_write_src_nvlist(hdl, &zc, args); - if (err == 0) - err = zfs_ioctl(hdl, ZFS_IOC_LOG_HISTORY, &zc); + zcmd_write_src_nvlist(hdl, &zc, args); + int err = zfs_ioctl(hdl, ZFS_IOC_LOG_HISTORY, &zc); nvlist_free(args); zcmd_free_nvlists(&zc); return (err); @@ -4476,17 +4434,17 @@ int zpool_get_history(zpool_handle_t *zhp, nvlist_t **nvhisp, uint64_t *off, boolean_t *eof) { + libzfs_handle_t *hdl = zhp->zpool_hdl; char *buf; int buflen = 128 * 1024; nvlist_t **records = NULL; uint_t numrecords = 0; - int err, i; + int err = 0, i; uint64_t start = *off; - buf = malloc(buflen); - if (buf == NULL) - return (ENOMEM); - /* process about 1MB a time */ + buf = zfs_alloc(hdl, buflen); + + /* process about 1MiB a time */ while (*off - start < 1024 * 1024) { uint64_t bytes_read = buflen; uint64_t leftover; @@ -4501,8 +4459,12 @@ zpool_get_history(zpool_handle_t *zhp, nvlist_t **nvhisp, uint64_t *off, } if ((err = zpool_history_unpack(buf, bytes_read, - &leftover, &records, &numrecords)) != 0) + &leftover, &records, &numrecords)) != 0) { + zpool_standard_error_fmt(hdl, err, + dgettext(TEXT_DOMAIN, + "cannot get history for '%s'"), zhp->zpool_name); break; + } *off -= leftover; if (leftover == bytes_read) { /* @@ -4511,9 +4473,7 @@ zpool_get_history(zpool_handle_t *zhp, nvlist_t **nvhisp, uint64_t *off, */ buflen *= 2; free(buf); - buf = malloc(buflen); - if (buf == NULL) - return (ENOMEM); + buf = zfs_alloc(hdl, buflen); } } @@ -4556,8 +4516,7 @@ zpool_events_next(libzfs_handle_t *hdl, nvlist_t **nvp, if (flags & ZEVENT_NONBLOCK) zc.zc_guid = ZEVENT_NONBLOCK; - if (zcmd_alloc_dst_nvlist(hdl, &zc, ZEVENT_SIZE) != 0) - return (-1); + zcmd_alloc_dst_nvlist(hdl, &zc, ZEVENT_SIZE); retry: if (zfs_ioctl(hdl, ZFS_IOC_EVENTS_NEXT, &zc) != 0) { @@ -4574,13 +4533,8 @@ zpool_events_next(libzfs_handle_t *hdl, nvlist_t **nvp, goto out; case ENOMEM: - if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) { - error = zfs_error_fmt(hdl, EZFS_NOMEM, - dgettext(TEXT_DOMAIN, "cannot get event")); - goto out; - } else { - goto retry; - } + zcmd_expand_dst_nvlist(hdl, &zc); + goto retry; default: error = zpool_standard_error_fmt(hdl, errno, dgettext(TEXT_DOMAIN, "cannot get event")); @@ -5225,7 +5179,7 @@ zpool_get_vdev_prop(zpool_handle_t *zhp, const char *vdevname, vdev_prop_t prop, { nvlist_t *reqnvl, *reqprops; nvlist_t *retprops = NULL; - uint64_t vdev_guid; + uint64_t vdev_guid = 0; int ret; if ((ret = zpool_vdev_guid(zhp, vdevname, &vdev_guid)) != 0) @@ -5284,7 +5238,7 @@ zpool_get_all_vdev_props(zpool_handle_t *zhp, const char *vdevname, nvlist_t **outnvl) { nvlist_t *nvl = NULL; - uint64_t vdev_guid; + uint64_t vdev_guid = 0; int ret; if ((ret = zpool_vdev_guid(zhp, vdevname, &vdev_guid)) != 0) diff --git a/sys/contrib/openzfs/lib/libzfs/libzfs_sendrecv.c b/sys/contrib/openzfs/lib/libzfs/libzfs_sendrecv.c index 4e805c5750ef..6017b0e43a51 100644 --- a/sys/contrib/openzfs/lib/libzfs/libzfs_sendrecv.c +++ b/sys/contrib/openzfs/lib/libzfs/libzfs_sendrecv.c @@ -910,7 +910,7 @@ send_progress_thread(void *arg) uint64_t blocks; char buf[16]; time_t t; - struct tm *tm; + struct tm tm; int err; if (!pa->pa_parsable) { @@ -934,33 +934,47 @@ send_progress_thread(void *arg) } (void) time(&t); - tm = localtime(&t); + localtime_r(&t, &tm); if (pa->pa_verbosity >= 2 && pa->pa_parsable) { (void) fprintf(stderr, "%02d:%02d:%02d\t%llu\t%llu\t%s\n", - tm->tm_hour, tm->tm_min, tm->tm_sec, + tm.tm_hour, tm.tm_min, tm.tm_sec, (u_longlong_t)bytes, (u_longlong_t)blocks, zhp->zfs_name); } else if (pa->pa_verbosity >= 2) { zfs_nicenum(bytes, buf, sizeof (buf)); (void) fprintf(stderr, "%02d:%02d:%02d %5s %8llu %s\n", - tm->tm_hour, tm->tm_min, tm->tm_sec, + tm.tm_hour, tm.tm_min, tm.tm_sec, buf, (u_longlong_t)blocks, zhp->zfs_name); } else if (pa->pa_parsable) { (void) fprintf(stderr, "%02d:%02d:%02d\t%llu\t%s\n", - tm->tm_hour, tm->tm_min, tm->tm_sec, + tm.tm_hour, tm.tm_min, tm.tm_sec, (u_longlong_t)bytes, zhp->zfs_name); } else { zfs_nicebytes(bytes, buf, sizeof (buf)); (void) fprintf(stderr, "%02d:%02d:%02d %5s %s\n", - tm->tm_hour, tm->tm_min, tm->tm_sec, + tm.tm_hour, tm.tm_min, tm.tm_sec, buf, zhp->zfs_name); } } } +static boolean_t +send_progress_thread_exit(libzfs_handle_t *hdl, pthread_t ptid) +{ + void *status = NULL; + (void) pthread_cancel(ptid); + (void) pthread_join(ptid, &status); + int error = (int)(uintptr_t)status; + if (error != 0 && status != PTHREAD_CANCELED) + return (zfs_standard_error(hdl, error, + dgettext(TEXT_DOMAIN, "progress thread exited nonzero"))); + else + return (B_FALSE); +} + static void send_print_verbose(FILE *fout, const char *tosnap, const char *fromsnap, uint64_t size, boolean_t parsable) @@ -1133,17 +1147,9 @@ dump_snapshot(zfs_handle_t *zhp, void *arg) err = dump_ioctl(zhp, sdd->prevsnap, sdd->prevsnap_obj, fromorigin, sdd->outfd, flags, sdd->debugnv); - if (sdd->progress) { - void *status = NULL; - (void) pthread_cancel(tid); - (void) pthread_join(tid, &status); - int error = (int)(uintptr_t)status; - if (error != 0 && status != PTHREAD_CANCELED) { - return (zfs_standard_error(zhp->zfs_hdl, error, - dgettext(TEXT_DOMAIN, - "progress thread exited nonzero"))); - } - } + if (sdd->progress && + send_progress_thread_exit(zhp->zfs_hdl, tid)) + return (-1); } (void) strcpy(sdd->prevsnap, thissnap); @@ -1505,20 +1511,8 @@ estimate_size(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags, lzc_flags_from_sendflags(flags), resumeobj, resumeoff, bytes, redactbook, fd, &size); - if (flags->progress) { - void *status = NULL; - (void) pthread_cancel(ptid); - (void) pthread_join(ptid, &status); - int error = (int)(uintptr_t)status; - if (error != 0 && status != PTHREAD_CANCELED) { - char errbuf[1024]; - (void) snprintf(errbuf, sizeof (errbuf), - dgettext(TEXT_DOMAIN, "progress thread exited " - "nonzero")); - return (zfs_standard_error(zhp->zfs_hdl, error, - errbuf)); - } - } + if (flags->progress && send_progress_thread_exit(zhp->zfs_hdl, ptid)) + return (-1); if (err != 0) { zfs_error_aux(zhp->zfs_hdl, "%s", strerror(err)); @@ -1830,19 +1824,8 @@ zfs_send_resume_impl_cb_impl(libzfs_handle_t *hdl, sendflags_t *flags, if (redact_book != NULL) free(redact_book); - if (flags->progress) { - void *status = NULL; - (void) pthread_cancel(tid); - (void) pthread_join(tid, &status); - int error = (int)(uintptr_t)status; - if (error != 0 && status != PTHREAD_CANCELED) { - char errbuf[1024]; - (void) snprintf(errbuf, sizeof (errbuf), - dgettext(TEXT_DOMAIN, - "progress thread exited nonzero")); - return (zfs_standard_error(hdl, error, errbuf)); - } - } + if (flags->progress && send_progress_thread_exit(hdl, tid)) + return (-1); char errbuf[1024]; (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, @@ -2641,17 +2624,8 @@ zfs_send_one_cb_impl(zfs_handle_t *zhp, const char *from, int fd, err = lzc_send_redacted(name, from, fd, lzc_flags_from_sendflags(flags), redactbook); - if (flags->progress) { - void *status = NULL; - if (err != 0) - (void) pthread_cancel(ptid); - (void) pthread_join(ptid, &status); - int error = (int)(uintptr_t)status; - if (error != 0 && status != PTHREAD_CANCELED) - return (zfs_standard_error_fmt(hdl, error, - dgettext(TEXT_DOMAIN, - "progress thread exited nonzero"))); - } + if (flags->progress && send_progress_thread_exit(hdl, ptid)) + return (-1); if (err == 0 && (flags->props || flags->holds || flags->backup)) { /* Write the final end record. */ @@ -2778,8 +2752,6 @@ recv_read_nvlist(libzfs_handle_t *hdl, int fd, int len, nvlist_t **nvp, int err; buf = zfs_alloc(hdl, len); - if (buf == NULL) - return (ENOMEM); if (len > hdl->libzfs_max_nvlist) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "nvlist too large")); @@ -3521,12 +3493,10 @@ recv_incremental_replication(libzfs_handle_t *hdl, const char *tofs, zc.zc_cookie = B_TRUE; /* received */ (void) snprintf(zc.zc_name, sizeof (zc.zc_name), "%s@%s", fsname, nvpair_name(snapelem)); - if (zcmd_write_src_nvlist(hdl, &zc, - props) == 0) { - (void) zfs_ioctl(hdl, - ZFS_IOC_SET_PROP, &zc); - zcmd_free_nvlists(&zc); - } + zcmd_write_src_nvlist(hdl, &zc, props); + (void) zfs_ioctl(hdl, + ZFS_IOC_SET_PROP, &zc); + zcmd_free_nvlists(&zc); } /* check for different snapname */ @@ -4879,10 +4849,9 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, (void) strcpy(zc.zc_name, destsnap); zc.zc_cookie = B_TRUE; /* received */ - if (zcmd_write_src_nvlist(hdl, &zc, snapprops_nvlist) == 0) { - (void) zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc); - zcmd_free_nvlists(&zc); - } + zcmd_write_src_nvlist(hdl, &zc, snapprops_nvlist); + (void) zfs_ioctl(hdl, ZFS_IOC_SET_PROP, &zc); + zcmd_free_nvlists(&zc); } if (err == 0 && snapholds_nvlist) { nvpair_t *pair; diff --git a/sys/contrib/openzfs/lib/libzfs/libzfs_util.c b/sys/contrib/openzfs/lib/libzfs/libzfs_util.c index 71072b5a74e2..c47a5782c8fb 100644 --- a/sys/contrib/openzfs/lib/libzfs/libzfs_util.c +++ b/sys/contrib/openzfs/lib/libzfs/libzfs_util.c @@ -1149,7 +1149,7 @@ zfs_path_to_zhandle(libzfs_handle_t *hdl, const char *path, zfs_type_t argtype) * Initialize the zc_nvlist_dst member to prepare for receiving an nvlist from * an ioctl(). */ -int +void zcmd_alloc_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, size_t len) { if (len == 0) @@ -1157,10 +1157,6 @@ zcmd_alloc_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, size_t len) zc->zc_nvlist_dst_size = len; zc->zc_nvlist_dst = (uint64_t)(uintptr_t)zfs_alloc(hdl, zc->zc_nvlist_dst_size); - if (zc->zc_nvlist_dst == 0) - return (-1); - - return (0); } /* @@ -1168,16 +1164,12 @@ zcmd_alloc_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, size_t len) * expand the nvlist to the size specified in 'zc_nvlist_dst_size', which was * filled in by the kernel to indicate the actual required size. */ -int +void zcmd_expand_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc) { free((void *)(uintptr_t)zc->zc_nvlist_dst); zc->zc_nvlist_dst = (uint64_t)(uintptr_t)zfs_alloc(hdl, zc->zc_nvlist_dst_size); - if (zc->zc_nvlist_dst == 0) - return (-1); - - return (0); } /* @@ -1194,36 +1186,33 @@ zcmd_free_nvlists(zfs_cmd_t *zc) zc->zc_nvlist_dst = 0; } -static int +static void zcmd_write_nvlist_com(libzfs_handle_t *hdl, uint64_t *outnv, uint64_t *outlen, nvlist_t *nvl) { char *packed; size_t len = fnvlist_size(nvl); - if ((packed = zfs_alloc(hdl, len)) == NULL) - return (-1); + packed = zfs_alloc(hdl, len); verify(nvlist_pack(nvl, &packed, &len, NV_ENCODE_NATIVE, 0) == 0); *outnv = (uint64_t)(uintptr_t)packed; *outlen = len; - - return (0); } -int +void zcmd_write_conf_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, nvlist_t *nvl) { - return (zcmd_write_nvlist_com(hdl, &zc->zc_nvlist_conf, - &zc->zc_nvlist_conf_size, nvl)); + zcmd_write_nvlist_com(hdl, &zc->zc_nvlist_conf, + &zc->zc_nvlist_conf_size, nvl); } -int +void zcmd_write_src_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, nvlist_t *nvl) { - return (zcmd_write_nvlist_com(hdl, &zc->zc_nvlist_src, - &zc->zc_nvlist_src_size, nvl)); + zcmd_write_nvlist_com(hdl, &zc->zc_nvlist_src, + &zc->zc_nvlist_src_size, nvl); } /* @@ -1863,8 +1852,7 @@ zprop_expand_list_cb(int prop, void *cb) zprop_list_t *entry; expand_data_t *edp = cb; - if ((entry = zfs_alloc(edp->hdl, sizeof (zprop_list_t))) == NULL) - return (ZPROP_INVAL); + entry = zfs_alloc(edp->hdl, sizeof (zprop_list_t)); entry->pl_prop = prop; entry->pl_width = zprop_width(prop, &entry->pl_fixed, edp->type); diff --git a/sys/contrib/openzfs/lib/libzfs/os/freebsd/libzfs_compat.c b/sys/contrib/openzfs/lib/libzfs/os/freebsd/libzfs_compat.c index a4b30df85d2b..d2bc6ddfc23a 100644 --- a/sys/contrib/openzfs/lib/libzfs/os/freebsd/libzfs_compat.c +++ b/sys/contrib/openzfs/lib/libzfs/os/freebsd/libzfs_compat.c @@ -338,15 +338,13 @@ zpool_nextboot(libzfs_handle_t *hdl, uint64_t pool_guid, uint64_t dev_guid, { zfs_cmd_t zc = {"\0"}; nvlist_t *args; - int error; args = fnvlist_alloc(); fnvlist_add_uint64(args, ZPOOL_CONFIG_POOL_GUID, pool_guid); fnvlist_add_uint64(args, ZPOOL_CONFIG_GUID, dev_guid); fnvlist_add_string(args, "command", command); - error = zcmd_write_src_nvlist(hdl, &zc, args); - if (error == 0) - error = zfs_ioctl(hdl, ZFS_IOC_NEXTBOOT, &zc); + zcmd_write_src_nvlist(hdl, &zc, args); + int error = zfs_ioctl(hdl, ZFS_IOC_NEXTBOOT, &zc); zcmd_free_nvlists(&zc); nvlist_free(args); return (error); diff --git a/sys/contrib/openzfs/lib/libzfs_core/Makefile.am b/sys/contrib/openzfs/lib/libzfs_core/Makefile.am index 64cb76f1995b..9370da4e3e74 100644 --- a/sys/contrib/openzfs/lib/libzfs_core/Makefile.am +++ b/sys/contrib/openzfs/lib/libzfs_core/Makefile.am @@ -1,37 +1,31 @@ -include $(top_srcdir)/config/Rules.am +libzfs_core_la_CFLAGS = $(AM_CFLAGS) $(LIBRARY_CFLAGS) +libzfs_core_la_CFLAGS += -fvisibility=hidden -pkgconfig_DATA = libzfs_core.pc +lib_LTLIBRARIES += libzfs_core.la +CPPCHECKTARGETS += libzfs_core.la -AM_CFLAGS += -fvisibility=hidden - -lib_LTLIBRARIES = libzfs_core.la - -include $(top_srcdir)/config/Abigail.am - -USER_C = \ - libzfs_core.c +libzfs_core_la_SOURCES = \ + %D%/libzfs_core.c if BUILD_LINUX -USER_C += \ - os/linux/libzfs_core_ioctl.c +libzfs_core_la_SOURCES += \ + %D%/os/linux/libzfs_core_ioctl.c endif +libzfs_core_la_CPPFLAGS = $(AM_CPPFLAGS) if BUILD_FREEBSD -DEFAULT_INCLUDES += -I$(top_srcdir)/include/os/freebsd/zfs +libzfs_core_la_CPPFLAGS += -Iinclude/os/freebsd/zfs -USER_C += \ - os/freebsd/libzfs_core_ioctl.c +libzfs_core_la_SOURCES += \ + %D%/os/freebsd/libzfs_core_ioctl.c -VPATH += $(top_srcdir)/module/os/freebsd/zfs - -nodist_libzfs_core_la_SOURCES = zfs_ioctl_compat.c +nodist_libzfs_core_la_SOURCES = \ + module/os/freebsd/zfs/zfs_ioctl_compat.c endif -libzfs_core_la_SOURCES = $(USER_C) - libzfs_core_la_LIBADD = \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la \ - $(abs_top_builddir)/lib/libspl/libspl.la + libnvpair.la \ + libspl.la libzfs_core_la_LIBADD += $(LTLIBINTL) @@ -47,7 +41,6 @@ endif libzfs_core_la_LDFLAGS += -version-info 3:0:0 -include $(top_srcdir)/config/CppCheck.am +pkgconfig_DATA += %D%/libzfs_core.pc -# Library ABI -EXTRA_DIST = libzfs_core.abi libzfs_core.suppr +EXTRA_DIST += $(addprefix %D%/,libzfs_core.abi libzfs_core.suppr) diff --git a/sys/contrib/openzfs/lib/libzfs_core/libzfs_core.c b/sys/contrib/openzfs/lib/libzfs_core/libzfs_core.c index 0d74aa2133f4..681fd8c7ba5e 100644 --- a/sys/contrib/openzfs/lib/libzfs_core/libzfs_core.c +++ b/sys/contrib/openzfs/lib/libzfs_core/libzfs_core.c @@ -607,6 +607,19 @@ max_pipe_buffer(int infd) } unsigned int cur = fcntl(infd, F_GETPIPE_SZ); + /* + * Sadly, Linux has an unfixed deadlock if you do SETPIPE_SZ on a pipe + * with data in it. + * cf. #13232, https://bugzilla.kernel.org/show_bug.cgi?id=212295 + * + * And since the problem is in waking up the writer, there's nothing + * we can do about it from here. + * + * So if people want to, they can set this, but they + * may regret it... + */ + if (getenv("ZFS_SET_PIPE_MAX") == NULL) + return (cur); if (cur < max && fcntl(infd, F_SETPIPE_SZ, max) != -1) cur = max; return (cur); diff --git a/sys/contrib/openzfs/lib/libzfsbootenv/Makefile.am b/sys/contrib/openzfs/lib/libzfsbootenv/Makefile.am index 0c454a5e031b..7b87bfe6786b 100644 --- a/sys/contrib/openzfs/lib/libzfsbootenv/Makefile.am +++ b/sys/contrib/openzfs/lib/libzfsbootenv/Makefile.am @@ -1,31 +1,20 @@ -include $(top_srcdir)/config/Rules.am +libzfsbootenv_la_CFLAGS = $(AM_CFLAGS) $(LIBRARY_CFLAGS) +libzfsbootenv_la_CFLAGS += -fvisibility=hidden -pkgconfig_DATA = libzfsbootenv.pc +lib_LTLIBRARIES += libzfsbootenv.la +CPPCHECKTARGETS += libzfsbootenv.la -AM_CFLAGS += -fvisibility=hidden - -lib_LTLIBRARIES = libzfsbootenv.la - -include $(top_srcdir)/config/Abigail.am - -if BUILD_FREEBSD -DEFAULT_INCLUDES += -I$(top_srcdir)/include/os/freebsd/zfs -endif -if BUILD_LINUX -DEFAULT_INCLUDES += -I$(top_srcdir)/include/os/linux/zfs -endif - -USER_C = \ - lzbe_device.c \ - lzbe_pair.c \ - lzbe_util.c +libzfsbootenv_la_CPPFLAGS = $(AM_CPPFLAGS) +libzfsbootenv_la_CPPFLAGS += -I$(srcdir)/include/os/@ac_system_l@/zfs dist_libzfsbootenv_la_SOURCES = \ - $(USER_C) + %D%/lzbe_device.c \ + %D%/lzbe_pair.c \ + %D%/lzbe_util.c libzfsbootenv_la_LIBADD = \ - $(abs_top_builddir)/lib/libzfs/libzfs.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la + libzfs.la \ + libnvpair.la libzfsbootenv_la_LDFLAGS = @@ -35,7 +24,6 @@ endif libzfsbootenv_la_LDFLAGS += -version-info 1:0:0 -include $(top_srcdir)/config/CppCheck.am +pkgconfig_DATA += %D%/libzfsbootenv.pc -# Library ABI -EXTRA_DIST = libzfsbootenv.abi libzfsbootenv.suppr +EXTRA_DIST += $(addprefix %D%/,libzfsbootenv.abi libzfsbootenv.suppr) diff --git a/sys/contrib/openzfs/lib/libzfsbootenv/libzfsbootenv.abi b/sys/contrib/openzfs/lib/libzfsbootenv/libzfsbootenv.abi index f1401a14f7a0..86ec25cf8470 100644 --- a/sys/contrib/openzfs/lib/libzfsbootenv/libzfsbootenv.abi +++ b/sys/contrib/openzfs/lib/libzfsbootenv/libzfsbootenv.abi @@ -5,8 +5,6 @@ - - @@ -20,6 +18,7 @@ + @@ -84,21 +83,16 @@ + + + + + + - - - - - - - - - - - @@ -167,16 +161,16 @@ - + - + - + - + @@ -188,19 +182,20 @@ - - - + + + + + - diff --git a/sys/contrib/openzfs/lib/libzpool/Makefile.am b/sys/contrib/openzfs/lib/libzpool/Makefile.am index e60a906a5cb6..60eb30749847 100644 --- a/sys/contrib/openzfs/lib/libzpool/Makefile.am +++ b/sys/contrib/openzfs/lib/libzpool/Makefile.am @@ -1,220 +1,196 @@ -include $(top_srcdir)/config/Rules.am +libzpool_la_CFLAGS = $(AM_CFLAGS) $(KERNEL_CFLAGS) $(LIBRARY_CFLAGS) +libzpool_la_CFLAGS += $(ZLIB_CFLAGS) -VPATH = \ - $(top_srcdir)/module/zfs \ - $(top_srcdir)/module/zcommon \ - $(top_srcdir)/module/lua \ - $(top_srcdir)/module/os/linux/zfs \ - $(top_srcdir)/lib/libzpool +libzpool_la_CPPFLAGS = $(AM_CPPFLAGS) $(FORCEDEBUG_CPPFLAGS) +libzpool_la_CPPFLAGS += -I$(srcdir)/include/os/@ac_system_l@/zfs +libzpool_la_CPPFLAGS += -DLIB_ZPOOL_BUILD -if BUILD_FREEBSD -DEFAULT_INCLUDES += -I$(top_srcdir)/include/os/freebsd/zfs -endif -if BUILD_LINUX -DEFAULT_INCLUDES += -I$(top_srcdir)/include/os/linux/zfs -endif - -# Unconditionally enable debugging for libzpool -AM_CPPFLAGS += -DDEBUG -UNDEBUG -DZFS_DEBUG - -# Includes kernel code generate warnings for large stack frames -AM_CFLAGS += $(FRAME_LARGER_THAN) - -AM_CFLAGS += $(ZLIB_CFLAGS) - -AM_CFLAGS += -DLIB_ZPOOL_BUILD - -lib_LTLIBRARIES = libzpool.la - -USER_C = \ - kernel.c \ - taskq.c \ - util.c - -KERNEL_C = \ - zfeature_common.c \ - zfs_comutil.c \ - zfs_deleg.c \ - zfs_fletcher.c \ - zfs_fletcher_aarch64_neon.c \ - zfs_fletcher_avx512.c \ - zfs_fletcher_intel.c \ - zfs_fletcher_sse.c \ - zfs_fletcher_superscalar.c \ - zfs_fletcher_superscalar4.c \ - zfs_namecheck.c \ - zfs_prop.c \ - zpool_prop.c \ - zprop_common.c \ - abd.c \ - abd_os.c \ - aggsum.c \ - arc.c \ - arc_os.c \ - blkptr.c \ - bplist.c \ - bpobj.c \ - bptree.c \ - bqueue.c \ - btree.c \ - cityhash.c \ - dbuf.c \ - dbuf_stats.c \ - ddt.c \ - ddt_zap.c \ - dmu.c \ - dmu_diff.c \ - dmu_object.c \ - dmu_objset.c \ - dmu_recv.c \ - dmu_redact.c \ - dmu_send.c \ - dmu_traverse.c \ - dmu_tx.c \ - dmu_zfetch.c \ - dnode.c \ - dnode_sync.c \ - dsl_bookmark.c \ - dsl_crypt.c \ - dsl_dataset.c \ - dsl_deadlist.c \ - dsl_deleg.c \ - dsl_destroy.c \ - dsl_dir.c \ - dsl_pool.c \ - dsl_prop.c \ - dsl_scan.c \ - dsl_synctask.c \ - dsl_userhold.c \ - edonr_zfs.c \ - fm.c \ - gzip.c \ - hkdf.c \ - lz4.c \ - lz4_zfs.c \ - lzjb.c \ - metaslab.c \ - mmp.c \ - multilist.c \ - objlist.c \ - pathname.c \ - range_tree.c \ - refcount.c \ - rrwlock.c \ - sa.c \ - sha256.c \ - skein_zfs.c \ - spa.c \ - spa_boot.c \ - spa_checkpoint.c \ - spa_config.c \ - spa_errlog.c \ - spa_history.c \ - spa_log_spacemap.c \ - spa_misc.c \ - spa_stats.c \ - space_map.c \ - space_reftree.c \ - trace.c \ - txg.c \ - uberblock.c \ - unique.c \ - vdev.c \ - vdev_cache.c \ - vdev_draid.c \ - vdev_draid_rand.c \ - vdev_file.c \ - vdev_indirect.c \ - vdev_indirect_births.c \ - vdev_indirect_mapping.c \ - vdev_initialize.c \ - vdev_label.c \ - vdev_mirror.c \ - vdev_missing.c \ - vdev_queue.c \ - vdev_raidz.c \ - vdev_raidz_math.c \ - vdev_raidz_math_aarch64_neon.c \ - vdev_raidz_math_aarch64_neonx2.c \ - vdev_raidz_math_avx2.c \ - vdev_raidz_math_avx512bw.c \ - vdev_raidz_math_avx512f.c \ - vdev_raidz_math_powerpc_altivec.c \ - vdev_raidz_math_scalar.c \ - vdev_raidz_math_sse2.c \ - vdev_raidz_math_ssse3.c \ - vdev_rebuild.c \ - vdev_removal.c \ - vdev_root.c \ - vdev_trim.c \ - zap.c \ - zap_leaf.c \ - zap_micro.c \ - zcp.c \ - zcp_get.c \ - zcp_global.c \ - zcp_iter.c \ - zcp_set.c \ - zcp_synctask.c \ - zfeature.c \ - zfs_byteswap.c \ - zfs_debug.c \ - zfs_fm.c \ - zfs_fuid.c \ - zfs_racct.c \ - zfs_sa.c \ - zfs_ratelimit.c \ - zfs_rlock.c \ - zfs_znode.c \ - zil.c \ - zio.c \ - zio_checksum.c \ - zio_compress.c \ - zio_crypt.c \ - zio_inject.c \ - zle.c \ - zrlock.c \ - zthr.c - -LUA_C = \ - lapi.c \ - lauxlib.c \ - lbaselib.c \ - lcode.c \ - lcompat.c \ - lcorolib.c \ - lctype.c \ - ldebug.c \ - ldo.c \ - lfunc.c \ - lgc.c \ - llex.c \ - lmem.c \ - lobject.c \ - lopcodes.c \ - lparser.c \ - lstate.c \ - lstring.c \ - lstrlib.c \ - ltable.c \ - ltablib.c \ - ltm.c \ - lvm.c \ - lzio.c +lib_LTLIBRARIES += libzpool.la +CPPCHECKTARGETS += libzpool.la dist_libzpool_la_SOURCES = \ - $(USER_C) + %D%/kernel.c \ + %D%/taskq.c \ + %D%/util.c nodist_libzpool_la_SOURCES = \ - $(KERNEL_C) \ - $(LUA_C) + module/lua/lapi.c \ + module/lua/lauxlib.c \ + module/lua/lbaselib.c \ + module/lua/lcode.c \ + module/lua/lcompat.c \ + module/lua/lcorolib.c \ + module/lua/lctype.c \ + module/lua/ldebug.c \ + module/lua/ldo.c \ + module/lua/lfunc.c \ + module/lua/lgc.c \ + module/lua/llex.c \ + module/lua/lmem.c \ + module/lua/lobject.c \ + module/lua/lopcodes.c \ + module/lua/lparser.c \ + module/lua/lstate.c \ + module/lua/lstring.c \ + module/lua/lstrlib.c \ + module/lua/ltable.c \ + module/lua/ltablib.c \ + module/lua/ltm.c \ + module/lua/lvm.c \ + module/lua/lzio.c \ + \ + module/os/linux/zfs/abd_os.c \ + module/os/linux/zfs/arc_os.c \ + module/os/linux/zfs/trace.c \ + module/os/linux/zfs/vdev_file.c \ + module/os/linux/zfs/zfs_debug.c \ + module/os/linux/zfs/zfs_racct.c \ + module/os/linux/zfs/zfs_znode.c \ + module/os/linux/zfs/zio_crypt.c \ + \ + module/zcommon/cityhash.c \ + module/zcommon/zfeature_common.c \ + module/zcommon/zfs_comutil.c \ + module/zcommon/zfs_deleg.c \ + module/zcommon/zfs_fletcher.c \ + module/zcommon/zfs_fletcher_aarch64_neon.c \ + module/zcommon/zfs_fletcher_avx512.c \ + module/zcommon/zfs_fletcher_intel.c \ + module/zcommon/zfs_fletcher_sse.c \ + module/zcommon/zfs_fletcher_superscalar.c \ + module/zcommon/zfs_fletcher_superscalar4.c \ + module/zcommon/zfs_namecheck.c \ + module/zcommon/zfs_prop.c \ + module/zcommon/zpool_prop.c \ + module/zcommon/zprop_common.c \ + \ + module/zfs/abd.c \ + module/zfs/aggsum.c \ + module/zfs/arc.c \ + module/zfs/blkptr.c \ + module/zfs/bplist.c \ + module/zfs/bpobj.c \ + module/zfs/bptree.c \ + module/zfs/bqueue.c \ + module/zfs/btree.c \ + module/zfs/dbuf.c \ + module/zfs/dbuf_stats.c \ + module/zfs/ddt.c \ + module/zfs/ddt_zap.c \ + module/zfs/dmu.c \ + module/zfs/dmu_diff.c \ + module/zfs/dmu_object.c \ + module/zfs/dmu_objset.c \ + module/zfs/dmu_recv.c \ + module/zfs/dmu_redact.c \ + module/zfs/dmu_send.c \ + module/zfs/dmu_traverse.c \ + module/zfs/dmu_tx.c \ + module/zfs/dmu_zfetch.c \ + module/zfs/dnode.c \ + module/zfs/dnode_sync.c \ + module/zfs/dsl_bookmark.c \ + module/zfs/dsl_crypt.c \ + module/zfs/dsl_dataset.c \ + module/zfs/dsl_deadlist.c \ + module/zfs/dsl_deleg.c \ + module/zfs/dsl_destroy.c \ + module/zfs/dsl_dir.c \ + module/zfs/dsl_pool.c \ + module/zfs/dsl_prop.c \ + module/zfs/dsl_scan.c \ + module/zfs/dsl_synctask.c \ + module/zfs/dsl_userhold.c \ + module/zfs/edonr_zfs.c \ + module/zfs/fm.c \ + module/zfs/gzip.c \ + module/zfs/hkdf.c \ + module/zfs/lz4.c \ + module/zfs/lz4_zfs.c \ + module/zfs/lzjb.c \ + module/zfs/metaslab.c \ + module/zfs/mmp.c \ + module/zfs/multilist.c \ + module/zfs/objlist.c \ + module/zfs/pathname.c \ + module/zfs/range_tree.c \ + module/zfs/refcount.c \ + module/zfs/rrwlock.c \ + module/zfs/sa.c \ + module/zfs/sha256.c \ + module/zfs/skein_zfs.c \ + module/zfs/spa.c \ + module/zfs/spa_boot.c \ + module/zfs/spa_checkpoint.c \ + module/zfs/spa_config.c \ + module/zfs/spa_errlog.c \ + module/zfs/spa_history.c \ + module/zfs/spa_log_spacemap.c \ + module/zfs/spa_misc.c \ + module/zfs/spa_stats.c \ + module/zfs/space_map.c \ + module/zfs/space_reftree.c \ + module/zfs/txg.c \ + module/zfs/uberblock.c \ + module/zfs/unique.c \ + module/zfs/vdev.c \ + module/zfs/vdev_cache.c \ + module/zfs/vdev_draid.c \ + module/zfs/vdev_draid_rand.c \ + module/zfs/vdev_indirect.c \ + module/zfs/vdev_indirect_births.c \ + module/zfs/vdev_indirect_mapping.c \ + module/zfs/vdev_initialize.c \ + module/zfs/vdev_label.c \ + module/zfs/vdev_mirror.c \ + module/zfs/vdev_missing.c \ + module/zfs/vdev_queue.c \ + module/zfs/vdev_raidz.c \ + module/zfs/vdev_raidz_math.c \ + module/zfs/vdev_raidz_math_aarch64_neon.c \ + module/zfs/vdev_raidz_math_aarch64_neonx2.c \ + module/zfs/vdev_raidz_math_avx2.c \ + module/zfs/vdev_raidz_math_avx512bw.c \ + module/zfs/vdev_raidz_math_avx512f.c \ + module/zfs/vdev_raidz_math_powerpc_altivec.c \ + module/zfs/vdev_raidz_math_scalar.c \ + module/zfs/vdev_raidz_math_sse2.c \ + module/zfs/vdev_raidz_math_ssse3.c \ + module/zfs/vdev_rebuild.c \ + module/zfs/vdev_removal.c \ + module/zfs/vdev_root.c \ + module/zfs/vdev_trim.c \ + module/zfs/zap.c \ + module/zfs/zap_leaf.c \ + module/zfs/zap_micro.c \ + module/zfs/zcp.c \ + module/zfs/zcp_get.c \ + module/zfs/zcp_global.c \ + module/zfs/zcp_iter.c \ + module/zfs/zcp_set.c \ + module/zfs/zcp_synctask.c \ + module/zfs/zfeature.c \ + module/zfs/zfs_byteswap.c \ + module/zfs/zfs_fm.c \ + module/zfs/zfs_fuid.c \ + module/zfs/zfs_ratelimit.c \ + module/zfs/zfs_rlock.c \ + module/zfs/zfs_sa.c \ + module/zfs/zil.c \ + module/zfs/zio.c \ + module/zfs/zio_checksum.c \ + module/zfs/zio_compress.c \ + module/zfs/zio_inject.c \ + module/zfs/zle.c \ + module/zfs/zrlock.c \ + module/zfs/zthr.c libzpool_la_LIBADD = \ - $(abs_top_builddir)/lib/libicp/libicp.la \ - $(abs_top_builddir)/lib/libunicode/libunicode.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la \ - $(abs_top_builddir)/lib/libzstd/libzstd.la \ - $(abs_top_builddir)/lib/libzutil/libzutil.la + libicp.la \ + libunicode.la \ + libnvpair.la \ + libzstd.la \ + libzutil.la libzpool_la_LIBADD += $(LIBCLOCK_GETTIME) $(ZLIB_LIBS) -ldl -lm @@ -231,8 +207,6 @@ endif libzpool_la_LDFLAGS += -version-info 5:0:0 if TARGET_CPU_POWERPC -vdev_raidz_math_powerpc_altivec.$(OBJEXT): CFLAGS += -maltivec -vdev_raidz_math_powerpc_altivec.l$(OBJEXT): CFLAGS += -maltivec +module/zfs/libzpool_la-vdev_raidz_math_powerpc_altivec.$(OBJEXT) : CFLAGS += -maltivec +module/zfs/libzpool_la-vdev_raidz_math_powerpc_altivec.l$(OBJEXT): CFLAGS += -maltivec endif - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/lib/libzpool/kernel.c b/sys/contrib/openzfs/lib/libzpool/kernel.c index 89151f70ecb1..011f9d2110ce 100644 --- a/sys/contrib/openzfs/lib/libzpool/kernel.c +++ b/sys/contrib/openzfs/lib/libzpool/kernel.c @@ -53,7 +53,7 @@ */ uint64_t physmem; -char hw_serial[HW_HOSTID_LEN]; +uint32_t hostid; struct utsname hw_utsname; /* If set, all blocks read will be copied to the specified directory. */ @@ -299,7 +299,7 @@ zone_get_hostid(void *zonep) * We're emulating the system's hostid in userland. */ (void) zonep; - return (strtoul(hw_serial, NULL, 10)); + return (hostid); } int @@ -766,18 +766,6 @@ random_get_pseudo_bytes(uint8_t *ptr, size_t len) return (random_get_bytes_common(ptr, len, urandom_fd)); } -int -ddi_strtoul(const char *hw_serial, char **nptr, int base, unsigned long *result) -{ - (void) nptr; - char *end; - - *result = strtoul(hw_serial, &end, base); - if (*result == 0) - return (errno); - return (0); -} - int ddi_strtoull(const char *str, char **nptr, int base, u_longlong_t *result) { @@ -823,8 +811,7 @@ kernel_init(int mode) dprintf("physmem = %llu pages (%.2f GB)\n", (u_longlong_t)physmem, (double)physmem * sysconf(_SC_PAGE_SIZE) / (1ULL << 30)); - (void) snprintf(hw_serial, sizeof (hw_serial), "%ld", - (mode & SPA_MODE_WRITE) ? get_system_hostid() : 0); + hostid = (mode & SPA_MODE_WRITE) ? get_system_hostid() : 0; random_init(); diff --git a/sys/contrib/openzfs/lib/libzstd/Makefile.am b/sys/contrib/openzfs/lib/libzstd/Makefile.am index 91b7a366c3b2..49bfb328a6f7 100644 --- a/sys/contrib/openzfs/lib/libzstd/Makefile.am +++ b/sys/contrib/openzfs/lib/libzstd/Makefile.am @@ -1,42 +1,32 @@ -include $(top_srcdir)/config/Rules.am - -VPATH = $(top_srcdir)/module/zstd - +libzstd_la_CFLAGS = $(AM_CFLAGS) $(LIBRARY_CFLAGS) # -fno-tree-vectorize is set for gcc in zstd/common/compiler.h # Set it for other compilers, too. -AM_CFLAGS += -fno-tree-vectorize +libzstd_la_CFLAGS += -fno-tree-vectorize -noinst_LTLIBRARIES = libzstd.la +noinst_LTLIBRARIES += libzstd.la -KERNEL_C = lib/common/entropy_common.c \ - lib/common/error_private.c \ - lib/common/fse_decompress.c \ - lib/common/pool.c \ - lib/common/zstd_common.c \ - lib/compress/fse_compress.c \ - lib/compress/hist.c \ - lib/compress/huf_compress.c \ - lib/compress/zstd_compress_literals.c \ - lib/compress/zstd_compress_sequences.c \ - lib/compress/zstd_compress_superblock.c \ - lib/compress/zstd_compress.c \ - lib/compress/zstd_double_fast.c \ - lib/compress/zstd_fast.c \ - lib/compress/zstd_lazy.c \ - lib/compress/zstd_ldm.c \ - lib/compress/zstd_opt.c \ - lib/decompress/huf_decompress.c \ - lib/decompress/zstd_ddict.c \ - lib/decompress/zstd_decompress.c \ - lib/decompress/zstd_decompress_block.c \ - zfs_zstd.c +nodist_libzstd_la_SOURCES = \ + module/zstd/lib/common/entropy_common.c \ + module/zstd/lib/common/error_private.c \ + module/zstd/lib/common/fse_decompress.c \ + module/zstd/lib/common/pool.c \ + module/zstd/lib/common/zstd_common.c \ + module/zstd/lib/compress/fse_compress.c \ + module/zstd/lib/compress/hist.c \ + module/zstd/lib/compress/huf_compress.c \ + module/zstd/lib/compress/zstd_compress_literals.c \ + module/zstd/lib/compress/zstd_compress_sequences.c \ + module/zstd/lib/compress/zstd_compress_superblock.c \ + module/zstd/lib/compress/zstd_compress.c \ + module/zstd/lib/compress/zstd_double_fast.c \ + module/zstd/lib/compress/zstd_fast.c \ + module/zstd/lib/compress/zstd_lazy.c \ + module/zstd/lib/compress/zstd_ldm.c \ + module/zstd/lib/compress/zstd_opt.c \ + module/zstd/lib/decompress/huf_decompress.c \ + module/zstd/lib/decompress/zstd_ddict.c \ + module/zstd/lib/decompress/zstd_decompress.c \ + module/zstd/lib/decompress/zstd_decompress_block.c \ + module/zstd/zfs_zstd.c -nodist_libzstd_la_SOURCES = $(KERNEL_C) - -%.$(OBJEXT): CFLAGS += -fno-tree-vectorize -include $(top_srcdir)/module/zstd/include/zstd_compat_wrapper.h -Wp,-w -%.l$(OBJEXT): CFLAGS += -fno-tree-vectorize -include $(top_srcdir)/module/zstd/include/zstd_compat_wrapper.h -Wp,-w - -zfs_zstd.$(OBJEXT): CFLAGS += -include $(top_srcdir)/module/zstd/include/zstd_compat_wrapper.h -zfs_zstd.l$(OBJEXT): CFLAGS += -include $(top_srcdir)/module/zstd/include/zstd_compat_wrapper.h - -include $(top_srcdir)/config/CppCheck.am +libzstd_la_CFLAGS += -include $(top_srcdir)/module/zstd/include/zstd_compat_wrapper.h -fno-tree-vectorize -Wp,-w $(AM_CFLAGS) diff --git a/sys/contrib/openzfs/lib/libzutil/Makefile.am b/sys/contrib/openzfs/lib/libzutil/Makefile.am index 4f2dbc62bc0f..ecdf940508b2 100644 --- a/sys/contrib/openzfs/lib/libzutil/Makefile.am +++ b/sys/contrib/openzfs/lib/libzutil/Makefile.am @@ -1,45 +1,42 @@ -include $(top_srcdir)/config/Rules.am +libzutil_la_CFLAGS = $(AM_CFLAGS) $(LIBRARY_CFLAGS) +libzutil_la_CFLAGS += $(LIBBLKID_CFLAGS) $(LIBUDEV_CFLAGS) +libzutil_la_CFLAGS += -fvisibility=hidden -AM_CFLAGS += $(LIBBLKID_CFLAGS) $(LIBUDEV_CFLAGS) -AM_CFLAGS += -fvisibility=hidden +libzutil_la_CPPFLAGS = $(AM_CPPFLAGS) +libzutil_la_CPPFLAGS += -I$(srcdir)/%D% -DEFAULT_INCLUDES += -I$(srcdir) +noinst_LTLIBRARIES += libzutil.la +CPPCHECKTARGETS += libzutil.la -noinst_LTLIBRARIES = libzutil.la - -USER_C = \ - zutil_device_path.c \ - zutil_import.c \ - zutil_import.h \ - zutil_nicenum.c \ - zutil_pool.c +libzutil_la_SOURCES = \ + %D%/zutil_device_path.c \ + %D%/zutil_import.c \ + %D%/zutil_import.h \ + %D%/zutil_nicenum.c \ + %D%/zutil_pool.c if BUILD_LINUX -USER_C += \ - os/linux/zutil_device_path_os.c \ - os/linux/zutil_import_os.c +libzutil_la_SOURCES += \ + %D%/os/linux/zutil_device_path_os.c \ + %D%/os/linux/zutil_import_os.c endif if BUILD_FREEBSD -USER_C += \ - os/freebsd/zutil_device_path_os.c \ - os/freebsd/zutil_import_os.c +libzutil_la_SOURCES += \ + %D%/os/freebsd/zutil_device_path_os.c \ + %D%/os/freebsd/zutil_import_os.c endif -libzutil_la_SOURCES = $(USER_C) - libzutil_la_LIBADD = \ - $(abs_top_builddir)/lib/libavl/libavl.la \ - $(abs_top_builddir)/lib/libtpool/libtpool.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la \ - $(abs_top_builddir)/lib/libspl/libspl.la + libavl.la \ + libtpool.la \ + libnvpair.la \ + libspl.la if BUILD_LINUX libzutil_la_LIBADD += \ - $(abs_top_builddir)/lib/libefi/libefi.la \ + libefi.la \ -lrt endif libzutil_la_LIBADD += -lm $(LIBBLKID_LIBS) $(LIBUDEV_LIBS) - -include $(top_srcdir)/config/CppCheck.am diff --git a/sys/contrib/openzfs/lib/libzutil/os/freebsd/zutil_device_path_os.c b/sys/contrib/openzfs/lib/libzutil/os/freebsd/zutil_device_path_os.c index ac4748ec7ac8..f93ab9ad7538 100644 --- a/sys/contrib/openzfs/lib/libzutil/os/freebsd/zutil_device_path_os.c +++ b/sys/contrib/openzfs/lib/libzutil/os/freebsd/zutil_device_path_os.c @@ -40,7 +40,7 @@ * Note: The caller must free the returned string. */ char * -zfs_strip_partition(char *dev) +zfs_strip_partition(const char *dev) { return (strdup(dev)); } @@ -56,8 +56,8 @@ zfs_append_partition(char *path, size_t max_len) * On FreeBSD we only want to remove "/dev/" from the beginning of * paths if present. */ -char * -zfs_strip_path(char *path) +const char * +zfs_strip_path(const char *path) { if (strncmp(path, _PATH_DEV, sizeof (_PATH_DEV) - 1) == 0) return (path + sizeof (_PATH_DEV) - 1); diff --git a/sys/contrib/openzfs/lib/libzutil/os/linux/zutil_device_path_os.c b/sys/contrib/openzfs/lib/libzutil/os/linux/zutil_device_path_os.c index f24696259f23..cfd4bfbf1e2c 100644 --- a/sys/contrib/openzfs/lib/libzutil/os/linux/zutil_device_path_os.c +++ b/sys/contrib/openzfs/lib/libzutil/os/linux/zutil_device_path_os.c @@ -81,7 +81,7 @@ zfs_append_partition(char *path, size_t max_len) * caller must free the returned string */ char * -zfs_strip_partition(char *path) +zfs_strip_partition(const char *path) { char *tmp = strdup(path); char *part = NULL, *d = NULL; @@ -117,7 +117,7 @@ zfs_strip_partition(char *path) * Returned string must be freed. */ static char * -zfs_strip_partition_path(char *path) +zfs_strip_partition_path(const char *path) { char *newpath = strdup(path); char *sd_offset; @@ -148,10 +148,18 @@ zfs_strip_partition_path(char *path) /* * Strip the unwanted portion of a device path. */ -char * -zfs_strip_path(char *path) +const char * +zfs_strip_path(const char *path) { - return (strrchr(path, '/') + 1); + size_t spath_count; + const char *const *spaths = zpool_default_search_paths(&spath_count); + + for (size_t i = 0; i < spath_count; ++i) + if (strncmp(path, spaths[i], strlen(spaths[i])) == 0 && + path[strlen(spaths[i])] == '/') + return (path + strlen(spaths[i]) + 1); + + return (path); } /* diff --git a/sys/contrib/openzfs/lib/libzutil/zutil_pool.c b/sys/contrib/openzfs/lib/libzutil/zutil_pool.c index 734650f3cffc..21dc1f9d9458 100644 --- a/sys/contrib/openzfs/lib/libzutil/zutil_pool.c +++ b/sys/contrib/openzfs/lib/libzutil/zutil_pool.c @@ -120,8 +120,9 @@ zpool_history_unpack(char *buf, uint64_t bytes_read, uint64_t *leftover, break; /* unpack record */ - if (nvlist_unpack(buf + sizeof (reclen), reclen, &nv, 0) != 0) - return (ENOMEM); + int err = nvlist_unpack(buf + sizeof (reclen), reclen, &nv, 0); + if (err != 0) + return (err); bytes_read -= sizeof (reclen) + reclen; buf += sizeof (reclen) + reclen; diff --git a/sys/contrib/openzfs/man/Makefile.am b/sys/contrib/openzfs/man/Makefile.am index 8ab1b757242c..362ee9b7e149 100644 --- a/sys/contrib/openzfs/man/Makefile.am +++ b/sys/contrib/openzfs/man/Makefile.am @@ -1,117 +1,123 @@ -include $(top_srcdir)/config/Substfiles.am - EXTRA_DIST += \ - man1/cstyle.1 + %D%/man1/cstyle.1 dist_man_MANS = \ - man1/zhack.1 \ - man1/ztest.1 \ - man1/raidz_test.1 \ - man1/zvol_wait.1 \ - man1/arcstat.1 \ + %D%/man1/arcstat.1 \ + %D%/man1/raidz_test.1 \ + %D%/man1/test-runner.1 \ + %D%/man1/zhack.1 \ + %D%/man1/ztest.1 \ + %D%/man1/zvol_wait.1 \ \ - man5/vdev_id.conf.5 \ + %D%/man5/vdev_id.conf.5 \ \ - man4/spl.4 \ - man4/zfs.4 \ + %D%/man4/spl.4 \ + %D%/man4/zfs.4 \ \ - man7/zpool-features.7 \ - man7/zfsconcepts.7 \ - man7/zfsprops.7 \ - man7/zpoolconcepts.7 \ - man7/zpoolprops.7 \ + %D%/man7/dracut.zfs.7 \ + %D%/man7/zfsconcepts.7 \ + %D%/man7/zfsprops.7 \ + %D%/man7/zpool-features.7 \ + %D%/man7/zpoolconcepts.7 \ + %D%/man7/zpoolprops.7 \ \ - man8/fsck.zfs.8 \ - man8/mount.zfs.8 \ - man8/vdev_id.8 \ - man8/zdb.8 \ - man8/zfs.8 \ - man8/zfs-allow.8 \ - man8/zfs-bookmark.8 \ - man8/zfs-change-key.8 \ - man8/zfs-clone.8 \ - man8/zfs-create.8 \ - man8/zfs-destroy.8 \ - man8/zfs-diff.8 \ - man8/zfs-get.8 \ - man8/zfs-groupspace.8 \ - man8/zfs-hold.8 \ - man8/zfs-inherit.8 \ - man8/zfs-jail.8 \ - man8/zfs-list.8 \ - man8/zfs-load-key.8 \ - man8/zfs-mount.8 \ - man8/zfs-program.8 \ - man8/zfs-project.8 \ - man8/zfs-projectspace.8 \ - man8/zfs-promote.8 \ - man8/zfs-receive.8 \ - man8/zfs-recv.8 \ - man8/zfs-redact.8 \ - man8/zfs-release.8 \ - man8/zfs-rename.8 \ - man8/zfs-rollback.8 \ - man8/zfs-send.8 \ - man8/zfs-set.8 \ - man8/zfs-share.8 \ - man8/zfs-snapshot.8 \ - man8/zfs-unallow.8 \ - man8/zfs-unjail.8 \ - man8/zfs-unload-key.8 \ - man8/zfs-unmount.8 \ - man8/zfs-upgrade.8 \ - man8/zfs-userspace.8 \ - man8/zfs-wait.8 \ - man8/zfs_ids_to_path.8 \ - man8/zgenhostid.8 \ - man8/zinject.8 \ - man8/zpool.8 \ - man8/zpool-add.8 \ - man8/zpool-attach.8 \ - man8/zpool-checkpoint.8 \ - man8/zpool-clear.8 \ - man8/zpool-create.8 \ - man8/zpool-destroy.8 \ - man8/zpool-detach.8 \ - man8/zpool-events.8 \ - man8/zpool-export.8 \ - man8/zpool-get.8 \ - man8/zpool-history.8 \ - man8/zpool-import.8 \ - man8/zpool-initialize.8 \ - man8/zpool-iostat.8 \ - man8/zpool-labelclear.8 \ - man8/zpool-list.8 \ - man8/zpool-offline.8 \ - man8/zpool-online.8 \ - man8/zpool-reguid.8 \ - man8/zpool-remove.8 \ - man8/zpool-reopen.8 \ - man8/zpool-replace.8 \ - man8/zpool-resilver.8 \ - man8/zpool-scrub.8 \ - man8/zpool-set.8 \ - man8/zpool-split.8 \ - man8/zpool-status.8 \ - man8/zpool-sync.8 \ - man8/zpool-trim.8 \ - man8/zpool-upgrade.8 \ - man8/zpool-wait.8 \ - man8/zstream.8 \ - man8/zstreamdump.8 \ - man8/zpool_influxdb.8 + %D%/man8/fsck.zfs.8 \ + %D%/man8/mount.zfs.8 \ + %D%/man8/vdev_id.8 \ + %D%/man8/zdb.8 \ + %D%/man8/zfs.8 \ + %D%/man8/zfs-allow.8 \ + %D%/man8/zfs-bookmark.8 \ + %D%/man8/zfs-change-key.8 \ + %D%/man8/zfs-clone.8 \ + %D%/man8/zfs-create.8 \ + %D%/man8/zfs-destroy.8 \ + %D%/man8/zfs-diff.8 \ + %D%/man8/zfs-get.8 \ + %D%/man8/zfs-groupspace.8 \ + %D%/man8/zfs-hold.8 \ + %D%/man8/zfs-inherit.8 \ + %D%/man8/zfs-jail.8 \ + %D%/man8/zfs-list.8 \ + %D%/man8/zfs-load-key.8 \ + %D%/man8/zfs-mount.8 \ + %D%/man8/zfs-program.8 \ + %D%/man8/zfs-project.8 \ + %D%/man8/zfs-projectspace.8 \ + %D%/man8/zfs-promote.8 \ + %D%/man8/zfs-receive.8 \ + %D%/man8/zfs-recv.8 \ + %D%/man8/zfs-redact.8 \ + %D%/man8/zfs-release.8 \ + %D%/man8/zfs-rename.8 \ + %D%/man8/zfs-rollback.8 \ + %D%/man8/zfs-send.8 \ + %D%/man8/zfs-set.8 \ + %D%/man8/zfs-share.8 \ + %D%/man8/zfs-snapshot.8 \ + %D%/man8/zfs-unallow.8 \ + %D%/man8/zfs-unjail.8 \ + %D%/man8/zfs-unload-key.8 \ + %D%/man8/zfs-unmount.8 \ + %D%/man8/zfs-upgrade.8 \ + %D%/man8/zfs-userspace.8 \ + %D%/man8/zfs-wait.8 \ + %D%/man8/zfs_ids_to_path.8 \ + %D%/man8/zgenhostid.8 \ + %D%/man8/zinject.8 \ + %D%/man8/zpool.8 \ + %D%/man8/zpool-add.8 \ + %D%/man8/zpool-attach.8 \ + %D%/man8/zpool-checkpoint.8 \ + %D%/man8/zpool-clear.8 \ + %D%/man8/zpool-create.8 \ + %D%/man8/zpool-destroy.8 \ + %D%/man8/zpool-detach.8 \ + %D%/man8/zpool-events.8 \ + %D%/man8/zpool-export.8 \ + %D%/man8/zpool-get.8 \ + %D%/man8/zpool-history.8 \ + %D%/man8/zpool-import.8 \ + %D%/man8/zpool-initialize.8 \ + %D%/man8/zpool-iostat.8 \ + %D%/man8/zpool-labelclear.8 \ + %D%/man8/zpool-list.8 \ + %D%/man8/zpool-offline.8 \ + %D%/man8/zpool-online.8 \ + %D%/man8/zpool-reguid.8 \ + %D%/man8/zpool-remove.8 \ + %D%/man8/zpool-reopen.8 \ + %D%/man8/zpool-replace.8 \ + %D%/man8/zpool-resilver.8 \ + %D%/man8/zpool-scrub.8 \ + %D%/man8/zpool-set.8 \ + %D%/man8/zpool-split.8 \ + %D%/man8/zpool-status.8 \ + %D%/man8/zpool-sync.8 \ + %D%/man8/zpool-trim.8 \ + %D%/man8/zpool-upgrade.8 \ + %D%/man8/zpool-wait.8 \ + %D%/man8/zstream.8 \ + %D%/man8/zstreamdump.8 \ + %D%/man8/zpool_influxdb.8 nodist_man_MANS = \ - man8/zed.8 \ - man8/zfs-mount-generator.8 + %D%/man8/zed.8 \ + %D%/man8/zfs-mount-generator.8 SUBSTFILES += $(nodist_man_MANS) +CHECKS += mancheck +mancheck: + $(top_srcdir)/scripts/mancheck.sh $(srcdir)/%D% + + if BUILD_LINUX # The manual pager in most Linux distros defaults to "BSD" when .Os is blank, # but leaving it blank makes things a lot easier on # FreeBSD when OpenZFS is vendored in the base system. -install-data-hook: - cd $(DESTDIR)$(mandir) && $(SED) ${ac_inplace} -e 's/^\.Os$$/.Os OpenZFS/' $(dist_man_MANS) $(nodist_man_MANS) +INSTALL_DATA_HOOKS += man-install-data-hook +man-install-data-hook: + cd $(DESTDIR)$(mandir) && $(SED) $(ac_inplace) 's/^\.Os$$/.Os OpenZFS/' $(subst %D%/,,$(dist_man_MANS) $(nodist_man_MANS)) endif diff --git a/sys/contrib/openzfs/man/man1/cstyle.1 b/sys/contrib/openzfs/man/man1/cstyle.1 index f5f9ec78f827..e8f30f1f5950 100644 --- a/sys/contrib/openzfs/man/man1/cstyle.1 +++ b/sys/contrib/openzfs/man/man1/cstyle.1 @@ -30,7 +30,6 @@ .Sh SYNOPSIS .Nm .Op Fl chpvCP -.Op Fl o Ar construct Ns Op , Ns Ar construct Ns … .Oo Ar file Oc Ns … .Sh DESCRIPTION .Nm @@ -45,7 +44,6 @@ does not mean that you've followed Sun's C style. .Em Caveat emptor . . .Sh OPTIONS -The following options are supported: .Bl -tag -width "-c" .It Fl c Check continuation line indentation inside of functions. @@ -59,9 +57,6 @@ continuation line problems within functions only. The checks have some limitations; see .Sy CONTINUATION CHECKING , below. -.It Fl h -Performs heuristic checks that are sometimes wrong. -Not generally used. .It Fl p Performs some of the more picky checks. Includes ANSI @@ -74,10 +69,6 @@ Used as part of the putback checks. Verbose output; includes the text of the line of error, and, for .Fl c , the first statement in the current continuation block. -.It Fl C -Ignore errors in header comments (i.e. block comments starting in the -first column). -Not generally used. .It Fl P Check for use of non-POSIX types. Historically, types like @@ -91,16 +82,17 @@ types etc. This detects any use of the deprecated types. Used as part of the putback checks. -.It Fl o Ar construct Ns Op , Ns Ar construct Ns … -Available constructs include: -.Bl -tag -compact -width "doxygen" -.It Sy doxygen -Allow doxygen-style block comments -.Pq Sy /** No and Sy /*!\& . -.It Sy splint -Allow splint-style lint comments -.Pq Sy /*@ Ns ... Ns Sy @*/ . +.It Fl g +Also print GitHub-Actions-style +.Li ::error +output. .El +. +.Sh ENVIRONMENT +.Bl -tag -compact -width ".Ev CI" +.It Ev CI +If set and nonempty, equivalent to +.Fl g . .El . .Sh CONTINUATION CHECKING diff --git a/sys/contrib/openzfs/tests/test-runner/man/test-runner.1 b/sys/contrib/openzfs/man/man1/test-runner.1 similarity index 100% rename from sys/contrib/openzfs/tests/test-runner/man/test-runner.1 rename to sys/contrib/openzfs/man/man1/test-runner.1 diff --git a/sys/contrib/openzfs/man/man1/ztest.1 b/sys/contrib/openzfs/man/man1/ztest.1 index fd1374a2f106..9e44eb4579f9 100644 --- a/sys/contrib/openzfs/man/man1/ztest.1 +++ b/sys/contrib/openzfs/man/man1/ztest.1 @@ -157,7 +157,17 @@ Time per pass. Max loops in .Fn spa_freeze . .It Fl B , -alt-ztest Ns = -Alternate ztest path. +Path to alternate ("older") +.Nm ztest +to drive, which will be used to initialise the pool, and, a stochastic half the time, to run the tests. +The parallel +.Pa lib +directory is prepended to +.Ev LD_LIBRARY_PATH ; +i.e. given +.Fl B Pa ./chroots/lenny/usr/bin/ Ns Nm , +.Pa ./chroots/lenny/usr/lib +will be loaded. .It Fl C , -vdev-class-state Ns = Ns Sy on Ns | Ns Sy off Ns | Ns Sy random No (default: Sy random ) The vdev allocation class state. .It Fl o , -option Ns = Ns Ar variable Ns = Ns Ar value diff --git a/sys/contrib/openzfs/man/man4/zfs.4 b/sys/contrib/openzfs/man/man4/zfs.4 index 01e9c5de445d..5ef517c46faa 100644 --- a/sys/contrib/openzfs/man/man4/zfs.4 +++ b/sys/contrib/openzfs/man/man4/zfs.4 @@ -70,7 +70,7 @@ to a log2 fraction of the target ARC size. dnode slots allocated in a single operation as a power of 2. The default value minimizes lock contention for the bulk operation performed. . -.It Sy dmu_prefetch_max Ns = Ns Sy 134217728 Ns B Po 128MB Pc Pq int +.It Sy dmu_prefetch_max Ns = Ns Sy 134217728 Ns B Po 128 MiB Pc Pq int Limit the amount we can prefetch with one call to this amount in bytes. This helps to limit the amount of memory that can be used by prefetching. . @@ -164,7 +164,7 @@ If set to .Sy 100 we TRIM twice the space required to accommodate upcoming writes. A minimum of -.Sy 64MB +.Sy 64 MiB will be trimmed. It also enables TRIM of the whole L2ARC device upon creation or addition to an existing pool or if the header of the device is @@ -194,12 +194,12 @@ to enable caching/reading prefetches to/from L2ARC. .It Sy l2arc_norw Ns = Ns Sy 0 Ns | Ns 1 Pq int No reads during writes. . -.It Sy l2arc_write_boost Ns = Ns Sy 8388608 Ns B Po 8MB Pc Pq ulong +.It Sy l2arc_write_boost Ns = Ns Sy 8388608 Ns B Po 8 MiB Pc Pq ulong Cold L2ARC devices will have .Sy l2arc_write_max increased by this amount while they remain cold. . -.It Sy l2arc_write_max Ns = Ns Sy 8388608 Ns B Po 8MB Pc Pq ulong +.It Sy l2arc_write_max Ns = Ns Sy 8388608 Ns B Po 8 MiB Pc Pq ulong Max write bytes per interval. . .It Sy l2arc_rebuild_enabled Ns = Ns Sy 1 Ns | Ns 0 Pq int @@ -209,35 +209,35 @@ or attaching an L2ARC device (e.g. the L2ARC device is slow in reading stored log metadata, or the metadata has become somehow fragmented/unusable). . -.It Sy l2arc_rebuild_blocks_min_l2size Ns = Ns Sy 1073741824 Ns B Po 1GB Pc Pq ulong +.It Sy l2arc_rebuild_blocks_min_l2size Ns = Ns Sy 1073741824 Ns B Po 1 GiB Pc Pq ulong Mininum size of an L2ARC device required in order to write log blocks in it. The log blocks are used upon importing the pool to rebuild the persistent L2ARC. .Pp -For L2ARC devices less than 1GB, the amount of data +For L2ARC devices less than 1 GiB, the amount of data .Fn l2arc_evict evicts is significant compared to the amount of restored L2ARC data. In this case, do not write log blocks in L2ARC in order not to waste space. . -.It Sy metaslab_aliquot Ns = Ns Sy 524288 Ns B Po 512kB Pc Pq ulong +.It Sy metaslab_aliquot Ns = Ns Sy 1048576 Ns B Po 1 MiB Pc Pq ulong Metaslab granularity, in bytes. This is roughly similar to what would be referred to as the "stripe size" in traditional RAID arrays. -In normal operation, ZFS will try to write this amount of data -to a top-level vdev before moving on to the next one. +In normal operation, ZFS will try to write this amount of data to each disk +before moving on to the next top-level vdev. . .It Sy metaslab_bias_enabled Ns = Ns Sy 1 Ns | Ns 0 Pq int Enable metaslab group biasing based on their vdevs' over- or under-utilization relative to the pool. . -.It Sy metaslab_force_ganging Ns = Ns Sy 16777217 Ns B Ns B Po 16MB + 1B Pc Pq ulong +.It Sy metaslab_force_ganging Ns = Ns Sy 16777217 Ns B Po 16 MiB + 1 B Pc Pq ulong Make some blocks above a certain size be gang blocks. This option is used by the test suite to facilitate testing. . -.It Sy zfs_history_output_max Ns = Ns Sy 1048576 Ns B Ns B Po 1MB Pc Pq int +.It Sy zfs_history_output_max Ns = Ns Sy 1048576 Ns B Po 1 MiB Pc Pq int When attempting to log an output nvlist of an ioctl in the on-disk history, the output will not be stored if it is larger than this size (in bytes). This must be less than -.Sy DMU_MAX_ACCESS Pq 64MB . +.Sy DMU_MAX_ACCESS Pq 64 MiB . This applies primarily to .Fn zfs_ioc_channel_program Pq cf. Xr zfs-program 8 . . @@ -261,7 +261,7 @@ Prevent metaslabs from being unloaded. .It Sy metaslab_fragmentation_factor_enabled Ns = Ns Sy 1 Ns | Ns 0 Pq int Enable use of the fragmentation metric in computing metaslab weights. . -.It Sy metaslab_df_max_search Ns = Ns Sy 16777216 Ns B Po 16MB Pc Pq int +.It Sy metaslab_df_max_search Ns = Ns Sy 16777216 Ns B Po 16 MiB Pc Pq int Maximum distance to search forward from the last offset. Without this limit, fragmented pools can see .Em >100`000 @@ -270,7 +270,7 @@ iterations and becomes the performance limiting factor on high-performance storage. .Pp With the default setting of -.Sy 16MB , +.Sy 16 MiB , we typically see less than .Em 500 iterations, even with very fragmented @@ -279,7 +279,7 @@ pools. The maximum number of iterations possible is .Sy metaslab_df_max_search / 2^(ashift+1) . With the default setting of -.Sy 16MB +.Sy 16 MiB this is .Em 16*1024 Pq with Sy ashift Ns = Ns Sy 9 or @@ -293,7 +293,7 @@ this tunable controls which segment is used. If set, we will use the largest free segment. If unset, we will use a segment of at least the requested size. . -.It Sy zfs_metaslab_max_size_cache_sec Ns = Ns Sy 3600 Ns s Po 1h Pc Pq ulong +.It Sy zfs_metaslab_max_size_cache_sec Ns = Ns Sy 3600 Ns s Po 1 hour Pc Pq ulong When we unload a metaslab, we cache the size of the largest free chunk. We use that cached size to determine whether or not to load a metaslab for a given allocation. @@ -344,7 +344,7 @@ and the allocation can't actually be satisfied .It Sy zfs_vdev_default_ms_count Ns = Ns Sy 200 Pq int When a vdev is added, target this number of metaslabs per top-level vdev. . -.It Sy zfs_vdev_default_ms_shift Ns = Ns Sy 29 Po 512MB Pc Pq int +.It Sy zfs_vdev_default_ms_shift Ns = Ns Sy 29 Po 512 MiB Pc Pq int Default limit for metaslab size. . .It Sy zfs_vdev_max_auto_ashift Ns = Ns Sy ASHIFT_MAX Po 16 Pc Pq ulong @@ -380,7 +380,7 @@ Note that both this many TXGs and .Sy metaslab_unload_delay_ms milliseconds must pass before unloading will occur. . -.It Sy metaslab_unload_delay_ms Ns = Ns Sy 600000 Ns ms Po 10min Pc Pq int +.It Sy metaslab_unload_delay_ms Ns = Ns Sy 600000 Ns ms Po 10 min Pc Pq int After a metaslab is used, we keep it loaded for this many milliseconds, to attempt to reduce unnecessary reloading. Note, that both this many milliseconds and @@ -454,7 +454,14 @@ If we have less than this amount of free space, most ZPL operations (e.g. write, create) will return .Sy ENOSPC . . -.It Sy vdev_removal_max_span Ns = Ns Sy 32768 Ns B Po 32kB Pc Pq int +.It Sy spa_upgrade_errlog_limit Ns = Ns Sy 0 Pq uint +Limits the number of on-disk error log entries that will be converted to the +new format when enabling the +.Sy head_errlog +feature. +The default is to convert all log entries. +. +.It Sy vdev_removal_max_span Ns = Ns Sy 32768 Ns B Po 32 KiB Pc Pq int During top-level vdev removal, chunks of data are copied from the vdev which may include free space in order to trade bandwidth for IOPS. This parameter determines the maximum span of free space, in bytes, @@ -465,10 +472,10 @@ The default value here was chosen to align with which is a similar concept when doing regular reads (but there's no reason it has to be the same). . -.It Sy vdev_file_logical_ashift Ns = Ns Sy 9 Po 512B Pc Pq ulong +.It Sy vdev_file_logical_ashift Ns = Ns Sy 9 Po 512 B Pc Pq ulong Logical ashift for file-based devices. . -.It Sy vdev_file_physical_ashift Ns = Ns Sy 9 Po 512B Pc Pq ulong +.It Sy vdev_file_physical_ashift Ns = Ns Sy 9 Po 512 B Pc Pq ulong Physical ashift for file-based devices. . .It Sy zap_iterate_prefetch Ns = Ns Sy 1 Ns | Ns 0 Pq int @@ -477,13 +484,13 @@ prefetch the entire object (all leaf blocks). However, this is limited by .Sy dmu_prefetch_max . . -.It Sy zfetch_array_rd_sz Ns = Ns Sy 1048576 Ns B Po 1MB Pc Pq ulong +.It Sy zfetch_array_rd_sz Ns = Ns Sy 1048576 Ns B Po 1 MiB Pc Pq ulong If prefetching is enabled, disable prefetching for reads larger than this size. . -.It Sy zfetch_max_distance Ns = Ns Sy 8388608 Ns B Po 8MB Pc Pq uint +.It Sy zfetch_max_distance Ns = Ns Sy 8388608 Ns B Po 8 MiB Pc Pq uint Max bytes to prefetch per stream. . -.It Sy zfetch_max_idistance Ns = Ns Sy 67108864 Ns B Po 64MB Pc Pq uint +.It Sy zfetch_max_idistance Ns = Ns Sy 67108864 Ns B Po 64 MiB Pc Pq uint Max bytes to prefetch indirects for per stream. . .It Sy zfetch_max_streams Ns = Ns Sy 8 Pq uint @@ -506,7 +513,7 @@ The value of .Sy MAX_ORDER depends on kernel configuration. . -.It Sy zfs_abd_scatter_min_size Ns = Ns Sy 1536 Ns B Po 1.5kB Pc Pq uint +.It Sy zfs_abd_scatter_min_size Ns = Ns Sy 1536 Ns B Po 1.5 KiB Pc Pq uint This is the minimum allocation size that will use scatter (page-based) ABDs. Smaller allocations will use linear ABDs. . @@ -538,10 +545,10 @@ Percentage of ARC dnodes to try to scan in response to demand for non-metadata when the number of bytes consumed by dnodes exceeds .Sy zfs_arc_dnode_limit . . -.It Sy zfs_arc_average_blocksize Ns = Ns Sy 8192 Ns B Po 8kB Pc Pq int +.It Sy zfs_arc_average_blocksize Ns = Ns Sy 8192 Ns B Po 8 KiB Pc Pq int The ARC's buffer hash table is sized based on the assumption of an average block size of this value. -This works out to roughly 1MB of hash table per 1GB of physical memory +This works out to roughly 1 MiB of hash table per 1 GiB of physical memory with 8-byte pointers. For configurations with a known larger average block size, this value can be increased to reduce the memory footprint. @@ -552,9 +559,9 @@ When .Fn arc_get_data_impl waits for this percent of the requested amount of data to be evicted. For example, by default, for every -.Em 2kB +.Em 2 KiB that's evicted, -.Em 1kB +.Em 1 KiB of it may be "reused" by a new allocation. Since this is above .Sy 100 Ns % , @@ -595,12 +602,12 @@ Under Linux, half of system memory will be used as the limit. Under .Fx , the larger of -.Sy all_system_memory No \- Sy 1GB +.Sy all_system_memory No \- Sy 1 GiB and .Sy 5/8 No \(mu Sy all_system_memory will be used as the limit. This value must be at least -.Sy 67108864 Ns B Pq 64MB . +.Sy 67108864 Ns B Pq 64 MiB . .Pp This value can be changed dynamically, with some caveats. It cannot be set back to @@ -668,7 +675,7 @@ to evict the required number of metadata buffers. Min size of ARC in bytes. .No If set to Sy 0 , arc_c_min will default to consuming the larger of -.Sy 32MB +.Sy 32 MiB and .Sy all_system_memory No / Sy 32 . . @@ -709,7 +716,7 @@ If equivalent to a quarter of the user-wired memory limit under .Fx and to -.Sy 134217728 Ns B Pq 128MB +.Sy 134217728 Ns B Pq 128 MiB under Linux. . .It Sy zfs_multilist_num_sublists Ns = Ns Sy 0 Pq int @@ -787,10 +794,10 @@ Note that in practice, the kernel's shrinker can ask us to evict up to about four times this for one allocation attempt. .Pp The default limit of -.Sy 10000 Pq in practice, Em 160MB No per allocation attempt with 4kB pages +.Sy 10000 Pq in practice, Em 160 MiB No per allocation attempt with 4 KiB pages limits the amount of time spent attempting to reclaim ARC memory to -less than 100ms per allocation attempt, -even with a small average compressed block size of ~8kB. +less than 100 ms per allocation attempt, +even with a small average compressed block size of ~8 KiB. .Pp The parameter can be set to 0 (zero) to disable the limit, and only applies on Linux. @@ -798,7 +805,7 @@ and only applies on Linux. .It Sy zfs_arc_sys_free Ns = Ns Sy 0 Ns B Pq ulong The target number of bytes the ARC should leave as free memory on the system. If zero, equivalent to the bigger of -.Sy 512kB No and Sy all_system_memory/64 . +.Sy 512 KiB No and Sy all_system_memory/64 . . .It Sy zfs_autoimport_disable Ns = Ns Sy 1 Ns | Ns 0 Pq int Disable pool import at module load by ignoring the cache file @@ -839,12 +846,12 @@ bytes of memory and if the obsolete space map object uses more than bytes on-disk. The condensing process is an attempt to save memory by removing obsolete mappings. . -.It Sy zfs_condense_max_obsolete_bytes Ns = Ns Sy 1073741824 Ns B Po 1GB Pc Pq ulong +.It Sy zfs_condense_max_obsolete_bytes Ns = Ns Sy 1073741824 Ns B Po 1 GiB Pc Pq ulong Only attempt to condense indirect vdev mappings if the on-disk size of the obsolete space map object is greater than this number of bytes .Pq see Sy zfs_condense_indirect_vdevs_enable . . -.It Sy zfs_condense_min_mapping_bytes Ns = Ns Sy 131072 Ns B Po 128kB Pc Pq ulong +.It Sy zfs_condense_min_mapping_bytes Ns = Ns Sy 131072 Ns B Po 128 KiB Pc Pq ulong Minimum size vdev mapping to attempt to condense .Pq see Sy zfs_condense_indirect_vdevs_enable . . @@ -860,7 +867,7 @@ to the file clears the log. This setting does not influence debug prints due to .Sy zfs_flags . . -.It Sy zfs_dbgmsg_maxsize Ns = Ns Sy 4194304 Ns B Po 4MB Pc Pq int +.It Sy zfs_dbgmsg_maxsize Ns = Ns Sy 4194304 Ns B Po 4 MiB Pc Pq int Maximum size of the internal ZFS debug log. . .It Sy zfs_dbuf_state_index Ns = Ns Sy 0 Pq int @@ -900,21 +907,21 @@ This can be used to facilitate automatic fail-over to a properly configured fail-over partner. .El . -.It Sy zfs_deadman_checktime_ms Ns = Ns Sy 60000 Ns ms Po 1min Pc Pq int +.It Sy zfs_deadman_checktime_ms Ns = Ns Sy 60000 Ns ms Po 1 min Pc Pq int Check time in milliseconds. This defines the frequency at which we check for hung I/O requests and potentially invoke the .Sy zfs_deadman_failmode behavior. . -.It Sy zfs_deadman_synctime_ms Ns = Ns Sy 600000 Ns ms Po 10min Pc Pq ulong +.It Sy zfs_deadman_synctime_ms Ns = Ns Sy 600000 Ns ms Po 10 min Pc Pq ulong Interval in milliseconds after which the deadman is triggered and also the interval after which a pool sync operation is considered to be "hung". Once this limit is exceeded the deadman will be invoked every .Sy zfs_deadman_checktime_ms milliseconds until the pool sync completes. . -.It Sy zfs_deadman_ziotime_ms Ns = Ns Sy 300000 Ns ms Po 5min Pc Pq ulong +.It Sy zfs_deadman_ziotime_ms Ns = Ns Sy 300000 Ns ms Po 5 min Pc Pq ulong Interval in milliseconds after which the deadman is triggered and an individual I/O operation is considered to be "hung". As long as the operation remains "hung", @@ -967,7 +974,7 @@ same object. Rate limit delay and deadman zevents (which report slow I/O operations) to this many per second. . -.It Sy zfs_unflushed_max_mem_amt Ns = Ns Sy 1073741824 Ns B Po 1GB Pc Pq ulong +.It Sy zfs_unflushed_max_mem_amt Ns = Ns Sy 1073741824 Ns B Po 1 GiB Pc Pq ulong Upper-bound limit for unflushed metadata changes to be held by the log spacemap in memory, in bytes. . @@ -975,16 +982,16 @@ log spacemap in memory, in bytes. Part of overall system memory that ZFS allows to be used for unflushed metadata changes by the log spacemap, in millionths. . -.It Sy zfs_unflushed_log_block_max Ns = Ns Sy 262144 Po 256k Pc Pq ulong +.It Sy zfs_unflushed_log_block_max Ns = Ns Sy 131072 Po 128k Pc Pq ulong Describes the maximum number of log spacemap blocks allowed for each pool. The default value means that the space in all the log spacemaps can add up to no more than -.Sy 262144 +.Sy 131072 blocks (which means -.Em 32GB +.Em 16 GiB of logical space before compression and ditto blocks, assuming that blocksize is -.Em 128kB ) . +.Em 128 KiB ) . .Pp This tunable is important because it involves a trade-off between import time after an unclean export and the frequency of flushing metaslabs. @@ -1011,7 +1018,12 @@ Thus we always allow at least this many log blocks. .It Sy zfs_unflushed_log_block_pct Ns = Ns Sy 400 Ns % Pq ulong Tunable used to determine the number of blocks that can be used for the spacemap log, expressed as a percentage of the total number of -metaslabs in the pool. +unflushed metaslabs in the pool. +. +.It Sy zfs_unflushed_log_txg_max Ns = Ns Sy 1000 Pq ulong +Tunable limiting maximum time in TXGs any metaslab may remain unflushed. +It effectively limits maximum number of unflushed per-TXG spacemap logs +that need to be read after unclean pool export. . .It Sy zfs_unlink_suspend_progress Ns = Ns Sy 0 Ns | Ns 1 Pq uint When enabled, files will not be asynchronously removed from the list of pending @@ -1383,7 +1395,7 @@ Similar to .Sy zfs_free_min_time_ms , but for cleanup of old indirection records for removed vdevs. . -.It Sy zfs_immediate_write_sz Ns = Ns Sy 32768 Ns B Po 32kB Pc Pq long +.It Sy zfs_immediate_write_sz Ns = Ns Sy 32768 Ns B Po 32 KiB Pc Pq long Largest data block to write to the ZIL. Larger blocks will be treated as if the dataset being written to had the .Sy logbias Ns = Ns Sy throughput @@ -1393,7 +1405,7 @@ property set. Pattern written to vdev free space by .Xr zpool-initialize 8 . . -.It Sy zfs_initialize_chunk_size Ns = Ns Sy 1048576 Ns B Po 1MB Pc Pq ulong +.It Sy zfs_initialize_chunk_size Ns = Ns Sy 1048576 Ns B Po 1 MiB Pc Pq ulong Size of writes used by .Xr zpool-initialize 8 . This option is used by the test suite. @@ -1441,7 +1453,7 @@ This option is used by the test suite to trigger race conditions. The maximum execution time limit that can be set for a ZFS channel program, specified as a number of Lua instructions. . -.It Sy zfs_lua_max_memlimit Ns = Ns Sy 104857600 Po 100MB Pc Pq ulong +.It Sy zfs_lua_max_memlimit Ns = Ns Sy 104857600 Po 100 MiB Pc Pq ulong The maximum memory limit that can be set for a ZFS channel program, specified in bytes. . @@ -1457,15 +1469,15 @@ feature uses to estimate incoming log blocks. .It Sy zfs_max_logsm_summary_length Ns = Ns Sy 10 Pq ulong Maximum number of rows allowed in the summary of the spacemap log. . -.It Sy zfs_max_recordsize Ns = Ns Sy 1048576 Po 1MB Pc Pq int +.It Sy zfs_max_recordsize Ns = Ns Sy 16777216 Po 16 MiB Pc Pq int We currently support block sizes from -.Em 512B No to Em 16MB . +.Em 512 Po 512 B Pc No to Em 16777216 Po 16 MiB Pc . The benefits of larger blocks, and thus larger I/O, need to be weighed against the cost of COWing a giant block to modify one byte. Additionally, very large blocks can have an impact on I/O latency, and also potentially on the memory allocator. -Therefore, we do not allow the recordsize to be set larger than this tunable. -Larger blocks can be created by changing it, +Therefore, we formerly forbade creating blocks larger than 1M. +Larger blocks could be created by changing it, and pools with larger blocks can always be imported and used, regardless of this setting. . @@ -1523,7 +1535,7 @@ into the special allocation class. Historical statistics for this many latest multihost updates will be available in .Pa /proc/spl/kstat/zfs/ Ns Ao Ar pool Ac Ns Pa /multihost . . -.It Sy zfs_multihost_interval Ns = Ns Sy 1000 Ns ms Po 1s Pc Pq ulong +.It Sy zfs_multihost_interval Ns = Ns Sy 1000 Ns ms Po 1 s Pc Pq ulong Used to control the frequency of multihost writes which are performed when the .Sy multihost pool property is on. @@ -1556,7 +1568,7 @@ delay found in the best uberblock indicates actual multihost updates happened at longer intervals than .Sy zfs_multihost_interval . A minimum of -.Em 100ms +.Em 100 ms is enforced. .Pp .Sy 0 No is equivalent to Sy 1 . @@ -1605,7 +1617,7 @@ When enabled forces ZFS to sync data when flags are used allowing holes in a file to be accurately reported. When disabled holes will not be reported in recently dirtied files. . -.It Sy zfs_pd_bytes_max Ns = Ns Sy 52428800 Ns B Po 50MB Pc Pq int +.It Sy zfs_pd_bytes_max Ns = Ns Sy 52428800 Ns B Po 50 MiB Pc Pq int The number of bytes which should be prefetched during a pool traversal, like .Nm zfs Cm send or other data crawling operations. @@ -1644,7 +1656,7 @@ Disable QAT hardware acceleration for AES-GCM encryption. May be unset after the ZFS modules have been loaded to initialize the QAT hardware as long as support is compiled in and the QAT driver is present. . -.It Sy zfs_vnops_read_chunk_size Ns = Ns Sy 1048576 Ns B Po 1MB Pc Pq long +.It Sy zfs_vnops_read_chunk_size Ns = Ns Sy 1048576 Ns B Po 1 MiB Pc Pq long Bytes to read per chunk. . .It Sy zfs_read_history Ns = Ns Sy 0 Pq int @@ -1654,7 +1666,7 @@ Historical statistics for this many latest reads will be available in .It Sy zfs_read_history_hits Ns = Ns Sy 0 Ns | Ns 1 Pq int Include cache hits in read history . -.It Sy zfs_rebuild_max_segment Ns = Ns Sy 1048576 Ns B Po 1MB Pc Pq ulong +.It Sy zfs_rebuild_max_segment Ns = Ns Sy 1048576 Ns B Po 1 MiB Pc Pq ulong Maximum read segment size to issue when sequentially resilvering a top-level vdev. . @@ -1664,7 +1676,7 @@ completes in order to verify the checksums of all blocks which have been resilvered. This is enabled by default and strongly recommended. . -.It Sy zfs_rebuild_vdev_limit Ns = Ns Sy 33554432 Ns B Po 32MB Pc Pq ulong +.It Sy zfs_rebuild_vdev_limit Ns = Ns Sy 33554432 Ns B Po 32 MiB Pc Pq ulong Maximum amount of I/O that can be concurrently issued for a sequential resilver per leaf device, given in bytes. . @@ -1696,7 +1708,7 @@ pool cannot be returned to a healthy state prior to removing the device. This is used by the test suite so that it can ensure that certain actions happen while in the middle of a removal. . -.It Sy zfs_remove_max_segment Ns = Ns Sy 16777216 Ns B Po 16MB Pc Pq int +.It Sy zfs_remove_max_segment Ns = Ns Sy 16777216 Ns B Po 16 MiB Pc Pq int The largest contiguous segment that we will attempt to allocate when removing a device. If there is a performance problem with attempting to allocate large blocks, @@ -1709,7 +1721,7 @@ Ignore the feature, causing an operation that would start a resilver to immediately restart the one in progress. . -.It Sy zfs_resilver_min_time_ms Ns = Ns Sy 3000 Ns ms Po 3s Pc Pq int +.It Sy zfs_resilver_min_time_ms Ns = Ns Sy 3000 Ns ms Po 3 s Pc Pq int Resilvers are processed by the sync thread. While resilvering, it will spend at least this much time working on a resilver between TXG flushes. @@ -1720,12 +1732,12 @@ even if there were unrepairable errors. Intended to be used during pool repair or recovery to stop resilvering when the pool is next imported. . -.It Sy zfs_scrub_min_time_ms Ns = Ns Sy 1000 Ns ms Po 1s Pc Pq int +.It Sy zfs_scrub_min_time_ms Ns = Ns Sy 1000 Ns ms Po 1 s Pc Pq int Scrubs are processed by the sync thread. While scrubbing, it will spend at least this much time working on a scrub between TXG flushes. . -.It Sy zfs_scan_checkpoint_intval Ns = Ns Sy 7200 Ns s Po 2h Pc Pq int +.It Sy zfs_scan_checkpoint_intval Ns = Ns Sy 7200 Ns s Po 2 hour Pc Pq int To preserve progress across reboots, the sequential scan algorithm periodically needs to stop metadata scanning and issue all the verification I/O to disk. The frequency of this flushing is determined by this tunable. @@ -1762,7 +1774,7 @@ Otherwise indicates that the legacy algorithm will be used, where I/O is initiated as soon as it is discovered. Unsetting will not affect scrubs or resilvers that are already in progress. . -.It Sy zfs_scan_max_ext_gap Ns = Ns Sy 2097152 Ns B Po 2MB Pc Pq int +.It Sy zfs_scan_max_ext_gap Ns = Ns Sy 2097152 Ns B Po 2 MiB Pc Pq int Sets the largest gap in bytes between scrub/resilver I/O operations that will still be considered sequential for sorting purposes. Changing this value will not @@ -1791,7 +1803,7 @@ When disabled, the memory limit may be exceeded by fast disks. Freezes a scrub/resilver in progress without actually pausing it. Intended for testing/debugging. . -.It Sy zfs_scan_vdev_limit Ns = Ns Sy 4194304 Ns B Po 4MB Pc Pq int +.It Sy zfs_scan_vdev_limit Ns = Ns Sy 4194304 Ns B Po 4 MiB Pc Pq int Maximum amount of data that can be concurrently issued at once for scrubs and resilvers per leaf device, given in bytes. . @@ -1811,7 +1823,7 @@ The fill fraction of the internal queues. The fill fraction controls the timing with which internal threads are woken up. . -.It Sy zfs_send_no_prefetch_queue_length Ns = Ns Sy 1048576 Ns B Po 1MB Pc Pq int +.It Sy zfs_send_no_prefetch_queue_length Ns = Ns Sy 1048576 Ns B Po 1 MiB Pc Pq int The maximum number of bytes allowed in .Nm zfs Cm send Ns 's internal queues. @@ -1822,7 +1834,7 @@ The fill fraction of the prefetch queue. The fill fraction controls the timing with which internal threads are woken up. . -.It Sy zfs_send_queue_length Ns = Ns Sy 16777216 Ns B Po 16MB Pc Pq int +.It Sy zfs_send_queue_length Ns = Ns Sy 16777216 Ns B Po 16 MiB Pc Pq int The maximum number of bytes allowed that will be prefetched by .Nm zfs Cm send . This value must be at least twice the maximum block size in use. @@ -1833,20 +1845,20 @@ The fill fraction of the queue. The fill fraction controls the timing with which internal threads are woken up. . -.It Sy zfs_recv_queue_length Ns = Ns Sy 16777216 Ns B Po 16MB Pc Pq int +.It Sy zfs_recv_queue_length Ns = Ns Sy 16777216 Ns B Po 16 MiB Pc Pq int The maximum number of bytes allowed in the .Nm zfs Cm receive queue. This value must be at least twice the maximum block size in use. . -.It Sy zfs_recv_write_batch_size Ns = Ns Sy 1048576 Ns B Po 1MB Pc Pq int +.It Sy zfs_recv_write_batch_size Ns = Ns Sy 1048576 Ns B Po 1 MiB Pc Pq int The maximum amount of data, in bytes, that .Nm zfs Cm receive will write in one DMU transaction. This is the uncompressed size, even when receiving a compressed send stream. This setting will not reduce the write size below a single block. Capped at a maximum of -.Sy 32MB . +.Sy 32 MiB . . .It Sy zfs_override_estimate_recordsize Ns = Ns Sy 0 Ns | Ns 1 Pq ulong Setting this variable overrides the default logic for estimating block @@ -1861,7 +1873,7 @@ and you require accurate zfs send size estimates. Flushing of data to disk is done in passes. Defer frees starting in this pass. . -.It Sy zfs_spa_discard_memory_limit Ns = Ns Sy 16777216 Ns B Po 16MB Pc Pq int +.It Sy zfs_spa_discard_memory_limit Ns = Ns Sy 16777216 Ns B Po 16 MiB Pc Pq int Maximum memory used for prefetching a checkpoint's space map on each vdev while discarding the checkpoint. . @@ -1883,11 +1895,11 @@ the average number of sync passes; because when we turn compression off, many blocks' size will change, and thus we have to re-allocate (not overwrite) them. It also increases the number of -.Em 128kB +.Em 128 KiB allocations (e.g. for indirect blocks and spacemaps) because these will not be compressed. The -.Em 128kB +.Em 128 KiB allocations are especially detrimental to performance on highly fragmented systems, which may have very few free segments of this size, and may need to load new metaslabs to satisfy these allocations. @@ -1902,11 +1914,11 @@ The default value of .Sy 75% will create a maximum of one thread per CPU. . -.It Sy zfs_trim_extent_bytes_max Ns = Ns Sy 134217728 Ns B Po 128MB Pc Pq uint +.It Sy zfs_trim_extent_bytes_max Ns = Ns Sy 134217728 Ns B Po 128 MiB Pc Pq uint Maximum size of TRIM command. Larger ranges will be split into chunks no larger than this value before issuing. . -.It Sy zfs_trim_extent_bytes_min Ns = Ns Sy 32768 Ns B Po 32kB Pc Pq uint +.It Sy zfs_trim_extent_bytes_min Ns = Ns Sy 32768 Ns B Po 32 KiB Pc Pq uint Minimum size of TRIM commands. TRIM ranges smaller than this will be skipped, unless they're part of a larger range which was chunked. @@ -1954,20 +1966,20 @@ This is normally not helpful because the extents to be trimmed will have been already been aggregated by the metaslab. This option is provided for debugging and performance analysis. . -.It Sy zfs_vdev_aggregation_limit Ns = Ns Sy 1048576 Ns B Po 1MB Pc Pq int +.It Sy zfs_vdev_aggregation_limit Ns = Ns Sy 1048576 Ns B Po 1 MiB Pc Pq int Max vdev I/O aggregation size. . -.It Sy zfs_vdev_aggregation_limit_non_rotating Ns = Ns Sy 131072 Ns B Po 128kB Pc Pq int +.It Sy zfs_vdev_aggregation_limit_non_rotating Ns = Ns Sy 131072 Ns B Po 128 KiB Pc Pq int Max vdev I/O aggregation size for non-rotating media. . -.It Sy zfs_vdev_cache_bshift Ns = Ns Sy 16 Po 64kB Pc Pq int +.It Sy zfs_vdev_cache_bshift Ns = Ns Sy 16 Po 64 KiB Pc Pq int Shift size to inflate reads to. . -.It Sy zfs_vdev_cache_max Ns = Ns Sy 16384 Ns B Po 16kB Pc Pq int +.It Sy zfs_vdev_cache_max Ns = Ns Sy 16384 Ns B Po 16 KiB Pc Pq int Inflate reads smaller than this value to meet the .Sy zfs_vdev_cache_bshift size -.Pq default Sy 64kB . +.Pq default Sy 64 KiB . . .It Sy zfs_vdev_cache_size Ns = Ns Sy 0 Pq int Total size of the per-disk cache in bytes. @@ -1989,7 +2001,7 @@ lacks locality as defined by Operations within this that are not immediately following the previous operation are incremented by half. . -.It Sy zfs_vdev_mirror_rotating_seek_offset Ns = Ns Sy 1048576 Ns B Po 1MB Pc Pq int +.It Sy zfs_vdev_mirror_rotating_seek_offset Ns = Ns Sy 1048576 Ns B Po 1 MiB Pc Pq int The maximum distance for the last queued I/O operation in which the balancing algorithm considers an operation to have locality. .No See Sx ZFS I/O SCHEDULER . @@ -2007,11 +2019,11 @@ locality as defined by the Operations within this that are not immediately following the previous operation are incremented by half. . -.It Sy zfs_vdev_read_gap_limit Ns = Ns Sy 32768 Ns B Po 32kB Pc Pq int +.It Sy zfs_vdev_read_gap_limit Ns = Ns Sy 32768 Ns B Po 32 KiB Pc Pq int Aggregate read I/O operations if the on-disk gap between them is within this threshold. . -.It Sy zfs_vdev_write_gap_limit Ns = Ns Sy 4096 Ns B Po 4kB Pc Pq int +.It Sy zfs_vdev_write_gap_limit Ns = Ns Sy 4096 Ns B Po 4 KiB Pc Pq int Aggregate write I/O operations if the on-disk gap between them is within this threshold. . @@ -2059,7 +2071,7 @@ Setting this to .Sy 0 disables duplicate detection. . -.It Sy zfs_zevent_retain_expire_secs Ns = Ns Sy 900 Ns s Po 15min Pc Pq int +.It Sy zfs_zevent_retain_expire_secs Ns = Ns Sy 900 Ns s Po 15 min Pc Pq int Lifespan for a recent ereport that was retained for duplicate checking. . .It Sy zfs_zil_clean_taskq_maxalloc Ns = Ns Sy 1048576 Pq int @@ -2078,10 +2090,10 @@ The default value of .Sy 100% will create a maximum of one thread per cpu. . -.It Sy zil_maxblocksize Ns = Ns Sy 131072 Ns B Po 128kB Pc Pq int +.It Sy zil_maxblocksize Ns = Ns Sy 131072 Ns B Po 128 KiB Pc Pq int This sets the maximum block size used by the ZIL. On very fragmented pools, lowering this -.Pq typically to Sy 36kB +.Pq typically to Sy 36 KiB can improve performance. . .It Sy zil_nocacheflush Ns = Ns Sy 0 Ns | Ns 1 Pq int @@ -2094,7 +2106,7 @@ if a volatile out-of-order write cache is enabled. Disable intent logging replay. Can be disabled for recovery from corrupted ZIL. . -.It Sy zil_slog_bulk Ns = Ns Sy 786432 Ns B Po 768kB Pc Pq ulong +.It Sy zil_slog_bulk Ns = Ns Sy 786432 Ns B Po 768 KiB Pc Pq ulong Limit SLOG write size per commit executed with synchronous priority. Any writes above that will be executed with lower (asynchronous) priority to limit potential SLOG device abuse by single active ZIL writer. @@ -2126,7 +2138,7 @@ diagnostic information for hang conditions which don't involve a mutex or other locking primitive: typically conditions in which a thread in the zio pipeline is looping indefinitely. . -.It Sy zio_slow_io_ms Ns = Ns Sy 30000 Ns ms Po 30s Pc Pq int +.It Sy zio_slow_io_ms Ns = Ns Sy 30000 Ns ms Po 30 s Pc Pq int When an I/O operation takes more than this much time to complete, it's marked as slow. Each slow operation causes a delay zevent. @@ -2202,7 +2214,7 @@ many blocks, where block size is determined by the .Sy volblocksize property of a zvol. . -.It Sy zvol_prefetch_bytes Ns = Ns Sy 131072 Ns B Po 128kB Pc Pq uint +.It Sy zvol_prefetch_bytes Ns = Ns Sy 131072 Ns B Po 128 KiB Pc Pq uint When adding a zvol to the system, prefetch this many bytes from the start and end of the volume. Prefetching these regions of the volume is desirable, @@ -2394,7 +2406,7 @@ delay Note, that since the delay is added to the outstanding time remaining on the most recent transaction it's effectively the inverse of IOPS. Here, the midpoint of -.Em 500us +.Em 500 us translates to .Em 2000 IOPS . The shape of the curve diff --git a/sys/contrib/openzfs/man/man7/dracut.zfs.7 b/sys/contrib/openzfs/man/man7/dracut.zfs.7 new file mode 100644 index 000000000000..0f446fe2fe3f --- /dev/null +++ b/sys/contrib/openzfs/man/man7/dracut.zfs.7 @@ -0,0 +1,278 @@ +.\" SPDX-License-Identifier: 0BSD +.\" +.Dd April 4, 2022 +.Dt DRACUT.ZFS 7 +.Os +. +.Sh NAME +.Nm dracut.zfs +.Nd overview of ZFS dracut hooks +. +.Sh SYNOPSIS +.Bd -literal -compact + parse-zfs.sh \(-> dracut-cmdline.service + | \(da + | … + | \(da + \e\(em\(em\(em\(em\(em\(em\(em\(em\(-> dracut-initqueue.service + | zfs-import-opts.sh + zfs-load-module.service \(da | | + | | sysinit.target \(da | + \(da | | zfs-import-scan.service \(da +zfs-import-scan.service \(da \(da | zfs-import-cache.service + | zfs-import-cache.service basic.target | | + \e__________________| | \(da \(da + \(da | zfs-load-key.sh + zfs-env-bootfs.service | | + \(da \(da \(da + zfs-import.target \(-> dracut-pre-mount.service + | \(ua | + | dracut-zfs-generator | + | ____________________/| + |/ \(da + | sysroot.mount \(<-\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em dracut-zfs-generator + | | \(da | + | \(da sysroot-{usr,etc,lib,&c.}.mount | + | initrd-root-fs.target \(<-\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em or \(da + | | zfs-nonroot-necessities.service + | \(da | + \(da dracut-mount.service | + zfs-snapshot-bootfs.service | | + | \(da | + \(da … | + zfs-rollback-bootfs.service | | + | \(da | + | sysroot-usr.mount \(<-\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em\(em/ + | | + | \(da + | initrd-fs.target + \e______________________ | + \e| + \(da + export-zfs.sh initrd.target + | | + \(da \(da + dracut-shutdown.service … + | + \(da + zfs-needshutdown.sh \(-> initrd-cleanup.service +.Ed +.Pp +Compare +.Xr dracut.bootup 7 +for the full flowchart. +. +.Sh DESCRIPTION +Under dracut, booting with +.No ZFS-on- Ns Pa / +is facilitated by a number of hooks in the +.Nm 90zfs +module. +.Pp +Booting into a ZFS dataset requires +.Sy mountpoint Ns = Ns Pa / +to be set on the dataset containing the root filesystem (henceforth "the boot dataset") and at the very least either the +.Sy bootfs +property to be set to that dataset, or the +.Sy root= +kernel cmdline (or dracut drop-in) argument to specify it. +.Pp +All children of the boot dataset with +.Sy canmount Ns = Ns Sy on +with +.Sy mountpoint Ns s +matching +.Pa /etc , /bin , /lib , /lib?? , /libx32 , No and Pa /usr +globs are deemed essential and will be mounted as well. +.Pp +.Xr zfs-mount-generator 8 +is recommended for proper functioning of the system afterward (correct mount properties, remounting, &c.). +. +.Sh CMDLINE +.Ss Standard +.Bl -tag -compact -width ".Sy root=zfs:AUTO , root=zfs: , root=zfs , Op Sy root=" +.It Sy root=zfs:\& Ns Ar dataset , Sy root=ZFS= Ns Ar dataset +Use +.Ar dataset +as the boot dataset. +All pluses +.Pq Sq + +are replaced with spaces +.Pq Sq \ . +. +.It Sy root=zfs:AUTO , root=zfs:\& , root=zfs , Op Sy root= +After import, search for the first pool with the +.Sy bootfs +property set, use its value as-if specified as the +.Ar dataset +above. +. +.It Sy rootfstype=zfs root= Ns Ar dataset +Equivalent to +.Sy root=zfs:\& Ns Ar dataset . +. +.It Sy rootfstype=zfs Op Sy root= +Equivalent to +.Sy root=zfs:AUTO . +. +.It Sy rootflags= Ns Ar flags +Mount the boot dataset with +.Fl o Ar flags ; +cf.\& +.Sx Temporary Mount Point Properties +in +.Xr zfsprops 7 . +These properties will not last, since all filesystems will be re-mounted from the real root. +. +.It Sy debug +If specified, +.Nm dracut-zfs-generator +logs to the journal. +.El +.Pp +Be careful about setting neither +.Sy rootfstype=zfs +nor +.Sy root=zfs:\& Ns Ar dataset +\(em other automatic boot selection methods, like +.Nm systemd-gpt-auto-generator +and +.Nm systemd-fstab-generator +might take precedent. +. +.Ss ZFS-specific +.Bl -tag -compact -width ".Sy bootfs.snapshot Ns Op Sy = Ns Ar snapshot-name" +.It Sy bootfs.snapshot Ns Op Sy = Ns Ar snapshot-name +Execute +.Nm zfs Cm snapshot Ar boot-dataset Ns Sy @ Ns Ar snapshot-name +before pivoting to the real root. +.Ar snapshot-name +defaults to the current kernel release. +. +.It Sy bootfs.rollback Ns Op Sy = Ns Ar snapshot-name +Execute +.Nm zfs Cm snapshot Fl Rf Ar boot-dataset Ns Sy @ Ns Ar snapshot-name +before pivoting to the real root. +.Ar snapshot-name +defaults to the current kernel release. +. +.It Sy spl_hostid= Ns Ar host-id +Use +.Xr zgenhostid 8 +to set the host ID to +.Ar host-id ; +otherwise, +.Pa /etc/hostid +inherited from the real root is used. +. +.It Sy zfs_force , zfs.force , zfsforce +Appends +.Fl f +to all +.Nm zpool Cm import +invocations; primarily useful in conjunction with +.Sy spl_hostid= , +or if no host ID was inherited. +.El +. +.Sh FILES +.Bl -tag -width 0 +.It Pa parse-zfs.sh Pq Sy cmdline +Processes +.Sy spl_hostid= . +If +.Sy root= +matches a known pattern, above, provides +.Pa /dev/root +and delays the initqueue until +.Xr zfs 4 +is loaded, +. +.It Pa zfs-import-opts.sh Pq Nm systemd No environment generator +Turns +.Sy zfs_force , zfs.force , No or Sy zfsforce +into +.Ev ZPOOL_IMPORT_OPTS Ns = Ns Fl f +for +.Pa zfs-import-scan.service +or +.Pa zfs-import-cache.service . +. +.It Pa zfs-load-key.sh Pq Sy pre-mount +Loads encryption keys for the boot dataset and its essential descendants. +.Bl -tag -compact -offset 4n -width ".Sy keylocation Ns = Ns Sy https:// Ns Ar URL , Sy keylocation Ns = Ns Sy http:// Ns Ar URL" +.It Sy keylocation Ns = Ns Sy prompt +Is prompted for via +.Nm systemd-ask-password +thrice. +. +.It Sy keylocation Ns = Ns Sy https:// Ns Ar URL , Sy keylocation Ns = Ns Sy http:// Ns Ar URL +.Pa network-online.target +is started before loading. +. +.It Sy keylocation Ns = Ns Sy file:// Ns Ar path +If +.Ar path +doesn't exist, +.Nm udevadm No is Cm settle Ns d . +If it still doesn't, it's waited for for up to +.Sy 10 Ns s . +.El +. +.It Pa zfs-env-bootfs.service Pq Nm systemd No service +After pool import, sets +.Ev BOOTFS Ns = +in the systemd environment to the first non-null +.Sy bootfs +value in iteration order. +. +.It Pa dracut-zfs-generator Pq Nm systemd No generator +Generates +.Pa sysroot.mount Pq using Sy rootflags= , No if any . +If an explicit boot dataset was specified, also generates essential mountpoints +.Pq Pa sysroot-etc.mount , sysroot-bin.mount , No &c.\& , +otherwise generates +.Pa zfs-nonroot-necessities.service +which mounts them explicitly after +.Pa /sysroot +using +.Ev BOOTFS Ns = . +. +.It Pa zfs-snapshot-bootfs.service , zfs-rollback-bootfs.service Pq Nm systemd No services +Consume +.Sy bootfs.snapshot +and +.Sy bootfs.rollback +as described in +.Sx CMDLINE . +Use +.Ev BOOTFS Ns = +if no explicit boot dataset was specified. +. +.It Pa zfs-needshutdown.sh Pq Sy cleanup +If any pools were imported, signals that shutdown hooks are required. +. +.It Pa export-zfs.sh Pq Sy shutdown +Forcibly exports all pools. +. +.It Pa /etc/hostid , /etc/zfs/zpool.cache , /etc/zfs/vdev_id.conf Pq regular files +Included verbatim, hostonly. +. +.It Pa mount-zfs.sh Pq Sy mount +Does nothing on +.Nm systemd +systems +.Pq if Pa dracut-zfs-generator No succeeded . +Otherwise, loads encryption key for the boot dataset from the console or via plymouth. +It may not work at all! +.El +. +.Sh SEE ALSO +.Xr dracut.bootup 7 , +.Xr zfsprops 7 , +.Xr zpoolprops 7 , +.Xr dracut-shutdown.service 8 , +.Xr systemd-fstab-generator 8 , +.Xr systemd-gpt-auto-generator 8 , +.Xr zfs-mount-generator 8 , +.Xr zgenhostid 8 diff --git a/sys/contrib/openzfs/man/man7/zfsprops.7 b/sys/contrib/openzfs/man/man7/zfsprops.7 index 0976e80d7309..2694938aa206 100644 --- a/sys/contrib/openzfs/man/man7/zfsprops.7 +++ b/sys/contrib/openzfs/man/man7/zfsprops.7 @@ -388,7 +388,7 @@ privilege with can access everyone's usage. .Pp The -.Sy userused Ns @ Ns Ar ... +.Sy userused Ns @ Ns Ar … properties are not displayed by .Nm zfs Cm get Sy all . The user's name must be appended after the @@ -872,14 +872,17 @@ This is done using .Sy zstd-fast- Ns Ar N , where .Ar N -is an integer in [1-9,10,20,30,...,100,500,1000] which maps to a negative +is an integer in +.Bq Sy 1 Ns - Ns Sy 10 , 20 , 30 , No … , Sy 100 , 500 , 1000 +which maps to a negative .Sy zstd level. -The lower the level the faster the compression - -.Ar 1000 No provides the fastest compression and lowest compression ratio. +The lower the level the faster the compression \(em +.Sy 1000 +provides the fastest compression and lowest compression ratio. .Sy zstd-fast is equivalent to -.Sy zstd-fast-1 . +.Sy zstd-fast- Ns Ar 1 . .Pp The .Sy zle @@ -901,7 +904,7 @@ after compression, otherwise the compression will not be considered worthwhile and the block saved uncompressed. Note that when the logical block is less than 8 times the disk sector size this effectively reduces the necessary compression -ratio; for example, 8kB blocks on disks with 4kB disk sectors must compress to 1/2 +ratio; for example, 8 KiB blocks on disks with 4 KiB disk sectors must compress to 1/2 or less of their original size. .It Xo .Sy context Ns = Ns Sy none Ns | Ns @@ -1196,7 +1199,7 @@ blocks into the special allocation class. Blocks smaller than or equal to this value will be assigned to the special allocation class while greater blocks will be assigned to the regular class. -Valid values are zero or a power of two from 512B up to 1M. +Valid values are zero or a power of two from 512 up to 1048576 (1 MiB). The default size is 0 which means no small file blocks will be allocated in the special class. .Pp @@ -1315,7 +1318,7 @@ can get and set everyone's quota. This property is not available on volumes, on file systems before version 4, or on pools before version 15. The -.Sy userquota@ Ns Ar ... +.Sy userquota@ Ns Ar … properties are not displayed by .Nm zfs Cm get Sy all . The user's name must be appended after the @@ -1423,13 +1426,13 @@ Use of this property for general purpose file systems is strongly discouraged, and may adversely affect performance. .Pp The size specified must be a power of two greater than or equal to -.Ar 512B +.Ar 512 B and less than or equal to -.Ar 128kB . +.Ar 128 KiB . If the .Sy large_blocks feature is enabled on the pool, the size may be up to -.Ar 1MB . +.Ar 1 MiB . See .Xr zpool-features 7 for details on ZFS feature flags. diff --git a/sys/contrib/openzfs/man/man7/zpool-features.7 b/sys/contrib/openzfs/man/man7/zpool-features.7 index 9a202ca8a596..b92109c4ac98 100644 --- a/sys/contrib/openzfs/man/man7/zpool-features.7 +++ b/sys/contrib/openzfs/man/man7/zpool-features.7 @@ -157,7 +157,7 @@ separated by whitespace and/or commas. Only features present in all files are enabled. .Pp Simple sanity checks are applied to the files: -they must be between 1B and 16kB in size, and must end with a newline character. +they must be between 1 B and 16 KiB in size, and must end with a newline character. .Pp The requested features are applied when a pool is created using .Nm zpool Cm create Fl o Sy compatibility Ns = Ns Ar … @@ -446,7 +446,7 @@ or smaller can take advantage of this feature. When this feature is enabled, the contents of highly-compressible blocks are stored in the block "pointer" itself (a misnomer in this case, as it contains the compressed data, rather than a pointer to its location on disk). -Thus the space of the block (one sector, typically 512B or 4kB) is saved, +Thus the space of the block (one sector, typically 512 B or 4 KiB) is saved, and no additional I/O is needed to read and write the data block. . \*[instant-never] @@ -507,6 +507,17 @@ once either of the limit properties has been set on a dataset and will never return to being .Sy enabled . . +.feature com.delphix head_errlog no +This feature enables the upgraded version of errlog, which required an on-disk +error log format change. +Now the error log of each head dataset is stored separately in the zap object +and keyed by the head id. +With this feature enabled, every dataset affected by an error block is listed +in the output of +.Nm zpool Cm status . +.Pp +\*[instant-never] +. .feature com.delphix hole_birth no enabled_txg This feature has/had bugs, the result of which is that, if you do a .Nm zfs Cm send Fl i @@ -554,29 +565,29 @@ already exist on the receiving side. \*[instant-never] . .feature org.open-zfs large_blocks no extensible_dataset -This feature allows the record size on a dataset to be set larger than 128kB. +This feature allows the record size on a dataset to be set larger than 128 KiB. .Pp This feature becomes .Sy active -once a dataset contains a file with a block size larger than 128kB, +once a dataset contains a file with a block size larger than 128 KiB, and will return to being .Sy enabled -once all filesystems that have ever had their recordsize larger than 128kB +once all filesystems that have ever had their recordsize larger than 128 KiB are destroyed. . .feature org.zfsonlinux large_dnode no extensible_dataset -This feature allows the size of dnodes in a dataset to be set larger than 512B. +This feature allows the size of dnodes in a dataset to be set larger than 512 B. . This feature becomes .Sy active -once a dataset contains an object with a dnode larger than 512B, +once a dataset contains an object with a dnode larger than 512 B, which occurs as a result of setting the .Sy dnodesize dataset property to a value other than .Sy legacy . The feature will return to being .Sy enabled -once all filesystems that have ever contained a dnode larger than 512B +once all filesystems that have ever contained a dnode larger than 512 B are destroyed. Large dnodes allow more data to be stored in the bonus buffer, thus potentially improving performance by avoiding the use of spill blocks. diff --git a/sys/contrib/openzfs/man/man7/zpoolconcepts.7 b/sys/contrib/openzfs/man/man7/zpoolconcepts.7 index 582aeae50e29..ea2b783f32a7 100644 --- a/sys/contrib/openzfs/man/man7/zpoolconcepts.7 +++ b/sys/contrib/openzfs/man/man7/zpoolconcepts.7 @@ -107,7 +107,7 @@ Unlike raidz, dRAID uses a fixed stripe width (padding as necessary with zeros) to allow fully sequential resilvering. This fixed stripe width significantly effects both usable capacity and IOPS. For example, with the default -.Em D=8 No and Em 4kB No disk sectors the minimum allocation size is Em 32kB . +.Em D=8 No and Em 4 KiB No disk sectors the minimum allocation size is Em 32 KiB . If using compression, this relatively large allocation size can reduce the effective compression ratio. When using ZFS volumes and dRAID, the default of the @@ -422,13 +422,13 @@ asynchronously when importing the pool in L2ARC (persistent L2ARC). This can be disabled by setting .Sy l2arc_rebuild_enabled Ns = Ns Sy 0 . For cache devices smaller than -.Em 1GB , +.Em 1 GiB , we do not write the metadata structures required for rebuilding the L2ARC in order not to waste space. This can be changed with .Sy l2arc_rebuild_blocks_min_l2size . The cache device header -.Pq Em 512B +.Pq Em 512 B is updated even if no metadata structures are written. Setting .Sy l2arc_headroom Ns = Ns Sy 0 diff --git a/sys/contrib/openzfs/man/man8/zed.8.in b/sys/contrib/openzfs/man/man8/zed.8.in index d3297605206e..6c51f10695cc 100644 --- a/sys/contrib/openzfs/man/man8/zed.8.in +++ b/sys/contrib/openzfs/man/man8/zed.8.in @@ -75,7 +75,7 @@ Custom .Ev $PATH for zedlets to use. Normally zedlets run in a locked-down environment, with hardcoded paths to the ZFS commands -.Pq Ev $ZFS , $ZPOOL , $ZED , ... , +.Pq Ev $ZFS , $ZPOOL , $ZED , … , and a hard-coded .Ev $PATH . This is done for security reasons. diff --git a/sys/contrib/openzfs/man/man8/zfs-allow.8 b/sys/contrib/openzfs/man/man8/zfs-allow.8 index f949a0a5eee5..52b7c43f44ba 100644 --- a/sys/contrib/openzfs/man/man8/zfs-allow.8 +++ b/sys/contrib/openzfs/man/man8/zfs-allow.8 @@ -215,19 +215,19 @@ send subcommand share subcommand Allows sharing file systems over NFS or SMB protocols snapshot subcommand Must also have the \fBmount\fR ability -groupquota other Allows accessing any \fBgroupquota@\fI...\fR property -groupobjquota other Allows accessing any \fBgroupobjquota@\fI...\fR property -groupused other Allows reading any \fBgroupused@\fI...\fR property -groupobjused other Allows reading any \fBgroupobjused@\fI...\fR property +groupquota other Allows accessing any \fBgroupquota@\fI…\fR property +groupobjquota other Allows accessing any \fBgroupobjquota@\fI…\fR property +groupused other Allows reading any \fBgroupused@\fI…\fR property +groupobjused other Allows reading any \fBgroupobjused@\fI…\fR property userprop other Allows changing any user property -userquota other Allows accessing any \fBuserquota@\fI...\fR property -userobjquota other Allows accessing any \fBuserobjquota@\fI...\fR property -userused other Allows reading any \fBuserused@\fI...\fR property -userobjused other Allows reading any \fBuserobjused@\fI...\fR property -projectobjquota other Allows accessing any \fBprojectobjquota@\fI...\fR property -projectquota other Allows accessing any \fBprojectquota@\fI...\fR property -projectobjused other Allows reading any \fBprojectobjused@\fI...\fR property -projectused other Allows reading any \fBprojectused@\fI...\fR property +userquota other Allows accessing any \fBuserquota@\fI…\fR property +userobjquota other Allows accessing any \fBuserobjquota@\fI…\fR property +userused other Allows reading any \fBuserused@\fI…\fR property +userobjused other Allows reading any \fBuserobjused@\fI…\fR property +projectobjquota other Allows accessing any \fBprojectobjquota@\fI…\fR property +projectquota other Allows accessing any \fBprojectquota@\fI…\fR property +projectobjused other Allows reading any \fBprojectobjused@\fI…\fR property +projectused other Allows reading any \fBprojectused@\fI…\fR property aclinherit property aclmode property diff --git a/sys/contrib/openzfs/man/man8/zfs-bookmark.8 b/sys/contrib/openzfs/man/man8/zfs-bookmark.8 index 88153b2ccfb5..8b268b714385 100644 --- a/sys/contrib/openzfs/man/man8/zfs-bookmark.8 +++ b/sys/contrib/openzfs/man/man8/zfs-bookmark.8 @@ -30,7 +30,7 @@ .\" Copyright 2019 Joyent, Inc. .\" Copyright (c) 2019, 2020 by Christian Schwarz. All Rights Reserved. .\" -.Dd March 16, 2022 +.Dd May 12, 2022 .Dt ZFS-BOOKMARK 8 .Os . @@ -65,8 +65,8 @@ feature. .\" These are, respectively, examples 23 from zfs.8 .\" Make sure to update them bidirectionally .Ss Example 1 : No Creating a bookmark -The following example create a bookmark to a snapshot. -This bookmark can then be used instead of snapshot in send streams. +The following example creates a bookmark to a snapshot. +This bookmark can then be used instead of a snapshot in send streams. .Dl # Nm zfs Cm bookmark Ar rpool Ns @ Ns Ar snapshot rpool Ns # Ns Ar bookmark . .Sh SEE ALSO diff --git a/sys/contrib/openzfs/man/man8/zfs-program.8 b/sys/contrib/openzfs/man/man8/zfs-program.8 index 4a9718cdcfcb..06415b2190eb 100644 --- a/sys/contrib/openzfs/man/man8/zfs-program.8 +++ b/sys/contrib/openzfs/man/man8/zfs-program.8 @@ -73,7 +73,7 @@ The default limit is 10 million instructions, and it can be set to a maximum of Memory limit, in bytes. If a channel program attempts to allocate more memory than the given limit, it will be stopped and an error returned. -The default memory limit is 10 MB, and can be set to a maximum of 100 MB. +The default memory limit is 10 MiB, and can be set to a maximum of 100 MiB. .El .Pp All remaining argument strings will be passed directly to the Lua script as @@ -96,16 +96,17 @@ argv = args["argv"] -- argv == {1="arg1", 2="arg2", ...} .Ed .Pp -If invoked from the libZFS interface, an arbitrary argument list can be +If invoked from the libzfs interface, an arbitrary argument list can be passed to the channel program, which is accessible via the same -"..." syntax in Lua: +.Qq Li ... +syntax in Lua: .Bd -literal -compact -offset indent args = ... -- args == {"foo"="bar", "baz"={...}, ...} .Ed .Pp Note that because Lua arrays are 1-indexed, arrays passed to Lua from the -libZFS interface will have their indices incremented by 1. +libzfs interface will have their indices incremented by 1. That is, the element in .Va arr[0] @@ -166,7 +167,7 @@ See the section below for function-specific details on error return codes. . .Ss Lua to C Value Conversion -When invoking a channel program via the libZFS interface, it is necessary to +When invoking a channel program via the libzfs interface, it is necessary to translate arguments and return values from Lua values to their C equivalents, and vice-versa. .Pp diff --git a/sys/contrib/openzfs/man/man8/zfs-send.8 b/sys/contrib/openzfs/man/man8/zfs-send.8 index 67e94ca85bc7..137deb94e20d 100644 --- a/sys/contrib/openzfs/man/man8/zfs-send.8 +++ b/sys/contrib/openzfs/man/man8/zfs-send.8 @@ -39,8 +39,8 @@ .Sh SYNOPSIS .Nm zfs .Cm send -.Op Fl DLPRbcehnpsvw -.Op Fl X Ar dataset Ns Oo , Ns Ar dataset Oc Ns ... +.Op Fl DLPbcehnpsvw +.Op Fl R Op Fl X Ar dataset Ns Oo , Ns Ar dataset Oc Ns … .Op Oo Fl I Ns | Ns Fl i Oc Ar snapshot .Ar snapshot .Nm zfs @@ -73,8 +73,8 @@ .It Xo .Nm zfs .Cm send -.Op Fl DLPRbcehnpvw -.Op Fl X Ar dataset Ns Oo , Ns Ar dataset Oc Ns ... +.Op Fl DLPbcehnpsvw +.Op Fl R Op Fl X Ar dataset Ns Oo , Ns Ar dataset Oc Ns … .Op Oo Fl I Ns | Ns Fl i Oc Ar snapshot .Ar snapshot .Xc @@ -102,12 +102,12 @@ The incremental source may be specified as with the .Fl i option. .It Fl L , -large-block -Generate a stream which may contain blocks larger than 128KB. +Generate a stream which may contain blocks larger than 128 KiB. This flag has no effect if the .Sy large_blocks pool feature is disabled, or if the .Sy recordsize -property of this filesystem has never been set above 128KB. +property of this filesystem has never been set above 128 KiB. The receiving system must have the .Sy large_blocks pool feature enabled as well. @@ -142,23 +142,16 @@ If the flag is used to send encrypted datasets, then .Fl w must also be specified. -.It Fl X , -exclude Ar dataset Ns Oo , Ns Ar dataset Oc Ns ... -When the -.Fl R -flag is given, +.It Fl X , -exclude Ar dataset Ns Oo , Ns Ar dataset Oc Ns … +With +.Fl R , .Fl X -can be used to specify a list of datasets to be excluded from the -data stream. -The -.Fl X -option can be used multiple times, or the list of datasets can be -specified as a comma-separated list, or both. -.Ar dataset -must not be the pool's root dataset, and all descendant datasets of -.Ar dataset -will be excluded from the send stream. -Requires -.Fl R . +specifies a set of datasets (and, hence, their descendants), +to be excluded from the send stream. +The root dataset may not be excluded. +.Fl X Ar a Fl X Ar b +is equivalent to +.Fl X Ar a , Ns Ar b . .It Fl e , -embed Generate a more compact stream by using .Sy WRITE_EMBEDDED @@ -324,12 +317,12 @@ Deduplicated send is no longer supported. This flag is accepted for backwards compatibility, but a regular, non-deduplicated stream will be generated. .It Fl L , -large-block -Generate a stream which may contain blocks larger than 128KB. +Generate a stream which may contain blocks larger than 128 KiB. This flag has no effect if the .Sy large_blocks pool feature is disabled, or if the .Sy recordsize -property of this filesystem has never been set above 128KB. +property of this filesystem has never been set above 128 KiB. The receiving system must have the .Sy large_blocks pool feature enabled as well. diff --git a/sys/contrib/openzfs/man/man8/zfs-set.8 b/sys/contrib/openzfs/man/man8/zfs-set.8 index 6092e49dfbcf..9d0c437df217 100644 --- a/sys/contrib/openzfs/man/man8/zfs-set.8 +++ b/sys/contrib/openzfs/man/man8/zfs-set.8 @@ -170,8 +170,9 @@ inherited. .It Fl r Recursively inherit the given property for all children. .It Fl S -Revert the property to the received value if one exists; otherwise operate as -if the +Revert the property to the received value, if one exists; +otherwise, for non-inheritable properties, to the default; +otherwise, operate as if the .Fl S option was not specified. .El diff --git a/sys/contrib/openzfs/man/man8/zfs.8 b/sys/contrib/openzfs/man/man8/zfs.8 index dd901e1e6e81..cac4327e0721 100644 --- a/sys/contrib/openzfs/man/man8/zfs.8 +++ b/sys/contrib/openzfs/man/man8/zfs.8 @@ -36,7 +36,7 @@ .\" Copyright 2018 Nexenta Systems, Inc. .\" Copyright 2019 Joyent, Inc. .\" -.Dd March 16, 2022 +.Dd May 12, 2022 .Dt ZFS 8 .Os . @@ -57,13 +57,32 @@ The .Nm command configures ZFS datasets within a ZFS storage pool, as described in .Xr zpool 8 . -A dataset is identified by a unique path within the ZFS namespace. -For example: -.Dl pool/{filesystem,volume,snapshot} +A dataset is identified by a unique path within the ZFS namespace: .Pp -where the maximum length of a dataset name is -.Sy MAXNAMELEN Pq 256B -and the maximum amount of nesting allowed in a path is 50 levels deep. +.D1 Ar pool Ns Oo Sy / Ns Ar component Oc Ns Sy / Ns Ar component +.Pp +for example: +.Pp +.Dl rpool/var/log +.Pp +The maximum length of a dataset name is +.Sy ZFS_MAX_DATASET_NAME_LEN No - 1 +ASCII characters (currently 255) satisfying +.Sy [A-Za-z_.:/ -] . +Additionally snapshots are allowed to contain a single +.Sy @ +character, while bookmarks are allowed to contain a single +.Sy # +character. +.Sy / +is used as separator between components. +The maximum amount of nesting allowed in a path is +.Sy zfs_max_dataset_nesting +levels deep. +ZFS tunables +.Pq Sy zfs_* +are explained in +.Xr zfs 4 . .Pp A dataset can be one of the following: .Bl -tag -offset Ds -width "file system" @@ -226,7 +245,7 @@ option reverted to the received value if one exists. Displays space consumed by, and quotas on, each user, group, or project in the specified filesystem or snapshot. .It Xr zfs-project 8 -List, set, or clear project ID and/or inherit flag on the file(s) or directories. +List, set, or clear project ID and/or inherit flag on the files or directories. .El . .Ss Mountpoints @@ -263,7 +282,8 @@ Add or change an encryption key on the specified dataset. .It Xr zfs-load-key 8 Load the key for the specified encrypted dataset, enabling access. .It Xr zfs-unload-key 8 -Unload a key for the specified dataset, removing the ability to access the dataset. +Unload a key for the specified dataset, +removing the ability to access the dataset. .El . .Ss Channel Programs @@ -586,7 +606,7 @@ mount point permission is set to 755 by default, user will be unable to mount file systems under .Ar tank/cindys . Add an ACE similar to the following syntax to provide mount point access: -.Dl # Cm chmod No A+user: Ns Ar cindys Ns :add_subdirectory:allow Ar /tank/cindys +.Dl # Cm chmod No A+user : Ns Ar cindys Ns :add_subdirectory:allow Ar /tank/cindys . .Ss Example 18 : No Delegating Create Time Permissions on a ZFS Dataset The following example shows how to grant anyone in the group @@ -683,8 +703,8 @@ M F /tank/test/modified .Ed . .Ss Example 23 : No Creating a bookmark -The following example create a bookmark to a snapshot. -This bookmark can then be used instead of snapshot in send streams. +The following example creates a bookmark to a snapshot. +This bookmark can then be used instead of a snapshot in send streams. .Dl # Nm zfs Cm bookmark Ar rpool Ns @ Ns Ar snapshot rpool Ns # Ns Ar bookmark . .Ss Example 24 : No Setting Sy sharesmb No Property Options on a ZFS File System @@ -725,6 +745,14 @@ to use to mount ZFS datasets. This option is provided for backwards compatibility with older ZFS versions. .El +.Bl -tag -width "ZFS_SET_PIPE_MAX" +.It Sy ZFS_SET_PIPE_MAX +Tells +.Nm zfs +to set the maximum pipe size for sends/recieves. +Disabled by default on Linux +due to an unfixed deadlock in Linux's pipe size handling code. +.El . .Sh INTERFACE STABILITY .Sy Committed . diff --git a/sys/contrib/openzfs/man/man8/zpool-import.8 b/sys/contrib/openzfs/man/man8/zpool-import.8 index 20ce41e6459b..b23d7dabdb55 100644 --- a/sys/contrib/openzfs/man/man8/zpool-import.8 +++ b/sys/contrib/openzfs/man/man8/zpool-import.8 @@ -71,7 +71,8 @@ .Xc Lists pools available to import. If the -.Fl d or +.Fl d +or .Fl c options are not specified, this command searches for devices using libblkid on Linux and geom on diff --git a/sys/contrib/openzfs/man/man8/zpool-list.8 b/sys/contrib/openzfs/man/man8/zpool-list.8 index ce8e34b61dec..88183b4dce1a 100644 --- a/sys/contrib/openzfs/man/man8/zpool-list.8 +++ b/sys/contrib/openzfs/man/man8/zpool-list.8 @@ -128,7 +128,7 @@ zion - - - - - - - FAULTED - The following command displays the detailed information for the pool .Ar data . This pool is comprised of a single raidz vdev where one of its devices -increased its capacity by 10GB. +increased its capacity by 10 GiB. In this example, the pool will not be able to utilize this extra capacity until all the devices under the raidz vdev have been expanded. .Bd -literal -compact -offset Ds diff --git a/sys/contrib/openzfs/man/man8/zpool.8 b/sys/contrib/openzfs/man/man8/zpool.8 index e99eaf536f2f..34c816bf0342 100644 --- a/sys/contrib/openzfs/man/man8/zpool.8 +++ b/sys/contrib/openzfs/man/man8/zpool.8 @@ -395,7 +395,7 @@ The command to remove the mirrored data The following command displays the detailed information for the pool .Ar data . This pool is comprised of a single raidz vdev where one of its devices -increased its capacity by 10GB. +increased its capacity by 10 GiB. In this example, the pool will not be able to utilize this extra capacity until all the devices under the raidz vdev have been expanded. .Bd -literal -compact -offset Ds diff --git a/sys/contrib/openzfs/module/Kbuild.in b/sys/contrib/openzfs/module/Kbuild.in index 1507965c5750..11099999fb87 100644 --- a/sys/contrib/openzfs/module/Kbuild.in +++ b/sys/contrib/openzfs/module/Kbuild.in @@ -1,20 +1,6 @@ # When integrated in to a monolithic kernel the spl module must appear # first. This ensures its module initialization function is run before # any of the other module initialization functions which depend on it. -ZFS_MODULES += spl/ -ZFS_MODULES += avl/ -ZFS_MODULES += icp/ -ZFS_MODULES += lua/ -ZFS_MODULES += nvpair/ -ZFS_MODULES += unicode/ -ZFS_MODULES += zcommon/ -ZFS_MODULES += zfs/ -ZFS_MODULES += zstd/ - -# The rest is only relevant when run by kbuild -ifneq ($(KERNELRELEASE),) - -obj-$(CONFIG_ZFS) := $(ZFS_MODULES) ZFS_MODULE_CFLAGS += -std=gnu99 -Wno-declaration-after-statement ZFS_MODULE_CFLAGS += -Wmissing-prototypes @@ -22,10 +8,16 @@ ZFS_MODULE_CFLAGS += @KERNEL_DEBUG_CFLAGS@ @NO_FORMAT_ZERO_LENGTH@ ifneq ($(KBUILD_EXTMOD),) zfs_include = @abs_top_srcdir@/include +icp_include = @abs_srcdir@/icp/include +zstd_include = @abs_srcdir@/zstd/include ZFS_MODULE_CFLAGS += -include @abs_top_builddir@/zfs_config.h ZFS_MODULE_CFLAGS += -I@abs_top_builddir@/include +src = @abs_srcdir@ +obj = @abs_builddir@ else zfs_include = $(srctree)/include/zfs +icp_include = $(srctree)/$(src)/icp/include +zstd_include = $(srctree)/$(src)/zstd/include ZFS_MODULE_CFLAGS += -include $(zfs_include)/zfs_config.h endif @@ -36,12 +28,415 @@ ZFS_MODULE_CFLAGS += -I$(zfs_include) ZFS_MODULE_CPPFLAGS += -D_KERNEL ZFS_MODULE_CPPFLAGS += @KERNEL_DEBUG_CPPFLAGS@ +# KASAN enables -Werror=frame-larger-than=1024, which +# breaks oh so many parts of our build. +ifeq ($(CONFIG_KASAN),y) +ZFS_MODULE_CFLAGS += -Wno-error=frame-larger-than= +endif + ifneq ($(KBUILD_EXTMOD),) @CONFIG_QAT_TRUE@ZFS_MODULE_CFLAGS += -I@QAT_SRC@/include @CONFIG_QAT_TRUE@KBUILD_EXTRA_SYMBOLS += @QAT_SYMBOLS@ endif -subdir-asflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS) -subdir-ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS) +asflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS) +ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS) +# Suppress unused-value warnings in sparc64 architecture headers +ccflags-$(CONFIG_SPARC64) += -Wno-unused-value + + +obj-$(CONFIG_ZFS) := spl.o zfs.o + +SPL_OBJS := \ + spl-atomic.o \ + spl-condvar.o \ + spl-cred.o \ + spl-err.o \ + spl-generic.o \ + spl-kmem-cache.o \ + spl-kmem.o \ + spl-kstat.o \ + spl-proc.o \ + spl-procfs-list.o \ + spl-taskq.o \ + spl-thread.o \ + spl-trace.o \ + spl-tsd.o \ + spl-vmem.o \ + spl-xdr.o \ + spl-zlib.o + +spl-objs += $(addprefix os/linux/spl/,$(SPL_OBJS)) + +zfs-objs += avl/avl.o + +ICP_OBJS := \ + algs/aes/aes_impl.o \ + algs/aes/aes_impl_generic.o \ + algs/aes/aes_modes.o \ + algs/edonr/edonr.o \ + algs/modes/cbc.o \ + algs/modes/ccm.o \ + algs/modes/ctr.o \ + algs/modes/ecb.o \ + algs/modes/gcm.o \ + algs/modes/gcm_generic.o \ + algs/modes/modes.o \ + algs/sha2/sha2.o \ + algs/skein/skein.o \ + algs/skein/skein_block.o \ + algs/skein/skein_iv.o \ + api/kcf_cipher.o \ + api/kcf_ctxops.o \ + api/kcf_mac.o \ + core/kcf_callprov.o \ + core/kcf_mech_tabs.o \ + core/kcf_prov_lib.o \ + core/kcf_prov_tabs.o \ + core/kcf_sched.o \ + illumos-crypto.o \ + io/aes.o \ + io/sha2_mod.o \ + io/skein_mod.o \ + spi/kcf_spi.o + +ICP_OBJS_X86_64 := \ + asm-x86_64/aes/aes_aesni.o \ + asm-x86_64/aes/aes_amd64.o \ + asm-x86_64/aes/aeskey.o \ + asm-x86_64/modes/aesni-gcm-x86_64.o \ + asm-x86_64/modes/gcm_pclmulqdq.o \ + asm-x86_64/modes/ghash-x86_64.o \ + asm-x86_64/sha2/sha256_impl.o \ + asm-x86_64/sha2/sha512_impl.o + +ICP_OBJS_X86 := \ + algs/aes/aes_impl_aesni.o \ + algs/aes/aes_impl_x86-64.o \ + algs/modes/gcm_pclmulqdq.o + +zfs-objs += $(addprefix icp/,$(ICP_OBJS)) +zfs-$(CONFIG_X86) += $(addprefix icp/,$(ICP_OBJS_X86)) +zfs-$(CONFIG_X86_64) += $(addprefix icp/,$(ICP_OBJS_X86_64)) + +$(addprefix $(obj)/icp/,$(ICP_OBJS) $(ICP_OBJS_X86) $(ICP_OBJS_X86_64)) : asflags-y += -I$(icp_include) +$(addprefix $(obj)/icp/,$(ICP_OBJS) $(ICP_OBJS_X86) $(ICP_OBJS_X86_64)) : ccflags-y += -I$(icp_include) + +# Suppress objtool "can't find jump dest instruction at" warnings. They +# are caused by the constants which are defined in the text section of the +# assembly file using .byte instructions (e.g. bswap_mask). The objtool +# utility tries to interpret them as opcodes and obviously fails doing so. +OBJECT_FILES_NON_STANDARD_aesni-gcm-x86_64.o := y +OBJECT_FILES_NON_STANDARD_ghash-x86_64.o := y +# Suppress objtool "unsupported stack pointer realignment" warnings. We are +# not using a DRAP register while aligning the stack to a 64 byte boundary. +# See #6950 for the reasoning. +OBJECT_FILES_NON_STANDARD_sha256_impl.o := y +OBJECT_FILES_NON_STANDARD_sha512_impl.o := y + + +LUA_OBJS := \ + lapi.o \ + lauxlib.o \ + lbaselib.o \ + lcode.o \ + lcompat.o \ + lcorolib.o \ + lctype.o \ + ldebug.o \ + ldo.o \ + lfunc.o \ + lgc.o \ + llex.o \ + lmem.o \ + lobject.o \ + lopcodes.o \ + lparser.o \ + lstate.o \ + lstring.o \ + lstrlib.o \ + ltable.o \ + ltablib.o \ + ltm.o \ + lvm.o \ + lzio.o \ + setjmp/setjmp.o + +zfs-objs += $(addprefix lua/,$(LUA_OBJS)) + + +NVPAIR_OBJS := \ + fnvpair.o \ + nvpair.o \ + nvpair_alloc_fixed.o \ + nvpair_alloc_spl.o + +zfs-objs += $(addprefix nvpair/,$(NVPAIR_OBJS)) + + +UNICODE_OBJS := \ + u8_textprep.o \ + uconv.o + +zfs-objs += $(addprefix unicode/,$(UNICODE_OBJS)) + + +ZCOMMON_OBJS := \ + cityhash.o \ + zfeature_common.o \ + zfs_comutil.o \ + zfs_deleg.o \ + zfs_fletcher.o \ + zfs_fletcher_superscalar.o \ + zfs_fletcher_superscalar4.o \ + zfs_namecheck.o \ + zfs_prop.o \ + zpool_prop.o \ + zprop_common.o + +ZCOMMON_OBJS_X86 := \ + zfs_fletcher_avx512.o \ + zfs_fletcher_intel.o \ + zfs_fletcher_sse.o + +ZCOMMON_OBJS_ARM64 := \ + zfs_fletcher_aarch64_neon.o + +zfs-objs += $(addprefix zcommon/,$(ZCOMMON_OBJS)) +zfs-$(CONFIG_X86) += $(addprefix zcommon/,$(ZCOMMON_OBJS_X86)) +zfs-$(CONFIG_ARM64) += $(addprefix zcommon/,$(ZCOMMON_OBJS_ARM64)) + + +# Zstd uses -O3 by default, so we should follow +ZFS_ZSTD_FLAGS := -O3 + +# -fno-tree-vectorize gets set for gcc in zstd/common/compiler.h +# Set it for other compilers, too. +ZFS_ZSTD_FLAGS += -fno-tree-vectorize + +# SSE register return with SSE disabled if -march=znverX is passed +ZFS_ZSTD_FLAGS += -U__BMI__ + +# Quiet warnings about frame size due to unused code in unmodified zstd lib +ZFS_ZSTD_FLAGS += -Wframe-larger-than=20480 + +ZSTD_OBJS := \ + zfs_zstd.o \ + zstd_sparc.o + +ZSTD_UPSTREAM_OBJS := \ + lib/common/entropy_common.o \ + lib/common/error_private.o \ + lib/common/fse_decompress.o \ + lib/common/pool.o \ + lib/common/zstd_common.o \ + lib/compress/fse_compress.o \ + lib/compress/hist.o \ + lib/compress/huf_compress.o \ + lib/compress/zstd_compress.o \ + lib/compress/zstd_compress_literals.o \ + lib/compress/zstd_compress_sequences.o \ + lib/compress/zstd_compress_superblock.o \ + lib/compress/zstd_double_fast.o \ + lib/compress/zstd_fast.o \ + lib/compress/zstd_lazy.o \ + lib/compress/zstd_ldm.o \ + lib/compress/zstd_opt.o \ + lib/decompress/huf_decompress.o \ + lib/decompress/zstd_ddict.o \ + lib/decompress/zstd_decompress.o \ + lib/decompress/zstd_decompress_block.o + +zfs-objs += $(addprefix zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) + +# Disable aarch64 neon SIMD instructions for kernel mode +$(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -I$(zstd_include) $(ZFS_ZSTD_FLAGS) +$(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : asflags-y += -I$(zstd_include) +$(addprefix $(obj)/zstd/,$(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -include $(zstd_include)/aarch64_compat.h -include $(zstd_include)/zstd_compat_wrapper.h -Wp,-w +$(obj)/zstd/zfs_zstd.o : ccflags-y += -include $(zstd_include)/zstd_compat_wrapper.h + + +ZFS_OBJS := \ + abd.o \ + aggsum.o \ + arc.o \ + blkptr.o \ + bplist.o \ + bpobj.o \ + bptree.o \ + bqueue.o \ + btree.o \ + dataset_kstats.o \ + dbuf.o \ + dbuf_stats.o \ + ddt.o \ + ddt_zap.o \ + dmu.o \ + dmu_diff.o \ + dmu_object.o \ + dmu_objset.o \ + dmu_recv.o \ + dmu_redact.o \ + dmu_send.o \ + dmu_traverse.o \ + dmu_tx.o \ + dmu_zfetch.o \ + dnode.o \ + dnode_sync.o \ + dsl_bookmark.o \ + dsl_crypt.o \ + dsl_dataset.o \ + dsl_deadlist.o \ + dsl_deleg.o \ + dsl_destroy.o \ + dsl_dir.o \ + dsl_pool.o \ + dsl_prop.o \ + dsl_scan.o \ + dsl_synctask.o \ + dsl_userhold.o \ + edonr_zfs.o \ + fm.o \ + gzip.o \ + hkdf.o \ + lz4.o \ + lz4_zfs.o \ + lzjb.o \ + metaslab.o \ + mmp.o \ + multilist.o \ + objlist.o \ + pathname.o \ + range_tree.o \ + refcount.o \ + rrwlock.o \ + sa.o \ + sha256.o \ + skein_zfs.o \ + spa.o \ + spa_boot.o \ + spa_checkpoint.o \ + spa_config.o \ + spa_errlog.o \ + spa_history.o \ + spa_log_spacemap.o \ + spa_misc.o \ + spa_stats.o \ + space_map.o \ + space_reftree.o \ + txg.o \ + uberblock.o \ + unique.o \ + vdev.o \ + vdev_cache.o \ + vdev_draid.o \ + vdev_draid_rand.o \ + vdev_indirect.o \ + vdev_indirect_births.o \ + vdev_indirect_mapping.o \ + vdev_initialize.o \ + vdev_label.o \ + vdev_mirror.o \ + vdev_missing.o \ + vdev_queue.o \ + vdev_raidz.o \ + vdev_raidz_math.o \ + vdev_raidz_math_scalar.o \ + vdev_rebuild.o \ + vdev_removal.o \ + vdev_root.o \ + vdev_trim.o \ + zap.o \ + zap_leaf.o \ + zap_micro.o \ + zcp.o \ + zcp_get.o \ + zcp_global.o \ + zcp_iter.o \ + zcp_set.o \ + zcp_synctask.o \ + zfeature.o \ + zfs_byteswap.o \ + zfs_fm.o \ + zfs_fuid.o \ + zfs_ioctl.o \ + zfs_log.o \ + zfs_onexit.o \ + zfs_quota.o \ + zfs_ratelimit.o \ + zfs_replay.o \ + zfs_rlock.o \ + zfs_sa.o \ + zfs_vnops.o \ + zil.o \ + zio.o \ + zio_checksum.o \ + zio_compress.o \ + zio_inject.o \ + zle.o \ + zrlock.o \ + zthr.o \ + zvol.o + +ZFS_OBJS_OS := \ + abd_os.o \ + arc_os.o \ + mmp_os.o \ + policy.o \ + qat.o \ + qat_compress.o \ + qat_crypt.o \ + spa_misc_os.o \ + trace.o \ + vdev_disk.o \ + vdev_file.o \ + zfs_acl.o \ + zfs_ctldir.o \ + zfs_debug.o \ + zfs_dir.o \ + zfs_file_os.o \ + zfs_ioctl_os.o \ + zfs_racct.o \ + zfs_sysfs.o \ + zfs_uio.o \ + zfs_vfsops.o \ + zfs_vnops_os.o \ + zfs_znode.o \ + zio_crypt.o \ + zpl_ctldir.o \ + zpl_export.o \ + zpl_file.o \ + zpl_inode.o \ + zpl_super.o \ + zpl_xattr.o \ + zvol_os.o + +ZFS_OBJS_X86 := \ + vdev_raidz_math_avx2.o \ + vdev_raidz_math_avx512bw.o \ + vdev_raidz_math_avx512f.o \ + vdev_raidz_math_sse2.o \ + vdev_raidz_math_ssse3.o + +ZFS_OBJS_ARM64 := \ + vdev_raidz_math_aarch64_neon.o \ + vdev_raidz_math_aarch64_neonx2.o + +ZFS_OBJS_PPC_PPC64 := \ + vdev_raidz_math_powerpc_altivec.o + +zfs-objs += $(addprefix zfs/,$(ZFS_OBJS)) $(addprefix os/linux/zfs/,$(ZFS_OBJS_OS)) +zfs-$(CONFIG_X86) += $(addprefix zfs/,$(ZFS_OBJS_X86)) +zfs-$(CONFIG_ARM64) += $(addprefix zfs/,$(ZFS_OBJS_ARM64)) +zfs-$(CONFIG_PPC) += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64)) +zfs-$(CONFIG_PPC64) += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64)) + +# Suppress incorrect warnings from versions of objtool which are not +# aware of x86 EVEX prefix instructions used for AVX512. +OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512bw.o := y +OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512f.o := y + +ifeq ($(CONFIG_ALTIVEC),y) +$(obj)/zfs/vdev_raidz_math_powerpc_altivec.o : c_flags += -maltivec endif diff --git a/sys/contrib/openzfs/module/Makefile.in b/sys/contrib/openzfs/module/Makefile.in index 762f9394dd20..5b71e1abf79e 100644 --- a/sys/contrib/openzfs/module/Makefile.in +++ b/sys/contrib/openzfs/module/Makefile.in @@ -3,19 +3,19 @@ include Kbuild INSTALL_MOD_DIR ?= extra INSTALL_MOD_PATH ?= $(DESTDIR) -SUBDIR_TARGETS = icp lua zstd - all: modules distclean maintainer-clean: clean -install: modules_install -uninstall: modules_uninstall +install: modules_install data_install +uninstall: modules_uninstall data_uninstall check: .PHONY: all distclean maintainer-clean install uninstall check distdir \ modules modules-Linux modules-FreeBSD modules-unknown \ clean clean-Linux clean-FreeBSD \ modules_install modules_install-Linux modules_install-FreeBSD \ + data_install data_install-Linux data_install-FreeBSD \ modules_uninstall modules_uninstall-Linux modules_uninstall-FreeBSD \ + data_uninstall data_uninstall-Linux data_uninstall-FreeBSD \ cppcheck cppcheck-Linux cppcheck-FreeBSD # For FreeBSD, use debug options from ./configure if not overridden. @@ -51,7 +51,8 @@ endif FMAKE = env -u MAKEFLAGS make $(FMAKEFLAGS) modules-Linux: - list='$(SUBDIR_TARGETS)'; for td in $$list; do $(MAKE) -C $$td; done + mkdir -p $(sort $(dir $(spl-objs) $(spl-))) + mkdir -p $(sort $(dir $(zfs-objs) $(zfs-))) $(MAKE) -C @LINUX_OBJ@ $(if @KERNEL_CC@,CC=@KERNEL_CC@) \ $(if @KERNEL_LD@,LD=@KERNEL_LD@) $(if @KERNEL_LLVM@,LLVM=@KERNEL_LLVM@) \ M="$$PWD" @KERNEL_MAKE@ CONFIG_ZFS=m modules @@ -77,16 +78,20 @@ clean-FreeBSD: clean: clean-@ac_system@ -modules_install-Linux: +.PHONY: modules_uninstall-Linux-legacy +modules_uninstall-Linux-legacy: + $(RM) -r $(addprefix $(KMODDIR)/$(INSTALL_MOD_DIR)/,spl/ avl/ icp/ lua/ nvpair/ unicode/ zcommon/ zfs/ zstd/) + +KMODDIR := $(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@ +modules_install-Linux: modules_uninstall-Linux-legacy @# Install the kernel modules $(MAKE) -C @LINUX_OBJ@ M="$$PWD" modules_install \ INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) \ INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \ KERNELRELEASE=@LINUX_VERSION@ @# Remove extraneous build products when packaging - kmoddir=$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \ if [ -n "$(DESTDIR)" ]; then \ - find $$kmoddir -name 'modules.*' -delete; \ + find $(KMODDIR) -name 'modules.*' -delete; \ fi @# Debian ships tiny fake System.map files that are @# syntactically valid but just say @@ -107,18 +112,32 @@ modules_install-FreeBSD: modules_install: modules_install-@ac_system@ -modules_uninstall-Linux: +data_install-Linux: + @mkdir -p $(DESTDIR)/@prefix@/src/zfs-@VERSION@/@LINUX_VERSION@ + cp ../zfs.release ../zfs_config.h @LINUX_SYMBOLS@ $(DESTDIR)/@prefix@/src/zfs-@VERSION@/@LINUX_VERSION@ + +data_install-FreeBSD: + @ + +data_install: data_install-@ac_system@ + +modules_uninstall-Linux: modules_uninstall-Linux-legacy @# Uninstall the kernel modules - kmoddir=$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \ - for objdir in $(ZFS_MODULES); do \ - $(RM) -R $$kmoddir/$(INSTALL_MOD_DIR)/$$objdir; \ - done + $(RM) $(addprefix $(KMODDIR)/$(INSTALL_MOD_DIR)/,zfs.ko spl.ko) modules_uninstall-FreeBSD: @false modules_uninstall: modules_uninstall-@ac_system@ +data_uninstall-Linux: + $(RM) $(addprefix $(DESTDIR)/@prefix@/src/zfs-@VERSION@/@LINUX_VERSION@/,zfs.release zfs_config.h @LINUX_SYMBOLS@) + +data_uninstall-FreeBSD: + @ + +data_uninstall: data_uninstall-@ac_system@ + cppcheck-Linux: @CPPCHECK@ -j@CPU_COUNT@ --std=c99 --quiet --force --error-exitcode=2 \ --inline-suppr \ @@ -126,7 +145,7 @@ cppcheck-Linux: --suppress=noValidConfiguration \ --enable=warning,information -D_KERNEL \ --include=@LINUX_OBJ@/include/generated/autoconf.h \ - --include=@top_srcdir@/zfs_config.h \ + --include=@top_builddir@/zfs_config.h \ --config-exclude=@LINUX_OBJ@/include \ -i zstd/lib \ -I @LINUX_OBJ@/include \ @@ -134,7 +153,7 @@ cppcheck-Linux: -I @top_srcdir@/include/os/linux/spl \ -I @top_srcdir@/include/os/linux/zfs \ -I @top_srcdir@/include \ - avl icp lua nvpair spl unicode zcommon zfs zstd os/linux + avl icp lua nvpair unicode zcommon zfs zstd os/linux cppcheck-FreeBSD: @true @@ -142,9 +161,11 @@ cppcheck-FreeBSD: cppcheck: cppcheck-@ac_system@ distdir: - (cd @srcdir@ && find $(ZFS_MODULES) os -name '*.[chS]') | \ - while read path; do \ - mkdir -p $$distdir/$${path%/*}; \ - cp @srcdir@/$$path $$distdir/$$path; \ - done; \ + cd @srcdir@ && find . -name '*.[chS]' -exec sh -c 'for f; do mkdir -p $$distdir/$${f%/*}; cp @srcdir@/$$f $$distdir/$$f; done' _ {} + cp @srcdir@/Makefile.bsd $$distdir/Makefile.bsd + +gen-zstd-symbols: + for obj in $(addprefix zstd/,$(ZSTD_UPSTREAM_OBJS)); do echo; echo "/* $${obj#zstd/}: */"; @OBJDUMP@ -t $$obj | awk '$$2 == "g" && !/ zfs_/ {print "#define\t" $$6 " zfs_" $$6}' | sort; done >> zstd/include/zstd_compat_wrapper.h + +check-zstd-symbols: + @OBJDUMP@ -t $(addprefix zstd/,$(ZSTD_UPSTREAM_OBJS)) | awk '/file format/ {print} $$2 == "g" && !/ zfs_/ {++ret; print} END {exit ret}' diff --git a/sys/contrib/openzfs/module/avl/Makefile.in b/sys/contrib/openzfs/module/avl/Makefile.in deleted file mode 100644 index 991d5f95b8c0..000000000000 --- a/sys/contrib/openzfs/module/avl/Makefile.in +++ /dev/null @@ -1,10 +0,0 @@ -ifneq ($(KBUILD_EXTMOD),) -src = @abs_srcdir@ -obj = @abs_builddir@ -endif - -MODULE := zavl - -obj-$(CONFIG_ZFS) := $(MODULE).o - -$(MODULE)-objs += avl.o diff --git a/sys/contrib/openzfs/module/avl/avl.c b/sys/contrib/openzfs/module/avl/avl.c index 3891a2d62880..69cb8bf6815b 100644 --- a/sys/contrib/openzfs/module/avl/avl.c +++ b/sys/contrib/openzfs/module/avl/avl.c @@ -1044,28 +1044,6 @@ avl_destroy_nodes(avl_tree_t *tree, void **cookie) return (AVL_NODE2DATA(node, off)); } -#if defined(_KERNEL) - -static int __init -avl_init(void) -{ - return (0); -} - -static void __exit -avl_fini(void) -{ -} - -module_init(avl_init); -module_exit(avl_fini); -#endif - -ZFS_MODULE_DESCRIPTION("Generic AVL tree implementation"); -ZFS_MODULE_AUTHOR(ZFS_META_AUTHOR); -ZFS_MODULE_LICENSE(ZFS_META_LICENSE); -ZFS_MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); - EXPORT_SYMBOL(avl_create); EXPORT_SYMBOL(avl_find); EXPORT_SYMBOL(avl_insert); diff --git a/sys/contrib/openzfs/module/icp/Makefile.in b/sys/contrib/openzfs/module/icp/Makefile.in deleted file mode 100644 index 72c9ab12adb7..000000000000 --- a/sys/contrib/openzfs/module/icp/Makefile.in +++ /dev/null @@ -1,90 +0,0 @@ -ifneq ($(KBUILD_EXTMOD),) -src = @abs_srcdir@ -obj = @abs_builddir@ -icp_include = $(src)/include -else -icp_include = $(srctree)/$(src)/include -endif - -MODULE := icp - -obj-$(CONFIG_ZFS) := $(MODULE).o - -asflags-y := -I$(icp_include) -ccflags-y := -I$(icp_include) - -$(MODULE)-objs += illumos-crypto.o -$(MODULE)-objs += api/kcf_cipher.o -$(MODULE)-objs += api/kcf_mac.o -$(MODULE)-objs += api/kcf_ctxops.o -$(MODULE)-objs += core/kcf_callprov.o -$(MODULE)-objs += core/kcf_prov_tabs.o -$(MODULE)-objs += core/kcf_sched.o -$(MODULE)-objs += core/kcf_mech_tabs.o -$(MODULE)-objs += core/kcf_prov_lib.o -$(MODULE)-objs += spi/kcf_spi.o -$(MODULE)-objs += io/aes.o -$(MODULE)-objs += io/sha2_mod.o -$(MODULE)-objs += io/skein_mod.o -$(MODULE)-objs += algs/modes/cbc.o -$(MODULE)-objs += algs/modes/ccm.o -$(MODULE)-objs += algs/modes/ctr.o -$(MODULE)-objs += algs/modes/ecb.o -$(MODULE)-objs += algs/modes/gcm_generic.o -$(MODULE)-objs += algs/modes/gcm.o -$(MODULE)-objs += algs/modes/modes.o -$(MODULE)-objs += algs/aes/aes_impl_generic.o -$(MODULE)-objs += algs/aes/aes_impl.o -$(MODULE)-objs += algs/aes/aes_modes.o -$(MODULE)-objs += algs/edonr/edonr.o -$(MODULE)-objs += algs/sha2/sha2.o -$(MODULE)-objs += algs/skein/skein.o -$(MODULE)-objs += algs/skein/skein_block.o -$(MODULE)-objs += algs/skein/skein_iv.o - -$(MODULE)-$(CONFIG_X86_64) += asm-x86_64/aes/aeskey.o -$(MODULE)-$(CONFIG_X86_64) += asm-x86_64/aes/aes_amd64.o -$(MODULE)-$(CONFIG_X86_64) += asm-x86_64/aes/aes_aesni.o -$(MODULE)-$(CONFIG_X86_64) += asm-x86_64/modes/gcm_pclmulqdq.o -$(MODULE)-$(CONFIG_X86_64) += asm-x86_64/modes/aesni-gcm-x86_64.o -$(MODULE)-$(CONFIG_X86_64) += asm-x86_64/modes/ghash-x86_64.o -$(MODULE)-$(CONFIG_X86_64) += asm-x86_64/sha2/sha256_impl.o -$(MODULE)-$(CONFIG_X86_64) += asm-x86_64/sha2/sha512_impl.o - -$(MODULE)-$(CONFIG_X86) += algs/modes/gcm_pclmulqdq.o -$(MODULE)-$(CONFIG_X86) += algs/aes/aes_impl_aesni.o -$(MODULE)-$(CONFIG_X86) += algs/aes/aes_impl_x86-64.o - -# Suppress objtool "can't find jump dest instruction at" warnings. They -# are caused by the constants which are defined in the text section of the -# assembly file using .byte instructions (e.g. bswap_mask). The objtool -# utility tries to interpret them as opcodes and obviously fails doing so. -OBJECT_FILES_NON_STANDARD_aesni-gcm-x86_64.o := y -OBJECT_FILES_NON_STANDARD_ghash-x86_64.o := y -# Suppress objtool "unsupported stack pointer realignment" warnings. We are -# not using a DRAP register while aligning the stack to a 64 byte boundary. -# See #6950 for the reasoning. -OBJECT_FILES_NON_STANDARD_sha256_impl.o := y -OBJECT_FILES_NON_STANDARD_sha512_impl.o := y - -ICP_DIRS = \ - api \ - core \ - spi \ - io \ - os \ - algs \ - algs/aes \ - algs/edonr \ - algs/modes \ - algs/sha2 \ - algs/skein \ - asm-x86_64 \ - asm-x86_64/aes \ - asm-x86_64/modes \ - asm-x86_64/sha2 \ - asm-i386 \ - asm-generic - -all: - mkdir -p $(ICP_DIRS) diff --git a/sys/contrib/openzfs/module/icp/algs/edonr/edonr.c b/sys/contrib/openzfs/module/icp/algs/edonr/edonr.c index 6f3a43e263be..9388a6f6b7c9 100644 --- a/sys/contrib/openzfs/module/icp/algs/edonr/edonr.c +++ b/sys/contrib/openzfs/module/icp/algs/edonr/edonr.c @@ -47,10 +47,7 @@ #define hashState384(x) ((x)->pipe->p512) #define hashState512(x) ((x)->pipe->p512) -/* shift and rotate shortcuts */ -#define shl(x, n) ((x) << n) -#define shr(x, n) ((x) >> n) - +/* rotate shortcuts */ #define rotl32(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) #define rotr32(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) diff --git a/sys/contrib/openzfs/module/icp/algs/modes/gcm.c b/sys/contrib/openzfs/module/icp/algs/modes/gcm.c index e666b45b5f44..ee2100b7f425 100644 --- a/sys/contrib/openzfs/module/icp/algs/modes/gcm.c +++ b/sys/contrib/openzfs/module/icp/algs/modes/gcm.c @@ -806,7 +806,7 @@ static gcm_impl_ops_t *gcm_supp_impl[ARRAY_SIZE(gcm_all_impl)]; * fallback to the fastest generic implementation. */ const gcm_impl_ops_t * -gcm_impl_get_ops() +gcm_impl_get_ops(void) { if (!kfpu_allowed()) return (&gcm_generic_impl); diff --git a/sys/contrib/openzfs/module/icp/illumos-crypto.c b/sys/contrib/openzfs/module/icp/illumos-crypto.c index f68f6bc765a2..d17b90e7200a 100644 --- a/sys/contrib/openzfs/module/icp/illumos-crypto.c +++ b/sys/contrib/openzfs/module/icp/illumos-crypto.c @@ -104,7 +104,7 @@ * ZFS Makefiles. */ -void __exit +void icp_fini(void) { skein_mod_fini(); @@ -139,10 +139,7 @@ icp_init(void) return (0); } -#if defined(_KERNEL) +#if defined(_KERNEL) && defined(__FreeBSD__) module_exit(icp_fini); module_init(icp_init); -MODULE_AUTHOR(ZFS_META_AUTHOR); -MODULE_LICENSE(ZFS_META_LICENSE); -MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); #endif diff --git a/sys/contrib/openzfs/module/lua/Makefile.in b/sys/contrib/openzfs/module/lua/Makefile.in deleted file mode 100644 index 0a74c17e64e8..000000000000 --- a/sys/contrib/openzfs/module/lua/Makefile.in +++ /dev/null @@ -1,39 +0,0 @@ -ifneq ($(KBUILD_EXTMOD),) -src = @abs_srcdir@ -obj = @abs_builddir@ -endif - -MODULE := zlua - -obj-$(CONFIG_ZFS) := $(MODULE).o - -ccflags-y := -DLUA_USE_LONGLONG - -$(MODULE)-objs += lapi.o -$(MODULE)-objs += lauxlib.o -$(MODULE)-objs += lbaselib.o -$(MODULE)-objs += lcode.o -$(MODULE)-objs += lcompat.o -$(MODULE)-objs += lcorolib.o -$(MODULE)-objs += lctype.o -$(MODULE)-objs += ldebug.o -$(MODULE)-objs += ldo.o -$(MODULE)-objs += lfunc.o -$(MODULE)-objs += lgc.o -$(MODULE)-objs += llex.o -$(MODULE)-objs += lmem.o -$(MODULE)-objs += lobject.o -$(MODULE)-objs += lopcodes.o -$(MODULE)-objs += lparser.o -$(MODULE)-objs += lstate.o -$(MODULE)-objs += lstring.o -$(MODULE)-objs += lstrlib.o -$(MODULE)-objs += ltable.o -$(MODULE)-objs += ltablib.o -$(MODULE)-objs += ltm.o -$(MODULE)-objs += lvm.o -$(MODULE)-objs += lzio.o -$(MODULE)-objs += setjmp/setjmp.o - -all: - mkdir -p setjmp diff --git a/sys/contrib/openzfs/module/lua/lapi.c b/sys/contrib/openzfs/module/lua/lapi.c index 72b0037aa9a9..726e5c2ad4bb 100644 --- a/sys/contrib/openzfs/module/lua/lapi.c +++ b/sys/contrib/openzfs/module/lua/lapi.c @@ -1278,29 +1278,6 @@ LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1, luaC_objbarrier(L, f1, *up2); } -#if defined(_KERNEL) - -static int __init -lua_init(void) -{ - return (0); -} - -static void __exit -lua_fini(void) -{ -} - -module_init(lua_init); -module_exit(lua_fini); - -#endif - -ZFS_MODULE_DESCRIPTION("Lua Interpreter for ZFS"); -ZFS_MODULE_AUTHOR("Lua.org"); -ZFS_MODULE_LICENSE("Dual MIT/GPL"); -ZFS_MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); - EXPORT_SYMBOL(lua_absindex); EXPORT_SYMBOL(lua_atpanic); EXPORT_SYMBOL(lua_checkstack); diff --git a/sys/contrib/openzfs/module/nvpair/Makefile.in b/sys/contrib/openzfs/module/nvpair/Makefile.in deleted file mode 100644 index d8145236674b..000000000000 --- a/sys/contrib/openzfs/module/nvpair/Makefile.in +++ /dev/null @@ -1,13 +0,0 @@ -ifneq ($(KBUILD_EXTMOD),) -src = @abs_srcdir@ -obj = @abs_builddir@ -endif - -MODULE := znvpair - -obj-$(CONFIG_ZFS) := $(MODULE).o - -$(MODULE)-objs += nvpair.o -$(MODULE)-objs += fnvpair.o -$(MODULE)-objs += nvpair_alloc_spl.o -$(MODULE)-objs += nvpair_alloc_fixed.o diff --git a/sys/contrib/openzfs/module/nvpair/nvpair.c b/sys/contrib/openzfs/module/nvpair/nvpair.c index a5222dac7849..a442990dade0 100644 --- a/sys/contrib/openzfs/module/nvpair/nvpair.c +++ b/sys/contrib/openzfs/module/nvpair/nvpair.c @@ -3678,27 +3678,6 @@ nvs_xdr(nvstream_t *nvs, nvlist_t *nvl, char *buf, size_t *buflen) return (err); } -#if defined(_KERNEL) -static int __init -nvpair_init(void) -{ - return (0); -} - -static void __exit -nvpair_fini(void) -{ -} - -module_init(nvpair_init); -module_exit(nvpair_fini); -#endif - -ZFS_MODULE_DESCRIPTION("Generic name/value pair implementation"); -ZFS_MODULE_AUTHOR(ZFS_META_AUTHOR); -ZFS_MODULE_LICENSE(ZFS_META_LICENSE); -ZFS_MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); - EXPORT_SYMBOL(nv_alloc_init); EXPORT_SYMBOL(nv_alloc_reset); EXPORT_SYMBOL(nv_alloc_fini); diff --git a/sys/contrib/openzfs/module/os/freebsd/spl/spl_misc.c b/sys/contrib/openzfs/module/os/freebsd/spl/spl_misc.c index 0354b986cd5f..e46271a039de 100644 --- a/sys/contrib/openzfs/module/os/freebsd/spl/spl_misc.c +++ b/sys/contrib/openzfs/module/os/freebsd/spl/spl_misc.c @@ -43,15 +43,11 @@ static struct opensolaris_utsname hw_utsname = { .machine = MACHINE }; -#ifndef KERNEL_STATIC -char hw_serial[11] = "0"; - utsname_t * utsname(void) { return (&hw_utsname); } -#endif static void opensolaris_utsname_init(void *arg) diff --git a/sys/contrib/openzfs/module/os/freebsd/spl/spl_sunddi.c b/sys/contrib/openzfs/module/os/freebsd/spl/spl_sunddi.c index ebec77bdb37f..2a3c027c9389 100644 --- a/sys/contrib/openzfs/module/os/freebsd/spl/spl_sunddi.c +++ b/sys/contrib/openzfs/module/os/freebsd/spl/spl_sunddi.c @@ -45,19 +45,6 @@ ddi_strtol(const char *str, char **nptr, int base, long *result) return (0); } -int -ddi_strtoul(const char *str, char **nptr, int base, unsigned long *result) -{ - - if (str == hw_serial) { - *result = prison0.pr_hostid; - return (0); - } - - *result = strtoul(str, nptr, base); - return (0); -} - int ddi_strtoull(const char *str, char **nptr, int base, unsigned long long *result) { diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/vdev_geom.c b/sys/contrib/openzfs/module/os/freebsd/zfs/vdev_geom.c index 914e0e6ded66..1ac41f616a0d 100644 --- a/sys/contrib/openzfs/module/os/freebsd/zfs/vdev_geom.c +++ b/sys/contrib/openzfs/module/os/freebsd/zfs/vdev_geom.c @@ -1131,8 +1131,12 @@ vdev_geom_fill_unmap_cb(void *buf, size_t len, void *priv) vm_offset_t addr = (vm_offset_t)buf; vm_offset_t end = addr + len; - if (bp->bio_ma_n == 0) + if (bp->bio_ma_n == 0) { bp->bio_ma_offset = addr & PAGE_MASK; + addr &= ~PAGE_MASK; + } else { + ASSERT0(P2PHASE(addr, PAGE_SIZE)); + } do { bp->bio_ma[bp->bio_ma_n++] = PHYS_TO_VM_PAGE(pmap_kextract(addr)); diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c index e33aaea481b1..e57855770293 100644 --- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c +++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c @@ -97,6 +97,10 @@ VFS_SMR_DECLARE; +#if __FreeBSD_version < 1300103 +#define NDFREE_PNBUF(ndp) NDFREE((ndp), NDF_ONLY_PNBUF) +#endif + #if __FreeBSD_version >= 1300047 #define vm_page_wire_lock(pp) #define vm_page_wire_unlock(pp) @@ -237,7 +241,7 @@ zfs_open(vnode_t **vpp, int flag, cred_t *cr) } /* Keep a count of the synchronous opens in the znode */ - if (flag & (FSYNC | FDSYNC)) + if (flag & O_SYNC) atomic_inc_32(&zp->z_sync_cnt); ZFS_EXIT(zfsvfs); @@ -255,7 +259,7 @@ zfs_close(vnode_t *vp, int flag, int count, offset_t offset, cred_t *cr) ZFS_VERIFY_ZP(zp); /* Decrement the synchronous opens in the znode */ - if ((flag & (FSYNC | FDSYNC)) && (count == 1)) + if ((flag & O_SYNC) && (count == 1)) atomic_dec_32(&zp->z_sync_cnt); ZFS_EXIT(zfsvfs); @@ -4036,8 +4040,8 @@ zfs_getpages(struct vnode *vp, vm_page_t *ma, int count, int *rbehind, int pgsin_b, pgsin_a; int error; - ZFS_ENTER(zfsvfs); - ZFS_VERIFY_ZP(zp); + ZFS_ENTER_ERROR(zfsvfs, zfs_vm_pagerret_error); + ZFS_VERIFY_ZP_ERROR(zp, zfs_vm_pagerret_error); start = IDX_TO_OFF(ma[0]->pindex); end = IDX_TO_OFF(ma[count - 1]->pindex + 1); @@ -4161,19 +4165,18 @@ zfs_putpages(struct vnode *vp, vm_page_t *ma, size_t len, int flags, int err; int i; - ZFS_ENTER(zfsvfs); - ZFS_VERIFY_ZP(zp); - object = vp->v_object; - pcount = btoc(len); - ncount = pcount; - KASSERT(ma[0]->object == object, ("mismatching object")); KASSERT(len > 0 && (len & PAGE_MASK) == 0, ("unexpected length")); + pcount = btoc(len); + ncount = pcount; for (i = 0; i < pcount; i++) rtvals[i] = zfs_vm_pagerret_error; + ZFS_ENTER_ERROR(zfsvfs, zfs_vm_pagerret_error); + ZFS_VERIFY_ZP_ERROR(zp, zfs_vm_pagerret_error); + off = IDX_TO_OFF(ma[0]->pindex); blksz = zp->z_blksz; lo_off = rounddown(off, blksz); @@ -4399,11 +4402,11 @@ ioflags(int ioflags) int flags = 0; if (ioflags & IO_APPEND) - flags |= FAPPEND; + flags |= O_APPEND; if (ioflags & IO_NDELAY) - flags |= FNONBLOCK; + flags |= O_NONBLOCK; if (ioflags & IO_SYNC) - flags |= (FSYNC | FDSYNC | FRSYNC); + flags |= O_SYNC; return (flags); } @@ -4624,7 +4627,7 @@ zfs_freebsd_create(struct vop_create_args *ap) zfsvfs = ap->a_dvp->v_mount->mnt_data; *ap->a_vpp = NULL; - rc = zfs_create(VTOZ(ap->a_dvp), cnp->cn_nameptr, vap, !EXCL, mode, + rc = zfs_create(VTOZ(ap->a_dvp), cnp->cn_nameptr, vap, 0, mode, &zp, cnp->cn_cred, 0 /* flag */, NULL /* vsecattr */); if (rc == 0) *ap->a_vpp = ZTOV(zp); @@ -5447,7 +5450,7 @@ zfs_getextattr(struct vop_getextattr_args *ap) error = ENOENT; ZFS_ENTER(zfsvfs); - ZFS_VERIFY_ZP(zp) + ZFS_VERIFY_ZP(zp); rw_enter(&zp->z_xattr_lock, RW_READER); error = zfs_getextattr_impl(ap, zfs_xattr_compat); diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_znode.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_znode.c index 2496d6897d9a..877b7187b676 100644 --- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_znode.c +++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_znode.c @@ -153,6 +153,9 @@ zfs_znode_cache_constructor(void *buf, void *arg, int kmflags) zp->z_xattr_cached = NULL; zp->z_xattr_parent = 0; zp->z_vnode = NULL; + zp->z_sync_writes_cnt = 0; + zp->z_async_writes_cnt = 0; + return (0); } @@ -172,6 +175,9 @@ zfs_znode_cache_destructor(void *buf, void *arg) ASSERT3P(zp->z_acl_cached, ==, NULL); ASSERT3P(zp->z_xattr_cached, ==, NULL); + + ASSERT0(atomic_load_32(&zp->z_sync_writes_cnt)); + ASSERT0(atomic_load_32(&zp->z_async_writes_cnt)); } @@ -453,6 +459,8 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz, zp->z_blksz = blksz; zp->z_seq = 0x7A4653; zp->z_sync_cnt = 0; + zp->z_sync_writes_cnt = 0; + zp->z_async_writes_cnt = 0; #if __FreeBSD_version >= 1300139 atomic_store_ptr(&zp->z_cached_symlink, NULL); #endif diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zvol_os.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zvol_os.c index 487778472e79..1011aaf68ac6 100644 --- a/sys/contrib/openzfs/module/os/freebsd/zfs/zvol_os.c +++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zvol_os.c @@ -311,15 +311,13 @@ zvol_geom_open(struct g_provider *pp, int flag, int count) err = SET_ERROR(EBUSY); goto out_opened; } -#ifdef FEXCL - if (flag & FEXCL) { + if (flag & O_EXCL) { if (zv->zv_open_count != 0) { err = SET_ERROR(EBUSY); goto out_opened; } zv->zv_flags |= ZVOL_EXCL; } -#endif zv->zv_open_count += count; out_opened: @@ -952,18 +950,16 @@ zvol_cdev_open(struct cdev *dev, int flags, int fmt, struct thread *td) err = SET_ERROR(EBUSY); goto out_opened; } -#ifdef FEXCL - if (flags & FEXCL) { + if (flags & O_EXCL) { if (zv->zv_open_count != 0) { err = SET_ERROR(EBUSY); goto out_opened; } zv->zv_flags |= ZVOL_EXCL; } -#endif zv->zv_open_count++; - if (flags & (FSYNC | FDSYNC)) { + if (flags & O_SYNC) { zsd = &zv->zv_zso->zso_dev; zsd->zsd_sync_cnt++; if (zsd->zsd_sync_cnt == 1 && @@ -1037,7 +1033,7 @@ zvol_cdev_close(struct cdev *dev, int flags, int fmt, struct thread *td) * You may get multiple opens, but only one close. */ zv->zv_open_count--; - if (flags & (FSYNC | FDSYNC)) { + if (flags & O_SYNC) { zsd = &zv->zv_zso->zso_dev; zsd->zsd_sync_cnt--; } diff --git a/sys/contrib/openzfs/module/os/linux/spl/Makefile.in b/sys/contrib/openzfs/module/os/linux/spl/Makefile.in deleted file mode 100644 index b2325f91b4a7..000000000000 --- a/sys/contrib/openzfs/module/os/linux/spl/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -$(MODULE)-objs += ../os/linux/spl/spl-atomic.o -$(MODULE)-objs += ../os/linux/spl/spl-condvar.o -$(MODULE)-objs += ../os/linux/spl/spl-cred.o -$(MODULE)-objs += ../os/linux/spl/spl-err.o -$(MODULE)-objs += ../os/linux/spl/spl-generic.o -$(MODULE)-objs += ../os/linux/spl/spl-kmem.o -$(MODULE)-objs += ../os/linux/spl/spl-kmem-cache.o -$(MODULE)-objs += ../os/linux/spl/spl-kstat.o -$(MODULE)-objs += ../os/linux/spl/spl-proc.o -$(MODULE)-objs += ../os/linux/spl/spl-procfs-list.o -$(MODULE)-objs += ../os/linux/spl/spl-taskq.o -$(MODULE)-objs += ../os/linux/spl/spl-thread.o -$(MODULE)-objs += ../os/linux/spl/spl-trace.o -$(MODULE)-objs += ../os/linux/spl/spl-tsd.o -$(MODULE)-objs += ../os/linux/spl/spl-vmem.o -$(MODULE)-objs += ../os/linux/spl/spl-xdr.o -$(MODULE)-objs += ../os/linux/spl/spl-zlib.o diff --git a/sys/contrib/openzfs/module/os/linux/spl/spl-generic.c b/sys/contrib/openzfs/module/os/linux/spl/spl-generic.c index cc9a973fef62..f99a2f966660 100644 --- a/sys/contrib/openzfs/module/os/linux/spl/spl-generic.c +++ b/sys/contrib/openzfs/module/os/linux/spl/spl-generic.c @@ -425,22 +425,33 @@ EXPORT_SYMBOL(__aeabi_ldivmod); * functions against their Solaris counterparts. It is possible that I * may have misinterpreted the man page or the man page is incorrect. */ -int ddi_strtoul(const char *, char **, int, unsigned long *); int ddi_strtol(const char *, char **, int, long *); int ddi_strtoull(const char *, char **, int, unsigned long long *); int ddi_strtoll(const char *, char **, int, long long *); -#define define_ddi_strtoux(type, valtype) \ -int ddi_strtou##type(const char *str, char **endptr, \ +#define define_ddi_strtox(type, valtype) \ +int ddi_strto##type(const char *str, char **endptr, \ int base, valtype *result) \ { \ valtype last_value, value = 0; \ char *ptr = (char *)str; \ - int flag = 1, digit; \ + int digit, minus = 0; \ + \ + while (strchr(" \t\n\r\f", *ptr)) \ + ++ptr; \ \ if (strlen(ptr) == 0) \ return (EINVAL); \ \ + switch (*ptr) { \ + case '-': \ + minus = 1; \ + zfs_fallthrough; \ + case '+': \ + ++ptr; \ + break; \ + } \ + \ /* Auto-detect base based on prefix */ \ if (!base) { \ if (str[0] == '0') { \ @@ -474,46 +485,21 @@ int ddi_strtou##type(const char *str, char **endptr, \ if (last_value > value) /* Overflow */ \ return (ERANGE); \ \ - flag = 1; \ ptr++; \ } \ \ - if (flag) \ - *result = value; \ + *result = minus ? -value : value; \ \ if (endptr) \ - *endptr = (char *)(flag ? ptr : str); \ + *endptr = ptr; \ \ return (0); \ } \ -#define define_ddi_strtox(type, valtype) \ -int ddi_strto##type(const char *str, char **endptr, \ - int base, valtype *result) \ -{ \ - int rc; \ - \ - if (*str == '-') { \ - rc = ddi_strtou##type(str + 1, endptr, base, result); \ - if (!rc) { \ - if (*endptr == str + 1) \ - *endptr = (char *)str; \ - else \ - *result = -*result; \ - } \ - } else { \ - rc = ddi_strtou##type(str, endptr, base, result); \ - } \ - \ - return (rc); \ -} - -define_ddi_strtoux(l, unsigned long) define_ddi_strtox(l, long) -define_ddi_strtoux(ll, unsigned long long) +define_ddi_strtox(ull, unsigned long long) define_ddi_strtox(ll, long long) -EXPORT_SYMBOL(ddi_strtoul); EXPORT_SYMBOL(ddi_strtol); EXPORT_SYMBOL(ddi_strtoll); EXPORT_SYMBOL(ddi_strtoull); @@ -828,7 +814,7 @@ spl_fini(void) module_init(spl_init); module_exit(spl_fini); -ZFS_MODULE_DESCRIPTION("Solaris Porting Layer"); -ZFS_MODULE_AUTHOR(ZFS_META_AUTHOR); -ZFS_MODULE_LICENSE("GPL"); -ZFS_MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); +MODULE_DESCRIPTION("Solaris Porting Layer"); +MODULE_AUTHOR(ZFS_META_AUTHOR); +MODULE_LICENSE("GPL"); +MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); diff --git a/sys/contrib/openzfs/module/os/linux/spl/spl-kmem-cache.c b/sys/contrib/openzfs/module/os/linux/spl/spl-kmem-cache.c index bb2b56880646..33aaad653dc8 100644 --- a/sys/contrib/openzfs/module/os/linux/spl/spl-kmem-cache.c +++ b/sys/contrib/openzfs/module/os/linux/spl/spl-kmem-cache.c @@ -1420,7 +1420,7 @@ EXPORT_SYMBOL(spl_kmem_cache_reap_now); * it should do no harm. */ int -spl_kmem_cache_reap_active() +spl_kmem_cache_reap_active(void) { return (0); } diff --git a/sys/contrib/openzfs/module/os/linux/zfs/Makefile.in b/sys/contrib/openzfs/module/os/linux/zfs/Makefile.in deleted file mode 100644 index fa990776db83..000000000000 --- a/sys/contrib/openzfs/module/os/linux/zfs/Makefile.in +++ /dev/null @@ -1,38 +0,0 @@ -# -# Linux specific sources included from module/zfs/Makefile.in -# - -# Suppress unused-value warnings in sparc64 architecture headers -ccflags-$(CONFIG_SPARC64) += -Wno-unused-value - -$(MODULE)-objs += ../os/linux/zfs/abd_os.o -$(MODULE)-objs += ../os/linux/zfs/arc_os.o -$(MODULE)-objs += ../os/linux/zfs/mmp_os.o -$(MODULE)-objs += ../os/linux/zfs/policy.o -$(MODULE)-objs += ../os/linux/zfs/trace.o -$(MODULE)-objs += ../os/linux/zfs/qat.o -$(MODULE)-objs += ../os/linux/zfs/qat_compress.o -$(MODULE)-objs += ../os/linux/zfs/qat_crypt.o -$(MODULE)-objs += ../os/linux/zfs/spa_misc_os.o -$(MODULE)-objs += ../os/linux/zfs/vdev_disk.o -$(MODULE)-objs += ../os/linux/zfs/vdev_file.o -$(MODULE)-objs += ../os/linux/zfs/zfs_acl.o -$(MODULE)-objs += ../os/linux/zfs/zfs_ctldir.o -$(MODULE)-objs += ../os/linux/zfs/zfs_debug.o -$(MODULE)-objs += ../os/linux/zfs/zfs_dir.o -$(MODULE)-objs += ../os/linux/zfs/zfs_file_os.o -$(MODULE)-objs += ../os/linux/zfs/zfs_ioctl_os.o -$(MODULE)-objs += ../os/linux/zfs/zfs_racct.o -$(MODULE)-objs += ../os/linux/zfs/zfs_sysfs.o -$(MODULE)-objs += ../os/linux/zfs/zfs_uio.o -$(MODULE)-objs += ../os/linux/zfs/zfs_vfsops.o -$(MODULE)-objs += ../os/linux/zfs/zfs_vnops_os.o -$(MODULE)-objs += ../os/linux/zfs/zfs_znode.o -$(MODULE)-objs += ../os/linux/zfs/zio_crypt.o -$(MODULE)-objs += ../os/linux/zfs/zpl_ctldir.o -$(MODULE)-objs += ../os/linux/zfs/zpl_export.o -$(MODULE)-objs += ../os/linux/zfs/zpl_file.o -$(MODULE)-objs += ../os/linux/zfs/zpl_inode.o -$(MODULE)-objs += ../os/linux/zfs/zpl_super.o -$(MODULE)-objs += ../os/linux/zfs/zpl_xattr.o -$(MODULE)-objs += ../os/linux/zfs/zvol_os.o diff --git a/sys/contrib/openzfs/module/os/linux/zfs/abd_os.c b/sys/contrib/openzfs/module/os/linux/zfs/abd_os.c index 688458621b93..0cd4fa5213d4 100644 --- a/sys/contrib/openzfs/module/os/linux/zfs/abd_os.c +++ b/sys/contrib/openzfs/module/os/linux/zfs/abd_os.c @@ -620,7 +620,6 @@ abd_alloc_zero_scatter(void) ABD_SCATTER(abd_zero_scatter).abd_offset = 0; ABD_SCATTER(abd_zero_scatter).abd_nents = nr_pages; abd_zero_scatter->abd_size = SPA_MAXBLOCKSIZE; - zfs_refcount_create(&abd_zero_scatter->abd_children); ABD_SCATTER(abd_zero_scatter).abd_sgl = vmem_alloc(nr_pages * sizeof (struct scatterlist), KM_SLEEP); diff --git a/sys/contrib/openzfs/module/os/linux/zfs/vdev_disk.c b/sys/contrib/openzfs/module/os/linux/zfs/vdev_disk.c index 6cec5be44012..235cd1691c14 100644 --- a/sys/contrib/openzfs/module/os/linux/zfs/vdev_disk.c +++ b/sys/contrib/openzfs/module/os/linux/zfs/vdev_disk.c @@ -467,8 +467,11 @@ vdev_submit_bio_impl(struct bio *bio) * blkg_tryget() to use rcu_read_lock() instead of rcu_read_lock_sched(). * As a side effect the function was converted to GPL-only. Define our * own version when needed which uses rcu_read_lock_sched(). + * + * The Linux 5.17 kernel split linux/blk-cgroup.h into a private and a public + * part, moving blkg_tryget into the private one. Define our own version. */ -#if defined(HAVE_BLKG_TRYGET_GPL_ONLY) +#if defined(HAVE_BLKG_TRYGET_GPL_ONLY) || !defined(HAVE_BLKG_TRYGET) static inline bool vdev_blkg_tryget(struct blkcg_gq *blkg) { @@ -493,7 +496,7 @@ vdev_blkg_tryget(struct blkcg_gq *blkg) return (rc); } -#elif defined(HAVE_BLKG_TRYGET) +#else #define vdev_blkg_tryget(bg) blkg_tryget(bg) #endif #ifdef HAVE_BIO_SET_DEV_MACRO diff --git a/sys/contrib/openzfs/module/os/linux/zfs/zfs_acl.c b/sys/contrib/openzfs/module/os/linux/zfs/zfs_acl.c index 351e4dad799c..b70691ab31c1 100644 --- a/sys/contrib/openzfs/module/os/linux/zfs/zfs_acl.c +++ b/sys/contrib/openzfs/module/os/linux/zfs/zfs_acl.c @@ -863,6 +863,26 @@ zfs_unix_to_v4(uint32_t access_mask) return (new_mask); } + +static int +zfs_v4_to_unix(uint32_t access_mask, int *unmapped) +{ + int new_mask = 0; + + *unmapped = access_mask & + (ACE_WRITE_OWNER | ACE_WRITE_ACL | ACE_DELETE); + + if (access_mask & WRITE_MASK) + new_mask |= S_IWOTH; + if (access_mask & ACE_READ_DATA) + new_mask |= S_IROTH; + if (access_mask & ACE_EXECUTE) + new_mask |= S_IXOTH; + + return (new_mask); +} + + static void zfs_set_ace(zfs_acl_t *aclp, void *acep, uint32_t access_mask, uint16_t access_type, uint64_t fuid, uint16_t entry_type) @@ -2399,6 +2419,53 @@ zfs_has_access(znode_t *zp, cred_t *cr) return (B_TRUE); } +/* + * Simplified access check for case where ACL is known to not contain + * information beyond what is defined in the mode. In this case, we + * can pass along to the kernel / vfs generic_permission() check, which + * evaluates the mode and POSIX ACL. + * + * NFSv4 ACLs allow granting permissions that are usually relegated only + * to the file owner or superuser. Examples are ACE_WRITE_OWNER (chown), + * ACE_WRITE_ACL(chmod), and ACE_DELETE. ACE_DELETE requests must fail + * because with conventional posix permissions, right to delete file + * is determined by write bit on the parent dir. + * + * If unmappable perms are requested, then we must return EPERM + * and include those bits in the working_mode so that the caller of + * zfs_zaccess_common() can decide whether to perform additional + * policy / capability checks. EACCES is used in zfs_zaccess_aces_check() + * to indicate access check failed due to explicit DENY entry, and so + * we want to avoid that here. + */ +static int +zfs_zaccess_trivial(znode_t *zp, uint32_t *working_mode, cred_t *cr) +{ + int err, mask; + int unmapped = 0; + + ASSERT(zp->z_pflags & ZFS_ACL_TRIVIAL); + + mask = zfs_v4_to_unix(*working_mode, &unmapped); + if (mask == 0 || unmapped) { + *working_mode = unmapped; + return (unmapped ? SET_ERROR(EPERM) : 0); + } + +#if defined(HAVE_IOPS_PERMISSION_USERNS) + err = generic_permission(cr->user_ns, ZTOI(zp), mask); +#else + err = generic_permission(ZTOI(zp), mask); +#endif + if (err != 0) { + return (SET_ERROR(EPERM)); + } + + *working_mode = unmapped; + + return (0); +} + static int zfs_zaccess_common(znode_t *zp, uint32_t v4_mode, uint32_t *working_mode, boolean_t *check_privs, boolean_t skipaclchk, cred_t *cr) @@ -2450,6 +2517,9 @@ zfs_zaccess_common(znode_t *zp, uint32_t v4_mode, uint32_t *working_mode, return (SET_ERROR(EPERM)); } + if (zp->z_pflags & ZFS_ACL_TRIVIAL) + return (zfs_zaccess_trivial(zp, working_mode, cr)); + return (zfs_zaccess_aces_check(zp, working_mode, B_FALSE, cr)); } diff --git a/sys/contrib/openzfs/module/os/linux/zfs/zfs_ctldir.c b/sys/contrib/openzfs/module/os/linux/zfs/zfs_ctldir.c index f7e71461a3bd..aae19f6346fd 100644 --- a/sys/contrib/openzfs/module/os/linux/zfs/zfs_ctldir.c +++ b/sys/contrib/openzfs/module/os/linux/zfs/zfs_ctldir.c @@ -162,7 +162,7 @@ zfsctl_snapshot_free(zfs_snapentry_t *se) zfs_refcount_destroy(&se->se_refcount); kmem_strfree(se->se_name); kmem_strfree(se->se_path); - rw_destroy(se->se_taskqid_lock); + rw_destroy(&se->se_taskqid_lock); kmem_free(se, sizeof (zfs_snapentry_t)); } @@ -496,6 +496,8 @@ zfsctl_inode_alloc(zfsvfs_t *zfsvfs, uint64_t id, zp->z_pflags = 0; zp->z_mode = 0; zp->z_sync_cnt = 0; + zp->z_sync_writes_cnt = 0; + zp->z_async_writes_cnt = 0; ip->i_generation = 0; ip->i_ino = id; ip->i_mode = (S_IFDIR | S_IRWXUGO); diff --git a/sys/contrib/openzfs/module/os/linux/zfs/zfs_ioctl_os.c b/sys/contrib/openzfs/module/os/linux/zfs/zfs_ioctl_os.c index fee3fe540b90..c65702e1a053 100644 --- a/sys/contrib/openzfs/module/os/linux/zfs/zfs_ioctl_os.c +++ b/sys/contrib/openzfs/module/os/linux/zfs/zfs_ioctl_os.c @@ -58,6 +58,8 @@ #include #include #include +#include +#include #include @@ -233,8 +235,8 @@ zfsdev_detach(void) #define ZFS_DEBUG_STR "" #endif -static int __init -openzfs_init(void) +static int +openzfs_init_os(void) { int error; @@ -259,8 +261,8 @@ openzfs_init(void) return (0); } -static void __exit -openzfs_fini(void) +static void +openzfs_fini_os(void) { zfs_sysfs_fini(); zfs_kmod_fini(); @@ -269,12 +271,59 @@ openzfs_fini(void) ZFS_META_VERSION, ZFS_META_RELEASE, ZFS_DEBUG_STR); } + +extern int __init zcommon_init(void); +extern void zcommon_fini(void); + +static int __init +openzfs_init(void) +{ + int err; + if ((err = zcommon_init()) != 0) + goto zcommon_failed; + if ((err = icp_init()) != 0) + goto icp_failed; + if ((err = zstd_init()) != 0) + goto zstd_failed; + if ((err = openzfs_init_os()) != 0) + goto openzfs_os_failed; + return (0); + +openzfs_os_failed: + zstd_fini(); +zstd_failed: + icp_fini(); +icp_failed: + zcommon_fini(); +zcommon_failed: + return (err); +} + +static void __exit +openzfs_fini(void) +{ + openzfs_fini_os(); + zstd_fini(); + icp_fini(); + zcommon_fini(); +} + #if defined(_KERNEL) module_init(openzfs_init); module_exit(openzfs_fini); #endif -ZFS_MODULE_DESCRIPTION("ZFS"); -ZFS_MODULE_AUTHOR(ZFS_META_AUTHOR); -ZFS_MODULE_LICENSE(ZFS_META_LICENSE); -ZFS_MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); +MODULE_ALIAS("zavl"); +MODULE_ALIAS("icp"); +MODULE_ALIAS("zlua"); +MODULE_ALIAS("znvpair"); +MODULE_ALIAS("zunicode"); +MODULE_ALIAS("zcommon"); +MODULE_ALIAS("zzstd"); +MODULE_DESCRIPTION("ZFS"); +MODULE_AUTHOR(ZFS_META_AUTHOR); +MODULE_LICENSE("Lua: MIT"); +MODULE_LICENSE("zstd: Dual BSD/GPL"); +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_LICENSE(ZFS_META_LICENSE); +MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); diff --git a/sys/contrib/openzfs/module/os/linux/zfs/zfs_sysfs.c b/sys/contrib/openzfs/module/os/linux/zfs/zfs_sysfs.c index 6f71382cf74e..eb7c5f6166d2 100644 --- a/sys/contrib/openzfs/module/os/linux/zfs/zfs_sysfs.c +++ b/sys/contrib/openzfs/module/os/linux/zfs/zfs_sysfs.c @@ -65,16 +65,15 @@ /* * A zfs_mod_kobj_t represents a zfs kobject under '/sys/module/zfs' */ -struct zfs_mod_kobj; typedef struct zfs_mod_kobj zfs_mod_kobj_t; - struct zfs_mod_kobj { struct kobject zko_kobj; struct kobj_type zko_kobj_type; struct sysfs_ops zko_sysfs_ops; size_t zko_attr_count; struct attribute *zko_attr_list; /* allocated */ - struct attribute **zko_default_attrs; /* allocated */ + struct attribute_group zko_default_group; /* .attrs allocated */ + const struct attribute_group *zko_default_groups[2]; size_t zko_child_count; zfs_mod_kobj_t *zko_children; /* allocated */ }; @@ -127,10 +126,10 @@ zfs_kobj_release(struct kobject *kobj) zkobj->zko_attr_list = NULL; } - if (zkobj->zko_default_attrs != NULL) { - kmem_free(zkobj->zko_default_attrs, + if (zkobj->zko_default_group.attrs != NULL) { + kmem_free(zkobj->zko_default_group.attrs, DEFAULT_ATTR_SIZE(zkobj->zko_attr_count)); - zkobj->zko_default_attrs = NULL; + zkobj->zko_default_group.attrs = NULL; } if (zkobj->zko_child_count != 0) { @@ -154,11 +153,12 @@ zfs_kobj_add_attr(zfs_mod_kobj_t *zkobj, int attr_num, const char *attr_name) { VERIFY3U(attr_num, <, zkobj->zko_attr_count); ASSERT(zkobj->zko_attr_list); - ASSERT(zkobj->zko_default_attrs); + ASSERT(zkobj->zko_default_group.attrs); zkobj->zko_attr_list[attr_num].name = attr_name; zkobj->zko_attr_list[attr_num].mode = 0444; - zkobj->zko_default_attrs[attr_num] = &zkobj->zko_attr_list[attr_num]; + zkobj->zko_default_group.attrs[attr_num] = + &zkobj->zko_attr_list[attr_num]; sysfs_attr_init(&zkobj->zko_attr_list[attr_num]); } @@ -176,9 +176,9 @@ zfs_kobj_init(zfs_mod_kobj_t *zkobj, int attr_cnt, int child_cnt, return (ENOMEM); } /* this will always have at least one slot for NULL termination */ - zkobj->zko_default_attrs = kmem_zalloc(DEFAULT_ATTR_SIZE(attr_cnt), - KM_SLEEP); - if (zkobj->zko_default_attrs == NULL) { + zkobj->zko_default_group.attrs = + kmem_zalloc(DEFAULT_ATTR_SIZE(attr_cnt), KM_SLEEP); + if (zkobj->zko_default_group.attrs == NULL) { if (zkobj->zko_attr_list != NULL) { kmem_free(zkobj->zko_attr_list, ATTR_TABLE_SIZE(attr_cnt)); @@ -186,14 +186,19 @@ zfs_kobj_init(zfs_mod_kobj_t *zkobj, int attr_cnt, int child_cnt, return (ENOMEM); } zkobj->zko_attr_count = attr_cnt; - zkobj->zko_kobj_type.default_attrs = zkobj->zko_default_attrs; + zkobj->zko_default_groups[0] = &zkobj->zko_default_group; +#ifdef HAVE_SYSFS_DEFAULT_GROUPS + zkobj->zko_kobj_type.default_groups = zkobj->zko_default_groups; +#else + zkobj->zko_kobj_type.default_attrs = zkobj->zko_default_group.attrs; +#endif if (child_cnt > 0) { zkobj->zko_children = kmem_zalloc(CHILD_TABLE_SIZE(child_cnt), KM_SLEEP); if (zkobj->zko_children == NULL) { - if (zkobj->zko_default_attrs != NULL) { - kmem_free(zkobj->zko_default_attrs, + if (zkobj->zko_default_group.attrs != NULL) { + kmem_free(zkobj->zko_default_group.attrs, DEFAULT_ATTR_SIZE(attr_cnt)); } if (zkobj->zko_attr_list != NULL) { @@ -215,9 +220,9 @@ zfs_kobj_init(zfs_mod_kobj_t *zkobj, int attr_cnt, int child_cnt, static int zfs_kobj_add(zfs_mod_kobj_t *zkobj, struct kobject *parent, const char *name) { - /* zko_default_attrs must be NULL terminated */ - ASSERT(zkobj->zko_default_attrs != NULL); - ASSERT(zkobj->zko_default_attrs[zkobj->zko_attr_count] == NULL); + /* zko_default_group.attrs must be NULL terminated */ + ASSERT(zkobj->zko_default_group.attrs != NULL); + ASSERT(zkobj->zko_default_group.attrs[zkobj->zko_attr_count] == NULL); kobject_init(&zkobj->zko_kobj, &zkobj->zko_kobj_type); return (kobject_add(&zkobj->zko_kobj, parent, name)); @@ -226,7 +231,7 @@ zfs_kobj_add(zfs_mod_kobj_t *zkobj, struct kobject *parent, const char *name) /* * Each zfs property has these common attributes */ -static const char *zprop_attrs[] = { +static const char *const zprop_attrs[] = { "type", "readonly", "setonce", @@ -239,7 +244,7 @@ static const char *zprop_attrs[] = { #define ZFS_PROP_ATTR_COUNT ARRAY_SIZE(zprop_attrs) #define ZPOOL_PROP_ATTR_COUNT (ZFS_PROP_ATTR_COUNT - 1) -static const char *zprop_types[] = { +static const char *const zprop_types[] = { "number", "string", "index", @@ -250,7 +255,7 @@ typedef struct zfs_type_map { const char *ztm_name; } zfs_type_map_t; -static zfs_type_map_t type_map[] = { +static const zfs_type_map_t type_map[] = { {ZFS_TYPE_FILESYSTEM, "filesystem"}, {ZFS_TYPE_SNAPSHOT, "snapshot"}, {ZFS_TYPE_VOLUME, "volume"}, @@ -371,7 +376,7 @@ pool_property_show(struct kobject *kobj, struct attribute *attr, char *buf) * A user process can easily check if the running zfs kernel module * supports the new feature. */ -static const char *zfs_kernel_features[] = { +static const char *const zfs_kernel_features[] = { /* --> Add new kernel features here */ "com.delphix:vdev_initialize", "org.zfsonlinux:vdev_trim", @@ -439,7 +444,7 @@ zfs_kernel_features_init(zfs_mod_kobj_t *zfs_kobj, struct kobject *parent) /* * Each pool feature has these common attributes */ -static const char *pool_feature_attrs[] = { +static const char *const pool_feature_attrs[] = { "description", "guid", "uname", diff --git a/sys/contrib/openzfs/module/os/linux/zfs/zfs_uio.c b/sys/contrib/openzfs/module/os/linux/zfs/zfs_uio.c index ce47b3e6087a..4f31bcb5959d 100644 --- a/sys/contrib/openzfs/module/os/linux/zfs/zfs_uio.c +++ b/sys/contrib/openzfs/module/os/linux/zfs/zfs_uio.c @@ -248,7 +248,7 @@ zfs_uio_prefaultpages(ssize_t n, zfs_uio_t *uio) /* touch each page in this segment. */ p = iov->iov_base + skip; while (cnt) { - if (get_user(tmp, (uint8_t *)p)) + if (copy_from_user(&tmp, p, 1)) return (EFAULT); ulong_t incr = MIN(cnt, PAGESIZE); p += incr; @@ -256,7 +256,7 @@ zfs_uio_prefaultpages(ssize_t n, zfs_uio_t *uio) } /* touch the last byte in case it straddles a page. */ p--; - if (get_user(tmp, (uint8_t *)p)) + if (copy_from_user(&tmp, p, 1)) return (EFAULT); } } diff --git a/sys/contrib/openzfs/module/os/linux/zfs/zfs_vnops_os.c b/sys/contrib/openzfs/module/os/linux/zfs/zfs_vnops_os.c index ece7c373e852..d6ff838806eb 100644 --- a/sys/contrib/openzfs/module/os/linux/zfs/zfs_vnops_os.c +++ b/sys/contrib/openzfs/module/os/linux/zfs/zfs_vnops_os.c @@ -474,7 +474,7 @@ zfs_lookup(znode_t *zdp, char *nm, znode_t **zpp, int flags, cred_t *cr, */ if ((error = zfs_zaccess(*zpp, ACE_EXECUTE, 0, - B_FALSE, cr))) { + B_TRUE, cr))) { zrele(*zpp); *zpp = NULL; } @@ -3396,7 +3396,7 @@ zfs_link(znode_t *tdzp, znode_t *szp, char *name, cred_t *cr, } static void -zfs_putpage_commit_cb(void *arg) +zfs_putpage_sync_commit_cb(void *arg) { struct page *pp = arg; @@ -3404,13 +3404,26 @@ zfs_putpage_commit_cb(void *arg) end_page_writeback(pp); } +static void +zfs_putpage_async_commit_cb(void *arg) +{ + struct page *pp = arg; + znode_t *zp = ITOZ(pp->mapping->host); + + ClearPageError(pp); + end_page_writeback(pp); + atomic_dec_32(&zp->z_async_writes_cnt); +} + /* * Push a page out to disk, once the page is on stable storage the * registered commit callback will be run as notification of completion. * - * IN: ip - page mapped for inode. - * pp - page to push (page is locked) - * wbc - writeback control data + * IN: ip - page mapped for inode. + * pp - page to push (page is locked) + * wbc - writeback control data + * for_sync - does the caller intend to wait synchronously for the + * page writeback to complete? * * RETURN: 0 if success * error code if failure @@ -3419,7 +3432,8 @@ zfs_putpage_commit_cb(void *arg) * ip - ctime|mtime updated */ int -zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc) +zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc, + boolean_t for_sync) { znode_t *zp = ITOZ(ip); zfsvfs_t *zfsvfs = ITOZSB(ip); @@ -3517,6 +3531,16 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc) zfs_rangelock_exit(lr); if (wbc->sync_mode != WB_SYNC_NONE) { + /* + * Speed up any non-sync page writebacks since + * they may take several seconds to complete. + * Refer to the comment in zpl_fsync() (when + * HAVE_FSYNC_RANGE is defined) for details. + */ + if (atomic_load_32(&zp->z_async_writes_cnt) > 0) { + zil_commit(zfsvfs->z_log, zp->z_id); + } + if (PageWriteback(pp)) #ifdef HAVE_PAGEMAP_FOLIO_WAIT_BIT folio_wait_bit(page_folio(pp), PG_writeback); @@ -3542,6 +3566,8 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc) * was in fact not skipped and should not be counted as if it were. */ wbc->pages_skipped--; + if (!for_sync) + atomic_inc_32(&zp->z_async_writes_cnt); set_page_writeback(pp); unlock_page(pp); @@ -3556,9 +3582,15 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc) dmu_tx_wait(tx); dmu_tx_abort(tx); +#ifdef HAVE_VFS_FILEMAP_DIRTY_FOLIO + filemap_dirty_folio(page_mapping(pp), page_folio(pp)); +#else __set_page_dirty_nobuffers(pp); +#endif ClearPageError(pp); end_page_writeback(pp); + if (!for_sync) + atomic_dec_32(&zp->z_async_writes_cnt); zfs_rangelock_exit(lr); ZFS_EXIT(zfsvfs); return (err); @@ -3583,7 +3615,9 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc) err = sa_bulk_update(zp->z_sa_hdl, bulk, cnt, tx); zfs_log_write(zfsvfs->z_log, tx, TX_WRITE, zp, pgoff, pglen, 0, - zfs_putpage_commit_cb, pp); + for_sync ? zfs_putpage_sync_commit_cb : + zfs_putpage_async_commit_cb, pp); + dmu_tx_commit(tx); zfs_rangelock_exit(lr); @@ -3595,6 +3629,16 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc) * performance reasons. */ zil_commit(zfsvfs->z_log, zp->z_id); + } else if (!for_sync && atomic_load_32(&zp->z_sync_writes_cnt) > 0) { + /* + * If the caller does not intend to wait synchronously + * for this page writeback to complete and there are active + * synchronous calls on this file, do a commit so that + * the latter don't accidentally end up waiting for + * our writeback to complete. Refer to the comment in + * zpl_fsync() (when HAVE_FSYNC_RANGE is defined) for details. + */ + zil_commit(zfsvfs->z_log, zp->z_id); } dataset_kstats_update_write_kstats(&zfsvfs->z_kstat, pglen); diff --git a/sys/contrib/openzfs/module/os/linux/zfs/zfs_znode.c b/sys/contrib/openzfs/module/os/linux/zfs/zfs_znode.c index b76e65d16822..d921f2b07463 100644 --- a/sys/contrib/openzfs/module/os/linux/zfs/zfs_znode.c +++ b/sys/contrib/openzfs/module/os/linux/zfs/zfs_znode.c @@ -134,6 +134,9 @@ zfs_znode_cache_constructor(void *buf, void *arg, int kmflags) zp->z_acl_cached = NULL; zp->z_xattr_cached = NULL; zp->z_xattr_parent = 0; + zp->z_sync_writes_cnt = 0; + zp->z_async_writes_cnt = 0; + return (0); } @@ -154,6 +157,9 @@ zfs_znode_cache_destructor(void *buf, void *arg) ASSERT3P(zp->z_dirlocks, ==, NULL); ASSERT3P(zp->z_acl_cached, ==, NULL); ASSERT3P(zp->z_xattr_cached, ==, NULL); + + ASSERT0(atomic_load_32(&zp->z_sync_writes_cnt)); + ASSERT0(atomic_load_32(&zp->z_async_writes_cnt)); } static int @@ -554,6 +560,8 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz, zp->z_blksz = blksz; zp->z_seq = 0x7A4653; zp->z_sync_cnt = 0; + zp->z_sync_writes_cnt = 0; + zp->z_async_writes_cnt = 0; zfs_znode_sa_init(zfsvfs, zp, db, obj_type, hdl); diff --git a/sys/contrib/openzfs/module/os/linux/zfs/zpl_file.c b/sys/contrib/openzfs/module/os/linux/zfs/zpl_file.c index f78e50262af7..8b84eb795fc3 100644 --- a/sys/contrib/openzfs/module/os/linux/zfs/zpl_file.c +++ b/sys/contrib/openzfs/module/os/linux/zfs/zpl_file.c @@ -33,9 +33,13 @@ #include #include #include -#ifdef HAVE_VFS_SET_PAGE_DIRTY_NOBUFFERS +#if defined(HAVE_VFS_SET_PAGE_DIRTY_NOBUFFERS) || \ + defined(HAVE_VFS_FILEMAP_DIRTY_FOLIO) #include #endif +#ifdef HAVE_VFS_FILEMAP_DIRTY_FOLIO +#include +#endif /* * When using fallocate(2) to preallocate space, inflate the requested @@ -161,17 +165,56 @@ static int zpl_fsync(struct file *filp, loff_t start, loff_t end, int datasync) { struct inode *inode = filp->f_mapping->host; + znode_t *zp = ITOZ(inode); + zfsvfs_t *zfsvfs = ITOZSB(inode); cred_t *cr = CRED(); int error; fstrans_cookie_t cookie; + /* + * The variables z_sync_writes_cnt and z_async_writes_cnt work in + * tandem so that sync writes can detect if there are any non-sync + * writes going on and vice-versa. The "vice-versa" part to this logic + * is located in zfs_putpage() where non-sync writes check if there are + * any ongoing sync writes. If any sync and non-sync writes overlap, + * we do a commit to complete the non-sync writes since the latter can + * potentially take several seconds to complete and thus block sync + * writes in the upcoming call to filemap_write_and_wait_range(). + */ + atomic_inc_32(&zp->z_sync_writes_cnt); + /* + * If the following check does not detect an overlapping non-sync write + * (say because it's just about to start), then it is guaranteed that + * the non-sync write will detect this sync write. This is because we + * always increment z_sync_writes_cnt / z_async_writes_cnt before doing + * the check on z_async_writes_cnt / z_sync_writes_cnt here and in + * zfs_putpage() respectively. + */ + if (atomic_load_32(&zp->z_async_writes_cnt) > 0) { + ZPL_ENTER(zfsvfs); + zil_commit(zfsvfs->z_log, zp->z_id); + ZPL_EXIT(zfsvfs); + } + error = filemap_write_and_wait_range(inode->i_mapping, start, end); + + /* + * The sync write is not complete yet but we decrement + * z_sync_writes_cnt since zfs_fsync() increments and decrements + * it internally. If a non-sync write starts just after the decrement + * operation but before we call zfs_fsync(), it may not detect this + * overlapping sync write but it does not matter since we have already + * gone past filemap_write_and_wait_range() and we won't block due to + * the non-sync write. + */ + atomic_dec_32(&zp->z_sync_writes_cnt); + if (error) return (error); crhold(cr); cookie = spl_fstrans_mark(); - error = -zfs_fsync(ITOZ(inode), datasync, cr); + error = -zfs_fsync(zp, datasync, cr); spl_fstrans_unmark(cookie); crfree(cr); ASSERT3S(error, <=, 0); @@ -413,6 +456,8 @@ zpl_aio_write(struct kiocb *kiocb, const struct iovec *iov, if (ret) return (ret); + kiocb->ki_pos = pos; + zfs_uio_t uio; zfs_uio_iovec_init(&uio, iov, nr_segs, kiocb->ki_pos, UIO_USERSPACE, count, 0); @@ -647,24 +692,41 @@ zpl_readpage_filler(void *data, struct page *pp) * paging. For simplicity, the code relies on read_cache_pages() to * correctly lock each page for IO and call zpl_readpage(). */ +#ifdef HAVE_VFS_READPAGES static int zpl_readpages(struct file *filp, struct address_space *mapping, struct list_head *pages, unsigned nr_pages) { return (read_cache_pages(mapping, pages, zpl_readpage_filler, NULL)); } +#else +static void +zpl_readahead(struct readahead_control *ractl) +{ + struct page *page; + + while ((page = readahead_page(ractl)) != NULL) { + int ret; + + ret = zpl_readpage_filler(NULL, page); + put_page(page); + if (ret) + break; + } +} +#endif static int zpl_putpage(struct page *pp, struct writeback_control *wbc, void *data) { - struct address_space *mapping = data; + boolean_t *for_sync = data; fstrans_cookie_t cookie; ASSERT(PageLocked(pp)); ASSERT(!PageWriteback(pp)); cookie = spl_fstrans_mark(); - (void) zfs_putpage(mapping->host, pp, wbc); + (void) zfs_putpage(pp->mapping->host, pp, wbc, *for_sync); spl_fstrans_unmark(cookie); return (0); @@ -691,8 +753,9 @@ zpl_writepages(struct address_space *mapping, struct writeback_control *wbc) * we run it once in non-SYNC mode so that the ZIL gets all the data, * and then we commit it all in one go. */ + boolean_t for_sync = (sync_mode == WB_SYNC_ALL); wbc->sync_mode = WB_SYNC_NONE; - result = write_cache_pages(mapping, wbc, zpl_putpage, mapping); + result = write_cache_pages(mapping, wbc, zpl_putpage, &for_sync); if (sync_mode != wbc->sync_mode) { ZPL_ENTER(zfsvfs); ZPL_VERIFY_ZP(zp); @@ -708,7 +771,8 @@ zpl_writepages(struct address_space *mapping, struct writeback_control *wbc) * details). That being said, this is a no-op in most cases. */ wbc->sync_mode = sync_mode; - result = write_cache_pages(mapping, wbc, zpl_putpage, mapping); + result = write_cache_pages(mapping, wbc, zpl_putpage, + &for_sync); } return (result); } @@ -725,7 +789,9 @@ zpl_writepage(struct page *pp, struct writeback_control *wbc) if (ITOZSB(pp->mapping->host)->z_os->os_sync == ZFS_SYNC_ALWAYS) wbc->sync_mode = WB_SYNC_ALL; - return (zpl_putpage(pp, wbc, pp->mapping)); + boolean_t for_sync = (wbc->sync_mode == WB_SYNC_ALL); + + return (zpl_putpage(pp, wbc, &for_sync)); } /* @@ -764,11 +830,13 @@ zpl_fallocate_common(struct inode *ip, int mode, loff_t offset, loff_t len) if (mode & (test_mode)) { flock64_t bf; - if (offset > olen) - goto out_unmark; + if (mode & FALLOC_FL_KEEP_SIZE) { + if (offset > olen) + goto out_unmark; - if (offset + len > olen) - len = olen - offset; + if (offset + len > olen) + len = olen - offset; + } bf.l_type = F_WRLCK; bf.l_whence = SEEK_SET; bf.l_start = offset; @@ -1135,7 +1203,11 @@ zpl_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) const struct address_space_operations zpl_address_space_operations = { +#ifdef HAVE_VFS_READPAGES .readpages = zpl_readpages, +#else + .readahead = zpl_readahead, +#endif .readpage = zpl_readpage, .writepage = zpl_writepage, .writepages = zpl_writepages, @@ -1143,6 +1215,9 @@ const struct address_space_operations zpl_address_space_operations = { #ifdef HAVE_VFS_SET_PAGE_DIRTY_NOBUFFERS .set_page_dirty = __set_page_dirty_nobuffers, #endif +#ifdef HAVE_VFS_FILEMAP_DIRTY_FOLIO + .dirty_folio = filemap_dirty_folio, +#endif }; const struct file_operations zpl_file_operations = { diff --git a/sys/contrib/openzfs/module/os/linux/zfs/zvol_os.c b/sys/contrib/openzfs/module/os/linux/zfs/zvol_os.c index c964cce0de9a..4ebdf8331695 100644 --- a/sys/contrib/openzfs/module/os/linux/zfs/zvol_os.c +++ b/sys/contrib/openzfs/module/os/linux/zfs/zvol_os.c @@ -46,7 +46,10 @@ static unsigned int zvol_request_sync = 0; static unsigned int zvol_prefetch_bytes = (128 * 1024); static unsigned long zvol_max_discard_blocks = 16384; static unsigned int zvol_threads = 32; + +#ifndef HAVE_BLKDEV_GET_ERESTARTSYS static const unsigned int zvol_open_timeout_ms = 1000; +#endif struct zvol_state_os { struct gendisk *zvo_disk; /* generic disk */ @@ -903,22 +906,17 @@ zvol_alloc(dev_t dev, const char *name) zso->zvo_disk->major = zvol_major; zso->zvo_disk->events = DISK_EVENT_MEDIA_CHANGE; + /* + * Setting ZFS_VOLMODE_DEV disables partitioning on ZVOL devices. + * This is accomplished by limiting the number of minors for the + * device to one and explicitly disabling partition scanning. + */ if (volmode == ZFS_VOLMODE_DEV) { - /* - * ZFS_VOLMODE_DEV disable partitioning on ZVOL devices: set - * gendisk->minors = 1 as noted in include/linux/blkdev.h. - * Also disable extended partition numbers (GENHD_FL_EXT_DEVT) - * and suppresses partition scanning (GENHD_FL_NO_PART_SCAN) - * setting gendisk->flags accordingly. - */ zso->zvo_disk->minors = 1; -#if defined(GENHD_FL_EXT_DEVT) - zso->zvo_disk->flags &= ~GENHD_FL_EXT_DEVT; -#endif -#if defined(GENHD_FL_NO_PART_SCAN) - zso->zvo_disk->flags |= GENHD_FL_NO_PART_SCAN; -#endif + zso->zvo_disk->flags &= ~ZFS_GENHD_FL_EXT_DEVT; + zso->zvo_disk->flags |= ZFS_GENHD_FL_NO_PART; } + zso->zvo_disk->first_minor = (dev & MINORMASK); zso->zvo_disk->fops = &zvol_ops; zso->zvo_disk->private_data = zv; diff --git a/sys/contrib/openzfs/module/spl/Makefile.in b/sys/contrib/openzfs/module/spl/Makefile.in deleted file mode 100644 index cedbfe92b58a..000000000000 --- a/sys/contrib/openzfs/module/spl/Makefile.in +++ /dev/null @@ -1,13 +0,0 @@ -ifneq ($(KBUILD_EXTMOD),) -src = @abs_srcdir@ -obj = @abs_builddir@ -mfdir = $(obj) -else -mfdir = $(srctree)/$(src) -endif - -MODULE := spl - -obj-$(CONFIG_ZFS) := $(MODULE).o - -include $(mfdir)/../os/linux/spl/Makefile diff --git a/sys/contrib/openzfs/module/unicode/Makefile.in b/sys/contrib/openzfs/module/unicode/Makefile.in deleted file mode 100644 index 59c07c4555b7..000000000000 --- a/sys/contrib/openzfs/module/unicode/Makefile.in +++ /dev/null @@ -1,11 +0,0 @@ -ifneq ($(KBUILD_EXTMOD),) -src = @abs_srcdir@ -obj = @abs_builddir@ -endif - -MODULE := zunicode - -obj-$(CONFIG_ZFS) := $(MODULE).o - -$(MODULE)-objs += u8_textprep.o -$(MODULE)-objs += uconv.o diff --git a/sys/contrib/openzfs/module/unicode/u8_textprep.c b/sys/contrib/openzfs/module/unicode/u8_textprep.c index b6b07b2453af..37d648b2172d 100644 --- a/sys/contrib/openzfs/module/unicode/u8_textprep.c +++ b/sys/contrib/openzfs/module/unicode/u8_textprep.c @@ -2129,27 +2129,6 @@ u8_textprep_str(char *inarray, size_t *inlen, char *outarray, size_t *outlen, return (ret_val); } -#if defined(_KERNEL) -static int __init -unicode_init(void) -{ - return (0); -} - -static void __exit -unicode_fini(void) -{ -} - -module_init(unicode_init); -module_exit(unicode_fini); -#endif - -ZFS_MODULE_DESCRIPTION("Unicode implementation"); -ZFS_MODULE_AUTHOR(ZFS_META_AUTHOR); -ZFS_MODULE_LICENSE(ZFS_META_LICENSE); -ZFS_MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); - EXPORT_SYMBOL(u8_validate); EXPORT_SYMBOL(u8_strcmp); EXPORT_SYMBOL(u8_textprep_str); diff --git a/sys/contrib/openzfs/module/zcommon/Makefile.in b/sys/contrib/openzfs/module/zcommon/Makefile.in deleted file mode 100644 index ebc538440445..000000000000 --- a/sys/contrib/openzfs/module/zcommon/Makefile.in +++ /dev/null @@ -1,28 +0,0 @@ -ifneq ($(KBUILD_EXTMOD),) -src = @abs_srcdir@ -obj = @abs_builddir@ -endif - -MODULE := zcommon - -obj-$(CONFIG_ZFS) := $(MODULE).o - -# Suppress unused-value warnings in sparc64 architecture headers -ccflags-$(CONFIG_SPARC64) += -Wno-unused-value - -$(MODULE)-objs += cityhash.o -$(MODULE)-objs += zfeature_common.o -$(MODULE)-objs += zfs_comutil.o -$(MODULE)-objs += zfs_deleg.o -$(MODULE)-objs += zfs_fletcher.o -$(MODULE)-objs += zfs_fletcher_superscalar.o -$(MODULE)-objs += zfs_fletcher_superscalar4.o -$(MODULE)-objs += zfs_namecheck.o -$(MODULE)-objs += zfs_prop.o -$(MODULE)-objs += zpool_prop.o -$(MODULE)-objs += zprop_common.o - -$(MODULE)-$(CONFIG_X86) += zfs_fletcher_intel.o -$(MODULE)-$(CONFIG_X86) += zfs_fletcher_sse.o -$(MODULE)-$(CONFIG_X86) += zfs_fletcher_avx512.o -$(MODULE)-$(CONFIG_ARM64) += zfs_fletcher_aarch64_neon.o diff --git a/sys/contrib/openzfs/module/zcommon/zfeature_common.c b/sys/contrib/openzfs/module/zcommon/zfeature_common.c index 13dbccae2d4a..f09389e6d02e 100644 --- a/sys/contrib/openzfs/module/zcommon/zfeature_common.c +++ b/sys/contrib/openzfs/module/zcommon/zfeature_common.c @@ -696,6 +696,7 @@ zpool_feature_init(void) ZFEATURE_FLAG_MOS, ZFEATURE_TYPE_BOOLEAN, NULL, sfeatures); { + static const spa_feature_t zilsaxattr_deps[] = { SPA_FEATURE_EXTENSIBLE_DATASET, SPA_FEATURE_NONE @@ -707,6 +708,12 @@ zpool_feature_init(void) ZFEATURE_TYPE_BOOLEAN, zilsaxattr_deps, sfeatures); } + zfeature_register(SPA_FEATURE_HEAD_ERRLOG, + "com.delphix:head_errlog", "head_errlog", + "Support for per-dataset on-disk error logs.", + ZFEATURE_FLAG_ACTIVATE_ON_ENABLE, ZFEATURE_TYPE_BOOLEAN, NULL, + sfeatures); + zfs_mod_list_supported_free(sfeatures); } diff --git a/sys/contrib/openzfs/module/zcommon/zfs_prop.c b/sys/contrib/openzfs/module/zcommon/zfs_prop.c index 8b3e774d99ec..500d80a33b6b 100644 --- a/sys/contrib/openzfs/module/zcommon/zfs_prop.c +++ b/sys/contrib/openzfs/module/zcommon/zfs_prop.c @@ -1006,7 +1006,10 @@ uint8_t **zfs_kfpu_fpregs; EXPORT_SYMBOL(zfs_kfpu_fpregs); #endif /* defined(HAVE_KERNEL_FPU_INTERNAL) */ -static int __init +extern int __init zcommon_init(void); +extern void zcommon_fini(void); + +int __init zcommon_init(void) { int error = kfpu_init(); @@ -1018,22 +1021,19 @@ zcommon_init(void) return (0); } -static void __exit +void zcommon_fini(void) { fletcher_4_fini(); kfpu_fini(); } +#ifdef __FreeBSD__ module_init_early(zcommon_init); module_exit(zcommon_fini); - #endif -ZFS_MODULE_DESCRIPTION("Generic ZFS support"); -ZFS_MODULE_AUTHOR(ZFS_META_AUTHOR); -ZFS_MODULE_LICENSE(ZFS_META_LICENSE); -ZFS_MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE); +#endif /* zfs dataset property functions */ EXPORT_SYMBOL(zfs_userquota_prop_prefixes); diff --git a/sys/contrib/openzfs/module/zcommon/zprop_common.c b/sys/contrib/openzfs/module/zcommon/zprop_common.c index 0f496877577b..b1da4ca64bd5 100644 --- a/sys/contrib/openzfs/module/zcommon/zprop_common.c +++ b/sys/contrib/openzfs/module/zcommon/zprop_common.c @@ -136,7 +136,7 @@ zprop_register_string(int prop, const char *name, const char *def, const char *colname, const struct zfs_mod_supported_features *sfeatures) { zprop_register_impl(prop, name, PROP_TYPE_STRING, 0, def, attr, - objset_types, values, colname, B_FALSE, B_TRUE, B_FALSE, NULL, + objset_types, values, colname, B_FALSE, B_TRUE, B_TRUE, NULL, sfeatures); } @@ -159,7 +159,7 @@ zprop_register_index(int prop, const char *name, uint64_t def, const struct zfs_mod_supported_features *sfeatures) { zprop_register_impl(prop, name, PROP_TYPE_INDEX, def, NULL, attr, - objset_types, values, colname, B_FALSE, B_TRUE, B_FALSE, idx_tbl, + objset_types, values, colname, B_FALSE, B_TRUE, B_TRUE, idx_tbl, sfeatures); } diff --git a/sys/contrib/openzfs/module/zfs/Makefile.in b/sys/contrib/openzfs/module/zfs/Makefile.in deleted file mode 100644 index 30dc91a7eb59..000000000000 --- a/sys/contrib/openzfs/module/zfs/Makefile.in +++ /dev/null @@ -1,158 +0,0 @@ -ifneq ($(KBUILD_EXTMOD),) -src = @abs_srcdir@ -obj = @abs_builddir@ -mfdir = $(obj) -else -mfdir = $(srctree)/$(src) -endif - -MODULE := zfs - -obj-$(CONFIG_ZFS) := $(MODULE).o - -# Suppress unused-value warnings in sparc64 architecture headers -ccflags-$(CONFIG_SPARC64) += -Wno-unused-value - -$(MODULE)-objs += abd.o -$(MODULE)-objs += aggsum.o -$(MODULE)-objs += arc.o -$(MODULE)-objs += blkptr.o -$(MODULE)-objs += bplist.o -$(MODULE)-objs += bpobj.o -$(MODULE)-objs += bptree.o -$(MODULE)-objs += btree.o -$(MODULE)-objs += bqueue.o -$(MODULE)-objs += dataset_kstats.o -$(MODULE)-objs += dbuf.o -$(MODULE)-objs += dbuf_stats.o -$(MODULE)-objs += ddt.o -$(MODULE)-objs += ddt_zap.o -$(MODULE)-objs += dmu.o -$(MODULE)-objs += dmu_diff.o -$(MODULE)-objs += dmu_object.o -$(MODULE)-objs += dmu_objset.o -$(MODULE)-objs += dmu_recv.o -$(MODULE)-objs += dmu_redact.o -$(MODULE)-objs += dmu_send.o -$(MODULE)-objs += dmu_traverse.o -$(MODULE)-objs += dmu_tx.o -$(MODULE)-objs += dmu_zfetch.o -$(MODULE)-objs += dnode.o -$(MODULE)-objs += dnode_sync.o -$(MODULE)-objs += dsl_bookmark.o -$(MODULE)-objs += dsl_crypt.o -$(MODULE)-objs += dsl_dataset.o -$(MODULE)-objs += dsl_deadlist.o -$(MODULE)-objs += dsl_deleg.o -$(MODULE)-objs += dsl_destroy.o -$(MODULE)-objs += dsl_dir.o -$(MODULE)-objs += dsl_pool.o -$(MODULE)-objs += dsl_prop.o -$(MODULE)-objs += dsl_scan.o -$(MODULE)-objs += dsl_synctask.o -$(MODULE)-objs += dsl_userhold.o -$(MODULE)-objs += edonr_zfs.o -$(MODULE)-objs += fm.o -$(MODULE)-objs += gzip.o -$(MODULE)-objs += hkdf.o -$(MODULE)-objs += lz4.o -$(MODULE)-objs += lz4_zfs.o -$(MODULE)-objs += lzjb.o -$(MODULE)-objs += metaslab.o -$(MODULE)-objs += mmp.o -$(MODULE)-objs += multilist.o -$(MODULE)-objs += objlist.o -$(MODULE)-objs += pathname.o -$(MODULE)-objs += range_tree.o -$(MODULE)-objs += refcount.o -$(MODULE)-objs += rrwlock.o -$(MODULE)-objs += sa.o -$(MODULE)-objs += sha256.o -$(MODULE)-objs += skein_zfs.o -$(MODULE)-objs += spa.o -$(MODULE)-objs += spa_boot.o -$(MODULE)-objs += spa_checkpoint.o -$(MODULE)-objs += spa_config.o -$(MODULE)-objs += spa_errlog.o -$(MODULE)-objs += spa_history.o -$(MODULE)-objs += spa_log_spacemap.o -$(MODULE)-objs += spa_misc.o -$(MODULE)-objs += spa_stats.o -$(MODULE)-objs += space_map.o -$(MODULE)-objs += space_reftree.o -$(MODULE)-objs += txg.o -$(MODULE)-objs += uberblock.o -$(MODULE)-objs += unique.o -$(MODULE)-objs += vdev.o -$(MODULE)-objs += vdev_cache.o -$(MODULE)-objs += vdev_draid.o -$(MODULE)-objs += vdev_draid_rand.o -$(MODULE)-objs += vdev_indirect.o -$(MODULE)-objs += vdev_indirect_births.o -$(MODULE)-objs += vdev_indirect_mapping.o -$(MODULE)-objs += vdev_initialize.o -$(MODULE)-objs += vdev_label.o -$(MODULE)-objs += vdev_mirror.o -$(MODULE)-objs += vdev_missing.o -$(MODULE)-objs += vdev_queue.o -$(MODULE)-objs += vdev_raidz.o -$(MODULE)-objs += vdev_raidz_math.o -$(MODULE)-objs += vdev_raidz_math_scalar.o -$(MODULE)-objs += vdev_rebuild.o -$(MODULE)-objs += vdev_removal.o -$(MODULE)-objs += vdev_root.o -$(MODULE)-objs += vdev_trim.o -$(MODULE)-objs += zap.o -$(MODULE)-objs += zap_leaf.o -$(MODULE)-objs += zap_micro.o -$(MODULE)-objs += zcp.o -$(MODULE)-objs += zcp_get.o -$(MODULE)-objs += zcp_global.o -$(MODULE)-objs += zcp_iter.o -$(MODULE)-objs += zcp_set.o -$(MODULE)-objs += zcp_synctask.o -$(MODULE)-objs += zfeature.o -$(MODULE)-objs += zfs_byteswap.o -$(MODULE)-objs += zfs_fm.o -$(MODULE)-objs += zfs_fuid.o -$(MODULE)-objs += zfs_ioctl.o -$(MODULE)-objs += zfs_log.o -$(MODULE)-objs += zfs_onexit.o -$(MODULE)-objs += zfs_quota.o -$(MODULE)-objs += zfs_ratelimit.o -$(MODULE)-objs += zfs_replay.o -$(MODULE)-objs += zfs_rlock.o -$(MODULE)-objs += zfs_sa.o -$(MODULE)-objs += zfs_vnops.o -$(MODULE)-objs += zil.o -$(MODULE)-objs += zio.o -$(MODULE)-objs += zio_checksum.o -$(MODULE)-objs += zio_compress.o -$(MODULE)-objs += zio_inject.o -$(MODULE)-objs += zle.o -$(MODULE)-objs += zrlock.o -$(MODULE)-objs += zthr.o -$(MODULE)-objs += zvol.o - -# Suppress incorrect warnings from versions of objtool which are not -# aware of x86 EVEX prefix instructions used for AVX512. -OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512bw.o := y -OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512f.o := y - -$(MODULE)-$(CONFIG_X86) += vdev_raidz_math_sse2.o -$(MODULE)-$(CONFIG_X86) += vdev_raidz_math_ssse3.o -$(MODULE)-$(CONFIG_X86) += vdev_raidz_math_avx2.o -$(MODULE)-$(CONFIG_X86) += vdev_raidz_math_avx512f.o -$(MODULE)-$(CONFIG_X86) += vdev_raidz_math_avx512bw.o - -$(MODULE)-$(CONFIG_ARM64) += vdev_raidz_math_aarch64_neon.o -$(MODULE)-$(CONFIG_ARM64) += vdev_raidz_math_aarch64_neonx2.o - -$(MODULE)-$(CONFIG_PPC) += vdev_raidz_math_powerpc_altivec.o -$(MODULE)-$(CONFIG_PPC64) += vdev_raidz_math_powerpc_altivec.o - -ifeq ($(CONFIG_ALTIVEC),y) -$(obj)/vdev_raidz_math_powerpc_altivec.o: c_flags += -maltivec -endif - -include $(mfdir)/../os/linux/zfs/Makefile diff --git a/sys/contrib/openzfs/module/zfs/arc.c b/sys/contrib/openzfs/module/zfs/arc.c index 79e754c4abcb..af42670cc2c9 100644 --- a/sys/contrib/openzfs/module/zfs/arc.c +++ b/sys/contrib/openzfs/module/zfs/arc.c @@ -9337,26 +9337,37 @@ l2arc_apply_transforms(spa_t *spa, arc_buf_hdr_t *hdr, uint64_t asize, } if (compress != ZIO_COMPRESS_OFF && !HDR_COMPRESSION_ENABLED(hdr)) { - cabd = abd_alloc_for_io(asize, ismd); - tmp = abd_borrow_buf(cabd, asize); + /* + * In some cases, we can wind up with size > asize, so + * we need to opt for the larger allocation option here. + * + * (We also need abd_return_buf_copy in all cases because + * it's an ASSERT() to modify the buffer before returning it + * with arc_return_buf(), and all the compressors + * write things before deciding to fail compression in nearly + * every case.) + */ + cabd = abd_alloc_for_io(size, ismd); + tmp = abd_borrow_buf(cabd, size); psize = zio_compress_data(compress, to_write, tmp, size, hdr->b_complevel); - if (psize >= size) { - abd_return_buf(cabd, tmp, asize); + if (psize >= asize) { + psize = HDR_GET_PSIZE(hdr); + abd_return_buf_copy(cabd, tmp, size); HDR_SET_COMPRESS(hdr, ZIO_COMPRESS_OFF); to_write = cabd; - abd_copy(to_write, hdr->b_l1hdr.b_pabd, size); - if (size != asize) - abd_zero_off(to_write, size, asize - size); + abd_copy(to_write, hdr->b_l1hdr.b_pabd, psize); + if (psize != asize) + abd_zero_off(to_write, psize, asize - psize); goto encrypt; } ASSERT3U(psize, <=, HDR_GET_PSIZE(hdr)); if (psize < asize) memset((char *)tmp + psize, 0, asize - psize); psize = HDR_GET_PSIZE(hdr); - abd_return_buf_copy(cabd, tmp, asize); + abd_return_buf_copy(cabd, tmp, size); to_write = cabd; } @@ -11045,20 +11056,20 @@ EXPORT_SYMBOL(arc_add_prune_callback); EXPORT_SYMBOL(arc_remove_prune_callback); ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, min, param_set_arc_min, - param_get_long, ZMOD_RW, "Min arc size"); + param_get_long, ZMOD_RW, "Minimum ARC size in bytes"); ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, max, param_set_arc_max, - param_get_long, ZMOD_RW, "Max arc size"); + param_get_long, ZMOD_RW, "Maximum ARC size in bytes"); ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, meta_limit, param_set_arc_long, - param_get_long, ZMOD_RW, "Metadata limit for arc size"); + param_get_long, ZMOD_RW, "Metadata limit for ARC size in bytes"); ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, meta_limit_percent, param_set_arc_long, param_get_long, ZMOD_RW, - "Percent of arc size for arc meta limit"); + "Percent of ARC size for ARC meta limit"); ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, meta_min, param_set_arc_long, - param_get_long, ZMOD_RW, "Min arc metadata"); + param_get_long, ZMOD_RW, "Minimum ARC metadata size in bytes"); ZFS_MODULE_PARAM(zfs_arc, zfs_arc_, meta_prune, INT, ZMOD_RW, "Meta objects to scan for prune"); @@ -11070,16 +11081,16 @@ ZFS_MODULE_PARAM(zfs_arc, zfs_arc_, meta_strategy, INT, ZMOD_RW, "Meta reclaim strategy"); ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, grow_retry, param_set_arc_int, - param_get_int, ZMOD_RW, "Seconds before growing arc size"); + param_get_int, ZMOD_RW, "Seconds before growing ARC size"); ZFS_MODULE_PARAM(zfs_arc, zfs_arc_, p_dampener_disable, INT, ZMOD_RW, "Disable arc_p adapt dampener"); ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, shrink_shift, param_set_arc_int, - param_get_int, ZMOD_RW, "log2(fraction of arc to reclaim)"); + param_get_int, ZMOD_RW, "log2(fraction of ARC to reclaim)"); ZFS_MODULE_PARAM(zfs_arc, zfs_arc_, pc_percent, UINT, ZMOD_RW, - "Percent of pagecache to reclaim arc to"); + "Percent of pagecache to reclaim ARC to"); ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, p_min_shift, param_set_arc_int, param_get_int, ZMOD_RW, "arc_c shift to calc min/max arc_p"); @@ -11088,7 +11099,7 @@ ZFS_MODULE_PARAM(zfs_arc, zfs_arc_, average_blocksize, INT, ZMOD_RD, "Target average block size"); ZFS_MODULE_PARAM(zfs, zfs_, compressed_arc_enabled, INT, ZMOD_RW, - "Disable compressed arc buffers"); + "Disable compressed ARC buffers"); ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, min_prefetch_ms, param_set_arc_int, param_get_int, ZMOD_RW, "Min life of prefetch block in ms"); @@ -11149,7 +11160,7 @@ ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, sys_free, param_set_arc_long, param_get_long, ZMOD_RW, "System free memory target size in bytes"); ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, dnode_limit, param_set_arc_long, - param_get_long, ZMOD_RW, "Minimum bytes of dnodes in arc"); + param_get_long, ZMOD_RW, "Minimum bytes of dnodes in ARC"); ZFS_MODULE_PARAM_CALL(zfs_arc, zfs_arc_, dnode_limit_percent, param_set_arc_long, param_get_long, ZMOD_RW, diff --git a/sys/contrib/openzfs/module/zfs/dbuf.c b/sys/contrib/openzfs/module/zfs/dbuf.c index ee2470b38606..9a273b010fb1 100644 --- a/sys/contrib/openzfs/module/zfs/dbuf.c +++ b/sys/contrib/openzfs/module/zfs/dbuf.c @@ -339,18 +339,18 @@ dbuf_find(objset_t *os, uint64_t obj, uint8_t level, uint64_t blkid) hv = dbuf_hash(os, obj, level, blkid); idx = hv & h->hash_table_mask; - mutex_enter(DBUF_HASH_MUTEX(h, idx)); + rw_enter(DBUF_HASH_RWLOCK(h, idx), RW_READER); for (db = h->hash_table[idx]; db != NULL; db = db->db_hash_next) { if (DBUF_EQUAL(db, os, obj, level, blkid)) { mutex_enter(&db->db_mtx); if (db->db_state != DB_EVICTING) { - mutex_exit(DBUF_HASH_MUTEX(h, idx)); + rw_exit(DBUF_HASH_RWLOCK(h, idx)); return (db); } mutex_exit(&db->db_mtx); } } - mutex_exit(DBUF_HASH_MUTEX(h, idx)); + rw_exit(DBUF_HASH_RWLOCK(h, idx)); return (NULL); } @@ -393,13 +393,13 @@ dbuf_hash_insert(dmu_buf_impl_t *db) hv = dbuf_hash(os, obj, level, blkid); idx = hv & h->hash_table_mask; - mutex_enter(DBUF_HASH_MUTEX(h, idx)); + rw_enter(DBUF_HASH_RWLOCK(h, idx), RW_WRITER); for (dbf = h->hash_table[idx], i = 0; dbf != NULL; dbf = dbf->db_hash_next, i++) { if (DBUF_EQUAL(dbf, os, obj, level, blkid)) { mutex_enter(&dbf->db_mtx); if (dbf->db_state != DB_EVICTING) { - mutex_exit(DBUF_HASH_MUTEX(h, idx)); + rw_exit(DBUF_HASH_RWLOCK(h, idx)); return (dbf); } mutex_exit(&dbf->db_mtx); @@ -417,7 +417,7 @@ dbuf_hash_insert(dmu_buf_impl_t *db) mutex_enter(&db->db_mtx); db->db_hash_next = h->hash_table[idx]; h->hash_table[idx] = db; - mutex_exit(DBUF_HASH_MUTEX(h, idx)); + rw_exit(DBUF_HASH_RWLOCK(h, idx)); uint64_t he = atomic_inc_64_nv(&dbuf_stats.hash_elements.value.ui64); DBUF_STAT_MAX(hash_elements_max, he); @@ -474,13 +474,13 @@ dbuf_hash_remove(dmu_buf_impl_t *db) /* * We mustn't hold db_mtx to maintain lock ordering: - * DBUF_HASH_MUTEX > db_mtx. + * DBUF_HASH_RWLOCK > db_mtx. */ ASSERT(zfs_refcount_is_zero(&db->db_holds)); ASSERT(db->db_state == DB_EVICTING); ASSERT(!MUTEX_HELD(&db->db_mtx)); - mutex_enter(DBUF_HASH_MUTEX(h, idx)); + rw_enter(DBUF_HASH_RWLOCK(h, idx), RW_WRITER); dbp = &h->hash_table[idx]; while ((dbf = *dbp) != db) { dbp = &dbf->db_hash_next; @@ -491,7 +491,7 @@ dbuf_hash_remove(dmu_buf_impl_t *db) if (h->hash_table[idx] && h->hash_table[idx]->db_hash_next == NULL) DBUF_STAT_BUMPDOWN(hash_chains); - mutex_exit(DBUF_HASH_MUTEX(h, idx)); + rw_exit(DBUF_HASH_RWLOCK(h, idx)); atomic_dec_64(&dbuf_stats.hash_elements.value.ui64); } @@ -914,8 +914,8 @@ dbuf_init(void) sizeof (dmu_buf_impl_t), 0, dbuf_cons, dbuf_dest, NULL, NULL, NULL, 0); - for (i = 0; i < DBUF_MUTEXES; i++) - mutex_init(&h->hash_mutexes[i], NULL, MUTEX_DEFAULT, NULL); + for (i = 0; i < DBUF_RWLOCKS; i++) + rw_init(&h->hash_rwlocks[i], NULL, RW_DEFAULT, NULL); dbuf_stats_init(h); @@ -981,8 +981,8 @@ dbuf_fini(void) dbuf_stats_destroy(); - for (i = 0; i < DBUF_MUTEXES; i++) - mutex_destroy(&h->hash_mutexes[i]); + for (i = 0; i < DBUF_RWLOCKS; i++) + rw_destroy(&h->hash_rwlocks[i]); #if defined(_KERNEL) /* * Large allocations which do not require contiguous pages @@ -3947,7 +3947,7 @@ dmu_buf_get_user(dmu_buf_t *db_fake) } void -dmu_buf_user_evict_wait() +dmu_buf_user_evict_wait(void) { taskq_wait(dbu_evict_taskq); } diff --git a/sys/contrib/openzfs/module/zfs/dbuf_stats.c b/sys/contrib/openzfs/module/zfs/dbuf_stats.c index fa9a5f08060a..a42750ac8e90 100644 --- a/sys/contrib/openzfs/module/zfs/dbuf_stats.c +++ b/sys/contrib/openzfs/module/zfs/dbuf_stats.c @@ -137,7 +137,7 @@ dbuf_stats_hash_table_data(char *buf, size_t size, void *data) if (size) buf[0] = 0; - mutex_enter(DBUF_HASH_MUTEX(h, dsh->idx)); + rw_enter(DBUF_HASH_RWLOCK(h, dsh->idx), RW_READER); for (db = h->hash_table[dsh->idx]; db != NULL; db = db->db_hash_next) { /* * Returning ENOMEM will cause the data and header functions @@ -158,7 +158,7 @@ dbuf_stats_hash_table_data(char *buf, size_t size, void *data) mutex_exit(&db->db_mtx); } - mutex_exit(DBUF_HASH_MUTEX(h, dsh->idx)); + rw_exit(DBUF_HASH_RWLOCK(h, dsh->idx)); return (error); } diff --git a/sys/contrib/openzfs/module/zfs/dmu.c b/sys/contrib/openzfs/module/zfs/dmu.c index 461feeffb6a3..7d8b2c96bd74 100644 --- a/sys/contrib/openzfs/module/zfs/dmu.c +++ b/sys/contrib/openzfs/module/zfs/dmu.c @@ -86,7 +86,7 @@ static int zfs_dmu_offset_next_sync = 1; * helps to limit the amount of memory that can be used by prefetching. * Larger objects should be prefetched a bit at a time. */ -static int dmu_prefetch_max = 8 * SPA_MAXBLOCKSIZE; +int dmu_prefetch_max = 8 * SPA_MAXBLOCKSIZE; const dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES] = { {DMU_BSWAP_UINT8, TRUE, FALSE, FALSE, "unallocated" }, diff --git a/sys/contrib/openzfs/module/zfs/dsl_dataset.c b/sys/contrib/openzfs/module/zfs/dsl_dataset.c index e836d681e920..ca894c35253c 100644 --- a/sys/contrib/openzfs/module/zfs/dsl_dataset.c +++ b/sys/contrib/openzfs/module/zfs/dsl_dataset.c @@ -73,12 +73,19 @@ * The SPA supports block sizes up to 16MB. However, very large blocks * can have an impact on i/o latency (e.g. tying up a spinning disk for * ~300ms), and also potentially on the memory allocator. Therefore, - * we do not allow the recordsize to be set larger than zfs_max_recordsize - * (default 1MB). Larger blocks can be created by changing this tunable, - * and pools with larger blocks can always be imported and used, regardless - * of this setting. + * we did not allow the recordsize to be set larger than zfs_max_recordsize + * (former default: 1MB). Larger blocks could be created by changing this + * tunable, and pools with larger blocks could always be imported and used, + * regardless of this setting. + * + * We do, however, still limit it by default to 1M on x86_32, because Linux's + * 3/1 memory split doesn't leave much room for 16M chunks. */ -int zfs_max_recordsize = 1 * 1024 * 1024; +#ifdef _ILP32 +int zfs_max_recordsize = 1 * 1024 * 1024; +#else +int zfs_max_recordsize = 16 * 1024 * 1024; +#endif static int zfs_allow_redacted_dataset_mount = 0; #define SWITCH64(x, y) \ @@ -3708,6 +3715,15 @@ dsl_dataset_promote_sync(void *arg, dmu_tx_t *tx) dsl_dir_rele(odd, FTAG); promote_rele(ddpa, FTAG); + + /* + * Transfer common error blocks from old head to new head. + */ + if (spa_feature_is_enabled(dp->dp_spa, SPA_FEATURE_HEAD_ERRLOG)) { + uint64_t old_head = origin_head->ds_object; + uint64_t new_head = hds->ds_object; + spa_swap_errlog(dp->dp_spa, new_head, old_head, tx); + } } /* @@ -4924,13 +4940,38 @@ dsl_dataset_activate_redaction(dsl_dataset_t *ds, uint64_t *redact_snaps, ds->ds_feature[SPA_FEATURE_REDACTED_DATASETS] = ftuaa; } -#if defined(_LP64) -#define RECORDSIZE_PERM ZMOD_RW -#else -/* Limited to 1M on 32-bit platforms due to lack of virtual address space */ -#define RECORDSIZE_PERM ZMOD_RD -#endif -ZFS_MODULE_PARAM(zfs, zfs_, max_recordsize, INT, RECORDSIZE_PERM, +/* + * Find and return (in *oldest_dsobj) the oldest snapshot of the dsobj + * dataset whose birth time is >= min_txg. + */ +int +dsl_dataset_oldest_snapshot(spa_t *spa, uint64_t head_ds, uint64_t min_txg, + uint64_t *oldest_dsobj) +{ + dsl_dataset_t *ds; + dsl_pool_t *dp = spa->spa_dsl_pool; + + int error = dsl_dataset_hold_obj(dp, head_ds, FTAG, &ds); + if (error != 0) + return (error); + + uint64_t prev_obj = dsl_dataset_phys(ds)->ds_prev_snap_obj; + uint64_t prev_obj_txg = dsl_dataset_phys(ds)->ds_prev_snap_txg; + + while (prev_obj != 0 && min_txg < prev_obj_txg) { + dsl_dataset_rele(ds, FTAG); + if ((error = dsl_dataset_hold_obj(dp, prev_obj, + FTAG, &ds)) != 0) + return (error); + prev_obj_txg = dsl_dataset_phys(ds)->ds_prev_snap_txg; + prev_obj = dsl_dataset_phys(ds)->ds_prev_snap_obj; + } + *oldest_dsobj = ds->ds_object; + dsl_dataset_rele(ds, FTAG); + return (0); +} + +ZFS_MODULE_PARAM(zfs, zfs_, max_recordsize, INT, ZMOD_RW, "Max allowed record size"); ZFS_MODULE_PARAM(zfs, zfs_, allow_redacted_dataset_mount, INT, ZMOD_RW, diff --git a/sys/contrib/openzfs/module/zfs/dsl_destroy.c b/sys/contrib/openzfs/module/zfs/dsl_destroy.c index b32929b3320c..7dddd8eed5e9 100644 --- a/sys/contrib/openzfs/module/zfs/dsl_destroy.c +++ b/sys/contrib/openzfs/module/zfs/dsl_destroy.c @@ -1153,6 +1153,9 @@ dsl_destroy_head_sync_impl(dsl_dataset_t *ds, dmu_tx_t *tx) dsl_destroy_snapshot_sync_impl(prev, B_FALSE, tx); dsl_dataset_rele(prev, FTAG); } + /* Delete errlog. */ + if (spa_feature_is_enabled(dp->dp_spa, SPA_FEATURE_HEAD_ERRLOG)) + spa_delete_dataset_errlog(dp->dp_spa, ds->ds_object, tx); } void diff --git a/sys/contrib/openzfs/module/zfs/metaslab.c b/sys/contrib/openzfs/module/zfs/metaslab.c index 7ed83b305db7..ab32bfec1310 100644 --- a/sys/contrib/openzfs/module/zfs/metaslab.c +++ b/sys/contrib/openzfs/module/zfs/metaslab.c @@ -48,10 +48,10 @@ /* * Metaslab granularity, in bytes. This is roughly similar to what would be * referred to as the "stripe size" in traditional RAID arrays. In normal - * operation, we will try to write this amount of data to a top-level vdev - * before moving on to the next one. + * operation, we will try to write this amount of data to each disk before + * moving on to the next top-level vdev. */ -static unsigned long metaslab_aliquot = 512 << 10; +static unsigned long metaslab_aliquot = 1024 * 1024; /* * For testing, make some blocks above a certain size be gang blocks. @@ -899,7 +899,8 @@ metaslab_group_activate(metaslab_group_t *mg) if (++mg->mg_activation_count <= 0) return; - mg->mg_aliquot = metaslab_aliquot * MAX(1, mg->mg_vd->vdev_children); + mg->mg_aliquot = metaslab_aliquot * MAX(1, + vdev_get_ndisks(mg->mg_vd) - vdev_get_nparity(mg->mg_vd)); metaslab_group_alloc_update(mg); if ((mgprev = mc->mc_allocator[0].mca_rotor) == NULL) { @@ -2750,7 +2751,8 @@ metaslab_fini_flush_data(metaslab_t *msp) mutex_exit(&spa->spa_flushed_ms_lock); spa_log_sm_decrement_mscount(spa, metaslab_unflushed_txg(msp)); - spa_log_summary_decrement_mscount(spa, metaslab_unflushed_txg(msp)); + spa_log_summary_decrement_mscount(spa, metaslab_unflushed_txg(msp), + metaslab_unflushed_dirty(msp)); } uint64_t @@ -3728,6 +3730,61 @@ metaslab_condense(metaslab_t *msp, dmu_tx_t *tx) metaslab_flush_update(msp, tx); } +static void +metaslab_unflushed_add(metaslab_t *msp, dmu_tx_t *tx) +{ + spa_t *spa = msp->ms_group->mg_vd->vdev_spa; + ASSERT(spa_syncing_log_sm(spa) != NULL); + ASSERT(msp->ms_sm != NULL); + ASSERT(range_tree_is_empty(msp->ms_unflushed_allocs)); + ASSERT(range_tree_is_empty(msp->ms_unflushed_frees)); + + mutex_enter(&spa->spa_flushed_ms_lock); + metaslab_set_unflushed_txg(msp, spa_syncing_txg(spa), tx); + metaslab_set_unflushed_dirty(msp, B_TRUE); + avl_add(&spa->spa_metaslabs_by_flushed, msp); + mutex_exit(&spa->spa_flushed_ms_lock); + + spa_log_sm_increment_current_mscount(spa); + spa_log_summary_add_flushed_metaslab(spa, B_TRUE); +} + +void +metaslab_unflushed_bump(metaslab_t *msp, dmu_tx_t *tx, boolean_t dirty) +{ + spa_t *spa = msp->ms_group->mg_vd->vdev_spa; + ASSERT(spa_syncing_log_sm(spa) != NULL); + ASSERT(msp->ms_sm != NULL); + ASSERT(metaslab_unflushed_txg(msp) != 0); + ASSERT3P(avl_find(&spa->spa_metaslabs_by_flushed, msp, NULL), ==, msp); + ASSERT(range_tree_is_empty(msp->ms_unflushed_allocs)); + ASSERT(range_tree_is_empty(msp->ms_unflushed_frees)); + + VERIFY3U(tx->tx_txg, <=, spa_final_dirty_txg(spa)); + + /* update metaslab's position in our flushing tree */ + uint64_t ms_prev_flushed_txg = metaslab_unflushed_txg(msp); + boolean_t ms_prev_flushed_dirty = metaslab_unflushed_dirty(msp); + mutex_enter(&spa->spa_flushed_ms_lock); + avl_remove(&spa->spa_metaslabs_by_flushed, msp); + metaslab_set_unflushed_txg(msp, spa_syncing_txg(spa), tx); + metaslab_set_unflushed_dirty(msp, dirty); + avl_add(&spa->spa_metaslabs_by_flushed, msp); + mutex_exit(&spa->spa_flushed_ms_lock); + + /* update metaslab counts of spa_log_sm_t nodes */ + spa_log_sm_decrement_mscount(spa, ms_prev_flushed_txg); + spa_log_sm_increment_current_mscount(spa); + + /* update log space map summary */ + spa_log_summary_decrement_mscount(spa, ms_prev_flushed_txg, + ms_prev_flushed_dirty); + spa_log_summary_add_flushed_metaslab(spa, dirty); + + /* cleanup obsolete logs if any */ + spa_cleanup_old_sm_logs(spa, tx); +} + /* * Called when the metaslab has been flushed (its own spacemap now reflects * all the contents of the pool-wide spacemap log). Updates the metaslab's @@ -3743,8 +3800,6 @@ metaslab_flush_update(metaslab_t *msp, dmu_tx_t *tx) ASSERT(MUTEX_HELD(&msp->ms_lock)); ASSERT3U(spa_sync_pass(spa), ==, 1); - ASSERT(range_tree_is_empty(msp->ms_unflushed_allocs)); - ASSERT(range_tree_is_empty(msp->ms_unflushed_frees)); /* * Just because a metaslab got flushed, that doesn't mean that @@ -3757,39 +3812,11 @@ metaslab_flush_update(metaslab_t *msp, dmu_tx_t *tx) * We may end up here from metaslab_condense() without the * feature being active. In that case this is a no-op. */ - if (!spa_feature_is_active(spa, SPA_FEATURE_LOG_SPACEMAP)) + if (!spa_feature_is_active(spa, SPA_FEATURE_LOG_SPACEMAP) || + metaslab_unflushed_txg(msp) == 0) return; - ASSERT(spa_syncing_log_sm(spa) != NULL); - ASSERT(msp->ms_sm != NULL); - ASSERT(metaslab_unflushed_txg(msp) != 0); - ASSERT3P(avl_find(&spa->spa_metaslabs_by_flushed, msp, NULL), ==, msp); - - VERIFY3U(tx->tx_txg, <=, spa_final_dirty_txg(spa)); - - /* update metaslab's position in our flushing tree */ - uint64_t ms_prev_flushed_txg = metaslab_unflushed_txg(msp); - mutex_enter(&spa->spa_flushed_ms_lock); - avl_remove(&spa->spa_metaslabs_by_flushed, msp); - metaslab_set_unflushed_txg(msp, spa_syncing_txg(spa), tx); - avl_add(&spa->spa_metaslabs_by_flushed, msp); - mutex_exit(&spa->spa_flushed_ms_lock); - - /* update metaslab counts of spa_log_sm_t nodes */ - spa_log_sm_decrement_mscount(spa, ms_prev_flushed_txg); - spa_log_sm_increment_current_mscount(spa); - - /* cleanup obsolete logs if any */ - uint64_t log_blocks_before = spa_log_sm_nblocks(spa); - spa_cleanup_old_sm_logs(spa, tx); - uint64_t log_blocks_after = spa_log_sm_nblocks(spa); - VERIFY3U(log_blocks_after, <=, log_blocks_before); - - /* update log space map summary */ - uint64_t blocks_gone = log_blocks_before - log_blocks_after; - spa_log_summary_add_flushed_metaslab(spa); - spa_log_summary_decrement_mscount(spa, ms_prev_flushed_txg); - spa_log_summary_decrement_blkcount(spa, blocks_gone); + metaslab_unflushed_bump(msp, tx, B_FALSE); } boolean_t @@ -4005,23 +4032,6 @@ metaslab_sync(metaslab_t *msp, uint64_t txg) ASSERT0(metaslab_allocated_space(msp)); } - if (metaslab_unflushed_txg(msp) == 0 && - spa_feature_is_active(spa, SPA_FEATURE_LOG_SPACEMAP)) { - ASSERT(spa_syncing_log_sm(spa) != NULL); - - metaslab_set_unflushed_txg(msp, spa_syncing_txg(spa), tx); - spa_log_sm_increment_current_mscount(spa); - spa_log_summary_add_flushed_metaslab(spa); - - ASSERT(msp->ms_sm != NULL); - mutex_enter(&spa->spa_flushed_ms_lock); - avl_add(&spa->spa_metaslabs_by_flushed, msp); - mutex_exit(&spa->spa_flushed_ms_lock); - - ASSERT(range_tree_is_empty(msp->ms_unflushed_allocs)); - ASSERT(range_tree_is_empty(msp->ms_unflushed_frees)); - } - if (!range_tree_is_empty(msp->ms_checkpointing) && vd->vdev_checkpoint_sm == NULL) { ASSERT(spa_has_checkpoint(spa)); @@ -4069,6 +4079,10 @@ metaslab_sync(metaslab_t *msp, uint64_t txg) space_map_t *log_sm = spa_syncing_log_sm(spa); if (log_sm != NULL) { ASSERT(spa_feature_is_enabled(spa, SPA_FEATURE_LOG_SPACEMAP)); + if (metaslab_unflushed_txg(msp) == 0) + metaslab_unflushed_add(msp, tx); + else if (!metaslab_unflushed_dirty(msp)) + metaslab_unflushed_bump(msp, tx, B_TRUE); space_map_write(log_sm, alloctree, SM_ALLOC, vd->vdev_id, tx); @@ -6131,6 +6145,12 @@ metaslab_enable(metaslab_t *msp, boolean_t sync, boolean_t unload) mutex_exit(&mg->mg_ms_disabled_lock); } +void +metaslab_set_unflushed_dirty(metaslab_t *ms, boolean_t dirty) +{ + ms->ms_unflushed_dirty = dirty; +} + static void metaslab_update_ondisk_flush_data(metaslab_t *ms, dmu_tx_t *tx) { @@ -6167,15 +6187,16 @@ metaslab_update_ondisk_flush_data(metaslab_t *ms, dmu_tx_t *tx) void metaslab_set_unflushed_txg(metaslab_t *ms, uint64_t txg, dmu_tx_t *tx) { - spa_t *spa = ms->ms_group->mg_vd->vdev_spa; - - if (!spa_feature_is_active(spa, SPA_FEATURE_LOG_SPACEMAP)) - return; - ms->ms_unflushed_txg = txg; metaslab_update_ondisk_flush_data(ms, tx); } +boolean_t +metaslab_unflushed_dirty(metaslab_t *ms) +{ + return (ms->ms_unflushed_dirty); +} + uint64_t metaslab_unflushed_txg(metaslab_t *ms) { diff --git a/sys/contrib/openzfs/module/zfs/sa.c b/sys/contrib/openzfs/module/zfs/sa.c index 2b6776581a47..db8c2b831f1d 100644 --- a/sys/contrib/openzfs/module/zfs/sa.c +++ b/sys/contrib/openzfs/module/zfs/sa.c @@ -1068,8 +1068,8 @@ sa_setup(objset_t *os, uint64_t sa_obj, const sa_attr_reg_t *reg_attrs, za.za_num_integers); break; } - VERIFY(ddi_strtoull(za.za_name, NULL, 10, - (unsigned long long *)&lot_num) == 0); + VERIFY0(ddi_strtoull(za.za_name, NULL, 10, + (unsigned long long *)&lot_num)); (void) sa_add_layout_entry(os, lot_attrs, za.za_num_integers, lot_num, diff --git a/sys/contrib/openzfs/module/zfs/spa.c b/sys/contrib/openzfs/module/zfs/spa.c index e69cb5527be8..01114dedef48 100644 --- a/sys/contrib/openzfs/module/zfs/spa.c +++ b/sys/contrib/openzfs/module/zfs/spa.c @@ -4355,7 +4355,7 @@ spa_ld_load_vdev_metadata(spa_t *spa) error = spa_ld_log_spacemaps(spa); if (error != 0) { - spa_load_failed(spa, "spa_ld_log_sm_data failed [error=%d]", + spa_load_failed(spa, "spa_ld_log_spacemaps failed [error=%d]", error); return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, error)); } diff --git a/sys/contrib/openzfs/module/zfs/spa_errlog.c b/sys/contrib/openzfs/module/zfs/spa_errlog.c index c6b28ea7d1b8..9e5d1de63c0b 100644 --- a/sys/contrib/openzfs/module/zfs/spa_errlog.c +++ b/sys/contrib/openzfs/module/zfs/spa_errlog.c @@ -20,7 +20,8 @@ */ /* * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2013, 2014 by Delphix. All rights reserved. + * Copyright (c) 2013, 2014, Delphix. All rights reserved. + * Copyright (c) 2021, George Amanakis. All rights reserved. */ /* @@ -43,6 +44,16 @@ * calculation when the data is requested, storing the result so future queries * will be faster. * + * If the head_errlog feature is enabled, a different on-disk format is used. + * The error log of each head dataset is stored separately in the zap object + * and keyed by the head id. This enables listing every dataset affected in + * userland. In order to be able to track whether an error block has been + * modified or added to snapshots since it was marked as an error, a new tuple + * is introduced: zbookmark_err_phys_t. It allows the storage of the birth + * transaction group of an error block on-disk. The birth transaction group is + * used by check_filesystem() to assess whether this block was freed, + * re-written or added to a snapshot since its marking as an error. + * * This log is then shipped into an nvlist where the key is the dataset name and * the value is the object name. Userland is then responsible for uniquifying * this list and displaying it to the user. @@ -53,7 +64,17 @@ #include #include #include +#include +#include +#include +/* + * spa_upgrade_errlog_limit : A zfs module parameter that controls the number + * of on-disk error log entries that will be converted to the new + * format when enabling head_errlog. Defaults to 0 which converts + * all log entries. + */ +static uint32_t spa_upgrade_errlog_limit = 0; /* * Convert a bookmark to a string. @@ -67,9 +88,35 @@ bookmark_to_name(zbookmark_phys_t *zb, char *buf, size_t len) } /* - * Convert a string to a bookmark + * Convert an err_phys to a string. + */ +static void +errphys_to_name(zbookmark_err_phys_t *zep, char *buf, size_t len) +{ + (void) snprintf(buf, len, "%llx:%llx:%llx:%llx", + (u_longlong_t)zep->zb_object, (u_longlong_t)zep->zb_level, + (u_longlong_t)zep->zb_blkid, (u_longlong_t)zep->zb_birth); +} + +/* + * Convert a string to a err_phys. + */ +static void +name_to_errphys(char *buf, zbookmark_err_phys_t *zep) +{ + zep->zb_object = zfs_strtonum(buf, &buf); + ASSERT(*buf == ':'); + zep->zb_level = (int)zfs_strtonum(buf + 1, &buf); + ASSERT(*buf == ':'); + zep->zb_blkid = zfs_strtonum(buf + 1, &buf); + ASSERT(*buf == ':'); + zep->zb_birth = zfs_strtonum(buf + 1, &buf); + ASSERT(*buf == '\0'); +} + +/* + * Convert a string to a bookmark. */ -#ifdef _KERNEL static void name_to_bookmark(char *buf, zbookmark_phys_t *zb) { @@ -82,8 +129,74 @@ name_to_bookmark(char *buf, zbookmark_phys_t *zb) zb->zb_blkid = zfs_strtonum(buf + 1, &buf); ASSERT(*buf == '\0'); } + +#ifdef _KERNEL +static void +zep_to_zb(uint64_t dataset, zbookmark_err_phys_t *zep, zbookmark_phys_t *zb) +{ + zb->zb_objset = dataset; + zb->zb_object = zep->zb_object; + zb->zb_level = zep->zb_level; + zb->zb_blkid = zep->zb_blkid; +} #endif +static void +name_to_object(char *buf, uint64_t *obj) +{ + *obj = zfs_strtonum(buf, &buf); + ASSERT(*buf == '\0'); +} + +static int +get_head_and_birth_txg(spa_t *spa, zbookmark_err_phys_t *zep, uint64_t ds_obj, + uint64_t *head_dataset_id) +{ + dsl_pool_t *dp = spa->spa_dsl_pool; + dsl_dataset_t *ds; + objset_t *os; + + dsl_pool_config_enter(dp, FTAG); + int error = dsl_dataset_hold_obj(dp, ds_obj, FTAG, &ds); + if (error != 0) { + dsl_pool_config_exit(dp, FTAG); + return (error); + } + ASSERT(head_dataset_id); + *head_dataset_id = dsl_dir_phys(ds->ds_dir)->dd_head_dataset_obj; + + error = dmu_objset_from_ds(ds, &os); + if (error != 0) { + dsl_dataset_rele(ds, FTAG); + dsl_pool_config_exit(dp, FTAG); + return (error); + } + + dnode_t *dn; + blkptr_t bp; + + error = dnode_hold(os, zep->zb_object, FTAG, &dn); + if (error != 0) { + dsl_dataset_rele(ds, FTAG); + dsl_pool_config_exit(dp, FTAG); + return (error); + } + + rw_enter(&dn->dn_struct_rwlock, RW_READER); + error = dbuf_dnode_findbp(dn, zep->zb_level, zep->zb_blkid, &bp, NULL, + NULL); + + if (error == 0 && BP_IS_HOLE(&bp)) + error = SET_ERROR(ENOENT); + + zep->zb_birth = bp.blk_birth; + rw_exit(&dn->dn_struct_rwlock); + dnode_rele(dn, FTAG); + dsl_dataset_rele(ds, FTAG); + dsl_pool_config_exit(dp, FTAG); + return (error); +} + /* * Log an uncorrectable error to the persistent error log. We add it to the * spa's list of pending errors. The changes are actually synced out to disk @@ -128,6 +241,276 @@ spa_log_error(spa_t *spa, const zbookmark_phys_t *zb) mutex_exit(&spa->spa_errlist_lock); } +#ifdef _KERNEL +static int +find_birth_txg(dsl_dataset_t *ds, zbookmark_err_phys_t *zep, + uint64_t *birth_txg) +{ + objset_t *os; + int error = dmu_objset_from_ds(ds, &os); + if (error != 0) + return (error); + + dnode_t *dn; + blkptr_t bp; + + error = dnode_hold(os, zep->zb_object, FTAG, &dn); + if (error != 0) + return (error); + + rw_enter(&dn->dn_struct_rwlock, RW_READER); + error = dbuf_dnode_findbp(dn, zep->zb_level, zep->zb_blkid, &bp, NULL, + NULL); + + if (error == 0 && BP_IS_HOLE(&bp)) + error = SET_ERROR(ENOENT); + + *birth_txg = bp.blk_birth; + rw_exit(&dn->dn_struct_rwlock); + dnode_rele(dn, FTAG); + return (error); +} + +/* + * This function serves a double role. If only_count is true, it returns + * (in *count) how many times an error block belonging to this filesystem is + * referenced by snapshots or clones. If only_count is false, each time the + * error block is referenced by a snapshot or clone, it fills the userspace + * array at uaddr with the bookmarks of the error blocks. The array is filled + * from the back and *count is modified to be the number of unused entries at + * the beginning of the array. + */ +static int +check_filesystem(spa_t *spa, uint64_t head_ds, zbookmark_err_phys_t *zep, + uint64_t *count, void *uaddr, boolean_t only_count) +{ + dsl_dataset_t *ds; + dsl_pool_t *dp = spa->spa_dsl_pool; + + int error = dsl_dataset_hold_obj(dp, head_ds, FTAG, &ds); + if (error != 0) + return (error); + + uint64_t latest_txg; + uint64_t txg_to_consider = spa->spa_syncing_txg; + boolean_t check_snapshot = B_TRUE; + error = find_birth_txg(ds, zep, &latest_txg); + if (error == 0) { + if (zep->zb_birth == latest_txg) { + /* Block neither free nor rewritten. */ + if (!only_count) { + zbookmark_phys_t zb; + zep_to_zb(head_ds, zep, &zb); + if (copyout(&zb, (char *)uaddr + (*count - 1) + * sizeof (zbookmark_phys_t), + sizeof (zbookmark_phys_t)) != 0) { + dsl_dataset_rele(ds, FTAG); + return (SET_ERROR(EFAULT)); + } + (*count)--; + } else { + (*count)++; + } + check_snapshot = B_FALSE; + } else { + ASSERT3U(zep->zb_birth, <, latest_txg); + txg_to_consider = latest_txg; + } + } + + /* How many snapshots reference this block. */ + uint64_t snap_count; + error = zap_count(spa->spa_meta_objset, + dsl_dataset_phys(ds)->ds_snapnames_zapobj, &snap_count); + if (error != 0) { + dsl_dataset_rele(ds, FTAG); + return (error); + } + + if (snap_count == 0) { + /* File system has no snapshot. */ + dsl_dataset_rele(ds, FTAG); + return (0); + } + + uint64_t *snap_obj_array = kmem_alloc(snap_count * sizeof (uint64_t), + KM_SLEEP); + + int aff_snap_count = 0; + uint64_t snap_obj = dsl_dataset_phys(ds)->ds_prev_snap_obj; + uint64_t snap_obj_txg = dsl_dataset_phys(ds)->ds_prev_snap_txg; + + /* Check only snapshots created from this file system. */ + while (snap_obj != 0 && zep->zb_birth < snap_obj_txg && + snap_obj_txg <= txg_to_consider) { + + dsl_dataset_rele(ds, FTAG); + error = dsl_dataset_hold_obj(dp, snap_obj, FTAG, &ds); + if (error != 0) + goto out; + + if (dsl_dir_phys(ds->ds_dir)->dd_head_dataset_obj != head_ds) + break; + + boolean_t affected = B_TRUE; + if (check_snapshot) { + uint64_t blk_txg; + error = find_birth_txg(ds, zep, &blk_txg); + affected = (error == 0 && zep->zb_birth == blk_txg); + } + + if (affected) { + snap_obj_array[aff_snap_count] = snap_obj; + aff_snap_count++; + + if (!only_count) { + zbookmark_phys_t zb; + zep_to_zb(snap_obj, zep, &zb); + if (copyout(&zb, (char *)uaddr + (*count - 1) * + sizeof (zbookmark_phys_t), + sizeof (zbookmark_phys_t)) != 0) { + dsl_dataset_rele(ds, FTAG); + error = SET_ERROR(EFAULT); + goto out; + } + (*count)--; + } else { + (*count)++; + } + + /* + * Only clones whose origins were affected could also + * have affected snapshots. + */ + zap_cursor_t zc; + zap_attribute_t za; + for (zap_cursor_init(&zc, spa->spa_meta_objset, + dsl_dataset_phys(ds)->ds_next_clones_obj); + zap_cursor_retrieve(&zc, &za) == 0; + zap_cursor_advance(&zc)) { + error = check_filesystem(spa, + za.za_first_integer, zep, + count, uaddr, only_count); + + if (error != 0) { + zap_cursor_fini(&zc); + goto out; + } + } + zap_cursor_fini(&zc); + } + snap_obj_txg = dsl_dataset_phys(ds)->ds_prev_snap_txg; + snap_obj = dsl_dataset_phys(ds)->ds_prev_snap_obj; + } + dsl_dataset_rele(ds, FTAG); + +out: + kmem_free(snap_obj_array, sizeof (*snap_obj_array)); + return (error); +} + +static int +find_top_affected_fs(spa_t *spa, uint64_t head_ds, zbookmark_err_phys_t *zep, + uint64_t *top_affected_fs) +{ + uint64_t oldest_dsobj; + int error = dsl_dataset_oldest_snapshot(spa, head_ds, zep->zb_birth, + &oldest_dsobj); + if (error != 0) + return (error); + + dsl_dataset_t *ds; + error = dsl_dataset_hold_obj(spa->spa_dsl_pool, oldest_dsobj, + FTAG, &ds); + if (error != 0) + return (error); + + *top_affected_fs = + dsl_dir_phys(ds->ds_dir)->dd_head_dataset_obj; + dsl_dataset_rele(ds, FTAG); + return (0); +} + +static int +process_error_block(spa_t *spa, uint64_t head_ds, zbookmark_err_phys_t *zep, + uint64_t *count, void *uaddr, boolean_t only_count) +{ + dsl_pool_t *dp = spa->spa_dsl_pool; + dsl_pool_config_enter(dp, FTAG); + uint64_t top_affected_fs; + + int error = find_top_affected_fs(spa, head_ds, zep, &top_affected_fs); + if (error == 0) + error = check_filesystem(spa, top_affected_fs, zep, count, + uaddr, only_count); + + dsl_pool_config_exit(dp, FTAG); + return (error); +} + +static uint64_t +get_errlog_size(spa_t *spa, uint64_t spa_err_obj) +{ + if (spa_err_obj == 0) + return (0); + uint64_t total = 0; + + zap_cursor_t zc; + zap_attribute_t za; + for (zap_cursor_init(&zc, spa->spa_meta_objset, spa_err_obj); + zap_cursor_retrieve(&zc, &za) == 0; zap_cursor_advance(&zc)) { + + zap_cursor_t head_ds_cursor; + zap_attribute_t head_ds_attr; + zbookmark_err_phys_t head_ds_block; + + uint64_t head_ds; + name_to_object(za.za_name, &head_ds); + + for (zap_cursor_init(&head_ds_cursor, spa->spa_meta_objset, + za.za_first_integer); zap_cursor_retrieve(&head_ds_cursor, + &head_ds_attr) == 0; zap_cursor_advance(&head_ds_cursor)) { + + name_to_errphys(head_ds_attr.za_name, &head_ds_block); + (void) process_error_block(spa, head_ds, &head_ds_block, + &total, NULL, B_TRUE); + } + zap_cursor_fini(&head_ds_cursor); + } + zap_cursor_fini(&zc); + return (total); +} + +static uint64_t +get_errlist_size(spa_t *spa, avl_tree_t *tree) +{ + if (avl_numnodes(tree) == 0) + return (0); + uint64_t total = 0; + + spa_error_entry_t *se; + for (se = avl_first(tree); se != NULL; se = AVL_NEXT(tree, se)) { + zbookmark_err_phys_t zep; + zep.zb_object = se->se_bookmark.zb_object; + zep.zb_level = se->se_bookmark.zb_level; + zep.zb_blkid = se->se_bookmark.zb_blkid; + + /* + * If we cannot find out the head dataset and birth txg of + * the present error block, we opt not to error out. In the + * next pool sync this information will be retrieved by + * sync_error_list() and written to the on-disk error log. + */ + uint64_t head_ds_obj; + if (get_head_and_birth_txg(spa, &zep, + se->se_bookmark.zb_objset, &head_ds_obj) == 0) + (void) process_error_block(spa, head_ds_obj, &zep, + &total, NULL, B_TRUE); + } + return (total); +} +#endif + /* * Return the number of errors currently in the error log. This is actually the * sum of both the last log and the current log, since we don't know the union @@ -136,83 +519,284 @@ spa_log_error(spa_t *spa, const zbookmark_phys_t *zb) uint64_t spa_get_errlog_size(spa_t *spa) { - uint64_t total = 0, count; + uint64_t total = 0; - mutex_enter(&spa->spa_errlog_lock); - if (spa->spa_errlog_scrub != 0 && - zap_count(spa->spa_meta_objset, spa->spa_errlog_scrub, - &count) == 0) - total += count; + if (!spa_feature_is_enabled(spa, SPA_FEATURE_HEAD_ERRLOG)) { + mutex_enter(&spa->spa_errlog_lock); + uint64_t count; + if (spa->spa_errlog_scrub != 0 && + zap_count(spa->spa_meta_objset, spa->spa_errlog_scrub, + &count) == 0) + total += count; - if (spa->spa_errlog_last != 0 && !spa->spa_scrub_finished && - zap_count(spa->spa_meta_objset, spa->spa_errlog_last, - &count) == 0) - total += count; - mutex_exit(&spa->spa_errlog_lock); + if (spa->spa_errlog_last != 0 && !spa->spa_scrub_finished && + zap_count(spa->spa_meta_objset, spa->spa_errlog_last, + &count) == 0) + total += count; + mutex_exit(&spa->spa_errlog_lock); - mutex_enter(&spa->spa_errlist_lock); - total += avl_numnodes(&spa->spa_errlist_last); - total += avl_numnodes(&spa->spa_errlist_scrub); - mutex_exit(&spa->spa_errlist_lock); + mutex_enter(&spa->spa_errlist_lock); + total += avl_numnodes(&spa->spa_errlist_last); + total += avl_numnodes(&spa->spa_errlist_scrub); + mutex_exit(&spa->spa_errlist_lock); + } else { +#ifdef _KERNEL + mutex_enter(&spa->spa_errlog_lock); + total += get_errlog_size(spa, spa->spa_errlog_last); + total += get_errlog_size(spa, spa->spa_errlog_scrub); + mutex_exit(&spa->spa_errlog_lock); + mutex_enter(&spa->spa_errlist_lock); + total += get_errlist_size(spa, &spa->spa_errlist_last); + total += get_errlist_size(spa, &spa->spa_errlist_scrub); + mutex_exit(&spa->spa_errlist_lock); +#endif + } return (total); } -#ifdef _KERNEL -static int -process_error_log(spa_t *spa, uint64_t obj, void *addr, size_t *count) +/* + * This function sweeps through an on-disk error log and stores all bookmarks + * as error bookmarks in a new ZAP object. At the end we discard the old one, + * and spa_update_errlog() will set the spa's on-disk error log to new ZAP + * object. + */ +static void +sync_upgrade_errlog(spa_t *spa, uint64_t spa_err_obj, uint64_t *newobj, + dmu_tx_t *tx) { zap_cursor_t zc; zap_attribute_t za; zbookmark_phys_t zb; + uint64_t count; + + *newobj = zap_create(spa->spa_meta_objset, DMU_OT_ERROR_LOG, + DMU_OT_NONE, 0, tx); + + /* + * If we cannnot perform the upgrade we should clear the old on-disk + * error logs. + */ + if (zap_count(spa->spa_meta_objset, spa_err_obj, &count) != 0) { + VERIFY0(dmu_object_free(spa->spa_meta_objset, spa_err_obj, tx)); + return; + } + + for (zap_cursor_init(&zc, spa->spa_meta_objset, spa_err_obj); + zap_cursor_retrieve(&zc, &za) == 0; + zap_cursor_advance(&zc)) { + if (spa_upgrade_errlog_limit != 0 && + zc.zc_cd == spa_upgrade_errlog_limit) + break; + + name_to_bookmark(za.za_name, &zb); + + zbookmark_err_phys_t zep; + zep.zb_object = zb.zb_object; + zep.zb_level = zb.zb_level; + zep.zb_blkid = zb.zb_blkid; + + /* + * We cannot use get_head_and_birth_txg() because it will + * acquire the pool config lock, which we already have. In case + * of an error we simply continue. + */ + uint64_t head_dataset_obj; + dsl_pool_t *dp = spa->spa_dsl_pool; + dsl_dataset_t *ds; + objset_t *os; + + int error = dsl_dataset_hold_obj(dp, zb.zb_objset, FTAG, &ds); + if (error != 0) + continue; + + head_dataset_obj = + dsl_dir_phys(ds->ds_dir)->dd_head_dataset_obj; + + /* + * The objset and the dnode are required for getting the block + * pointer, which is used to determine if BP_IS_HOLE(). If + * getting the objset or the dnode fails, do not create a + * zap entry (presuming we know the dataset) as this may create + * spurious errors that we cannot ever resolve. If an error is + * truly persistent, it should re-appear after a scan. + */ + if (dmu_objset_from_ds(ds, &os) != 0) { + dsl_dataset_rele(ds, FTAG); + continue; + } + + dnode_t *dn; + blkptr_t bp; + + if (dnode_hold(os, zep.zb_object, FTAG, &dn) != 0) { + dsl_dataset_rele(ds, FTAG); + continue; + } + + rw_enter(&dn->dn_struct_rwlock, RW_READER); + error = dbuf_dnode_findbp(dn, zep.zb_level, zep.zb_blkid, &bp, + NULL, NULL); + + zep.zb_birth = bp.blk_birth; + rw_exit(&dn->dn_struct_rwlock); + dnode_rele(dn, FTAG); + dsl_dataset_rele(ds, FTAG); + + if (error != 0 || BP_IS_HOLE(&bp)) + continue; + + uint64_t err_obj; + error = zap_lookup_int_key(spa->spa_meta_objset, *newobj, + head_dataset_obj, &err_obj); + + if (error == ENOENT) { + err_obj = zap_create(spa->spa_meta_objset, + DMU_OT_ERROR_LOG, DMU_OT_NONE, 0, tx); + + (void) zap_update_int_key(spa->spa_meta_objset, + *newobj, head_dataset_obj, err_obj, tx); + } + + char buf[64]; + char *name = ""; + errphys_to_name(&zep, buf, sizeof (buf)); + + (void) zap_update(spa->spa_meta_objset, err_obj, + buf, 1, strlen(name) + 1, name, tx); + } + zap_cursor_fini(&zc); + + VERIFY0(dmu_object_free(spa->spa_meta_objset, spa_err_obj, tx)); +} + +void +spa_upgrade_errlog(spa_t *spa, dmu_tx_t *tx) +{ + uint64_t newobj = 0; + + mutex_enter(&spa->spa_errlog_lock); + if (spa->spa_errlog_last != 0) { + sync_upgrade_errlog(spa, spa->spa_errlog_last, &newobj, tx); + spa->spa_errlog_last = newobj; + } + + if (spa->spa_errlog_scrub != 0) { + sync_upgrade_errlog(spa, spa->spa_errlog_scrub, &newobj, tx); + spa->spa_errlog_scrub = newobj; + } + mutex_exit(&spa->spa_errlog_lock); +} + +#ifdef _KERNEL +/* + * If an error block is shared by two datasets it will be counted twice. For + * detailed message see spa_get_errlog_size() above. + */ +static int +process_error_log(spa_t *spa, uint64_t obj, void *uaddr, uint64_t *count) +{ + zap_cursor_t zc; + zap_attribute_t za; if (obj == 0) return (0); + if (!spa_feature_is_enabled(spa, SPA_FEATURE_HEAD_ERRLOG)) { + for (zap_cursor_init(&zc, spa->spa_meta_objset, obj); + zap_cursor_retrieve(&zc, &za) == 0; + zap_cursor_advance(&zc)) { + if (*count == 0) { + zap_cursor_fini(&zc); + return (SET_ERROR(ENOMEM)); + } + + zbookmark_phys_t zb; + name_to_bookmark(za.za_name, &zb); + + if (copyout(&zb, (char *)uaddr + + (*count - 1) * sizeof (zbookmark_phys_t), + sizeof (zbookmark_phys_t)) != 0) { + zap_cursor_fini(&zc); + return (SET_ERROR(EFAULT)); + } + *count -= 1; + + } + zap_cursor_fini(&zc); + return (0); + } + for (zap_cursor_init(&zc, spa->spa_meta_objset, obj); zap_cursor_retrieve(&zc, &za) == 0; zap_cursor_advance(&zc)) { - if (*count == 0) { - zap_cursor_fini(&zc); - return (SET_ERROR(ENOMEM)); + zap_cursor_t head_ds_cursor; + zap_attribute_t head_ds_attr; + + uint64_t head_ds_err_obj = za.za_first_integer; + uint64_t head_ds; + name_to_object(za.za_name, &head_ds); + for (zap_cursor_init(&head_ds_cursor, spa->spa_meta_objset, + head_ds_err_obj); zap_cursor_retrieve(&head_ds_cursor, + &head_ds_attr) == 0; zap_cursor_advance(&head_ds_cursor)) { + + zbookmark_err_phys_t head_ds_block; + name_to_errphys(head_ds_attr.za_name, &head_ds_block); + int error = process_error_block(spa, head_ds, + &head_ds_block, count, uaddr, B_FALSE); + + if (error != 0) { + zap_cursor_fini(&head_ds_cursor); + zap_cursor_fini(&zc); + return (error); + } } - - name_to_bookmark(za.za_name, &zb); - - if (copyout(&zb, (char *)addr + - (*count - 1) * sizeof (zbookmark_phys_t), - sizeof (zbookmark_phys_t)) != 0) { - zap_cursor_fini(&zc); - return (SET_ERROR(EFAULT)); - } - - *count -= 1; + zap_cursor_fini(&head_ds_cursor); } - zap_cursor_fini(&zc); - return (0); } static int -process_error_list(avl_tree_t *list, void *addr, size_t *count) +process_error_list(spa_t *spa, avl_tree_t *list, void *uaddr, uint64_t *count) { spa_error_entry_t *se; - for (se = avl_first(list); se != NULL; se = AVL_NEXT(list, se)) { + if (!spa_feature_is_enabled(spa, SPA_FEATURE_HEAD_ERRLOG)) { + for (se = avl_first(list); se != NULL; + se = AVL_NEXT(list, se)) { - if (*count == 0) - return (SET_ERROR(ENOMEM)); + if (*count == 0) + return (SET_ERROR(ENOMEM)); - if (copyout(&se->se_bookmark, (char *)addr + - (*count - 1) * sizeof (zbookmark_phys_t), - sizeof (zbookmark_phys_t)) != 0) - return (SET_ERROR(EFAULT)); + if (copyout(&se->se_bookmark, (char *)uaddr + + (*count - 1) * sizeof (zbookmark_phys_t), + sizeof (zbookmark_phys_t)) != 0) + return (SET_ERROR(EFAULT)); - *count -= 1; + *count -= 1; + } + return (0); } + for (se = avl_first(list); se != NULL; se = AVL_NEXT(list, se)) { + zbookmark_err_phys_t zep; + zep.zb_object = se->se_bookmark.zb_object; + zep.zb_level = se->se_bookmark.zb_level; + zep.zb_blkid = se->se_bookmark.zb_blkid; + + uint64_t head_ds_obj; + int error = get_head_and_birth_txg(spa, &zep, + se->se_bookmark.zb_objset, &head_ds_obj); + if (error != 0) + return (error); + + error = process_error_block(spa, head_ds_obj, &zep, count, + uaddr, B_FALSE); + if (error != 0) + return (error); + } return (0); } #endif @@ -229,7 +813,7 @@ process_error_list(avl_tree_t *list, void *addr, size_t *count) * the error list lock when we are finished. */ int -spa_get_errlog(spa_t *spa, void *uaddr, size_t *count) +spa_get_errlog(spa_t *spa, void *uaddr, uint64_t *count) { int ret = 0; @@ -244,10 +828,10 @@ spa_get_errlog(spa_t *spa, void *uaddr, size_t *count) mutex_enter(&spa->spa_errlist_lock); if (!ret) - ret = process_error_list(&spa->spa_errlist_scrub, uaddr, + ret = process_error_list(spa, &spa->spa_errlist_scrub, uaddr, count); if (!ret) - ret = process_error_list(&spa->spa_errlist_last, uaddr, + ret = process_error_list(spa, &spa->spa_errlist_last, uaddr, count); mutex_exit(&spa->spa_errlist_lock); @@ -299,35 +883,91 @@ spa_errlog_drain(spa_t *spa) /* * Process a list of errors into the current on-disk log. */ -static void +void sync_error_list(spa_t *spa, avl_tree_t *t, uint64_t *obj, dmu_tx_t *tx) { spa_error_entry_t *se; char buf[64]; void *cookie; - if (avl_numnodes(t) != 0) { - /* create log if necessary */ - if (*obj == 0) - *obj = zap_create(spa->spa_meta_objset, - DMU_OT_ERROR_LOG, DMU_OT_NONE, - 0, tx); + if (avl_numnodes(t) == 0) + return; - /* add errors to the current log */ + /* create log if necessary */ + if (*obj == 0) + *obj = zap_create(spa->spa_meta_objset, DMU_OT_ERROR_LOG, + DMU_OT_NONE, 0, tx); + + /* add errors to the current log */ + if (!spa_feature_is_enabled(spa, SPA_FEATURE_HEAD_ERRLOG)) { for (se = avl_first(t); se != NULL; se = AVL_NEXT(t, se)) { char *name = se->se_name ? se->se_name : ""; bookmark_to_name(&se->se_bookmark, buf, sizeof (buf)); - (void) zap_update(spa->spa_meta_objset, - *obj, buf, 1, strlen(name) + 1, name, tx); + (void) zap_update(spa->spa_meta_objset, *obj, buf, 1, + strlen(name) + 1, name, tx); } + } else { + for (se = avl_first(t); se != NULL; se = AVL_NEXT(t, se)) { + char *name = se->se_name ? se->se_name : ""; - /* purge the error list */ - cookie = NULL; - while ((se = avl_destroy_nodes(t, &cookie)) != NULL) - kmem_free(se, sizeof (spa_error_entry_t)); + zbookmark_err_phys_t zep; + zep.zb_object = se->se_bookmark.zb_object; + zep.zb_level = se->se_bookmark.zb_level; + zep.zb_blkid = se->se_bookmark.zb_blkid; + + /* + * If we cannot find out the head dataset and birth txg + * of the present error block, we simply continue. + * Reinserting that error block to the error lists, + * even if we are not syncing the final txg, results + * in duplicate posting of errors. + */ + uint64_t head_dataset_obj; + int error = get_head_and_birth_txg(spa, &zep, + se->se_bookmark.zb_objset, &head_dataset_obj); + if (error != 0) + continue; + + uint64_t err_obj; + error = zap_lookup_int_key(spa->spa_meta_objset, + *obj, head_dataset_obj, &err_obj); + + if (error == ENOENT) { + err_obj = zap_create(spa->spa_meta_objset, + DMU_OT_ERROR_LOG, DMU_OT_NONE, 0, tx); + + (void) zap_update_int_key(spa->spa_meta_objset, + *obj, head_dataset_obj, err_obj, tx); + } + errphys_to_name(&zep, buf, sizeof (buf)); + + (void) zap_update(spa->spa_meta_objset, + err_obj, buf, 1, strlen(name) + 1, name, tx); + } } + /* purge the error list */ + cookie = NULL; + while ((se = avl_destroy_nodes(t, &cookie)) != NULL) + kmem_free(se, sizeof (spa_error_entry_t)); +} + +static void +delete_errlog(spa_t *spa, uint64_t spa_err_obj, dmu_tx_t *tx) +{ + if (spa_feature_is_enabled(spa, SPA_FEATURE_HEAD_ERRLOG)) { + zap_cursor_t zc; + zap_attribute_t za; + for (zap_cursor_init(&zc, spa->spa_meta_objset, spa_err_obj); + zap_cursor_retrieve(&zc, &za) == 0; + zap_cursor_advance(&zc)) { + VERIFY0(dmu_object_free(spa->spa_meta_objset, + za.za_first_integer, tx)); + } + zap_cursor_fini(&zc); + } + VERIFY0(dmu_object_free(spa->spa_meta_objset, spa_err_obj, tx)); } /* @@ -378,8 +1018,7 @@ spa_errlog_sync(spa_t *spa, uint64_t txg) */ if (scrub_finished) { if (spa->spa_errlog_last != 0) - VERIFY(dmu_object_free(spa->spa_meta_objset, - spa->spa_errlog_last, tx) == 0); + delete_errlog(spa, spa->spa_errlog_last, tx); spa->spa_errlog_last = spa->spa_errlog_scrub; spa->spa_errlog_scrub = 0; @@ -406,6 +1045,137 @@ spa_errlog_sync(spa_t *spa, uint64_t txg) mutex_exit(&spa->spa_errlog_lock); } +static void +delete_dataset_errlog(spa_t *spa, uint64_t spa_err_obj, uint64_t ds, + dmu_tx_t *tx) +{ + if (spa_err_obj == 0) + return; + + zap_cursor_t zc; + zap_attribute_t za; + for (zap_cursor_init(&zc, spa->spa_meta_objset, spa_err_obj); + zap_cursor_retrieve(&zc, &za) == 0; zap_cursor_advance(&zc)) { + uint64_t head_ds; + name_to_object(za.za_name, &head_ds); + if (head_ds == ds) { + (void) zap_remove(spa->spa_meta_objset, spa_err_obj, + za.za_name, tx); + VERIFY0(dmu_object_free(spa->spa_meta_objset, + za.za_first_integer, tx)); + break; + } + } + zap_cursor_fini(&zc); +} + +void +spa_delete_dataset_errlog(spa_t *spa, uint64_t ds, dmu_tx_t *tx) +{ + mutex_enter(&spa->spa_errlog_lock); + delete_dataset_errlog(spa, spa->spa_errlog_scrub, ds, tx); + delete_dataset_errlog(spa, spa->spa_errlog_last, ds, tx); + mutex_exit(&spa->spa_errlog_lock); +} + +static int +find_txg_ancestor_snapshot(spa_t *spa, uint64_t new_head, uint64_t old_head, + uint64_t *txg) +{ + dsl_dataset_t *ds; + dsl_pool_t *dp = spa->spa_dsl_pool; + + int error = dsl_dataset_hold_obj(dp, old_head, FTAG, &ds); + if (error != 0) + return (error); + + uint64_t prev_obj = dsl_dataset_phys(ds)->ds_prev_snap_obj; + uint64_t prev_obj_txg = dsl_dataset_phys(ds)->ds_prev_snap_txg; + + while (prev_obj != 0) { + dsl_dataset_rele(ds, FTAG); + if ((error = dsl_dataset_hold_obj(dp, prev_obj, + FTAG, &ds)) == 0 && + dsl_dir_phys(ds->ds_dir)->dd_head_dataset_obj == new_head) + break; + + if (error != 0) + return (error); + + prev_obj_txg = dsl_dataset_phys(ds)->ds_prev_snap_txg; + prev_obj = dsl_dataset_phys(ds)->ds_prev_snap_obj; + } + dsl_dataset_rele(ds, FTAG); + ASSERT(prev_obj != 0); + *txg = prev_obj_txg; + return (0); +} + +static void +swap_errlog(spa_t *spa, uint64_t spa_err_obj, uint64_t new_head, uint64_t + old_head, dmu_tx_t *tx) +{ + if (spa_err_obj == 0) + return; + + uint64_t old_head_errlog; + int error = zap_lookup_int_key(spa->spa_meta_objset, spa_err_obj, + old_head, &old_head_errlog); + + /* If no error log, then there is nothing to do. */ + if (error != 0) + return; + + uint64_t txg; + error = find_txg_ancestor_snapshot(spa, new_head, old_head, &txg); + if (error != 0) + return; + + /* + * Create an error log if the file system being promoted does not + * already have one. + */ + uint64_t new_head_errlog; + error = zap_lookup_int_key(spa->spa_meta_objset, spa_err_obj, new_head, + &new_head_errlog); + + if (error != 0) { + new_head_errlog = zap_create(spa->spa_meta_objset, + DMU_OT_ERROR_LOG, DMU_OT_NONE, 0, tx); + + (void) zap_update_int_key(spa->spa_meta_objset, spa_err_obj, + new_head, new_head_errlog, tx); + } + + zap_cursor_t zc; + zap_attribute_t za; + zbookmark_err_phys_t err_block; + for (zap_cursor_init(&zc, spa->spa_meta_objset, old_head_errlog); + zap_cursor_retrieve(&zc, &za) == 0; zap_cursor_advance(&zc)) { + + char *name = ""; + name_to_errphys(za.za_name, &err_block); + if (err_block.zb_birth < txg) { + (void) zap_update(spa->spa_meta_objset, new_head_errlog, + za.za_name, 1, strlen(name) + 1, name, tx); + + (void) zap_remove(spa->spa_meta_objset, old_head_errlog, + za.za_name, tx); + } + } + zap_cursor_fini(&zc); +} + +void +spa_swap_errlog(spa_t *spa, uint64_t new_head_ds, uint64_t old_head_ds, + dmu_tx_t *tx) +{ + mutex_enter(&spa->spa_errlog_lock); + swap_errlog(spa, spa->spa_errlog_scrub, new_head_ds, old_head_ds, tx); + swap_errlog(spa, spa->spa_errlog_last, new_head_ds, old_head_ds, tx); + mutex_exit(&spa->spa_errlog_lock); +} + #if defined(_KERNEL) /* error handling */ EXPORT_SYMBOL(spa_log_error); @@ -415,4 +1185,14 @@ EXPORT_SYMBOL(spa_errlog_rotate); EXPORT_SYMBOL(spa_errlog_drain); EXPORT_SYMBOL(spa_errlog_sync); EXPORT_SYMBOL(spa_get_errlists); +EXPORT_SYMBOL(spa_delete_dataset_errlog); +EXPORT_SYMBOL(spa_swap_errlog); +EXPORT_SYMBOL(sync_error_list); +EXPORT_SYMBOL(spa_upgrade_errlog); #endif + +/* BEGIN CSTYLED */ +ZFS_MODULE_PARAM(zfs_spa, spa_, upgrade_errlog_limit, INT, ZMOD_RW, + "Limit the number of errors which will be upgraded to the new " + "on-disk error log when enabling head_errlog"); +/* END CSTYLED */ diff --git a/sys/contrib/openzfs/module/zfs/spa_log_spacemap.c b/sys/contrib/openzfs/module/zfs/spa_log_spacemap.c index 110a4eab99f9..f831509a4247 100644 --- a/sys/contrib/openzfs/module/zfs/spa_log_spacemap.c +++ b/sys/contrib/openzfs/module/zfs/spa_log_spacemap.c @@ -257,7 +257,12 @@ static unsigned long zfs_unflushed_log_block_min = 1000; * terms of performance. Thus we have a hard limit in the size of the log in * terms of blocks. */ -static unsigned long zfs_unflushed_log_block_max = (1ULL << 18); +static unsigned long zfs_unflushed_log_block_max = (1ULL << 17); + +/* + * Also we have a hard limit in the size of the log in terms of dirty TXGs. + */ +static unsigned long zfs_unflushed_log_txg_max = 1000; /* * Max # of rows allowed for the log_summary. The tradeoff here is accuracy and @@ -333,9 +338,13 @@ spa_log_sm_set_blocklimit(spa_t *spa) return; } - uint64_t calculated_limit = - (spa_total_metaslabs(spa) * zfs_unflushed_log_block_pct) / 100; - spa->spa_unflushed_stats.sus_blocklimit = MIN(MAX(calculated_limit, + uint64_t msdcount = 0; + for (log_summary_entry_t *e = list_head(&spa->spa_log_summary); + e; e = list_next(&spa->spa_log_summary, e)) + msdcount += e->lse_msdcount; + + uint64_t limit = msdcount * zfs_unflushed_log_block_pct / 100; + spa->spa_unflushed_stats.sus_blocklimit = MIN(MAX(limit, zfs_unflushed_log_block_min), zfs_unflushed_log_block_max); } @@ -380,8 +389,13 @@ spa_log_summary_verify_counts(spa_t *spa) } static boolean_t -summary_entry_is_full(spa_t *spa, log_summary_entry_t *e) +summary_entry_is_full(spa_t *spa, log_summary_entry_t *e, uint64_t txg) { + if (e->lse_end == txg) + return (0); + if (e->lse_txgcount >= DIV_ROUND_UP(zfs_unflushed_log_txg_max, + zfs_max_logsm_summary_length)) + return (1); uint64_t blocks_per_row = MAX(1, DIV_ROUND_UP(spa_log_sm_blocklimit(spa), zfs_max_logsm_summary_length)); @@ -401,7 +415,7 @@ summary_entry_is_full(spa_t *spa, log_summary_entry_t *e) * the metaslab. */ void -spa_log_summary_decrement_mscount(spa_t *spa, uint64_t txg) +spa_log_summary_decrement_mscount(spa_t *spa, uint64_t txg, boolean_t dirty) { /* * We don't track summary data for read-only pools and this function @@ -429,6 +443,8 @@ spa_log_summary_decrement_mscount(spa_t *spa, uint64_t txg) } target->lse_mscount--; + if (dirty) + target->lse_msdcount--; } /* @@ -490,8 +506,10 @@ spa_log_summary_decrement_mscount(spa_t *spa, uint64_t txg) void spa_log_summary_decrement_blkcount(spa_t *spa, uint64_t blocks_gone) { - for (log_summary_entry_t *e = list_head(&spa->spa_log_summary); - e != NULL; e = list_head(&spa->spa_log_summary)) { + log_summary_entry_t *e = list_head(&spa->spa_log_summary); + if (e->lse_txgcount > 0) + e->lse_txgcount--; + for (; e != NULL; e = list_head(&spa->spa_log_summary)) { if (e->lse_blkcount > blocks_gone) { /* * Assert that we stopped at an entry that is not @@ -560,31 +578,52 @@ spa_log_sm_increment_current_mscount(spa_t *spa) static void summary_add_data(spa_t *spa, uint64_t txg, uint64_t metaslabs_flushed, - uint64_t nblocks) + uint64_t metaslabs_dirty, uint64_t nblocks) { log_summary_entry_t *e = list_tail(&spa->spa_log_summary); - if (e == NULL || summary_entry_is_full(spa, e)) { + if (e == NULL || summary_entry_is_full(spa, e, txg)) { e = kmem_zalloc(sizeof (log_summary_entry_t), KM_SLEEP); - e->lse_start = txg; + e->lse_start = e->lse_end = txg; + e->lse_txgcount = 1; list_insert_tail(&spa->spa_log_summary, e); } ASSERT3U(e->lse_start, <=, txg); + if (e->lse_end < txg) { + e->lse_end = txg; + e->lse_txgcount++; + } e->lse_mscount += metaslabs_flushed; + e->lse_msdcount += metaslabs_dirty; e->lse_blkcount += nblocks; } static void spa_log_summary_add_incoming_blocks(spa_t *spa, uint64_t nblocks) { - summary_add_data(spa, spa_syncing_txg(spa), 0, nblocks); + summary_add_data(spa, spa_syncing_txg(spa), 0, 0, nblocks); } void -spa_log_summary_add_flushed_metaslab(spa_t *spa) +spa_log_summary_add_flushed_metaslab(spa_t *spa, boolean_t dirty) { - summary_add_data(spa, spa_syncing_txg(spa), 1, 0); + summary_add_data(spa, spa_syncing_txg(spa), 1, dirty ? 1 : 0, 0); +} + +void +spa_log_summary_dirty_flushed_metaslab(spa_t *spa, uint64_t txg) +{ + log_summary_entry_t *target = NULL; + for (log_summary_entry_t *e = list_head(&spa->spa_log_summary); + e != NULL; e = list_next(&spa->spa_log_summary, e)) { + if (e->lse_start > txg) + break; + target = e; + } + ASSERT3P(target, !=, NULL); + ASSERT3U(target->lse_mscount, !=, 0); + target->lse_msdcount++; } /* @@ -630,6 +669,11 @@ spa_estimate_metaslabs_to_flush(spa_t *spa) int64_t available_blocks = spa_log_sm_blocklimit(spa) - spa_log_sm_nblocks(spa) - incoming; + int64_t available_txgs = zfs_unflushed_log_txg_max; + for (log_summary_entry_t *e = list_head(&spa->spa_log_summary); + e; e = list_next(&spa->spa_log_summary, e)) + available_txgs -= e->lse_txgcount; + /* * This variable tells us the total number of flushes needed to * keep the log size within the limit when we reach txgs_in_future. @@ -637,9 +681,7 @@ spa_estimate_metaslabs_to_flush(spa_t *spa) uint64_t total_flushes = 0; /* Holds the current maximum of our estimates so far. */ - uint64_t max_flushes_pertxg = - MIN(avl_numnodes(&spa->spa_metaslabs_by_flushed), - zfs_min_metaslabs_to_flush); + uint64_t max_flushes_pertxg = zfs_min_metaslabs_to_flush; /* * For our estimations we only look as far in the future @@ -653,11 +695,14 @@ spa_estimate_metaslabs_to_flush(spa_t *spa) * then keep skipping TXGs accumulating more blocks * based on the incoming rate until we exceed it. */ - if (available_blocks >= 0) { - uint64_t skip_txgs = (available_blocks / incoming) + 1; + if (available_blocks >= 0 && available_txgs >= 0) { + uint64_t skip_txgs = MIN(available_txgs + 1, + (available_blocks / incoming) + 1); available_blocks -= (skip_txgs * incoming); + available_txgs -= skip_txgs; txgs_in_future += skip_txgs; ASSERT3S(available_blocks, >=, -incoming); + ASSERT3S(available_txgs, >=, -1); } /* @@ -666,9 +711,10 @@ spa_estimate_metaslabs_to_flush(spa_t *spa) * based on the current entry in the summary, updating * our available_blocks. */ - ASSERT3S(available_blocks, <, 0); + ASSERT(available_blocks < 0 || available_txgs < 0); available_blocks += e->lse_blkcount; - total_flushes += e->lse_mscount; + available_txgs += e->lse_txgcount; + total_flushes += e->lse_msdcount; /* * Keep the running maximum of the total_flushes that @@ -680,8 +726,6 @@ spa_estimate_metaslabs_to_flush(spa_t *spa) */ max_flushes_pertxg = MAX(max_flushes_pertxg, DIV_ROUND_UP(total_flushes, txgs_in_future)); - ASSERT3U(avl_numnodes(&spa->spa_metaslabs_by_flushed), >=, - max_flushes_pertxg); } return (max_flushes_pertxg); } @@ -771,14 +815,11 @@ spa_flush_metaslabs(spa_t *spa, dmu_tx_t *tx) uint64_t want_to_flush; if (spa_flush_all_logs_requested(spa)) { ASSERT3S(spa_state(spa), ==, POOL_STATE_EXPORTED); - want_to_flush = avl_numnodes(&spa->spa_metaslabs_by_flushed); + want_to_flush = UINT64_MAX; } else { want_to_flush = spa_estimate_metaslabs_to_flush(spa); } - ASSERT3U(avl_numnodes(&spa->spa_metaslabs_by_flushed), >=, - want_to_flush); - /* Used purely for verification purposes */ uint64_t visited = 0; @@ -809,31 +850,22 @@ spa_flush_metaslabs(spa_t *spa, dmu_tx_t *tx) if (want_to_flush == 0 && !spa_log_exceeds_memlimit(spa)) break; - mutex_enter(&curr->ms_sync_lock); - mutex_enter(&curr->ms_lock); - boolean_t flushed = metaslab_flush(curr, tx); - mutex_exit(&curr->ms_lock); - mutex_exit(&curr->ms_sync_lock); - - /* - * If we failed to flush a metaslab (because it was loading), - * then we are done with the block heuristic as it's not - * possible to destroy any log space maps once you've skipped - * a metaslab. In that case we just set our counter to 0 but - * we continue looping in case there is still memory pressure - * due to unflushed changes. Note that, flushing a metaslab - * that is not the oldest flushed in the pool, will never - * destroy any log space maps [see spa_cleanup_old_sm_logs()]. - */ - if (!flushed) { - want_to_flush = 0; - } else if (want_to_flush > 0) { - want_to_flush--; - } + if (metaslab_unflushed_dirty(curr)) { + mutex_enter(&curr->ms_sync_lock); + mutex_enter(&curr->ms_lock); + metaslab_flush(curr, tx); + mutex_exit(&curr->ms_lock); + mutex_exit(&curr->ms_sync_lock); + if (want_to_flush > 0) + want_to_flush--; + } else + metaslab_unflushed_bump(curr, tx, B_FALSE); visited++; } ASSERT3U(avl_numnodes(&spa->spa_metaslabs_by_flushed), >=, visited); + + spa_log_sm_set_blocklimit(spa); } /* @@ -904,6 +936,7 @@ spa_cleanup_old_sm_logs(spa_t *spa, dmu_tx_t *tx) avl_remove(&spa->spa_sm_logs_by_txg, sls); space_map_free_obj(mos, sls->sls_sm_obj, tx); VERIFY0(zap_remove_int(mos, spacemap_zap, sls->sls_txg, tx)); + spa_log_summary_decrement_blkcount(spa, sls->sls_nblocks); spa->spa_unflushed_stats.sus_nblocks -= sls->sls_nblocks; kmem_free(sls, sizeof (spa_log_sm_t)); } @@ -963,12 +996,7 @@ spa_generate_syncing_log_sm(spa_t *spa, dmu_tx_t *tx) VERIFY0(space_map_open(&spa->spa_syncing_log_sm, mos, sm_obj, 0, UINT64_MAX, SPA_MINBLOCKSHIFT)); - /* - * If the log space map feature was just enabled, the blocklimit - * has not yet been set. - */ - if (spa_log_sm_blocklimit(spa) == 0) - spa_log_sm_set_blocklimit(spa); + spa_log_sm_set_blocklimit(spa); } /* @@ -1094,12 +1122,18 @@ spa_ld_log_sm_cb(space_map_entry_t *sme, void *arg) panic("invalid maptype_t"); break; } + if (!metaslab_unflushed_dirty(ms)) { + metaslab_set_unflushed_dirty(ms, B_TRUE); + spa_log_summary_dirty_flushed_metaslab(spa, + metaslab_unflushed_txg(ms)); + } return (0); } static int spa_ld_log_sm_data(spa_t *spa) { + spa_log_sm_t *sls, *psls; int error = 0; /* @@ -1113,41 +1147,71 @@ spa_ld_log_sm_data(spa_t *spa) ASSERT0(spa->spa_unflushed_stats.sus_memused); hrtime_t read_logs_starttime = gethrtime(); - /* this is a no-op when we don't have space map logs */ - for (spa_log_sm_t *sls = avl_first(&spa->spa_sm_logs_by_txg); - sls; sls = AVL_NEXT(&spa->spa_sm_logs_by_txg, sls)) { - space_map_t *sm = NULL; - error = space_map_open(&sm, spa_meta_objset(spa), - sls->sls_sm_obj, 0, UINT64_MAX, SPA_MINBLOCKSHIFT); - if (error != 0) { - spa_load_failed(spa, "spa_ld_log_sm_data(): failed at " - "space_map_open(obj=%llu) [error %d]", - (u_longlong_t)sls->sls_sm_obj, error); - goto out; + + /* Prefetch log spacemaps dnodes. */ + for (sls = avl_first(&spa->spa_sm_logs_by_txg); sls; + sls = AVL_NEXT(&spa->spa_sm_logs_by_txg, sls)) { + dmu_prefetch(spa_meta_objset(spa), sls->sls_sm_obj, + 0, 0, 0, ZIO_PRIORITY_SYNC_READ); + } + + uint_t pn = 0; + uint64_t ps = 0; + psls = sls = avl_first(&spa->spa_sm_logs_by_txg); + while (sls != NULL) { + /* Prefetch log spacemaps up to 16 TXGs or MBs ahead. */ + if (psls != NULL && pn < 16 && + (pn < 2 || ps < 2 * dmu_prefetch_max)) { + error = space_map_open(&psls->sls_sm, + spa_meta_objset(spa), psls->sls_sm_obj, 0, + UINT64_MAX, SPA_MINBLOCKSHIFT); + if (error != 0) { + spa_load_failed(spa, "spa_ld_log_sm_data(): " + "failed at space_map_open(obj=%llu) " + "[error %d]", + (u_longlong_t)sls->sls_sm_obj, error); + goto out; + } + dmu_prefetch(spa_meta_objset(spa), psls->sls_sm_obj, + 0, 0, space_map_length(psls->sls_sm), + ZIO_PRIORITY_ASYNC_READ); + pn++; + ps += space_map_length(psls->sls_sm); + psls = AVL_NEXT(&spa->spa_sm_logs_by_txg, psls); + continue; } + /* Load TXG log spacemap into ms_unflushed_allocs/frees. */ + cond_resched(); + ASSERT0(sls->sls_nblocks); + sls->sls_nblocks = space_map_nblocks(sls->sls_sm); + spa->spa_unflushed_stats.sus_nblocks += sls->sls_nblocks; + summary_add_data(spa, sls->sls_txg, + sls->sls_mscount, 0, sls->sls_nblocks); + struct spa_ld_log_sm_arg vla = { .slls_spa = spa, .slls_txg = sls->sls_txg }; - error = space_map_iterate(sm, space_map_length(sm), - spa_ld_log_sm_cb, &vla); + error = space_map_iterate(sls->sls_sm, + space_map_length(sls->sls_sm), spa_ld_log_sm_cb, &vla); if (error != 0) { - space_map_close(sm); spa_load_failed(spa, "spa_ld_log_sm_data(): failed " "at space_map_iterate(obj=%llu) [error %d]", (u_longlong_t)sls->sls_sm_obj, error); goto out; } - ASSERT0(sls->sls_nblocks); - sls->sls_nblocks = space_map_nblocks(sm); - spa->spa_unflushed_stats.sus_nblocks += sls->sls_nblocks; - summary_add_data(spa, sls->sls_txg, - sls->sls_mscount, sls->sls_nblocks); + pn--; + ps -= space_map_length(sls->sls_sm); + space_map_close(sls->sls_sm); + sls->sls_sm = NULL; + sls = AVL_NEXT(&spa->spa_sm_logs_by_txg, sls); - space_map_close(sm); + /* Update log block limits considering just loaded. */ + spa_log_sm_set_blocklimit(spa); } + hrtime_t read_logs_endtime = gethrtime(); spa_load_note(spa, "read %llu log space maps (%llu total blocks - blksz = %llu bytes) " @@ -1157,6 +1221,18 @@ spa_ld_log_sm_data(spa_t *spa) (longlong_t)((read_logs_endtime - read_logs_starttime) / 1000000)); out: + if (error != 0) { + for (spa_log_sm_t *sls = avl_first(&spa->spa_sm_logs_by_txg); + sls; sls = AVL_NEXT(&spa->spa_sm_logs_by_txg, sls)) { + if (sls->sls_sm) { + space_map_close(sls->sls_sm); + sls->sls_sm = NULL; + } + } + } else { + ASSERT0(pn); + ASSERT0(ps); + } /* * Now that the metaslabs contain their unflushed changes: * [1] recalculate their actual allocated space @@ -1237,6 +1313,9 @@ spa_ld_unflushed_txgs(vdev_t *vd) } ms->ms_unflushed_txg = entry.msp_unflushed_txg; + ms->ms_unflushed_dirty = B_FALSE; + ASSERT(range_tree_is_empty(ms->ms_unflushed_allocs)); + ASSERT(range_tree_is_empty(ms->ms_unflushed_frees)); if (ms->ms_unflushed_txg != 0) { mutex_enter(&spa->spa_flushed_ms_lock); avl_add(&spa->spa_metaslabs_by_flushed, ms); @@ -1300,6 +1379,10 @@ ZFS_MODULE_PARAM(zfs, zfs_, unflushed_log_block_min, ULONG, ZMOD_RW, "Lower-bound limit for the maximum amount of blocks allowed in " "log spacemap (see zfs_unflushed_log_block_max)"); +ZFS_MODULE_PARAM(zfs, zfs_, unflushed_log_txg_max, ULONG, ZMOD_RW, + "Hard limit (upper-bound) in the size of the space map log " + "in terms of dirty TXGs."); + ZFS_MODULE_PARAM(zfs, zfs_, unflushed_log_block_pct, ULONG, ZMOD_RW, "Tunable used to determine the number of blocks that can be used for " "the spacemap log, expressed as a percentage of the total number of " diff --git a/sys/contrib/openzfs/module/zfs/vdev.c b/sys/contrib/openzfs/module/zfs/vdev.c index db2d2c5e44fb..ce7f020a0d86 100644 --- a/sys/contrib/openzfs/module/zfs/vdev.c +++ b/sys/contrib/openzfs/module/zfs/vdev.c @@ -1523,13 +1523,6 @@ vdev_metaslab_init(vdev_t *vd, uint64_t txg) if (txg == 0) spa_config_exit(spa, SCL_ALLOC, FTAG); - /* - * Regardless whether this vdev was just added or it is being - * expanded, the metaslab count has changed. Recalculate the - * block limit. - */ - spa_log_sm_set_blocklimit(spa); - return (0); } diff --git a/sys/contrib/openzfs/module/zfs/vdev_removal.c b/sys/contrib/openzfs/module/zfs/vdev_removal.c index 17f9d6c90804..5508d273758d 100644 --- a/sys/contrib/openzfs/module/zfs/vdev_removal.c +++ b/sys/contrib/openzfs/module/zfs/vdev_removal.c @@ -1386,7 +1386,6 @@ vdev_remove_complete(spa_t *spa) vdev_metaslab_fini(vd); metaslab_group_destroy(vd->vdev_mg); vd->vdev_mg = NULL; - spa_log_sm_set_blocklimit(spa); } if (vd->vdev_log_mg != NULL) { ASSERT0(vd->vdev_ms_count); @@ -2131,7 +2130,6 @@ spa_vdev_remove_log(vdev_t *vd, uint64_t *txg) * metaslab_class_histogram_verify() */ vdev_metaslab_fini(vd); - spa_log_sm_set_blocklimit(spa); spa_vdev_config_exit(spa, NULL, *txg, 0, FTAG); *txg = spa_vdev_config_enter(spa); @@ -2251,7 +2249,6 @@ spa_vdev_remove_top_check(vdev_t *vd) * and not be raidz or draid. */ vdev_t *rvd = spa->spa_root_vdev; - int num_indirect = 0; for (uint64_t id = 0; id < rvd->vdev_children; id++) { vdev_t *cvd = rvd->vdev_child[id]; @@ -2267,8 +2264,6 @@ spa_vdev_remove_top_check(vdev_t *vd) if (cvd->vdev_ashift != 0 && cvd->vdev_alloc_bias == VDEV_BIAS_NONE) ASSERT3U(cvd->vdev_ashift, ==, spa->spa_max_ashift); - if (cvd->vdev_ops == &vdev_indirect_ops) - num_indirect++; if (!vdev_is_concrete(cvd)) continue; if (vdev_get_nparity(cvd) != 0) diff --git a/sys/contrib/openzfs/module/zfs/zfeature.c b/sys/contrib/openzfs/module/zfs/zfeature.c index 9d16fff81d0a..fc9167aa6611 100644 --- a/sys/contrib/openzfs/module/zfs/zfeature.c +++ b/sys/contrib/openzfs/module/zfs/zfeature.c @@ -389,6 +389,13 @@ feature_enable_sync(spa_t *spa, zfeature_info_t *feature, dmu_tx_t *tx) !spa_feature_is_active(spa, SPA_FEATURE_ENCRYPTION) && feature->fi_feature == SPA_FEATURE_BOOKMARK_V2) spa->spa_errata = 0; + + /* + * Convert the old on-disk error log to the new format when activating + * the head_errlog feature. + */ + if (feature->fi_feature == SPA_FEATURE_HEAD_ERRLOG) + spa_upgrade_errlog(spa, tx); } static void diff --git a/sys/contrib/openzfs/module/zfs/zfs_ioctl.c b/sys/contrib/openzfs/module/zfs/zfs_ioctl.c index a2824c5cc804..b3f32d64f3ef 100644 --- a/sys/contrib/openzfs/module/zfs/zfs_ioctl.c +++ b/sys/contrib/openzfs/module/zfs/zfs_ioctl.c @@ -5670,7 +5670,7 @@ zfs_ioc_error_log(zfs_cmd_t *zc) { spa_t *spa; int error; - size_t count = (size_t)zc->zc_nvlist_dst_size; + uint64_t count = zc->zc_nvlist_dst_size; if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0) return (error); diff --git a/sys/contrib/openzfs/module/zfs/zfs_vnops.c b/sys/contrib/openzfs/module/zfs/zfs_vnops.c index 62806e9fe8b1..a039b4da2833 100644 --- a/sys/contrib/openzfs/module/zfs/zfs_vnops.c +++ b/sys/contrib/openzfs/module/zfs/zfs_vnops.c @@ -68,7 +68,9 @@ zfs_fsync(znode_t *zp, int syncflag, cred_t *cr) if (zfsvfs->z_os->os_sync != ZFS_SYNC_DISABLED) { ZFS_ENTER(zfsvfs); ZFS_VERIFY_ZP(zp); + atomic_inc_32(&zp->z_sync_writes_cnt); zil_commit(zfsvfs->z_log, zp->z_id); + atomic_dec_32(&zp->z_sync_writes_cnt); ZFS_EXIT(zfsvfs); } tsd_set(zfs_fsyncer_key, NULL); @@ -357,11 +359,11 @@ zfs_clear_setid_bits_if_necessary(zfsvfs_t *zfsvfs, znode_t *zp, cred_t *cr, if (*clear_setid_bits_txgp != dmu_tx_get_txg(tx)) { vattr_t va = {0}; - va.va_mask = AT_MODE; + va.va_mask = ATTR_MODE; va.va_nodeid = zp->z_id; va.va_mode = newmode; - zfs_log_setattr(zilog, tx, TX_SETATTR, zp, &va, AT_MODE, - NULL); + zfs_log_setattr(zilog, tx, TX_SETATTR, zp, &va, + ATTR_MODE, NULL); *clear_setid_bits_txgp = dmu_tx_get_txg(tx); } } else { diff --git a/sys/contrib/openzfs/module/zfs/zio.c b/sys/contrib/openzfs/module/zfs/zio.c index f6adea572418..2a16d5cef2e2 100644 --- a/sys/contrib/openzfs/module/zfs/zio.c +++ b/sys/contrib/openzfs/module/zfs/zio.c @@ -166,15 +166,6 @@ zio_init(void) cflags = (zio_exclude_metadata || size > zio_buf_debug_limit) ? KMC_NODEBUG : 0; -#if defined(_ILP32) && defined(_KERNEL) - /* - * Cache size limited to 1M on 32-bit platforms until ARC - * buffers no longer require virtual address space. - */ - if (size > zfs_max_recordsize) - break; -#endif - while (!ISP2(p2)) p2 &= p2 - 1; diff --git a/sys/contrib/openzfs/module/zfs/zvol.c b/sys/contrib/openzfs/module/zfs/zvol.c index eb68b05c567b..ac7c3a0c3232 100644 --- a/sys/contrib/openzfs/module/zfs/zvol.c +++ b/sys/contrib/openzfs/module/zfs/zvol.c @@ -513,6 +513,7 @@ zil_replay_func_t *const zvol_replay_vector[TX_MAX_TYPE] = { zvol_replay_err, /* TX_MKDIR_ATTR */ zvol_replay_err, /* TX_MKDIR_ACL_ATTR */ zvol_replay_err, /* TX_WRITE2 */ + zvol_replay_err, /* TX_SETSAXATTR */ }; /* diff --git a/sys/contrib/openzfs/module/zstd/Makefile.in b/sys/contrib/openzfs/module/zstd/Makefile.in deleted file mode 100644 index 80096c3e379d..000000000000 --- a/sys/contrib/openzfs/module/zstd/Makefile.in +++ /dev/null @@ -1,69 +0,0 @@ -ifneq ($(KBUILD_EXTMOD),) -src = @abs_srcdir@ -obj = @abs_builddir@ -zstd_include = $(src)/include -else -zstd_include = $(srctree)/$(src)/include -endif - -MODULE := zzstd - -obj-$(CONFIG_ZFS) := $(MODULE).o - -asflags-y := -I$(zstd_include) -ccflags-y := -I$(zstd_include) - -# Zstd uses -O3 by default, so we should follow -ccflags-y += -O3 - -# -fno-tree-vectorize gets set for gcc in zstd/common/compiler.h -# Set it for other compilers, too. -common_flags := -fno-tree-vectorize - -# SSE register return with SSE disabled if -march=znverX is passed -common_flags += -U__BMI__ - -# Quiet warnings about frame size due to unused code in unmodified zstd lib -common_flags += -Wframe-larger-than=20480 - -ccflags-y += $(common_flags) - -vanilla-objs := lib/common/entropy_common.o \ - lib/common/error_private.o \ - lib/common/fse_decompress.o \ - lib/common/pool.o \ - lib/common/zstd_common.o \ - lib/compress/fse_compress.o \ - lib/compress/hist.o \ - lib/compress/huf_compress.o \ - lib/compress/zstd_compress_literals.o \ - lib/compress/zstd_compress_sequences.o \ - lib/compress/zstd_compress_superblock.o \ - lib/compress/zstd_compress.o \ - lib/compress/zstd_double_fast.o \ - lib/compress/zstd_fast.o \ - lib/compress/zstd_lazy.o \ - lib/compress/zstd_ldm.o \ - lib/compress/zstd_opt.o \ - lib/decompress/huf_decompress.o \ - lib/decompress/zstd_ddict.o \ - lib/decompress/zstd_decompress.o \ - lib/decompress/zstd_decompress_block.o - -# Disable aarch64 neon SIMD instructions for kernel mode -$(addprefix $(obj)/,$(vanilla-objs)) : ccflags-y += -include $(zstd_include)/aarch64_compat.h -include $(zstd_include)/zstd_compat_wrapper.h -Wp,-w $(common_flags) - -$(obj)/zfs_zstd.o: ccflags-y += -include $(zstd_include)/zstd_compat_wrapper.h $(common_flags) - -$(MODULE)-objs += zfs_zstd.o -$(MODULE)-objs += zstd_sparc.o -$(MODULE)-objs += $(vanilla-objs) - -all: - mkdir -p lib/common lib/compress lib/decompress - -gensymbols: - for obj in $(vanilla-objs); do echo; echo "/* $$obj: */"; @OBJDUMP@ -t $$obj | awk '$$2 == "g" && !/ zfs_/ {print "#define\t" $$6 " zfs_" $$6}' | sort; done >> include/zstd_compat_wrapper.h - -checksymbols: - @OBJDUMP@ -t $(vanilla-objs) | awk '/file format/ {print} $$2 == "g" && !/ zfs_/ {++ret; print} END {exit ret}' diff --git a/sys/contrib/openzfs/module/zstd/README.md b/sys/contrib/openzfs/module/zstd/README.md index 26d618b61b6e..7ad00e0bd804 100644 --- a/sys/contrib/openzfs/module/zstd/README.md +++ b/sys/contrib/openzfs/module/zstd/README.md @@ -9,7 +9,7 @@ library, besides upgrading to a newer ZSTD release. Tree structure: -* `zfs_zstd.c` is the actual `zzstd` kernel module. +* `zfs_zstd.c` are the actual `zfs` kernel module hooks. * `lib/` contains the unmodified version of the `Zstandard` library * `zstd-in.c` is our template file for generating the single-file library * `include/`: This directory contains supplemental includes for platform @@ -25,16 +25,7 @@ To update ZSTD the following steps need to be taken: `grep include [path to zstd]/contrib/single_file_libs/zstd-in.c | awk '{ print $2 }'` 3. Remove debug.c, threading.c, and zstdmt_compress.c. 4. Update Makefiles with resulting file lists. - -~~~ - -Note: if the zstd library for zfs is updated to a newer version, -the macro list in include/zstd_compat_wrapper.h usually needs to be updated. -this can be done with some hand crafting of the output of the following -script (on the object file generated from the "single-file library" script in zstd's -contrib/single_file_libs): -`nm zstd.o | awk '{print "#define "$3 " zfs_" $3}' > macrotable` - +5. Follow symbol renaming notes in `include/zstd_compat_wrapper.h` ## Altering ZSTD and breaking changes diff --git a/sys/contrib/openzfs/module/zstd/include/zstd_compat_wrapper.h b/sys/contrib/openzfs/module/zstd/include/zstd_compat_wrapper.h index de428175c7df..2c4baad27d4e 100644 --- a/sys/contrib/openzfs/module/zstd/include/zstd_compat_wrapper.h +++ b/sys/contrib/openzfs/module/zstd/include/zstd_compat_wrapper.h @@ -38,7 +38,7 @@ * This will cause a symbol collision with the older in-kernel zstd library. * * On update, truncate this file at the scissor line, rebuild the module, - * and make gensymbols. + * and make gen-zstd-symbols. */ #define MEM_MODULE diff --git a/sys/contrib/openzfs/module/zstd/lib/compress/fse_compress.c b/sys/contrib/openzfs/module/zstd/lib/compress/fse_compress.c index a42759814fdd..e27414ccbbcd 100644 --- a/sys/contrib/openzfs/module/zstd/lib/compress/fse_compress.c +++ b/sys/contrib/openzfs/module/zstd/lib/compress/fse_compress.c @@ -304,7 +304,7 @@ size_t FSE_writeNCount (void* buffer, size_t bufferSize, FSE_CTable* FSE_createCTable (unsigned maxSymbolValue, unsigned tableLog) { - size_t size; + size_t size __attribute__ ((unused)); if (tableLog > FSE_TABLELOG_ABSOLUTE_MAX) tableLog = FSE_TABLELOG_ABSOLUTE_MAX; size = FSE_CTABLE_SIZE_U32 (tableLog, maxSymbolValue) * sizeof(U32); return (FSE_CTable*)malloc(size); diff --git a/sys/contrib/openzfs/module/zstd/lib/compress/zstd_compress_superblock.c b/sys/contrib/openzfs/module/zstd/lib/compress/zstd_compress_superblock.c index b693866c0ac1..ffa4bb67597f 100644 --- a/sys/contrib/openzfs/module/zstd/lib/compress/zstd_compress_superblock.c +++ b/sys/contrib/openzfs/module/zstd/lib/compress/zstd_compress_superblock.c @@ -409,7 +409,7 @@ static size_t ZSTD_seqDecompressedSize(seqStore_t const* seqStore, const seqDef* const seqDef* const send = sequences + nbSeq; const seqDef* sp = sstart; size_t matchLengthSum = 0; - size_t litLengthSum = 0; + size_t litLengthSum __attribute__ ((unused)) = 0; while (send-sp > 0) { ZSTD_sequenceLength const seqLen = ZSTD_getSequenceLength(seqStore, sp); litLengthSum += seqLen.litLength; diff --git a/sys/contrib/openzfs/module/zstd/zfs_zstd.c b/sys/contrib/openzfs/module/zstd/zfs_zstd.c index 7f042b5bcd6f..2ccc6818754e 100644 --- a/sys/contrib/openzfs/module/zstd/zfs_zstd.c +++ b/sys/contrib/openzfs/module/zstd/zfs_zstd.c @@ -50,7 +50,7 @@ #include "lib/zstd.h" #include "lib/common/zstd_errors.h" -kstat_t *zstd_ksp = NULL; +static kstat_t *zstd_ksp = NULL; typedef struct zstd_stats { kstat_named_t zstd_stat_alloc_fail; @@ -702,7 +702,7 @@ zstd_meminit(void) } /* Release object from pool and free memory */ -static void __exit +static void release_pool(struct zstd_pool *pool) { mutex_destroy(&pool->barrier); @@ -712,7 +712,7 @@ release_pool(struct zstd_pool *pool) } /* Release memory pool objects */ -static void __exit +static void zstd_mempool_deinit(void) { for (int i = 0; i < ZSTD_POOL_MAX; i++) { @@ -765,7 +765,7 @@ zstd_init(void) return (0); } -extern void __exit +extern void zstd_fini(void) { /* Deinitialize kstat */ @@ -783,12 +783,10 @@ zstd_fini(void) } #if defined(_KERNEL) +#ifdef __FreeBSD__ module_init(zstd_init); module_exit(zstd_fini); - -ZFS_MODULE_DESCRIPTION("ZSTD Compression for ZFS"); -ZFS_MODULE_LICENSE("Dual BSD/GPL"); -ZFS_MODULE_VERSION(ZSTD_VERSION_STRING "a"); +#endif EXPORT_SYMBOL(zfs_zstd_compress); EXPORT_SYMBOL(zfs_zstd_decompress_level); diff --git a/sys/contrib/openzfs/rpm/.gitignore b/sys/contrib/openzfs/rpm/.gitignore new file mode 100644 index 000000000000..f83960d1a7c0 --- /dev/null +++ b/sys/contrib/openzfs/rpm/.gitignore @@ -0,0 +1 @@ +/*/*.spec diff --git a/sys/contrib/openzfs/rpm/Makefile.am b/sys/contrib/openzfs/rpm/Makefile.am index f2cf72cef13c..216cb731fea9 100644 --- a/sys/contrib/openzfs/rpm/Makefile.am +++ b/sys/contrib/openzfs/rpm/Makefile.am @@ -1 +1,8 @@ -SUBDIRS = generic redhat +EXTRA_DIST += \ + %D%/generic/zfs-dkms.spec.in \ + %D%/generic/zfs-kmod.spec.in \ + %D%/generic/zfs.spec.in \ + \ + %D%/redhat/zfs-dkms.spec.in \ + %D%/redhat/zfs-kmod.spec.in \ + %D%/redhat/zfs.spec.in diff --git a/sys/contrib/openzfs/rpm/generic/.gitignore b/sys/contrib/openzfs/rpm/generic/.gitignore deleted file mode 100644 index 7f5daafdd6d4..000000000000 --- a/sys/contrib/openzfs/rpm/generic/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/zfs-dkms.spec -/zfs-kmod.spec -/zfs.spec diff --git a/sys/contrib/openzfs/rpm/generic/Makefile.am b/sys/contrib/openzfs/rpm/generic/Makefile.am deleted file mode 100644 index 89b13640d622..000000000000 --- a/sys/contrib/openzfs/rpm/generic/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST = zfs.spec.in zfs-kmod.spec.in zfs-dkms.spec.in diff --git a/sys/contrib/openzfs/rpm/generic/zfs-kmod.spec.in b/sys/contrib/openzfs/rpm/generic/zfs-kmod.spec.in index 53b1e1385159..4ed719b8fe14 100644 --- a/sys/contrib/openzfs/rpm/generic/zfs-kmod.spec.in +++ b/sys/contrib/openzfs/rpm/generic/zfs-kmod.spec.in @@ -162,7 +162,7 @@ for kernel_version in %{?kernel_versions}; do cd .. done # find-debuginfo.sh only considers executables -chmod u+x ${RPM_BUILD_ROOT}%{kmodinstdir_prefix}/*/extra/*/*/* +chmod u+x ${RPM_BUILD_ROOT}%{kmodinstdir_prefix}/*/extra/*/* %{?akmod_install} diff --git a/sys/contrib/openzfs/rpm/generic/zfs.spec.in b/sys/contrib/openzfs/rpm/generic/zfs.spec.in index 4b78a93085ac..0a29601639c3 100644 --- a/sys/contrib/openzfs/rpm/generic/zfs.spec.in +++ b/sys/contrib/openzfs/rpm/generic/zfs.spec.in @@ -518,6 +518,8 @@ systemctl --system daemon-reload >/dev/null || true %config(noreplace) %{_sysconfdir}/%{name}/vdev_id.conf.*.example %attr(440, root, root) %config(noreplace) %{_sysconfdir}/sudoers.d/* +%config(noreplace) %{_sysconfdir}/bash_completion.d/zfs + %files -n libzpool5 %{_libdir}/libzpool.so.* diff --git a/sys/contrib/openzfs/rpm/redhat/.gitignore b/sys/contrib/openzfs/rpm/redhat/.gitignore deleted file mode 100644 index 7f5daafdd6d4..000000000000 --- a/sys/contrib/openzfs/rpm/redhat/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/zfs-dkms.spec -/zfs-kmod.spec -/zfs.spec diff --git a/sys/contrib/openzfs/rpm/redhat/Makefile.am b/sys/contrib/openzfs/rpm/redhat/Makefile.am deleted file mode 100644 index 89b13640d622..000000000000 --- a/sys/contrib/openzfs/rpm/redhat/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST = zfs.spec.in zfs-kmod.spec.in zfs-dkms.spec.in diff --git a/sys/contrib/openzfs/rpm/redhat/zfs-kmod.spec.in b/sys/contrib/openzfs/rpm/redhat/zfs-kmod.spec.in index 7b74fdc51f43..7ee04e2340c6 100644 --- a/sys/contrib/openzfs/rpm/redhat/zfs-kmod.spec.in +++ b/sys/contrib/openzfs/rpm/redhat/zfs-kmod.spec.in @@ -82,11 +82,10 @@ make install \ %{__rm} -f %{buildroot}/lib/modules/%{kverrel}/modules.* # find-debuginfo.sh only considers executables -%{__chmod} u+x %{buildroot}/lib/modules/%{kverrel}/extra/*/*/* +%{__chmod} u+x %{buildroot}/lib/modules/%{kverrel}/extra/*/* %clean rm -rf $RPM_BUILD_ROOT %files -n kmod-%{kmod_name}-devel %{_usrsrc}/%{kmod_name}-%{version} -%{_usrsrc}/spl-%{version} diff --git a/sys/contrib/openzfs/scripts/Makefile.am b/sys/contrib/openzfs/scripts/Makefile.am index e2772cf1d605..6f1dc9ccdba5 100644 --- a/sys/contrib/openzfs/scripts/Makefile.am +++ b/sys/contrib/openzfs/scripts/Makefile.am @@ -1,90 +1,89 @@ -include $(top_srcdir)/config/Shellcheck.am - -pkgdatadir = $(datadir)/@PACKAGE@ - -dist_pkgdata_SCRIPTS = \ - zimport.sh \ - zfs.sh \ - zfs-tests.sh \ - zloop.sh \ - zfs-helpers.sh +scriptsdir = $(datadir)/$(PACKAGE) +dist_scripts_SCRIPTS = \ + %D%/zfs-helpers.sh \ + %D%/zfs-tests.sh \ + %D%/zfs.sh \ + %D%/zimport.sh \ + %D%/zloop.sh EXTRA_SCRIPTS = \ - commitcheck.sh \ - common.sh.in \ - dkms.mkconf \ - dkms.postbuild \ - kmodtool \ - make_gitrev.sh \ - man-dates.sh \ - paxcheck.sh \ - mancheck.sh \ - zfs-tests-color.sh + %D%/commitcheck.sh \ + %D%/common.sh.in \ + %D%/dkms.mkconf \ + %D%/dkms.postbuild \ + %D%/kmodtool \ + %D%/make_gitrev.sh \ + %D%/man-dates.sh \ + %D%/mancheck.sh \ + %D%/paxcheck.sh \ + %D%/zfs-tests-color.sh -EXTRA_DIST = \ - cstyle.pl \ - enum-extract.pl \ - zfs2zol-patch.sed \ - zol2zfs-patch.sed \ +EXTRA_DIST += \ + %D%/cstyle.pl \ + %D%/enum-extract.pl \ + %D%/zfs2zol-patch.sed \ + %D%/zol2zfs-patch.sed \ $(EXTRA_SCRIPTS) -SHELLCHECKSCRIPTS = $(EXTRA_SCRIPTS) +SHELLCHECKSCRIPTS += $(dist_scripts_SCRIPTS) $(EXTRA_SCRIPTS) -define EXTRA_ENVIRONMENT +define SCRIPTS_EXTRA_ENVIRONMENT # Only required for in-tree use export INTREE="yes" export GDB="libtool --mode=execute gdb" export LDMOD=/sbin/insmod -export CMD_DIR=@abs_top_builddir@/cmd -export UDEV_RULE_DIR=@abs_top_builddir@/udev/rules.d -export ZEDLET_ETC_DIR=$$CMD_DIR/zed/zed.d -export ZEDLET_LIBEXEC_DIR=$$CMD_DIR/zed/zed.d -export ZPOOL_SCRIPT_DIR=$$CMD_DIR/zpool/zpool.d -export ZPOOL_SCRIPTS_PATH=$$CMD_DIR/zpool/zpool.d -export ZPOOL_COMPAT_DIR=$$CMD_DIR/zpool/compatibility.d -export CONTRIB_DIR=@abs_top_builddir@/contrib -export LIB_DIR=@abs_top_builddir@/lib -export SYSCONF_DIR=@abs_top_builddir@/etc +export CMD_DIR=$(abs_top_builddir) +export UDEV_SCRIPT_DIR=$(abs_top_srcdir)/udev +export UDEV_CMD_DIR=$(abs_top_builddir)/udev +export UDEV_RULE_DIR=$(abs_top_builddir)/udev/rules.d +export ZEDLET_ETC_DIR=$$CMD_DIR/cmd/zed/zed.d +export ZEDLET_LIBEXEC_DIR=$$CMD_DIR/cmd/zed/zed.d +export ZPOOL_SCRIPT_DIR=$$CMD_DIR/cmd/zpool/zpool.d +export ZPOOL_SCRIPTS_PATH=$$CMD_DIR/cmd/zpool/zpool.d +export ZPOOL_COMPAT_DIR=$$CMD_DIR/cmd/zpool/compatibility.d +export CONTRIB_DIR=$(abs_top_builddir)/contrib +export LIB_DIR=$(abs_top_builddir)/.libs +export SYSCONF_DIR=$(abs_top_builddir)/etc -export INSTALL_UDEV_DIR=@udevdir@ -export INSTALL_UDEV_RULE_DIR=@udevruledir@ -export INSTALL_MOUNT_HELPER_DIR=@mounthelperdir@ -export INSTALL_SYSCONF_DIR=@sysconfdir@ -export INSTALL_PYTHON_DIR=@pythonsitedir@ +export INSTALL_UDEV_DIR=$(udevdir) +export INSTALL_UDEV_RULE_DIR=$(udevruledir) +export INSTALL_MOUNT_HELPER_DIR=$(mounthelperdir) +export INSTALL_SYSCONF_DIR=$(sysconfdir) +export INSTALL_PYTHON_DIR=$(pythonsitedir) -export KMOD_SPL=@abs_top_builddir@/module/spl/spl.ko -export KMOD_ZAVL=@abs_top_builddir@/module/avl/zavl.ko -export KMOD_ZNVPAIR=@abs_top_builddir@/module/nvpair/znvpair.ko -export KMOD_ZUNICODE=@abs_top_builddir@/module/unicode/zunicode.ko -export KMOD_ZCOMMON=@abs_top_builddir@/module/zcommon/zcommon.ko -export KMOD_ZLUA=@abs_top_builddir@/module/lua/zlua.ko -export KMOD_ICP=@abs_top_builddir@/module/icp/icp.ko -export KMOD_ZFS=@abs_top_builddir@/module/zfs/zfs.ko -export KMOD_FREEBSD=@abs_top_builddir@/module/openzfs.ko -export KMOD_ZZSTD=@abs_top_builddir@/module/zstd/zzstd.ko +export KMOD_SPL=$(abs_top_builddir)/module/spl.ko +export KMOD_ZFS=$(abs_top_builddir)/module/zfs.ko +export KMOD_FREEBSD=$(abs_top_builddir)/module/openzfs.ko endef -export EXTRA_ENVIRONMENT +export SCRIPTS_EXTRA_ENVIRONMENT -all-local: - -$(SED) -e '\|^export BIN_DIR=|s|$$|@abs_top_builddir@/bin|' \ - -e '\|^export SBIN_DIR=|s|$$|@abs_top_builddir@/bin|' \ - -e '\|^export LIBEXEC_DIR=|s|$$|@abs_top_builddir@/bin|' \ - -e '\|^export ZTS_DIR=|s|$$|@abs_top_srcdir@/tests|' \ - -e '\|^export SCRIPT_DIR=|s|$$|@abs_top_srcdir@/scripts|' \ - $(abs_top_srcdir)/scripts/common.sh.in >common.sh - -echo "$$EXTRA_ENVIRONMENT" >>common.sh +CLEANFILES += %D%/common.sh +%D%/common.sh: %D%/common.sh.in Makefile + -$(AM_V_at)$(MKDIR_P) $(@D) + -$(AM_V_GEN)$(SED) -e '/^export BIN_DIR=/s|$$|$(abs_top_builddir)/tests/zfs-tests/bin|' \ + -e '/^export SBIN_DIR=/s|$$|$(abs_top_builddir)|' \ + -e '/^export LIBEXEC_DIR=/s|$$|$(abs_top_builddir)|' \ + -e '/^export ZTS_DIR=/s|$$|$(abs_top_srcdir)/tests|' \ + -e '/^export SCRIPT_DIR=/s|$$|$(abs_top_srcdir)/scripts|' \ + $< >$@ + -$(AM_V_at)echo "$$SCRIPTS_EXTRA_ENVIRONMENT" >>$@ -clean-local: - -$(RM) common.sh +ALL_LOCAL += scripts-all-local +scripts-all-local: %D%/common.sh + -SCRIPT_COMMON=$< $(srcdir)/%D%/zfs-tests.sh -c -install-data-hook: - -$(SED) -e '\|^export BIN_DIR=|s|$$|@bindir@|' \ - -e '\|^export SBIN_DIR=|s|$$|@sbindir@|' \ - -e '\|^export LIBEXEC_DIR=|s|$$|@zfsexecdir@|' \ - -e '\|^export ZTS_DIR=|s|$$|@datadir@/@PACKAGE@|' \ - -e '\|^export SCRIPT_DIR=|s|$$|@datadir@/@PACKAGE@|' \ - $(abs_top_srcdir)/scripts/common.sh.in \ - >$(DESTDIR)$(datadir)/@PACKAGE@/common.sh +CLEAN_LOCAL += scripts-clean-local +scripts-clean-local: + -$(RM) -r tests/zfs-tests/bin/ + +INSTALL_DATA_HOOKS += scripts-install-data-hook +scripts-install-data-hook: %D%/common.sh.in Makefile + -$(SED) -e '/^export BIN_DIR=/s|$$|$(bindir)|' \ + -e '/^export SBIN_DIR=/s|$$|$(sbindir)|' \ + -e '/^export LIBEXEC_DIR=/s|$$|$(zfsexecdir)|' \ + -e '/^export ZTS_DIR=/s|$$|$(datadir)/$(PACKAGE)|' \ + -e '/^export SCRIPT_DIR=/s|$$|$(datadir)/$(PACKAGE)|' \ + $< >$(DESTDIR)$(datadir)/$(PACKAGE)/common.sh diff --git a/sys/contrib/openzfs/scripts/cstyle.pl b/sys/contrib/openzfs/scripts/cstyle.pl index d4563cdc9f1a..4846ea570ff3 100755 --- a/sys/contrib/openzfs/scripts/cstyle.pl +++ b/sys/contrib/openzfs/scripts/cstyle.pl @@ -58,52 +58,27 @@ use Getopt::Std; use strict; my $usage = -"usage: cstyle [-cghpvCP] [-o constructs] file ... +"usage: cstyle [-cgpvP] file... -c check continuation indentation inside functions -g print github actions' workflow commands - -h perform heuristic checks that are sometimes wrong -p perform some of the more picky checks -v verbose - -C don't check anything in header block comments -P check for use of non-POSIX types - -o constructs - allow a comma-separated list of optional constructs: - doxygen allow doxygen-style block comments (/** /*!) - splint allow splint-style lint comments (/*@ ... @*/) "; my %opts; -if (!getopts("cgho:pvCP", \%opts)) { +if (!getopts("cghpvCP", \%opts)) { print $usage; exit 2; } my $check_continuation = $opts{'c'}; my $github_workflow = $opts{'g'} || $ENV{'CI'}; -my $heuristic = $opts{'h'}; my $picky = $opts{'p'}; my $verbose = $opts{'v'}; -my $ignore_hdr_comment = $opts{'C'}; my $check_posix_types = $opts{'P'}; -my $doxygen_comments = 0; -my $splint_comments = 0; - -if (defined($opts{'o'})) { - for my $x (split /,/, $opts{'o'}) { - if ($x eq "doxygen") { - $doxygen_comments = 1; - } elsif ($x eq "splint") { - $splint_comments = 1; - } else { - print "cstyle: unrecognized construct \"$x\"\n"; - print $usage; - exit 2; - } - } -} - my ($filename, $line, $prev); # shared globals my $fmt; @@ -115,12 +90,7 @@ if ($verbose) { $fmt = "%s: %d: %s\n"; } -if ($doxygen_comments) { - # doxygen comments look like "/*!" or "/**"; allow them. - $hdr_comment_start = qr/^\s*\/\*[\!\*]?$/; -} else { - $hdr_comment_start = qr/^\s*\/\*$/; -} +$hdr_comment_start = qr/^\s*\/\*$/; # Note, following must be in single quotes so that \s and \w work right. my $typename = '(int|char|short|long|unsigned|float|double' . @@ -146,8 +116,6 @@ my $lint_re = qr/\/\*(?: PROTOLIB[0-9]*|SCANFLIKE[0-9]*|CSTYLED.*? )\*\//x; -my $splint_re = qr/\/\*@.*?@\*\//x; - my $warlock_re = qr/\/\*\s*(?: VARIABLES\ PROTECTED\ BY| MEMBERS\ PROTECTED\ BY| @@ -241,7 +209,6 @@ my $in_cpp = 0; my $next_in_cpp = 0; my $in_comment = 0; -my $in_header_comment = 0; my $comment_done = 0; my $in_warlock_comment = 0; my $in_function = 0; @@ -472,7 +439,6 @@ line: while (<$filehandle>) { if ($comment_done) { $in_comment = 0; - $in_header_comment = 0; $comment_done = 0; } # does this looks like the start of a block comment? @@ -483,9 +449,6 @@ line: while (<$filehandle>) { $in_comment = 1; /^(\s*)\//; $comment_prefix = $1; - if ($comment_prefix eq "") { - $in_header_comment = 1; - } $prev = $line; next line; } @@ -495,20 +458,13 @@ line: while (<$filehandle>) { $comment_done = 1; } elsif (/\*\//) { $comment_done = 1; - err("improper block comment close") - unless ($ignore_hdr_comment && $in_header_comment); + err("improper block comment close"); } elsif (!/^$comment_prefix \*[ \t]/ && !/^$comment_prefix \*$/) { - err("improper block comment") - unless ($ignore_hdr_comment && $in_header_comment); + err("improper block comment"); } } - if ($in_header_comment && $ignore_hdr_comment) { - $prev = $line; - next line; - } - # check for errors that might occur in comments and in code. # allow spaces to be used to draw pictures in all comments. @@ -536,12 +492,10 @@ line: while (<$filehandle>) { next line; } - if ((/[^(]\/\*\S/ || /^\/\*\S/) && - !(/$lint_re/ || ($splint_comments && /$splint_re/))) { + if ((/[^(]\/\*\S/ || /^\/\*\S/) && !/$lint_re/) { err("missing blank after open comment"); } - if (/\S\*\/[^)]|\S\*\/$/ && - !(/$lint_re/ || ($splint_comments && /$splint_re/))) { + if (/\S\*\/[^)]|\S\*\/$/ && !/$lint_re/) { err("missing blank before close comment"); } if (/\/\/\S/) { # C++ comments @@ -735,19 +689,6 @@ line: while (<$filehandle>) { err("non-POSIX typedef $1 used: use $old2posix{$1} instead"); } } - if ($heuristic) { - # cannot check this everywhere due to "struct {\n...\n} foo;" - if ($in_function && !$in_declaration && - /\}./ && !/\}\s+=/ && !/\{.*\}[;,]$/ && !/\}(\s|)*$/ && - !/\} (else|while)/ && !/\}\}/) { - err("possible bad text following right brace"); - } - # cannot check this because sub-blocks in - # the middle of code are ok - if ($in_function && /^\s+\{/) { - err("possible left brace starting a line"); - } - } if (/^\s*else\W/) { if ($prev =~ /^\s*\}$/) { err_prefix($prev, diff --git a/sys/contrib/openzfs/scripts/dkms.mkconf b/sys/contrib/openzfs/scripts/dkms.mkconf index 4090efa087f7..0bd383420435 100755 --- a/sys/contrib/openzfs/scripts/dkms.mkconf +++ b/sys/contrib/openzfs/scripts/dkms.mkconf @@ -77,38 +77,10 @@ STRIP[0]="\$( && echo -n no )" STRIP[1]="\${STRIP[0]}" -STRIP[2]="\${STRIP[0]}" -STRIP[3]="\${STRIP[0]}" -STRIP[4]="\${STRIP[0]}" -STRIP[5]="\${STRIP[0]}" -STRIP[6]="\${STRIP[0]}" -STRIP[7]="\${STRIP[0]}" -STRIP[8]="\${STRIP[0]}" -BUILT_MODULE_NAME[0]="zavl" -BUILT_MODULE_LOCATION[0]="module/avl/" -DEST_MODULE_LOCATION[0]="/extra/avl/avl" -BUILT_MODULE_NAME[1]="znvpair" -BUILT_MODULE_LOCATION[1]="module/nvpair/" -DEST_MODULE_LOCATION[1]="/extra/nvpair/znvpair" -BUILT_MODULE_NAME[2]="zunicode" -BUILT_MODULE_LOCATION[2]="module/unicode/" -DEST_MODULE_LOCATION[2]="/extra/unicode/zunicode" -BUILT_MODULE_NAME[3]="zcommon" -BUILT_MODULE_LOCATION[3]="module/zcommon/" -DEST_MODULE_LOCATION[3]="/extra/zcommon/zcommon" -BUILT_MODULE_NAME[4]="zfs" -BUILT_MODULE_LOCATION[4]="module/zfs/" -DEST_MODULE_LOCATION[4]="/extra/zfs/zfs" -BUILT_MODULE_NAME[5]="icp" -BUILT_MODULE_LOCATION[5]="module/icp/" -DEST_MODULE_LOCATION[5]="/extra/icp/icp" -BUILT_MODULE_NAME[6]="zlua" -BUILT_MODULE_LOCATION[6]="module/lua/" -DEST_MODULE_LOCATION[6]="/extra/lua/zlua" -BUILT_MODULE_NAME[7]="spl" -BUILT_MODULE_LOCATION[7]="module/spl/" -DEST_MODULE_LOCATION[7]="/extra/spl/spl" -BUILT_MODULE_NAME[8]="zzstd" -BUILT_MODULE_LOCATION[8]="module/zstd/" -DEST_MODULE_LOCATION[8]="/extra/zstd/zzstd" +BUILT_MODULE_NAME[0]="zfs" +BUILT_MODULE_LOCATION[0]="module/" +DEST_MODULE_LOCATION[0]="/extra" +BUILT_MODULE_NAME[1]="spl" +BUILT_MODULE_LOCATION[1]="module/" +DEST_MODULE_LOCATION[1]="/extra" EOF diff --git a/sys/contrib/openzfs/scripts/kmodtool b/sys/contrib/openzfs/scripts/kmodtool index afbb6ab3b03c..f66341196acb 100755 --- a/sys/contrib/openzfs/scripts/kmodtool +++ b/sys/contrib/openzfs/scripts/kmodtool @@ -263,16 +263,10 @@ the ${kmodname}-devel- objects for the newest kernel. %defattr(644,root,root,755) %{_usrsrc}/${kmodname}-%{version} EOF - if [ -n "${obsolete_name}" ]; then - echo "%{_usrsrc}/${obsolete_name}-%{version}" - fi for kernel in ${1}; do local kernel_uname_r=${kernel} echo "%exclude %{_usrsrc}/${kmodname}-%{version}/${kernel_uname_r}" - if [ -n "${obsolete_name}" ]; then - echo "%exclude %{_usrsrc}/${obsolete_name}-%{version}/${kernel_uname_r}" - fi done echo @@ -328,9 +322,6 @@ kernel ${kernel_uname_r} for the %{_target_cpu} family of processors. %defattr(644,root,root,755) %{_usrsrc}/${kmodname}-%{version}/${kernel_uname_r} EOF - if [ -n "${obsolete_name}" ]; then - echo "%{_usrsrc}/${obsolete_name}-%{version}/${kernel_uname_r}" - fi } print_rpmtemplate_kmodmetapkg () diff --git a/sys/contrib/openzfs/scripts/zfs-helpers.sh b/sys/contrib/openzfs/scripts/zfs-helpers.sh index a86a6eb61a60..8dcb0630126a 100755 --- a/sys/contrib/openzfs/scripts/zfs-helpers.sh +++ b/sys/contrib/openzfs/scripts/zfs-helpers.sh @@ -18,7 +18,7 @@ # --sysconfdir=DIR install zfs configuration files [PREFIX/etc] # -BASE_DIR=$(dirname "$0") +BASE_DIR=${0%/*} SCRIPT_COMMON=common.sh if [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then . "${BASE_DIR}/${SCRIPT_COMMON}" @@ -46,7 +46,7 @@ msg() { usage() { cat << EOF USAGE: -$0 [dhirv] +$0 [-dhirv] DESCRIPTION: Install/remove the ZFS helper utilities. @@ -99,7 +99,7 @@ if [ "$INSTALL" = "no" ] && [ "$REMOVE" = "no" ]; then fail "Either -i or -r must be specified" fi -if [ "$(id -u)" != "0" ]; then +if [ "$(id -u)" != "0" ] && [ "$DRYRUN" = "no" ]; then fail "Must run as root" fi @@ -126,13 +126,13 @@ install() { echo "Symlink exists: $dst" elif [ -e "$dst" ]; then echo "File exists: $dst" - elif [ ! -e "$src" ]; then + elif ! [ -e "$src" ]; then echo "Source missing: $src" else msg "ln -s $src $dst" if [ "$DRYRUN" = "no" ]; then - DIR=$(dirname "$dst") + DIR=${dst%/*} mkdir -p "$DIR" >/dev/null 2>&1 ln -s "$src" "$dst" fi @@ -145,7 +145,7 @@ remove() { if [ -h "$dst" ]; then msg "rm $dst" rm "$dst" - DIR=$(dirname "$dst") + DIR=${dst%/*} rmdir "$DIR" >/dev/null 2>&1 elif [ -e "$dst" ]; then echo "Expected symlink: $dst" @@ -153,32 +153,23 @@ remove() { } if [ "${INSTALL}" = "yes" ]; then - install "$CMD_DIR/mount_zfs/mount.zfs" \ - "$INSTALL_MOUNT_HELPER_DIR/mount.zfs" - install "$CMD_DIR/fsck_zfs/fsck.zfs" \ - "$INSTALL_MOUNT_HELPER_DIR/fsck.zfs" - install "$CMD_DIR/zvol_id/zvol_id" \ - "$INSTALL_UDEV_DIR/zvol_id" - install "$CMD_DIR/vdev_id/vdev_id" \ - "$INSTALL_UDEV_DIR/vdev_id" - install "$UDEV_RULE_DIR/60-zvol.rules" \ - "$INSTALL_UDEV_RULE_DIR/60-zvol.rules" - install "$UDEV_RULE_DIR/69-vdev.rules" \ - "$INSTALL_UDEV_RULE_DIR/69-vdev.rules" - install "$UDEV_RULE_DIR/90-zfs.rules" \ - "$INSTALL_UDEV_RULE_DIR/90-zfs.rules" - install "$CMD_DIR/zpool/zpool.d" \ - "$INSTALL_SYSCONF_DIR/zfs/zpool.d" - install "$CONTRIB_DIR/pyzfs/libzfs_core" \ - "$INSTALL_PYTHON_DIR/libzfs_core" + for cmd in "mount.zfs" "fsck.zfs"; do + install "$CMD_DIR/$cmd" "$INSTALL_MOUNT_HELPER_DIR/$cmd" + done + for udev in "$UDEV_CMD_DIR/zvol_id" "$UDEV_SCRIPT_DIR/vdev_id"; do + install "$udev" "$INSTALL_UDEV_DIR/${udev##*/}" + done + for rule in "60-zvol.rules" "69-vdev.rules" "90-zfs.rules"; do + install "$UDEV_RULE_DIR/$rule" "$INSTALL_UDEV_RULE_DIR/$rule" + done + install "$ZPOOL_SCRIPT_DIR" "$INSTALL_SYSCONF_DIR/zfs/zpool.d" + install "$CONTRIB_DIR/pyzfs/libzfs_core" "$INSTALL_PYTHON_DIR/libzfs_core" # Ideally we would install these in the configured ${libdir}, which is # by default "/usr/local/lib and unfortunately not included in the # dynamic linker search path. - install "$(find "$LIB_DIR/libzfs_core" -type f -name 'libzfs_core.so*')" \ - "/lib/libzfs_core.so" - install "$(find "$LIB_DIR/libnvpair" -type f -name 'libnvpair.so*')" \ - "/lib/libnvpair.so" - ldconfig + install "$LIB_DIR"/libzfs_core.so.?.?.? "/lib/libzfs_core.so" + install "$LIB_DIR"/libnvpair.so.?.?.? "/lib/libnvpair.so" + [ "$DRYRUN" = "no" ] && ldconfig else remove "$INSTALL_MOUNT_HELPER_DIR/mount.zfs" remove "$INSTALL_MOUNT_HELPER_DIR/fsck.zfs" diff --git a/sys/contrib/openzfs/scripts/zfs-tests.sh b/sys/contrib/openzfs/scripts/zfs-tests.sh index 851ff8b74e52..cad65d04869f 100755 --- a/sys/contrib/openzfs/scripts/zfs-tests.sh +++ b/sys/contrib/openzfs/scripts/zfs-tests.sh @@ -26,13 +26,8 @@ # Copyright 2020 OmniOS Community Edition (OmniOSce) Association. # -BASE_DIR=$(dirname "$0") -SCRIPT_COMMON=common.sh -if [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then -. "${BASE_DIR}/${SCRIPT_COMMON}" -else -echo "Missing helper script ${SCRIPT_COMMON}" && exit 1 -fi +SCRIPT_COMMON=${SCRIPT_COMMON:-${0%/*}/common.sh} +. "${SCRIPT_COMMON}" || exit PROG=zfs-tests.sh VERBOSE="no" @@ -53,7 +48,7 @@ TAGS="" ITERATIONS=1 ZFS_DBGMSG="$STF_SUITE/callbacks/zfs_dbgmsg.ksh" ZFS_DMESG="$STF_SUITE/callbacks/zfs_dmesg.ksh" -UNAME=$(uname -s) +UNAME=$(uname) RERUN="" KMEMLEAK="" @@ -100,7 +95,7 @@ cleanup_linux_loopback() { for TEST_LOOPBACK in ${LOOPBACKS}; do LOOP_DEV="${TEST_LOOPBACK##*/}" DM_DEV=$(sudo "${DMSETUP}" ls 2>/dev/null | \ - grep "${LOOP_DEV}" | cut -f1) + awk -v l="${LOOP_DEV}" '$0 ~ l {print $1}') if [ -n "$DM_DEV" ]; then sudo "${DMSETUP}" remove "${DM_DEV}" || @@ -133,9 +128,8 @@ cleanup() { fi fi - for TEST_FILE in ${FILES}; do - rm -f "${TEST_FILE}" >/dev/null 2>&1 - done + # shellcheck disable=SC2086 + rm -f ${FILES} >/dev/null 2>&1 if [ "$STF_PATH_REMOVE" = "yes" ] && [ -d "$STF_PATH" ]; then rm -Rf "$STF_PATH" @@ -150,28 +144,30 @@ trap cleanup EXIT # be dangerous and should only be used in a dedicated test environment. # cleanup_all() { - TEST_POOLS=$(sudo env ASAN_OPTIONS=detect_leaks=false "$ZPOOL" list -H -o name | grep testpool) + TEST_POOLS=$(ASAN_OPTIONS=detect_leaks=false "$ZPOOL" list -Ho name | grep testpool) if [ "$UNAME" = "FreeBSD" ] ; then TEST_LOOPBACKS=$(sudo "${LOSETUP}" -l) else - TEST_LOOPBACKS=$(sudo "${LOSETUP}" -a|grep file-vdev|cut -f1 -d:) + TEST_LOOPBACKS=$("${LOSETUP}" -a | awk -F: '/file-vdev/ {print $1}') fi - TEST_FILES=$(ls /var/tmp/file-vdev* 2>/dev/null) + TEST_FILES=$(ls "${FILEDIR}"/file-vdev* /var/tmp/file-vdev* 2>/dev/null) msg msg "--- Cleanup ---" - msg "Removing pool(s): $(echo "${TEST_POOLS}" | tr '\n' ' ')" + # shellcheck disable=2116,2086 + msg "Removing pool(s): $(echo ${TEST_POOLS})" for TEST_POOL in $TEST_POOLS; do sudo env ASAN_OPTIONS=detect_leaks=false "$ZPOOL" destroy "${TEST_POOL}" done if [ "$UNAME" != "FreeBSD" ] ; then - msg "Removing dm(s): $(sudo "${DMSETUP}" ls | + msg "Removing all dm(s): $(sudo "${DMSETUP}" ls | grep loop | tr '\n' ' ')" sudo "${DMSETUP}" remove_all fi - msg "Removing loopback(s): $(echo "${TEST_LOOPBACKS}" | tr '\n' ' ')" + # shellcheck disable=2116,2086 + msg "Removing loopback(s): $(echo ${TEST_LOOPBACKS})" for TEST_LOOPBACK in $TEST_LOOPBACKS; do if [ "$UNAME" = "FreeBSD" ] ; then sudo "${LOSETUP}" -d -u "${TEST_LOOPBACK}" @@ -180,10 +176,10 @@ cleanup_all() { fi done - msg "Removing files(s): $(echo "${TEST_FILES}" | tr '\n' ' ')" - for TEST_FILE in $TEST_FILES; do - sudo rm -f "${TEST_FILE}" - done + # shellcheck disable=2116,2086 + msg "Removing files(s): $(echo ${TEST_FILES})" + # shellcheck disable=2086 + sudo rm -f ${TEST_FILES} } # @@ -197,19 +193,18 @@ cleanup_all() { # find_runfile() { NAME=$1 - RESULT="" if [ -f "$RUNFILE_DIR/$NAME" ]; then - RESULT="$RUNFILE_DIR/$NAME" + echo "$RUNFILE_DIR/$NAME" elif [ -f "$RUNFILE_DIR/$NAME.run" ]; then - RESULT="$RUNFILE_DIR/$NAME.run" + echo "$RUNFILE_DIR/$NAME.run" elif [ -f "$NAME" ]; then - RESULT="$NAME" + echo "$NAME" elif [ -f "$NAME.run" ]; then - RESULT="$NAME.run" + echo "$NAME.run" + else + return 1 fi - - echo "$RESULT" } # @@ -253,7 +248,7 @@ constrain_path() { SYSTEM_DIRS="$SYSTEM_DIRS /usr/bin /usr/sbin /bin /sbin $LIBEXEC_DIR" if [ "$INTREE" = "yes" ]; then - # Constrained path set to ./zfs/bin/ + # Constrained path set to $(top_builddir)/tests/zfs-tests/bin STF_PATH="$BIN_DIR" STF_PATH_REMOVE="no" STF_MISSING_BIN="" @@ -263,14 +258,10 @@ constrain_path() { fi # Special case links for standard zfs utilities - DIRS="$(find "$CMD_DIR" -type d \( ! -name .deps -a \ - ! -name .libs \) -print | tr '\n' ' ')" - create_links "$DIRS" "$ZFS_FILES" + create_links "$CMD_DIR" "$ZFS_FILES" # Special case links for zfs test suite utilities - DIRS="$(find "$STF_SUITE" -type d \( ! -name .deps -a \ - ! -name .libs \) -print | tr '\n' ' ')" - create_links "$DIRS" "$ZFSTEST_FILES" + create_links "$CMD_DIR/tests/zfs-tests/cmd" "$ZFSTEST_FILES" else # Constrained path set to /var/tmp/constrained_path.* SYSTEMDIR=${SYSTEMDIR:-/var/tmp/constrained_path.XXXXXX} @@ -297,14 +288,11 @@ constrain_path() { create_links "$SYSTEM_DIRS" "$SYSTEM_FILES" # Exceptions - ln -fs "$STF_PATH/awk" "$STF_PATH/nawk" if [ "$UNAME" = "Linux" ] ; then ln -fs /sbin/fsck.ext4 "$STF_PATH/fsck" ln -fs /sbin/mkfs.ext4 "$STF_PATH/newfs" ln -fs "$STF_PATH/gzip" "$STF_PATH/compress" ln -fs "$STF_PATH/gunzip" "$STF_PATH/uncompress" - ln -fs "$STF_PATH/exportfs" "$STF_PATH/share" - ln -fs "$STF_PATH/exportfs" "$STF_PATH/unshare" elif [ "$UNAME" = "FreeBSD" ] ; then ln -fs /usr/local/bin/ksh93 "$STF_PATH/ksh" fi @@ -335,7 +323,7 @@ OPTIONS: -m Enable kmemleak reporting (Linux only) -n NFSFILE Use the nfsfile to determine the NFS configuration -I NUM Number of iterations - -d DIR Use DIR for files and loopback devices + -d DIR Use world-writable DIR for files and loopback devices -s SIZE Use vdevs of SIZE (default: 4G) -r RUNFILES Run tests in RUNFILES (default: ${DEFAULT_RUNFILES}) -t PATH Run single test at PATH relative to test suite @@ -343,7 +331,7 @@ OPTIONS: -u USER Run single test as USER (default: root) EXAMPLES: -# Run the default (linux) suite of tests and output the configuration used. +# Run the default ($(echo "${DEFAULT_RUNFILES}" | sed 's/\.run//')) suite of tests and output the configuration used. $0 -v # Run a smaller suite of tests designed to run more quickly. @@ -353,7 +341,7 @@ $0 -r linux-fast $0 -t tests/functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh # Cleanup a previous run of the test suite prior to testing, run the -# default (linux) suite of tests and perform no cleanup on exit. +# default ($(echo "${DEFAULT_RUNFILES}" | sed 's/\.run//')) suite of tests and perform no cleanup on exit. $0 -x EOF @@ -449,11 +437,7 @@ if [ -n "$SINGLETEST" ]; then fi RUNFILE_DIR="/var/tmp" RUNFILES="zfs-tests.$$.run" - SINGLEQUIET="False" - - if [ -n "$QUIET" ]; then - SINGLEQUIET="True" - fi + [ -n "$QUIET" ] && SINGLEQUIET="True" || SINGLEQUIET="False" cat >"${RUNFILE_DIR}/${RUNFILES}" << EOF [DEFAULT] @@ -466,19 +450,14 @@ post_user = root post = outputdir = /var/tmp/test_results EOF - SINGLETESTDIR=$(dirname "$SINGLETEST") - SINGLETESTFILE=$(basename "$SINGLETEST") - SETUPSCRIPT= - CLEANUPSCRIPT= + SINGLETESTDIR="${SINGLETEST%/*}" - if [ -f "$STF_SUITE/$SINGLETESTDIR/setup.ksh" ]; then - SETUPSCRIPT="setup" - fi - - if [ -f "$STF_SUITE/$SINGLETESTDIR/cleanup.ksh" ]; then - CLEANUPSCRIPT="cleanup" - fi + SETUPDIR="$SINGLETESTDIR" + [ "${SETUPDIR#/}" = "$SETUPDIR" ] && SETUPDIR="$STF_SUITE/$SINGLETESTDIR" + [ -x "$SETUPDIR/setup.ksh" ] && SETUPSCRIPT="setup" || SETUPSCRIPT= + [ -x "$SETUPDIR/cleanup.ksh" ] && CLEANUPSCRIPT="cleanup" || CLEANUPSCRIPT= + SINGLETESTFILE="${SINGLETEST##*/}" cat >>"${RUNFILE_DIR}/${RUNFILES}" << EOF [$SINGLETESTDIR] @@ -502,8 +481,8 @@ IFS=, for RUNFILE in $RUNFILES; do if [ -n "$RUNFILE" ]; then SAVED_RUNFILE="$RUNFILE" - RUNFILE=$(find_runfile "$RUNFILE") - [ -z "$RUNFILE" ] && fail "Cannot find runfile: $SAVED_RUNFILE" + RUNFILE=$(find_runfile "$RUNFILE") || + fail "Cannot find runfile: $SAVED_RUNFILE" R="$R,$RUNFILE" fi @@ -523,7 +502,7 @@ if [ "$(id -u)" = "0" ]; then fail "This script must not be run as root." fi -if [ "$(sudo whoami)" != "root" ]; then +if [ "$(sudo id -un)" != "root" ]; then fail "Passwordless sudo access required." fi @@ -560,16 +539,14 @@ fi # # By default preserve any existing pools -# NOTE: Since 'zpool list' outputs a newline-delimited list convert $KEEP from -# space-delimited to newline-delimited. # if [ -z "${KEEP}" ]; then - KEEP="$(sudo env ASAN_OPTIONS=detect_leaks=false "$ZPOOL" list -H -o name)" + KEEP="$(ASAN_OPTIONS=detect_leaks=false "$ZPOOL" list -Ho name | tr -s '[:space:]' ' ')" if [ -z "${KEEP}" ]; then KEEP="rpool" fi else - KEEP="$(echo "$KEEP" | tr '[:blank:]' '\n')" + KEEP="$(echo "$KEEP" | tr -s '[:space:]' ' ')" fi # @@ -581,11 +558,7 @@ fi # # See libzfs/libzfs_config.c for more information. # -if [ "$UNAME" = "FreeBSD" ] ; then - __ZFS_POOL_EXCLUDE="$(echo "$KEEP" | tr -s '\n' ' ')" -else - __ZFS_POOL_EXCLUDE="$(echo "$KEEP" | sed ':a;N;s/\n/ /g;ba')" -fi +__ZFS_POOL_EXCLUDE="$KEEP" . "$STF_SUITE/include/default.cfg" @@ -625,8 +598,7 @@ if [ -z "${DISKS}" ]; then DISKS="$DISKS $MDDEVICE" LOOPBACKS="$LOOPBACKS $MDDEVICE" else - TEST_LOOPBACK=$(sudo "${LOSETUP}" -f) - sudo "${LOSETUP}" "${TEST_LOOPBACK}" "${TEST_FILE}" || + TEST_LOOPBACK=$(sudo "${LOSETUP}" --show -f "${TEST_FILE}") || fail "Failed: ${TEST_FILE} -> ${TEST_LOOPBACK}" BASELOOPBACK="${TEST_LOOPBACK##*/}" DISKS="$DISKS $BASELOOPBACK" @@ -652,7 +624,7 @@ fi # # Disable SELinux until the ZFS Test Suite has been updated accordingly. # -if [ -x "$STF_PATH/setenforce" ]; then +if command -v setenforce >/dev/null; then sudo setenforce permissive >/dev/null 2>&1 fi @@ -660,8 +632,8 @@ fi # Enable internal ZFS debug log and clear it. # if [ -e /sys/module/zfs/parameters/zfs_dbgmsg_enable ]; then - sudo /bin/sh -c "echo 1 >/sys/module/zfs/parameters/zfs_dbgmsg_enable" - sudo /bin/sh -c "echo 0 >/proc/spl/kstat/zfs/dbgmsg" + sudo sh -c "echo 1 >/sys/module/zfs/parameters/zfs_dbgmsg_enable" + sudo sh -c "echo 0 >/proc/spl/kstat/zfs/dbgmsg" fi msg @@ -691,7 +663,6 @@ export FILEDIR export KEEP export __ZFS_POOL_EXCLUDE export TESTFAIL_CALLBACKS -export PATH=$STF_PATH mktemp_file() { if [ "$UNAME" = "FreeBSD" ]; then @@ -715,7 +686,8 @@ msg "${TEST_RUNNER}" \ "-T \"${TAGS}\"" \ "-i \"${STF_SUITE}\"" \ "-I \"${ITERATIONS}\"" -{ ${TEST_RUNNER} \ +{ PATH=$STF_PATH \ + ${TEST_RUNNER} \ ${QUIET:+-q} \ ${KMEMLEAK:+-m} \ ${KMSG:+-K} \ @@ -740,9 +712,10 @@ if [ "$RESULT" -eq "2" ] && [ -n "$RERUN" ]; then for test_name in $MAYBES; do grep "$test_name " "$TEMP_RESULTS_FILE" >>"$TEST_LIST" done - { ${TEST_RUNNER} \ - ${QUIET:+-q} \ - ${KMEMLEAK:+-m} \ + { PATH=$STF_PATH \ + ${TEST_RUNNER} \ + ${QUIET:+-q} \ + ${KMEMLEAK:+-m} \ -c "${RUNFILES}" \ -T "${TAGS}" \ -i "${STF_SUITE}" \ @@ -765,7 +738,7 @@ if [ -d "$RESULTS_DIR" ]; then cat "$RESULTS_FILE" "$REPORT_FILE" >"$RESULTS_DIR/results" fi -rm -f "$RESULTS_FILE" "$REPORT_FILE" +rm -f "$RESULTS_FILE" "$REPORT_FILE" "$TEST_LIST" "$TEMP_RESULTS_FILE" if [ -n "$SINGLETEST" ]; then rm -f "$RUNFILES" >/dev/null 2>&1 diff --git a/sys/contrib/openzfs/scripts/zfs.sh b/sys/contrib/openzfs/scripts/zfs.sh index 0561092a089f..502c5430ab05 100755 --- a/sys/contrib/openzfs/scripts/zfs.sh +++ b/sys/contrib/openzfs/scripts/zfs.sh @@ -3,7 +3,7 @@ # A simple script to load/unload the ZFS module stack. # -BASE_DIR=$(dirname "$0") +BASE_DIR=${0%/*} SCRIPT_COMMON=common.sh if [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then . "${BASE_DIR}/${SCRIPT_COMMON}" @@ -11,7 +11,6 @@ else echo "Missing helper script ${SCRIPT_COMMON}" && exit 1 fi -PROG=zfs.sh VERBOSE="no" UNLOAD="no" LOAD="yes" @@ -19,44 +18,35 @@ STACK_TRACER="no" ZED_PIDFILE=${ZED_PIDFILE:-/var/run/zed.pid} LDMOD=${LDMOD:-/sbin/modprobe} +DELMOD=${DELMOD:-/sbin/rmmod} KMOD_ZLIB_DEFLATE=${KMOD_ZLIB_DEFLATE:-zlib_deflate} KMOD_ZLIB_INFLATE=${KMOD_ZLIB_INFLATE:-zlib_inflate} KMOD_SPL=${KMOD_SPL:-spl} -KMOD_ZAVL=${KMOD_ZAVL:-zavl} -KMOD_ZNVPAIR=${KMOD_ZNVPAIR:-znvpair} -KMOD_ZUNICODE=${KMOD_ZUNICODE:-zunicode} -KMOD_ZCOMMON=${KMOD_ZCOMMON:-zcommon} -KMOD_ZLUA=${KMOD_ZLUA:-zlua} -KMOD_ICP=${KMOD_ICP:-icp} KMOD_ZFS=${KMOD_ZFS:-zfs} KMOD_FREEBSD=${KMOD_FREEBSD:-openzfs} -KMOD_ZZSTD=${KMOD_ZZSTD:-zzstd} usage() { -cat << EOF + cat << EOF USAGE: -$0 [hvudS] [module-options] +$0 [hvudS] DESCRIPTION: Load/unload the ZFS module stack. OPTIONS: - -h Show this message - -v Verbose + -h Show this message + -v Verbose -r Reload modules - -u Unload modules - -S Enable kernel stack tracer + -u Unload modules + -S Enable kernel stack tracer EOF + exit 1 } while getopts 'hvruS' OPTION; do case $OPTION in - h) - usage - exit 1 - ;; v) VERBOSE="yes" ;; @@ -71,18 +61,17 @@ while getopts 'hvruS' OPTION; do S) STACK_TRACER="yes" ;; - ?) - usage - exit - ;; *) + usage ;; esac done +shift $(( OPTIND - 1 )) +[ $# -eq 0 ] || usage kill_zed() { if [ -f "$ZED_PIDFILE" ]; then - PID=$(cat "$ZED_PIDFILE") + read -r PID <"$ZED_PIDFILE" kill "$PID" fi } @@ -91,8 +80,7 @@ check_modules_linux() { LOADED_MODULES="" MISSING_MODULES="" - for KMOD in $KMOD_SPL $KMOD_ZAVL $KMOD_ZNVPAIR $KMOD_ZUNICODE $KMOD_ZCOMMON \ - $KMOD_ZLUA $KMOD_ZZSTD $KMOD_ICP $KMOD_ZFS; do + for KMOD in $KMOD_SPL $KMOD_ZFS; do NAME="${KMOD##*/}" NAME="${NAME%.ko}" @@ -106,7 +94,7 @@ check_modules_linux() { done if [ -n "$LOADED_MODULES" ]; then - printf "Unload the kernel modules by running '%s -u':\n" "$PROG" + printf "Unload the kernel modules by running '%s -u':\n" "$0" printf "%b" "$LOADED_MODULES" exit 1 fi @@ -123,10 +111,11 @@ check_modules_linux() { load_module_linux() { KMOD=$1 - FILE=$(modinfo "$KMOD" | awk '/^filename:/ {print $2}') - VERSION=$(modinfo "$KMOD" | awk '/^version:/ {print $2}') + FILE=$(modinfo "$KMOD" 2>&1 | awk 'NR == 1 && /zlib/ && /not found/ {print "(builtin)"; exit} /^filename:/ {print $2}') + [ "$FILE" = "(builtin)" ] && return if [ "$VERBOSE" = "yes" ]; then + VERSION=$(modinfo "$KMOD" | awk '/^version:/ {print $2}') echo "Loading: $FILE ($VERSION)" fi @@ -151,17 +140,7 @@ load_modules_freebsd() { load_modules_linux() { mkdir -p /etc/zfs - if modinfo "$KMOD_ZLIB_DEFLATE" >/dev/null 2>&1; then - modprobe "$KMOD_ZLIB_DEFLATE" >/dev/null 2>&1 - fi - - if modinfo "$KMOD_ZLIB_INFLATE">/dev/null 2>&1; then - modprobe "$KMOD_ZLIB_INFLATE" >/dev/null 2>&1 - fi - - for KMOD in $KMOD_SPL $KMOD_ZAVL $KMOD_ZNVPAIR \ - $KMOD_ZUNICODE $KMOD_ZCOMMON $KMOD_ZLUA $KMOD_ZZSTD \ - $KMOD_ICP $KMOD_ZFS; do + for KMOD in "$KMOD_ZLIB_DEFLATE" "$KMOD_ZLIB_INFLATE" $KMOD_SPL $KMOD_ZFS; do load_module_linux "$KMOD" || return 1 done @@ -172,23 +151,6 @@ load_modules_linux() { return 0 } -unload_module_linux() { - KMOD=$1 - - NAME="${KMOD##*/}" - NAME="${NAME%.ko}" - FILE=$(modinfo "$KMOD" | awk '/^filename:/ {print $2}') - VERSION=$(modinfo "$KMOD" | awk '/^version:/ {print $2}') - - if [ "$VERBOSE" = "yes" ]; then - echo "Unloading: $KMOD ($VERSION)" - fi - - rmmod "$NAME" || echo "Failed to unload $NAME" - - return 0 -} - unload_modules_freebsd() { kldunload "$KMOD_FREEBSD" || echo "Failed to unload $KMOD_FREEBSD" @@ -200,33 +162,16 @@ unload_modules_freebsd() { } unload_modules_linux() { - for KMOD in $KMOD_ZFS $KMOD_ICP $KMOD_ZZSTD $KMOD_ZLUA $KMOD_ZCOMMON \ - $KMOD_ZUNICODE $KMOD_ZNVPAIR $KMOD_ZAVL $KMOD_SPL; do + legacy_kmods="icp zzstd zlua zcommon zunicode znvpair zavl" + for KMOD in "$KMOD_ZFS" $legacy_kmods "$KMOD_SPL"; do NAME="${KMOD##*/}" NAME="${NAME%.ko}" - USE_COUNT=$(lsmod | awk '/^'"${NAME}"'/ {print $3}') - - if [ "$USE_COUNT" = "0" ] ; then - unload_module_linux "$KMOD" || return 1 - elif [ "$USE_COUNT" != "" ] ; then - echo "Module ${NAME} is still in use!" - return 1 - fi + ! [ -d "/sys/module/$NAME" ] || $DELMOD "$NAME" || return done - if modinfo "$KMOD_ZLIB_DEFLATE" >/dev/null 2>&1; then - modprobe -r "$KMOD_ZLIB_DEFLATE" >/dev/null 2>&1 - fi - - if modinfo "$KMOD_ZLIB_INFLATE">/dev/null 2>&1; then - modprobe -r "$KMOD_ZLIB_INFLATE" >/dev/null 2>&1 - fi - if [ "$VERBOSE" = "yes" ]; then echo "Successfully unloaded ZFS module stack" fi - - return 0 } stack_clear_linux() { @@ -245,8 +190,7 @@ stack_check_linux() { STACK_LIMIT=15362 if [ -e "$STACK_MAX_SIZE" ]; then - STACK_SIZE=$(cat "$STACK_MAX_SIZE") - + read -r STACK_SIZE <"$STACK_MAX_SIZE" if [ "$STACK_SIZE" -ge "$STACK_LIMIT" ]; then echo echo "Warning: max stack size $STACK_SIZE bytes" @@ -260,22 +204,22 @@ if [ "$(id -u)" != 0 ]; then exit 1 fi -UNAME=$(uname -s) +UNAME=$(uname) if [ "$UNLOAD" = "yes" ]; then kill_zed umount -t zfs -a case $UNAME in FreeBSD) - unload_modules_freebsd + unload_modules_freebsd ;; Linux) - stack_check_linux - unload_modules_linux + stack_check_linux + unload_modules_linux ;; *) - echo "unknown system: $UNAME" >&2 - exit 1 + echo "unknown system: $UNAME" >&2 + exit 1 ;; esac fi @@ -287,13 +231,13 @@ if [ "$LOAD" = "yes" ]; then Linux) stack_clear_linux check_modules_linux - load_modules_linux "$@" + load_modules_linux udevadm trigger udevadm settle ;; *) - echo "unknown system: $UNAME" >&2 - exit 1 + echo "unknown system: $UNAME" >&2 + exit 1 ;; esac fi diff --git a/sys/contrib/openzfs/scripts/zfs2zol-patch.sed b/sys/contrib/openzfs/scripts/zfs2zol-patch.sed index 99824d6dd4af..2d744cd5de52 100755 --- a/sys/contrib/openzfs/scripts/zfs2zol-patch.sed +++ b/sys/contrib/openzfs/scripts/zfs2zol-patch.sed @@ -19,7 +19,7 @@ s:usr/src/test/zfs-tests/runfiles:tests/runfiles:g s:usr/src/test/zfs-tests/tests/functional:tests/zfs-tests/tests/functional:g s:usr/src/test/zfs-tests/tests/perf:tests/zfs-tests/tests/perf:g s:usr/src/test/test-runner/cmd/run.py:tests/test-runner/cmd/test-runner.py:g -s/usr\/src\/common\/zfs\/\(.*\)\.c/module\/zcommon\/\1.c/g +s:usr/src/common/zfs/\(.*\)\.c:module/zcommon/\1.c:g # crypto framework s:usr/src/common/crypto:module/icp/algs:g diff --git a/sys/contrib/openzfs/scripts/zimport.sh b/sys/contrib/openzfs/scripts/zimport.sh index 14d2813ce268..595de494e50b 100755 --- a/sys/contrib/openzfs/scripts/zimport.sh +++ b/sys/contrib/openzfs/scripts/zimport.sh @@ -235,8 +235,8 @@ src_set_vars() { ZFS_CMD=$(command -v zfs) ZFS_SH="/usr/share/zfs/zfs.sh" else - ZPOOL_CMD="./cmd/zpool/zpool" - ZFS_CMD="./cmd/zfs/zfs" + ZPOOL_CMD="./zpool" + ZFS_CMD="./zfs" ZFS_SH="./scripts/zfs.sh" fi } diff --git a/sys/contrib/openzfs/scripts/zloop.sh b/sys/contrib/openzfs/scripts/zloop.sh index dd89ff6fdf29..ade2c84c55b7 100755 --- a/sys/contrib/openzfs/scripts/zloop.sh +++ b/sys/contrib/openzfs/scripts/zloop.sh @@ -21,7 +21,7 @@ # Copyright (c) 2017, Intel Corporation. # -BASE_DIR=$(dirname "$0") +BASE_DIR=${0%/*} SCRIPT_COMMON=common.sh if [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then . "${BASE_DIR}/${SCRIPT_COMMON}" @@ -66,8 +66,7 @@ EOF function or_die { - # shellcheck disable=SC2068 - if ! $@; then + if ! "$@"; then echo "Command failed: $*" exit 1 fi @@ -79,7 +78,7 @@ FreeBSD) ;; Linux) # core file helpers - origcorepattern="$(cat /proc/sys/kernel/core_pattern)" + read -r origcorepattern >ztest.zdb dest=$coredir/$coreid - or_die mkdir -p "$dest" or_die mkdir -p "$dest/vdev" if [[ $symlink -ne 0 ]]; then @@ -137,10 +135,8 @@ function store_core echo "*** ztest crash found - moving logs to $dest" - or_die mv ztest.history "$dest/" - or_die mv ztest.zdb "$dest/" - or_die mv ztest.out "$dest/" - or_die mv "$workdir/ztest*" "$dest/vdev/" + or_die mv ztest.history ztest.zdb ztest.out "$dest/" + or_die mv "$workdir/"ztest* "$dest/vdev/" if [[ -e "$workdir/zpool.cache" ]]; then or_die mv "$workdir/zpool.cache" "$dest/vdev/" @@ -235,9 +231,7 @@ if [[ ! -w $coredir ]]; then exit 1 fi -or_die rm -f ztest.history -or_die rm -f ztest.zdb -or_die rm -f ztest.cores +or_die rm -f ztest.history ztest.zdb ztest.cores ztrc=0 # ztest return value foundcrashes=0 # number of crashes found so far @@ -312,9 +306,7 @@ while (( timeout == 0 )) || (( curtime <= (starttime + timeout) )); do zopt="$zopt -f $workdir" cmd="$ZTEST $zopt $*" - desc="$(date '+%m/%d %T') $cmd" - echo "$desc" | tee -a ztest.history - echo "$desc" >>ztest.out + echo "$(date '+%m/%d %T') $cmd" | tee -a ztest.history ztest.out $cmd >>ztest.out 2>&1 ztrc=$? grep -E '===|WARNING' ztest.out >>ztest.history diff --git a/sys/contrib/openzfs/tests/Makefile.am b/sys/contrib/openzfs/tests/Makefile.am index 1dfc2cc5f518..d6ca957eccc8 100644 --- a/sys/contrib/openzfs/tests/Makefile.am +++ b/sys/contrib/openzfs/tests/Makefile.am @@ -1,8 +1,30 @@ -include $(top_srcdir)/config/Shellcheck.am +include $(srcdir)/%D%/zfs-tests/Makefile.am -SUBDIRS = runfiles test-runner zfs-tests -EXTRA_DIST = README.md +scripts_test_runner_bindir = $(datadir)/$(PACKAGE)/test-runner/bin +scripts_test_runner_bin_SCRIPTS = \ + %D%/test-runner/bin/test-runner.py \ + %D%/test-runner/bin/zts-report.py -SHELLCHECKSCRIPTS = $$(find . -name '*.sh') -.PHONY: $(SHELLCHECKSCRIPTS) +SUBSTFILES += $(scripts_test_runner_bin_SCRIPTS) + + +scripts_test_runner_includedir = $(datadir)/$(PACKAGE)/test-runner/include +dist_scripts_test_runner_include_DATA = \ + %D%/test-runner/include/logapi.shlib + + +scripts_runfilesdir = $(datadir)/$(PACKAGE)/runfiles +dist_scripts_runfiles_DATA = \ + %D%/runfiles/common.run \ + %D%/runfiles/freebsd.run \ + %D%/runfiles/linux.run \ + %D%/runfiles/longevity.run \ + %D%/runfiles/perf-regression.run \ + %D%/runfiles/sanity.run \ + %D%/runfiles/sunos.run + + +EXTRA_DIST += $(addprefix %D%/,README.md) + +SHELLCHECKSCRIPTS += $(shell find $(srcdir)/%D% -name '*.sh') diff --git a/sys/contrib/openzfs/tests/README.md b/sys/contrib/openzfs/tests/README.md index a01ffbe12cf7..624f5efd16e5 100644 --- a/sys/contrib/openzfs/tests/README.md +++ b/sys/contrib/openzfs/tests/README.md @@ -39,6 +39,9 @@ The pre-requisites for running the ZFS Test Suite are: * The ZFS Test Suite will add users and groups to test machine to verify functionality. Therefore it is strongly advised that a dedicated test machine, which can be a VM, be used for testing. + * On FreeBSD, mountd(8) must use `/etc/zfs/exports` + as one of its export files – by default this can be done by setting + `zfs_enable=yes` in `/etc/rc.conf`. Once the pre-requisites are satisfied simply run the zfs-tests.sh script: @@ -88,6 +91,7 @@ The following zfs-tests.sh options are supported: -d DIR Create sparse files for vdevs in the DIR directory. By default these files are created under /var/tmp/. + This directory must be world-writable. -s SIZE Use vdevs of SIZE (default: 4G) diff --git a/sys/contrib/openzfs/tests/runfiles/Makefile.am b/sys/contrib/openzfs/tests/runfiles/Makefile.am deleted file mode 100644 index 278e94934fe1..000000000000 --- a/sys/contrib/openzfs/tests/runfiles/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/runfiles -dist_pkgdata_DATA = \ - common.run \ - freebsd.run \ - linux.run \ - longevity.run \ - perf-regression.run \ - sanity.run \ - sunos.run diff --git a/sys/contrib/openzfs/tests/runfiles/common.run b/sys/contrib/openzfs/tests/runfiles/common.run index 87b669db7dcb..4ff46e7af35f 100644 --- a/sys/contrib/openzfs/tests/runfiles/common.run +++ b/sys/contrib/openzfs/tests/runfiles/common.run @@ -40,6 +40,10 @@ tests = ['alloc_class_001_pos', 'alloc_class_002_neg', 'alloc_class_003_pos', 'alloc_class_013_pos'] tags = ['functional', 'alloc_class'] +[tests/functional/append] +tests = ['file_append', 'threadsappend_001_pos'] +tags = ['functional', 'append'] + [tests/functional/arc] tests = ['dbufstats_001_pos', 'dbufstats_002_pos', 'dbufstats_003_pos', 'arcstats_runtime_tuning'] @@ -305,7 +309,7 @@ tags = ['functional', 'cli_root', 'zfs_unmount'] [tests/functional/cli_root/zfs_unshare] tests = ['zfs_unshare_001_pos', 'zfs_unshare_002_pos', 'zfs_unshare_003_pos', 'zfs_unshare_004_neg', 'zfs_unshare_005_neg', 'zfs_unshare_006_pos', - 'zfs_unshare_007_pos'] + 'zfs_unshare_007_pos', 'zfs_unshare_008_pos'] tags = ['functional', 'cli_root', 'zfs_unshare'] [tests/functional/cli_root/zfs_upgrade] @@ -488,6 +492,7 @@ tags = ['functional', 'cli_root', 'zpool_split'] [tests/functional/cli_root/zpool_status] tests = ['zpool_status_001_pos', 'zpool_status_002_pos', + 'zpool_status_003_pos', 'zpool_status_004_pos', 'zpool_status_features_001_pos'] tags = ['functional', 'cli_root', 'zpool_status'] @@ -640,7 +645,9 @@ tests = ['history_001_pos', 'history_002_pos', 'history_003_pos', tags = ['functional', 'history'] [tests/functional/hkdf] -tests = ['run_hkdf_test'] +pre = +post = +tests = ['hkdf_test'] tags = ['functional', 'hkdf'] [tests/functional/inheritance] @@ -678,7 +685,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', 'mmap_seek_001_pos'] +tests = ['mmap_write_001_pos', 'mmap_read_001_pos', 'mmap_seek_001_pos', 'mmap_sync_001_pos'] tags = ['functional', 'mmap'] [tests/functional/mount] @@ -881,10 +888,6 @@ tests = ['suid_write_to_suid', 'suid_write_to_sgid', 'suid_write_to_suid_sgid', 'suid_write_to_none', 'suid_write_zil_replay'] tags = ['functional', 'suid'] -[tests/functional/threadsappend] -tests = ['threadsappend_001_pos'] -tags = ['functional', 'threadsappend'] - [tests/functional/trim] tests = ['autotrim_integrity', 'autotrim_config', 'autotrim_trim_integrity', 'trim_integrity', 'trim_config', 'trim_l2arc'] diff --git a/sys/contrib/openzfs/tests/runfiles/linux.run b/sys/contrib/openzfs/tests/runfiles/linux.run index 8412a7ea5a95..3985da146044 100644 --- a/sys/contrib/openzfs/tests/runfiles/linux.run +++ b/sys/contrib/openzfs/tests/runfiles/linux.run @@ -90,7 +90,7 @@ tests = ['events_001_pos', 'events_002_pos', 'zed_rc_filter', 'zed_fd_spill'] tags = ['functional', 'events'] [tests/functional/fallocate:Linux] -tests = ['fallocate_prealloc'] +tests = ['fallocate_prealloc', 'fallocate_zero-range'] tags = ['functional', 'fallocate'] [tests/functional/fault:Linux] diff --git a/sys/contrib/openzfs/tests/runfiles/sanity.run b/sys/contrib/openzfs/tests/runfiles/sanity.run index 9faf0e4d9913..f5dcfa5be4b7 100644 --- a/sys/contrib/openzfs/tests/runfiles/sanity.run +++ b/sys/contrib/openzfs/tests/runfiles/sanity.run @@ -438,7 +438,9 @@ tests = ['history_004_pos', 'history_005_neg', 'history_007_pos', tags = ['functional', 'history'] [tests/functional/hkdf] -tests = ['run_hkdf_test'] +pre = +post = +tests = ['hkdf_test'] tags = ['functional', 'hkdf'] [tests/functional/inuse] @@ -582,7 +584,7 @@ tests = ['suid_write_to_suid', 'suid_write_to_sgid', 'suid_write_to_suid_sgid', 'suid_write_to_none'] tags = ['functional', 'suid'] -[tests/functional/threadsappend] +[tests/functional/append] tests = ['threadsappend_001_pos'] tags = ['functional', 'threadsappend'] diff --git a/sys/contrib/openzfs/tests/test-runner/Makefile.am b/sys/contrib/openzfs/tests/test-runner/Makefile.am deleted file mode 100644 index db3d966142d6..000000000000 --- a/sys/contrib/openzfs/tests/test-runner/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = bin include man diff --git a/sys/contrib/openzfs/tests/test-runner/bin/Makefile.am b/sys/contrib/openzfs/tests/test-runner/bin/Makefile.am deleted file mode 100644 index e11e55fffdeb..000000000000 --- a/sys/contrib/openzfs/tests/test-runner/bin/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am - -pkgdatadir = $(datadir)/@PACKAGE@/test-runner/bin -pkgdata_SCRIPTS = \ - test-runner.py \ - zts-report.py - -SUBSTFILES += $(pkgdata_SCRIPTS) diff --git a/sys/contrib/openzfs/tests/test-runner/bin/test-runner.py.in b/sys/contrib/openzfs/tests/test-runner/bin/test-runner.py.in index 5c868d945a8c..cb453b266f3c 100755 --- a/sys/contrib/openzfs/tests/test-runner/bin/test-runner.py.in +++ b/sys/contrib/openzfs/tests/test-runner/bin/test-runner.py.in @@ -291,7 +291,7 @@ User: %s self.result.starttime = monotonic_time() if kmemleak: - cmd = f'echo clear | {SUDO} tee {KMEMLEAK_FILE}' + cmd = f'{SUDO} sh -c "echo clear > {KMEMLEAK_FILE}"' check_output(cmd, shell=True) proc = Popen(privcmd, stdout=PIPE, stderr=PIPE) @@ -305,7 +305,7 @@ User: %s self.result.stdout, self.result.stderr = self.collect_output(proc) if kmemleak: - cmd = f'echo scan | {SUDO} tee {KMEMLEAK_FILE}' + cmd = f'{SUDO} sh -c "echo scan > {KMEMLEAK_FILE}"' check_output(cmd, shell=True) cmd = f'{SUDO} cat {KMEMLEAK_FILE}' self.result.kmemleak = check_output(cmd, shell=True) @@ -880,7 +880,7 @@ class TestRun(object): self.outputdir, LOG_ERR) if options.kmemleak: - cmd = f'echo scan=0 | {SUDO} tee {KMEMLEAK_FILE}' + cmd = f'{SUDO} -c "echo scan=0 > {KMEMLEAK_FILE}"' check_output(cmd, shell=True) iteration = 0 diff --git a/sys/contrib/openzfs/tests/test-runner/bin/zts-report.py.in b/sys/contrib/openzfs/tests/test-runner/bin/zts-report.py.in index 560f7dce6814..ddb9bb7eed1d 100755 --- a/sys/contrib/openzfs/tests/test-runner/bin/zts-report.py.in +++ b/sys/contrib/openzfs/tests/test-runner/bin/zts-report.py.in @@ -67,7 +67,6 @@ exec_reason = 'Test user execute permissions required for utilities' # additional python modules be installed, for example python3-cffi is required # by the pyzfs tests. # -python_reason = 'Python v3.6 or newer required' python_deps_reason = 'Python modules missing: python3-cffi' # @@ -82,11 +81,6 @@ tmpfile_reason = 'Kernel O_TMPFILE support required' # statx_reason = 'Kernel statx(2) system call required on Linux' -# -# Some tests require that the NFS client and server utilities be installed. -# -share_reason = 'NFS client and server utilities required' - # # Some tests require that the lsattr utility support the project id feature. # @@ -106,14 +100,6 @@ user_ns_reason = 'Kernel user namespace support required' # rewind_reason = 'Arbitrary pool rewind is not guaranteed' -# -# Some tests may by structured in a way that relies on exact knowledge -# of how much free space in available in a pool. These tests cannot be -# made completely reliable because the internal details of how free space -# is managed are not exposed to user space. -# -enospc_reason = 'Exact free space reporting is not guaranteed' - # # Some tests require a minimum version of the fio benchmark utility. # Older distributions such as CentOS 6.x only provide fio-2.0.13. @@ -146,11 +132,6 @@ na_reason = "Not applicable" # ci_reason = 'CI runner doesn\'t have all requirements' -summary = { - 'total': float(0), - 'passed': float(0), - 'logfile': "Could not determine logfile location." -} # # These tests are known to fail, thus we use this list to prevent these @@ -164,10 +145,8 @@ summary = { # reasons listed above can be used. # known = { - 'casenorm/mixed_none_lookup_ci': ['FAIL', '7633'], - '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], + 'casenorm/mixed_none_lookup_ci': ['FAIL', 7633], + 'casenorm/mixed_formd_lookup_ci': ['FAIL', 7633], 'cli_root/zpool_import/import_rewind_device_replaced': ['FAIL', rewind_reason], 'cli_user/misc/zfs_share_001_neg': ['SKIP', na_reason], @@ -175,7 +154,7 @@ known = { 'privilege/setup': ['SKIP', na_reason], 'refreserv/refreserv_004_pos': ['FAIL', known_reason], 'rootpool/setup': ['SKIP', na_reason], - 'rsend/rsend_008_pos': ['SKIP', '6066'], + 'rsend/rsend_008_pos': ['SKIP', 6066], 'vdev_zaps/vdev_zaps_007_pos': ['FAIL', known_reason], } @@ -186,15 +165,19 @@ if sys.platform.startswith('freebsd'): 'cli_root/zpool_wait/zpool_wait_trim_basic': ['SKIP', trim_reason], 'cli_root/zpool_wait/zpool_wait_trim_cancel': ['SKIP', trim_reason], 'cli_root/zpool_wait/zpool_wait_trim_flag': ['SKIP', trim_reason], + 'cli_root/zfs_unshare/zfs_unshare_008_pos': ['SKIP', na_reason], 'link_count/link_count_001': ['SKIP', na_reason], + 'casenorm/mixed_create_failure': ['FAIL', 13215], + 'mmap/mmap_sync_001_pos': ['SKIP', na_reason], }) elif sys.platform.startswith('linux'): known.update({ - 'casenorm/mixed_formd_lookup': ['FAIL', '7633'], - 'casenorm/mixed_formd_delete': ['FAIL', '7633'], - 'casenorm/sensitive_formd_lookup': ['FAIL', '7633'], - 'casenorm/sensitive_formd_delete': ['FAIL', '7633'], + 'casenorm/mixed_formd_lookup': ['FAIL', 7633], + 'casenorm/mixed_formd_delete': ['FAIL', 7633], + 'casenorm/sensitive_formd_lookup': ['FAIL', 7633], + 'casenorm/sensitive_formd_delete': ['FAIL', 7633], 'removal/removal_with_zdb': ['SKIP', known_reason], + 'cli_root/zfs_unshare/zfs_unshare_002_pos': ['SKIP', na_reason], }) @@ -216,50 +199,50 @@ maybe = { 'cli_root/zfs_destroy/zfs_destroy_dev_removal_condense': ['FAIL', known_reason], 'cli_root/zfs_get/zfs_get_004_pos': ['FAIL', known_reason], - 'cli_root/zfs_get/zfs_get_009_pos': ['SKIP', '5479'], + 'cli_root/zfs_get/zfs_get_009_pos': ['SKIP', 5479], 'cli_root/zfs_rollback/zfs_rollback_001_pos': ['FAIL', known_reason], 'cli_root/zfs_rollback/zfs_rollback_002_pos': ['FAIL', known_reason], - 'cli_root/zfs_share/setup': ['SKIP', share_reason], 'cli_root/zfs_snapshot/zfs_snapshot_002_neg': ['FAIL', known_reason], - 'cli_root/zfs_unshare/setup': ['SKIP', share_reason], + 'cli_root/zfs_unshare/zfs_unshare_006_pos': ['SKIP', na_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/zpool_import_missing_003_pos': ['SKIP', '6839'], + 'cli_root/zpool_destroy/zpool_destroy_001_pos': ['SKIP', 6145], + 'cli_root/zpool_import/zpool_import_missing_003_pos': ['SKIP', 6839], 'cli_root/zpool_initialize/zpool_initialize_import_export': - ['FAIL', '11948'], + ['FAIL', 11948], 'cli_root/zpool_labelclear/zpool_labelclear_removed': ['FAIL', known_reason], 'cli_root/zpool_trim/setup': ['SKIP', trim_reason], - 'cli_root/zpool_upgrade/zpool_upgrade_004_pos': ['FAIL', '6141'], + 'cli_root/zpool_upgrade/zpool_upgrade_004_pos': ['FAIL', 6141], 'delegate/setup': ['SKIP', exec_reason], 'fallocate/fallocate_punch-hole': ['SKIP', fspacectl_reason], - 'history/history_004_pos': ['FAIL', '7026'], - 'history/history_005_neg': ['FAIL', '6680'], - 'history/history_006_neg': ['FAIL', '5657'], + 'history/history_004_pos': ['FAIL', 7026], + 'history/history_005_neg': ['FAIL', 6680], + 'history/history_006_neg': ['FAIL', 5657], 'history/history_008_pos': ['FAIL', known_reason], 'history/history_010_pos': ['SKIP', exec_reason], 'io/mmap': ['SKIP', fio_reason], 'largest_pool/largest_pool_001_pos': ['FAIL', known_reason], 'mmp/mmp_on_uberblocks': ['FAIL', known_reason], 'pyzfs/pyzfs_unittest': ['SKIP', python_deps_reason], - 'pool_checkpoint/checkpoint_discard_busy': ['FAIL', '11946'], + 'pool_checkpoint/checkpoint_discard_busy': ['FAIL', 11946], 'projectquota/setup': ['SKIP', exec_reason], - 'redundancy/redundancy_004_neg': ['FAIL', '7290'], - 'redundancy/redundancy_draid_spare3': ['SKIP', known_reason], + 'redundancy/redundancy_004_neg': ['FAIL', 7290], + 'redundancy/redundancy_draid_spare1': ['FAIL', known_reason], + 'redundancy/redundancy_draid_spare3': ['FAIL', known_reason], 'removal/removal_condense_export': ['FAIL', known_reason], - 'reservation/reservation_008_pos': ['FAIL', '7741'], - 'reservation/reservation_018_pos': ['FAIL', '5642'], + 'reservation/reservation_008_pos': ['FAIL', 7741], + 'reservation/reservation_018_pos': ['FAIL', 5642], 'snapshot/clone_001_pos': ['FAIL', known_reason], - 'snapshot/snapshot_009_pos': ['FAIL', '7961'], - 'snapshot/snapshot_010_pos': ['FAIL', '7961'], - 'snapused/snapused_004_pos': ['FAIL', '5513'], + 'snapshot/snapshot_009_pos': ['FAIL', 7961], + 'snapshot/snapshot_010_pos': ['FAIL', 7961], + 'snapused/snapused_004_pos': ['FAIL', 5513], 'tmpfile/setup': ['SKIP', tmpfile_reason], - 'threadsappend/threadsappend_001_pos': ['FAIL', '6136'], + 'append/threadsappend_001_pos': ['FAIL', 6136], 'trim/setup': ['SKIP', trim_reason], 'upgrade/upgrade_projectquota_001_pos': ['SKIP', project_id_reason], 'user_namespace/setup': ['SKIP', user_ns_reason], 'userquota/setup': ['SKIP', exec_reason], - 'zvol/zvol_ENOSPC/zvol_ENOSPC_001_pos': ['FAIL', '5848'], + 'zvol/zvol_ENOSPC/zvol_ENOSPC_001_pos': ['FAIL', 5848], 'pam/setup': ['SKIP', "pamtester might be not available"], } @@ -267,28 +250,28 @@ if sys.platform.startswith('freebsd'): maybe.update({ 'cli_root/zfs_copies/zfs_copies_002_pos': ['FAIL', known_reason], 'cli_root/zfs_inherit/zfs_inherit_001_neg': ['FAIL', known_reason], - 'cli_root/zfs_share/zfs_share_011_pos': ['FAIL', known_reason], 'cli_root/zfs_share/zfs_share_concurrent_shares': ['FAIL', known_reason], 'cli_root/zpool_import/zpool_import_012_pos': ['FAIL', known_reason], 'delegate/zfs_allow_003_pos': ['FAIL', known_reason], - 'inheritance/inherit_001_pos': ['FAIL', '11829'], + 'inheritance/inherit_001_pos': ['FAIL', 11829], 'resilver/resilver_restart_001': ['FAIL', known_reason], - 'pool_checkpoint/checkpoint_big_rewind': ['FAIL', '12622'], - 'pool_checkpoint/checkpoint_indirect': ['FAIL', '12623'], + 'pool_checkpoint/checkpoint_big_rewind': ['FAIL', 12622], + 'pool_checkpoint/checkpoint_indirect': ['FAIL', 12623], }) elif sys.platform.startswith('linux'): maybe.update({ 'cli_root/zfs_rename/zfs_rename_002_pos': ['FAIL', known_reason], 'cli_root/zpool_reopen/zpool_reopen_003_pos': ['FAIL', known_reason], - 'fault/auto_spare_shared': ['FAIL', '11889'], + 'fault/auto_spare_shared': ['FAIL', 11889], + 'fault/auto_spare_multiple': ['FAIL', 11889], 'io/io_uring': ['SKIP', 'io_uring support required'], 'limits/filesystem_limit': ['SKIP', known_reason], 'limits/snapshot_limit': ['SKIP', known_reason], 'mmp/mmp_active_import': ['FAIL', known_reason], 'mmp/mmp_exported_import': ['FAIL', known_reason], 'mmp/mmp_inactive_import': ['FAIL', known_reason], - 'zvol/zvol_misc/zvol_misc_snapdev': ['FAIL', '12621'], + 'zvol/zvol_misc/zvol_misc_snapdev': ['FAIL', 12621], 'zvol/zvol_misc/zvol_misc_volmode': ['FAIL', known_reason], }) @@ -319,44 +302,37 @@ if os.environ.get('CI') == 'true': }) maybe.update({ - 'events/events_002_pos': ['FAIL', '11546'], + 'events/events_002_pos': ['FAIL', 11546], }) -def usage(s): - print(s) - sys.exit(1) - - def process_results(pathname): try: f = open(pathname) except IOError as e: - print('Error opening file: %s' % e) + print('Error opening file:', e) sys.exit(1) prefix = '/zfs-tests/tests/functional/' pattern = \ r'^Test(?:\s+\(\S+\))?:' + \ - r'\s*\S*%s(\S+)\s*\(run as (\S+)\)\s*\[(\S+)\]\s*\[(\S+)\]' \ - % prefix + rf'\s*\S*{prefix}(\S+)' + \ + r'\s*\(run as (\S+)\)\s*\[(\S+)\]\s*\[(\S+)\]' pattern_log = r'^\s*Log directory:\s*(\S*)' d = {} + logdir = 'Could not determine log directory.' for line in f.readlines(): m = re.match(pattern, line) if m and len(m.groups()) == 4: - summary['total'] += 1 - if m.group(4) == "PASS": - summary['passed'] += 1 d[m.group(1)] = m.group(4) continue m = re.match(pattern_log, line) if m: - summary['logfile'] = m.group(1) + logdir = m.group(1) - return d + return d, logdir class ListMaybesAction(argparse.Action): @@ -385,11 +361,11 @@ if __name__ == "__main__": parser.add_argument('--no-maybes', action='store_false', dest='maybes') args = parser.parse_args() - results = process_results(args.logfile) + results, logdir = process_results(args.logfile) - if summary['total'] == 0: + if not results: print("\n\nNo test results were found.") - print("Log directory: %s" % summary['logfile']) + print("Log directory:", logdir) sys.exit(0) expected = [] @@ -429,13 +405,13 @@ if __name__ == "__main__": if test in known: if known[test][1] == na_reason: continue - elif known[test][1].isdigit(): - expect = issue_url + known[test][1] + elif isinstance(known[test][1], int): + expect = f"{issue_url}{known[test][1]}" else: expect = known[test][1] elif test in maybe: - if maybe[test][1].isdigit(): - expect = issue_url + maybe[test][1] + if isinstance(maybe[test][1], int): + expect = f"{issue_url}{maybe[test][1]}" else: expect = maybe[test][1] elif setup in known and known[setup][0] == "SKIP" and setup != test: @@ -444,7 +420,7 @@ if __name__ == "__main__": continue else: expect = "UNKNOWN REASON" - print(" %s %s (%s)" % (results[test], test, expect)) + print(f" {results[test]} {test} ({expect})") print("\nTests with result of PASS that are unexpected:") for test in sorted(known.keys()): @@ -452,13 +428,12 @@ if __name__ == "__main__": # where "test" is not in "results". if test not in results or results[test] != "PASS": continue - print(" %s %s (expected %s)" % (results[test], test, - known[test][0])) + print(f" {results[test]} {test} (expected {known[test][0]})") print("\nTests with results other than PASS that are unexpected:") for test in sorted(unexpected): expect = "PASS" if test not in known else known[test][0] - print(" %s %s (expected %s)" % (results[test], test, expect)) + print(f" {results[test]} {test} (expected {expect})") if len(unexpected) == 0: sys.exit(0) diff --git a/sys/contrib/openzfs/tests/test-runner/include/Makefile.am b/sys/contrib/openzfs/tests/test-runner/include/Makefile.am deleted file mode 100644 index d3eeb32de914..000000000000 --- a/sys/contrib/openzfs/tests/test-runner/include/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/test-runner/include - -dist_pkgdata_DATA = \ - logapi.shlib \ - stf.shlib diff --git a/sys/contrib/openzfs/tests/test-runner/include/logapi.shlib b/sys/contrib/openzfs/tests/test-runner/include/logapi.shlib index 33423a7e3c65..094e8cb21a33 100644 --- a/sys/contrib/openzfs/tests/test-runner/include/logapi.shlib +++ b/sys/contrib/openzfs/tests/test-runner/include/logapi.shlib @@ -26,7 +26,11 @@ # Copyright (c) 2012, 2020 by Delphix. All rights reserved. # -. ${STF_TOOLS}/include/stf.shlib +STF_PASS=0 +STF_FAIL=1 +STF_UNRESOLVED=2 +STF_UNSUPPORTED=4 +STF_UNTESTED=5 # Output an assertion # @@ -54,7 +58,7 @@ function log_note function log_neg { - log_neg_expect "" "$@" + log_neg_expect "" "$@" } # Execute a positive test and exit $STF_FAIL is test fails @@ -85,7 +89,6 @@ function log_must_nostderr # function log_must_retry { - typeset out="" typeset logfile="/tmp/log.$$" typeset status=1 typeset expect=$1 @@ -100,14 +103,10 @@ function log_must_retry while (( $retry > 0 )); do "$@" 2>$logfile status=$? - out="cat $logfile" if (( $status == 0 )); then - $out | egrep -i "internal error|assertion failed" \ - > /dev/null 2>&1 - # internal error or assertion failed - if [[ $? -eq 0 ]]; then - print -u2 $($out) + if grep -qEi "internal error|assertion failed" $logfile; then + cat $logfile >&2 _printerror "$@" "internal error or" \ " assertion failure exited $status" status=1 @@ -117,9 +116,8 @@ function log_must_retry fi break else - $out | grep -i "$expect" > /dev/null 2>&1 - if (( $? == 0 )); then - print -u2 $($out) + if grep -qi "$expect" $logfile; then + cat $logfile >&2 _printerror "$@" "Retry in $delay seconds" sleep $delay @@ -132,7 +130,7 @@ function log_must_retry done if (( $status != 0 )) ; then - print -u2 $($out) + cat $logfile >&2 _printerror "$@" "exited $status" fi @@ -197,7 +195,6 @@ EXIT_SIGSEGV=$((EXIT_SIGNAL + SIGSEGV)) function log_neg_expect { - typeset out="" typeset logfile="/tmp/log.$$" typeset ret=1 typeset expect=$1 @@ -209,38 +206,33 @@ function log_neg_expect "$@" 2>$logfile typeset status=$? - out="cat $logfile" # unexpected status if (( $status == EXIT_SUCCESS )); then - print -u2 $($out) + cat $logfile >&2 _printerror "$@" "unexpectedly exited $status" # missing binary elif (( $status == EXIT_NOTFOUND )); then - print -u2 $($out) + cat $logfile >&2 _printerror "$@" "unexpectedly exited $status (File not found)" # bus error - core dump elif (( $status == EXIT_SIGBUS )); then - print -u2 $($out) + cat $logfile >&2 _printerror "$@" "unexpectedly exited $status (Bus Error)" # segmentation violation - core dump elif (( $status == EXIT_SIGSEGV )); then - print -u2 $($out) + cat $logfile >&2 _printerror "$@" "unexpectedly exited $status (SEGV)" else - $out | egrep -i "internal error|assertion failed" \ - > /dev/null 2>&1 - # internal error or assertion failed - if (( $? == 0 )); then - print -u2 $($out) + if grep -qEi "internal error|assertion failed" $logfile; then + cat $logfile >&2 _printerror "$@" "internal error or assertion failure" \ " exited $status" elif [[ -n $expect ]] ; then - $out | grep -i "$expect" > /dev/null 2>&1 - if (( $? == 0 )); then + if grep -qi "$expect" $logfile; then ret=0 else - print -u2 $($out) + cat $logfile >&2 _printerror "$@" "unexpectedly exited $status" fi else @@ -264,7 +256,6 @@ function log_neg_expect function log_pos { - typeset out="" typeset logfile="/tmp/log.$$" while [[ -e $logfile ]]; do @@ -273,17 +264,13 @@ function log_pos "$@" 2>$logfile typeset status=$? - out="cat $logfile" if (( $status != 0 )) ; then - print -u2 $($out) + cat $logfile >&2 _printerror "$@" "exited $status" else - $out | egrep -i "internal error|assertion failed" \ - > /dev/null 2>&1 - # internal error or assertion failed - if [[ $? -eq 0 ]]; then - print -u2 $($out) + if grep -qEi "internal error|assertion failed" $logfile; then + cat $logfile >&2 _printerror "$@" "internal error or assertion failure" \ " exited $status" status=1 @@ -306,7 +293,6 @@ function log_pos function log_pos_nostderr { - typeset out="" typeset logfile="/tmp/log.$$" while [[ -e $logfile ]]; do @@ -315,15 +301,13 @@ function log_pos_nostderr "$@" 2>$logfile typeset status=$? - out="cat $logfile" - typeset out_msg=$($out) if (( $status != 0 )) ; then - print -u2 $out_msg + cat $logfile >&2 _printerror "$@" "exited $status" else - if [[ ! -z "$out_msg" ]]; then - print -u2 $out_msg + if [ -s "$logfile" ]; then + cat $logfile >&2 _printerror "$@" "message in stderr" \ " exited $status" status=1 @@ -392,15 +376,6 @@ function log_unresolved _endlog $STF_UNRESOLVED "$@" } -# Perform cleanup and exit $STF_NOTINUSE -# -# $@ - message text - -function log_notinuse -{ - _endlog $STF_NOTINUSE "$@" -} - # Perform cleanup and exit $STF_UNSUPPORTED # # $@ - message text @@ -419,51 +394,6 @@ function log_untested _endlog $STF_UNTESTED "$@" } -# Perform cleanup and exit $STF_UNINITIATED -# -# $@ - message text - -function log_uninitiated -{ - _endlog $STF_UNINITIATED "$@" -} - -# Perform cleanup and exit $STF_NORESULT -# -# $@ - message text - -function log_noresult -{ - _endlog $STF_NORESULT "$@" -} - -# Perform cleanup and exit $STF_WARNING -# -# $@ - message text - -function log_warning -{ - _endlog $STF_WARNING "$@" -} - -# Perform cleanup and exit $STF_TIMED_OUT -# -# $@ - message text - -function log_timed_out -{ - _endlog $STF_TIMED_OUT "$@" -} - -# Perform cleanup and exit $STF_OTHER -# -# $@ - message text - -function log_other -{ - _endlog $STF_OTHER "$@" -} - function set_main_pid { _MAINPID=$1 @@ -481,12 +411,12 @@ function _execute_testfail_callbacks { typeset callback - print "$TESTFAIL_CALLBACKS:" | while read -d ":" callback; do + while read -d ":" callback; do if [[ -n "$callback" ]] ; then log_note "Performing test-fail callback ($callback)" $callback fi - done + done <<<"$TESTFAIL_CALLBACKS:" } # Perform cleanup and exit @@ -534,7 +464,7 @@ function _endlog function _printline { - print "$@" + echo "$@" } # Output an error message diff --git a/sys/contrib/openzfs/tests/test-runner/include/stf.shlib b/sys/contrib/openzfs/tests/test-runner/include/stf.shlib deleted file mode 100644 index ea879a84c131..000000000000 --- a/sys/contrib/openzfs/tests/test-runner/include/stf.shlib +++ /dev/null @@ -1,57 +0,0 @@ -# -# 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 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# Copyright (c) 2012 by Delphix. All rights reserved. -# - - -STF_PASS=0 -STF_FAIL=1 -STF_UNRESOLVED=2 -STF_NOTINUSE=3 -STF_UNSUPPORTED=4 -STF_UNTESTED=5 -STF_UNINITIATED=6 -STF_NORESULT=7 -STF_WARNING=8 -STF_TIMED_OUT=9 -STF_OTHER=10 - -# do this to use the names: eval echo \$STF_RESULT_NAME_${result} -STF_RESULT_NAME_0="PASS" -STF_RESULT_NAME_1="FAIL" -STF_RESULT_NAME_2="UNRESOLVED" -STF_RESULT_NAME_3="NOTINUSE" -STF_RESULT_NAME_4="UNSUPPORTED" -STF_RESULT_NAME_5="UNTESTED" -STF_RESULT_NAME_6="UNINITIATED" -STF_RESULT_NAME_7="NORESULT" -STF_RESULT_NAME_8="WARNING" -STF_RESULT_NAME_9="TIMED_OUT" -STF_RESULT_NAME_10="OTHER" - -# do this to use the array: ${STF_RESULT_NAMES[$result]} -STF_RESULT_NAMES=( "PASS" "FAIL" "UNRESOLVED" "NOTINUSE" "UNSUPPORTED" \ - "UNTESTED" "UNINITIATED" "NORESULT" "WARNING" "TIMED_OUT" "OTHER" ) diff --git a/sys/contrib/openzfs/tests/test-runner/man/Makefile.am b/sys/contrib/openzfs/tests/test-runner/man/Makefile.am deleted file mode 100644 index a7017f5f0535..000000000000 --- a/sys/contrib/openzfs/tests/test-runner/man/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -dist_man_MANS = test-runner.1 - -install-data-local: - $(INSTALL) -d -m 0755 "$(DESTDIR)$(mandir)/man1" diff --git a/sys/contrib/openzfs/tests/zfs-tests/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/.gitignore new file mode 100644 index 000000000000..ba077a4031ad --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/.gitignore @@ -0,0 +1 @@ +bin diff --git a/sys/contrib/openzfs/tests/zfs-tests/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/Makefile.am index ef4e6be9e980..f8166352489e 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/Makefile.am +++ b/sys/contrib/openzfs/tests/zfs-tests/Makefile.am @@ -1 +1,48 @@ -SUBDIRS = cmd include tests callbacks +SUBDIRS += %D%/tests + +include $(srcdir)/%D%/cmd/Makefile.am + + +scripts_zfs_tests_functional_libzfsdir = $(datadir)/$(PACKAGE)/zfs-tests/tests/functional/libzfs +scripts_zfs_tests_functional_libzfs_PROGRAMS = %D%/tests/functional/libzfs/many_fds +%C%_tests_functional_libzfs_many_fds_LDADD = \ + libzfs.la + +scripts_zfs_tests_functional_hkdfdir = $(datadir)/$(PACKAGE)/zfs-tests/tests/functional/hkdf +scripts_zfs_tests_functional_hkdf_PROGRAMS = %D%/tests/functional/hkdf/hkdf_test +%C%_tests_functional_hkdf_hkdf_test_LDADD = \ + libzpool.la + +if BUILD_LINUX +scripts_zfs_tests_functional_tmpfiledir = $(datadir)/$(PACKAGE)/zfs-tests/tests/functional/tmpfile +scripts_zfs_tests_functional_tmpfile_PROGRAMS = \ + %D%/tests/functional/tmpfile/tmpfile_001_pos \ + %D%/tests/functional/tmpfile/tmpfile_002_pos \ + %D%/tests/functional/tmpfile/tmpfile_003_pos \ + %D%/tests/functional/tmpfile/tmpfile_stat_mode \ + %D%/tests/functional/tmpfile/tmpfile_test +endif + + +scripts_zfs_tests_callbacksdir = $(datadir)/$(PACKAGE)/zfs-tests/callbacks +dist_scripts_zfs_tests_callbacks_SCRIPTS = \ + %D%/callbacks/zfs_dbgmsg.ksh \ + %D%/callbacks/zfs_dmesg.ksh \ + %D%/callbacks/zfs_failsafe.ksh \ + %D%/callbacks/zfs_mmp.ksh + + +scripts_zfs_tests_includedir = $(datadir)/$(PACKAGE)/zfs-tests/include +dist_scripts_zfs_tests_include_DATA = \ + %D%/include/blkdev.shlib \ + %D%/include/commands.cfg \ + %D%/include/libtest.shlib \ + %D%/include/math.shlib \ + %D%/include/properties.shlib \ + %D%/include/tunables.cfg \ + %D%/include/zpool_script.shlib + +nodist_scripts_zfs_tests_include_DATA = \ + %D%/include/default.cfg + +SUBSTFILES += $(nodist_scripts_zfs_tests_include_DATA) diff --git a/sys/contrib/openzfs/tests/zfs-tests/callbacks/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/callbacks/Makefile.am deleted file mode 100644 index 512a737bb5c9..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/callbacks/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/callbacks -dist_pkgdata_SCRIPTS = \ - zfs_failsafe.ksh \ - zfs_dbgmsg.ksh \ - zfs_dmesg.ksh \ - zfs_mmp.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/.gitignore new file mode 100644 index 000000000000..1830cab76fee --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/cmd/.gitignore @@ -0,0 +1,47 @@ +/badsend +/btree_test +/chg_usr_exec +/devname2devid +/dir_rd_update +/draid +/file_append +/file_check +/file_trunc +/file_write +/get_diff +/getversion +/largest_file +/libzfs_input_check +/mkbusy +/mkfile +/mkfiles +/mktree +/mmap_exec +/mmap_libaio +/mmap_seek +/mmap_sync +/mmapwrite +/nvlist_to_lua +/randfree_file +/randwritecomp +/read_dos_attributes +/readmmap +/rename_dir +/rm_lnkcnt_zero_file +/send_doall +/stride_dd +/threadsappend +/user_ns_exec +/write_dos_attributes +/xattrtest +/zed_fd_spill-zedlet +/suid_write_to_file +/cp_files +/ctime +/truncate_test +/ereports +/zfs_diff-socket +/dosmode_readonly_write +/edonr_test +/skein_test +/sha2_test diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/Makefile.am index 88d8c8cf08b2..71edd4939424 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/Makefile.am +++ b/sys/contrib/openzfs/tests/zfs-tests/cmd/Makefile.am @@ -1,41 +1,127 @@ -EXTRA_DIST = file_common.h +scripts_zfs_tests_bindir = $(datadir)/$(PACKAGE)/zfs-tests/bin + + +scripts_zfs_tests_bin_PROGRAMS = %D%/chg_usr_exec +scripts_zfs_tests_bin_PROGRAMS += %D%/cp_files +scripts_zfs_tests_bin_PROGRAMS += %D%/ctime +scripts_zfs_tests_bin_PROGRAMS += %D%/dir_rd_update +scripts_zfs_tests_bin_PROGRAMS += %D%/dosmode_readonly_write +scripts_zfs_tests_bin_PROGRAMS += %D%/get_diff +scripts_zfs_tests_bin_PROGRAMS += %D%/rename_dir +scripts_zfs_tests_bin_PROGRAMS += %D%/suid_write_to_file +scripts_zfs_tests_bin_PROGRAMS += %D%/truncate_test +scripts_zfs_tests_bin_PROGRAMS += %D%/zfs_diff-socket + + +scripts_zfs_tests_bin_PROGRAMS += %D%/badsend +%C%_badsend_LDADD = \ + libzfs_core.la \ + libzfs.la \ + libnvpair.la + + +scripts_zfs_tests_bin_PROGRAMS += %D%/btree_test +%C%_btree_test_CPPFLAGS = $(AM_CPPFLAGS) $(FORCEDEBUG_CPPFLAGS) +%C%_btree_test_LDADD = \ + libzpool.la \ + libzfs_core.la + + +if WANT_DEVNAME2DEVID +scripts_zfs_tests_bin_PROGRAMS += %D%/devname2devid +%C%_devname2devid_CFLAGS = $(AM_CFLAGS) $(LIBUDEV_CFLAGS) +%C%_devname2devid_LDADD = $(LIBUDEV_LIBS) +endif + + +scripts_zfs_tests_bin_PROGRAMS += %D%/draid +%C%_draid_CFLAGS = $(AM_CFLAGS) $(ZLIB_CFLAGS) +%C%_draid_LDADD = \ + libzpool.la \ + libnvpair.la +%C%_draid_LDADD += $(ZLIB_LIBS) + +EXTRA_DIST += $(addprefix %D%/,file/file_common.h) +scripts_zfs_tests_bin_PROGRAMS += %D%/file_append %D%/file_check %D%/file_trunc %D%/file_write %D%/largest_file %D%/randwritecomp +%C%_file_append_SOURCES = %D%/file/file_append.c +%C%_file_check_SOURCES = %D%/file/file_check.c +%C%_file_trunc_SOURCES = %D%/file/file_trunc.c +%C%_file_write_SOURCES = %D%/file/file_write.c +%C%_largest_file_SOURCES = %D%/file/largest_file.c +%C%_randwritecomp_SOURCES = %D%/file/randwritecomp.c + + +scripts_zfs_tests_bin_PROGRAMS += %D%/libzfs_input_check +%C%_libzfs_input_check_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/include/os/@ac_system_l@/zfs +%C%_libzfs_input_check_LDADD = \ + libzfs_core.la \ + libnvpair.la + + +scripts_zfs_tests_bin_PROGRAMS += %D%/mkbusy %D%/mkfile %D%/mkfiles %D%/mktree +%C%_mkfile_LDADD = $(LTLIBINTL) + + +scripts_zfs_tests_bin_PROGRAMS += %D%/mmap_exec %D%/mmap_seek %D%/mmap_sync %D%/mmapwrite %D%/readmmap +%C%_mmapwrite_LDADD = -lpthread + +if WANT_MMAP_LIBAIO +scripts_zfs_tests_bin_PROGRAMS += %D%/mmap_libaio +%C%_mmap_libaio_CFLAGS = $(AM_CFLAGS) $(LIBAIO_CFLAGS) +%C%_mmap_libaio_LDADD = $(LIBAIO_LIBS) +endif + + +scripts_zfs_tests_bin_PROGRAMS += %D%/nvlist_to_lua +%C%_nvlist_to_lua_LDADD = \ + libzfs_core.la \ + libnvpair.la + +scripts_zfs_tests_bin_PROGRAMS += %D%/rm_lnkcnt_zero_file +%C%_rm_lnkcnt_zero_file_LDADD = -lpthread + +scripts_zfs_tests_bin_PROGRAMS += %D%/send_doall +%C%_send_doall_LDADD = \ + libzfs_core.la \ + libzfs.la \ + libnvpair.la + +scripts_zfs_tests_bin_PROGRAMS += %D%/stride_dd +%C%_stride_dd_LDADD = -lrt + +scripts_zfs_tests_bin_PROGRAMS += %D%/threadsappend +%C%_threadsappend_LDADD = -lpthread + +scripts_zfs_tests_bin_PROGRAMS += %D%/ereports +%C%_ereports_LDADD = \ + libnvpair.la \ + libzfs.la + + +scripts_zfs_tests_bin_PROGRAMS += %D%/edonr_test %D%/skein_test %D%/sha2_test +%C%_skein_test_SOURCES = %D%/checksum/skein_test.c +%C%_sha2_test_SOURCES = %D%/checksum/sha2_test.c +%C%_edonr_test_SOURCES = %D%/checksum/edonr_test.c +%C%_skein_test_LDADD = \ + libicp.la \ + libspl_assert.la +%C%_sha2_test_LDADD = $(%C%_skein_test_LDADD) +%C%_edonr_test_LDADD = $(%C%_skein_test_LDADD) -SUBDIRS = \ - badsend \ - btree_test \ - chg_usr_exec \ - devname2devid \ - dir_rd_update \ - draid \ - file_check \ - file_trunc \ - file_write \ - get_diff \ - largest_file \ - libzfs_input_check \ - mkbusy \ - mkfile \ - mkfiles \ - mktree \ - mmap_exec \ - mmap_libaio \ - mmap_seek \ - mmapwrite \ - nvlist_to_lua \ - randwritecomp \ - readmmap \ - rename_dir \ - rm_lnkcnt_zero_file \ - send_doall \ - stride_dd \ - threadsappend if BUILD_LINUX -SUBDIRS += \ - getversion \ - randfree_file \ - read_dos_attributes \ - user_ns_exec \ - write_dos_attributes \ - xattrtest +scripts_zfs_tests_bin_PROGRAMS += %D%/getversion +scripts_zfs_tests_bin_PROGRAMS += %D%/user_ns_exec +scripts_zfs_tests_bin_PROGRAMS += %D%/xattrtest +scripts_zfs_tests_bin_PROGRAMS += %D%/zed_fd_spill-zedlet + + +EXTRA_DIST += $(addprefix %D%/,linux_dos_attributes/dos_attributes.h) +scripts_zfs_tests_bin_PROGRAMS += %D%/read_dos_attributes %D%/write_dos_attributes +%C%_read_dos_attributes_SOURCES = %D%/linux_dos_attributes/read_dos_attributes.c +%C%_write_dos_attributes_SOURCES = %D%/linux_dos_attributes/write_dos_attributes.c + + +scripts_zfs_tests_bin_PROGRAMS += %D%/randfree_file +%C%_randfree_file_SOURCES = %D%/file/randfree_file.c endif diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/badsend/badsend.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/badsend.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/badsend/badsend.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/badsend.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/badsend/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/badsend/.gitignore deleted file mode 100644 index d2efa627aa29..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/badsend/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/badsend diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/badsend/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/badsend/Makefile.am deleted file mode 100644 index 5a8946f0d4bf..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/badsend/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = badsend - -badsend_SOURCES = badsend.c -badsend_LDADD = \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libzfs/libzfs.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/btree_test/btree_test.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/btree_test.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/btree_test/btree_test.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/btree_test.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/btree_test/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/btree_test/.gitignore deleted file mode 100644 index 73777c4c1f4b..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/btree_test/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/btree_test diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/btree_test/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/btree_test/Makefile.am deleted file mode 100644 index 4c9a1a4cc296..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/btree_test/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -# -# This file and its contents are supplied under the terms of the -# Common Development and Distribution License ("CDDL"), version 1.0. -# You may only use this file in accordance with the terms of version -# 1.0 of the CDDL. -# -# A full copy of the text of the CDDL should have accompanied this -# source. A copy of the CDDL is also available via the Internet at -# http://www.illumos.org/license/CDDL. -# - -# -# Copyright (c) 2019 by Delphix. All rights reserved. -# - -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -DEFAULT_INCLUDES += \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/lib/libspl/include - -# Unconditionally enable ASSERTs -AM_CPPFLAGS += -DDEBUG -UNDEBUG -DZFS_DEBUG - -pkgexec_PROGRAMS = btree_test -btree_test_SOURCES = btree_test.c - -btree_test_LDADD = \ - $(abs_top_builddir)/lib/libzpool/libzpool.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/edonr_test.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/checksum/edonr_test.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/edonr_test.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/checksum/edonr_test.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/sha2_test.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/checksum/sha2_test.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/sha2_test.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/checksum/sha2_test.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/skein_test.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/checksum/skein_test.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/skein_test.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/checksum/skein_test.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/chg_usr_exec/chg_usr_exec.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/chg_usr_exec.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/chg_usr_exec/chg_usr_exec.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/chg_usr_exec.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/chg_usr_exec/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/chg_usr_exec/.gitignore deleted file mode 100644 index a8b44df7c5bf..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/chg_usr_exec/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/chg_usr_exec diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/chg_usr_exec/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/chg_usr_exec/Makefile.am deleted file mode 100644 index 6f2968f1fac4..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/chg_usr_exec/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = chg_usr_exec -chg_usr_exec_SOURCES = chg_usr_exec.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cp_files/cp_files.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/cp_files.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/tests/functional/cp_files/cp_files.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/cp_files.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/ctime/ctime.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/ctime.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/tests/functional/ctime/ctime.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/ctime.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/devname2devid/devname2devid.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/devname2devid.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/devname2devid/devname2devid.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/devname2devid.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/devname2devid/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/devname2devid/.gitignore deleted file mode 100644 index fa9fb6c509a7..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/devname2devid/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/devname2devid diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/devname2devid/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/devname2devid/Makefile.am deleted file mode 100644 index b8b630dc2dd4..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/devname2devid/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -if WANT_DEVNAME2DEVID -pkgexec_PROGRAMS = devname2devid -devname2devid_SOURCES = devname2devid.c -devname2devid_CFLAGS = $(AM_CFLAGS) $(LIBUDEV_CFLAGS) -devname2devid_LDADD = $(LIBUDEV_LIBS) -endif diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/dir_rd_update/dir_rd_update.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/dir_rd_update.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/dir_rd_update/dir_rd_update.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/dir_rd_update.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/dir_rd_update/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/dir_rd_update/.gitignore deleted file mode 100644 index ec9a15f17a1d..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/dir_rd_update/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/dir_rd_update diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/dir_rd_update/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/dir_rd_update/Makefile.am deleted file mode 100644 index 27cc9e97e0e9..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/dir_rd_update/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = dir_rd_update -dir_rd_update_SOURCES = dir_rd_update.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/off/dosmode_readonly_write.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/dosmode_readonly_write.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/off/dosmode_readonly_write.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/dosmode_readonly_write.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/draid/draid.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/draid.c similarity index 99% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/draid/draid.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/draid.c index 6f4ecd5ef4c5..618cb9c4df52 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/draid/draid.c +++ b/sys/contrib/openzfs/tests/zfs-tests/cmd/draid.c @@ -1312,14 +1312,11 @@ static int draid_merge(int argc, char *argv[]) { char filename[MAXPATHLEN] = {0}; - int c, error, total_merged = 0, verbose = 0; + int c, error, total_merged = 0; nvlist_t *allcfgs; - while ((c = getopt(argc, argv, ":v")) != -1) { + while ((c = getopt(argc, argv, ":")) != -1) { switch (c) { - case 'v': - verbose++; - break; case ':': (void) fprintf(stderr, "missing argument for '%c' option\n", optopt); diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/draid/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/draid/.gitignore deleted file mode 100644 index 911b9f07785a..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/draid/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/draid diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/draid/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/draid/Makefile.am deleted file mode 100644 index 69fed7a6bea4..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/draid/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -AM_CFLAGS += $(ZLIB_CFLAGS) - -pkgexec_PROGRAMS = draid - -draid_SOURCES = draid.c - -draid_LDADD = \ - $(abs_top_builddir)/lib/libzpool/libzpool.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la - -draid_LDADD += $(ZLIB_LIBS) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/ereports.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/ereports.c similarity index 98% rename from sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/ereports.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/ereports.c index bff3bb1ee808..392f5952d27a 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/ereports.c +++ b/sys/contrib/openzfs/tests/zfs-tests/cmd/ereports.c @@ -42,7 +42,7 @@ * When the class and all of these values match, then an ereport is * considered to be a duplicate. */ -static const char *criteria_name[] = { +static const char *const criteria_name[] = { FM_EREPORT_PAYLOAD_ZFS_POOL, FM_EREPORT_PAYLOAD_ZFS_VDEV_GUID, FM_EREPORT_PAYLOAD_ZFS_ZIO_ERR, diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/file/file_append.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/file/file_append.c new file mode 100644 index 000000000000..32433e4fa2f6 --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/cmd/file/file_append.c @@ -0,0 +1,206 @@ +/* + * 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) 2022 by Triad National Security, LLC + */ + +#include "file_common.h" +#include +#include + +static char *filename = NULL; +static int expected_offset = -1; +static int blocksize = 131072; /* 128KiB */ +static int numblocks = 8; +static const char *execname = "file_append"; +static int use_odirect = 0; + +static void +usage(void) +{ + (void) fprintf(stderr, + "usage %s -f filename -e expected_offset [-b blocksize] \n" + " [-n numblocks] [-d use_odirect] [-h help]\n" + "\n" + "Opens a file using O_APPEND and writes numblocks blocksize\n" + "blocks to filename.\n" + "Checks if expected_offst == lseek(fd, 0, SEEK_CUR)).\n" + "\n" + " filename: File to open with O_APPEND and write to.\n" + " expected_offset: Expected file offset after writing\n" + " blocksize numblocks to filename\n" + " blocksize: Size of each block to writei (must be at\n" + " least >= 512). If using use_odirect (-d)\n" + " must be a mutltiple of _SC_PAGE_SIZE\n" + " numblocks: Total number of blocksized blocks to\n" + " write.\n" + " use_odirect: Open file using O_DIRECT.\n" + " help: Print usage information and exit.\n" + "\n" + " Required parameters:\n" + " filename\n" + " expected_offset\n" + "\n" + " Default values:\n" + " blocksize -> 131072 (128 KiB)\n" + " numblocks -> 8\n" + " use_odirect -> False\n", + execname); + (void) exit(1); +} + +static void +parse_options(int argc, char *argv[]) +{ + int c; + int errflag = 0; + extern char *optarg; + extern int optind, optopt; + + while ((c = getopt(argc, argv, "b:de:f:hn:")) != -1) { + switch (c) { + case 'b': + blocksize = atoi(optarg); + break; + case 'd': + use_odirect = 1; + break; + case 'e': + expected_offset = atoi(optarg); + break; + case 'f': + filename = optarg; + break; + case 'h': + (void) usage(); + break; + case 'n': + numblocks = atoi(optarg); + break; + case ':': + (void) fprintf(stderr, + "Option -%c requires an operand\n", + optopt); + errflag++; + break; + case '?': + default: + (void) fprintf(stderr, + "Unrecognized option: -%c\n", optopt); + errflag++; + break; + } + } + + if (errflag) + (void) usage(); + + if (use_odirect && ((blocksize % sysconf(_SC_PAGE_SIZE)) != 0)) { + (void) fprintf(stderr, + "blocksize parameter invalid when using O_DIRECT.\n"); + (void) usage(); + } + + if (blocksize < 512 || expected_offset < 0 || filename == NULL || + numblocks <= 0) { + (void) fprintf(stderr, + "Required parameters(s) missing or invalid value for " + "parameter.\n"); + (void) usage(); + } +} + +int +main(int argc, char *argv[]) +{ + int err; + const char *datapattern = "0xf00ba3"; + int fd = -1; + int fd_flags = O_WRONLY | O_CREAT | O_APPEND; + int buf_offset = 0; + char *buf; + + parse_options(argc, argv); + + if (use_odirect) + fd_flags |= O_DIRECT; + + fd = open(filename, fd_flags, 0666); + if (fd == -1) { + (void) fprintf(stderr, "%s: %s: ", execname, filename); + perror("open"); + (void) exit(2); + } + + err = posix_memalign((void **)&buf, sysconf(_SC_PAGE_SIZE), + blocksize); + + if (err != 0) { + (void) fprintf(stderr, + "%s: %s\n", execname, strerror(err)); + (void) exit(2); + } + + /* Putting known data pattern in buffer */ + int left = blocksize; + while (left) { + size_t amt = MIN(strlen(datapattern), left); + memcpy(&buf[buf_offset], datapattern, amt); + buf_offset += amt; + left -= amt; + } + + for (int i = 0; i < numblocks; i++) { + int wrote = write(fd, buf, blocksize); + + if (wrote != blocksize) { + if (wrote < 0) { + perror("write"); + } else { + (void) fprintf(stderr, + "%s: unexpected short write, wrote %d " + "byte, expected %d\n", execname, wrote, + blocksize); + } + (void) exit(2); + } + } + + /* Getting current file offset */ + off_t off = lseek(fd, 0, SEEK_CUR); + + if (off == -1) { + perror("output seek"); + (void) exit(2); + } else if (off != expected_offset) { + (void) fprintf(stderr, + "%s: expected offset %d but current offset in %s is set " + "to %ld\n", execname, expected_offset, filename, + (long int)off); + (void) exit(2); + } + + (void) close(fd); + free(buf); + + return (0); +} diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_check/file_check.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/file/file_check.c similarity index 98% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/file_check/file_check.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/file/file_check.c index 3d3db753f3d7..c93b56f45bba 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_check/file_check.c +++ b/sys/contrib/openzfs/tests/zfs-tests/cmd/file/file_check.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ -#include "../file_common.h" +#include "file_common.h" static unsigned char bigbuffer[BIGBUFFERSIZE]; diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_common.h b/sys/contrib/openzfs/tests/zfs-tests/cmd/file/file_common.h similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/file_common.h rename to sys/contrib/openzfs/tests/zfs-tests/cmd/file/file_common.h diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_trunc/file_trunc.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/file/file_trunc.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/file_trunc/file_trunc.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/file/file_trunc.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_write/file_write.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/file/file_write.c similarity index 98% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/file_write/file_write.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/file/file_write.c index 60893c34fbc9..8791c151f66f 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_write/file_write.c +++ b/sys/contrib/openzfs/tests/zfs-tests/cmd/file/file_write.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ -#include "../file_common.h" +#include "file_common.h" #include #include #include @@ -251,7 +251,7 @@ usage(char *prog) "\t[-s offset] [-c write_count] [-d data]\n\n" "Where [data] equal to zero causes chars " "0->%d to be repeated throughout, or [data]\n" - "equal to 'R' for psudorandom data.\n", + "equal to 'R' for pseudorandom data.\n", prog, DATA_RANGE); exit(1); diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/largest_file/largest_file.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/file/largest_file.c similarity index 99% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/largest_file/largest_file.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/file/largest_file.c index 912607640965..5acb5f1db87d 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/largest_file/largest_file.c +++ b/sys/contrib/openzfs/tests/zfs-tests/cmd/file/largest_file.c @@ -28,7 +28,7 @@ * Copyright (c) 2012 by Delphix. All rights reserved. */ -#include "../file_common.h" +#include "file_common.h" #include #include #include diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/randfree_file/randfree_file.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/file/randfree_file.c similarity index 99% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/randfree_file/randfree_file.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/file/randfree_file.c index c708d647e8b9..e00780cd2e81 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/randfree_file/randfree_file.c +++ b/sys/contrib/openzfs/tests/zfs-tests/cmd/file/randfree_file.c @@ -28,7 +28,7 @@ * Copyright (c) 2012 by Delphix. All rights reserved. */ -#include "../file_common.h" +#include "file_common.h" #include #include #include diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/randwritecomp/randwritecomp.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/file/randwritecomp.c similarity index 99% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/randwritecomp/randwritecomp.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/file/randwritecomp.c index 3cff7fd0a01e..cc70d1212f84 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/randwritecomp/randwritecomp.c +++ b/sys/contrib/openzfs/tests/zfs-tests/cmd/file/randwritecomp.c @@ -15,7 +15,7 @@ #include #include -#include "../file_common.h" +#include "file_common.h" /* * The following sample was derived from real-world data diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_check/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/file_check/.gitignore deleted file mode 100644 index 24fe113221d2..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_check/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/file_check diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_check/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/file_check/Makefile.am deleted file mode 100644 index 13027ef5bd02..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_check/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = file_check -file_check_SOURCES = file_check.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_trunc/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/file_trunc/.gitignore deleted file mode 100644 index 90b149ff51c3..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_trunc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/file_trunc diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_trunc/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/file_trunc/Makefile.am deleted file mode 100644 index 0455eb4a4633..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_trunc/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = file_trunc -file_trunc_SOURCES = file_trunc.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_write/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/file_write/.gitignore deleted file mode 100644 index 9f691d580a57..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_write/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/file_write diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_write/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/file_write/Makefile.am deleted file mode 100644 index 60895711e7dc..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/file_write/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = file_write -file_write_SOURCES = file_write.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/get_diff/get_diff.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/get_diff.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/get_diff/get_diff.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/get_diff.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/get_diff/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/get_diff/.gitignore deleted file mode 100644 index f5fc360a6839..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/get_diff/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/get_diff diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/get_diff/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/get_diff/Makefile.am deleted file mode 100644 index 06c39ddd81ce..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/get_diff/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = get_diff -get_diff_SOURCES = get_diff.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/getversion/getversion.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/getversion.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/getversion/getversion.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/getversion.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/getversion/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/getversion/.gitignore deleted file mode 100644 index b347c417aa13..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/getversion/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/getversion diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/getversion/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/getversion/Makefile.am deleted file mode 100644 index d6b5e84082b2..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/getversion/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = getversion -getversion_SOURCES = getversion.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/largest_file/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/largest_file/.gitignore deleted file mode 100644 index f8f480d06542..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/largest_file/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/largest_file diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/largest_file/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/largest_file/Makefile.am deleted file mode 100644 index a3e4e9337cf0..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/largest_file/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = largest_file -largest_file_SOURCES = largest_file.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/libzfs_input_check.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/libzfs_input_check.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/libzfs_input_check/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/libzfs_input_check/.gitignore deleted file mode 100644 index c8796008483f..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/libzfs_input_check/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/libzfs_input_check diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/libzfs_input_check/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/libzfs_input_check/Makefile.am deleted file mode 100644 index cd462208957c..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/libzfs_input_check/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = libzfs_input_check - -if BUILD_FREEBSD -DEFAULT_INCLUDES += -I$(top_srcdir)/include/os/freebsd/zfs -endif -if BUILD_LINUX -DEFAULT_INCLUDES += -I$(top_srcdir)/include/os/linux/zfs -endif - -libzfs_input_check_SOURCES = libzfs_input_check.c -libzfs_input_check_LDADD = \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/linux_dos_attributes/dos_attributes.h b/sys/contrib/openzfs/tests/zfs-tests/cmd/linux_dos_attributes/dos_attributes.h new file mode 100644 index 000000000000..dd3a820ff20c --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/cmd/linux_dos_attributes/dos_attributes.h @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: 0BSD + +#include + + +#define U_APPEND_SHORT "uappnd" +#define U_APPEND_FULL "uappend" +#define SU_APPEND_SHORT "sappnd" +#define SU_APPEND_FULL "sappend" + +#define U_ARCH_SHORT "uarch" +#define U_ARCH_FULL "uarchive" +#define SU_ARCH_SHORT "arch" +#define SU_ARCH_FULL "archived" + +#define U_HIDDEN_SHORT "hidden" +#define U_HIDDEN_FULL "uhidden" + +#define SU_IMMUTABLE_FULL "simmutable" +#define SU_IMMUTABLE_SHORT "schange" +#define SU_IMMUTABLE "schg" +#define U_IMMUTABLE_FULL "uimmutable" +#define U_IMMUTABLE_SHORT "uchange" +#define U_IMMUTABLE "uchg" + +#define SU_NODUMP "nodump" +#define UNSET_NODUMP "dump" + +#define U_UNLINK_SHORT "uunlnk" +#define U_UNLINK_FULL "uunlink" +#define SU_UNLINK_SHORT "sunlnk" +#define SU_UNLINK_FULL "sunlink" + +#define U_OFFLINE_SHORT "offline" +#define U_OFFLINE_FULL "uoffline" + +#define U_RDONLY "rdonly" +#define U_RDONLY_SHORT "urdonly" +#define U_RDONLY_FULL "readonly" + +#define U_REPARSE_SHORT "reparse" +#define U_REPARSE_FULL "ureparse" + +#define U_SPARSE_SHORT "sparse" +#define U_SPARSE_FULL "usparse" + +#define U_SYSTEM_SHORT "system" +#define U_SYSTEM_FULL "usystem" + + +static const uint64_t all_dos_attributes[] = { + ZFS_ARCHIVE, + ZFS_APPENDONLY, + ZFS_IMMUTABLE, + ZFS_NOUNLINK, + ZFS_NODUMP, + ZFS_HIDDEN, + ZFS_OFFLINE, + ZFS_READONLY, + ZFS_SPARSE, + ZFS_SYSTEM, + ZFS_REPARSE, +}; + +static const char *const all_dos_attribute_names[][7] = { + {U_ARCH_SHORT, U_ARCH_FULL, SU_ARCH_SHORT, SU_ARCH_FULL}, + {U_APPEND_SHORT, U_APPEND_FULL, SU_APPEND_SHORT, SU_APPEND_FULL}, + {SU_IMMUTABLE_FULL, SU_IMMUTABLE_SHORT, SU_IMMUTABLE, + U_IMMUTABLE_FULL, U_IMMUTABLE_SHORT, U_IMMUTABLE}, + {U_UNLINK_SHORT, U_UNLINK_FULL, SU_UNLINK_FULL, SU_UNLINK_SHORT}, + {SU_NODUMP, /* UNSET_NODUMP */}, + {U_HIDDEN_SHORT, U_HIDDEN_FULL}, + {U_OFFLINE_SHORT, U_OFFLINE_FULL}, + {U_RDONLY, U_RDONLY_SHORT, U_RDONLY_FULL}, + {U_SPARSE_SHORT, U_SPARSE_FULL}, + {U_SYSTEM_SHORT, U_SYSTEM_FULL}, + {U_REPARSE_SHORT, U_REPARSE_FULL}, +}; + +_Static_assert( + ARRAY_SIZE(all_dos_attributes) == ARRAY_SIZE(all_dos_attribute_names), + "attribute list length mismatch"); diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/linux_dos_attributes/read_dos_attributes.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/linux_dos_attributes/read_dos_attributes.c new file mode 100644 index 000000000000..07821140512e --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/cmd/linux_dos_attributes/read_dos_attributes.c @@ -0,0 +1,60 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2022 iXsystems, Inc. + */ + +/* + * FreeBSD exposes additional file attributes via ls -o and chflags. + * Under Linux, we provide ZFS_IOC_[GS]ETDOSFLAGS ioctl()s. + * + * This application is the equivalent to FreeBSD ls -lo $1 | awk '{print $5}'. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "dos_attributes.h" + +int +main(int argc, const char *const *argv) +{ + if (argc != 2) + errx(EXIT_FAILURE, "usage: %s file", argv[0]); + + int fd = open(argv[1], O_RDONLY | O_CLOEXEC); + if (fd == -1) + err(EXIT_FAILURE, "%s", argv[1]); + + uint64_t flags; + if (ioctl(fd, ZFS_IOC_GETDOSFLAGS, &flags) == -1) + err(EXIT_FAILURE, "ZFS_IOC_GETDOSFLAGS"); + + bool any = false; + for (size_t i = 0; i < ARRAY_SIZE(all_dos_attributes); ++i) + if (flags & all_dos_attributes[i]) { + if (any) + putchar(','); + (void) fputs(*all_dos_attribute_names[i], stdout); + any = true; + } + if (any) + (void) putchar('\n'); + else + (void) puts("-"); +} diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/linux_dos_attributes/write_dos_attributes.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/linux_dos_attributes/write_dos_attributes.c new file mode 100644 index 000000000000..3cea7d4b1c7d --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/cmd/linux_dos_attributes/write_dos_attributes.c @@ -0,0 +1,95 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2022 iXsystems, Inc. + */ + +/* + * FreeBSD exposes additional file attributes via ls -o and chflags. + * Under Linux, we provide ZFS_IOC_[GS]ETDOSFLAGS ioctl()s. + * + * This application is equivalent to FreeBSD chflags. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "dos_attributes.h" + +int +main(int argc, const char *const *argv) +{ + if (argc != 3) + errx(EXIT_FAILURE, "usage: %s flag file", argv[0]); + + bool unset = false; + uint64_t attr = 0; + const char *flag = argv[1]; + if (strcmp(flag, "0") == 0) + ; + else if (strcmp(flag, SU_NODUMP) == 0) + attr = ZFS_NODUMP; + else if (strcmp(flag, UNSET_NODUMP) == 0) { + attr = ZFS_NODUMP; + unset = true; + } else { + if (strncmp(flag, "no", 2) == 0) { + unset = true; + flag += 2; + } + for (size_t i = 0; i < ARRAY_SIZE(all_dos_attribute_names); ++i) + for (const char *const *nm = all_dos_attribute_names[i]; + *nm; ++nm) + if (strcmp(flag, *nm) == 0) { + attr = all_dos_attributes[i]; + goto found; + } + + errx(EXIT_FAILURE, "%s: unknown flag", argv[1]); +found:; + } + + int fd = open(argv[2], O_RDWR | O_APPEND | O_CLOEXEC); + if (fd == -1) + err(EXIT_FAILURE, "%s", argv[2]); + + uint64_t flags; + if (ioctl(fd, ZFS_IOC_GETDOSFLAGS, &flags) == -1) + err(EXIT_FAILURE, "ZFS_IOC_GETDOSFLAGS"); + + if (attr == 0) + flags = 0; + else if (unset) + flags &= ~attr; + else + flags |= attr; + + if (ioctl(fd, ZFS_IOC_SETDOSFLAGS, &flags) == -1) + err(EXIT_FAILURE, "ZFS_IOC_SETDOSFLAGS"); + + uint64_t newflags; + if (ioctl(fd, ZFS_IOC_GETDOSFLAGS, &newflags) == -1) + err(EXIT_FAILURE, "second ZFS_IOC_GETDOSFLAGS"); + + if (newflags != flags) + errx(EXIT_FAILURE, "expecting %#" PRIx64 ", got %#" PRIx64 + "; %ssetting %#" PRIx64 "", + flags, newflags, unset ? "un" : "", attr); + + (void) printf("%#" PRIx64 "\n", flags); +} diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mkbusy/mkbusy.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/mkbusy.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/mkbusy/mkbusy.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/mkbusy.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mkbusy/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/mkbusy/.gitignore deleted file mode 100644 index 18d099c08eec..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/mkbusy/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mkbusy diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mkbusy/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/mkbusy/Makefile.am deleted file mode 100644 index abae69dea8c7..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/mkbusy/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = mkbusy -mkbusy_SOURCES = mkbusy.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mkfile/mkfile.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/mkfile.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/mkfile/mkfile.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/mkfile.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mkfile/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/mkfile/.gitignore deleted file mode 100644 index 93e9a8a6ded4..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/mkfile/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mkfile diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mkfile/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/mkfile/Makefile.am deleted file mode 100644 index 5f0e2e03efd9..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/mkfile/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = mkfile -mkfile_SOURCES = mkfile.c - -mkfile_LDADD = $(LTLIBINTL) diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mkfiles/mkfiles.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/mkfiles.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/mkfiles/mkfiles.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/mkfiles.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mkfiles/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/mkfiles/.gitignore deleted file mode 100644 index cee4858b701b..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/mkfiles/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mkfiles diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mkfiles/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/mkfiles/Makefile.am deleted file mode 100644 index 54c21597f3eb..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/mkfiles/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = mkfiles -mkfiles_SOURCES = mkfiles.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mktree/mktree.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/mktree.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/mktree/mktree.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/mktree.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mktree/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/mktree/.gitignore deleted file mode 100644 index 588bc6d1cce6..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/mktree/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mktree diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mktree/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/mktree/Makefile.am deleted file mode 100644 index 88c74ae0a346..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/mktree/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = mktree -mktree_SOURCES = mktree.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_exec/mmap_exec.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_exec.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_exec/mmap_exec.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_exec.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_exec/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_exec/.gitignore deleted file mode 100644 index 63a68bbc681e..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_exec/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mmap_exec diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_exec/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_exec/Makefile.am deleted file mode 100644 index ab9f81be9463..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_exec/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = mmap_exec -mmap_exec_SOURCES = mmap_exec.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_libaio/mmap_libaio.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_libaio.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_libaio/mmap_libaio.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_libaio.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_libaio/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_libaio/.gitignore deleted file mode 100644 index 792c8d3400b0..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_libaio/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mmap_libaio diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_libaio/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_libaio/Makefile.am deleted file mode 100644 index 25f9dda2b623..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_libaio/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -if WANT_MMAP_LIBAIO -pkgexec_PROGRAMS = mmap_libaio -mmap_libaio_SOURCES = mmap_libaio.c -mmap_libaio_CFLAGS = $(AM_CFLAGS) $(LIBAIO_CFLAGS) -mmap_libaio_LDADD = $(LIBAIO_LIBS) -endif diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_seek/mmap_seek.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_seek.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_seek/mmap_seek.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_seek.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_seek/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_seek/.gitignore deleted file mode 100644 index 6b05a7917500..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_seek/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mmap_seek diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_seek/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_seek/Makefile.am deleted file mode 100644 index b938931125f5..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_seek/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -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/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_sync.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_sync.c new file mode 100644 index 000000000000..0e4bba37d7be --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/cmd/mmap_sync.c @@ -0,0 +1,152 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://opensource.org/licenses/CDDL-1.0. + * 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 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void +cleanup(char *file) +{ + remove(file); +} + +int +main(int argc, char *argv[]) +{ + char *testdir = getenv("TESTDIR"); + if (!testdir) { + fprintf(stderr, "environment variable TESTDIR not set\n"); + return (1); + } + + struct stat st; + umask(0); + if (stat(testdir, &st) != 0 && + mkdir(testdir, 0777) != 0) { + perror("mkdir"); + return (1); + } + + if (argc > 3) { + fprintf(stderr, "usage: %s " + "[run time in mins] " + "[max msync time in ms]\n", argv[0]); + return (1); + } + + int run_time_mins = 5; + if (argc >= 2) { + run_time_mins = atoi(argv[1]); + } + + int max_msync_time_ms = 1000; + if (argc >= 3) { + max_msync_time_ms = atoi(argv[2]); + } + + char filepath[512]; + filepath[0] = '\0'; + char *file = &filepath[0]; + + strcat(file, testdir); + strcat(file, "/msync_file"); + + const int LEN = 8; + cleanup(file); + + int fd = open(file, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | + S_IRGRP | S_IROTH); + + if (fd == -1) { + (void) fprintf(stderr, "%s: %s: ", argv[0], file); + perror("open"); + return (1); + } + + if (ftruncate(fd, LEN) != 0) { + perror("ftruncate"); + cleanup(file); + return (1); + } + + void *ptr = mmap(NULL, LEN, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + + if (ptr == MAP_FAILED) { + perror("mmap"); + cleanup(file); + return (1); + } + + struct timeval tstart; + gettimeofday(&tstart, NULL); + + long long x = 0LL; + + for (;;) { + *((long long *)ptr) = x; + x++; + + struct timeval t1, t2; + gettimeofday(&t1, NULL); + if (msync(ptr, LEN, MS_SYNC|MS_INVALIDATE) != 0) { + perror("msync"); + cleanup(file); + return (1); + } + + gettimeofday(&t2, NULL); + + double elapsed = (t2.tv_sec - t1.tv_sec) * 1000.0; + elapsed += ((t2.tv_usec - t1.tv_usec) / 1000.0); + if (elapsed > max_msync_time_ms) { + fprintf(stderr, "slow msync: %f ms\n", elapsed); + munmap(ptr, LEN); + cleanup(file); + return (1); + } + + double elapsed_start = (t2.tv_sec - tstart.tv_sec) * 1000.0; + elapsed_start += ((t2.tv_usec - tstart.tv_usec) / 1000.0); + if (elapsed_start > run_time_mins * 60 * 1000) { + break; + } + } + + if (munmap(ptr, LEN) != 0) { + perror("munmap"); + cleanup(file); + return (1); + } + + if (close(fd) != 0) { + perror("close"); + } + + cleanup(file); + return (0); +} diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmapwrite/mmapwrite.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/mmapwrite.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/mmapwrite/mmapwrite.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/mmapwrite.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmapwrite/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/mmapwrite/.gitignore deleted file mode 100644 index 4e7043bbfd58..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmapwrite/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mmapwrite diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmapwrite/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/mmapwrite/Makefile.am deleted file mode 100644 index b21b9e779bf2..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/mmapwrite/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = mmapwrite -mmapwrite_SOURCES = mmapwrite.c -mmapwrite_LDADD = -lpthread diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/nvlist_to_lua/nvlist_to_lua.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/nvlist_to_lua.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/nvlist_to_lua/nvlist_to_lua.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/nvlist_to_lua.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/nvlist_to_lua/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/nvlist_to_lua/.gitignore deleted file mode 100644 index b31db6454dce..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/nvlist_to_lua/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/nvlist_to_lua diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/nvlist_to_lua/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/nvlist_to_lua/Makefile.am deleted file mode 100644 index 511b6c6913bb..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/nvlist_to_lua/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = nvlist_to_lua - -nvlist_to_lua_SOURCES = nvlist_to_lua.c -nvlist_to_lua_LDADD = \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/randfree_file/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/randfree_file/.gitignore deleted file mode 100644 index 0f5b394c5fbd..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/randfree_file/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/randfree_file diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/randfree_file/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/randfree_file/Makefile.am deleted file mode 100644 index 6306e0e75740..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/randfree_file/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = randfree_file -randfree_file_SOURCES = randfree_file.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/randwritecomp/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/randwritecomp/.gitignore deleted file mode 100644 index fb231c678cb2..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/randwritecomp/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/randwritecomp diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/randwritecomp/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/randwritecomp/Makefile.am deleted file mode 100644 index 0002291fa7bf..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/randwritecomp/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -DEFAULT_INCLUDES += \ - -I$(top_srcdir)/include - -pkgexec_PROGRAMS = randwritecomp -randwritecomp_SOURCES = randwritecomp.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/read_dos_attributes/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/read_dos_attributes/.gitignore deleted file mode 100644 index 52584e4a738b..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/read_dos_attributes/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/read_dos_attributes diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/read_dos_attributes/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/read_dos_attributes/Makefile.am deleted file mode 100644 index 69412f05f650..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/read_dos_attributes/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = read_dos_attributes -read_dos_attributes_SOURCES = read_dos_attributes.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/read_dos_attributes/read_dos_attributes.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/read_dos_attributes/read_dos_attributes.c deleted file mode 100644 index ed0906c36a6f..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/read_dos_attributes/read_dos_attributes.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * This file and its contents are supplied under the terms of the - * Common Development and Distribution License ("CDDL"), version 1.0. - * You may only use this file in accordance with the terms of version - * 1.0 of the CDDL. - * - * A full copy of the text of the CDDL should have accompanied this - * source. A copy of the CDDL is also available via the Internet at - * http://www.illumos.org/license/CDDL. - */ - -/* - * Copyright 2022 iXsystems, Inc. - */ - -/* - * FreeBSD allows to update and retreive additional file level attributes. - * For Linux, two IOCTLs have been added to update and retrieve additional - * level attributes. - * - * This application reads additional file level attributes on a given - * file and prints FreeBSD keywords that map to respective attributes. - * - * Usage: 'read_dos_attributes filepath' - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SU_ARCH_SHORT "arch" -#define SU_ARCH_FULL "archived" -#define SU_NODUMP "nodump" -#define SU_APPEND_SHORT "sappnd" -#define SU_APPEND_FULL "sappend" -#define SU_IMMUTABLE "schg" -#define SU_IMMUTABLE_SHORT "schange" -#define SU_IMMUTABLE_FULL "simmutable" -#define SU_UNLINK_SHORT "sunlnk" -#define SU_UNLINK_FULL "sunlink" -#define U_APPEND_SHORT "uappnd" -#define U_APPEND_FULL "uappend" -#define U_ARCH_SHORT "uarch" -#define U_ARCH_FULL "uarchive" -#define U_IMMUTABLE "uchg" -#define U_IMMUTABLE_SHORT "uchange" -#define U_IMMUTABLE_FULL "uimmutable" -#define U_HIDDEN_SHORT "hidden" -#define U_HIDDEN_FULL "uhidden" -#define U_OFFLINE_SHORT "offline" -#define U_OFFLINE_FULL "uoffline" -#define U_RDONLY "rdonly" -#define U_RDONLY_SHORT "urdonly" -#define U_RDONLY_FULL "readonly" -#define U_SPARSE_SHORT "sparse" -#define U_SPARSE_FULL "usparse" -#define U_SYSTEM_SHORT "system" -#define U_SYSTEM_FULL "usystem" -#define U_REPARSE_SHORT "reparse" -#define U_REPARSE_FULL "ureparse" -#define U_UNLINK_SHORT "uunlnk" -#define U_UNLINK_FULL "uunlink" -#define UNSET_NODUMP "dump" - -#define NO_ATTRIBUTE "-" - -#define SEPARATOR "," - -#define BUFFER_SIZE 0x200 - -void attribute_to_str(uint64_t attributes, char *buff); - -void -attribute_to_str(uint64_t attributes, char *buff) -{ - if (attributes & ZFS_ARCHIVE) { - strcat(buff, U_ARCH_SHORT); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_APPENDONLY) { - strcat(buff, U_APPEND_SHORT); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_IMMUTABLE) { - strcat(buff, U_IMMUTABLE_FULL); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_NOUNLINK) { - strcat(buff, U_UNLINK_SHORT); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_NODUMP) { - strcat(buff, SU_NODUMP); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_HIDDEN) { - strcat(buff, U_HIDDEN_SHORT); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_OFFLINE) { - strcat(buff, U_OFFLINE_SHORT); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_READONLY) { - strcat(buff, U_RDONLY); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_SPARSE) { - strcat(buff, U_SPARSE_SHORT); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_SYSTEM) { - strcat(buff, U_SYSTEM_SHORT); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_REPARSE) { - strcat(buff, U_REPARSE_SHORT); - strcat(buff, SEPARATOR); - } - - if (buff[0] == '\0') - strcat(buff, NO_ATTRIBUTE); - else - buff[strlen(buff) - 1] = '\0'; -} - -int -main(int argc, const char * const argv[]) -{ - if (argc != 2) - errx(EXIT_FAILURE, "Usage: %s filepath", argv[0]); - - int fd = open(argv[1], O_RDWR | O_APPEND); - if (fd < 0) - err(EXIT_FAILURE, "Failed to open %s", argv[1]); - - uint64_t dosflags = 0; - if (ioctl(fd, ZFS_IOC_GETDOSFLAGS, &dosflags) == -1) - err(EXIT_FAILURE, "ZFS_IOC_GETDOSFLAGS failed"); - - (void) close(fd); - - char buffer[BUFFER_SIZE]; - memset(buffer, 0, BUFFER_SIZE); - - (void) attribute_to_str(dosflags, buffer); - - (void) printf("%s\n", buffer); - - return (EXIT_SUCCESS); -} diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/readmmap/readmmap.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/readmmap.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/readmmap/readmmap.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/readmmap.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/readmmap/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/readmmap/.gitignore deleted file mode 100644 index 3799193a92be..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/readmmap/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/readmmap diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/readmmap/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/readmmap/Makefile.am deleted file mode 100644 index 9b735c287e69..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/readmmap/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = readmmap -readmmap_SOURCES = readmmap.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/rename_dir/rename_dir.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/rename_dir.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/rename_dir/rename_dir.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/rename_dir.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/rename_dir/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/rename_dir/.gitignore deleted file mode 100644 index 39a0cb222ad1..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/rename_dir/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/rename_dir diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/rename_dir/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/rename_dir/Makefile.am deleted file mode 100644 index 21971cd888fb..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/rename_dir/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = rename_dir -rename_dir_SOURCES = rename_dir.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/rm_lnkcnt_zero_file.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/rm_lnkcnt_zero_file.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/rm_lnkcnt_zero_file.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/rm_lnkcnt_zero_file.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/.gitignore deleted file mode 100644 index fc6323fb3ff3..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/rm_lnkcnt_zero_file diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/Makefile.am deleted file mode 100644 index 90fc8d0541b6..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = rm_lnkcnt_zero_file -rm_lnkcnt_zero_file_SOURCES = rm_lnkcnt_zero_file.c -rm_lnkcnt_zero_file_LDADD = -lpthread diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/send_doall/send_doall.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/send_doall.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/send_doall/send_doall.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/send_doall.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/send_doall/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/send_doall/.gitignore deleted file mode 100644 index 6ba2e603f744..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/send_doall/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/send_doall diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/send_doall/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/send_doall/Makefile.am deleted file mode 100644 index 33a6b83122b8..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/send_doall/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = send_doall - -send_doall_SOURCES = send_doall.c -send_doall_LDADD = \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libzfs/libzfs.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/stride_dd/stride_dd.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/stride_dd.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/stride_dd/stride_dd.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/stride_dd.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/stride_dd/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/stride_dd/.gitignore deleted file mode 100644 index 7c072ee0dec6..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/stride_dd/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/stride_dd diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/stride_dd/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/stride_dd/Makefile.am deleted file mode 100644 index d6f1adbac2b7..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/stride_dd/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = stride_dd -stride_dd_SOURCES = stride_dd.c -stride_dd_LDADD = -lrt diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_file.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/suid_write_to_file.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_file.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/suid_write_to_file.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/threadsappend/threadsappend.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/threadsappend.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/threadsappend/threadsappend.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/threadsappend.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/threadsappend/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/threadsappend/.gitignore deleted file mode 100644 index 4c8c8cdf34c1..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/threadsappend/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/threadsappend diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/threadsappend/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/threadsappend/Makefile.am deleted file mode 100644 index f030b42d50fe..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/threadsappend/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = threadsappend -threadsappend_SOURCES = threadsappend.c -threadsappend_LDADD = -lpthread diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/truncate/truncate_test.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/truncate_test.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/tests/functional/truncate/truncate_test.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/truncate_test.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/user_ns_exec/user_ns_exec.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/user_ns_exec.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/user_ns_exec/user_ns_exec.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/user_ns_exec.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/user_ns_exec/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/user_ns_exec/.gitignore deleted file mode 100644 index 655867a640a3..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/user_ns_exec/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/user_ns_exec diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/user_ns_exec/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/user_ns_exec/Makefile.am deleted file mode 100644 index 5b4bc9aaa683..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/user_ns_exec/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = user_ns_exec -user_ns_exec_SOURCES = user_ns_exec.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/write_dos_attributes/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/write_dos_attributes/.gitignore deleted file mode 100644 index f3949ac82822..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/write_dos_attributes/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/write_dos_attributes diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/write_dos_attributes/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/write_dos_attributes/Makefile.am deleted file mode 100644 index c297fd49e0e9..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/write_dos_attributes/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = write_dos_attributes -write_dos_attributes_SOURCES = write_dos_attributes.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/write_dos_attributes/write_dos_attributes.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/write_dos_attributes/write_dos_attributes.c deleted file mode 100644 index c373d3b15318..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/write_dos_attributes/write_dos_attributes.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * This file and its contents are supplied under the terms of the - * Common Development and Distribution License ("CDDL"), version 1.0. - * You may only use this file in accordance with the terms of version - * 1.0 of the CDDL. - * - * A full copy of the text of the CDDL should have accompanied this - * source. A copy of the CDDL is also available via the Internet at - * http://www.illumos.org/license/CDDL. - */ - -/* - * Copyright 2022 iXsystems, Inc. - */ - -/* - * FreeBSD allows to update and retreive additional file level attributes. - * For Linux, two IOCTLs have been added to update and retrieve additional - * level attributes. - * - * This application updates additional file level attributes on a given - * file. FreeBSD keywords can be used to specify the flag. - * - * Usage: 'write_dos_attributes flag filepath' - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SU_ARCH_SHORT "arch" -#define SU_ARCH_FULL "archived" -#define SU_NODUMP "nodump" -#define SU_APPEND_SHORT "sappnd" -#define SU_APPEND_FULL "sappend" -#define SU_IMMUTABLE "schg" -#define SU_IMMUTABLE_SHORT "schange" -#define SU_IMMUTABLE_FULL "simmutable" -#define SU_UNLINK_SHORT "sunlnk" -#define SU_UNLINK_FULL "sunlink" -#define U_APPEND_SHORT "uappnd" -#define U_APPEND_FULL "uappend" -#define U_ARCH_SHORT "uarch" -#define U_ARCH_FULL "uarchive" -#define U_IMMUTABLE "uchg" -#define U_IMMUTABLE_SHORT "uchange" -#define U_IMMUTABLE_FULL "uimmutable" -#define U_HIDDEN_SHORT "hidden" -#define U_HIDDEN_FULL "uhidden" -#define U_OFFLINE_SHORT "offline" -#define U_OFFLINE_FULL "uoffline" -#define U_RDONLY "rdonly" -#define U_RDONLY_SHORT "urdonly" -#define U_RDONLY_FULL "readonly" -#define U_SPARSE_SHORT "sparse" -#define U_SPARSE_FULL "usparse" -#define U_SYSTEM_SHORT "system" -#define U_SYSTEM_FULL "usystem" -#define U_REPARSE_SHORT "reparse" -#define U_REPARSE_FULL "ureparse" -#define U_UNLINK_SHORT "uunlnk" -#define U_UNLINK_FULL "uunlink" -#define UNSET_NODUMP "dump" - -#define IS_NO(s) (s[0] == 'n' && s[1] == 'o') - -uint64_t str_to_attribute(char *str); - -uint64_t -str_to_attribute(char *str) -{ - if ((strcmp(str, SU_ARCH_SHORT) == 0) || - (strcmp(str, SU_ARCH_FULL) == 0) || - (strcmp(str, U_ARCH_SHORT) == 0) || - (strcmp(str, U_ARCH_FULL) == 0)) - return (ZFS_ARCHIVE); - - else if ((strcmp(str, SU_APPEND_SHORT) == 0) || - (strcmp(str, SU_APPEND_FULL) == 0) || - (strcmp(str, U_APPEND_SHORT) == 0) || - (strcmp(str, U_APPEND_FULL) == 0)) - return (ZFS_APPENDONLY); - - else if ((strcmp(str, SU_IMMUTABLE) == 0) || - (strcmp(str, SU_IMMUTABLE_SHORT) == 0) || - (strcmp(str, SU_IMMUTABLE_FULL) == 0)) - return (ZFS_IMMUTABLE); - - else if ((strcmp(str, SU_UNLINK_SHORT) == 0) || - (strcmp(str, SU_UNLINK_FULL) == 0) || - (strcmp(str, U_UNLINK_SHORT) == 0) || - (strcmp(str, SU_UNLINK_FULL) == 0)) - return (ZFS_NOUNLINK); - - else if ((strcmp(str, U_HIDDEN_SHORT) == 0) || - (strcmp(str, U_HIDDEN_FULL) == 0)) - return (ZFS_HIDDEN); - - else if ((strcmp(str, U_OFFLINE_SHORT) == 0) || - (strcmp(str, U_OFFLINE_FULL) == 0)) - return (ZFS_OFFLINE); - - else if ((strcmp(str, U_RDONLY) == 0) || - (strcmp(str, U_RDONLY_SHORT) == 0) || - (strcmp(str, U_RDONLY_FULL) == 0)) - return (ZFS_READONLY); - - else if ((strcmp(str, U_SPARSE_SHORT) == 0) || - (strcmp(str, U_SPARSE_FULL) == 0)) - return (ZFS_SPARSE); - - else if ((strcmp(str, U_SYSTEM_SHORT) == 0) || - (strcmp(str, U_SYSTEM_FULL) == 0)) - return (ZFS_SYSTEM); - - else if ((strcmp(str, U_REPARSE_SHORT) == 0) || - (strcmp(str, U_REPARSE_FULL) == 0)) - return (ZFS_REPARSE); - - return (-1); -} - -int -main(int argc, const char * const argv[]) -{ - if (argc != 3) - errx(EXIT_FAILURE, "Usage: %s flag filepath", argv[0]); - - uint8_t unset, unset_all; - uint64_t attribute, dosflags; - char *flag = strdup(argv[1]); - unset = unset_all = 0; - attribute = dosflags = 0; - - // convert the flag to lower case - for (int i = 0; i < strlen(argv[1]); ++i) - flag[i] = tolower((unsigned char) flag[i]); - - // check if flag starts with 'no' - if (IS_NO(flag)) { - if (strcmp(flag, SU_NODUMP) == 0) { - attribute = ZFS_NODUMP; - } else { - attribute = str_to_attribute(flag + 2); - unset = 1; - } - } - // check if '0' was passed - else if (strcmp(flag, "0") == 0) { - unset_all = 1; - } - // check if the flag is 'dump' - else if (strcmp(flag, UNSET_NODUMP) == 0) { - attribute = ZFS_NODUMP; - unset = 1; - } else { - attribute = str_to_attribute(flag); - } - - if (attribute == -1) - errx(EXIT_FAILURE, "Invalid Flag %s", argv[1]); - - int fd = open(argv[2], O_RDWR | O_APPEND); - if (fd < 0) - err(EXIT_FAILURE, "Failed to open %s", argv[2]); - - if (ioctl(fd, ZFS_IOC_GETDOSFLAGS, &dosflags) == -1) - err(EXIT_FAILURE, "ZFS_IOC_GETDOSFLAGS failed"); - - if (unset == 0 && attribute != 0) - attribute |= dosflags; - else if (unset == 1 && attribute != 0) - attribute = dosflags & (~attribute); - else if (unset_all == 1) - attribute = 0; - - // set the attribute/s - if (ioctl(fd, ZFS_IOC_SETDOSFLAGS, &attribute) == -1) - err(EXIT_FAILURE, "ZFS_IOC_SETDOSFLAGS failed"); - - // get the attributes to confirm - dosflags = -1; - if (ioctl(fd, ZFS_IOC_GETDOSFLAGS, &dosflags) == -1) - err(EXIT_FAILURE, "ZFS_IOC_GETDOSFLAGS failed"); - - (void) close(fd); - - if (dosflags != attribute) - errx(EXIT_FAILURE, "Could not set %s attribute", argv[1]); - - (void) printf("New Dos Flags: 0x%llx\n", (u_longlong_t)dosflags); - - return (EXIT_SUCCESS); -} diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/xattrtest/xattrtest.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/xattrtest.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/cmd/xattrtest/xattrtest.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/xattrtest.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/xattrtest/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/cmd/xattrtest/.gitignore deleted file mode 100644 index 7d2128383639..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/xattrtest/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/xattrtest diff --git a/sys/contrib/openzfs/tests/zfs-tests/cmd/xattrtest/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/cmd/xattrtest/Makefile.am deleted file mode 100644 index 7398ae634629..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/cmd/xattrtest/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = xattrtest -xattrtest_SOURCES = xattrtest.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/zed_fd_spill-zedlet.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/zed_fd_spill-zedlet.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/zed_fd_spill-zedlet.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/zed_fd_spill-zedlet.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/socket.c b/sys/contrib/openzfs/tests/zfs-tests/cmd/zfs_diff-socket.c similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/socket.c rename to sys/contrib/openzfs/tests/zfs-tests/cmd/zfs_diff-socket.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/include/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/include/Makefile.am deleted file mode 100644 index 16cdf2c81432..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/include/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/include -dist_pkgdata_DATA = \ - blkdev.shlib \ - commands.cfg \ - libtest.shlib \ - math.shlib \ - properties.shlib \ - tunables.cfg \ - zpool_script.shlib - -nodist_pkgdata_DATA = default.cfg -SUBSTFILES += $(nodist_pkgdata_DATA) diff --git a/sys/contrib/openzfs/tests/zfs-tests/include/blkdev.shlib b/sys/contrib/openzfs/tests/zfs-tests/include/blkdev.shlib index 7159b92c080f..6b83b10d604d 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/include/blkdev.shlib +++ b/sys/contrib/openzfs/tests/zfs-tests/include/blkdev.shlib @@ -45,9 +45,7 @@ function scan_scsi_hosts log_must eval "echo '- - -' > $host/scan" done else - log_must eval \ - "echo /sys/class/scsi_host/host$hostnum/scan" \ - > /dev/null + log_note "/sys/class/scsi_host/host$hostnum/scan" log_must eval \ "echo '- - -' > /sys/class/scsi_host/host$hostnum/scan" fi @@ -115,21 +113,18 @@ function is_physical_device #device if is_linux; then is_disk_device "$DEV_DSKDIR/$device" && \ - [[ -f /sys/module/loop/parameters/max_part ]] - return $? + [ -f /sys/module/loop/parameters/max_part ] elif is_freebsd; then is_disk_device "$DEV_DSKDIR/$device" && \ - echo $device | egrep -q \ + echo $device | grep -qE \ -e '^a?da[0-9]+$' \ -e '^md[0-9]+$' \ -e '^mfid[0-9]+$' \ -e '^nda[0-9]+$' \ -e '^nvd[0-9]+$' \ -e '^vtbd[0-9]+$' - return $? else - echo $device | egrep "^c[0-F]+([td][0-F]+)+$" > /dev/null 2>&1 - return $? + echo $device | grep -qE "^c[0-F]+([td][0-F]+)+$" fi } @@ -143,8 +138,7 @@ function is_real_device #disk if is_linux; then lsblk $DEV_RDSKDIR/$disk -o TYPE 2>/dev/null | \ - egrep disk >/dev/null - return $? + grep -q disk fi } @@ -158,8 +152,7 @@ function is_loop_device #disk if is_linux; then lsblk $DEV_RDSKDIR/$disk -o TYPE 2>/dev/null | \ - egrep loop >/dev/null - return $? + grep -q loop fi } @@ -181,13 +174,11 @@ function is_mpath_device #disk [[ -z $disk ]] && log_fail "No argument for disk given." if is_linux; then - lsblk $DEV_MPATHDIR/$disk -o TYPE 2>/dev/null | \ - egrep mpath >/dev/null - if (($? == 0)); then + if lsblk $DEV_MPATHDIR/$disk -o TYPE 2>/dev/null | \ + grep -q mpath; then readlink $DEV_MPATHDIR/$disk > /dev/null 2>&1 - return $? else - return $? + false fi elif is_freebsd; then is_disk_device $DEV_MPATHDIR/$disk @@ -223,13 +214,11 @@ function set_slice_prefix if is_linux; then while (( i < $DISK_ARRAY_NUM )); do - disk="$(echo $DISKS | nawk '{print $(i + 1)}')" - if ( is_mpath_device $disk ) && [[ -z $(echo $disk | awk 'substr($1,18,1)\ - ~ /^[[:digit:]]+$/') ]] || ( is_real_device $disk ); then + disk="$(echo $DISKS | awk '{print $(i + 1)}')" + if is_mpath_device $disk && ! echo $disk | awk 'substr($1,18,1) ~ /^[[:digit:]]+$/ {exit 1}' || is_real_device $disk; then export SLICE_PREFIX="" return 0 - elif ( is_mpath_device $disk || is_loop_device \ - $disk ); then + elif is_mpath_device $disk || is_loop_device $disk; then export SLICE_PREFIX="p" return 0 else @@ -255,7 +244,7 @@ function set_device_dir if is_linux; then while (( i < $DISK_ARRAY_NUM )); do - disk="$(echo $DISKS | nawk '{print $(i + 1)}')" + disk="$(echo $DISKS | awk '{print $(i + 1)}')" if is_mpath_device $disk; then export DEV_DSKDIR=$DEV_MPATHDIR return 0 @@ -296,20 +285,15 @@ function get_device_dir #device function get_persistent_disk_name #device { typeset device=$1 - typeset dev_id if is_linux; then if is_real_device $device; then - dev_id="$(udevadm info -q all -n $DEV_DSKDIR/$device \ - | egrep disk/by-id | nawk '{print $2; exit}' \ - | nawk -F / '{print $3}')" - echo $dev_id + udevadm info -q all -n $DEV_DSKDIR/$device \ + | awk '/disk\/by-id/ {print $2; exit}' | cut -d/ -f3 elif is_mpath_device $device; then - dev_id="$(udevadm info -q all -n $DEV_DSKDIR/$device \ - | egrep disk/by-id/dm-uuid \ - | nawk '{print $2; exit}' \ - | nawk -F / '{print $3}')" - echo $dev_id + udevadm info -q all -n $DEV_DSKDIR/$device \ + | awk '/disk\/by-id\/dm-uuid/ {print $2; exit}' \ + | cut -d/ -f3 else echo $device fi @@ -336,42 +320,33 @@ function on_off_disk # disk state{online,offline} host if is_linux; then if [[ $state == "offline" ]] && ( is_mpath_device $disk ); then - dm_name="$(readlink $DEV_DSKDIR/$disk \ - | nawk -F / '{print $2}')" - dep="$(ls /sys/block/${dm_name}/slaves \ - | nawk '{print $1}')" + dm_name="$(readlink $DEV_DSKDIR/$disk | cut -d/ -f2)" + dep="$(ls /sys/block/${dm_name}/slaves | awk '{print $1}')" while [[ -n $dep ]]; do #check if disk is online - lsscsi | egrep $dep > /dev/null - if (($? == 0)); then + if lsscsi | grep -qF $dep; then dep_dir="/sys/block/${dm_name}" dep_dir+="/slaves/${dep}/device" ss="${dep_dir}/state" sd="${dep_dir}/delete" log_must eval "echo 'offline' > ${ss}" log_must eval "echo '1' > ${sd}" - lsscsi | egrep $dep > /dev/null - if (($? == 0)); then - log_fail "Offlining" \ - "$disk failed" - fi + if lsscsi | grep -qF $dep; then + log_fail "Offlining $disk failed" + fi fi - dep="$(ls /sys/block/$dm_name/slaves \ - 2>/dev/null | nawk '{print $1}')" + dep="$(ls /sys/block/$dm_name/slaves 2>/dev/null | awk '{print $1}')" done elif [[ $state == "offline" ]] && ( is_real_device $disk ); then #check if disk is online - lsscsi | egrep $disk > /dev/null - if (($? == 0)); then + if lsscsi | grep -qF $disk; then dev_state="/sys/block/$disk/device/state" dev_delete="/sys/block/$disk/device/delete" log_must eval "echo 'offline' > ${dev_state}" log_must eval "echo '1' > ${dev_delete}" - lsscsi | egrep $disk > /dev/null - if (($? == 0)); then - log_fail "Offlining $disk" \ - "failed" - fi + if lsscsi | grep -qF $disk; then + log_fail "Offlining $disk failed" + fi else log_note "$disk is already offline" fi @@ -380,18 +355,15 @@ function on_off_disk # disk state{online,offline} host scan_scsi_hosts $host block_device_wait if is_mpath_device $disk; then - dm_name="$(readlink $DEV_DSKDIR/$disk \ - | nawk -F / '{print $2}')" - dep="$(ls /sys/block/$dm_name/slaves \ - | nawk '{print $1}')" - lsscsi | egrep $dep > /dev/null - if (($? != 0)); then + dm_name="$(readlink $DEV_DSKDIR/$disk | cut -d/ -f2)" + dep="$(ls /sys/block/$dm_name/slaves | awk '{print $1}')" + if lsscsi | grep -qF $dep; then log_fail "Onlining $disk failed" fi elif is_real_device $disk; then block_device_wait typeset -i retries=0 - while ! lsscsi | egrep -q $disk; do + while ! lsscsi | grep -qF $disk; do if (( $retries > 2 )); then log_fail "Onlining $disk failed" break @@ -462,21 +434,16 @@ function load_scsi_debug # dev_size_mb add_host num_tgts max_luns blksz esac if is_linux; then - modprobe -n scsi_debug - if (($? != 0)); then - log_unsupported "Platform does not have scsi_debug" - "module" - fi - lsmod | egrep scsi_debug > /dev/null - if (($? == 0)); then + modprobe -n scsi_debug || + log_unsupported "Platform does not have scsi_debug module" + if lsmod | grep -q scsi_debug; then log_fail "scsi_debug module already installed" else log_must modprobe scsi_debug dev_size_mb=$devsize \ add_host=$hosts num_tgts=$tgts max_luns=$luns \ sector_size=$sector physblk_exp=$blkexp block_device_wait - lsscsi | egrep scsi_debug > /dev/null - if (($? == 1)); then + if ! lsscsi | grep -q scsi_debug; then log_fail "scsi_debug module install failed" fi fi @@ -498,7 +465,7 @@ function unload_scsi_debug function get_debug_device { for i in {1..10} ; do - val=$(lsscsi | nawk '/scsi_debug/ {print $6; exit}' | cut -d / -f3) + val=$(lsscsi | awk '/scsi_debug/ {print $6; exit}' | cut -d/ -f3) # lsscsi can take time to settle if [ "$val" != "-" ] ; then @@ -518,11 +485,11 @@ function get_pool_devices #testpool #devdir typeset devdir=$2 typeset out="" - if is_linux || is_freebsd; then - out=$(zpool status -P $testpool |grep ${devdir} | awk '{print $1}') - out=$(echo $out | sed -e "s|${devdir}/||g" | tr '\n' ' ') - fi - echo $out + case "$UNAME" in + Linux|FreeBSD) + zpool status -P $testpool | awk -v d="$devdir" '$1 ~ d {sub(d "/", ""); printf("%s ", $1)}' + ;; + esac } # diff --git a/sys/contrib/openzfs/tests/zfs-tests/include/commands.cfg b/sys/contrib/openzfs/tests/zfs-tests/include/commands.cfg index b247a67ff669..9dc2b4d0e08b 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/include/commands.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/include/commands.cfg @@ -8,9 +8,7 @@ # Please keep the contents of each variable sorted for ease of reading # and maintenance. # -export SYSTEM_FILES_COMMON='arp - awk - base64 +export SYSTEM_FILES_COMMON='awk basename bc bunzip2 @@ -32,7 +30,6 @@ export SYSTEM_FILES_COMMON='arp dmesg du echo - egrep env expr false @@ -53,10 +50,10 @@ export SYSTEM_FILES_COMMON='arp ksh ldd ln - logname ls mkdir mknod + mkfifo mktemp mount mv @@ -68,12 +65,9 @@ export SYSTEM_FILES_COMMON='arp pgrep ping pkill - printenv printf ps - pwd python3 - quotaon readlink rm rmdir @@ -89,34 +83,26 @@ export SYSTEM_FILES_COMMON='arp ssh stat strings - su sudo - sum swapoff swapon sync tail tar - tee timeout touch tr true truncate - umask umount uname uniq - uuidgen vmstat - wait - wc - which' + wc' export SYSTEM_FILES_FREEBSD='chflags compress diskinfo - dumpon fsck getextattr gpart @@ -126,7 +112,6 @@ export SYSTEM_FILES_FREEBSD='chflags lsextattr md5 mdconfig - mkfifo newfs pw rmextattr @@ -138,14 +123,11 @@ export SYSTEM_FILES_FREEBSD='chflags uncompress' export SYSTEM_FILES_LINUX='attr - bash blkid blockdev chattr - dmidecode exportfs fallocate - fdisk free getfattr groupadd @@ -162,16 +144,17 @@ export SYSTEM_FILES_LINUX='attr mkswap modprobe mpstat - nproc parted perf - setenforce setfattr sha256sum udevadm useradd userdel - usermod' + usermod + + flock + logger' export ZFS_FILES='zdb zfs @@ -196,6 +179,7 @@ export ZFSTEST_FILES='badsend devname2devid dir_rd_update draid + file_append file_check file_trunc file_write @@ -210,6 +194,7 @@ export ZFSTEST_FILES='badsend mmap_exec mmap_libaio mmap_seek + mmap_sync mmapwrite nvlist_to_lua randfree_file @@ -223,4 +208,15 @@ export ZFSTEST_FILES='badsend user_ns_exec write_dos_attributes xattrtest - stride_dd' + stride_dd + zed_fd_spill-zedlet + suid_write_to_file + cp_files + edonr_test + skein_test + sha2_test + ctime + truncate_test + ereports + zfs_diff-socket + dosmode_readonly_write' diff --git a/sys/contrib/openzfs/tests/zfs-tests/include/default.cfg.in b/sys/contrib/openzfs/tests/zfs-tests/include/default.cfg.in index cf382cfe994c..a9a17de34ae7 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/include/default.cfg.in +++ b/sys/contrib/openzfs/tests/zfs-tests/include/default.cfg.in @@ -170,8 +170,8 @@ if [ "@UBSAN_ENABLED@" = "yes" ]; then fi -case $(uname -o) in -GNU/Linux) +case $(uname) in +Linux) unpack_opts="--sparse -xf" pack_opts="--sparse -cf" verbose=" -v" @@ -209,7 +209,7 @@ FreeBSD) NEWFS_DEFAULT_FS="ufs" SLICE_PREFIX="p" ;; -illumos) +*) export AUTO_SNAP=$(svcs -a | \ awk '/auto-snapshot/ && /online/ { print $3 }') # finally, if we're running in a local zone diff --git a/sys/contrib/openzfs/tests/zfs-tests/include/libtest.shlib b/sys/contrib/openzfs/tests/zfs-tests/include/libtest.shlib index 3c0cd04c5e0f..51d4e225f10f 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/include/libtest.shlib +++ b/sys/contrib/openzfs/tests/zfs-tests/include/libtest.shlib @@ -31,12 +31,12 @@ # Use is subject to license terms. # +. ${STF_SUITE}/include/tunables.cfg + . ${STF_TOOLS}/include/logapi.shlib . ${STF_SUITE}/include/math.shlib . ${STF_SUITE}/include/blkdev.shlib -. ${STF_SUITE}/include/tunables.cfg - # # Apply constrained path when available. This is required since the # PATH may have been modified by sudo's secure_path behavior. @@ -52,11 +52,7 @@ fi # function compare_version_gte { - if [[ "$(printf "$1\n$2" | sort -V | tail -n1)" == "$1" ]]; then - return 0 - else - return 1 - fi + [ "$(printf "$1\n$2" | sort -V | tail -n1)" = "$1" ] } # Linux kernel version comparison function @@ -69,17 +65,16 @@ function linux_version { typeset ver="$1" - [[ -z "$ver" ]] && ver=$(uname -r | grep -Eo "^[0-9]+\.[0-9]+\.[0-9]+") + [ -z "$ver" ] && ver=$(uname -r | grep -Eo "^[0-9]+\.[0-9]+\.[0-9]+") - typeset version=$(echo $ver | cut -d '.' -f 1) - typeset major=$(echo $ver | cut -d '.' -f 2) - typeset minor=$(echo $ver | cut -d '.' -f 3) + typeset version major minor _ + IFS='.' read -r version major minor _ <<<"$ver" - [[ -z "$version" ]] && version=0 - [[ -z "$major" ]] && major=0 - [[ -z "$minor" ]] && minor=0 + [ -z "$version" ] && version=0 + [ -z "$major" ] && major=0 + [ -z "$minor" ] && minor=0 - echo $((version * 10000 + major * 100 + minor)) + echo $((version * 100000 + major * 1000 + minor)) } # Determine if this is a Linux test system @@ -88,11 +83,7 @@ function linux_version function is_linux { - if [[ $(uname -o) == "GNU/Linux" ]]; then - return 0 - else - return 1 - fi + [ "$UNAME" = "Linux" ] } # Determine if this is an illumos test system @@ -100,11 +91,7 @@ function is_linux # Return 0 if platform illumos, 1 if otherwise function is_illumos { - if [[ $(uname -o) == "illumos" ]]; then - return 0 - else - return 1 - fi + [ "$UNAME" = "illumos" ] } # Determine if this is a FreeBSD test system @@ -113,26 +100,7 @@ function is_illumos function is_freebsd { - if [[ $(uname -o) == "FreeBSD" ]]; then - return 0 - else - return 1 - fi -} - -# Determine if this is a DilOS test system -# -# Return 0 if platform DilOS, 1 if otherwise - -function is_dilos -{ - typeset ID="" - [[ -f /etc/os-release ]] && . /etc/os-release - if [[ $ID == "dilos" ]]; then - return 0 - else - return 1 - fi + [ "$UNAME" = "FreeBSD" ] } # Determine if this is a 32-bit system @@ -141,11 +109,7 @@ function is_dilos function is_32bit { - if [[ $(getconf LONG_BIT) == "32" ]]; then - return 0 - else - return 1 - fi + [ $(getconf LONG_BIT) = "32" ] } # Determine if kmemleak is enabled @@ -154,11 +118,7 @@ function is_32bit function is_kmemleak { - if is_linux && [[ -e /sys/kernel/debug/kmemleak ]]; then - return 0 - else - return 1 - fi + is_linux && [ -e /sys/kernel/debug/kmemleak ] } # Determine whether a dataset is mounted @@ -172,18 +132,14 @@ function ismounted { typeset fstype=$2 [[ -z $fstype ]] && fstype=zfs - typeset out dir name ret + typeset out dir name case $fstype in zfs) if [[ "$1" == "/"* ]] ; then - for out in $(zfs mount | awk '{print $2}'); do - [[ $1 == $out ]] && return 0 - done + ! zfs mount | awk -v fs="$1" '$2 == fs {exit 1}' else - for out in $(zfs mount | awk '{print $1}'); do - [[ $1 == $out ]] && return 0 - done + ! zfs mount | awk -v ds="$1" '$1 == ds {exit 1}' fi ;; ufs|nfs) @@ -192,9 +148,7 @@ function ismounted [[ "$1" == "$dev" || "$1" == "$dir" ]] && return 0 done else - out=$(df -F $fstype $1 2>/dev/null) - ret=$? - (($ret != 0)) && return $ret + out=$(df -F $fstype $1 2>/dev/null) || return dir=${out%%\(*} dir=${dir%% *} @@ -206,8 +160,7 @@ function ismounted fi ;; ext*) - out=$(df -t $fstype $1 2>/dev/null) - return $? + df -t $fstype $1 > /dev/null 2>&1 ;; zvol) if [[ -L "$ZVOL_DEVDIR/$1" ]]; then @@ -217,9 +170,10 @@ function ismounted return 0 fi ;; + *) + false + ;; esac - - return 1 } # Return 0 if a dataset is mounted; 1 otherwise @@ -230,8 +184,6 @@ function ismounted function mounted { ismounted $1 $2 - (($? == 0)) && return 0 - return 1 } # Return 0 if a dataset is unmounted; 1 otherwise @@ -241,18 +193,7 @@ function mounted function unmounted { - ismounted $1 $2 - (($? == 1)) && return 0 - return 1 -} - -# split line on "," -# -# $1 - line to split - -function splitline -{ - echo $1 | tr ',' ' ' + ! ismounted $1 $2 } function default_setup @@ -492,48 +433,6 @@ function default_mirror_setup_noexit log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS } -# -# create a number of mirrors. -# We create a number($1) of 2 way mirrors using the pairs of disks named -# on the command line. These mirrors are *not* mounted -# @parameters: $1 the number of mirrors to create -# $... the devices to use to create the mirrors on -# @uses: ZPOOL ZFS TESTPOOL -function setup_mirrors -{ - typeset -i nmirrors=$1 - - shift - while ((nmirrors > 0)); do - log_must test -n "$1" -a -n "$2" - [[ -d /$TESTPOOL$nmirrors ]] && rm -rf /$TESTPOOL$nmirrors - log_must zpool create -f $TESTPOOL$nmirrors mirror $1 $2 - shift 2 - ((nmirrors = nmirrors - 1)) - done -} - -# -# create a number of raidz pools. -# We create a number($1) of 2 raidz pools using the pairs of disks named -# on the command line. These pools are *not* mounted -# @parameters: $1 the number of pools to create -# $... the devices to use to create the pools on -# @uses: ZPOOL ZFS TESTPOOL -function setup_raidzs -{ - typeset -i nraidzs=$1 - - shift - while ((nraidzs > 0)); do - log_must test -n "$1" -a -n "$2" - [[ -d /$TESTPOOL$nraidzs ]] && rm -rf /$TESTPOOL$nraidzs - log_must zpool create -f $TESTPOOL$nraidzs raidz $1 $2 - shift 2 - ((nraidzs = nraidzs - 1)) - done -} - # # Destroy the configured testpool mirrors. # the mirrors are of the form ${TESTPOOL}{number} @@ -645,10 +544,8 @@ function default_cleanup_noexit log_must zfs set reservation=none $fs log_must zfs set recordsize=128K $fs log_must zfs set mountpoint=/$fs $fs - typeset enc="" - enc=$(get_prop encryption $fs) - if [[ $? -ne 0 ]] || [[ -z "$enc" ]] || \ - [[ "$enc" == "off" ]]; then + typeset enc=$(get_prop encryption $fs) + if [ -z "$enc" ] || [ "$enc" = "off" ]; then log_must zfs set checksum=on $fs fi log_must zfs set compression=off $fs @@ -686,15 +583,14 @@ function default_container_cleanup reexport_pool fi - ismounted $TESTPOOL/$TESTCTR/$TESTFS1 - [[ $? -eq 0 ]] && \ + ismounted $TESTPOOL/$TESTCTR/$TESTFS1 && log_must zfs unmount $TESTPOOL/$TESTCTR/$TESTFS1 destroy_dataset "$TESTPOOL/$TESTCTR/$TESTFS1" "-R" destroy_dataset "$TESTPOOL/$TESTCTR" "-Rf" [[ -e $TESTDIR1 ]] && \ - log_must rm -rf $TESTDIR1 > /dev/null 2>&1 + log_must rm -rf $TESTDIR1 default_cleanup } @@ -721,8 +617,6 @@ function destroy_snapshot typeset mtpt="" if ismounted $snap; then mtpt=$(get_prop mountpoint $snap) - (($? != 0)) && \ - log_fail "get_prop mountpoint $snap failed." fi destroy_dataset "$snap" @@ -747,8 +641,6 @@ function destroy_clone typeset mtpt="" if ismounted $clone; then mtpt=$(get_prop mountpoint $clone) - (($? != 0)) && \ - log_fail "get_prop mountpoint $clone failed." fi destroy_dataset "$clone" @@ -780,7 +672,6 @@ function destroy_bookmark function snapexists { zfs list -H -t snapshot "$1" > /dev/null 2>&1 - return $? } # @@ -791,7 +682,6 @@ function snapexists function bkmarkexists { zfs list -H -t bookmark "$1" > /dev/null 2>&1 - return $? } # @@ -802,8 +692,7 @@ function bkmarkexists # function holdexists { - zfs holds "$2" | awk '{ print $2 }' | grep "$1" > /dev/null 2>&1 - return $? + ! zfs holds "$2" | awk -v t="$1" '$2 ~ t { exit 1 }' } # @@ -839,46 +728,6 @@ function dataset_setprop return 0 } -# -# Assign suite defined dataset properties. -# This function is used to apply the suite's defined default set of -# properties to a dataset. -# @parameters: $1 dataset to use -# @uses: ZFS COMPRESSION_PROP CHECKSUM_PROP -# @returns: -# 0 if the dataset has been altered. -# 1 if no pool name was passed in. -# 2 if the dataset could not be found. -# 3 if the dataset could not have it's properties set. -# -function dataset_set_defaultproperties -{ - typeset dataset="$1" - - [[ -z $dataset ]] && return 1 - - typeset confset= - typeset -i found=0 - for confset in $(zfs list); do - if [[ $dataset = $confset ]]; then - found=1 - break - fi - done - [[ $found -eq 0 ]] && return 2 - if [[ -n $COMPRESSION_PROP ]]; then - dataset_setprop $dataset compression $COMPRESSION_PROP || \ - return 3 - log_note "Compression set to '$COMPRESSION_PROP' on $dataset" - fi - if [[ -n $CHECKSUM_PROP ]]; then - dataset_setprop $dataset checksum $CHECKSUM_PROP || \ - return 3 - log_note "Checksum set to '$CHECKSUM_PROP' on $dataset" - fi - return 0 -} - # # Check a numeric assertion # @parameter: $@ the assertion to check @@ -938,7 +787,7 @@ function set_partition typeset disk=${4#$DEV_DSKDIR/} disk=${disk#$DEV_RDSKDIR/} - case "$(uname)" in + case "$UNAME" in Linux) if [[ -z $size || -z $disk ]]; then log_fail "The size or disk name is unspecified." @@ -956,8 +805,7 @@ function set_partition parted $disk -s -- print 1 >/dev/null typeset ret_val=$? if [[ $slicenum -eq 0 || $ret_val -ne 0 ]]; then - parted $disk -s -- mklabel gpt - if [[ $? -ne 0 ]]; then + if ! parted $disk -s -- mklabel gpt; then log_note "Failed to create GPT partition table on $disk" return 1 fi @@ -971,9 +819,8 @@ function set_partition # Determine the cylinder size for the device and using # that calculate the end offset in cylinders. typeset -i cly_size_kb=0 - cly_size_kb=$(parted -m $disk -s -- \ - unit cyl print | head -3 | tail -1 | \ - awk -F '[:k.]' '{print $4}') + cly_size_kb=$(parted -m $disk -s -- unit cyl print | + awk -F '[:k.]' 'NR == 3 {print $4}') ((end = (size_mb * 1024 / cly_size_kb) + start)) parted $disk -s -- \ @@ -995,8 +842,7 @@ function set_partition if [[ $slicenum -eq 0 ]] || ! gpart show $disk >/dev/null 2>&1; then gpart destroy -F $disk >/dev/null 2>&1 - gpart create -s GPT $disk - if [[ $? -ne 0 ]]; then + if ! gpart create -s GPT $disk; then log_note "Failed to create GPT partition table on $disk" return 1 fi @@ -1094,7 +940,7 @@ function get_endslice # log_fail "The disk name or slice number is unspecified." fi - case "$(uname)" in + case "$UNAME" in Linux) endcyl=$(parted -s $DEV_DSKDIR/$disk -- unit cyl print | \ awk "/part${slice}/"' {sub(/cyl/, "", $3); print $3}') @@ -1114,15 +960,14 @@ function get_endslice # typeset -i ratio=0 ratio=$(prtvtoc /dev/rdsk/${disk}s2 | \ - grep "sectors\/cylinder" | \ - awk '{print $2}') + awk '/sectors\/cylinder/ {print $2}') if ((ratio == 0)); then return fi typeset -i endcyl=$(prtvtoc -h /dev/rdsk/${disk}s2 | - nawk -v token="$slice" '{if ($1==token) print $6}') + awk -v token="$slice" '$1 == token {print $6}') ((endcyl = (endcyl + 1) / ratio)) ;; @@ -1195,61 +1040,26 @@ function fill_fs # destdir dirnum filenum bytes num_writes data mkdir -p $destdir/{1..$dirnum} for f in $destdir/{1..$dirnum}/$TESTFILE{1..$filenum}; do file_write -o create -f $f -b $bytes -c $num_writes -d $data \ - || return $? + || return done - return 0 } -# -# Simple function to get the specified property. If unable to -# get the property then exits. -# -# Note property is in 'parsable' format (-p) -# +# Get the specified dataset property in parsable format or fail function get_prop # property dataset { - typeset prop_val typeset prop=$1 typeset dataset=$2 - prop_val=$(zfs get -pH -o value $prop $dataset 2>/dev/null) - if [[ $? -ne 0 ]]; then - log_note "Unable to get $prop property for dataset " \ - "$dataset" - return 1 - fi - - echo "$prop_val" - return 0 + zfs get -Hpo value "$prop" "$dataset" || log_fail "zfs get $prop $dataset" } -# -# Simple function to get the specified property of pool. If unable to -# get the property then exits. -# -# Note property is in 'parsable' format (-p) -# +# Get the specified pool property in parsable format or fail function get_pool_prop # property pool { - typeset prop_val typeset prop=$1 typeset pool=$2 - if poolexists $pool ; then - prop_val=$(zpool get -pH $prop $pool 2>/dev/null | tail -1 | \ - awk '{print $3}') - if [[ $? -ne 0 ]]; then - log_note "Unable to get $prop property for pool " \ - "$pool" - return 1 - fi - else - log_note "Pool $pool not exists." - return 1 - fi - - echo "$prop_val" - return 0 + zpool get -Hpo value "$prop" "$pool" || log_fail "zpool get $prop $pool" } # Return 0 if a pool exists; $? otherwise @@ -1266,7 +1076,6 @@ function poolexists fi zpool get name "$pool" > /dev/null 2>&1 - return $? } # Return 0 if all the specified datasets exist; $? otherwise @@ -1279,13 +1088,7 @@ function datasetexists return 1 fi - while (($# > 0)); do - zfs get name $1 > /dev/null 2>&1 || \ - return $? - shift - done - - return 0 + zfs get name "$@" > /dev/null 2>&1 } # return 0 if none of the specified datasets exists, otherwise return 1. @@ -1307,11 +1110,23 @@ function datasetnonexists return 0 } +# FreeBSD breaks exports(5) at whitespace and doesn't process escapes +# Solaris just breaks +# +# cf. https://github.com/openzfs/zfs/pull/13165#issuecomment-1059845807 +# +# Linux can have spaces (which are \OOO-escaped), +# but can't have backslashes because they're parsed recursively +function shares_can_have_whitespace +{ + is_linux +} + function is_shared_freebsd { typeset fs=$1 - pgrep -q mountd && showmount -E | grep -qx $fs + pgrep -q mountd && showmount -E | grep -qx "$fs" } function is_shared_illumos @@ -1336,14 +1151,7 @@ function is_shared_illumos function is_shared_linux { typeset fs=$1 - typeset mtpt - - for mtpt in `share | awk '{print $1}'` ; do - if [[ $mtpt == $fs ]] ; then - return 0 - fi - done - return 1 + ! exportfs -s | awk -v fs="${fs//\\/\\\\}" '/^\// && $1 == fs {exit 1}' } # @@ -1361,7 +1169,7 @@ function is_shared return 1 else mtpt=$(get_prop mountpoint "$fs") - case $mtpt in + case "$mtpt" in none|legacy|-) return 1 ;; *) fs=$mtpt @@ -1370,7 +1178,7 @@ function is_shared fi fi - case $(uname) in + case "$UNAME" in FreeBSD) is_shared_freebsd "$fs" ;; Linux) is_shared_linux "$fs" ;; *) is_shared_illumos "$fs" ;; @@ -1380,13 +1188,11 @@ function is_shared function is_exported_illumos { typeset fs=$1 - typeset mtpt + typeset mtpt _ - for mtpt in `awk '{print $1}' /etc/dfs/sharetab` ; do - if [[ $mtpt == $fs ]] ; then - return 0 - fi - done + while read -r mtpt _; do + [ "$mtpt" = "$fs" ] && return + done < /etc/dfs/sharetab return 1 } @@ -1394,13 +1200,11 @@ function is_exported_illumos function is_exported_freebsd { typeset fs=$1 - typeset mtpt + typeset mtpt _ - for mtpt in `awk '{print $1}' /etc/zfs/exports` ; do - if [[ $mtpt == $fs ]] ; then - return 0 - fi - done + while read -r mtpt _; do + [ "$mtpt" = "$fs" ] && return + done < /etc/zfs/exports return 1 } @@ -1408,13 +1212,11 @@ function is_exported_freebsd function is_exported_linux { typeset fs=$1 - typeset mtpt + typeset mtpt _ - for mtpt in `awk '{print $1}' /etc/exports.d/zfs.exports` ; do - if [[ $mtpt == $fs ]] ; then - return 0 - fi - done + while read -r mtpt _; do + [ "$(printf "$mtpt")" = "$fs" ] && return + done < /etc/exports.d/zfs.exports return 1 } @@ -1444,7 +1246,7 @@ function is_exported fi fi - case $(uname) in + case "$UNAME" in FreeBSD) is_exported_freebsd "$fs" ;; Linux) is_exported_linux "$fs" ;; *) is_exported_illumos "$fs" ;; @@ -1459,23 +1261,13 @@ function is_exported function is_shared_smb { typeset fs=$1 - typeset mtpt - if datasetnonexists "$fs" ; then - return 1 - else - fs=$(echo $fs | tr / _) - fi + datasetexists "$fs" || return if is_linux; then - for mtpt in `net usershare list | awk '{print $1}'` ; do - if [[ $mtpt == $fs ]] ; then - return 0 - fi - done - return 1 + net usershare list | grep -xFq "${fs//\//_}" else - log_note "Currently unsupported by the test framework" + log_note "SMB on $UNAME currently unsupported by the test framework" return 1 fi } @@ -1487,14 +1279,7 @@ function is_shared_smb # function not_shared { - typeset fs=$1 - - is_shared $fs - if (($? == 0)); then - return 1 - fi - - return 0 + ! is_shared $1 } # @@ -1504,14 +1289,7 @@ function not_shared # function not_shared_smb { - typeset fs=$1 - - is_shared_smb $fs - if (($? == 0)); then - return 1 - fi - - return 0 + ! is_shared_smb $1 } # @@ -1521,12 +1299,9 @@ function unshare_fs #fs { typeset fs=$1 - is_shared $fs || is_shared_smb $fs - if (($? == 0)); then - zfs unshare $fs || log_fail "zfs unshare $fs failed" + if is_shared $fs || is_shared_smb $fs; then + log_must zfs unshare $fs fi - - return 0 } # @@ -1536,17 +1311,22 @@ function share_nfs #fs { typeset fs=$1 - if is_linux; then - is_shared $fs - if (($? != 0)); then - log_must share "*:$fs" - fi - else - is_shared $fs - if (($? != 0)); then - log_must share -F nfs $fs - fi - fi + is_shared "$fs" && return + + case "$UNAME" in + Linux) + log_must exportfs "*:$fs" + ;; + FreeBSD) + typeset mountd + read -r mountd < /var/run/mountd.pid + log_must eval "printf '%s\t\n' \"$fs\" >> /etc/zfs/exports" + log_must kill -s HUP "$mountd" + ;; + *) + log_must share -F nfs "$fs" + ;; + esac return 0 } @@ -1558,17 +1338,23 @@ function unshare_nfs #fs { typeset fs=$1 - if is_linux; then - is_shared $fs - if (($? == 0)); then - log_must unshare -u "*:$fs" - fi - else - is_shared $fs - if (($? == 0)); then - log_must unshare -F nfs $fs - fi - fi + ! is_shared "$fs" && return + + case "$UNAME" in + Linux) + log_must exportfs -u "*:$fs" + ;; + FreeBSD) + typeset mountd + read -r mountd < /var/run/mountd.pid + awk -v fs="${fs//\\/\\\\}" '$1 != fs' /etc/zfs/exports > /etc/zfs/exports.$$ + log_must mv /etc/zfs/exports.$$ /etc/zfs/exports + log_must kill -s HUP "$mountd" + ;; + *) + log_must unshare -F nfs $fs + ;; + esac return 0 } @@ -1578,42 +1364,32 @@ function unshare_nfs #fs # function showshares_nfs { - if is_linux; then - share -v - else + case "$UNAME" in + Linux) + exportfs -v + ;; + FreeBSD) + showmount + ;; + *) share -F nfs - fi - - return 0 -} - -# -# Helper function to show SMB shares. -# -function showshares_smb -{ - if is_linux; then - net usershare list - else - share -F smb - fi - - return 0 + ;; + esac } function check_nfs { - if is_linux; then - share -s - elif is_freebsd; then + case "$UNAME" in + Linux) + exportfs -s + ;; + FreeBSD) showmount -e - else + ;; + *) log_unsupported "Unknown platform" - fi - - if [[ $? -ne 0 ]]; then - log_unsupported "The NFS utilities are not installed" - fi + ;; + esac || log_unsupported "The NFS utilities are not installed" } # @@ -1633,12 +1409,12 @@ function setup_nfs_server # Re-synchronize /var/lib/nfs/etab with /etc/exports and # /etc/exports.d./* to provide a clean test environment. # - log_must share -r + log_must exportfs -r log_note "NFS server must be started prior to running ZTS." return elif is_freebsd; then - kill -s HUP $(cat /var/run/mountd.pid) + log_must kill -s HUP $(/dev/null) - if [[ $cur_zone != "global" ]]; then - return 1 - fi - return 0 + [ $cur_zone = "global" ] fi } @@ -1841,7 +1614,7 @@ function create_dataset #dataset dataset_options # $2 - custom arguments for zfs destroy # Destroy dataset with the given parameters. -function destroy_dataset #dataset #args +function destroy_dataset # dataset [args] { typeset dataset=$1 typeset mtpt @@ -1857,8 +1630,7 @@ function destroy_dataset #dataset #args mtpt=$(get_prop mountpoint "$dataset") log_must_busy zfs destroy $args $dataset - [[ -d $mtpt ]] && \ - log_must rm -rf $mtpt + [ -d $mtpt ] && log_must rm -rf $mtpt else log_note "Dataset does not exist. ($dataset)" return 1 @@ -1868,118 +1640,6 @@ function destroy_dataset #dataset #args return 0 } -# -# Firstly, create a pool with 5 datasets. Then, create a single zone and -# export the 5 datasets to it. In addition, we also add a ZFS filesystem -# and a zvol device to the zone. -# -# $1 zone name -# $2 zone root directory prefix -# $3 zone ip -# -function zfs_zones_setup #zone_name zone_root zone_ip -{ - typeset zone_name=${1:-$(hostname)-z} - typeset zone_root=${2:-"/zone_root"} - typeset zone_ip=${3:-"10.1.1.10"} - typeset prefix_ctr=$ZONE_CTR - typeset pool_name=$ZONE_POOL - typeset -i cntctr=5 - typeset -i i=0 - - # Create pool and 5 container within it - # - [[ -d /$pool_name ]] && rm -rf /$pool_name - log_must zpool create -f $pool_name $DISKS - while ((i < cntctr)); do - log_must zfs create $pool_name/$prefix_ctr$i - ((i += 1)) - done - - # create a zvol - log_must zfs create -V 1g $pool_name/zone_zvol - block_device_wait - - # - # Add slog device for pool - # - typeset sdevs="$TEST_BASE_DIR/sdev1 $TEST_BASE_DIR/sdev2" - log_must mkfile $MINVDEVSIZE $sdevs - log_must zpool add $pool_name log mirror $sdevs - - # this isn't supported just yet. - # Create a filesystem. In order to add this to - # the zone, it must have it's mountpoint set to 'legacy' - # log_must zfs create $pool_name/zfs_filesystem - # log_must zfs set mountpoint=legacy $pool_name/zfs_filesystem - - [[ -d $zone_root ]] && \ - log_must rm -rf $zone_root/$zone_name - [[ ! -d $zone_root ]] && \ - log_must mkdir -p -m 0700 $zone_root/$zone_name - - # Create zone configure file and configure the zone - # - typeset zone_conf=/tmp/zone_conf.$$ - echo "create" > $zone_conf - echo "set zonepath=$zone_root/$zone_name" >> $zone_conf - echo "set autoboot=true" >> $zone_conf - i=0 - while ((i < cntctr)); do - echo "add dataset" >> $zone_conf - echo "set name=$pool_name/$prefix_ctr$i" >> \ - $zone_conf - echo "end" >> $zone_conf - ((i += 1)) - done - - # add our zvol to the zone - echo "add device" >> $zone_conf - echo "set match=/dev/zvol/dsk/$pool_name/zone_zvol" >> $zone_conf - echo "end" >> $zone_conf - - # add a corresponding zvol rdsk to the zone - echo "add device" >> $zone_conf - echo "set match=$ZVOL_RDEVDIR/$pool_name/zone_zvol" >> $zone_conf - echo "end" >> $zone_conf - - # once it's supported, we'll add our filesystem to the zone - # echo "add fs" >> $zone_conf - # echo "set type=zfs" >> $zone_conf - # echo "set special=$pool_name/zfs_filesystem" >> $zone_conf - # echo "set dir=/export/zfs_filesystem" >> $zone_conf - # echo "end" >> $zone_conf - - echo "verify" >> $zone_conf - echo "commit" >> $zone_conf - log_must zonecfg -z $zone_name -f $zone_conf - log_must rm -f $zone_conf - - # Install the zone - zoneadm -z $zone_name install - if (($? == 0)); then - log_note "SUCCESS: zoneadm -z $zone_name install" - else - log_fail "FAIL: zoneadm -z $zone_name install" - fi - - # Install sysidcfg file - # - typeset sysidcfg=$zone_root/$zone_name/root/etc/sysidcfg - echo "system_locale=C" > $sysidcfg - echo "terminal=dtterm" >> $sysidcfg - echo "network_interface=primary {" >> $sysidcfg - echo "hostname=$zone_name" >> $sysidcfg - echo "}" >> $sysidcfg - echo "name_service=NONE" >> $sysidcfg - echo "root_password=mo791xfZ/SFiw" >> $sysidcfg - echo "security_policy=NONE" >> $sysidcfg - echo "timezone=US/Eastern" >> $sysidcfg - - # Boot this zone - log_must zoneadm -z $zone_name boot -} - # # Reexport TESTPOOL & TESTPOOL(1-4) # @@ -2020,14 +1680,10 @@ function check_state # pool disk state{online,offline,degraded} if [[ -z $disk ]]; then #check pool state only - zpool get -H -o value health $pool \ - | grep -i "$state" > /dev/null 2>&1 + zpool get -H -o value health $pool | grep -qi "$state" else - zpool status -v $pool | grep "$disk" \ - | grep -i "$state" > /dev/null 2>&1 + zpool status -v $pool | grep "$disk" | grep -qi "$state" fi - - return $? } # @@ -2061,19 +1717,16 @@ function verify_ashift # device ashift typeset device="$1" typeset ashift="$2" - zdb -e -lll $device | awk -v ashift=$ashift '/ashift: / { - if (ashift != $2) - exit 1; - else - count++; - } END { - if (count != 4) - exit 1; - else - exit 0; + zdb -e -lll $device | awk -v ashift=$ashift ' + /ashift: / { + if (ashift != $2) + exit 1; + else + count++; + } + END { + exit (count != 4); }' - - return $? } # @@ -2104,10 +1757,10 @@ function verify_filesys # pool filesystem dir log_must zpool import $search_path $pool - zdb -cudi $filesys > $zdbout 2>&1 - if [[ $? != 0 ]]; then + if ! zdb -cudi $filesys > $zdbout 2>&1; then log_note "Output: zdb -cudi $filesys" cat $zdbout + rm -f $zdbout log_fail "zdb detected errors with: '$filesys'" fi @@ -2142,13 +1795,8 @@ function verify_pool # function get_disklist # pool { - typeset disklist="" - - disklist=$(zpool iostat -v $1 | nawk '(NR >4) {print $1}' | \ - grep -v "\-\-\-\-\-" | \ - egrep -v -e "^(mirror|raidz[1-3]|draid[1-3]|spare|log|cache|special|dedup)|\-[0-9]$") - - echo $disklist + echo $(zpool iostat -v $1 | awk '(NR > 4) {print $1}' | \ + grep -vEe '^-----' -e "^(mirror|raidz[1-3]|draid[1-3]|spare|log|cache|special|dedup)|\-[0-9]$") } # @@ -2157,8 +1805,7 @@ function get_disklist # pool # function get_disklist_fullpath # pool { - args="-P $1" - get_disklist $args + get_disklist "-P $1" } @@ -2186,10 +1833,8 @@ function stress_timeout log_note "Killing child processes after ${TIMEOUT} stress timeout." typeset pid for pid in $cpids; do - ps -p $pid > /dev/null 2>&1 - if (($? == 0)); then + ps -p $pid > /dev/null 2>&1 && log_must kill -USR1 $pid - fi done } @@ -2206,10 +1851,7 @@ function check_hotspare_state # pool disk state{inuse,avail} cur_state=$(get_device_state $pool $disk "spares") - if [[ $state != ${cur_state} ]]; then - return 1 - fi - return 0 + [ $state = $cur_state ] } # @@ -2237,25 +1879,6 @@ function wait_hotspare_state # pool disk state timeout return 1 } -# -# Verify a given slog disk is inuse or avail -# -# Return 0 is pool/disk matches expected state, 1 otherwise -# -function check_slog_state # pool disk state{online,offline,unavail} -{ - typeset pool=$1 - typeset disk=${2#$DEV_DSKDIR/} - typeset state=$3 - - cur_state=$(get_device_state $pool $disk "logs") - - if [[ $state != ${cur_state} ]]; then - return 1 - fi - return 0 -} - # # Verify a given vdev disk is inuse or avail # @@ -2269,10 +1892,7 @@ function check_vdev_state # pool disk state{online,offline,unavail} cur_state=$(get_device_state $pool $disk) - if [[ $state != ${cur_state} ]]; then - return 1 - fi - return 0 + [ $state = $cur_state ] } # @@ -2313,14 +1933,11 @@ function check_pool_status # pool token keyword typeset keyword=$3 typeset verbose=${4:-false} - scan=$(zpool status -v "$pool" 2>/dev/null | nawk -v token="$token:" ' - ($1==token) {print $0}') + scan=$(zpool status -v "$pool" 2>/dev/null | awk -v token="$token:" '$1==token') if [[ $verbose == true ]]; then log_note $scan fi - echo $scan | egrep -i "$keyword" > /dev/null 2>&1 - - return $? + echo $scan | grep -qi "$keyword" } # @@ -2339,55 +1956,46 @@ function is_pool_resilvering #pool { check_pool_status "$1" "scan" \ "resilver[ ()0-9A-Za-z:_-]* in progress since" $2 - return $? } function is_pool_resilvered #pool { check_pool_status "$1" "scan" "resilvered " $2 - return $? } function is_pool_scrubbing #pool { check_pool_status "$1" "scan" "scrub in progress since " $2 - return $? } function is_pool_scrubbed #pool { check_pool_status "$1" "scan" "scrub repaired" $2 - return $? } function is_pool_scrub_stopped #pool { check_pool_status "$1" "scan" "scrub canceled" $2 - return $? } function is_pool_scrub_paused #pool { check_pool_status "$1" "scan" "scrub paused since " $2 - return $? } function is_pool_removing #pool { check_pool_status "$1" "remove" "in progress since " - return $? } function is_pool_removed #pool { check_pool_status "$1" "remove" "completed on" - return $? } function is_pool_discarding #pool { check_pool_status "$1" "checkpoint" "discarding" - return $? } function wait_for_degraded @@ -2454,55 +2062,39 @@ function find_disks swap -l > $sfi dumpadm > $dmpi 2>/dev/null -# write an awk script that can process the output of format -# to produce a list of disks we know about. Note that we have -# to escape "$2" so that the shell doesn't interpret it while -# we're creating the awk script. -# ------------------- - cat > /tmp/find_disks.awk </dev/null | awk ' +BEGIN { FS="."; } - /^Specify disk/{ - searchdisks=0; +/^Specify disk/{ + searchdisks=0; +} + +{ + if (searchdisks && $2 !~ "^$"){ + split($2,arr," "); + print arr[1]; } +} - { - if (searchdisks && \$2 !~ "^$"){ - split(\$2,arr," "); - print arr[1]; - } - } - - /^AVAILABLE DISK SELECTIONS:/{ - searchdisks=1; - } -EOF -#--------------------- - - chmod 755 /tmp/find_disks.awk - disks=${@:-$(echo "" | format -e 2>/dev/null | /tmp/find_disks.awk)} - rm /tmp/find_disks.awk +/^AVAILABLE DISK SELECTIONS:/{ + searchdisks=1; +} +')} unused="" for disk in $disks; do # Check for mounted - grep "${disk}[sp]" /etc/mnttab >/dev/null - (($? == 0)) && continue + grep -q "${disk}[sp]" /etc/mnttab && continue # Check for swap - grep "${disk}[sp]" $sfi >/dev/null - (($? == 0)) && continue + grep -q "${disk}[sp]" $sfi && continue # check for dump device - grep "${disk}[sp]" $dmpi >/dev/null - (($? == 0)) && continue + grep -q "${disk}[sp]" $dmpi && continue # check to see if this disk hasn't been explicitly excluded # by a user-set environment variable - echo "${ZFS_HOST_DEVICES_IGNORE}" | grep "${disk}" > /dev/null - (($? == 0)) && continue + echo "${ZFS_HOST_DEVICES_IGNORE}" | grep -q "${disk}" && continue unused_candidates="$unused_candidates $disk" done - rm $sfi - rm $dmpi + rm $sfi $dmpi # now just check to see if those disks do actually exist # by looking for a device pointing to the first slice in @@ -2535,10 +2127,8 @@ function add_user_freebsd # # Assign 1000 as the base uid typeset -i uid=1000 while true; do - typeset -i ret pw useradd -u $uid -g $group -d $basedir/$user -m -n $user - ret=$? - case $ret in + case $? in 0) break ;; # The uid is not unique 65) ((uid += 1)) ;; @@ -2589,8 +2179,7 @@ function add_group_freebsd # typeset -i gid=1000 while true; do pw groupadd -g $gid -n $group > /dev/null 2>&1 - typeset -i ret=$? - case $ret in + case $? in 0) return 0 ;; # The gid is not unique 65) ((gid += 1)) ;; @@ -2612,8 +2201,7 @@ function del_group_freebsd # typeset group=$1 pw groupdel -n $group > /dev/null 2>&1 - typeset -i ret=$? - case $ret in + case $? in # Group does not exist, or was deleted successfully. 0|6|65) return 0 ;; # Name already exists as a group name @@ -2653,8 +2241,7 @@ function add_group_illumos # typeset -i gid=100 while true; do groupadd -g $gid $group > /dev/null 2>&1 - typeset -i ret=$? - case $ret in + case $? in 0) return 0 ;; # The gid is not unique 4) ((gid += 1)) ;; @@ -2668,8 +2255,7 @@ function del_group_illumos # typeset group=$1 groupmod -n $grp $grp > /dev/null 2>&1 - typeset -i ret=$? - case $ret in + case $? in # Group does not exist. 6) return 0 ;; # Name already exists as a group name @@ -2689,7 +2275,7 @@ function add_user_linux # # Add new users to the same group and the command line utils. # This allows them to be run out of the original users home # directory as long as it permissioned to be group readable. - cmd_group=$(stat --format="%G" $(which zfs)) + cmd_group=$(stat --format="%G" $(command -v zfs)) log_must usermod -a -G $cmd_group $user return 0 @@ -2702,8 +2288,6 @@ function del_user_linux # if id $user > /dev/null 2>&1; then log_must_retry "currently used" 6 userdel $user fi - - return 0 } function add_group_linux # @@ -2714,8 +2298,7 @@ function add_group_linux # # Linux because for many distributions 1000 and under are reserved. while true; do groupadd $group > /dev/null 2>&1 - typeset -i ret=$? - case $ret in + case $? in 0) return 0 ;; *) return 1 ;; esac @@ -2727,8 +2310,7 @@ function del_group_linux # typeset group=$1 getent group $group > /dev/null 2>&1 - typeset -i ret=$? - case $ret in + case $? in # Group does not exist. 2) return 0 ;; # Name already exists as a group name @@ -2756,7 +2338,7 @@ function add_user # log_fail "group name or user name are not defined." fi - case $(uname) in + case "$UNAME" in FreeBSD) add_user_freebsd "$group" "$user" "$basedir" ;; @@ -2786,7 +2368,7 @@ function del_user # log_fail "login name is necessary." fi - case $(uname) in + case "$UNAME" in FreeBSD) del_user_freebsd "$user" ;; @@ -2816,7 +2398,7 @@ function add_group # log_fail "group name is necessary." fi - case $(uname) in + case "$UNAME" in FreeBSD) add_group_freebsd "$group" ;; @@ -2844,7 +2426,7 @@ function del_group # log_fail "group name is necessary." fi - case $(uname) in + case "$UNAME" in FreeBSD) del_group_freebsd "$group" ;; @@ -2880,23 +2462,21 @@ function safe_to_destroy_pool { # $1 the pool name # this is a list of the top-level directories in each of the # files that make up the path to the files the pool is based on - FILEPOOL=$(zpool status -v $pool | grep /$1/ | \ - awk '{print $1}') + FILEPOOL=$(zpool status -v $pool | awk -v pool="/$1/" '$0 ~ pool {print $1}') # this is a list of the zvols that make up the pool - ZVOLPOOL=$(zpool status -v $pool | grep "$ZVOL_DEVDIR/$1$" \ - | awk '{print $1}') + ZVOLPOOL=$(zpool status -v $pool | awk -v zvols="$ZVOL_DEVDIR/$1$" '$0 ~ zvols {print $1}') # also want to determine if it's a file-based pool using an # alternate mountpoint... POOL_FILE_DIRS=$(zpool status -v $pool | \ - grep / | awk '{print $1}' | \ - awk -F/ '{print $2}' | grep -v "dev") + awk '/\// {print $1}' | \ + awk -F/ '!/dev/ {print $2}') for pooldir in $POOL_FILE_DIRS do OUTPUT=$(zfs list -H -r -o mountpoint $1 | \ - grep "${pooldir}$" | awk '{print $1}') + awk -v pd="${pooldir}$" '$0 ~ pd {print $1}') ALTMOUNTPOOL="${ALTMOUNTPOOL}${OUTPUT}" done @@ -3009,26 +2589,15 @@ function get_config { typeset pool=$1 typeset config=$2 - typeset alt_root if ! poolexists "$pool" ; then return 1 fi - alt_root=$(zpool list -H $pool | awk '{print $NF}') - if [[ $alt_root == "-" ]]; then - value=$(zdb -C $pool | grep "$config:" | awk -F: \ - '{print $2}') + if [ "$(get_pool_prop cachefile "$pool")" = "none" ]; then + zdb -e $pool else - value=$(zdb -e $pool | grep "$config:" | awk -F: \ - '{print $2}') - fi - if [[ -n $value ]] ; then - value=${value#'} - value=${value%'} - fi - echo $value - - return 0 + zdb -C $pool + fi | awk -F: -v cfg="$config:" '$0 ~ cfg {sub(/^'\''/, $2); sub(/'\''$/, $2); print $2}' } # @@ -3046,8 +2615,7 @@ function _random_get typeset -i ind ((ind = RANDOM % cnt + 1)) - typeset ret=$(echo "$str" | cut -f $ind -d ' ') - echo $ret + echo "$str" | cut -f $ind -d ' ' } # @@ -3110,20 +2678,7 @@ function datasetcksum typeset cksum sync sync_all_pools - cksum=$(zdb -vvv $1 | grep "^Dataset $1 \[" | grep "cksum" \ - | awk -F= '{print $7}') - echo $cksum -} - -# -# Get cksum of file -# #1 file path -# -function checksum -{ - typeset cksum - cksum=$(cksum $1 | awk '{print $1}') - echo $cksum + zdb -vvv $1 | awk -F= -v ds="^Dataset $1 "'\\[' '$0 ~ ds && /cksum/ {print $7}' } # @@ -3135,99 +2690,14 @@ function get_device_state #pool disk field("", "spares","logs") typeset disk=${2#$DEV_DSKDIR/} typeset field=${3:-$pool} - state=$(zpool status -v "$pool" 2>/dev/null | \ - nawk -v device=$disk -v pool=$pool -v field=$field \ + zpool status -v "$pool" 2>/dev/null | \ + awk -v device=$disk -v pool=$pool -v field=$field \ 'BEGIN {startconfig=0; startfield=0; } /config:/ {startconfig=1} (startconfig==1) && ($1==field) {startfield=1; next;} (startfield==1) && ($1==device) {print $2; exit;} (startfield==1) && - ($1==field || $1 ~ "^spares$" || $1 ~ "^logs$") {startfield=0}') - echo $state -} - - -# -# print the given directory filesystem type -# -# $1 directory name -# -function get_fstype -{ - typeset dir=$1 - - if [[ -z $dir ]]; then - log_fail "Usage: get_fstype " - fi - - # - # $ df -n / - # / : ufs - # - df -n $dir | awk '{print $3}' -} - -# -# Given a disk, label it to VTOC regardless what label was on the disk -# $1 disk -# -function labelvtoc -{ - typeset disk=$1 - if [[ -z $disk ]]; then - log_fail "The disk name is unspecified." - fi - typeset label_file=/var/tmp/labelvtoc.$$ - typeset arch=$(uname -p) - - if is_linux || is_freebsd; then - log_note "Currently unsupported by the test framework" - return 1 - fi - - if [[ $arch == "i386" ]]; then - echo "label" > $label_file - echo "0" >> $label_file - echo "" >> $label_file - echo "q" >> $label_file - echo "q" >> $label_file - - fdisk -B $disk >/dev/null 2>&1 - # wait a while for fdisk finishes - sleep 60 - elif [[ $arch == "sparc" ]]; then - echo "label" > $label_file - echo "0" >> $label_file - echo "" >> $label_file - echo "" >> $label_file - echo "" >> $label_file - echo "q" >> $label_file - else - log_fail "unknown arch type" - fi - - format -e -s -d $disk -f $label_file - typeset -i ret_val=$? - rm -f $label_file - # - # wait the format to finish - # - sleep 60 - if ((ret_val != 0)); then - log_fail "unable to label $disk as VTOC." - fi - - return 0 -} - -# -# check if the system was installed as zfsroot or not -# return: 0 if zfsroot, non-zero if not -# -function is_zfsroot -{ - df -n / | grep zfs > /dev/null 2>&1 - return $? + ($1==field || $1 ~ "^spares$" || $1 ~ "^logs$") {startfield=0}' } # @@ -3241,14 +2711,13 @@ function get_rootfs if is_freebsd; then rootfs=$(mount -p | awk '$2 == "/" && $3 == "zfs" {print $1}') elif ! is_linux; then - rootfs=$(awk '{if ($2 == "/" && $3 == "zfs") print $1}' \ + rootfs=$(awk '$2 == "/" && $3 == "zfs" {print $1}' \ /etc/mnttab) fi if [[ -z "$rootfs" ]]; then log_fail "Can not get rootfs" fi - zfs list $rootfs > /dev/null 2>&1 - if (($? == 0)); then + if datasetexists $rootfs; then echo $rootfs else log_fail "This is not a zfsroot system." @@ -3262,32 +2731,8 @@ function get_rootfs # function get_rootpool { - typeset rootfs="" - typeset rootpool="" - - if is_freebsd; then - rootfs=$(mount -p | awk '$2 == "/" && $3 == "zfs" {print $1}') - elif ! is_linux; then - rootfs=$(awk '{if ($2 == "/" && $3 =="zfs") print $1}' \ - /etc/mnttab) - fi - if [[ -z "$rootfs" ]]; then - log_fail "Can not get rootpool" - fi - zfs list $rootfs > /dev/null 2>&1 - if (($? == 0)); then - echo ${rootfs%%/*} - else - log_fail "This is not a zfsroot system." - fi -} - -# -# Get the word numbers from a string separated by white space -# -function get_word_count -{ - echo $1 | wc -w + typeset rootfs=$(get_rootfs) + echo ${rootfs%%/*} } # @@ -3297,7 +2742,7 @@ function verify_disk_count { typeset -i min=${2:-1} - typeset -i count=$(get_word_count "$1") + typeset -i count=$(echo "$1" | wc -w) if ((count < min)); then log_untested "A minimum of $min disks is required to run." \ @@ -3308,22 +2753,13 @@ function verify_disk_count function ds_is_volume { typeset type=$(get_prop type $1) - [[ $type = "volume" ]] && return 0 - return 1 + [ $type = "volume" ] } function ds_is_filesystem { typeset type=$(get_prop type $1) - [[ $type = "filesystem" ]] && return 0 - return 1 -} - -function ds_is_snapshot -{ - typeset type=$(get_prop type $1) - [[ $type = "snapshot" ]] && return 0 - return 1 + [ $type = "filesystem" ] } # @@ -3331,26 +2767,23 @@ function ds_is_snapshot # function is_te_enabled { - svcs -H -o state labeld 2>/dev/null | grep "enabled" - if (($? != 0)); then - return 1 - else - return 0 - fi + svcs -H -o state labeld 2>/dev/null | grep -q "enabled" } # Utility function to determine if a system has multiple cpus. function is_mp { - if is_linux; then - (($(nproc) > 1)) - elif is_freebsd; then - sysctl -n kern.smp.cpus - else - (($(psrinfo | wc -l) > 1)) - fi - - return $? + case "$UNAME" in + Linux) + (($(grep -c '^processor' /proc/cpuinfo) > 1)) + ;; + FreeBSD) + sysctl -n kern.smp.cpus + ;; + *) + (($(psrinfo | wc -l) > 1)) + ;; + esac } function get_cpu_freq @@ -3409,14 +2842,12 @@ function vdevs_in_pool # therefore we use the 'zpool status' output. typeset tmpfile=$(mktemp) zpool status -v "$pool" | grep -A 1000 "config:" >$tmpfile - for vdev in $@; do - grep -w ${vdev##*/} $tmpfile >/dev/null 2>&1 - [[ $? -ne 0 ]] && return 1 + for vdev in "$@"; do + grep -wq ${vdev##*/} $tmpfile || return 1 done rm -f $tmpfile - - return 0; + return 0 } function get_max @@ -3431,18 +2862,6 @@ function get_max echo $max } -function get_min -{ - typeset -l i min=$1 - shift - - for i in "$@"; do - min=$((min < i ? min : i)) - done - - echo $min -} - # Write data that can be compressed into a directory function write_compressible { @@ -3474,20 +2893,21 @@ function write_compressible done done else - log_must eval "fio \ + command -v fio > /dev/null || log_unsupported "fio missing" + log_must eval fio \ --name=job \ --fallocate=0 \ --minimal \ --randrepeat=0 \ --buffer_compress_percentage=66 \ --buffer_compress_chunk=4096 \ - --directory=$dir \ - --numjobs=$nfiles \ - --nrfiles=$nfiles \ + --directory="$dir" \ + --numjobs="$nfiles" \ + --nrfiles="$nfiles" \ --rw=write \ - --bs=$bs \ - --filesize=$megs \ - --filename_format='$fname.\$jobnum' >/dev/null" + --bs="$bs" \ + --filesize="$megs" \ + "--filename_format='$fname.\$jobnum' >/dev/null" fi } @@ -3565,9 +2985,7 @@ function wait_freeing #pool function wait_replacing #pool { typeset pool=${1:-$TESTPOOL} - while true; do - [[ "" == "$(zpool status $pool | - awk '/replacing-[0-9]+/ {print $1}')" ]] && break + while zpool status $pool | grep -qE 'replacing-[0-9]+'; do log_must sleep 1 done } @@ -3609,7 +3027,7 @@ function zed_rc_restore function zed_setup { if ! is_linux; then - log_unsupported "No zed on $(uname)" + log_unsupported "No zed on $UNAME" fi if [[ ! -d $ZEDLET_DIR ]]; then @@ -3658,24 +3076,13 @@ function zed_cleanup if ! is_linux; then return fi - EXTRA_ZEDLETS=$@ - log_must rm -f ${ZEDLET_DIR}/zed.rc - log_must rm -f ${ZEDLET_DIR}/zed-functions.sh - log_must rm -f ${ZEDLET_DIR}/all-syslog.sh - log_must rm -f ${ZEDLET_DIR}/all-debug.sh - log_must rm -f ${ZEDLET_DIR}/state - - if [[ -n "$EXTRA_ZEDLETS" ]] ; then - for i in $EXTRA_ZEDLETS ; do - log_must rm -f ${ZEDLET_DIR}/$i - done - fi - log_must rm -f $ZED_LOG - log_must rm -f $ZED_DEBUG_LOG - log_must rm -f $VDEVID_CONF_ETC - log_must rm -f $VDEVID_CONF - rmdir $ZEDLET_DIR + for extra_zedlet; do + log_must rm -f ${ZEDLET_DIR}/$extra_zedlet + done + log_must rm -fd ${ZEDLET_DIR}/zed.rc ${ZEDLET_DIR}/zed-functions.sh ${ZEDLET_DIR}/all-syslog.sh ${ZEDLET_DIR}/all-debug.sh ${ZEDLET_DIR}/state \ + $ZED_LOG $ZED_DEBUG_LOG $VDEVID_CONF_ETC $VDEVID_CONF \ + $ZEDLET_DIR } # @@ -3687,9 +3094,7 @@ function zed_check return fi zedpids="$(pgrep -x zed)" -# ret1=$? zedpids2="$(pgrep -x lt-zed)" -# ret2=$? echo ${zedpids} ${zedpids2} } @@ -3788,15 +3193,17 @@ function is_swap_inuse return 1 fi - if is_linux; then - swapon -s | grep -w $(readlink -f $device) > /dev/null 2>&1 - elif is_freebsd; then - swapctl -l | grep -w $device - else - swap -l | grep -w $device > /dev/null 2>&1 - fi - - return $? + case "$UNAME" in + Linux) + swapon -s | grep -wq $(readlink -f $device) + ;; + FreeBSD) + swapctl -l | grep -wq $device + ;; + *) + swap -l | grep -wq $device + ;; + esac } # @@ -3806,14 +3213,18 @@ function swap_setup { typeset swapdev=$1 - if is_linux; then + case "$UNAME" in + Linux) log_must eval "mkswap $swapdev > /dev/null 2>&1" log_must swapon $swapdev - elif is_freebsd; then + ;; + FreeBSD) log_must swapctl -a $swapdev - else - log_must swap -a $swapdev - fi + ;; + *) + log_must swap -a $swapdev + ;; + esac return 0 } @@ -3865,12 +3276,11 @@ function set_tunable_impl typeset name="$1" typeset value="$2" typeset mdb_cmd="$3" - typeset module="${4:-zfs}" eval "typeset tunable=\$$name" case "$tunable" in UNSUPPORTED) - log_unsupported "Tunable '$name' is unsupported on $(uname)" + log_unsupported "Tunable '$name' is unsupported on $UNAME" ;; "") log_fail "Tunable '$name' must be added to tunables.cfg" @@ -3882,21 +3292,16 @@ function set_tunable_impl [[ -z "$value" ]] && return 1 [[ -z "$mdb_cmd" ]] && return 1 - case "$(uname)" in + case "$UNAME" in Linux) - typeset zfs_tunables="/sys/module/$module/parameters" - [[ -w "$zfs_tunables/$tunable" ]] || return 1 - cat >"$zfs_tunables/$tunable" <<<"$value" - return $? + typeset zfs_tunables="/sys/module/zfs/parameters" + echo "$value" >"$zfs_tunables/$tunable" ;; FreeBSD) sysctl vfs.zfs.$tunable=$value - return "$?" ;; SunOS) - [[ "$module" -eq "zfs" ]] || return 1 echo "${tunable}/${mdb_cmd}0t${value}" | mdb -kw - return $? ;; esac } @@ -3919,7 +3324,7 @@ function get_tunable_impl eval "typeset tunable=\$$name" case "$tunable" in UNSUPPORTED) - log_unsupported "Tunable '$name' is unsupported on $(uname)" + log_unsupported "Tunable '$name' is unsupported on $UNAME" ;; "") log_fail "Tunable '$name' must be added to tunables.cfg" @@ -3928,12 +3333,10 @@ function get_tunable_impl ;; esac - case "$(uname)" in + case "$UNAME" in Linux) typeset zfs_tunables="/sys/module/$module/parameters" - [[ -f "$zfs_tunables/$tunable" ]] || return 1 cat $zfs_tunables/$tunable - return $? ;; FreeBSD) sysctl -n vfs.zfs.$tunable @@ -3942,69 +3345,6 @@ function get_tunable_impl [[ "$module" -eq "zfs" ]] || return 1 ;; esac - - return 1 -} - -# -# Prints the current time in seconds since UNIX Epoch. -# -function current_epoch -{ - printf '%(%s)T' -} - -# -# Get decimal value of global uint32_t variable using mdb. -# -function mdb_get_uint32 -{ - typeset variable=$1 - typeset value - - value=$(mdb -k -e "$variable/X | ::eval .=U") - if [[ $? -ne 0 ]]; then - log_fail "Failed to get value of '$variable' from mdb." - return 1 - fi - - echo $value - return 0 -} - -# -# Set global uint32_t variable to a decimal value using mdb. -# -function mdb_set_uint32 -{ - typeset variable=$1 - typeset value=$2 - - mdb -kw -e "$variable/W 0t$value" > /dev/null - if [[ $? -ne 0 ]]; then - echo "Failed to set '$variable' to '$value' in mdb." - return 1 - fi - - return 0 -} - -# -# Set global scalar integer variable to a hex value using mdb. -# Note: Target should have CTF data loaded. -# -function mdb_ctf_set_int -{ - typeset variable=$1 - typeset value=$2 - - mdb -kw -e "$variable/z $value" > /dev/null - if [[ $? -ne 0 ]]; then - echo "Failed to set '$variable' to '$value' in mdb." - return 1 - fi - - return 0 } # @@ -4015,12 +3355,14 @@ function md5digest { typeset file=$1 - case $(uname) in + case "$UNAME" in FreeBSD) md5 -q $file ;; *) - md5sum -b $file | awk '{ print $1 }' + typeset sum _ + read -r sum _ < <(md5sum -b $file) + echo $sum ;; esac } @@ -4033,19 +3375,21 @@ function sha256digest { typeset file=$1 - case $(uname) in + case "$UNAME" in FreeBSD) sha256 -q $file ;; *) - sha256sum -b $file | awk '{ print $1 }' + typeset sum _ + read -r sum _ < <(sha256sum -b $file) + echo $sum ;; esac } function new_fs # { - case $(uname) in + case "$UNAME" in FreeBSD) newfs "$@" ;; @@ -4059,7 +3403,7 @@ function stat_size # { typeset path=$1 - case $(uname) in + case "$UNAME" in FreeBSD) stat -f %z "$path" ;; @@ -4073,7 +3417,7 @@ function stat_ctime # { typeset path=$1 - case $(uname) in + case "$UNAME" in FreeBSD) stat -f %c "$path" ;; @@ -4087,7 +3431,7 @@ function stat_crtime # { typeset path=$1 - case $(uname) in + case "$UNAME" in FreeBSD) stat -f %B "$path" ;; @@ -4101,7 +3445,7 @@ function stat_generation # { typeset path=$1 - case $(uname) in + case "$UNAME" in Linux) getversion "${path}" ;; @@ -4146,7 +3490,7 @@ function get_xattr # name path typeset name=$1 typeset path=$2 - case $(uname) in + case "$UNAME" in FreeBSD) getextattr -qq user "${name}" "${path}" ;; @@ -4162,7 +3506,7 @@ function set_xattr # name value path typeset value=$2 typeset path=$3 - case $(uname) in + case "$UNAME" in FreeBSD) setextattr user "${name}" "${value}" "${path}" ;; @@ -4177,7 +3521,7 @@ function set_xattr_stdin # name value typeset name=$1 typeset path=$2 - case $(uname) in + case "$UNAME" in FreeBSD) setextattr -i user "${name}" "${path}" ;; @@ -4192,7 +3536,7 @@ function rm_xattr # name path typeset name=$1 typeset path=$2 - case $(uname) in + case "$UNAME" in FreeBSD) rmextattr -q user "${name}" "${path}" ;; @@ -4206,7 +3550,7 @@ function ls_xattr # path { typeset path=$1 - case $(uname) in + case "$UNAME" in FreeBSD) lsextattr -qq user "${path}" ;; @@ -4221,14 +3565,12 @@ function kstat # stat flags? typeset stat=$1 typeset flags=${2-"-n"} - case $(uname) in + case "$UNAME" in FreeBSD) sysctl $flags kstat.zfs.misc.$stat ;; Linux) - typeset zfs_kstat="/proc/spl/kstat/zfs/$stat" - [[ -f "$zfs_kstat" ]] || return 1 - cat $zfs_kstat + cat "/proc/spl/kstat/zfs/$stat" 2>/dev/null ;; *) false @@ -4240,12 +3582,12 @@ function get_arcstat # stat { typeset stat=$1 - case $(uname) in + case "$UNAME" in FreeBSD) kstat arcstats.$stat ;; Linux) - kstat arcstats | awk "/$stat/ { print \$3 }" + kstat arcstats | awk "/$stat/"' { print $3 }' ;; *) false @@ -4259,7 +3601,7 @@ function punch_hole # offset length file typeset length=$2 typeset file=$3 - case $(uname) in + case "$UNAME" in FreeBSD) truncate -d -o $offset -l $length "$file" ;; @@ -4272,6 +3614,22 @@ function punch_hole # offset length file esac } +function zero_range # offset length file +{ + typeset offset=$1 + typeset length=$2 + typeset file=$3 + + case "$UNAME" in + Linux) + fallocate --zero-range --offset $offset --length $length "$file" + ;; + *) + false + ;; + esac +} + # # Wait for the specified arcstat to reach non-zero quiescence. # If echo is 1 echo the value after reaching quiescence, otherwise @@ -4371,10 +3729,10 @@ function directory_diff # dir_a dir_b # We check ctimes even with zil_replay=1 because the ZIL does store # creation times and we should make sure they match (if the creation times # do not match there is a "c" entry in one of the columns). - if ( rsync --version | grep -q "[, ] crtimes" >/dev/null ); then + if rsync --version | grep -q "[, ] crtimes"; then args+=("--crtimes") else - echo "NOTE: This rsync package does not support --crtimes (-N)." + log_note "This rsync package does not support --crtimes (-N)." fi # If we are testing a ZIL replay, we need to ignore timestamp changes. @@ -4411,5 +3769,48 @@ function directory_diff # dir_a dir_b function replay_directory_diff # dir_a dir_b { LIBTEST_DIFF_ZIL_REPLAY=1 directory_diff "$@" - return $? +} + +# +# Put coredumps into $1/core.{basename} +# +# Output must be saved and passed to pop_coredump_pattern on cleanup +# +function push_coredump_pattern # dir +{ + ulimit -c unlimited + case "$UNAME" in + Linux) + cat /proc/sys/kernel/core_pattern /proc/sys/kernel/core_uses_pid + echo "$1/core.%e" >/proc/sys/kernel/core_pattern && + echo 0 >/proc/sys/kernel/core_uses_pid + ;; + FreeBSD) + sysctl -n kern.corefile + sysctl kern.corefile="$1/core.%N" >/dev/null + ;; + *) + # Nothing to output – set only for this shell + coreadm -p "$1/core.%f" + ;; + esac +} + +# +# Put coredumps back into the default location +# +function pop_coredump_pattern +{ + [ -s "$1" ] || return 0 + case "$UNAME" in + Linux) + typeset pat pid + { read -r pat; read -r pid; } < "$1" + echo "$pat" >/proc/sys/kernel/core_pattern && + echo "$pid" >/proc/sys/kernel/core_uses_pid + ;; + FreeBSD) + sysctl kern.corefile="$(<"$1")" >/dev/null + ;; + esac } diff --git a/sys/contrib/openzfs/tests/zfs-tests/include/math.shlib b/sys/contrib/openzfs/tests/zfs-tests/include/math.shlib index 7ac59f279604..38d9fecea7cf 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/include/math.shlib +++ b/sys/contrib/openzfs/tests/zfs-tests/include/math.shlib @@ -30,17 +30,14 @@ function within_percent typeset percent=$3 # Set $a or $b to $2 such that a >= b - [[ '1' = $(echo "if ($2 > $a) 1 else 0" | bc) ]] && a=$2 || b=$2 + [ 1 -eq $(echo "$2 > $a" | bc) ] && a=$2 || b=$2 # Prevent division by 0 [[ $a =~ [1-9] ]] || return 1 typeset p=$(echo "scale=2; $b * 100 / $a" | bc) log_note "Comparing $a and $b given $percent% (calculated: $p%)" - [[ '1' = $(echo "scale=2; if ($p >= $percent) 1 else 0" | bc) ]] && \ - return 0 - - return 1 + [ 1 -eq $(echo "scale=2; $p >= $percent" | bc) ] } # @@ -61,9 +58,7 @@ function within_tolerance #value #target #tolerance typeset diff=$((abs(val - target))) log_note "Checking if $val is within +/-$tol of $target (diff: $diff)" - ((diff <= tol)) && return 0 - - return 1 + ((diff <= tol)) } # diff --git a/sys/contrib/openzfs/tests/zfs-tests/include/properties.shlib b/sys/contrib/openzfs/tests/zfs-tests/include/properties.shlib index 6d467b60051d..ba82f96202b2 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/include/properties.shlib +++ b/sys/contrib/openzfs/tests/zfs-tests/include/properties.shlib @@ -69,26 +69,6 @@ function get_rand_prop_vals echo $retstr } -function get_rand_checksum -{ - get_rand_prop_vals checksum $1 2 -} - -function get_rand_checksum_any -{ - get_rand_prop_vals checksum $1 0 -} - -function get_rand_recsize -{ - get_rand_prop_vals recsize $1 0 -} - -function get_rand_large_recsize -{ - get_rand_prop_vals recsize $1 9 -} - # # Functions to toggle on/off properties # @@ -100,12 +80,8 @@ else binary_props+=('zoned') fi -if is_linux; then - # Only older kernels support non-blocking mandatory locks - if [[ $(linux_version) -lt $(linux_version "4.4") ]]; then - binary_props+=('nbmand') - fi -else +# Newer Linuxes dropped non-blocking mandatory locks +if ! is_linux || [ $(linux_version) -lt $(linux_version "4.4") ]; then binary_props+=('nbmand') fi @@ -114,7 +90,6 @@ function toggle_prop typeset ds=$1 typeset prop=$2 - datasetexists $ds || log_fail "$ds does not exist" typeset val=$(get_prop $prop $ds) typeset newval='off' @@ -137,7 +112,6 @@ function randomize_ds_props typeset ds=$1 typeset prop proplist val - datasetexists $ds || log_fail "$ds does not exist" if ds_is_volume $ds; then toggle_prop $ds readonly proplist="${vol_props[@]}" diff --git a/sys/contrib/openzfs/tests/zfs-tests/include/zpool_script.shlib b/sys/contrib/openzfs/tests/zfs-tests/include/zpool_script.shlib index 10bc0cc26128..cbf1e07803d4 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/include/zpool_script.shlib +++ b/sys/contrib/openzfs/tests/zfs-tests/include/zpool_script.shlib @@ -15,7 +15,7 @@ function test_zpool_script { out="$($wholecmd)" # Default number of columns that get printed without -c - if echo "$cmd" | grep -q iostat ; then + if [ "$cmd" != "${cmd/iostat/_/}" ]; then # iostat dcols=7 else @@ -39,9 +39,9 @@ function test_zpool_script { # zpool iostat -v output is 7 columns, so if the script ran correctly # we should see more than that. if ! newcols=$(echo "$out" | \ - awk '/\/dev/{print NF-'$dcols'; if (NF <= '$dcols') {exit 1}}' | \ - head -n 1) ; \ - then + awk '/\/dev/ {print NF-'$dcols'; if (NF <= '$dcols') {exit 1}}' | \ + head -n 1) + then log_fail "'$wholecmd' didn't create a new column value" else log_note "'$wholecmd' passed ($newcols new columns)" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/Makefile.am index f7494791524e..4bc05c92f592 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/Makefile.am +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/Makefile.am @@ -1 +1,1954 @@ -SUBDIRS = functional perf stress +CLEANFILES = +EXTRA_DIST = +include $(top_srcdir)/config/Substfiles.am + + +datadir_zfs_tests_testsdir = $(datadir)/$(PACKAGE)/zfs-tests/tests +nobase_dist_datadir_zfs_tests_tests_DATA = \ + perf/nfs-sample.cfg \ + perf/perf.shlib \ + \ + perf/fio/mkfiles.fio \ + perf/fio/random_reads.fio \ + perf/fio/random_readwrite.fio \ + perf/fio/random_readwrite_fixed.fio \ + perf/fio/random_writes.fio \ + perf/fio/sequential_reads.fio \ + perf/fio/sequential_readwrite.fio \ + perf/fio/sequential_writes.fio + +nobase_dist_datadir_zfs_tests_tests_SCRIPTS = \ + perf/regression/random_reads.ksh \ + perf/regression/random_readwrite.ksh \ + perf/regression/random_readwrite_fixed.ksh \ + perf/regression/random_writes.ksh \ + perf/regression/random_writes_zil.ksh \ + perf/regression/sequential_reads_arc_cached_clone.ksh \ + perf/regression/sequential_reads_arc_cached.ksh \ + perf/regression/sequential_reads_dbuf_cached.ksh \ + perf/regression/sequential_reads.ksh \ + perf/regression/sequential_writes.ksh \ + perf/regression/setup.ksh \ + \ + perf/scripts/prefetch_io.sh + +# These lists can be regenerated by running, on a *clean* source: +# find functional/ ! -type d ! -name .gitignore ! -name .dirstamp ! -name '*.Po' ! -executable -name '*.in' | sort | sed 's/\.in$//;s/^/\t/;$!s/$/ \\/' +# find functional/ ! -type d ! -name .gitignore ! -name .dirstamp ! -name '*.Po' -executable -name '*.in' | sort | sed 's/\.in$//;s/^/\t/;$!s/$/ \\/' +# find functional/ ! -type d ! -name .gitignore ! -name .dirstamp ! -name '*.Po' ! -name '*.in' ! -name '*.c' | grep -Fe /simd -e /tmpfile | sort | sed 's/^/\t/;$!s/$/ \\/' +# find functional/ ! -type d ! -name .gitignore ! -name .dirstamp ! -name '*.Po' ! -executable ! -name '*.in' ! -name '*.c' | grep -vFe /simd -e /tmpfile | sort | sed 's/^/\t/;$!s/$/ \\/' +# find functional/ ! -type d ! -name .gitignore ! -name .dirstamp ! -name '*.Po' -executable ! -name '*.in' ! -name '*.c' | grep -vFe /simd -e /tmpfile | sort | sed 's/^/\t/;$!s/$/ \\/' +# +# simd and tmpfile are Linux-only and not installed elsewhere +# +# C programs are specced in ../Makefile.am above as part of the main Makefile + +nobase_nodist_datadir_zfs_tests_tests_DATA = \ + functional/pam/utilities.kshlib +nobase_nodist_datadir_zfs_tests_tests_SCRIPTS = \ + functional/pyzfs/pyzfs_unittest.ksh + +SUBSTFILES += $(nobase_nodist_datadir_zfs_tests_tests_DATA) $(nobase_nodist_datadir_zfs_tests_tests_SCRIPTS) + +if BUILD_LINUX +nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \ + functional/simd/simd_supported.ksh \ + functional/tmpfile/cleanup.ksh \ + functional/tmpfile/setup.ksh +endif + +nobase_dist_datadir_zfs_tests_tests_DATA += \ + functional/acl/acl.cfg \ + functional/acl/acl_common.kshlib \ + functional/alloc_class/alloc_class.cfg \ + functional/alloc_class/alloc_class.kshlib \ + functional/atime/atime.cfg \ + functional/atime/atime_common.kshlib \ + functional/cache/cache.cfg \ + functional/cache/cache.kshlib \ + functional/cachefile/cachefile.cfg \ + functional/cachefile/cachefile.kshlib \ + functional/casenorm/casenorm.cfg \ + functional/casenorm/casenorm.kshlib \ + functional/channel_program/channel_common.kshlib \ + functional/channel_program/lua_core/tst.args_to_lua.out \ + functional/channel_program/lua_core/tst.args_to_lua.zcp \ + functional/channel_program/lua_core/tst.divide_by_zero.err \ + functional/channel_program/lua_core/tst.divide_by_zero.zcp \ + functional/channel_program/lua_core/tst.exists.zcp \ + functional/channel_program/lua_core/tst.large_prog.out \ + functional/channel_program/lua_core/tst.large_prog.zcp \ + functional/channel_program/lua_core/tst.lib_base.lua \ + functional/channel_program/lua_core/tst.lib_coroutine.lua \ + functional/channel_program/lua_core/tst.lib_strings.lua \ + functional/channel_program/lua_core/tst.lib_table.lua \ + functional/channel_program/lua_core/tst.nested_neg.zcp \ + functional/channel_program/lua_core/tst.nested_pos.zcp \ + functional/channel_program/lua_core/tst.recursive.zcp \ + functional/channel_program/lua_core/tst.return_large.zcp \ + functional/channel_program/lua_core/tst.return_recursive_table.zcp \ + functional/channel_program/lua_core/tst.stack_gsub.err \ + functional/channel_program/lua_core/tst.stack_gsub.zcp \ + functional/channel_program/lua_core/tst.timeout.zcp \ + functional/channel_program/synctask_core/tst.bookmark.copy.zcp \ + functional/channel_program/synctask_core/tst.bookmark.create.zcp \ + functional/channel_program/synctask_core/tst.get_index_props.out \ + functional/channel_program/synctask_core/tst.get_index_props.zcp \ + functional/channel_program/synctask_core/tst.get_number_props.out \ + functional/channel_program/synctask_core/tst.get_number_props.zcp \ + functional/channel_program/synctask_core/tst.get_string_props.out \ + functional/channel_program/synctask_core/tst.get_string_props.zcp \ + functional/channel_program/synctask_core/tst.promote_conflict.zcp \ + functional/channel_program/synctask_core/tst.set_props.zcp \ + functional/channel_program/synctask_core/tst.snapshot_destroy.zcp \ + functional/channel_program/synctask_core/tst.snapshot_neg.zcp \ + functional/channel_program/synctask_core/tst.snapshot_recursive.zcp \ + functional/channel_program/synctask_core/tst.snapshot_simple.zcp \ + functional/checksum/default.cfg \ + functional/clean_mirror/clean_mirror_common.kshlib \ + functional/clean_mirror/default.cfg \ + functional/cli_root/cli_common.kshlib \ + functional/cli_root/zfs_copies/zfs_copies.cfg \ + functional/cli_root/zfs_copies/zfs_copies.kshlib \ + functional/cli_root/zfs_create/properties.kshlib \ + functional/cli_root/zfs_create/zfs_create.cfg \ + functional/cli_root/zfs_create/zfs_create_common.kshlib \ + functional/cli_root/zfs_destroy/zfs_destroy.cfg \ + functional/cli_root/zfs_destroy/zfs_destroy_common.kshlib \ + functional/cli_root/zfs_get/zfs_get_common.kshlib \ + functional/cli_root/zfs_get/zfs_get_list_d.kshlib \ + functional/cli_root/zfs_jail/jail.conf \ + functional/cli_root/zfs_load-key/HEXKEY \ + functional/cli_root/zfs_load-key/PASSPHRASE \ + functional/cli_root/zfs_load-key/RAWKEY \ + functional/cli_root/zfs_load-key/zfs_load-key.cfg \ + functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib \ + functional/cli_root/zfs_mount/zfs_mount.cfg \ + functional/cli_root/zfs_mount/zfs_mount.kshlib \ + functional/cli_root/zfs_promote/zfs_promote.cfg \ + functional/cli_root/zfs_receive/zstd_test_data.txt \ + functional/cli_root/zfs_rename/zfs_rename.cfg \ + functional/cli_root/zfs_rename/zfs_rename.kshlib \ + functional/cli_root/zfs_rollback/zfs_rollback.cfg \ + functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib \ + functional/cli_root/zfs_send/zfs_send.cfg \ + functional/cli_root/zfs_set/zfs_set_common.kshlib \ + functional/cli_root/zfs_share/zfs_share.cfg \ + functional/cli_root/zfs_snapshot/zfs_snapshot.cfg \ + functional/cli_root/zfs_unmount/zfs_unmount.cfg \ + functional/cli_root/zfs_unmount/zfs_unmount.kshlib \ + functional/cli_root/zfs_upgrade/zfs_upgrade.kshlib \ + functional/cli_root/zfs_wait/zfs_wait.kshlib \ + functional/cli_root/zpool_add/zpool_add.cfg \ + functional/cli_root/zpool_add/zpool_add.kshlib \ + functional/cli_root/zpool_clear/zpool_clear.cfg \ + functional/cli_root/zpool_create/draidcfg.gz \ + functional/cli_root/zpool_create/zpool_create.cfg \ + functional/cli_root/zpool_create/zpool_create.shlib \ + functional/cli_root/zpool_destroy/zpool_destroy.cfg \ + functional/cli_root/zpool_events/zpool_events.cfg \ + functional/cli_root/zpool_events/zpool_events.kshlib \ + functional/cli_root/zpool_expand/zpool_expand.cfg \ + functional/cli_root/zpool_export/zpool_export.cfg \ + functional/cli_root/zpool_export/zpool_export.kshlib \ + functional/cli_root/zpool_get/zpool_get.cfg \ + functional/cli_root/zpool_get/zpool_get_parsable.cfg \ + functional/cli_root/zpool_import/blockfiles/cryptv0.dat.bz2 \ + functional/cli_root/zpool_import/blockfiles/missing_ivset.dat.bz2 \ + functional/cli_root/zpool_import/blockfiles/unclean_export.dat.bz2 \ + functional/cli_root/zpool_import/zpool_import.cfg \ + functional/cli_root/zpool_import/zpool_import.kshlib \ + functional/cli_root/zpool_initialize/zpool_initialize.kshlib \ + functional/cli_root/zpool_labelclear/labelclear.cfg \ + functional/cli_root/zpool_remove/zpool_remove.cfg \ + functional/cli_root/zpool_reopen/zpool_reopen.cfg \ + functional/cli_root/zpool_reopen/zpool_reopen.shlib \ + functional/cli_root/zpool_resilver/zpool_resilver.cfg \ + functional/cli_root/zpool_scrub/zpool_scrub.cfg \ + functional/cli_root/zpool_split/zpool_split.cfg \ + functional/cli_root/zpool_trim/zpool_trim.kshlib \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-broken-mirror1.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-broken-mirror2.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v10.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v11.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v12.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v13.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v14.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v15.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v1.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v1mirror1.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v1mirror2.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v1mirror3.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v1raidz1.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v1raidz2.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v1raidz3.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v1stripe1.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v1stripe2.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v1stripe3.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v2.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v2mirror1.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v2mirror2.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v2mirror3.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v2raidz1.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v2raidz2.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v2raidz3.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v2stripe1.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v2stripe2.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v2stripe3.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v3.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v3hotspare1.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v3hotspare2.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v3hotspare3.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v3mirror1.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v3mirror2.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v3mirror3.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v3raidz1.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v3raidz21.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v3raidz22.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v3raidz23.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v3raidz2.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v3raidz3.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v3stripe1.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v3stripe2.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v3stripe3.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v4.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v5.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v6.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v7.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v8.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v999.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v9.dat.bz2 \ + functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-vBROKEN.dat.bz2 \ + functional/cli_root/zpool_upgrade/zpool_upgrade.cfg \ + functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib \ + functional/cli_root/zpool_wait/zpool_wait.kshlib \ + functional/cli_user/misc/misc.cfg \ + functional/cli_user/zfs_list/zfs_list.cfg \ + functional/cli_user/zfs_list/zfs_list.kshlib \ + functional/compression/compress.cfg \ + functional/compression/testpool_zstd.tar.gz \ + functional/deadman/deadman.cfg \ + functional/delegate/delegate.cfg \ + functional/delegate/delegate_common.kshlib \ + functional/devices/devices.cfg \ + functional/devices/devices_common.kshlib \ + functional/events/events.cfg \ + functional/events/events_common.kshlib \ + functional/fault/fault.cfg \ + functional/grow/grow.cfg \ + functional/history/history.cfg \ + functional/history/history_common.kshlib \ + functional/history/i386.migratedpool.DAT.Z \ + functional/history/i386.orig_history.txt \ + functional/history/sparc.migratedpool.DAT.Z \ + functional/history/sparc.orig_history.txt \ + functional/history/zfs-pool-v4.dat.Z \ + functional/inheritance/config001.cfg \ + functional/inheritance/config002.cfg \ + functional/inheritance/config003.cfg \ + functional/inheritance/config004.cfg \ + functional/inheritance/config005.cfg \ + functional/inheritance/config006.cfg \ + functional/inheritance/config007.cfg \ + functional/inheritance/config008.cfg \ + functional/inheritance/config009.cfg \ + functional/inheritance/config010.cfg \ + functional/inheritance/config011.cfg \ + functional/inheritance/config012.cfg \ + functional/inheritance/config013.cfg \ + functional/inheritance/config014.cfg \ + functional/inheritance/config015.cfg \ + functional/inheritance/config016.cfg \ + functional/inheritance/config017.cfg \ + functional/inheritance/config018.cfg \ + functional/inheritance/config019.cfg \ + functional/inheritance/config020.cfg \ + functional/inheritance/config021.cfg \ + functional/inheritance/config022.cfg \ + functional/inheritance/config023.cfg \ + functional/inheritance/config024.cfg \ + functional/inheritance/inherit.kshlib \ + functional/inheritance/README.config \ + functional/inheritance/README.state \ + functional/inheritance/state001.cfg \ + functional/inheritance/state002.cfg \ + functional/inheritance/state003.cfg \ + functional/inheritance/state004.cfg \ + functional/inheritance/state005.cfg \ + functional/inheritance/state006.cfg \ + functional/inheritance/state007.cfg \ + functional/inheritance/state008.cfg \ + functional/inheritance/state009.cfg \ + functional/inheritance/state010.cfg \ + functional/inheritance/state011.cfg \ + functional/inheritance/state012.cfg \ + functional/inheritance/state013.cfg \ + functional/inheritance/state014.cfg \ + functional/inheritance/state015.cfg \ + functional/inheritance/state016.cfg \ + functional/inheritance/state017.cfg \ + functional/inheritance/state018.cfg \ + functional/inheritance/state019.cfg \ + functional/inheritance/state020.cfg \ + functional/inheritance/state021.cfg \ + functional/inheritance/state022.cfg \ + functional/inheritance/state023.cfg \ + functional/inheritance/state024.cfg \ + functional/inuse/inuse.cfg \ + functional/io/io.cfg \ + functional/l2arc/l2arc.cfg \ + functional/largest_pool/largest_pool.cfg \ + functional/migration/migration.cfg \ + functional/migration/migration.kshlib \ + functional/mmap/mmap.cfg \ + functional/mmp/mmp.cfg \ + functional/mmp/mmp.kshlib \ + functional/mv_files/mv_files.cfg \ + functional/mv_files/mv_files_common.kshlib \ + functional/nopwrite/nopwrite.shlib \ + functional/no_space/enospc.cfg \ + functional/online_offline/online_offline.cfg \ + functional/pool_checkpoint/pool_checkpoint.kshlib \ + functional/projectquota/projectquota.cfg \ + functional/projectquota/projectquota_common.kshlib \ + functional/quota/quota.cfg \ + functional/quota/quota.kshlib \ + functional/redacted_send/redacted.cfg \ + functional/redacted_send/redacted.kshlib \ + functional/redundancy/redundancy.cfg \ + functional/redundancy/redundancy.kshlib \ + functional/refreserv/refreserv.cfg \ + functional/removal/removal.kshlib \ + functional/replacement/replacement.cfg \ + functional/reservation/reservation.cfg \ + functional/reservation/reservation.shlib \ + functional/rsend/dedup_encrypted_zvol.bz2 \ + functional/rsend/dedup_encrypted_zvol.zsend.bz2 \ + functional/rsend/dedup.zsend.bz2 \ + functional/rsend/fs.tar.gz \ + functional/rsend/rsend.cfg \ + functional/rsend/rsend.kshlib \ + functional/scrub_mirror/default.cfg \ + functional/scrub_mirror/scrub_mirror_common.kshlib \ + functional/slog/slog.cfg \ + functional/slog/slog.kshlib \ + functional/snapshot/snapshot.cfg \ + functional/snapused/snapused.kshlib \ + functional/sparse/sparse.cfg \ + functional/trim/trim.cfg \ + functional/trim/trim.kshlib \ + functional/truncate/truncate.cfg \ + functional/upgrade/upgrade_common.kshlib \ + functional/user_namespace/user_namespace.cfg \ + functional/user_namespace/user_namespace_common.kshlib \ + functional/userquota/userquota.cfg \ + functional/userquota/userquota_common.kshlib \ + functional/vdev_zaps/vdev_zaps.kshlib \ + functional/xattr/xattr.cfg \ + functional/xattr/xattr_common.kshlib \ + functional/zvol/zvol.cfg \ + functional/zvol/zvol_cli/zvol_cli.cfg \ + functional/zvol/zvol_common.shlib \ + functional/zvol/zvol_ENOSPC/zvol_ENOSPC.cfg \ + functional/zvol/zvol_misc/zvol_misc_common.kshlib \ + functional/zvol/zvol_swap/zvol_swap.cfg + +nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \ + functional/acl/off/cleanup.ksh \ + functional/acl/off/dosmode.ksh \ + functional/acl/off/posixmode.ksh \ + functional/acl/off/setup.ksh \ + functional/acl/posix/cleanup.ksh \ + functional/acl/posix/posix_001_pos.ksh \ + functional/acl/posix/posix_002_pos.ksh \ + functional/acl/posix/posix_003_pos.ksh \ + functional/acl/posix/posix_004_pos.ksh \ + functional/acl/posix-sa/cleanup.ksh \ + functional/acl/posix-sa/posix_001_pos.ksh \ + functional/acl/posix-sa/posix_002_pos.ksh \ + functional/acl/posix-sa/posix_003_pos.ksh \ + functional/acl/posix-sa/posix_004_pos.ksh \ + functional/acl/posix-sa/setup.ksh \ + functional/acl/posix/setup.ksh \ + functional/alloc_class/alloc_class_001_pos.ksh \ + functional/alloc_class/alloc_class_002_neg.ksh \ + functional/alloc_class/alloc_class_003_pos.ksh \ + functional/alloc_class/alloc_class_004_pos.ksh \ + functional/alloc_class/alloc_class_005_pos.ksh \ + functional/alloc_class/alloc_class_006_pos.ksh \ + functional/alloc_class/alloc_class_007_pos.ksh \ + functional/alloc_class/alloc_class_008_pos.ksh \ + functional/alloc_class/alloc_class_009_pos.ksh \ + functional/alloc_class/alloc_class_010_pos.ksh \ + functional/alloc_class/alloc_class_011_neg.ksh \ + functional/alloc_class/alloc_class_012_pos.ksh \ + functional/alloc_class/alloc_class_013_pos.ksh \ + functional/alloc_class/cleanup.ksh \ + functional/alloc_class/setup.ksh \ + functional/append/file_append.ksh \ + functional/append/threadsappend_001_pos.ksh \ + functional/append/cleanup.ksh \ + functional/append/setup.ksh \ + functional/arc/arcstats_runtime_tuning.ksh \ + functional/arc/cleanup.ksh \ + functional/arc/dbufstats_001_pos.ksh \ + functional/arc/dbufstats_002_pos.ksh \ + functional/arc/dbufstats_003_pos.ksh \ + functional/arc/setup.ksh \ + functional/atime/atime_001_pos.ksh \ + functional/atime/atime_002_neg.ksh \ + functional/atime/atime_003_pos.ksh \ + functional/atime/cleanup.ksh \ + functional/atime/root_atime_off.ksh \ + functional/atime/root_atime_on.ksh \ + functional/atime/root_relatime_on.ksh \ + functional/atime/setup.ksh \ + functional/bootfs/bootfs_001_pos.ksh \ + functional/bootfs/bootfs_002_neg.ksh \ + functional/bootfs/bootfs_003_pos.ksh \ + functional/bootfs/bootfs_004_neg.ksh \ + functional/bootfs/bootfs_005_neg.ksh \ + functional/bootfs/bootfs_006_pos.ksh \ + functional/bootfs/bootfs_007_pos.ksh \ + functional/bootfs/bootfs_008_pos.ksh \ + functional/bootfs/cleanup.ksh \ + functional/bootfs/setup.ksh \ + functional/btree/btree_negative.ksh \ + functional/btree/btree_positive.ksh \ + functional/cache/cache_001_pos.ksh \ + functional/cache/cache_002_pos.ksh \ + functional/cache/cache_003_pos.ksh \ + functional/cache/cache_004_neg.ksh \ + functional/cache/cache_005_neg.ksh \ + functional/cache/cache_006_pos.ksh \ + functional/cache/cache_007_neg.ksh \ + functional/cache/cache_008_neg.ksh \ + functional/cache/cache_009_pos.ksh \ + functional/cache/cache_010_pos.ksh \ + functional/cache/cache_011_pos.ksh \ + functional/cache/cache_012_pos.ksh \ + functional/cache/cleanup.ksh \ + functional/cachefile/cachefile_001_pos.ksh \ + functional/cachefile/cachefile_002_pos.ksh \ + functional/cachefile/cachefile_003_pos.ksh \ + functional/cachefile/cachefile_004_pos.ksh \ + functional/cachefile/cleanup.ksh \ + functional/cachefile/setup.ksh \ + functional/cache/setup.ksh \ + functional/casenorm/case_all_values.ksh \ + functional/casenorm/cleanup.ksh \ + functional/casenorm/insensitive_formd_delete.ksh \ + functional/casenorm/insensitive_formd_lookup.ksh \ + functional/casenorm/insensitive_none_delete.ksh \ + functional/casenorm/insensitive_none_lookup.ksh \ + functional/casenorm/mixed_create_failure.ksh \ + functional/casenorm/mixed_formd_delete.ksh \ + functional/casenorm/mixed_formd_lookup_ci.ksh \ + functional/casenorm/mixed_formd_lookup.ksh \ + functional/casenorm/mixed_none_delete.ksh \ + functional/casenorm/mixed_none_lookup_ci.ksh \ + functional/casenorm/mixed_none_lookup.ksh \ + functional/casenorm/norm_all_values.ksh \ + functional/casenorm/sensitive_formd_delete.ksh \ + functional/casenorm/sensitive_formd_lookup.ksh \ + functional/casenorm/sensitive_none_delete.ksh \ + functional/casenorm/sensitive_none_lookup.ksh \ + functional/casenorm/setup.ksh \ + functional/channel_program/lua_core/cleanup.ksh \ + functional/channel_program/lua_core/setup.ksh \ + functional/channel_program/lua_core/tst.args_to_lua.ksh \ + functional/channel_program/lua_core/tst.divide_by_zero.ksh \ + functional/channel_program/lua_core/tst.exists.ksh \ + functional/channel_program/lua_core/tst.integer_illegal.ksh \ + functional/channel_program/lua_core/tst.integer_overflow.ksh \ + functional/channel_program/lua_core/tst.language_functions_neg.ksh \ + functional/channel_program/lua_core/tst.language_functions_pos.ksh \ + functional/channel_program/lua_core/tst.large_prog.ksh \ + functional/channel_program/lua_core/tst.libraries.ksh \ + functional/channel_program/lua_core/tst.memory_limit.ksh \ + functional/channel_program/lua_core/tst.nested_neg.ksh \ + functional/channel_program/lua_core/tst.nested_pos.ksh \ + functional/channel_program/lua_core/tst.nvlist_to_lua.ksh \ + functional/channel_program/lua_core/tst.recursive_neg.ksh \ + functional/channel_program/lua_core/tst.recursive_pos.ksh \ + functional/channel_program/lua_core/tst.return_large.ksh \ + functional/channel_program/lua_core/tst.return_nvlist_neg.ksh \ + functional/channel_program/lua_core/tst.return_nvlist_pos.ksh \ + functional/channel_program/lua_core/tst.return_recursive_table.ksh \ + functional/channel_program/lua_core/tst.stack_gsub.ksh \ + functional/channel_program/lua_core/tst.timeout.ksh \ + functional/channel_program/synctask_core/cleanup.ksh \ + functional/channel_program/synctask_core/setup.ksh \ + functional/channel_program/synctask_core/tst.bookmark.copy.ksh \ + functional/channel_program/synctask_core/tst.bookmark.create.ksh \ + functional/channel_program/synctask_core/tst.destroy_fs.ksh \ + functional/channel_program/synctask_core/tst.destroy_snap.ksh \ + functional/channel_program/synctask_core/tst.get_count_and_limit.ksh \ + functional/channel_program/synctask_core/tst.get_index_props.ksh \ + functional/channel_program/synctask_core/tst.get_mountpoint.ksh \ + functional/channel_program/synctask_core/tst.get_neg.ksh \ + functional/channel_program/synctask_core/tst.get_number_props.ksh \ + functional/channel_program/synctask_core/tst.get_string_props.ksh \ + functional/channel_program/synctask_core/tst.get_type.ksh \ + functional/channel_program/synctask_core/tst.get_userquota.ksh \ + functional/channel_program/synctask_core/tst.get_written.ksh \ + functional/channel_program/synctask_core/tst.inherit.ksh \ + functional/channel_program/synctask_core/tst.list_bookmarks.ksh \ + functional/channel_program/synctask_core/tst.list_children.ksh \ + functional/channel_program/synctask_core/tst.list_clones.ksh \ + functional/channel_program/synctask_core/tst.list_holds.ksh \ + functional/channel_program/synctask_core/tst.list_snapshots.ksh \ + functional/channel_program/synctask_core/tst.list_system_props.ksh \ + functional/channel_program/synctask_core/tst.list_user_props.ksh \ + functional/channel_program/synctask_core/tst.parse_args_neg.ksh \ + functional/channel_program/synctask_core/tst.promote_conflict.ksh \ + functional/channel_program/synctask_core/tst.promote_multiple.ksh \ + functional/channel_program/synctask_core/tst.promote_simple.ksh \ + functional/channel_program/synctask_core/tst.rollback_mult.ksh \ + functional/channel_program/synctask_core/tst.rollback_one.ksh \ + functional/channel_program/synctask_core/tst.set_props.ksh \ + functional/channel_program/synctask_core/tst.snapshot_destroy.ksh \ + functional/channel_program/synctask_core/tst.snapshot_neg.ksh \ + functional/channel_program/synctask_core/tst.snapshot_recursive.ksh \ + functional/channel_program/synctask_core/tst.snapshot_simple.ksh \ + functional/channel_program/synctask_core/tst.terminate_by_signal.ksh \ + functional/chattr/chattr_001_pos.ksh \ + functional/chattr/chattr_002_neg.ksh \ + functional/chattr/cleanup.ksh \ + functional/chattr/setup.ksh \ + functional/checksum/cleanup.ksh \ + functional/checksum/filetest_001_pos.ksh \ + functional/checksum/filetest_002_pos.ksh \ + functional/checksum/run_edonr_test.ksh \ + functional/checksum/run_sha2_test.ksh \ + functional/checksum/run_skein_test.ksh \ + functional/checksum/setup.ksh \ + functional/clean_mirror/clean_mirror_001_pos.ksh \ + functional/clean_mirror/clean_mirror_002_pos.ksh \ + functional/clean_mirror/clean_mirror_003_pos.ksh \ + functional/clean_mirror/clean_mirror_004_pos.ksh \ + functional/clean_mirror/cleanup.ksh \ + functional/clean_mirror/setup.ksh \ + functional/cli_root/zdb/zdb_002_pos.ksh \ + functional/cli_root/zdb/zdb_003_pos.ksh \ + functional/cli_root/zdb/zdb_004_pos.ksh \ + functional/cli_root/zdb/zdb_005_pos.ksh \ + functional/cli_root/zdb/zdb_006_pos.ksh \ + functional/cli_root/zdb/zdb_args_neg.ksh \ + functional/cli_root/zdb/zdb_args_pos.ksh \ + functional/cli_root/zdb/zdb_block_size_histogram.ksh \ + functional/cli_root/zdb/zdb_checksum.ksh \ + functional/cli_root/zdb/zdb_decompress.ksh \ + functional/cli_root/zdb/zdb_decompress_zstd.ksh \ + functional/cli_root/zdb/zdb_display_block.ksh \ + functional/cli_root/zdb/zdb_label_checksum.ksh \ + functional/cli_root/zdb/zdb_object_range_neg.ksh \ + functional/cli_root/zdb/zdb_object_range_pos.ksh \ + functional/cli_root/zdb/zdb_objset_id.ksh \ + functional/cli_root/zdb/zdb_recover_2.ksh \ + functional/cli_root/zdb/zdb_recover.ksh \ + functional/cli_root/zfs_bookmark/cleanup.ksh \ + functional/cli_root/zfs_bookmark/setup.ksh \ + functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh \ + functional/cli_root/zfs_change-key/cleanup.ksh \ + functional/cli_root/zfs_change-key/setup.ksh \ + functional/cli_root/zfs_change-key/zfs_change-key_child.ksh \ + functional/cli_root/zfs_change-key/zfs_change-key_clones.ksh \ + functional/cli_root/zfs_change-key/zfs_change-key_format.ksh \ + functional/cli_root/zfs_change-key/zfs_change-key_inherit.ksh \ + functional/cli_root/zfs_change-key/zfs_change-key.ksh \ + functional/cli_root/zfs_change-key/zfs_change-key_load.ksh \ + functional/cli_root/zfs_change-key/zfs_change-key_location.ksh \ + functional/cli_root/zfs_change-key/zfs_change-key_pbkdf2iters.ksh \ + functional/cli_root/zfs/cleanup.ksh \ + functional/cli_root/zfs_clone/cleanup.ksh \ + functional/cli_root/zfs_clone/setup.ksh \ + functional/cli_root/zfs_clone/zfs_clone_001_neg.ksh \ + functional/cli_root/zfs_clone/zfs_clone_002_pos.ksh \ + functional/cli_root/zfs_clone/zfs_clone_003_pos.ksh \ + functional/cli_root/zfs_clone/zfs_clone_004_pos.ksh \ + functional/cli_root/zfs_clone/zfs_clone_005_pos.ksh \ + functional/cli_root/zfs_clone/zfs_clone_006_pos.ksh \ + functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh \ + functional/cli_root/zfs_clone/zfs_clone_008_neg.ksh \ + functional/cli_root/zfs_clone/zfs_clone_009_neg.ksh \ + functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh \ + functional/cli_root/zfs_clone/zfs_clone_deeply_nested.ksh \ + functional/cli_root/zfs_clone/zfs_clone_encrypted.ksh \ + functional/cli_root/zfs_clone/zfs_clone_rm_nested.ksh \ + functional/cli_root/zfs_copies/cleanup.ksh \ + functional/cli_root/zfs_copies/setup.ksh \ + functional/cli_root/zfs_copies/zfs_copies_001_pos.ksh \ + functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh \ + functional/cli_root/zfs_copies/zfs_copies_003_pos.ksh \ + functional/cli_root/zfs_copies/zfs_copies_004_neg.ksh \ + functional/cli_root/zfs_copies/zfs_copies_005_neg.ksh \ + functional/cli_root/zfs_copies/zfs_copies_006_pos.ksh \ + functional/cli_root/zfs_create/cleanup.ksh \ + functional/cli_root/zfs_create/setup.ksh \ + functional/cli_root/zfs_create/zfs_create_001_pos.ksh \ + functional/cli_root/zfs_create/zfs_create_002_pos.ksh \ + functional/cli_root/zfs_create/zfs_create_003_pos.ksh \ + functional/cli_root/zfs_create/zfs_create_004_pos.ksh \ + functional/cli_root/zfs_create/zfs_create_005_pos.ksh \ + functional/cli_root/zfs_create/zfs_create_006_pos.ksh \ + functional/cli_root/zfs_create/zfs_create_007_pos.ksh \ + functional/cli_root/zfs_create/zfs_create_008_neg.ksh \ + functional/cli_root/zfs_create/zfs_create_009_neg.ksh \ + functional/cli_root/zfs_create/zfs_create_010_neg.ksh \ + functional/cli_root/zfs_create/zfs_create_011_pos.ksh \ + functional/cli_root/zfs_create/zfs_create_012_pos.ksh \ + functional/cli_root/zfs_create/zfs_create_013_pos.ksh \ + functional/cli_root/zfs_create/zfs_create_014_pos.ksh \ + functional/cli_root/zfs_create/zfs_create_crypt_combos.ksh \ + functional/cli_root/zfs_create/zfs_create_dryrun.ksh \ + functional/cli_root/zfs_create/zfs_create_encrypted.ksh \ + functional/cli_root/zfs_create/zfs_create_nomount.ksh \ + functional/cli_root/zfs_create/zfs_create_verbose.ksh \ + functional/cli_root/zfs_destroy/cleanup.ksh \ + functional/cli_root/zfs_destroy/setup.ksh \ + functional/cli_root/zfs_destroy/zfs_clone_livelist_condense_and_disable.ksh \ + functional/cli_root/zfs_destroy/zfs_clone_livelist_condense_races.ksh \ + functional/cli_root/zfs_destroy/zfs_clone_livelist_dedup.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_001_pos.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_002_pos.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_003_pos.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_005_neg.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_006_neg.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_007_neg.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_008_pos.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_009_pos.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_010_pos.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_011_pos.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_012_pos.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_013_neg.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_014_pos.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_015_pos.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_016_pos.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_clone_livelist.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_dev_removal_condense.ksh \ + functional/cli_root/zfs_destroy/zfs_destroy_dev_removal.ksh \ + functional/cli_root/zfs_diff/cleanup.ksh \ + functional/cli_root/zfs_diff/setup.ksh \ + functional/cli_root/zfs_diff/zfs_diff_changes.ksh \ + functional/cli_root/zfs_diff/zfs_diff_cliargs.ksh \ + functional/cli_root/zfs_diff/zfs_diff_encrypted.ksh \ + functional/cli_root/zfs_diff/zfs_diff_mangle.ksh \ + functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh \ + functional/cli_root/zfs_diff/zfs_diff_types.ksh \ + functional/cli_root/zfs_get/cleanup.ksh \ + functional/cli_root/zfs_get/setup.ksh \ + functional/cli_root/zfs_get/zfs_get_001_pos.ksh \ + functional/cli_root/zfs_get/zfs_get_002_pos.ksh \ + functional/cli_root/zfs_get/zfs_get_003_pos.ksh \ + functional/cli_root/zfs_get/zfs_get_004_pos.ksh \ + functional/cli_root/zfs_get/zfs_get_005_neg.ksh \ + functional/cli_root/zfs_get/zfs_get_006_neg.ksh \ + functional/cli_root/zfs_get/zfs_get_007_neg.ksh \ + functional/cli_root/zfs_get/zfs_get_008_pos.ksh \ + functional/cli_root/zfs_get/zfs_get_009_pos.ksh \ + functional/cli_root/zfs_get/zfs_get_010_neg.ksh \ + functional/cli_root/zfs_ids_to_path/cleanup.ksh \ + functional/cli_root/zfs_ids_to_path/setup.ksh \ + functional/cli_root/zfs_ids_to_path/zfs_ids_to_path_001_pos.ksh \ + functional/cli_root/zfs_inherit/cleanup.ksh \ + functional/cli_root/zfs_inherit/setup.ksh \ + functional/cli_root/zfs_inherit/zfs_inherit_001_neg.ksh \ + functional/cli_root/zfs_inherit/zfs_inherit_002_neg.ksh \ + functional/cli_root/zfs_inherit/zfs_inherit_003_pos.ksh \ + functional/cli_root/zfs_inherit/zfs_inherit_mountpoint.ksh \ + functional/cli_root/zfs_jail/cleanup.ksh \ + functional/cli_root/zfs_jail/setup.ksh \ + functional/cli_root/zfs_jail/zfs_jail_001_pos.ksh \ + functional/cli_root/zfs_load-key/cleanup.ksh \ + functional/cli_root/zfs_load-key/setup.ksh \ + functional/cli_root/zfs_load-key/zfs_load-key_all.ksh \ + functional/cli_root/zfs_load-key/zfs_load-key_file.ksh \ + functional/cli_root/zfs_load-key/zfs_load-key_https.ksh \ + functional/cli_root/zfs_load-key/zfs_load-key.ksh \ + functional/cli_root/zfs_load-key/zfs_load-key_location.ksh \ + functional/cli_root/zfs_load-key/zfs_load-key_noop.ksh \ + functional/cli_root/zfs_load-key/zfs_load-key_recursive.ksh \ + functional/cli_root/zfs_mount/cleanup.ksh \ + functional/cli_root/zfs_mount/setup.ksh \ + functional/cli_root/zfs_mount/zfs_mount_001_pos.ksh \ + functional/cli_root/zfs_mount/zfs_mount_002_pos.ksh \ + functional/cli_root/zfs_mount/zfs_mount_003_pos.ksh \ + functional/cli_root/zfs_mount/zfs_mount_004_pos.ksh \ + functional/cli_root/zfs_mount/zfs_mount_005_pos.ksh \ + functional/cli_root/zfs_mount/zfs_mount_006_pos.ksh \ + functional/cli_root/zfs_mount/zfs_mount_007_pos.ksh \ + functional/cli_root/zfs_mount/zfs_mount_008_pos.ksh \ + functional/cli_root/zfs_mount/zfs_mount_009_neg.ksh \ + functional/cli_root/zfs_mount/zfs_mount_010_neg.ksh \ + functional/cli_root/zfs_mount/zfs_mount_011_neg.ksh \ + functional/cli_root/zfs_mount/zfs_mount_012_pos.ksh \ + functional/cli_root/zfs_mount/zfs_mount_013_pos.ksh \ + functional/cli_root/zfs_mount/zfs_mount_014_neg.ksh \ + functional/cli_root/zfs_mount/zfs_mount_all_001_pos.ksh \ + functional/cli_root/zfs_mount/zfs_mount_all_fail.ksh \ + functional/cli_root/zfs_mount/zfs_mount_all_mountpoints.ksh \ + functional/cli_root/zfs_mount/zfs_mount_encrypted.ksh \ + functional/cli_root/zfs_mount/zfs_mount_remount.ksh \ + functional/cli_root/zfs_mount/zfs_mount_test_race.ksh \ + functional/cli_root/zfs_mount/zfs_multi_mount.ksh \ + functional/cli_root/zfs_program/cleanup.ksh \ + functional/cli_root/zfs_program/setup.ksh \ + functional/cli_root/zfs_program/zfs_program_json.ksh \ + functional/cli_root/zfs_promote/cleanup.ksh \ + functional/cli_root/zfs_promote/setup.ksh \ + functional/cli_root/zfs_promote/zfs_promote_001_pos.ksh \ + functional/cli_root/zfs_promote/zfs_promote_002_pos.ksh \ + functional/cli_root/zfs_promote/zfs_promote_003_pos.ksh \ + functional/cli_root/zfs_promote/zfs_promote_004_pos.ksh \ + functional/cli_root/zfs_promote/zfs_promote_005_pos.ksh \ + functional/cli_root/zfs_promote/zfs_promote_006_neg.ksh \ + functional/cli_root/zfs_promote/zfs_promote_007_neg.ksh \ + functional/cli_root/zfs_promote/zfs_promote_008_pos.ksh \ + functional/cli_root/zfs_promote/zfs_promote_encryptionroot.ksh \ + functional/cli_root/zfs_property/cleanup.ksh \ + functional/cli_root/zfs_property/setup.ksh \ + functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh \ + functional/cli_root/zfs_receive/cleanup.ksh \ + functional/cli_root/zfs_receive/receive-o-x_props_aliases.ksh \ + functional/cli_root/zfs_receive/receive-o-x_props_override.ksh \ + functional/cli_root/zfs_receive/setup.ksh \ + functional/cli_root/zfs_receive/zfs_receive_001_pos.ksh \ + functional/cli_root/zfs_receive/zfs_receive_002_pos.ksh \ + functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh \ + functional/cli_root/zfs_receive/zfs_receive_004_neg.ksh \ + functional/cli_root/zfs_receive/zfs_receive_005_neg.ksh \ + functional/cli_root/zfs_receive/zfs_receive_006_pos.ksh \ + functional/cli_root/zfs_receive/zfs_receive_007_neg.ksh \ + functional/cli_root/zfs_receive/zfs_receive_008_pos.ksh \ + functional/cli_root/zfs_receive/zfs_receive_009_neg.ksh \ + functional/cli_root/zfs_receive/zfs_receive_010_pos.ksh \ + functional/cli_root/zfs_receive/zfs_receive_011_pos.ksh \ + functional/cli_root/zfs_receive/zfs_receive_012_pos.ksh \ + functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh \ + functional/cli_root/zfs_receive/zfs_receive_014_pos.ksh \ + functional/cli_root/zfs_receive/zfs_receive_015_pos.ksh \ + functional/cli_root/zfs_receive/zfs_receive_016_pos.ksh \ + functional/cli_root/zfs_receive/zfs_receive_-e.ksh \ + functional/cli_root/zfs_receive/zfs_receive_from_encrypted.ksh \ + functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh \ + functional/cli_root/zfs_receive/zfs_receive_new_props.ksh \ + functional/cli_root/zfs_receive/zfs_receive_raw_-d.ksh \ + functional/cli_root/zfs_receive/zfs_receive_raw_incremental.ksh \ + functional/cli_root/zfs_receive/zfs_receive_raw.ksh \ + functional/cli_root/zfs_receive/zfs_receive_to_encrypted.ksh \ + functional/cli_root/zfs_receive/zfs_receive_-wR-encrypted-mix.ksh \ + functional/cli_root/zfs_rename/cleanup.ksh \ + functional/cli_root/zfs_rename/setup.ksh \ + functional/cli_root/zfs_rename/zfs_rename_001_pos.ksh \ + functional/cli_root/zfs_rename/zfs_rename_002_pos.ksh \ + functional/cli_root/zfs_rename/zfs_rename_003_pos.ksh \ + functional/cli_root/zfs_rename/zfs_rename_004_neg.ksh \ + functional/cli_root/zfs_rename/zfs_rename_005_neg.ksh \ + functional/cli_root/zfs_rename/zfs_rename_006_pos.ksh \ + functional/cli_root/zfs_rename/zfs_rename_007_pos.ksh \ + functional/cli_root/zfs_rename/zfs_rename_008_pos.ksh \ + functional/cli_root/zfs_rename/zfs_rename_009_neg.ksh \ + functional/cli_root/zfs_rename/zfs_rename_010_neg.ksh \ + functional/cli_root/zfs_rename/zfs_rename_011_pos.ksh \ + functional/cli_root/zfs_rename/zfs_rename_012_neg.ksh \ + functional/cli_root/zfs_rename/zfs_rename_013_pos.ksh \ + functional/cli_root/zfs_rename/zfs_rename_014_neg.ksh \ + functional/cli_root/zfs_rename/zfs_rename_encrypted_child.ksh \ + functional/cli_root/zfs_rename/zfs_rename_mountpoint.ksh \ + functional/cli_root/zfs_rename/zfs_rename_nounmount.ksh \ + functional/cli_root/zfs_rename/zfs_rename_to_encrypted.ksh \ + functional/cli_root/zfs_reservation/cleanup.ksh \ + functional/cli_root/zfs_reservation/setup.ksh \ + functional/cli_root/zfs_reservation/zfs_reservation_001_pos.ksh \ + functional/cli_root/zfs_reservation/zfs_reservation_002_pos.ksh \ + functional/cli_root/zfs_rollback/cleanup.ksh \ + functional/cli_root/zfs_rollback/setup.ksh \ + functional/cli_root/zfs_rollback/zfs_rollback_001_pos.ksh \ + functional/cli_root/zfs_rollback/zfs_rollback_002_pos.ksh \ + functional/cli_root/zfs_rollback/zfs_rollback_003_neg.ksh \ + functional/cli_root/zfs_rollback/zfs_rollback_004_neg.ksh \ + functional/cli_root/zfs_send/cleanup.ksh \ + functional/cli_root/zfs_send/setup.ksh \ + functional/cli_root/zfs_send/zfs_send_001_pos.ksh \ + functional/cli_root/zfs_send/zfs_send_002_pos.ksh \ + functional/cli_root/zfs_send/zfs_send_003_pos.ksh \ + functional/cli_root/zfs_send/zfs_send_004_neg.ksh \ + functional/cli_root/zfs_send/zfs_send_005_pos.ksh \ + functional/cli_root/zfs_send/zfs_send_006_pos.ksh \ + functional/cli_root/zfs_send/zfs_send_007_pos.ksh \ + functional/cli_root/zfs_send/zfs_send-b.ksh \ + functional/cli_root/zfs_send/zfs_send_encrypted.ksh \ + functional/cli_root/zfs_send/zfs_send_encrypted_unloaded.ksh \ + functional/cli_root/zfs_send/zfs_send_raw.ksh \ + functional/cli_root/zfs_send/zfs_send_skip_missing.ksh \ + functional/cli_root/zfs_send/zfs_send_sparse.ksh \ + functional/cli_root/zfs_set/cache_001_pos.ksh \ + functional/cli_root/zfs_set/cache_002_neg.ksh \ + functional/cli_root/zfs_set/canmount_001_pos.ksh \ + functional/cli_root/zfs_set/canmount_002_pos.ksh \ + functional/cli_root/zfs_set/canmount_003_pos.ksh \ + functional/cli_root/zfs_set/canmount_004_pos.ksh \ + functional/cli_root/zfs_set/checksum_001_pos.ksh \ + functional/cli_root/zfs_set/cleanup.ksh \ + functional/cli_root/zfs_set/compression_001_pos.ksh \ + functional/cli_root/zfs_set/mountpoint_001_pos.ksh \ + functional/cli_root/zfs_set/mountpoint_002_pos.ksh \ + functional/cli_root/zfs_set/mountpoint_003_pos.ksh \ + functional/cli_root/zfs_set/onoffs_001_pos.ksh \ + functional/cli_root/zfs_set/property_alias_001_pos.ksh \ + functional/cli_root/zfs_set/readonly_001_pos.ksh \ + functional/cli_root/zfs_set/reservation_001_neg.ksh \ + functional/cli_root/zfs_set/ro_props_001_pos.ksh \ + functional/cli_root/zfs_set/setup.ksh \ + functional/cli_root/zfs_set/share_mount_001_neg.ksh \ + functional/cli_root/zfs_set/snapdir_001_pos.ksh \ + functional/cli_root/zfs/setup.ksh \ + functional/cli_root/zfs_set/user_property_001_pos.ksh \ + functional/cli_root/zfs_set/user_property_002_pos.ksh \ + functional/cli_root/zfs_set/user_property_003_neg.ksh \ + functional/cli_root/zfs_set/user_property_004_pos.ksh \ + functional/cli_root/zfs_set/version_001_neg.ksh \ + functional/cli_root/zfs_set/zfs_set_001_neg.ksh \ + functional/cli_root/zfs_set/zfs_set_002_neg.ksh \ + functional/cli_root/zfs_set/zfs_set_003_neg.ksh \ + functional/cli_root/zfs_set/zfs_set_feature_activation.ksh \ + functional/cli_root/zfs_set/zfs_set_keylocation.ksh \ + functional/cli_root/zfs_share/cleanup.ksh \ + functional/cli_root/zfs_share/setup.ksh \ + functional/cli_root/zfs_share/zfs_share_001_pos.ksh \ + functional/cli_root/zfs_share/zfs_share_002_pos.ksh \ + functional/cli_root/zfs_share/zfs_share_003_pos.ksh \ + functional/cli_root/zfs_share/zfs_share_004_pos.ksh \ + functional/cli_root/zfs_share/zfs_share_005_pos.ksh \ + functional/cli_root/zfs_share/zfs_share_006_pos.ksh \ + functional/cli_root/zfs_share/zfs_share_007_neg.ksh \ + functional/cli_root/zfs_share/zfs_share_008_neg.ksh \ + functional/cli_root/zfs_share/zfs_share_009_neg.ksh \ + functional/cli_root/zfs_share/zfs_share_010_neg.ksh \ + functional/cli_root/zfs_share/zfs_share_011_pos.ksh \ + functional/cli_root/zfs_share/zfs_share_012_pos.ksh \ + functional/cli_root/zfs_share/zfs_share_013_pos.ksh \ + functional/cli_root/zfs_share/zfs_share_concurrent_shares.ksh \ + functional/cli_root/zfs_snapshot/cleanup.ksh \ + functional/cli_root/zfs_snapshot/setup.ksh \ + functional/cli_root/zfs_snapshot/zfs_snapshot_001_neg.ksh \ + functional/cli_root/zfs_snapshot/zfs_snapshot_002_neg.ksh \ + functional/cli_root/zfs_snapshot/zfs_snapshot_003_neg.ksh \ + functional/cli_root/zfs_snapshot/zfs_snapshot_004_neg.ksh \ + functional/cli_root/zfs_snapshot/zfs_snapshot_005_neg.ksh \ + functional/cli_root/zfs_snapshot/zfs_snapshot_006_pos.ksh \ + functional/cli_root/zfs_snapshot/zfs_snapshot_007_neg.ksh \ + functional/cli_root/zfs_snapshot/zfs_snapshot_008_neg.ksh \ + functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh \ + functional/cli_root/zfs_sysfs/cleanup.ksh \ + functional/cli_root/zfs_sysfs/setup.ksh \ + functional/cli_root/zfs_sysfs/zfeature_set_unsupported.ksh \ + functional/cli_root/zfs_sysfs/zfs_get_unsupported.ksh \ + functional/cli_root/zfs_sysfs/zfs_set_unsupported.ksh \ + functional/cli_root/zfs_sysfs/zfs_sysfs_live.ksh \ + functional/cli_root/zfs_sysfs/zpool_get_unsupported.ksh \ + functional/cli_root/zfs_sysfs/zpool_set_unsupported.ksh \ + functional/cli_root/zfs_unload-key/cleanup.ksh \ + functional/cli_root/zfs_unload-key/setup.ksh \ + functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh \ + functional/cli_root/zfs_unload-key/zfs_unload-key.ksh \ + functional/cli_root/zfs_unload-key/zfs_unload-key_recursive.ksh \ + functional/cli_root/zfs_unmount/cleanup.ksh \ + functional/cli_root/zfs_unmount/setup.ksh \ + functional/cli_root/zfs_unmount/zfs_unmount_001_pos.ksh \ + functional/cli_root/zfs_unmount/zfs_unmount_002_pos.ksh \ + functional/cli_root/zfs_unmount/zfs_unmount_003_pos.ksh \ + functional/cli_root/zfs_unmount/zfs_unmount_004_pos.ksh \ + functional/cli_root/zfs_unmount/zfs_unmount_005_pos.ksh \ + functional/cli_root/zfs_unmount/zfs_unmount_006_pos.ksh \ + functional/cli_root/zfs_unmount/zfs_unmount_007_neg.ksh \ + functional/cli_root/zfs_unmount/zfs_unmount_008_neg.ksh \ + functional/cli_root/zfs_unmount/zfs_unmount_009_pos.ksh \ + functional/cli_root/zfs_unmount/zfs_unmount_all_001_pos.ksh \ + functional/cli_root/zfs_unmount/zfs_unmount_nested.ksh \ + functional/cli_root/zfs_unmount/zfs_unmount_unload_keys.ksh \ + functional/cli_root/zfs_unshare/cleanup.ksh \ + functional/cli_root/zfs_unshare/setup.ksh \ + functional/cli_root/zfs_unshare/zfs_unshare_001_pos.ksh \ + functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh \ + functional/cli_root/zfs_unshare/zfs_unshare_003_pos.ksh \ + functional/cli_root/zfs_unshare/zfs_unshare_004_neg.ksh \ + functional/cli_root/zfs_unshare/zfs_unshare_005_neg.ksh \ + functional/cli_root/zfs_unshare/zfs_unshare_006_pos.ksh \ + functional/cli_root/zfs_unshare/zfs_unshare_007_pos.ksh \ + functional/cli_root/zfs_unshare/zfs_unshare_008_pos.ksh \ + functional/cli_root/zfs_upgrade/cleanup.ksh \ + functional/cli_root/zfs_upgrade/setup.ksh \ + functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh \ + functional/cli_root/zfs_upgrade/zfs_upgrade_002_pos.ksh \ + functional/cli_root/zfs_upgrade/zfs_upgrade_003_pos.ksh \ + functional/cli_root/zfs_upgrade/zfs_upgrade_004_pos.ksh \ + functional/cli_root/zfs_upgrade/zfs_upgrade_005_pos.ksh \ + functional/cli_root/zfs_upgrade/zfs_upgrade_006_neg.ksh \ + functional/cli_root/zfs_upgrade/zfs_upgrade_007_neg.ksh \ + functional/cli_root/zfs_wait/cleanup.ksh \ + functional/cli_root/zfs_wait/setup.ksh \ + functional/cli_root/zfs_wait/zfs_wait_deleteq.ksh \ + functional/cli_root/zfs_wait/zfs_wait_getsubopt.ksh \ + functional/cli_root/zfs/zfs_001_neg.ksh \ + functional/cli_root/zfs/zfs_002_pos.ksh \ + functional/cli_root/zfs/zfs_003_neg.ksh \ + functional/cli_root/zhack/zhack_label_checksum.ksh \ + functional/cli_root/zpool_add/add_nested_replacing_spare.ksh \ + functional/cli_root/zpool_add/add-o_ashift.ksh \ + functional/cli_root/zpool_add/add_prop_ashift.ksh \ + functional/cli_root/zpool_add/cleanup.ksh \ + functional/cli_root/zpool_add/setup.ksh \ + functional/cli_root/zpool_add/zpool_add_001_pos.ksh \ + functional/cli_root/zpool_add/zpool_add_002_pos.ksh \ + functional/cli_root/zpool_add/zpool_add_003_pos.ksh \ + functional/cli_root/zpool_add/zpool_add_004_pos.ksh \ + functional/cli_root/zpool_add/zpool_add_005_pos.ksh \ + functional/cli_root/zpool_add/zpool_add_006_pos.ksh \ + functional/cli_root/zpool_add/zpool_add_007_neg.ksh \ + functional/cli_root/zpool_add/zpool_add_008_neg.ksh \ + functional/cli_root/zpool_add/zpool_add_009_neg.ksh \ + functional/cli_root/zpool_add/zpool_add_010_pos.ksh \ + functional/cli_root/zpool_add/zpool_add_dryrun_output.ksh \ + functional/cli_root/zpool_attach/attach-o_ashift.ksh \ + functional/cli_root/zpool_attach/cleanup.ksh \ + functional/cli_root/zpool_attach/setup.ksh \ + functional/cli_root/zpool_attach/zpool_attach_001_neg.ksh \ + functional/cli_root/zpool/cleanup.ksh \ + functional/cli_root/zpool_clear/cleanup.ksh \ + functional/cli_root/zpool_clear/setup.ksh \ + functional/cli_root/zpool_clear/zpool_clear_001_pos.ksh \ + functional/cli_root/zpool_clear/zpool_clear_002_neg.ksh \ + functional/cli_root/zpool_clear/zpool_clear_003_neg.ksh \ + functional/cli_root/zpool_clear/zpool_clear_readonly.ksh \ + functional/cli_root/zpool_create/cleanup.ksh \ + functional/cli_root/zpool_create/create-o_ashift.ksh \ + functional/cli_root/zpool_create/setup.ksh \ + functional/cli_root/zpool_create/zpool_create_001_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_002_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_003_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_004_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_005_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_006_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_007_neg.ksh \ + functional/cli_root/zpool_create/zpool_create_008_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_009_neg.ksh \ + functional/cli_root/zpool_create/zpool_create_010_neg.ksh \ + functional/cli_root/zpool_create/zpool_create_011_neg.ksh \ + functional/cli_root/zpool_create/zpool_create_012_neg.ksh \ + functional/cli_root/zpool_create/zpool_create_014_neg.ksh \ + functional/cli_root/zpool_create/zpool_create_015_neg.ksh \ + functional/cli_root/zpool_create/zpool_create_016_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_017_neg.ksh \ + functional/cli_root/zpool_create/zpool_create_018_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_019_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_020_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_021_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_022_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_023_neg.ksh \ + functional/cli_root/zpool_create/zpool_create_024_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_crypt_combos.ksh \ + functional/cli_root/zpool_create/zpool_create_draid_001_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_draid_002_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_draid_003_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_draid_004_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_dryrun_output.ksh \ + functional/cli_root/zpool_create/zpool_create_encrypted.ksh \ + functional/cli_root/zpool_create/zpool_create_features_001_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_features_002_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_features_003_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_features_004_neg.ksh \ + functional/cli_root/zpool_create/zpool_create_features_005_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_features_006_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_features_007_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_features_008_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_features_009_pos.ksh \ + functional/cli_root/zpool_create/zpool_create_tempname.ksh \ + functional/cli_root/zpool_destroy/zpool_destroy_001_pos.ksh \ + functional/cli_root/zpool_destroy/zpool_destroy_002_pos.ksh \ + functional/cli_root/zpool_destroy/zpool_destroy_003_neg.ksh \ + functional/cli_root/zpool_detach/cleanup.ksh \ + functional/cli_root/zpool_detach/setup.ksh \ + functional/cli_root/zpool_detach/zpool_detach_001_neg.ksh \ + functional/cli_root/zpool_events/cleanup.ksh \ + functional/cli_root/zpool_events/setup.ksh \ + functional/cli_root/zpool_events/zpool_events_clear.ksh \ + functional/cli_root/zpool_events/zpool_events_clear_retained.ksh \ + functional/cli_root/zpool_events/zpool_events_cliargs.ksh \ + functional/cli_root/zpool_events/zpool_events_duplicates.ksh \ + functional/cli_root/zpool_events/zpool_events_errors.ksh \ + functional/cli_root/zpool_events/zpool_events_follow.ksh \ + functional/cli_root/zpool_events/zpool_events_poolname.ksh \ + functional/cli_root/zpool_expand/cleanup.ksh \ + functional/cli_root/zpool_expand/setup.ksh \ + functional/cli_root/zpool_expand/zpool_expand_001_pos.ksh \ + functional/cli_root/zpool_expand/zpool_expand_002_pos.ksh \ + functional/cli_root/zpool_expand/zpool_expand_003_neg.ksh \ + functional/cli_root/zpool_expand/zpool_expand_004_pos.ksh \ + functional/cli_root/zpool_expand/zpool_expand_005_pos.ksh \ + functional/cli_root/zpool_export/cleanup.ksh \ + functional/cli_root/zpool_export/setup.ksh \ + functional/cli_root/zpool_export/zpool_export_001_pos.ksh \ + functional/cli_root/zpool_export/zpool_export_002_pos.ksh \ + functional/cli_root/zpool_export/zpool_export_003_neg.ksh \ + functional/cli_root/zpool_export/zpool_export_004_pos.ksh \ + functional/cli_root/zpool_get/cleanup.ksh \ + functional/cli_root/zpool_get/setup.ksh \ + functional/cli_root/zpool_get/zpool_get_001_pos.ksh \ + functional/cli_root/zpool_get/zpool_get_002_pos.ksh \ + functional/cli_root/zpool_get/zpool_get_003_pos.ksh \ + functional/cli_root/zpool_get/zpool_get_004_neg.ksh \ + functional/cli_root/zpool_get/zpool_get_005_pos.ksh \ + functional/cli_root/zpool_history/cleanup.ksh \ + functional/cli_root/zpool_history/setup.ksh \ + functional/cli_root/zpool_history/zpool_history_001_neg.ksh \ + functional/cli_root/zpool_history/zpool_history_002_pos.ksh \ + functional/cli_root/zpool_import/cleanup.ksh \ + functional/cli_root/zpool_import/import_cachefile_device_added.ksh \ + functional/cli_root/zpool_import/import_cachefile_device_removed.ksh \ + functional/cli_root/zpool_import/import_cachefile_device_replaced.ksh \ + functional/cli_root/zpool_import/import_cachefile_mirror_attached.ksh \ + functional/cli_root/zpool_import/import_cachefile_mirror_detached.ksh \ + functional/cli_root/zpool_import/import_cachefile_paths_changed.ksh \ + functional/cli_root/zpool_import/import_cachefile_shared_device.ksh \ + functional/cli_root/zpool_import/import_devices_missing.ksh \ + functional/cli_root/zpool_import/import_paths_changed.ksh \ + functional/cli_root/zpool_import/import_rewind_config_changed.ksh \ + functional/cli_root/zpool_import/import_rewind_device_replaced.ksh \ + functional/cli_root/zpool_import/setup.ksh \ + functional/cli_root/zpool_import/zpool_import_001_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_002_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_003_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_004_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_005_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_006_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_007_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_008_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_009_neg.ksh \ + functional/cli_root/zpool_import/zpool_import_010_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_011_neg.ksh \ + functional/cli_root/zpool_import/zpool_import_012_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_013_neg.ksh \ + functional/cli_root/zpool_import/zpool_import_014_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_015_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_016_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_017_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_all_001_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_encrypted.ksh \ + functional/cli_root/zpool_import/zpool_import_encrypted_load.ksh \ + functional/cli_root/zpool_import/zpool_import_errata3.ksh \ + functional/cli_root/zpool_import/zpool_import_errata4.ksh \ + functional/cli_root/zpool_import/zpool_import_features_001_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_features_002_neg.ksh \ + functional/cli_root/zpool_import/zpool_import_features_003_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_missing_001_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_missing_002_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_missing_003_pos.ksh \ + functional/cli_root/zpool_import/zpool_import_rename_001_pos.ksh \ + functional/cli_root/zpool_initialize/cleanup.ksh \ + functional/cli_root/zpool_initialize/zpool_initialize_attach_detach_add_remove.ksh \ + functional/cli_root/zpool_initialize/zpool_initialize_fault_export_import_online.ksh \ + functional/cli_root/zpool_initialize/zpool_initialize_import_export.ksh \ + functional/cli_root/zpool_initialize/zpool_initialize_offline_export_import_online.ksh \ + functional/cli_root/zpool_initialize/zpool_initialize_online_offline.ksh \ + functional/cli_root/zpool_initialize/zpool_initialize_split.ksh \ + functional/cli_root/zpool_initialize/zpool_initialize_start_and_cancel_neg.ksh \ + functional/cli_root/zpool_initialize/zpool_initialize_start_and_cancel_pos.ksh \ + functional/cli_root/zpool_initialize/zpool_initialize_suspend_resume.ksh \ + functional/cli_root/zpool_initialize/zpool_initialize_unsupported_vdevs.ksh \ + functional/cli_root/zpool_initialize/zpool_initialize_verify_checksums.ksh \ + functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh \ + functional/cli_root/zpool_labelclear/zpool_labelclear_active.ksh \ + functional/cli_root/zpool_labelclear/zpool_labelclear_exported.ksh \ + functional/cli_root/zpool_labelclear/zpool_labelclear_removed.ksh \ + functional/cli_root/zpool_labelclear/zpool_labelclear_valid.ksh \ + functional/cli_root/zpool_offline/cleanup.ksh \ + functional/cli_root/zpool_offline/setup.ksh \ + functional/cli_root/zpool_offline/zpool_offline_001_pos.ksh \ + functional/cli_root/zpool_offline/zpool_offline_002_neg.ksh \ + functional/cli_root/zpool_offline/zpool_offline_003_pos.ksh \ + functional/cli_root/zpool_online/cleanup.ksh \ + functional/cli_root/zpool_online/setup.ksh \ + functional/cli_root/zpool_online/zpool_online_001_pos.ksh \ + functional/cli_root/zpool_online/zpool_online_002_neg.ksh \ + functional/cli_root/zpool_remove/cleanup.ksh \ + functional/cli_root/zpool_remove/setup.ksh \ + functional/cli_root/zpool_remove/zpool_remove_001_neg.ksh \ + functional/cli_root/zpool_remove/zpool_remove_002_pos.ksh \ + functional/cli_root/zpool_remove/zpool_remove_003_pos.ksh \ + functional/cli_root/zpool_reopen/cleanup.ksh \ + functional/cli_root/zpool_reopen/setup.ksh \ + functional/cli_root/zpool_reopen/zpool_reopen_001_pos.ksh \ + functional/cli_root/zpool_reopen/zpool_reopen_002_pos.ksh \ + functional/cli_root/zpool_reopen/zpool_reopen_003_pos.ksh \ + functional/cli_root/zpool_reopen/zpool_reopen_004_pos.ksh \ + functional/cli_root/zpool_reopen/zpool_reopen_005_pos.ksh \ + functional/cli_root/zpool_reopen/zpool_reopen_006_neg.ksh \ + functional/cli_root/zpool_reopen/zpool_reopen_007_pos.ksh \ + functional/cli_root/zpool_replace/cleanup.ksh \ + functional/cli_root/zpool_replace/replace-o_ashift.ksh \ + functional/cli_root/zpool_replace/replace_prop_ashift.ksh \ + functional/cli_root/zpool_replace/setup.ksh \ + functional/cli_root/zpool_replace/zpool_replace_001_neg.ksh \ + functional/cli_root/zpool_resilver/cleanup.ksh \ + functional/cli_root/zpool_resilver/setup.ksh \ + functional/cli_root/zpool_resilver/zpool_resilver_bad_args.ksh \ + functional/cli_root/zpool_resilver/zpool_resilver_restart.ksh \ + functional/cli_root/zpool_scrub/cleanup.ksh \ + functional/cli_root/zpool_scrub/setup.ksh \ + functional/cli_root/zpool_scrub/zpool_scrub_001_neg.ksh \ + functional/cli_root/zpool_scrub/zpool_scrub_002_pos.ksh \ + functional/cli_root/zpool_scrub/zpool_scrub_003_pos.ksh \ + functional/cli_root/zpool_scrub/zpool_scrub_004_pos.ksh \ + functional/cli_root/zpool_scrub/zpool_scrub_005_pos.ksh \ + functional/cli_root/zpool_scrub/zpool_scrub_encrypted_unloaded.ksh \ + functional/cli_root/zpool_scrub/zpool_scrub_multiple_copies.ksh \ + functional/cli_root/zpool_scrub/zpool_scrub_offline_device.ksh \ + functional/cli_root/zpool_scrub/zpool_scrub_print_repairing.ksh \ + functional/cli_root/zpool_set/cleanup.ksh \ + functional/cli_root/zpool_set/setup.ksh \ + functional/cli_root/zpool/setup.ksh \ + functional/cli_root/zpool_set/zpool_set_001_pos.ksh \ + functional/cli_root/zpool_set/zpool_set_002_neg.ksh \ + functional/cli_root/zpool_set/zpool_set_003_neg.ksh \ + functional/cli_root/zpool_set/zpool_set_ashift.ksh \ + functional/cli_root/zpool_set/zpool_set_features.ksh \ + functional/cli_root/zpool_split/cleanup.ksh \ + functional/cli_root/zpool_split/setup.ksh \ + functional/cli_root/zpool_split/zpool_split_cliargs.ksh \ + functional/cli_root/zpool_split/zpool_split_devices.ksh \ + functional/cli_root/zpool_split/zpool_split_dryrun_output.ksh \ + functional/cli_root/zpool_split/zpool_split_encryption.ksh \ + functional/cli_root/zpool_split/zpool_split_indirect.ksh \ + functional/cli_root/zpool_split/zpool_split_props.ksh \ + functional/cli_root/zpool_split/zpool_split_resilver.ksh \ + functional/cli_root/zpool_split/zpool_split_vdevs.ksh \ + functional/cli_root/zpool_split/zpool_split_wholedisk.ksh \ + functional/cli_root/zpool_status/cleanup.ksh \ + functional/cli_root/zpool_status/setup.ksh \ + functional/cli_root/zpool_status/zpool_status_001_pos.ksh \ + functional/cli_root/zpool_status/zpool_status_002_pos.ksh \ + functional/cli_root/zpool_status/zpool_status_003_pos.ksh \ + functional/cli_root/zpool_status/zpool_status_004_pos.ksh \ + functional/cli_root/zpool_status/zpool_status_features_001_pos.ksh \ + functional/cli_root/zpool_sync/cleanup.ksh \ + functional/cli_root/zpool_sync/setup.ksh \ + functional/cli_root/zpool_sync/zpool_sync_001_pos.ksh \ + functional/cli_root/zpool_sync/zpool_sync_002_neg.ksh \ + functional/cli_root/zpool_trim/cleanup.ksh \ + functional/cli_root/zpool_trim/setup.ksh \ + functional/cli_root/zpool_trim/zpool_trim_attach_detach_add_remove.ksh \ + functional/cli_root/zpool_trim/zpool_trim_fault_export_import_online.ksh \ + functional/cli_root/zpool_trim/zpool_trim_import_export.ksh \ + functional/cli_root/zpool_trim/zpool_trim_multiple.ksh \ + functional/cli_root/zpool_trim/zpool_trim_neg.ksh \ + functional/cli_root/zpool_trim/zpool_trim_offline_export_import_online.ksh \ + functional/cli_root/zpool_trim/zpool_trim_online_offline.ksh \ + functional/cli_root/zpool_trim/zpool_trim_partial.ksh \ + functional/cli_root/zpool_trim/zpool_trim_rate.ksh \ + functional/cli_root/zpool_trim/zpool_trim_rate_neg.ksh \ + functional/cli_root/zpool_trim/zpool_trim_secure.ksh \ + functional/cli_root/zpool_trim/zpool_trim_split.ksh \ + functional/cli_root/zpool_trim/zpool_trim_start_and_cancel_neg.ksh \ + functional/cli_root/zpool_trim/zpool_trim_start_and_cancel_pos.ksh \ + functional/cli_root/zpool_trim/zpool_trim_suspend_resume.ksh \ + functional/cli_root/zpool_trim/zpool_trim_unsupported_vdevs.ksh \ + functional/cli_root/zpool_trim/zpool_trim_verify_checksums.ksh \ + functional/cli_root/zpool_trim/zpool_trim_verify_trimmed.ksh \ + functional/cli_root/zpool_upgrade/cleanup.ksh \ + functional/cli_root/zpool_upgrade/setup.ksh \ + functional/cli_root/zpool_upgrade/zpool_upgrade_001_pos.ksh \ + functional/cli_root/zpool_upgrade/zpool_upgrade_002_pos.ksh \ + functional/cli_root/zpool_upgrade/zpool_upgrade_003_pos.ksh \ + functional/cli_root/zpool_upgrade/zpool_upgrade_004_pos.ksh \ + functional/cli_root/zpool_upgrade/zpool_upgrade_005_neg.ksh \ + functional/cli_root/zpool_upgrade/zpool_upgrade_006_neg.ksh \ + functional/cli_root/zpool_upgrade/zpool_upgrade_007_pos.ksh \ + functional/cli_root/zpool_upgrade/zpool_upgrade_008_pos.ksh \ + functional/cli_root/zpool_upgrade/zpool_upgrade_009_neg.ksh \ + functional/cli_root/zpool_upgrade/zpool_upgrade_features_001_pos.ksh \ + functional/cli_root/zpool_wait/cleanup.ksh \ + functional/cli_root/zpool_wait/scan/cleanup.ksh \ + functional/cli_root/zpool_wait/scan/setup.ksh \ + functional/cli_root/zpool_wait/scan/zpool_wait_rebuild.ksh \ + functional/cli_root/zpool_wait/scan/zpool_wait_replace_cancel.ksh \ + functional/cli_root/zpool_wait/scan/zpool_wait_replace.ksh \ + functional/cli_root/zpool_wait/scan/zpool_wait_resilver.ksh \ + functional/cli_root/zpool_wait/scan/zpool_wait_scrub_basic.ksh \ + functional/cli_root/zpool_wait/scan/zpool_wait_scrub_cancel.ksh \ + functional/cli_root/zpool_wait/scan/zpool_wait_scrub_flag.ksh \ + functional/cli_root/zpool_wait/setup.ksh \ + functional/cli_root/zpool_wait/zpool_wait_discard.ksh \ + functional/cli_root/zpool_wait/zpool_wait_freeing.ksh \ + functional/cli_root/zpool_wait/zpool_wait_initialize_basic.ksh \ + functional/cli_root/zpool_wait/zpool_wait_initialize_cancel.ksh \ + functional/cli_root/zpool_wait/zpool_wait_initialize_flag.ksh \ + functional/cli_root/zpool_wait/zpool_wait_multiple.ksh \ + functional/cli_root/zpool_wait/zpool_wait_no_activity.ksh \ + functional/cli_root/zpool_wait/zpool_wait_remove_cancel.ksh \ + functional/cli_root/zpool_wait/zpool_wait_remove.ksh \ + functional/cli_root/zpool_wait/zpool_wait_trim_basic.ksh \ + functional/cli_root/zpool_wait/zpool_wait_trim_cancel.ksh \ + functional/cli_root/zpool_wait/zpool_wait_trim_flag.ksh \ + functional/cli_root/zpool_wait/zpool_wait_usage.ksh \ + functional/cli_root/zpool/zpool_001_neg.ksh \ + functional/cli_root/zpool/zpool_002_pos.ksh \ + functional/cli_root/zpool/zpool_003_pos.ksh \ + functional/cli_root/zpool/zpool_colors.ksh \ + functional/cli_user/misc/arcstat_001_pos.ksh \ + functional/cli_user/misc/arc_summary_001_pos.ksh \ + functional/cli_user/misc/arc_summary_002_neg.ksh \ + functional/cli_user/misc/cleanup.ksh \ + functional/cli_user/misc/setup.ksh \ + functional/cli_user/misc/zdb_001_neg.ksh \ + functional/cli_user/misc/zfs_001_neg.ksh \ + functional/cli_user/misc/zfs_allow_001_neg.ksh \ + functional/cli_user/misc/zfs_clone_001_neg.ksh \ + functional/cli_user/misc/zfs_create_001_neg.ksh \ + functional/cli_user/misc/zfs_destroy_001_neg.ksh \ + functional/cli_user/misc/zfs_get_001_neg.ksh \ + functional/cli_user/misc/zfs_inherit_001_neg.ksh \ + functional/cli_user/misc/zfs_mount_001_neg.ksh \ + functional/cli_user/misc/zfs_promote_001_neg.ksh \ + functional/cli_user/misc/zfs_receive_001_neg.ksh \ + functional/cli_user/misc/zfs_rename_001_neg.ksh \ + functional/cli_user/misc/zfs_rollback_001_neg.ksh \ + functional/cli_user/misc/zfs_send_001_neg.ksh \ + functional/cli_user/misc/zfs_set_001_neg.ksh \ + functional/cli_user/misc/zfs_share_001_neg.ksh \ + functional/cli_user/misc/zfs_snapshot_001_neg.ksh \ + functional/cli_user/misc/zfs_unallow_001_neg.ksh \ + functional/cli_user/misc/zfs_unmount_001_neg.ksh \ + functional/cli_user/misc/zfs_unshare_001_neg.ksh \ + functional/cli_user/misc/zfs_upgrade_001_neg.ksh \ + functional/cli_user/misc/zpool_001_neg.ksh \ + functional/cli_user/misc/zpool_add_001_neg.ksh \ + functional/cli_user/misc/zpool_attach_001_neg.ksh \ + functional/cli_user/misc/zpool_clear_001_neg.ksh \ + functional/cli_user/misc/zpool_create_001_neg.ksh \ + functional/cli_user/misc/zpool_destroy_001_neg.ksh \ + functional/cli_user/misc/zpool_detach_001_neg.ksh \ + functional/cli_user/misc/zpool_export_001_neg.ksh \ + functional/cli_user/misc/zpool_get_001_neg.ksh \ + functional/cli_user/misc/zpool_history_001_neg.ksh \ + functional/cli_user/misc/zpool_import_001_neg.ksh \ + functional/cli_user/misc/zpool_import_002_neg.ksh \ + functional/cli_user/misc/zpool_offline_001_neg.ksh \ + functional/cli_user/misc/zpool_online_001_neg.ksh \ + functional/cli_user/misc/zpool_remove_001_neg.ksh \ + functional/cli_user/misc/zpool_replace_001_neg.ksh \ + functional/cli_user/misc/zpool_scrub_001_neg.ksh \ + functional/cli_user/misc/zpool_set_001_neg.ksh \ + functional/cli_user/misc/zpool_status_001_neg.ksh \ + functional/cli_user/misc/zpool_upgrade_001_neg.ksh \ + functional/cli_user/misc/zpool_wait_privilege.ksh \ + functional/cli_user/zfs_list/cleanup.ksh \ + functional/cli_user/zfs_list/setup.ksh \ + functional/cli_user/zfs_list/zfs_list_001_pos.ksh \ + functional/cli_user/zfs_list/zfs_list_002_pos.ksh \ + functional/cli_user/zfs_list/zfs_list_003_pos.ksh \ + functional/cli_user/zfs_list/zfs_list_004_neg.ksh \ + functional/cli_user/zfs_list/zfs_list_005_neg.ksh \ + functional/cli_user/zfs_list/zfs_list_007_pos.ksh \ + functional/cli_user/zfs_list/zfs_list_008_neg.ksh \ + functional/cli_user/zpool_iostat/cleanup.ksh \ + functional/cli_user/zpool_iostat/setup.ksh \ + functional/cli_user/zpool_iostat/zpool_iostat_001_neg.ksh \ + functional/cli_user/zpool_iostat/zpool_iostat_002_pos.ksh \ + functional/cli_user/zpool_iostat/zpool_iostat_003_neg.ksh \ + functional/cli_user/zpool_iostat/zpool_iostat_004_pos.ksh \ + functional/cli_user/zpool_iostat/zpool_iostat_005_pos.ksh \ + functional/cli_user/zpool_iostat/zpool_iostat_-c_disable.ksh \ + functional/cli_user/zpool_iostat/zpool_iostat_-c_homedir.ksh \ + functional/cli_user/zpool_iostat/zpool_iostat_-c_searchpath.ksh \ + functional/cli_user/zpool_list/cleanup.ksh \ + functional/cli_user/zpool_list/setup.ksh \ + functional/cli_user/zpool_list/zpool_list_001_pos.ksh \ + functional/cli_user/zpool_list/zpool_list_002_neg.ksh \ + functional/cli_user/zpool_status/cleanup.ksh \ + functional/cli_user/zpool_status/setup.ksh \ + functional/cli_user/zpool_status/zpool_status_003_pos.ksh \ + functional/cli_user/zpool_status/zpool_status_-c_disable.ksh \ + functional/cli_user/zpool_status/zpool_status_-c_homedir.ksh \ + functional/cli_user/zpool_status/zpool_status_-c_searchpath.ksh \ + functional/compression/cleanup.ksh \ + functional/compression/compress_001_pos.ksh \ + functional/compression/compress_002_pos.ksh \ + functional/compression/compress_003_pos.ksh \ + functional/compression/compress_004_pos.ksh \ + functional/compression/compress_zstd_bswap.ksh \ + functional/compression/l2arc_compressed_arc_disabled.ksh \ + functional/compression/l2arc_compressed_arc.ksh \ + functional/compression/l2arc_encrypted.ksh \ + functional/compression/l2arc_encrypted_no_compressed_arc.ksh \ + functional/compression/setup.ksh \ + functional/cp_files/cleanup.ksh \ + functional/cp_files/cp_files_001_pos.ksh \ + functional/cp_files/setup.ksh \ + functional/crtime/cleanup.ksh \ + functional/crtime/crtime_001_pos.ksh \ + functional/crtime/setup.ksh \ + functional/ctime/cleanup.ksh \ + functional/ctime/ctime_001_pos.ksh \ + functional/ctime/setup.ksh \ + functional/deadman/deadman_ratelimit.ksh \ + functional/deadman/deadman_sync.ksh \ + functional/deadman/deadman_zio.ksh \ + functional/delegate/cleanup.ksh \ + functional/delegate/setup.ksh \ + functional/delegate/zfs_allow_001_pos.ksh \ + functional/delegate/zfs_allow_002_pos.ksh \ + functional/delegate/zfs_allow_003_pos.ksh \ + functional/delegate/zfs_allow_004_pos.ksh \ + functional/delegate/zfs_allow_005_pos.ksh \ + functional/delegate/zfs_allow_006_pos.ksh \ + functional/delegate/zfs_allow_007_pos.ksh \ + functional/delegate/zfs_allow_008_pos.ksh \ + functional/delegate/zfs_allow_009_neg.ksh \ + functional/delegate/zfs_allow_010_pos.ksh \ + functional/delegate/zfs_allow_011_neg.ksh \ + functional/delegate/zfs_allow_012_neg.ksh \ + functional/delegate/zfs_unallow_001_pos.ksh \ + functional/delegate/zfs_unallow_002_pos.ksh \ + functional/delegate/zfs_unallow_003_pos.ksh \ + functional/delegate/zfs_unallow_004_pos.ksh \ + functional/delegate/zfs_unallow_005_pos.ksh \ + functional/delegate/zfs_unallow_006_pos.ksh \ + functional/delegate/zfs_unallow_007_neg.ksh \ + functional/delegate/zfs_unallow_008_neg.ksh \ + functional/devices/cleanup.ksh \ + functional/devices/devices_001_pos.ksh \ + functional/devices/devices_002_neg.ksh \ + functional/devices/devices_003_pos.ksh \ + functional/devices/setup.ksh \ + functional/dos_attributes/cleanup.ksh \ + functional/dos_attributes/read_dos_attrs_001.ksh \ + functional/dos_attributes/setup.ksh \ + functional/dos_attributes/write_dos_attrs_001.ksh \ + functional/events/cleanup.ksh \ + functional/events/events_001_pos.ksh \ + functional/events/events_002_pos.ksh \ + functional/events/setup.ksh \ + functional/events/zed_fd_spill.ksh \ + functional/events/zed_rc_filter.ksh \ + functional/exec/cleanup.ksh \ + functional/exec/exec_001_pos.ksh \ + functional/exec/exec_002_neg.ksh \ + functional/exec/setup.ksh \ + functional/fallocate/cleanup.ksh \ + functional/fallocate/fallocate_prealloc.ksh \ + functional/fallocate/fallocate_punch-hole.ksh \ + functional/fallocate/fallocate_zero-range.ksh \ + functional/fallocate/setup.ksh \ + functional/fault/auto_offline_001_pos.ksh \ + functional/fault/auto_online_001_pos.ksh \ + functional/fault/auto_online_002_pos.ksh \ + functional/fault/auto_replace_001_pos.ksh \ + functional/fault/auto_spare_001_pos.ksh \ + functional/fault/auto_spare_002_pos.ksh \ + functional/fault/auto_spare_ashift.ksh \ + functional/fault/auto_spare_multiple.ksh \ + functional/fault/auto_spare_shared.ksh \ + functional/fault/cleanup.ksh \ + functional/fault/decompress_fault.ksh \ + functional/fault/decrypt_fault.ksh \ + functional/fault/scrub_after_resilver.ksh \ + functional/fault/setup.ksh \ + functional/fault/zpool_status_-s.ksh \ + functional/features/async_destroy/async_destroy_001_pos.ksh \ + functional/features/async_destroy/cleanup.ksh \ + functional/features/async_destroy/setup.ksh \ + functional/features/large_dnode/cleanup.ksh \ + functional/features/large_dnode/large_dnode_001_pos.ksh \ + functional/features/large_dnode/large_dnode_002_pos.ksh \ + functional/features/large_dnode/large_dnode_003_pos.ksh \ + functional/features/large_dnode/large_dnode_004_neg.ksh \ + functional/features/large_dnode/large_dnode_005_pos.ksh \ + functional/features/large_dnode/large_dnode_006_pos.ksh \ + functional/features/large_dnode/large_dnode_007_neg.ksh \ + functional/features/large_dnode/large_dnode_008_pos.ksh \ + functional/features/large_dnode/large_dnode_009_pos.ksh \ + functional/features/large_dnode/setup.ksh \ + functional/grow/grow_pool_001_pos.ksh \ + functional/grow/grow_replicas_001_pos.ksh \ + functional/history/cleanup.ksh \ + functional/history/history_001_pos.ksh \ + functional/history/history_002_pos.ksh \ + functional/history/history_003_pos.ksh \ + functional/history/history_004_pos.ksh \ + functional/history/history_005_neg.ksh \ + functional/history/history_006_neg.ksh \ + functional/history/history_007_pos.ksh \ + functional/history/history_008_pos.ksh \ + functional/history/history_009_pos.ksh \ + functional/history/history_010_pos.ksh \ + functional/history/setup.ksh \ + functional/inheritance/cleanup.ksh \ + functional/inheritance/inherit_001_pos.ksh \ + functional/inuse/inuse_001_pos.ksh \ + functional/inuse/inuse_003_pos.ksh \ + functional/inuse/inuse_004_pos.ksh \ + functional/inuse/inuse_005_pos.ksh \ + functional/inuse/inuse_006_pos.ksh \ + functional/inuse/inuse_007_pos.ksh \ + functional/inuse/inuse_008_pos.ksh \ + functional/inuse/inuse_009_pos.ksh \ + functional/inuse/setup.ksh \ + functional/io/cleanup.ksh \ + functional/io/io_uring.ksh \ + functional/io/libaio.ksh \ + functional/io/mmap.ksh \ + functional/io/posixaio.ksh \ + functional/io/psync.ksh \ + functional/io/setup.ksh \ + functional/io/sync.ksh \ + functional/l2arc/cleanup.ksh \ + functional/l2arc/l2arc_arcstats_pos.ksh \ + functional/l2arc/l2arc_l2miss_pos.ksh \ + functional/l2arc/l2arc_mfuonly_pos.ksh \ + functional/l2arc/persist_l2arc_001_pos.ksh \ + functional/l2arc/persist_l2arc_002_pos.ksh \ + functional/l2arc/persist_l2arc_003_neg.ksh \ + functional/l2arc/persist_l2arc_004_pos.ksh \ + functional/l2arc/persist_l2arc_005_pos.ksh \ + functional/l2arc/setup.ksh \ + functional/large_files/cleanup.ksh \ + functional/large_files/large_files_001_pos.ksh \ + functional/large_files/large_files_002_pos.ksh \ + functional/large_files/setup.ksh \ + functional/largest_pool/largest_pool_001_pos.ksh \ + functional/libzfs/cleanup.ksh \ + functional/libzfs/libzfs_input.ksh \ + functional/libzfs/setup.ksh \ + functional/limits/cleanup.ksh \ + functional/limits/filesystem_count.ksh \ + functional/limits/filesystem_limit.ksh \ + functional/limits/setup.ksh \ + functional/limits/snapshot_count.ksh \ + functional/limits/snapshot_limit.ksh \ + functional/link_count/cleanup.ksh \ + functional/link_count/link_count_001.ksh \ + functional/link_count/link_count_root_inode.ksh \ + functional/link_count/setup.ksh \ + functional/log_spacemap/log_spacemap_import_logs.ksh \ + functional/migration/cleanup.ksh \ + functional/migration/migration_001_pos.ksh \ + functional/migration/migration_002_pos.ksh \ + functional/migration/migration_003_pos.ksh \ + functional/migration/migration_004_pos.ksh \ + functional/migration/migration_005_pos.ksh \ + functional/migration/migration_006_pos.ksh \ + functional/migration/migration_007_pos.ksh \ + functional/migration/migration_008_pos.ksh \ + functional/migration/migration_009_pos.ksh \ + functional/migration/migration_010_pos.ksh \ + functional/migration/migration_011_pos.ksh \ + functional/migration/migration_012_pos.ksh \ + functional/migration/setup.ksh \ + functional/mmap/cleanup.ksh \ + functional/mmap/mmap_libaio_001_pos.ksh \ + functional/mmap/mmap_read_001_pos.ksh \ + functional/mmap/mmap_seek_001_pos.ksh \ + functional/mmap/mmap_sync_001_pos.ksh \ + functional/mmap/mmap_write_001_pos.ksh \ + functional/mmap/setup.ksh \ + functional/mmp/cleanup.ksh \ + functional/mmp/mmp_active_import.ksh \ + functional/mmp/mmp_exported_import.ksh \ + functional/mmp/mmp_hostid.ksh \ + functional/mmp/mmp_inactive_import.ksh \ + functional/mmp/mmp_interval.ksh \ + functional/mmp/mmp_on_off.ksh \ + functional/mmp/mmp_on_thread.ksh \ + functional/mmp/mmp_on_uberblocks.ksh \ + functional/mmp/mmp_on_zdb.ksh \ + functional/mmp/mmp_reset_interval.ksh \ + functional/mmp/mmp_write_distribution.ksh \ + functional/mmp/mmp_write_uberblocks.ksh \ + functional/mmp/multihost_history.ksh \ + functional/mmp/setup.ksh \ + functional/mount/cleanup.ksh \ + functional/mount/setup.ksh \ + functional/mount/umount_001.ksh \ + functional/mount/umountall_001.ksh \ + functional/mount/umount_unlinked_drain.ksh \ + functional/mv_files/cleanup.ksh \ + functional/mv_files/mv_files_001_pos.ksh \ + functional/mv_files/mv_files_002_pos.ksh \ + functional/mv_files/random_creation.ksh \ + functional/mv_files/setup.ksh \ + functional/nestedfs/cleanup.ksh \ + functional/nestedfs/nestedfs_001_pos.ksh \ + functional/nestedfs/setup.ksh \ + functional/nopwrite/cleanup.ksh \ + functional/nopwrite/nopwrite_copies.ksh \ + functional/nopwrite/nopwrite_mtime.ksh \ + functional/nopwrite/nopwrite_negative.ksh \ + functional/nopwrite/nopwrite_promoted_clone.ksh \ + functional/nopwrite/nopwrite_recsize.ksh \ + functional/nopwrite/nopwrite_sync.ksh \ + functional/nopwrite/nopwrite_varying_compression.ksh \ + functional/nopwrite/nopwrite_volume.ksh \ + functional/nopwrite/setup.ksh \ + functional/no_space/cleanup.ksh \ + functional/no_space/enospc_001_pos.ksh \ + functional/no_space/enospc_002_pos.ksh \ + functional/no_space/enospc_003_pos.ksh \ + functional/no_space/enospc_df.ksh \ + functional/no_space/enospc_rm.ksh \ + functional/no_space/setup.ksh \ + functional/online_offline/cleanup.ksh \ + functional/online_offline/online_offline_001_pos.ksh \ + functional/online_offline/online_offline_002_neg.ksh \ + functional/online_offline/online_offline_003_neg.ksh \ + functional/online_offline/setup.ksh \ + functional/pam/cleanup.ksh \ + functional/pam/pam_basic.ksh \ + functional/pam/pam_nounmount.ksh \ + functional/pam/pam_short_password.ksh \ + functional/pam/setup.ksh \ + functional/pool_checkpoint/checkpoint_after_rewind.ksh \ + functional/pool_checkpoint/checkpoint_big_rewind.ksh \ + functional/pool_checkpoint/checkpoint_capacity.ksh \ + functional/pool_checkpoint/checkpoint_conf_change.ksh \ + functional/pool_checkpoint/checkpoint_discard_busy.ksh \ + functional/pool_checkpoint/checkpoint_discard.ksh \ + functional/pool_checkpoint/checkpoint_discard_many.ksh \ + functional/pool_checkpoint/checkpoint_indirect.ksh \ + functional/pool_checkpoint/checkpoint_invalid.ksh \ + functional/pool_checkpoint/checkpoint_lun_expsz.ksh \ + functional/pool_checkpoint/checkpoint_open.ksh \ + functional/pool_checkpoint/checkpoint_removal.ksh \ + functional/pool_checkpoint/checkpoint_rewind.ksh \ + functional/pool_checkpoint/checkpoint_ro_rewind.ksh \ + functional/pool_checkpoint/checkpoint_sm_scale.ksh \ + functional/pool_checkpoint/checkpoint_twice.ksh \ + functional/pool_checkpoint/checkpoint_vdev_add.ksh \ + functional/pool_checkpoint/checkpoint_zdb.ksh \ + functional/pool_checkpoint/checkpoint_zhack_feat.ksh \ + functional/pool_checkpoint/cleanup.ksh \ + functional/pool_checkpoint/setup.ksh \ + functional/pool_names/pool_names_001_pos.ksh \ + functional/pool_names/pool_names_002_neg.ksh \ + functional/poolversion/cleanup.ksh \ + functional/poolversion/poolversion_001_pos.ksh \ + functional/poolversion/poolversion_002_pos.ksh \ + functional/poolversion/setup.ksh \ + functional/privilege/cleanup.ksh \ + functional/privilege/privilege_001_pos.ksh \ + functional/privilege/privilege_002_pos.ksh \ + functional/privilege/setup.ksh \ + functional/procfs/cleanup.ksh \ + functional/procfs/pool_state.ksh \ + functional/procfs/procfs_list_basic.ksh \ + functional/procfs/procfs_list_concurrent_readers.ksh \ + functional/procfs/procfs_list_stale_read.ksh \ + functional/procfs/setup.ksh \ + functional/projectquota/cleanup.ksh \ + functional/projectquota/projectid_001_pos.ksh \ + functional/projectquota/projectid_002_pos.ksh \ + functional/projectquota/projectid_003_pos.ksh \ + functional/projectquota/projectquota_001_pos.ksh \ + functional/projectquota/projectquota_002_pos.ksh \ + functional/projectquota/projectquota_003_pos.ksh \ + functional/projectquota/projectquota_004_neg.ksh \ + functional/projectquota/projectquota_005_pos.ksh \ + functional/projectquota/projectquota_006_pos.ksh \ + functional/projectquota/projectquota_007_pos.ksh \ + functional/projectquota/projectquota_008_pos.ksh \ + functional/projectquota/projectquota_009_pos.ksh \ + functional/projectquota/projectspace_001_pos.ksh \ + functional/projectquota/projectspace_002_pos.ksh \ + functional/projectquota/projectspace_003_pos.ksh \ + functional/projectquota/projectspace_004_pos.ksh \ + functional/projectquota/projecttree_001_pos.ksh \ + functional/projectquota/projecttree_002_pos.ksh \ + functional/projectquota/projecttree_003_neg.ksh \ + functional/projectquota/setup.ksh \ + functional/quota/cleanup.ksh \ + functional/quota/quota_001_pos.ksh \ + functional/quota/quota_002_pos.ksh \ + functional/quota/quota_003_pos.ksh \ + functional/quota/quota_004_pos.ksh \ + functional/quota/quota_005_pos.ksh \ + functional/quota/quota_006_neg.ksh \ + functional/quota/setup.ksh \ + functional/raidz/cleanup.ksh \ + functional/raidz/raidz_001_neg.ksh \ + functional/raidz/raidz_002_pos.ksh \ + functional/raidz/raidz_003_pos.ksh \ + functional/raidz/raidz_004_pos.ksh \ + functional/raidz/setup.ksh \ + functional/redacted_send/cleanup.ksh \ + functional/redacted_send/redacted_compressed.ksh \ + functional/redacted_send/redacted_contents.ksh \ + functional/redacted_send/redacted_deleted.ksh \ + functional/redacted_send/redacted_disabled_feature.ksh \ + functional/redacted_send/redacted_embedded.ksh \ + functional/redacted_send/redacted_holes.ksh \ + functional/redacted_send/redacted_incrementals.ksh \ + functional/redacted_send/redacted_largeblocks.ksh \ + functional/redacted_send/redacted_many_clones.ksh \ + functional/redacted_send/redacted_mixed_recsize.ksh \ + functional/redacted_send/redacted_mounts.ksh \ + functional/redacted_send/redacted_negative.ksh \ + functional/redacted_send/redacted_origin.ksh \ + functional/redacted_send/redacted_panic.ksh \ + functional/redacted_send/redacted_props.ksh \ + functional/redacted_send/redacted_resume.ksh \ + functional/redacted_send/redacted_size.ksh \ + functional/redacted_send/redacted_volume.ksh \ + functional/redacted_send/setup.ksh \ + functional/redundancy/cleanup.ksh \ + functional/redundancy/redundancy_draid1.ksh \ + functional/redundancy/redundancy_draid2.ksh \ + functional/redundancy/redundancy_draid3.ksh \ + functional/redundancy/redundancy_draid_damaged.ksh \ + functional/redundancy/redundancy_draid.ksh \ + functional/redundancy/redundancy_draid_spare1.ksh \ + functional/redundancy/redundancy_draid_spare2.ksh \ + functional/redundancy/redundancy_draid_spare3.ksh \ + functional/redundancy/redundancy_mirror.ksh \ + functional/redundancy/redundancy_raidz1.ksh \ + functional/redundancy/redundancy_raidz2.ksh \ + functional/redundancy/redundancy_raidz3.ksh \ + functional/redundancy/redundancy_raidz.ksh \ + functional/redundancy/redundancy_stripe.ksh \ + functional/redundancy/setup.ksh \ + functional/refquota/cleanup.ksh \ + functional/refquota/refquota_001_pos.ksh \ + functional/refquota/refquota_002_pos.ksh \ + functional/refquota/refquota_003_pos.ksh \ + functional/refquota/refquota_004_pos.ksh \ + functional/refquota/refquota_005_pos.ksh \ + functional/refquota/refquota_006_neg.ksh \ + functional/refquota/refquota_007_neg.ksh \ + functional/refquota/refquota_008_neg.ksh \ + functional/refquota/setup.ksh \ + functional/refreserv/cleanup.ksh \ + functional/refreserv/refreserv_001_pos.ksh \ + functional/refreserv/refreserv_002_pos.ksh \ + functional/refreserv/refreserv_003_pos.ksh \ + functional/refreserv/refreserv_004_pos.ksh \ + functional/refreserv/refreserv_005_pos.ksh \ + functional/refreserv/refreserv_multi_raidz.ksh \ + functional/refreserv/refreserv_raidz.ksh \ + functional/refreserv/setup.ksh \ + functional/removal/cleanup.ksh \ + functional/removal/removal_all_vdev.ksh \ + functional/removal/removal_cancel.ksh \ + functional/removal/removal_check_space.ksh \ + functional/removal/removal_condense_export.ksh \ + functional/removal/removal_multiple_indirection.ksh \ + functional/removal/removal_nopwrite.ksh \ + functional/removal/removal_remap_deadlists.ksh \ + functional/removal/removal_reservation.ksh \ + functional/removal/removal_resume_export.ksh \ + functional/removal/removal_sanity.ksh \ + functional/removal/removal_with_add.ksh \ + functional/removal/removal_with_create_fs.ksh \ + functional/removal/removal_with_dedup.ksh \ + functional/removal/removal_with_errors.ksh \ + functional/removal/removal_with_export.ksh \ + functional/removal/removal_with_faulted.ksh \ + functional/removal/removal_with_ganging.ksh \ + functional/removal/removal_with_remove.ksh \ + functional/removal/removal_with_scrub.ksh \ + functional/removal/removal_with_send.ksh \ + functional/removal/removal_with_send_recv.ksh \ + functional/removal/removal_with_snapshot.ksh \ + functional/removal/removal_with_write.ksh \ + functional/removal/removal_with_zdb.ksh \ + functional/removal/remove_attach_mirror.ksh \ + functional/removal/remove_expanded.ksh \ + functional/removal/remove_indirect.ksh \ + functional/removal/remove_mirror.ksh \ + functional/removal/remove_mirror_sanity.ksh \ + functional/removal/remove_raidz.ksh \ + functional/rename_dirs/cleanup.ksh \ + functional/rename_dirs/rename_dirs_001_pos.ksh \ + functional/rename_dirs/setup.ksh \ + functional/replacement/attach_import.ksh \ + functional/replacement/attach_multiple.ksh \ + functional/replacement/attach_rebuild.ksh \ + functional/replacement/attach_resilver.ksh \ + functional/replacement/cleanup.ksh \ + functional/replacement/detach.ksh \ + functional/replacement/rebuild_disabled_feature.ksh \ + functional/replacement/rebuild_multiple.ksh \ + functional/replacement/rebuild_raidz.ksh \ + functional/replacement/replace_import.ksh \ + functional/replacement/replace_rebuild.ksh \ + functional/replacement/replace_resilver.ksh \ + functional/replacement/resilver_restart_001.ksh \ + functional/replacement/resilver_restart_002.ksh \ + functional/replacement/scrub_cancel.ksh \ + functional/replacement/setup.ksh \ + functional/reservation/cleanup.ksh \ + functional/reservation/reservation_001_pos.ksh \ + functional/reservation/reservation_002_pos.ksh \ + functional/reservation/reservation_003_pos.ksh \ + functional/reservation/reservation_004_pos.ksh \ + functional/reservation/reservation_005_pos.ksh \ + functional/reservation/reservation_006_pos.ksh \ + functional/reservation/reservation_007_pos.ksh \ + functional/reservation/reservation_008_pos.ksh \ + functional/reservation/reservation_009_pos.ksh \ + functional/reservation/reservation_010_pos.ksh \ + functional/reservation/reservation_011_pos.ksh \ + functional/reservation/reservation_012_pos.ksh \ + functional/reservation/reservation_013_pos.ksh \ + functional/reservation/reservation_014_pos.ksh \ + functional/reservation/reservation_015_pos.ksh \ + functional/reservation/reservation_016_pos.ksh \ + functional/reservation/reservation_017_pos.ksh \ + functional/reservation/reservation_018_pos.ksh \ + functional/reservation/reservation_019_pos.ksh \ + functional/reservation/reservation_020_pos.ksh \ + functional/reservation/reservation_021_neg.ksh \ + functional/reservation/reservation_022_pos.ksh \ + functional/reservation/setup.ksh \ + functional/rootpool/cleanup.ksh \ + functional/rootpool/rootpool_002_neg.ksh \ + functional/rootpool/rootpool_003_neg.ksh \ + functional/rootpool/rootpool_007_pos.ksh \ + functional/rootpool/setup.ksh \ + functional/rsend/cleanup.ksh \ + functional/rsend/recv_dedup_encrypted_zvol.ksh \ + functional/rsend/recv_dedup.ksh \ + functional/rsend/rsend_001_pos.ksh \ + functional/rsend/rsend_002_pos.ksh \ + functional/rsend/rsend_003_pos.ksh \ + functional/rsend/rsend_004_pos.ksh \ + functional/rsend/rsend_005_pos.ksh \ + functional/rsend/rsend_006_pos.ksh \ + functional/rsend/rsend_007_pos.ksh \ + functional/rsend/rsend_008_pos.ksh \ + functional/rsend/rsend_009_pos.ksh \ + functional/rsend/rsend_010_pos.ksh \ + functional/rsend/rsend_011_pos.ksh \ + functional/rsend/rsend_012_pos.ksh \ + functional/rsend/rsend_013_pos.ksh \ + functional/rsend/rsend_014_pos.ksh \ + functional/rsend/rsend_016_neg.ksh \ + functional/rsend/rsend_019_pos.ksh \ + functional/rsend/rsend_020_pos.ksh \ + functional/rsend/rsend_021_pos.ksh \ + functional/rsend/rsend_022_pos.ksh \ + functional/rsend/rsend_024_pos.ksh \ + functional/rsend/rsend_025_pos.ksh \ + functional/rsend/rsend_026_neg.ksh \ + functional/rsend/rsend_027_pos.ksh \ + functional/rsend/rsend_028_neg.ksh \ + functional/rsend/rsend_029_neg.ksh \ + functional/rsend/send-c_embedded_blocks.ksh \ + functional/rsend/send-c_incremental.ksh \ + functional/rsend/send-c_lz4_disabled.ksh \ + functional/rsend/send-c_mixed_compression.ksh \ + functional/rsend/send-cpL_varied_recsize.ksh \ + functional/rsend/send-c_props.ksh \ + functional/rsend/send-c_recv_dedup.ksh \ + functional/rsend/send-c_recv_lz4_disabled.ksh \ + functional/rsend/send-c_resume.ksh \ + functional/rsend/send-c_stream_size_estimate.ksh \ + functional/rsend/send-c_verify_contents.ksh \ + functional/rsend/send-c_verify_ratio.ksh \ + functional/rsend/send-c_volume.ksh \ + functional/rsend/send-c_zstreamdump.ksh \ + functional/rsend/send_doall.ksh \ + functional/rsend/send_encrypted_files.ksh \ + functional/rsend/send_encrypted_hierarchy.ksh \ + functional/rsend/send_encrypted_props.ksh \ + functional/rsend/send_encrypted_truncated_files.ksh \ + functional/rsend/send_freeobjects.ksh \ + functional/rsend/send_holds.ksh \ + functional/rsend/send_hole_birth.ksh \ + functional/rsend/send_invalid.ksh \ + functional/rsend/send-L_toggle.ksh \ + functional/rsend/send_mixed_raw.ksh \ + functional/rsend/send_partial_dataset.ksh \ + functional/rsend/send_raw_ashift.ksh \ + functional/rsend/send_raw_spill_block.ksh \ + functional/rsend/send_realloc_dnode_size.ksh \ + functional/rsend/send_realloc_encrypted_files.ksh \ + functional/rsend/send_realloc_files.ksh \ + functional/rsend/send_spill_block.ksh \ + functional/rsend/send-wR_encrypted_zvol.ksh \ + functional/rsend/setup.ksh \ + functional/scrub_mirror/cleanup.ksh \ + functional/scrub_mirror/scrub_mirror_001_pos.ksh \ + functional/scrub_mirror/scrub_mirror_002_pos.ksh \ + functional/scrub_mirror/scrub_mirror_003_pos.ksh \ + functional/scrub_mirror/scrub_mirror_004_pos.ksh \ + functional/scrub_mirror/setup.ksh \ + functional/slog/cleanup.ksh \ + functional/slog/setup.ksh \ + functional/slog/slog_001_pos.ksh \ + functional/slog/slog_002_pos.ksh \ + functional/slog/slog_003_pos.ksh \ + functional/slog/slog_004_pos.ksh \ + functional/slog/slog_005_pos.ksh \ + functional/slog/slog_006_pos.ksh \ + functional/slog/slog_007_pos.ksh \ + functional/slog/slog_008_neg.ksh \ + functional/slog/slog_009_neg.ksh \ + functional/slog/slog_010_neg.ksh \ + functional/slog/slog_011_neg.ksh \ + functional/slog/slog_012_neg.ksh \ + functional/slog/slog_013_pos.ksh \ + functional/slog/slog_014_pos.ksh \ + functional/slog/slog_015_neg.ksh \ + functional/slog/slog_016_pos.ksh \ + functional/slog/slog_replay_fs_001.ksh \ + functional/slog/slog_replay_fs_002.ksh \ + functional/slog/slog_replay_volume.ksh \ + functional/snapshot/cleanup.ksh \ + functional/snapshot/clone_001_pos.ksh \ + functional/snapshot/rollback_001_pos.ksh \ + functional/snapshot/rollback_002_pos.ksh \ + functional/snapshot/rollback_003_pos.ksh \ + functional/snapshot/setup.ksh \ + functional/snapshot/snapshot_001_pos.ksh \ + functional/snapshot/snapshot_002_pos.ksh \ + functional/snapshot/snapshot_003_pos.ksh \ + functional/snapshot/snapshot_004_pos.ksh \ + functional/snapshot/snapshot_005_pos.ksh \ + functional/snapshot/snapshot_006_pos.ksh \ + functional/snapshot/snapshot_007_pos.ksh \ + functional/snapshot/snapshot_008_pos.ksh \ + functional/snapshot/snapshot_009_pos.ksh \ + functional/snapshot/snapshot_010_pos.ksh \ + functional/snapshot/snapshot_011_pos.ksh \ + functional/snapshot/snapshot_012_pos.ksh \ + functional/snapshot/snapshot_013_pos.ksh \ + functional/snapshot/snapshot_014_pos.ksh \ + functional/snapshot/snapshot_015_pos.ksh \ + functional/snapshot/snapshot_016_pos.ksh \ + functional/snapshot/snapshot_017_pos.ksh \ + functional/snapused/cleanup.ksh \ + functional/snapused/setup.ksh \ + functional/snapused/snapused_001_pos.ksh \ + functional/snapused/snapused_002_pos.ksh \ + functional/snapused/snapused_003_pos.ksh \ + functional/snapused/snapused_004_pos.ksh \ + functional/snapused/snapused_005_pos.ksh \ + functional/sparse/cleanup.ksh \ + functional/sparse/setup.ksh \ + functional/sparse/sparse_001_pos.ksh \ + functional/stat/cleanup.ksh \ + functional/stat/setup.ksh \ + functional/stat/stat_001_pos.ksh \ + functional/suid/cleanup.ksh \ + functional/suid/setup.ksh \ + functional/suid/suid_write_to_none.ksh \ + functional/suid/suid_write_to_sgid.ksh \ + functional/suid/suid_write_to_suid.ksh \ + functional/suid/suid_write_to_suid_sgid.ksh \ + functional/suid/suid_write_zil_replay.ksh \ + functional/trim/autotrim_config.ksh \ + functional/trim/autotrim_integrity.ksh \ + functional/trim/autotrim_trim_integrity.ksh \ + functional/trim/cleanup.ksh \ + functional/trim/setup.ksh \ + functional/trim/trim_config.ksh \ + functional/trim/trim_integrity.ksh \ + functional/trim/trim_l2arc.ksh \ + functional/truncate/cleanup.ksh \ + functional/truncate/setup.ksh \ + functional/truncate/truncate_001_pos.ksh \ + functional/truncate/truncate_002_pos.ksh \ + functional/truncate/truncate_timestamps.ksh \ + functional/upgrade/cleanup.ksh \ + functional/upgrade/setup.ksh \ + functional/upgrade/upgrade_projectquota_001_pos.ksh \ + functional/upgrade/upgrade_readonly_pool.ksh \ + functional/upgrade/upgrade_userobj_001_pos.ksh \ + functional/user_namespace/cleanup.ksh \ + functional/user_namespace/setup.ksh \ + functional/user_namespace/user_namespace_001.ksh \ + functional/userquota/cleanup.ksh \ + functional/userquota/groupspace_001_pos.ksh \ + functional/userquota/groupspace_002_pos.ksh \ + functional/userquota/groupspace_003_pos.ksh \ + functional/userquota/setup.ksh \ + functional/userquota/userquota_001_pos.ksh \ + functional/userquota/userquota_002_pos.ksh \ + functional/userquota/userquota_003_pos.ksh \ + functional/userquota/userquota_004_pos.ksh \ + functional/userquota/userquota_005_neg.ksh \ + functional/userquota/userquota_006_pos.ksh \ + functional/userquota/userquota_007_pos.ksh \ + functional/userquota/userquota_008_pos.ksh \ + functional/userquota/userquota_009_pos.ksh \ + functional/userquota/userquota_010_pos.ksh \ + functional/userquota/userquota_011_pos.ksh \ + functional/userquota/userquota_012_neg.ksh \ + functional/userquota/userquota_013_pos.ksh \ + functional/userquota/userspace_001_pos.ksh \ + functional/userquota/userspace_002_pos.ksh \ + functional/userquota/userspace_003_pos.ksh \ + functional/userquota/userspace_encrypted.ksh \ + functional/userquota/userspace_send_encrypted.ksh \ + functional/vdev_zaps/cleanup.ksh \ + functional/vdev_zaps/setup.ksh \ + functional/vdev_zaps/vdev_zaps_001_pos.ksh \ + functional/vdev_zaps/vdev_zaps_002_pos.ksh \ + functional/vdev_zaps/vdev_zaps_003_pos.ksh \ + functional/vdev_zaps/vdev_zaps_004_pos.ksh \ + functional/vdev_zaps/vdev_zaps_005_pos.ksh \ + functional/vdev_zaps/vdev_zaps_006_pos.ksh \ + functional/vdev_zaps/vdev_zaps_007_pos.ksh \ + functional/write_dirs/cleanup.ksh \ + functional/write_dirs/setup.ksh \ + functional/write_dirs/write_dirs_001_pos.ksh \ + functional/write_dirs/write_dirs_002_pos.ksh \ + functional/xattr/cleanup.ksh \ + functional/xattr/setup.ksh \ + functional/xattr/xattr_001_pos.ksh \ + functional/xattr/xattr_002_neg.ksh \ + functional/xattr/xattr_003_neg.ksh \ + functional/xattr/xattr_004_pos.ksh \ + functional/xattr/xattr_005_pos.ksh \ + functional/xattr/xattr_006_pos.ksh \ + functional/xattr/xattr_007_neg.ksh \ + functional/xattr/xattr_008_pos.ksh \ + functional/xattr/xattr_009_neg.ksh \ + functional/xattr/xattr_010_neg.ksh \ + functional/xattr/xattr_011_pos.ksh \ + functional/xattr/xattr_012_pos.ksh \ + functional/xattr/xattr_013_pos.ksh \ + functional/xattr/xattr_compat.ksh \ + functional/zpool_influxdb/cleanup.ksh \ + functional/zpool_influxdb/setup.ksh \ + functional/zpool_influxdb/zpool_influxdb.ksh \ + functional/zvol/zvol_cli/cleanup.ksh \ + functional/zvol/zvol_cli/setup.ksh \ + functional/zvol/zvol_cli/zvol_cli_001_pos.ksh \ + functional/zvol/zvol_cli/zvol_cli_002_pos.ksh \ + functional/zvol/zvol_cli/zvol_cli_003_neg.ksh \ + functional/zvol/zvol_ENOSPC/cleanup.ksh \ + functional/zvol/zvol_ENOSPC/setup.ksh \ + functional/zvol/zvol_ENOSPC/zvol_ENOSPC_001_pos.ksh \ + functional/zvol/zvol_misc/cleanup.ksh \ + functional/zvol/zvol_misc/setup.ksh \ + functional/zvol/zvol_misc/zvol_misc_001_neg.ksh \ + functional/zvol/zvol_misc/zvol_misc_002_pos.ksh \ + functional/zvol/zvol_misc/zvol_misc_003_neg.ksh \ + functional/zvol/zvol_misc/zvol_misc_004_pos.ksh \ + functional/zvol/zvol_misc/zvol_misc_005_neg.ksh \ + functional/zvol/zvol_misc/zvol_misc_006_pos.ksh \ + functional/zvol/zvol_misc/zvol_misc_hierarchy.ksh \ + functional/zvol/zvol_misc/zvol_misc_rename_inuse.ksh \ + functional/zvol/zvol_misc/zvol_misc_snapdev.ksh \ + functional/zvol/zvol_misc/zvol_misc_volmode.ksh \ + functional/zvol/zvol_misc/zvol_misc_zil.ksh \ + functional/zvol/zvol_swap/cleanup.ksh \ + functional/zvol/zvol_swap/setup.ksh \ + functional/zvol/zvol_swap/zvol_swap_001_pos.ksh \ + functional/zvol/zvol_swap/zvol_swap_002_pos.ksh \ + functional/zvol/zvol_swap/zvol_swap_003_pos.ksh \ + functional/zvol/zvol_swap/zvol_swap_004_pos.ksh \ + functional/zvol/zvol_swap/zvol_swap_005_pos.ksh \ + functional/zvol/zvol_swap/zvol_swap_006_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/Makefile.am deleted file mode 100644 index 9164650e3419..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/Makefile.am +++ /dev/null @@ -1,95 +0,0 @@ -SUBDIRS = \ - acl \ - alloc_class \ - arc \ - atime \ - bootfs \ - btree \ - cache \ - cachefile \ - casenorm \ - channel_program \ - chattr \ - checksum \ - clean_mirror \ - cli_root \ - cli_user \ - compression \ - cp_files \ - crtime \ - ctime \ - deadman \ - delegate \ - devices \ - dos_attributes \ - events \ - exec \ - fallocate \ - fault \ - features \ - grow \ - history \ - hkdf \ - inheritance \ - inuse \ - io \ - l2arc \ - large_files \ - largest_pool \ - libzfs \ - limits \ - link_count \ - log_spacemap \ - migration \ - mmap \ - mmp \ - mount \ - mv_files \ - nestedfs \ - no_space \ - nopwrite \ - online_offline \ - pam \ - pool_checkpoint \ - pool_names \ - poolversion \ - privilege \ - procfs \ - projectquota \ - pyzfs \ - quota \ - raidz \ - redacted_send \ - redundancy \ - refquota \ - refreserv \ - removal \ - rename_dirs \ - replacement \ - reservation \ - rootpool \ - rsend \ - scrub_mirror \ - slog \ - snapshot \ - snapused \ - sparse \ - stat \ - suid \ - threadsappend \ - trim \ - truncate \ - upgrade \ - user_namespace \ - userquota \ - vdev_zaps \ - write_dirs \ - xattr \ - zpool_influxdb \ - zvol - -if BUILD_LINUX -SUBDIRS += \ - simd \ - tmpfile -endif diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/Makefile.am deleted file mode 100644 index d752f63744cb..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/acl -dist_pkgdata_DATA = \ - acl.cfg \ - acl_common.kshlib - -SUBDIRS = off posix posix-sa diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/acl_common.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/acl_common.kshlib index ba08bcb48bef..5f4f91485e8e 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/acl_common.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/acl_common.kshlib @@ -31,21 +31,6 @@ . $STF_SUITE/tests/functional/acl/acl.cfg . $STF_SUITE/include/libtest.shlib -# -# Get the given file/directory access mode -# -# $1 object -- file or directory -# -function get_mode # -{ - typeset obj=$1 - if (( ${#obj} == 0 )); then - return 1 - fi - - ls -ld $obj | awk '{print $1}' -} - # # Get the given file/directory ACL # @@ -58,7 +43,7 @@ function get_acl # return 1 fi - ls -vd $obj | nawk '(NR != 1) {print $0}' + ls -vd $obj | awk '(NR != 1) {print $0}' } # @@ -73,7 +58,7 @@ function get_compact_acl # return 1 fi - ls -Vd $obj | nawk '(NR != 1) {print $0}' + ls -Vd $obj | awk '(NR != 1) {print $0}' } # @@ -98,7 +83,7 @@ function compare_acls # get_acl $src > $tmpsrc get_acl $tgt > $tmptgt typeset -i ret=0 - diff $tmpsrc $tmptgt > /dev/null 2>&1 + cmp $tmpsrc $tmptgt > /dev/null ret=$? rm -f $tmpsrc $tmptgt @@ -108,43 +93,13 @@ function compare_acls # get_compact_acl $src > $tmpsrc get_compact_acl $tgt > $tmptgt - diff $tmpsrc $tmptgt > /dev/null 2>&1 + cmp $tmpsrc $tmptgt > /dev/null ret=$? rm -f $tmpsrc $tmptgt return $ret } -# -# Check that the given two objects have the same modes. -# Return 0, if their modes are equal with each other. Otherwise, return 1. -# -# $1 source object -# $2 target object -# -function compare_modes # -{ - typeset src=$1 - typeset tgt=$2 - typeset -i i=0 - set -A mode - - (( ${#src} == 0 || ${#tgt} == 0 )) && return 1 - [[ $src == $tgt ]] && return 0 - - typeset obj - for obj in $src $tgt - do - mode[i]=$(get_mode $obj) - - (( i = i + 1 )) - done - - [[ ${mode[0]} != ${mode[1]} ]] && return 1 - - return 0 -} - # # Check that the given two objects have the same xattrs. # Return 0, if their xattrs are equal with each other. Otherwise, return 1. @@ -166,69 +121,13 @@ function compare_xattrs # get_xattr $src > $tmpsrc get_xattr $tgt > $tmptgt typeset -i ret=0 - diff $tmpsrc $tmptgt > /dev/null 2>&1 + cmp $tmpsrc $tmptgt > /dev/null ret=$? rm -f $tmpsrc $tmptgt return $ret } -# -# Check '+' is set for a given file/directory with 'ls [-l]' command -# -# $1 object -- file or directory. -# -function plus_sign_check_l # -{ - typeset obj=$1 - if (( ${#obj} == 0 )); then - return 1 - fi - - ls -ld $obj | awk '{print $1}' | grep "+$" > /dev/null - - return $? -} - -# -# Check '+' is set for a given file/directory with 'ls [-v]' command -# -# $1 object -- file or directory. -# -function plus_sign_check_v # -{ - typeset obj=$1 - if (( ${#obj} == 0 )); then - return 1 - fi - - ls -vd $obj | awk '(NR == 1) {print $1}' | grep "+$" > /dev/null - - return $? -} - -# -# A wrapper function of c program -# -# $1 legal login name -# $2-n commands and options -# -function chgusr_exec # [...] -{ - chg_usr_exec $@ - return $? -} - -# -# Export the current user for the following usr_exec operating. -# -# $1 legal login name -# -function set_cur_usr # -{ - export ZFS_ACL_CUR_USER=$1 -} - # # Run commands by $ZFS_ACL_CUR_USER # @@ -237,83 +136,6 @@ function set_cur_usr # function usr_exec # [...] { chg_usr_exec "$ZFS_ACL_CUR_USER" $@ - return $? -} - -# -# Count how many ACEs for the specified file or directory. -# -# $1 file or directory name -# -function count_ACE # -{ - if [[ ! -e $1 ]]; then - log_note "Need input file or directory name." - return 1 - fi - - ls -vd $1 | nawk 'BEGIN {count=0} - (NR != 1)&&(/[0-9]:/) {count++} - END {print count}' - - return 0 -} - -# -# Get specified number ACE content of specified file or directory. -# -# $1 file or directory name -# $2 specified number -# -function get_ACE # -{ - if [[ ! -e $1 || $2 -ge $(count_ACE $1) ]]; then - return 1 - fi - - typeset file=$1 - typeset -i num=$2 - typeset format=${3:-verbose} - typeset -i next_num=-1 - - typeset tmpfile=$TEST_BASE_DIR/tmp_get_ACE.$$ - typeset line="" - typeset args - - case $format in - verbose) args="-vd" - ;; - compact) args="-Vd" - ;; - *) log_fail "Invalid parameter as ($format), " \ - "only verbose|compact is supported." - ;; - esac - - ls $args $file > $tmpfile - (( $? != 0 )) && log_fail "FAIL: ls $args $file > $tmpfile" - while read line; do - [[ -z $line ]] && continue - if [[ $args == -vd ]]; then - if [[ $line == "$num":* ]]; then - (( next_num = num + 1 )) - fi - if [[ $line == "$next_num":* ]]; then - break - fi - if (( next_num != -1 )); then - print -n $line - fi - else - if (( next_num == num )); then - print -n $line - fi - (( next_num += 1 )) - fi - done < $tmpfile - - rm -f $tmpfile - (( $? != 0 )) && log_fail "FAIL: rm -f $tmpfile" } # @@ -345,57 +167,6 @@ function cleanup fi } -# -# According to specified access or acl_spec, do relevant operating by using the -# specified user. -# -# $1 specified user -# $2 node -# $3 acl_spec or access -# -function rwx_node #user node acl_spec|access -{ - typeset user=$1 - typeset node=$2 - typeset acl_spec=$3 - - if [[ $user == "" || $node == "" || $acl_spec == "" ]]; then - log_note "node or acl_spec are not defined." - return 1 - fi - - if [[ -d $node ]]; then - case $acl_spec in - *:read_data:*|read_data) - chgusr_exec $user ls -l $node > /dev/null 2>&1 - return $? ;; - *:write_data:*|write_data) - if [[ -f ${node}/tmpfile ]]; then - log_must rm -f ${node}/tmpfile - fi - chgusr_exec $user touch ${node}/tmpfile > \ - /dev/null 2>&1 - return $? ;; - *"execute:"*|execute) - chgusr_exec $user find $node > /dev/null 2>&1 - return $? ;; - esac - else - case $acl_spec in - *:read_data:*|read_data) - chgusr_exec $user cat $node > /dev/null 2>&1 - return $? ;; - *:write_data:*|write_data) - chgusr_exec $user dd if=/usr/bin/ls of=$node > \ - /dev/null 2>&1 - return $? ;; - *"execute:"*|execute) - ZFS_ACL_ERR_STR=$(chgusr_exec $user $node 2>&1) - return $? ;; - esac - fi -} - # # Get the given file/directory xattr # @@ -409,133 +180,11 @@ function get_xattr # return 1 fi - for xattr in `runat $obj ls | \ - grep -E -v -e SUNWattr_ro -e SUNWattr_rw` ; do - runat $obj sum $xattr + for xattr in $(runat $obj ls | grep -v 'SUNWattr_r[ow]'); do + runat $obj cksum $xattr done } -# -# Get the owner of a file/directory -# -function get_owner #node -{ - typeset node=$1 - typeset value - - if [[ -z $node ]]; then - log_fail "node are not defined." - fi - - if [[ -d $node ]]; then - value=$(ls -dl $node | awk '{print $3}') - elif [[ -e $node ]]; then - value=$(ls -l $node | awk '{print $3}') - fi - - echo $value -} - -# -# Get the group of a file/directory -# -function get_group #node -{ - typeset node=$1 - typeset value - - if [[ -z $node ]]; then - log_fail "node are not defined." - fi - - if [[ -d $node ]]; then - value=$(ls -dl $node | awk '{print $4}') - elif [[ -e $node ]]; then - value=$(ls -l $node | awk '{print $4}') - fi - - echo $value -} - - -# -# Get the group name that a UID belongs to -# -function get_user_group #uid -{ - typeset uid=$1 - typeset value - - if [[ -z $uid ]]; then - log_fail "UID not defined." - fi - - value=$(id $uid) - - if [[ $? -eq 0 ]]; then - value=${value##*\(} - value=${value%%\)*} - echo $value - else - log_fail "Invalid UID (uid)." - fi -} - -# -# Get the specified item of the specified string -# -# $1: Item number, count from 0. -# $2-n: strings -# -function getitem -{ - typeset -i n=$1 - shift - - (( n += 1 )) - eval echo \${$n} -} - -# -# This function calculate the specified directory files checksum and write -# to the specified array. -# -# $1 directory in which the files will be cksum. -# $2 file array name which was used to store file cksum information. -# $3 attribute array name which was used to store attribute information. -# -function cksum_files # -{ - typeset dir=$1 - typeset farr_name=$2 - typeset aarr_name=$3 - - [[ ! -d $dir ]] && return - typeset oldpwd=$PWD - cd $dir - typeset files=$(ls file*) - - typeset -i i=0 - typeset -i n=0 - while (( i < NUM_FILE )); do - typeset f=$(getitem $i $files) - eval $farr_name[$i]=\$\(\cksum $f\) - - typeset -i j=0 - while (( j < NUM_ATTR )); do - eval $aarr_name[$n]=\$\(\runat \$f \cksum \ - attribute.$j\) - - (( j += 1 )) - (( n += 1 )) - done - - (( i += 1 )) - done - - cd $oldpwd -} - # # This function compare two cksum results array. # @@ -563,26 +212,6 @@ function compare_cksum # return 0 } -# -# This function calculate all the files cksum information in current directory -# and output them to the specified file. -# -# $1 directory from which the files will be cksum. -# $2 cksum output file -# -function record_cksum # -{ - typeset dir=$1 - typeset outfile=$2 - - [[ ! -d ${outfile%/*} ]] && usr_exec mkdir -p ${outfile%/*} - - usr_exec cd $dir ; find . -depth -type f -exec cksum {} \\\; | \ - sort > $outfile - usr_exec cd $dir ; find . -depth -type f -xattr -exec runat {} \ - cksum attribute* \\\; | sort >> $outfile -} - # # The function create_files creates the directories and files that the script # will operate on to test extended attribute functionality. diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/off/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/off/.gitignore deleted file mode 100644 index f3c93191cea9..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/off/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/dosmode_readonly_write diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/off/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/off/Makefile.am deleted file mode 100644 index ae6a9c69d934..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/off/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/acl/off - -dist_pkgdata_SCRIPTS = \ - dosmode.ksh \ - posixmode.ksh \ - cleanup.ksh \ - setup.ksh - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/acl/off - -pkgexec_PROGRAMS = dosmode_readonly_write -dosmode_readonly_write_SOURCES = dosmode_readonly_write.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/off/dosmode.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/off/dosmode.ksh index 585aa025390c..bab2109b9d58 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/off/dosmode.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/off/dosmode.ksh @@ -55,18 +55,15 @@ function hasflag typeset path=$2 if is_linux; then - read_dos_attributes $path | awk \ - '{ gsub(",", "\n", $1); print $1 }' | grep -qxF $flag + read_dos_attributes $path else - ls -lo $path | awk '{ gsub(",", "\n", $5); print $5 }' | \ - grep -qxF $flag - fi + ls -lo $path | awk '{ print $5 }' + fi | grep -qwF $flag } log_assert "Verify DOS mode flags function correctly" log_onexit cleanup -tests_base=$STF_SUITE/tests/functional/acl/off testfile=$TESTDIR/testfile owner=$ZFS_ACL_STAFF1 other=$ZFS_ACL_STAFF2 @@ -159,7 +156,7 @@ log_must rm $testfile # READONLY is set. We have a special test program for that. log_must user_run $owner touch $testfile log_mustnot user_run $other $changeflags rdonly $testfile -log_must user_run $owner $tests_base/dosmode_readonly_write $testfile +log_must user_run $owner dosmode_readonly_write $testfile log_mustnot user_run $other $changeflags nordonly $testfile log_must hasflag rdonly $testfile if ! is_linux; then diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix-sa/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix-sa/Makefile.am deleted file mode 100644 index 31d1237ce265..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix-sa/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/acl/posix-sa -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - posix_001_pos.ksh \ - posix_002_pos.ksh \ - posix_003_pos.ksh \ - posix_004_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/Makefile.am deleted file mode 100644 index e63f63185afe..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/acl/posix -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - posix_001_pos.ksh \ - posix_002_pos.ksh \ - posix_003_pos.ksh \ - posix_004_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh index d62bf9c346b6..65c15388cf20 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh @@ -57,41 +57,41 @@ log_onexit cleanup log_note "Testing access to FILE" log_must touch $TESTDIR/file.0 log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:rw $TESTDIR/file.0 -getfacl $TESTDIR/file.0 2> /dev/null | egrep -q \ - "^group:$ZFS_ACL_STAFF_GROUP:rw-$" -if [ "$?" -eq "0" ]; then - # Should be able to write to file - log_must user_run $ZFS_ACL_STAFF1 \ - "echo 'echo test > /dev/null' > $TESTDIR/file.0" - - # Since $TESTDIR is 777, create a new dir with controlled permissions - # for testing that creating a new file is not allowed. - log_must mkdir $TESTDIR/dir.0 - log_must chmod 700 $TESTDIR/dir.0 - log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:rw $TESTDIR/dir.0 - # Confirm permissions - ls -l $TESTDIR |grep "dir.0" |grep -q "drwxrw----+" - if [ "$?" -ne "0" ]; then - msk=$(ls -l $TESTDIR |grep "dir.0" | awk '{print $1}') - log_note "expected mask drwxrw----+ but found $msk" - log_fail "Expected permissions were not set." - fi - getfacl $TESTDIR/dir.0 2> /dev/null | egrep -q \ - "^group:$ZFS_ACL_STAFF_GROUP:rw-$" - if [ "$?" -ne "0" ]; then - acl=$(getfacl $TESTDIR/dir.0 2> /dev/null) - log_note $acl - log_fail "ACL group:$ZFS_ACL_STAFF_GROUP:rw- was not set." - fi - # Should NOT be able to create new file - log_mustnot user_run $ZFS_ACL_STAFF1 "touch $TESTDIR/dir.0/file.1" - - # Root should be able to run file, but not user - chmod +x $TESTDIR/file.0 - log_must $TESTDIR/file.0 - log_mustnot user_run $ZFS_ACL_STAFF1 $TESTDIR/file.0 - - log_pass "POSIX ACL mode works on files" -else +if ! getfacl $TESTDIR/file.0 2> /dev/null | + grep -qFx "group:$ZFS_ACL_STAFF_GROUP:rw-" +then + log_note "$(getfacl $TESTDIR/file.0 2> /dev/null)" log_fail "Group '$ZFS_ACL_STAFF_GROUP' does not have 'rw' as specified" fi + +# Should be able to write to file +log_must user_run $ZFS_ACL_STAFF1 \ + "echo 'echo test > /dev/null' > $TESTDIR/file.0" + +# Since $TESTDIR is 777, create a new dir with controlled permissions +# for testing that creating a new file is not allowed. +log_must mkdir $TESTDIR/dir.0 +log_must chmod 700 $TESTDIR/dir.0 +log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:rw $TESTDIR/dir.0 +# Confirm permissions +msk=$(ls -ld $TESTDIR/dir.0 | awk '{print $1}') +if ! [ "$msk" = "drwxrw----+" ]; then + log_note "expected mask drwxrw----+ but found $msk" + log_fail "Expected permissions were not set." +fi + +if ! getfacl $TESTDIR/dir.0 2> /dev/null | + grep -qFx "group:$ZFS_ACL_STAFF_GROUP:rw-" +then + log_note "$(getfacl $TESTDIR/dir.0 2> /dev/null)" + log_fail "ACL group:$ZFS_ACL_STAFF_GROUP:rw- was not set." +fi +# Should NOT be able to create new file +log_mustnot user_run $ZFS_ACL_STAFF1 "touch $TESTDIR/dir.0/file.1" + +# Root should be able to run file, but not user +chmod +x $TESTDIR/file.0 +log_must $TESTDIR/file.0 +log_mustnot user_run $ZFS_ACL_STAFF1 $TESTDIR/file.0 + +log_pass "POSIX ACL mode works on files" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh index d9b5036458f8..ac718ec58897 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh @@ -53,15 +53,14 @@ log_must mkdir $TESTDIR/dir.0 log_must chmod 700 $TESTDIR/dir.0 log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:wx $TESTDIR/dir.0 # Confirm permissions -ls -l $TESTDIR |grep "dir.0" |grep -q "drwx-wx---+" -if [ "$?" -ne "0" ]; then - msk=$(ls -l $TESTDIR |grep "dir.0" | awk '{print $1}') +if ! ls -l $TESTDIR | grep "dir.0" | grep -q "drwx-wx---+"; then + msk=$(ls -l $TESTDIR | awk '/dir.0/ {print $1}') log_note "expected mask drwx-wx---+ but found $msk" log_fail "Expected permissions were not set." fi -getfacl $TESTDIR/dir.0 2> /dev/null | egrep -q \ - "^group:$ZFS_ACL_STAFF_GROUP:-wx$" -if [ "$?" -eq "0" ]; then +if getfacl $TESTDIR/dir.0 2> /dev/null | + grep -q "^group:$ZFS_ACL_STAFF_GROUP:-wx$" +then # Should be able to create file in directory log_must user_run $ZFS_ACL_STAFF1 "touch $TESTDIR/dir.0/file.0" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/posix_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/posix_003_pos.ksh index 1b04a024f2ad..bdd77bd37603 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/posix_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/acl/posix/posix_003_pos.ksh @@ -43,16 +43,14 @@ log_note "Testing access to DIRECTORY" log_must mkdir $ACLDIR log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:wx $ACLDIR log_must setfacl -d -m g:$ZFS_ACL_STAFF_GROUP:wx $ACLDIR -getfacl $ACLDIR 2> /dev/null | egrep -q "$acl_str1" -if [ "$?" -eq "0" ]; then - getfacl $ACLDIR 2> /dev/null | egrep -q "$acl_str2" -fi -if [ "$?" -eq "0" ]; then +if getfacl $ACLDIR 2> /dev/null | grep -q "$acl_str1" && + getfacl $ACLDIR 2> /dev/null | grep -q "$acl_str2" +then log_must zfs unmount $TESTPOOL/$TESTFS log_must zfs mount $TESTPOOL/$TESTFS - log_must eval "getfacl $ACLDIR 2> /dev/null | egrep -q \"$acl_str1\"" - log_must eval "getfacl $ACLDIR 2> /dev/null | egrep -q \"$acl_str2\"" + log_must eval "getfacl $ACLDIR 2> /dev/null | grep -q \"$acl_str1\"" + log_must eval "getfacl $ACLDIR 2> /dev/null | grep -q \"$acl_str2\"" log_pass "POSIX ACLs survive remount" else log_fail "Group '$ZFS_ACL_STAFF_GROUP' does not have 'rwx'" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/Makefile.am deleted file mode 100644 index 7cffb2eac450..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/alloc_class -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - alloc_class_001_pos.ksh \ - alloc_class_002_neg.ksh \ - alloc_class_003_pos.ksh \ - alloc_class_004_pos.ksh \ - alloc_class_005_pos.ksh \ - alloc_class_006_pos.ksh \ - alloc_class_007_pos.ksh \ - alloc_class_008_pos.ksh \ - alloc_class_009_pos.ksh \ - alloc_class_010_pos.ksh \ - alloc_class_011_neg.ksh \ - alloc_class_012_pos.ksh \ - alloc_class_013_pos.ksh - -dist_pkgdata_DATA = \ - alloc_class.cfg \ - alloc_class.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/alloc_class_004_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/alloc_class_004_pos.ksh index 79ac9364c257..04ce486adb83 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/alloc_class_004_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/alloc_class_004_pos.ksh @@ -52,8 +52,7 @@ do log_must zpool create $TESTPOOL $type $ZPOOL_DISKS \ special $stype $sdisks - ac_value="$(zpool get -H -o property,value all | \ - egrep allocation_classes | nawk '{print $2}')" + ac_value="$(zpool get -H -o property,value all | awk '/allocation_classes/ {print $2}')" if [ "$ac_value" = "active" ]; then log_note "feature@allocation_classes is active" else diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/alloc_class_005_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/alloc_class_005_pos.ksh index 337114cdb59e..08c703e21acb 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/alloc_class_005_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/alloc_class_005_pos.ksh @@ -42,7 +42,7 @@ do log_must zpool create $TESTPOOL $type $ZPOOL_DISKS fi ac_value="$(zpool get -H -o property,value all | \ - egrep allocation_classes | awk '{print $2}')" + awk '/allocation_classes/ {print $2}')" if [ "$ac_value" = "enabled" ]; then log_note "feature@allocation_classes is enabled" else @@ -57,7 +57,7 @@ do $CLASS_DISK0 $CLASS_DISK1 fi ac_value="$(zpool get -H -o property,value all | \ - egrep allocation_classes | awk '{print $2}')" + awk '/allocation_classes/ {print $2}')" if [ "$ac_value" = "active" ]; then log_note "feature@allocation_classes is active" else diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/alloc_class_010_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/alloc_class_010_pos.ksh index 2c14c69d8b20..cbf5cbf89bdc 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/alloc_class_010_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/alloc_class_010_pos.ksh @@ -39,7 +39,7 @@ for value in 0 512 1024 2048 4096 8192 16384 32768 65536 131072 do log_must zfs set special_small_blocks=$value $TESTPOOL ACTUAL=$(zfs get -p special_small_blocks $TESTPOOL | \ - grep special_small_blocks | awk '{print $3}') + awk '/special_small_blocks/ {print $3}') if [ "$ACTUAL" != "$value" ] then log_fail "v. $ACTUAL set for $TESTPOOL, expected v. $value!" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/alloc_class_011_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/alloc_class_011_neg.ksh index d804e5371ebb..0be49b858758 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/alloc_class_011_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/alloc_class/alloc_class_011_neg.ksh @@ -35,7 +35,7 @@ log_must disk_setup log_must zpool create $TESTPOOL raidz $ZPOOL_DISKS special mirror \ $CLASS_DISK0 $CLASS_DISK1 -for value in 256 1025 2097152 +for value in 256 1025 33554432 do log_mustnot zfs set special_small_blocks=$value $TESTPOOL done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/threadsappend/cleanup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/append/cleanup.ksh similarity index 81% rename from sys/contrib/openzfs/tests/zfs-tests/tests/functional/threadsappend/cleanup.ksh rename to sys/contrib/openzfs/tests/zfs-tests/tests/functional/append/cleanup.ksh index 3166bd6ec16e..307feabd17c6 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/threadsappend/cleanup.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/append/cleanup.ksh @@ -21,14 +21,9 @@ # # -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 2022 by Triad National Security, LCC # -# -# Copyright (c) 2013 by Delphix. All rights reserved. -# - -. $STF_SUITE/include/libtest.shlib +. ${STF_SUITE}/include/libtest.shlib default_cleanup diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/append/file_append.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/append/file_append.ksh new file mode 100755 index 000000000000..b40d10c05edb --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/append/file_append.ksh @@ -0,0 +1,73 @@ +#!/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) 2022 by Triad National Security, LCC +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Tests file offset using O_APPEND. +# +# STRATEGY: +# 1. Open file using O_APPEND +# 2. Write to the file using random number of blocks (1, 2, or 3) +# 3. Verify that the file offset is correct using lseek after the write +# 4. Repeat steps 2 and 3, 5 times +# 5. Close the file. +# 6. Repeat steps 1-5 but also open file with O_DIRECT +# + +verify_runnable "global" + +log_assert "Ensure file offset is updated correctly when opened with O_APPEND" + +mntpt=$(get_prop mountpoint $TESTPOOL/$TESTFS) +filename=$mntpt/append_file.txt +bs=131072 +ITERATIONS=5 +expected=0 + +# First test using buffered writes with O_APPEND +for i in $(seq $ITERATIONS); do + num_blocks=$(random_int_between 1 3) + expected=$((expected + ( bs * num_blocks))) + log_must file_append -f $filename -e $expected -b $bs -n $num_blocks + curr_offset=$expected +done + +log_must rm -f $filename + +expected=0 + +# Repeat same test using O_DIRECT writes with O_APPEND +for i in $(seq $ITERATIONS); do + num_blocks=$(random_int_between 1 3) + expected=$((expected + ( bs * num_blocks))) + log_must file_append -f $filename -e $expected -b $bs -n $num_blocks -d +done + +log_must rm -f $filename + +log_pass "File offset updated correctly when opening a file with O_APPEND." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/threadsappend/setup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/append/setup.ksh similarity index 85% rename from sys/contrib/openzfs/tests/zfs-tests/tests/functional/threadsappend/setup.ksh rename to sys/contrib/openzfs/tests/zfs-tests/tests/functional/append/setup.ksh index 4fc55cd47803..e692d7b1bc0c 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/threadsappend/setup.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/append/setup.ksh @@ -21,12 +21,7 @@ # # -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# Copyright (c) 2013 by Delphix. All rights reserved. +# Copyright (c) 2022 by Triad National Security, LCC # . $STF_SUITE/include/libtest.shlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/threadsappend/threadsappend_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/append/threadsappend_001_pos.ksh similarity index 100% rename from sys/contrib/openzfs/tests/zfs-tests/tests/functional/threadsappend/threadsappend_001_pos.ksh rename to sys/contrib/openzfs/tests/zfs-tests/tests/functional/append/threadsappend_001_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/arc/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/arc/Makefile.am deleted file mode 100644 index 809d0346f872..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/arc/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/arc -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - arcstats_runtime_tuning.ksh \ - dbufstats_001_pos.ksh \ - dbufstats_002_pos.ksh \ - dbufstats_003_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh index 712309eda72f..aaab800b60ab 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh @@ -56,8 +56,7 @@ function testdbufstat # stat_name dbufstat_filter [[ -n "$2" ]] && filter="-F $2" if is_linux; then - from_dbufstat=$(grep -w "$name" "$DBUFSTATS_FILE" | - awk '{ print $3 }') + read -r _ _ from_dbufstat _ < <(grep -w "$name" "$DBUFSTATS_FILE") else from_dbufstat=$(awk "/dbufstats\.$name:/ { print \$2 }" \ "$DBUFSTATS_FILE") diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/arc/setup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/arc/setup.ksh index 37b8f352cc64..60699d365eb5 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/arc/setup.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/arc/setup.ksh @@ -26,5 +26,7 @@ . $STF_SUITE/include/libtest.shlib +is_freebsd && ! python3 -c 'import sysctl' 2>/dev/null && log_unsupported "python3 sysctl module missing" + DISK=${DISKS%% *} default_setup $DISK diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/atime/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/atime/Makefile.am deleted file mode 100644 index 63d510b99e75..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/atime/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/atime -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - atime_001_pos.ksh \ - atime_002_neg.ksh \ - atime_003_pos.ksh \ - root_atime_off.ksh \ - root_atime_on.ksh \ - root_relatime_on.ksh - -dist_pkgdata_DATA = \ - atime.cfg \ - atime_common.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/Makefile.am deleted file mode 100644 index 15a6e202c311..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/bootfs -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - bootfs_001_pos.ksh \ - bootfs_002_neg.ksh \ - bootfs_003_pos.ksh \ - bootfs_004_neg.ksh \ - bootfs_005_neg.ksh \ - bootfs_006_pos.ksh \ - bootfs_007_pos.ksh \ - bootfs_008_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_001_pos.ksh index 3e9357063bed..6f2f54ebdddc 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_001_pos.ksh @@ -59,12 +59,6 @@ function cleanup { fi } -zpool set 2>&1 | grep bootfs > /dev/null -if [ $? -ne 0 ] -then - log_unsupported "bootfs pool property not supported on this release." -fi - log_assert "Valid datasets are accepted as bootfs property values" log_onexit cleanup diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_002_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_002_neg.ksh index a5bc7753e96e..172b69400807 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_002_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_002_neg.ksh @@ -60,12 +60,6 @@ function cleanup { } -zpool set 2>&1 | grep bootfs > /dev/null -if [ $? -ne 0 ] -then - log_unsupported "bootfs pool property not supported on this release." -fi - log_assert "Invalid datasets are rejected as boot property values" log_onexit cleanup diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_003_pos.ksh index e719b94e2763..78559dd186c8 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_003_pos.ksh @@ -54,12 +54,6 @@ function cleanup { } -zpool set 2>&1 | grep bootfs > /dev/null -if [ $? -ne 0 ] -then - log_unsupported "bootfs pool property not supported on this release." -fi - log_onexit cleanup log_assert "Valid pool names are accepted by zpool set bootfs" @@ -74,7 +68,7 @@ do log_must zfs create $POOL/$TESTFS log_must zpool set bootfs=$POOL/$TESTFS $POOL - RES=$(zpool get bootfs $POOL | tail -1 | awk '{print $3}' ) + RES=$(zpool get bootfs $POOL | awk 'END {print $3}' ) if [ $RES != "$POOL/$TESTFS" ] then log_fail "Expected $RES == $POOL/$TESTFS" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_004_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_004_neg.ksh index 97b456aade3e..5ea0f6c1a95f 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_004_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_004_neg.ksh @@ -55,12 +55,6 @@ function cleanup { } -zpool set 2>&1 | grep bootfs > /dev/null -if [ $? -ne 0 ] -then - log_unsupported "bootfs pool property not supported on this release." -fi - log_assert "Invalid pool names are rejected by zpool set bootfs" log_onexit cleanup diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh index d29fe7e89c50..2738d3916e2c 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh @@ -44,12 +44,6 @@ verify_runnable "global" -zpool set 2>&1 | grep bootfs > /dev/null -if [ $? -ne 0 ] -then - log_unsupported "bootfs pool property not supported on this release." -fi - VDEV1=$TESTDIR/bootfs_006_pos_a.$$.dat VDEV2=$TESTDIR/bootfs_006_pos_b.$$.dat VDEV3=$TESTDIR/bootfs_006_pos_c.$$.dat @@ -60,7 +54,7 @@ function verify_bootfs { # $POOL log_must zfs create $POOL/$TESTFS log_must zpool set bootfs=$POOL/$TESTFS $POOL - VAL=$(zpool get bootfs $POOL | tail -1 | awk '{print $3}' ) + VAL=$(zpool get bootfs $POOL | awk 'END {print $3}' ) if [ $VAL != "$POOL/$TESTFS" ] then log_must zpool status -v $POOL @@ -74,7 +68,7 @@ function verify_no_bootfs { # $POOL POOL=$1 log_must zfs create $POOL/$TESTFS log_mustnot zpool set bootfs=$POOL/$TESTFS $POOL - VAL=$(zpool get bootfs $POOL | tail -1 | awk '{print $3}' ) + VAL=$(zpool get bootfs $POOL | awk 'END {print $3}' ) if [ $VAL == "$POOL/$TESTFS" ] then log_must zpool status -v $POOL diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/btree/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/btree/Makefile.am deleted file mode 100644 index 333209d98f2b..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/btree/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -# -# This file and its contents are supplied under the terms of the -# Common Development and Distribution License ("CDDL"), version 1.0. -# You may only use this file in accordance with the terms of version -# 1.0 of the CDDL. -# -# A full copy of the text of the CDDL should have accompanied this -# source. A copy of the CDDL is also available via the Internet at -# http://www.illumos.org/license/CDDL. -# - -# -# Copyright (c) 2019 by Delphix. All rights reserved. -# - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/btree - -dist_pkgdata_SCRIPTS = \ - btree_positive.ksh \ - btree_negative.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/btree/btree_negative.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/btree/btree_negative.ksh index cefcbc51e796..667ac87b4fea 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/btree/btree_negative.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/btree/btree_negative.ksh @@ -29,10 +29,7 @@ # looks for return values that correspond to a core dump and cause a test # failure. -btree_test -n insert_duplicate -[[ $? -eq 0 ]] && log_fail "Failure from insert_duplicate" - -btree_test -n remove_missing -[[ $? -eq 0 ]] && log_fail "Failure from remove_missing" +btree_test -n insert_duplicate && log_fail "Failure from insert_duplicate" +btree_test -n remove_missing && log_fail "Failure from remove_missing" log_pass "Btree negative tests passed" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cache/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cache/Makefile.am deleted file mode 100644 index f28130ee9e4d..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cache/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cache -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - cache_001_pos.ksh \ - cache_002_pos.ksh \ - cache_003_pos.ksh \ - cache_004_neg.ksh \ - cache_005_neg.ksh \ - cache_006_pos.ksh \ - cache_007_neg.ksh \ - cache_008_neg.ksh \ - cache_009_pos.ksh \ - cache_010_pos.ksh \ - cache_011_pos.ksh \ - cache_012_pos.ksh - -dist_pkgdata_DATA = \ - cache.cfg \ - cache.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cache/cache.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cache/cache.kshlib index 2e258e22cd39..9948c6280185 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cache/cache.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cache/cache.kshlib @@ -94,7 +94,7 @@ function verify_cache_device # # mirror:/disks/d ONLINE mirror:/disks/e ONLINE stripe:/disks/f ONLINE # - set -A dev_stat_tab $(zpool status -v $pool | nawk 'BEGIN {start=0} \ + set -A dev_stat_tab $(zpool status -v $pool | awk 'BEGIN {start=0} \ /\tcache/ {start=1} /\tmirror/ || /\tspares/ || /^$/ {start=0} (start==1) && /\t (\/|[a-zA-Z])/ \ @@ -146,9 +146,3 @@ function verify_cache_device log_note "Can not find device: $device" return 1 } - -function verify_cache_support -{ - zpool upgrade -v | grep "Cache devices" > /dev/null 2>&1 - return $? -} diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cache/cache_012_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cache/cache_012_pos.ksh index edefe9c1bf68..be250158bf7e 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cache/cache_012_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cache/cache_012_pos.ksh @@ -44,6 +44,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "Looping around a cache device succeeds." function cleanup diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cachefile/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cachefile/Makefile.am deleted file mode 100644 index 53d8c8c6c9d5..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cachefile/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cachefile -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - cachefile_001_pos.ksh \ - cachefile_002_pos.ksh \ - cachefile_003_pos.ksh \ - cachefile_004_pos.ksh - -dist_pkgdata_DATA = \ - cachefile.cfg \ - cachefile.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cachefile/cachefile.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cachefile/cachefile.cfg index d93ec3ed6f3b..bd48cfdf2f87 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cachefile/cachefile.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cachefile/cachefile.cfg @@ -33,5 +33,5 @@ export CPATH1=$TEST_BASE_DIR/cachefile.1.$$ export CPATH2=$TEST_BASE_DIR/cachefile.2.$$ export DISKSARRAY=$DISKS -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') set_device_dir diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/casenorm/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/casenorm/Makefile.am deleted file mode 100644 index b284a2560b27..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/casenorm/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/casenorm -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - case_all_values.ksh \ - insensitive_formd_delete.ksh \ - insensitive_formd_lookup.ksh \ - insensitive_none_delete.ksh \ - insensitive_none_lookup.ksh \ - mixed_create_failure.ksh \ - mixed_formd_delete.ksh \ - mixed_formd_lookup_ci.ksh \ - mixed_formd_lookup.ksh \ - mixed_none_delete.ksh \ - mixed_none_lookup_ci.ksh \ - mixed_none_lookup.ksh \ - norm_all_values.ksh \ - sensitive_formd_delete.ksh \ - sensitive_formd_lookup.ksh \ - sensitive_none_delete.ksh \ - sensitive_none_lookup.ksh - -dist_pkgdata_DATA = \ - casenorm.cfg \ - casenorm.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/casenorm/casenorm.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/casenorm/casenorm.kshlib index f0fe1bbaa886..ad5b5367ae48 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/casenorm/casenorm.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/casenorm/casenorm.kshlib @@ -50,13 +50,8 @@ function delete_file { typeset name=$TESTDIR/$1 - rm $name >/dev/null 2>&1 - - if [[ $? -ne 0 ]] ; then - return 1 - fi - - if [[ -f $name ]] ; then + rm $name >/dev/null 2>&1 || return 1 + if [ -f $name ]; then return 2 fi } @@ -86,10 +81,7 @@ function lookup_file_ci function lookup_any { for name in $NAMES_ALL ; do - lookup_file $name - if [[ $? -eq 0 ]] ; then - return 0 - fi + lookup_file $name && return done return 1 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/casenorm/mixed_create_failure.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/casenorm/mixed_create_failure.ksh index 51b5bb3f6584..208be91dea42 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/casenorm/mixed_create_failure.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/casenorm/mixed_create_failure.ksh @@ -70,6 +70,7 @@ function test_ops { typeset obj_type=$1 typeset testdir=$2 + typeset save_name= target_obj='target-file' @@ -83,7 +84,7 @@ function test_ops log_note "Created test dir $test_path" if [[ $obj_type = "symlink" || $obj_type = "hardlink" ]]; then - touch $test_path/$target_obj + > $test_path/$target_obj log_note "Created target: $test_path/$target_obj" op="$op $test_path/$target_obj" fi @@ -100,29 +101,24 @@ function test_ops save_name="$test_path/$name" break; else - log_err "$cmd failed with unexpected error : $out" + log_fail "$cmd failed: $out" fi fi done + [ -n "$save_name" ] || log_fail "Didn't ENOSPC!" - log_note 'Test rename \"sample_name\" rename' + log_note 'Test rename "sample_name" rename' TMP_OBJ="$test_path/tmp_obj" cmd="$op $TMP_OBJ" - out=$($cmd 2>&1) - ret=$? - if (($ret != 0)); then - log_err "cmd:$cmd failed out:$out" - fi + log_must $cmd # Now, try to rename the tmp_obj to the name which we failed to add earlier. # This should fail as well. - out=$(mv $TMP_OBJ $save_name 2>&1) - ret=$? - if (($ret != 0)); then + if ! out=$(mv $TMP_OBJ $save_name 2>&1); then if [[ $out = *@(No space left on device)* ]]; then - log_note "$cmd failed as expected : $out" + log_note "$cmd failed as expected: $out" else - log_err "$cmd failed with : $out" + log_fail "$cmd failed: $out" fi fi } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/Makefile.am deleted file mode 100644 index 3886863d1dfb..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -SUBDIRS = \ - lua_core \ - synctask_core - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/channel_program -dist_pkgdata_DATA = channel_common.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/channel_common.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/channel_common.kshlib index a828ba29065e..c937e90614c8 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/channel_common.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/channel_common.kshlib @@ -47,9 +47,10 @@ function log_program zfs program $cmdargs >$tmpout 2>$tmperr typeset ret=$? - log_note "input:\n$(cat $tmpin)" - log_note "output:\n$(cat $tmpout)" - log_note "error:\n$(cat $tmperr)" + log_note $'input:\n'"$(<$tmpin)" + log_note $'output:\n'"$(<$tmpout)" + log_note $'error:\n'"$(<$tmperr)" + log_note "ret: $ret" # # Verify correct return value @@ -64,35 +65,29 @@ function log_program # respectively. # if [[ -f "$basename.out" ]] && [[ $expectexit -eq 0 ]]; then - - outdiff=$(diff "$basename.out" "$tmpout") - if [[ $? -ne 0 ]]; then + if ! outdiff=$(diff "$basename.out" "$tmpout"); then output=$(<$tmpout) rm $tmpout $tmperr $tmpin - log_fail "Output mismatch. Expected:\n" \ - "$(<$basename.out)\nBut got:\n$output\n" \ - "Diff:\n$outdiff" + log_fail $'Output mismatch. Expected:\n' \ + "$(<$basename.out)"$'\nBut got:\n'"$output"$'\n' \ + $'Diff:\n'"$outdiff" fi elif [[ -f "$basename.err" ]] && [[ $expectexit -ne 0 ]]; then - - outdiff=$(diff "$basename.err" "$tmperr") - if [[ $? -ne 0 ]]; then + if ! outdiff=$(diff "$basename.err" "$tmperr"); then outputerror=$(<$tmperr) rm $tmpout $tmperr $tmpin - log_fail "Error mismatch. Expected:\n" \ - "$(<$basename.err)\nBut got:\n$outputerror\n" \ - "Diff:\n$outdiff" + log_fail $'Error mismatch. Expected:\n' \ + "$(<$basename.err)"$'\nBut got:\n'"$outputerror"$'\n' \ + $'Diff:\n'"$outdiff" fi elif [[ -n $expecterror ]] && [[ $expectexit -ne 0 ]]; then - - grep -q "$expecterror" $tmperr - if [[ $? -ne 0 ]]; then + if ! grep -q "$expecterror" $tmperr; then outputerror=$(<$tmperr) rm $tmpout $tmperr $tmpin - log_fail "Error mismatch. Expected to contain:\n" \ - "$expecterror\nBut got:\n$outputerror\n" + log_fail $'Error mismatch. Expected to contain:\n' \ + "$expecterror"$'\nBut got:\n'"$outputerror"$'\n' fi elif [[ $expectexit -ne 0 ]]; then diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/Makefile.am deleted file mode 100644 index fb352081190c..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/Makefile.am +++ /dev/null @@ -1,46 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/channel_program/lua_core -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - tst.args_to_lua.ksh \ - tst.divide_by_zero.ksh \ - tst.exists.ksh \ - tst.integer_illegal.ksh \ - tst.integer_overflow.ksh \ - tst.language_functions_neg.ksh \ - tst.language_functions_pos.ksh \ - tst.large_prog.ksh \ - tst.libraries.ksh \ - tst.memory_limit.ksh \ - tst.nested_neg.ksh \ - tst.nested_pos.ksh \ - tst.nvlist_to_lua.ksh \ - tst.recursive_neg.ksh \ - tst.recursive_pos.ksh \ - tst.return_large.ksh \ - tst.return_nvlist_neg.ksh \ - tst.return_nvlist_pos.ksh \ - tst.return_recursive_table.ksh \ - tst.stack_gsub.ksh \ - tst.timeout.ksh - -dist_pkgdata_DATA = \ - tst.args_to_lua.out \ - tst.args_to_lua.zcp \ - tst.divide_by_zero.err \ - tst.divide_by_zero.zcp \ - tst.exists.zcp \ - tst.large_prog.out \ - tst.large_prog.zcp \ - tst.lib_base.lua \ - tst.lib_coroutine.lua \ - tst.lib_strings.lua \ - tst.lib_table.lua \ - tst.nested_neg.zcp \ - tst.nested_pos.zcp \ - tst.recursive.zcp \ - tst.return_large.zcp \ - tst.return_recursive_table.zcp \ - tst.stack_gsub.err \ - tst.stack_gsub.zcp \ - tst.timeout.zcp diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.exists.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.exists.ksh index eba01b17c80e..34f29d9c039d 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.exists.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.exists.ksh @@ -38,8 +38,6 @@ log_must_program $TESTPOOL $ZCP_ROOT/lua_core/tst.exists.zcp \ $TESTPOOL/$TESTCLONE log_mustnot_checkerror_program "not in the target pool" \ - $TESTPOOL - <<-EOF - return zfs.exists('rpool') -EOF + $TESTPOOL - <<<"return zfs.exists('rpool')" log_pass "zfs.exists() gives correct results" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.integer_illegal.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.integer_illegal.ksh index c34f2afd9e18..1c70bc85920a 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.integer_illegal.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.integer_illegal.ksh @@ -32,9 +32,7 @@ set -A args "1.0" \ typeset -i i=0 while (( i < ${#args[*]} )); do - log_mustnot_checkerror_program "malformed number" $TESTPOOL - <<-EOF - return ${args[i]} - EOF + log_mustnot_checkerror_program "malformed number" $TESTPOOL - <<<"return ${args[i]}" ((i = i + 1)) done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.integer_overflow.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.integer_overflow.ksh index c129bae51b04..be2129792499 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.integer_overflow.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.integer_overflow.ksh @@ -25,8 +25,6 @@ verify_runnable "global" log_assert "overflowing a 64-bit integer should wrap around" -log_must_program $TESTPOOL - <<-EOF - assert(18446744073709551615 + 1 == (-18446744073709551616)) -EOF +log_must_program $TESTPOOL - <<<"assert(18446744073709551615 + 1 == (-18446744073709551616))" log_pass "overflowing a 64-bit integer should wrap around" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.language_functions_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.language_functions_neg.ksh index 0125d76c7036..3f91db2be9c3 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.language_functions_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.language_functions_neg.ksh @@ -43,9 +43,7 @@ log_assert "Runtime errors in lua scripts fail as expected." typeset -i i=0 while (( i < ${#args[*]} )); do - log_mustnot_checkerror_program "execution failed" $TESTPOOL - <<-EOF - ${args[i]} - EOF + log_mustnot_checkerror_program "execution failed" $TESTPOOL - <<<"${args[i]}" ((i = i + 1)) done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.language_functions_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.language_functions_pos.ksh index 924d8e2c6944..019622cf84cc 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.language_functions_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.language_functions_pos.ksh @@ -33,9 +33,7 @@ log_assert "Simple lua scripts pass." typeset -i i=0 while (( i < ${#args[*]} )); do - log_must_program $TESTPOOL - <<-EOF - ${args[i]} - EOF + log_must_program $TESTPOOL - <<<"${args[i]}" ((i = i + 1)) done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.return_large.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.return_large.ksh index bbaeb54f59a5..ae42665cd9f5 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.return_large.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.return_large.ksh @@ -41,8 +41,7 @@ log_must zfs create $fs output_lines=$(log_must zfs program $TESTPOOL \ $ZCP_ROOT/lua_core/tst.return_large.zcp | wc -l) -[[ $output_lines -lt 5000 ]] && - log_fail "Expected return of full list but only got $output_lines lines" +log_must [ $output_lines -ge 5000 ] # # Make sure we fail if the return is over the memory limit diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.return_nvlist_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.return_nvlist_neg.ksh index 10afa6727847..a8d4dd31d84b 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.return_nvlist_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.return_nvlist_neg.ksh @@ -45,17 +45,13 @@ set -A args 'function() return 1 end' \ typeset -i last_index=$((${#args[*]} - 1)) for i in $(seq 0 $last_index); do log_note "running program: ${args[i]}" - log_mustnot_checkerror_program "execution failed" $TESTPOOL - <<-EOF - return ${args[i]} - EOF + log_mustnot_checkerror_program "execution failed" $TESTPOOL - <<<"return ${args[i]}" ((i = i + 1)) done for i in $(seq 0 $last_index); do log_note "running program: ${args[i]}" - log_mustnot_checkerror_program "execution failed" $TESTPOOL - <<-EOF - error(${args[i]}) - EOF + log_mustnot_checkerror_program "execution failed" $TESTPOOL - <<<"error(${args[i]})" ((i = i + 1)) done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.return_nvlist_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.return_nvlist_pos.ksh index 8b4ef6e760b0..75ade2b45d12 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.return_nvlist_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.return_nvlist_pos.ksh @@ -39,18 +39,14 @@ log_assert "Returning valid lua constructs works." typeset -i i=0 while (( i < ${#args[*]} )); do log_note "running program: return ${args[i]}" - log_must_program $TESTPOOL - <<-EOF - return ${args[i]} - EOF + log_must_program $TESTPOOL - <<<"return ${args[i]}" ((i = i + 1)) done typeset -i i=0 while (( i < ${#args[*]} )); do log_note "running program: error(${args[i]})" - log_mustnot_checkerror_program "in function 'error'" $TESTPOOL - <<-EOF - error(${args[i]}) - EOF + log_mustnot_checkerror_program "in function 'error'" $TESTPOOL - <<<"error(${args[i]})" ((i = i + 1)) done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.timeout.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.timeout.ksh index 22ea37548173..905a3c327cce 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.timeout.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.timeout.ksh @@ -34,15 +34,11 @@ function test_instr_limit { typeset lim=$1 - error=$(zfs program -t $lim $TESTPOOL $ZCP_ROOT/lua_core/tst.timeout.zcp 2>&1) - [[ $? -ne 0 ]] || log_fail "Channel program with limit $lim exited 0: $error" + log_mustnot eval 'error=$(zfs program -t '$lim' $TESTPOOL $ZCP_ROOT/lua_core/tst.timeout.zcp 2>&1)' - instrs_run=$(echo $error | awk -F "chunk" '{print $2}' | awk '{print $1}') - if [[ $instrs_run -lt $(( $lim - 100 )) ]]; then - log_fail "Runtime (${instrs_run} instr) < limit (${lim} - 100 instr)" - elif [[ $instrs_run -gt $(( $lim + 100 )) ]]; then - log_fail "Runtime (${instrs_run} instr) > limit (${lim} + 100 instr)" - fi + read -r instrs_run _ < <(echo $error | awk -F "chunk" '{print $2}') + log_must [ $instrs_run -ge $(( $lim - 100 )) ] + log_must [ $instrs_run -le $(( $lim + 100 )) ] log_note "With limit $lim the program ended after $instrs_run instructions" } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/synctask_core/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/synctask_core/Makefile.am deleted file mode 100644 index 4d9aa9cebbfc..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/synctask_core/Makefile.am +++ /dev/null @@ -1,53 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/channel_program/synctask_core -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - tst.destroy_fs.ksh \ - tst.destroy_snap.ksh \ - tst.get_count_and_limit.ksh \ - tst.get_index_props.ksh \ - tst.get_mountpoint.ksh \ - tst.get_neg.ksh \ - tst.get_number_props.ksh \ - tst.get_string_props.ksh \ - tst.get_type.ksh \ - tst.get_userquota.ksh \ - tst.get_written.ksh \ - tst.inherit.ksh \ - tst.list_bookmarks.ksh \ - tst.list_children.ksh \ - tst.list_clones.ksh \ - tst.list_holds.ksh \ - tst.list_snapshots.ksh \ - tst.list_system_props.ksh \ - tst.list_user_props.ksh \ - tst.parse_args_neg.ksh \ - tst.promote_conflict.ksh \ - tst.promote_multiple.ksh \ - tst.promote_simple.ksh \ - tst.rollback_mult.ksh \ - tst.rollback_one.ksh \ - tst.set_props.ksh \ - tst.snapshot_destroy.ksh \ - tst.snapshot_neg.ksh \ - tst.snapshot_recursive.ksh \ - tst.bookmark.create.ksh \ - tst.bookmark.copy.ksh \ - tst.snapshot_simple.ksh \ - tst.terminate_by_signal.ksh - -dist_pkgdata_DATA = \ - tst.get_index_props.out \ - tst.get_index_props.zcp \ - tst.get_number_props.out \ - tst.get_number_props.zcp \ - tst.get_string_props.out \ - tst.get_string_props.zcp \ - tst.promote_conflict.zcp \ - tst.set_props.zcp \ - tst.snapshot_destroy.zcp \ - tst.snapshot_neg.zcp \ - tst.snapshot_recursive.zcp \ - tst.snapshot_simple.zcp \ - tst.bookmark.create.zcp \ - tst.bookmark.copy.zcp diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.terminate_by_signal.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.terminate_by_signal.ksh index 2c9014a08483..53d5b819daf6 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.terminate_by_signal.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.terminate_by_signal.ksh @@ -86,13 +86,10 @@ log_pos kill $CHILD # Make sure the channel program did not fully complete by enforcing # that not all of the snapshots were created. # -snap_count=$(zfs list -t snapshot | grep $TESTPOOL | wc -l) +snap_count=$(zfs list -t snapshot | grep -c $TESTPOOL) log_note "$snap_count snapshots created by ZCP" -if [ "$snap_count" -eq 0 ]; then - log_fail "Channel program failed to run." -elif [ "$snap_count" -gt 90 ]; then - log_fail "Too many snapshots after a cancel ($snap_count)." -else - log_pass "Canceling a long-running channel program works." -fi +log_mustnot [ "$snap_count" -eq 0 ] +log_mustnot [ "$snap_count" -gt 90 ] + +log_pass "Cancelling a long-running channel program works." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/chattr/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/chattr/Makefile.am deleted file mode 100644 index 431208e587ec..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/chattr/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/chattr -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - chattr_001_pos.ksh \ - chattr_002_neg.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/chattr/setup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/chattr/setup.ksh index d4b3cdcaba92..85c9b6ea6351 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/chattr/setup.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/chattr/setup.ksh @@ -47,10 +47,8 @@ log_must add_user $QGROUP $QUSER2 # # chmod 0750 $HOME # -user_run $QUSER1 zfs list -if [ $? -ne 0 ]; then +user_run $QUSER1 zfs list || log_unsupported "Test user $QUSER1 cannot execute zfs utilities" -fi DISK=${DISKS%% *} default_setup $DISK diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/.gitignore deleted file mode 100644 index 0411d5aa47dc..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -skein_test -edonr_test -sha2_test - diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/Makefile.am deleted file mode 100644 index 717098aa0723..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -LDADD = \ - $(abs_top_builddir)/lib/libicp/libicp.la \ - $(abs_top_builddir)/lib/libspl/libspl_assert.la - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/checksum - -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - run_edonr_test.ksh \ - run_sha2_test.ksh \ - run_skein_test.ksh \ - filetest_001_pos.ksh \ - filetest_002_pos.ksh - -dist_pkgdata_DATA = \ - default.cfg - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/checksum - -pkgexec_PROGRAMS = \ - edonr_test \ - skein_test \ - sha2_test - -skein_test_SOURCES = skein_test.c -sha2_test_SOURCES = sha2_test.c - -edonr_test_SOURCES = edonr_test.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh index 615b41f312b6..c9cefcd43dae 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh @@ -85,7 +85,7 @@ log_must zpool import $TESTPOOL log_must zpool scrub $TESTPOOL log_must wait_scrubbed $TESTPOOL -cksum=$(zpool status -P -v $TESTPOOL | grep "$firstvdev" | awk '{print $5}') +cksum=$(zpool status -P -v $TESTPOOL | awk -v v="$firstvdev" '$0 ~ v {print $5}') log_assert "Normal file write test saw $cksum checksum errors" log_must [ $cksum -eq 0 ] @@ -105,8 +105,7 @@ while [[ $j -lt ${#CHECKSUM_TYPES[*]} ]]; do log_must zpool scrub $TESTPOOL log_must wait_scrubbed $TESTPOOL - cksum=$(zpool status -P -v $TESTPOOL | grep "$firstvdev" | \ - awk '{print $5}') + cksum=$(zpool status -P -v $TESTPOOL | awk -v v="$firstvdev" '$0 ~ v {print $5}') log_assert "Checksum '$type' caught $cksum checksum errors" log_must [ $cksum -ne 0 ] diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/run_edonr_test.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/run_edonr_test.ksh index 42e88a8c8e3f..de5b21918edb 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/run_edonr_test.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/run_edonr_test.ksh @@ -25,6 +25,6 @@ log_assert "Run the tests for the EdonR hash algorithm." freq=$(get_cpu_freq) -log_must $STF_SUITE/tests/functional/checksum/edonr_test $freq +log_must edonr_test $freq log_pass "EdonR tests passed." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/run_sha2_test.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/run_sha2_test.ksh index e238d7a53e6d..23954a5d35fe 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/run_sha2_test.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/run_sha2_test.ksh @@ -25,6 +25,6 @@ log_assert "Run the tests for the SHA-2 hash algorithm." freq=$(get_cpu_freq) -log_must $STF_SUITE/tests/functional/checksum/sha2_test $freq +log_must sha2_test $freq log_pass "SHA-2 tests passed." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/run_skein_test.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/run_skein_test.ksh index b3a33c3ca8bc..d59bde206d77 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/run_skein_test.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/checksum/run_skein_test.ksh @@ -25,6 +25,6 @@ log_assert "Run the tests for the Skein hash algorithm." freq=$(get_cpu_freq) -log_must $STF_SUITE/tests/functional/checksum/skein_test $freq +log_must skein_test $freq log_pass "Skein tests passed." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/clean_mirror/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/clean_mirror/Makefile.am deleted file mode 100644 index 2bc67709fffb..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/clean_mirror/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/clean_mirror -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - clean_mirror_001_pos.ksh \ - clean_mirror_002_pos.ksh \ - clean_mirror_003_pos.ksh \ - clean_mirror_004_pos.ksh - -dist_pkgdata_DATA = \ - clean_mirror_common.kshlib \ - default.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/Makefile.am deleted file mode 100644 index 9951f96f31ef..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/Makefile.am +++ /dev/null @@ -1,67 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root -dist_pkgdata_DATA = \ - cli_common.kshlib - -SUBDIRS = \ - zdb \ - zfs \ - zfs_bookmark \ - zfs_change-key \ - zfs_clone \ - zfs_copies \ - zfs_create \ - zfs_destroy \ - zfs_diff \ - zfs_get \ - zfs_ids_to_path \ - zfs_inherit \ - zfs_jail \ - zfs_load-key \ - zfs_mount \ - zfs_program \ - zfs_promote \ - zfs_property \ - zfs_receive \ - zfs_rename \ - zfs_reservation \ - zfs_rollback \ - zfs_send \ - zfs_set \ - zfs_share \ - zfs_snapshot \ - zfs_sysfs \ - zfs_unload-key \ - zfs_unmount \ - zfs_unshare \ - zfs_upgrade \ - zfs_wait \ - zhack \ - zpool \ - zpool_add \ - zpool_attach \ - zpool_clear \ - zpool_create \ - zpool_destroy \ - zpool_detach \ - zpool_events \ - zpool_expand \ - zpool_export \ - zpool_get \ - zpool_history \ - zpool_import \ - zpool_initialize \ - zpool_labelclear \ - zpool_offline \ - zpool_online \ - zpool_remove \ - zpool_reopen \ - zpool_replace \ - zpool_resilver \ - zpool_scrub \ - zpool_set \ - zpool_split \ - zpool_status \ - zpool_sync \ - zpool_trim \ - zpool_upgrade \ - zpool_wait diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/cli_common.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/cli_common.kshlib index 4788de598663..1e4917affff7 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/cli_common.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/cli_common.kshlib @@ -31,21 +31,13 @@ . $STF_SUITE/include/libtest.shlib # -# Get the checksum and size of the file. -# -function get_cksum # -{ - return $(cksum $1 | awk '{print $1 $2}') -} - -# -# Compare the check sum of target files with the original file +# Compare the checksum of target files with the original file # function compare_cksum # ... { typeset orig_data=$1 - typeset orig_sum=$(get_cksum $orig_data) + typeset orig_sum=$(cksum < $orig_data) typeset target_sum="" typeset bad_data_list="" typeset -i bad_count=0 @@ -58,7 +50,7 @@ function compare_cksum # ... continue fi - target_sum=$(get_cksum $data) + target_sum=$(cksum < $data) if [[ $target_sum != $orig_sum ]]; then bad_data_list="$bad_data_list $data" (( bad_count +=1 )) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/Makefile.am deleted file mode 100644 index c1d4bf5a47ba..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zdb -dist_pkgdata_SCRIPTS = \ - zdb_002_pos.ksh \ - zdb_003_pos.ksh \ - zdb_004_pos.ksh \ - zdb_005_pos.ksh \ - zdb_006_pos.ksh \ - zdb_args_neg.ksh \ - zdb_args_pos.ksh \ - zdb_block_size_histogram.ksh \ - zdb_checksum.ksh \ - zdb_decompress.ksh \ - zdb_decompress_zstd.ksh \ - zdb_object_range_neg.ksh \ - zdb_object_range_pos.ksh \ - zdb_display_block.ksh \ - zdb_label_checksum.ksh \ - zdb_objset_id.ksh \ - zdb_recover.ksh \ - zdb_recover_2.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_003_pos.ksh index 36f1929dd193..0e4dcf8e6f1e 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_003_pos.ksh @@ -60,8 +60,8 @@ log_note "$DEVS" log_must dd if=/dev/${DISK[0]} of=/dev/${DISK[1]} bs=1K count=256 conv=notrunc for x in 0 1 ; do - config_count=$(zdb -l $DEV_RDSKDIR/${DISK[$x]} | grep -c features_for_read) - (( $? != 0)) && log_fail "failed to get config_count from DISK[$x]" + config_count=$(zdb -l $DEV_RDSKDIR/${DISK[$x]} | grep -c features_for_read) || + log_fail "failed to get config_count from DISK[$x]" log_note "vdev $x: message_count $config_count" [ $config_count -ne ${config_count[$x]} ] && \ log_fail "zdb produces an incorrect number of configuration dumps." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh index 2c6e6e9be070..52bcc0311375 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh @@ -70,12 +70,14 @@ log_must dd if=$DEV_RDSKDIR/${DISK[0]} of=$DEV_RDSKDIR/${DISK[1]} bs=1K count=25 ubs=$(zdb -lu ${DISK[1]} | grep -e LABEL -e Uberblock -e 'labels = ') log_note "vdev 1: ubs $ubs" +set -o pipefail ub_dump_counts=$(zdb -lu ${DISK[1]} | \ awk ' /LABEL/ {label=$NF; blocks[label]=0}; /Uberblock/ {blocks[label]++}; - END {print blocks[0],blocks[1],blocks[2],blocks[3]}') -(( $? != 0)) && log_fail "failed to get ub_dump_counts from DISK[1]" + END {print blocks[0],blocks[1],blocks[2],blocks[3]}') || + log_fail "failed to get ub_dump_counts from DISK[1]" log_note "vdev 1: ub_dump_counts $ub_dump_counts" +set +o pipefail set -A dump_count $ub_dump_counts for label in 0 1 2 3; do diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_pos.ksh index 4c2fc15ec025..75654c29b1ef 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_pos.ksh @@ -59,7 +59,7 @@ function test_imported_pool { typeset -a args=("-A" "-b" "-C" "-c" "-d" "-D" "-G" "-h" "-i" "-L" \ "-M" "-P" "-s" "-v" "-Y" "-y") - for i in ${args[@]}; do + for i in ${args[@]}; do log_must eval "zdb $i $TESTPOOL >/dev/null" done } @@ -69,7 +69,7 @@ function test_exported_pool log_must zpool export $TESTPOOL typeset -a args=("-A" "-b" "-C" "-c" "-d" "-D" "-F" "-G" "-h" "-i" "-L" "-M" \ "-P" "-s" "-v" "-X" "-Y" "-y") - for i in ${args[@]}; do + for i in ${args[@]}; do log_must eval "zdb -e $i $TESTPOOL >/dev/null" done log_must zpool import $TESTPOOL @@ -81,7 +81,7 @@ function test_vdev VDEVS=$(get_pool_devices ${TESTPOOL} ${DEV_RDSKDIR}) log_note $VDEVS set -A VDEV_ARRAY $VDEVS - for i in ${args[@]}; do + for i in ${args[@]}; do log_must eval "zdb -l $i ${VDEV_ARRAY[0]} >/dev/null" done } @@ -89,7 +89,7 @@ function test_vdev function test_metaslab { typeset -a args=("-A" "-L" "-P" "-Y") - for i in ${args[@]}; do + for i in ${args[@]}; do log_must eval "zdb -m $i $TESTPOOL >/dev/null" done } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_block_size_histogram.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_block_size_histogram.ksh index 6ad93d87ca9a..0a4d24fa695a 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_block_size_histogram.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_block_size_histogram.ksh @@ -115,8 +115,7 @@ function histo_populate_test_pool of=/${pool}/B_${this_rs}/file_${filenum} \ bs=${this_rs} count=${thiscount} \ iflag=fullblock 2>&1 | \ - egrep -v -e "records in" -e "records out" \ - -e "bytes.*copied" + grep -ve "records in" -e "records out" -e "bytes.*copied" ((filenum+=1)) done done @@ -146,8 +145,6 @@ function histo_check_test_pool typeset -i this_rs typeset -i this_ri typeset -i sum_filesizes=0 - typeset dumped - typeset stripped let histo_check_pool_size=$(get_pool_prop size ${pool}) if [[ ! ${histo_check_pool_size} =~ ${re_number} ]]; then @@ -158,11 +155,9 @@ function histo_check_test_pool log_fail "hctp: max_pool_record_size is not numeric ${max_pool_record_size}" fi - dumped="${TEST_BASE_DIR}/${pool}_dump.txt" stripped="${TEST_BASE_DIR}/${pool}_stripped.txt" zdb -Pbbb ${pool} | \ - tee ${dumped} | \ sed -e '1,/^block[ ][ ]*psize[ ][ ]*lsize.*$/d' \ -e '/^size[ ]*Count/d' -e '/^$/,$d' \ > ${stripped} @@ -247,6 +242,8 @@ function histo_check_test_pool fi fi done < ${stripped} + rm "${stripped}" + if [ ${fail_value} -gt 0 ]; then if [ ${error_count} -eq 1 ]; then log_note "hctp: There was ${error_count} error" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_checksum.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_checksum.ksh index 4f661262a72d..d79933fd5b59 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_checksum.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_checksum.ksh @@ -53,13 +53,13 @@ log_note "file $init_data has object number $obj" sync_pool $TESTPOOL output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ - |grep -m 1 "L0 DVA" |head -n1) + | grep -m 1 "L0 DVA") dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output") log_note "block 0 of $init_data has a DVA of $dva" cksum_expected=$(sed -Ene 's/^.+ cksum=([a-z0-9:]+)$/\1/p' <<< "$output") log_note "expecting cksum $cksum_expected" output=$(zdb -R $TESTPOOL $dva:c 2> /dev/null) -result=$(grep $cksum_expected <<< "$output") -(( $? != 0 )) && log_fail "zdb -R failed to print the correct checksum" +grep -q $cksum_expected <<<"$output" || + log_fail "zdb -R failed to print the correct checksum" log_pass "zdb -R generates the correct checksum" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress.ksh index 1ebcbfb44953..f10d13fb5d70 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress.ksh @@ -73,7 +73,7 @@ obj=${array[0]} log_note "file $init_data has object number $obj" output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ - |grep -m 1 "L0 DVA" |head -n1) + |grep -m 1 "L0 DVA") dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output") log_note "block 0 of $init_data has a DVA of $dva" @@ -81,15 +81,13 @@ log_note "block 0 of $init_data has a DVA of $dva" size_str=$(sed -Ene 's/^.+ size=([^ ]+) .*$/\1/p' <<< "$output") log_note "block size $size_str" -vdev=$(echo "$dva" |awk '{split($0,array,":")} END{print array[1]}') -offset=$(echo "$dva" |awk '{split($0,array,":")} END{print array[2]}') +vdev=$(echo "$dva" | cut -d: -f1) +offset=$(echo "$dva" | cut -d: -f2) output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:d 2> /dev/null) -echo $output |grep $pattern > /dev/null -(( $? != 0 )) && log_fail "zdb -R :d failed to decompress the data properly" +echo $output | grep -q $pattern || log_fail "zdb -R :d failed to decompress the data properly" output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:dr 2> /dev/null) -echo $output |grep $four_k > /dev/null -(( $? != 0 )) && log_fail "zdb -R :dr failed to decompress the data properly" +echo $output | grep -q $four_k || log_fail "zdb -R :dr failed to decompress the data properly" output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:dr 2> /dev/null) result=${#output} @@ -97,8 +95,8 @@ result=${#output} "zdb -R failed to decompress the data to the length (${#output} != $size_str)" # decompress using lsize -lsize=$(echo $size_str |awk '{split($0,array,"/")} END{print array[1]}') -psize=$(echo $size_str |awk '{split($0,array,"/")} END{print array[2]}') +lsize=$(echo $size_str | cut -d/ -f1) +psize=$(echo $size_str | cut -d/ -f2) output=$(zdb -R $TESTPOOL $vdev:$offset:$lsize:dr 2> /dev/null) result=${#output} (( $result != $blksize)) && log_fail \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh index 238d49560461..c7e10bac4570 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh @@ -63,52 +63,44 @@ done sync_pool $TESTPOOL true # get object number of file -listing=$(ls -i $init_data) -set -A array $listing -obj=${array[0]} +read -r obj _ < <(ls -i $init_data) log_note "file $init_data has object number $obj" output=$(zdb -Zddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ - |grep -m 1 "L0 DVA" |head -n1) + | grep -m 1 "L0 DVA") dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output") log_note "block 0 of $init_data has a DVA of $dva" # use the length reported by zdb -ddddddbbbbbb size_str=$(sed -Ene 's/^.+ size=([^ ]+) .*$/\1/p' <<< "$output") # convert sizes to decimal -lsize=$(echo $size_str |awk '{split($0,array,"/")} END{print array[1]}') +IFS='/' read -r lsize psize _ <<<"$size_str" lsize_orig=$lsize -lsize=${lsize%?} -lsize_bytes=$((16#$lsize)) -psize=$(echo $size_str |awk '{split($0,array,"/")} END{print array[2]}') psize_orig=$psize +lsize=${lsize%?} psize=${psize%?} +lsize_bytes=$((16#$lsize)) psize_bytes=$((16#$psize)) log_note "block size $size_str" # Get the ZSTD header reported by zdb -Z -zstd_str=$(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1:\2:\3/p' <<< "$output") -zstd_size=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[1]}') +read -r zstd_size zstd_version zstd_level < <(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1 \2 \3/p' <<<"$output") log_note "ZSTD compressed size $zstd_size" (( $psize_bytes < $zstd_size )) && log_fail \ "zdb -Z failed: physical block size was less than header content length ($psize_bytes < $zstd_size)" -zstd_version=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[2]}') log_note "ZSTD version $zstd_version" -zstd_level=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[3]}') log_note "ZSTD level $zstd_level" (( $zstd_level != $random_level )) && log_fail \ "zdb -Z failed: compression level did not match header level ($zstd_level < $random_level)" -vdev=$(echo "$dva" |awk '{split($0,array,":")} END{print array[1]}') -offset=$(echo "$dva" |awk '{split($0,array,":")} END{print array[2]}') +IFS=':' read -r vdev offset _ <<<"$dva" # Check the first 1024 bytes output=$(ZDB_NO_ZLE="true" zdb -R $TESTPOOL $vdev:$offset:$size_str:dr 2> /dev/null) -outsize=$(wc -c <<< "$output") -(( $outsize != $blksize )) && log_fail \ -"zdb -Z failed to decompress the data to the expected length ($outsize != $lsize_bytes)" -cmp $init_data - <<< "$output" -(( $? != 0 )) && log_fail "zdb -R :dr failed to decompress the data properly" +(( ${#output} + 1 != $blksize )) && log_fail \ +"zdb -Z failed to decompress the data to the expected length (${#output} != $lsize_bytes)" +cmp $init_data - <<< "$output" || + log_fail "zdb -R :dr failed to decompress the data properly" log_pass "zdb -Z flag (ZSTD compression header) works as expected" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh index 5cc4575851f7..bab0dea2969b 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh @@ -69,16 +69,16 @@ obj=${array[0]} log_note "file $init_data has object number $obj" output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ - |grep -m 1 "L1 DVA" |head -n1) + |grep -m 1 "L1 DVA" ) dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*/\1/p' <<< "$output") log_note "first L1 block $init_data has a DVA of $dva" output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ - |grep -m 1 "L0 DVA" |head -n1) + |grep -m 1 "L0 DVA" ) blk_out0=${output##*>} blk_out0=${blk_out0##+([[:space:]])} output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ - |grep -m 1 "1000 L0 DVA" |head -n1) + |grep -m 1 "1000 L0 DVA" ) blk_out1=${output##*>} blk_out1=${blk_out1##+([[:space:]])} @@ -106,11 +106,11 @@ if [ "$output" != "$blk_out1" ]; then log_fail "zdb -R :b80d (block 1 display/decompress) failed" fi -vdev=$(echo "$dva" |awk '{split($0,array,":")} END{print array[1]}') -offset=$(echo "$dva" |awk '{split($0,array,":")} END{print array[2]}') +vdev=$(echo "$dva" | cut -d: -f1) +offset=$(echo "$dva" | cut -d: -f2) output=$(export ZDB_NO_ZLE=\"true\";\ zdb -R $TESTPOOL $vdev:$offset:$l1_read_size:id 2> /dev/null) -block_cnt=$(echo "$output" | grep 'L0' | wc -l) +block_cnt=$(echo "$output" | grep -c 'L0') if [ $block_cnt -ne $write_count ]; then log_fail "zdb -R :id (indirect block display) failed" fi @@ -120,7 +120,7 @@ vdev="$vdev.0" log_note "Reading from DVA $vdev:$offset:$l1_read_size" output=$(export ZDB_NO_ZLE=\"true\";\ zdb -R $TESTPOOL $vdev:$offset:$l1_read_size:id 2> /dev/null) -block_cnt=$(echo "$output" | grep 'L0' | wc -l) +block_cnt=$(echo "$output" | grep -c 'L0') if [ $block_cnt -ne $write_count ]; then log_fail "zdb -R 0.0:offset:length:id (indirect block display) failed" fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh index e2014405853d..e4664b52eb94 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh @@ -65,7 +65,7 @@ done # Specifying a non-existent object identifier returns an error obj_id_highest=$(zdb -P -dd $TESTPOOL/$TESTFS 2>/dev/null | - egrep "^ +-?([0-9]+ +){7}" | sort -n | tail -n 1 | awk '{print $1}') + grep -E "^ +-?([0-9]+ +){7}" | sort -n | awk 'END {print $1}') obj_id_invalid=$(( $obj_id_highest + 1 )) log_mustnot zdb -dd $TESTPOOL/$TESTFS $obj_id_invalid diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_pos.ksh index 1e63ac7d2f4e..2c85e6e932a6 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_pos.ksh @@ -42,8 +42,8 @@ function get_object_list_range begin=$2 end=$3 get_object_list $dataset | - while read line; do - obj=$(echo $line | awk '{print $1}') + while read -r line; do + read -r obj _ <<<"$line" if [[ $obj -ge $begin && $obj -le $end ]] ; then echo "$line" elif [[ $obj -gt $end ]] ; then @@ -60,8 +60,7 @@ function get_object_list_range function get_object_list { zdb -P -dd $@ 2>/dev/null | - egrep "^ +-?([0-9]+ +){7}" | - sed 's/^[[:space:]]*//' | + sed -E '/^ +-?([0-9]+ +){7}/!d;s/^[[:space:]]*//' | sort -n } @@ -142,7 +141,7 @@ log_must test "\n$actual\n" == "\n$expected\n" # Specifying individual object IDs works objects="$start1 $end1 $start2 $end2" expected="$objects" -actual=$(get_object_list $TESTPOOL/$TESTFS $objects | awk '{print $1}' | tr '\n' ' ') +actual=$(get_object_list $TESTPOOL/$TESTFS $objects | awk '{printf("%s ", $1)}' | tr '\n' ' ') log_must test "${actual% }" == "$expected" # Get all objects in the meta-objset to test m (spacemap) and z (zap) flags diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh index accb125280f0..fdda9ba22638 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh @@ -67,9 +67,7 @@ obj=${array[0]} log_note "file $init_data has object number $obj" sync_pool $TESTPOOL -output=$(zdb -d $TESTPOOL/$TESTFS) -objset_id=$(echo $output | awk '{split($0,array,",")} END{print array[2]}' | - awk '{split($0,array," ")} END{print array[2]}') +IFS=", " read -r _ _ _ _ objset_id _ < <(zdb -d $TESTPOOL/$TESTFS) objset_hex=$(printf "0x%X" $objset_id) log_note "objset $TESTPOOL/$TESTFS has objset ID $objset_id ($objset_hex)" @@ -77,54 +75,32 @@ for id in "$objset_id" "$objset_hex" do log_note "zdb -dddddd $TESTPOOL/$id $obj" output=$(zdb -dddddd $TESTPOOL/$id $obj) - reason="($TESTPOOL/$TESTFS not in zdb output)" - echo $output |grep "$TESTPOOL/$TESTFS" > /dev/null - (( $? != 0 )) && log_fail \ - "zdb -dddddd $TESTPOOL/$id $obj failed $reason" - reason="(file1 not in zdb output)" - echo $output |grep "file1" > /dev/null - (( $? != 0 )) && log_fail \ - "zdb -dddddd $TESTPOOL/$id $obj failed $reason" - obj=$(printf "0x%X" $obj) + echo $output | grep -q "$TESTPOOL/$TESTFS" || + log_fail "zdb -dddddd $TESTPOOL/$id $obj failed ($TESTPOOL/$TESTFS not in zdb output)" + echo $output | grep -q "file1" || + log_fail "zdb -dddddd $TESTPOOL/$id $obj failed (file1 not in zdb output)" + obj=$(printf "0x%X" $obj) log_note "zdb -NNNNNN $TESTPOOL/$id $obj" - output=$(zdb -NNNNNN $TESTPOOL/$id $obj) - reason="($TESTPOOL/$TESTFS not in zdb output)" - echo $output |grep "$TESTPOOL/$TESTFS" > /dev/null - (( $? != 0 )) && log_fail \ - "zdb -NNNNNN $TESTPOOL/$id $obj failed $reason" - reason="(file1 not in zdb output)" - echo $output |grep "file1" > /dev/null - (( $? != 0 )) && log_fail \ - "zdb -NNNNNN $TESTPOOL/$id $obj failed $reason" + output=$(zdb -NNNNNN $TESTPOOL/$id $obj) + echo $output | grep -q "$TESTPOOL/$TESTFS" || + log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed ($TESTPOOL/$TESTFS not in zdb output)" + echo $output | grep -q "file1" || + log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed (file1 not in zdb output)" done if is_linux; then - output=$(ls -1 /proc/spl/kstat/zfs/$TESTPOOL |grep objset- |tail -1) + output=$(ls -1 /proc/spl/kstat/zfs/$TESTPOOL | grep objset- | tail -1) objset_hex=${output#*-} - name_from_proc=$(cat /proc/spl/kstat/zfs/$TESTPOOL/$output | - grep dataset_name | awk '{split($0,array," ")} END{print array[3]}') + name_from_proc=$(grep dataset_name /proc/spl/kstat/zfs/$TESTPOOL/$output | cut -d' ' -f3) log_note "checking zdb output for $name_from_proc" - reason="(name $name_from_proc from proc not in zdb output)" - log_note "zdb -dddddd $TESTPOOL/$objset_hex" - output=$(zdb -dddddd $TESTPOOL/$objset_hex) - echo $output |grep "$name_from_proc" > /dev/null - (( $? != 0 )) && log_fail \ - "zdb -dddddd $TESTPOOL/$objset_hex failed $reason" + log_must eval "zdb -dddddd $TESTPOOL/$objset_hex | grep -q \"$name_from_proc\"" fi log_must zfs create $hex_ds log_must zfs create $num_ds -output=$(zdb -d $hex_ds) -reason="($TESTPOOL/0x400 not in zdb output)" -echo $output |grep "$hex_ds" > /dev/null -(( $? != 0 )) && log_fail \ - "zdb -d $hex_ds failed $reason" -output=$(zdb -d $num_ds) -reason="($num_ds not in zdb output)" -echo $output |grep "$num_ds" > /dev/null -(( $? != 0 )) && log_fail \ - "zdb -d $num_ds failed $reason" +log_must eval "zdb -d $hex_ds | grep -q \"$hex_ds\"" +log_must eval "zdb -d $num_ds | grep -q \"$num_ds\"" # force numeric interpretation, expect fail log_mustnot zdb -N $hex_ds diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_recover_2.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_recover_2.ksh index 6470327a1765..d4529ff01105 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_recover_2.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_recover_2.ksh @@ -48,7 +48,7 @@ verify_disk_count "$DISKS" 2 default_mirror_setup_noexit $DISKS file_write -o create -w -f $init_data -b $blksize -c $write_count -log_must echo "zfs" >> $init_data +echo "zfs" >> $init_data sync_pool $TESTPOOL output=$(zdb -r $TESTPOOL/$TESTFS file1 $tmpfile) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/Makefile.am deleted file mode 100644 index 8b0ee276a3b0..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_001_neg.ksh \ - zfs_002_pos.ksh \ - zfs_003_neg.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_002_pos.ksh index 796b38928ec7..044ccb185c48 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_002_pos.ksh @@ -48,33 +48,23 @@ function cleanup { unset ZFS_ABORT - if is_freebsd && [[ -n $savedcorefile ]]; then - sysctl kern.corefile=$savedcorefile - fi + log_must pop_coredump_pattern "$coresavepath" - if [[ -d $corepath ]]; then - rm -rf $corepath - fi for ds in $fs1 $fs $ctr; do datasetexists $ds && destroy_dataset $ds -rRf done } -log_assert "With ZFS_ABORT set, all zfs commands can abort and generate a " \ - "core file." +log_assert "With ZFS_ABORT set, all zfs commands can abort and generate a core file." log_onexit cleanup -# Preparation work for testing -savedcorefile="" -corepath=$TESTDIR/core -corefile=$corepath/core.zfs -if [[ -d $corepath ]]; then - rm -rf $corepath -fi -log_must mkdir $corepath - ctr=$TESTPOOL/$TESTCTR -log_must zfs create $ctr +log_must zfs create -p $ctr + +# Preparation work for testing +corepath=/$ctr +corefile=$corepath/core.zfs +coresavepath=$corepath/save fs=$ctr/$TESTFS fs1=$ctr/$TESTFS1 @@ -93,24 +83,12 @@ typeset badparams=("" "create" "destroy" "snapshot" "rollback" "clone" \ "promote" "rename" "list -*" "set" "get -*" "inherit" "mount -A" \ "unmount" "share" "unshare" "send" "receive") -if is_linux; then - ulimit -c unlimited - echo "$corefile" >/proc/sys/kernel/core_pattern - echo 0 >/proc/sys/kernel/core_uses_pid -elif is_freebsd; then - ulimit -c unlimited - savedcorefile=$(sysctl -n kern.corefile) - log_must sysctl kern.corefile=$corepath/core.%N -else - log_must coreadm -p ${corepath}/core.%f -fi - +log_must eval "push_coredump_pattern \"$corepath\" > \"$coresavepath\"" log_must export ZFS_ABORT=yes for subcmd in "${cmds[@]}" "${badparams[@]}"; do - log_mustnot eval "zfs $subcmd >/dev/null 2>&1" - log_must rm $corefile + log_mustnot eval "zfs $subcmd" + log_must rm "$corefile" done -log_pass "With ZFS_ABORT set, zfs command can abort and generate core file " \ - "as expected." +log_pass "With ZFS_ABORT set, zfs command can abort and generate core file as expected." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_003_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_003_neg.ksh index 0438bae8f6ce..6c85e0c13ab4 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_003_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_003_neg.ksh @@ -45,7 +45,15 @@ verify_runnable "global" +function cleanup +{ + for file in $ZFS_DEV $MNTTAB; do + log_must eval "[ -e ${file} ] || mv ${file}.bak $file" + done +} + log_assert "zfs fails with unexpected scenario." +log_onexit cleanup #verify zfs failed if ZFS_DEV cannot be opened ZFS_DEV=/dev/zfs @@ -56,13 +64,11 @@ if is_linux; then fi for file in $ZFS_DEV $MNTTAB; do - if [[ -e $file ]]; then - mv $file ${file}.bak - fi + log_must mv $file ${file}.bak for cmd in "" "list" "get all" "mount"; do log_mustnot eval "zfs $cmd >/dev/null 2>&1" done - mv ${file}.bak $file + log_must mv ${file}.bak $file done log_pass "zfs fails with unexpected scenario as expected." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_bookmark/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_bookmark/Makefile.am deleted file mode 100644 index e71fbc85ca84..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_bookmark/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_bookmark -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_bookmark_cliargs.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh index 3a1cddb5c64a..ec21c81aba1b 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh @@ -62,6 +62,8 @@ function cleanup bkmarkexists "$DATASET#$TESTBMCOPY" && \ destroy_dataset "$DATASET#$TESTBMCOPY" + + log_must rm -f "$TEST_BASE_DIR/zfstest_datastream.$$" } log_assert "'zfs bookmark' should work only when passed valid arguments." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/Makefile.am deleted file mode 100644 index 72d6e4700e17..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_change-key/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_change-key -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_change-key.ksh \ - zfs_change-key_child.ksh \ - zfs_change-key_clones.ksh \ - zfs_change-key_inherit.ksh \ - zfs_change-key_format.ksh \ - zfs_change-key_load.ksh \ - zfs_change-key_location.ksh \ - zfs_change-key_pbkdf2iters.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_clone/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_clone/Makefile.am deleted file mode 100644 index 06099c0c2b79..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_clone/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_clone -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_clone_001_neg.ksh \ - zfs_clone_002_pos.ksh \ - zfs_clone_003_pos.ksh \ - zfs_clone_004_pos.ksh \ - zfs_clone_005_pos.ksh \ - zfs_clone_006_pos.ksh \ - zfs_clone_007_pos.ksh \ - zfs_clone_008_neg.ksh \ - zfs_clone_009_neg.ksh \ - zfs_clone_010_pos.ksh \ - zfs_clone_encrypted.ksh \ - zfs_clone_deeply_nested.ksh \ - zfs_clone_rm_nested.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_003_pos.ksh index 6484de9c91a8..ac3bc891c86f 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_003_pos.ksh @@ -49,6 +49,7 @@ verify_runnable "both" function cleanup { snapexists $SNAPFS && destroy_dataset $SNAPFS -Rf + log_must rm -df "/tmp/mnt$$" } log_onexit cleanup diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh index 4bfb3d5f78ab..5f42006de289 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh @@ -40,8 +40,7 @@ # 2. Verify it succeed while upgrade, but fails while the version downgraded. # -ZFS_VERSION=$(zfs upgrade | head -1 | awk '{print $NF}' \ - | sed -e 's/\.//g') +ZFS_VERSION=$(zfs upgrade | grep -wom1 '[[:digit:]]*') verify_runnable "both" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh index 13f5418d4bf5..643bf1cf28e7 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh @@ -221,7 +221,7 @@ for (( i = 1; i <= (ZFS_MAXPROPLEN / 200 + 1); i++ )); do log_must zfs clone ${fs}@snap ${fs}/${TESTCLONE}${xs}.${i} done clone_list=$(zfs list -o clones $fs@snap) -char_count=$(echo "$clone_list" | tail -1 | wc | awk '{print $3}') +char_count=$(echo "$clone_list" | tail -1 | wc -c) [[ $char_count -eq $ZFS_MAXPROPLEN ]] || \ log_fail "Clone list not truncated correctly. Unexpected character count" \ "$char_count" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_copies/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_copies/Makefile.am deleted file mode 100644 index 4ac103a8ec6a..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_copies/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_copies -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_copies_001_pos.ksh \ - zfs_copies_002_pos.ksh \ - zfs_copies_003_pos.ksh \ - zfs_copies_004_neg.ksh \ - zfs_copies_005_neg.ksh \ - zfs_copies_006_pos.ksh - -dist_pkgdata_DATA = \ - zfs_copies.cfg \ - zfs_copies.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh index 61d7aa28d27c..aa895956c936 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh @@ -94,11 +94,9 @@ done log_note "Verify df(1) can correctly display the space charged." for val in 1 2 3; do if is_freebsd; then - used=`df -m /$TESTPOOL/fs_$val | grep $TESTPOOL/fs_$val \ - | awk -v fs=fs_$val '$4 ~ fs {print $3}'` + used=`df -m /$TESTPOOL/fs_$val | awk -v pa=$TESTPOOL/fs_$val -v fs=fs_$val '$0 ~ pa && $4 ~ fs {print $3}'` else - used=`df -F zfs -k /$TESTPOOL/fs_$val/$FILE | grep $TESTPOOL/fs_$val \ - | awk '{print $3}'` + used=`df -F zfs -k /$TESTPOOL/fs_$val/$FILE | awk -v pa=$TESTPOOL/fs_$val '$0 ~ pa {print $3}'` (( used = used * 1024 )) # kb -> bytes fi check_used $used $val diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/Makefile.am deleted file mode 100644 index 7515753c1bc2..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_create -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_create_001_pos.ksh \ - zfs_create_002_pos.ksh \ - zfs_create_003_pos.ksh \ - zfs_create_004_pos.ksh \ - zfs_create_005_pos.ksh \ - zfs_create_006_pos.ksh \ - zfs_create_007_pos.ksh \ - zfs_create_008_neg.ksh \ - zfs_create_009_neg.ksh \ - zfs_create_010_neg.ksh \ - zfs_create_011_pos.ksh \ - zfs_create_012_pos.ksh \ - zfs_create_013_pos.ksh \ - zfs_create_014_pos.ksh \ - zfs_create_encrypted.ksh \ - zfs_create_crypt_combos.ksh \ - zfs_create_dryrun.ksh \ - zfs_create_nomount.ksh \ - zfs_create_verbose.ksh - -dist_pkgdata_DATA = \ - properties.kshlib \ - zfs_create_common.kshlib \ - zfs_create.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh index 0218e2e16b68..84f758904bd9 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh @@ -65,8 +65,7 @@ while (( $j < ${#size[*]} )); do typeset cmdline="zfs create -s -V ${size[j]} \ $TESTPOOL/${TESTVOL}${size[j]}" - str=$(eval $cmdline 2>&1) - if (( $? == 0 )); then + if str=$(eval $cmdline 2>&1); then log_note "SUCCESS: $cmdline" log_must datasetexists $TESTPOOL/${TESTVOL}${size[j]} elif [[ $str == *${VOL_LIMIT_KEYWORD1}* || \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_004_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_004_pos.ksh index 9e69366c8793..bd01623b3627 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_004_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_004_pos.ksh @@ -49,24 +49,23 @@ verify_runnable "both" function cleanup { datasetexists $TESTPOOL/$TESTFS1 && destroy_dataset $TESTPOOL/$TESTFS1 -f + log_must rm -df "/tmp/mnt$$" } log_onexit cleanup -log_assert "'zfs create -o property=value filesystem' can successfully create \ - a ZFS filesystem with correct property set." +log_assert "'zfs create -o property=value filesystem' can successfully create" \ + "a ZFS filesystem with correct property set." typeset -i i=0 while (( $i < ${#RW_FS_PROP[*]} )); do log_must zfs create -o ${RW_FS_PROP[$i]} $TESTPOOL/$TESTFS1 - datasetexists $TESTPOOL/$TESTFS1 || \ - 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 datasetexists $TESTPOOL/$TESTFS1 + log_must propertycheck $TESTPOOL/$TESTFS1 ${RW_FS_PROP[i]} log_must_busy zfs destroy -f $TESTPOOL/$TESTFS1 (( i = i + 1 )) done -log_pass "'zfs create -o property=value filesystem' can successfully create \ - a ZFS filesystem with correct property set." +log_pass "'zfs create -o property=value filesystem' can successfully create" \ + "a ZFS filesystem with correct property set." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_005_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_005_pos.ksh index 98cf70938e87..1321854d21cd 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_005_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_005_pos.ksh @@ -48,15 +48,16 @@ verify_runnable "both" function cleanup { - datasetexists $TESTPOOL/$TESTFS1 && \ + datasetexists $TESTPOOL/$TESTFS1 && destroy_dataset $TESTPOOL/$TESTFS1 -f + log_must rm -df "/tmp/mnt$$" } log_onexit cleanup -log_assert "'zfs create -o property=value filesystem' can successfully create \ - a ZFS filesystem with multiple properties set." +log_assert "'zfs create -o property=value filesystem' can successfully create" \ + "a ZFS filesystem with multiple properties set." typeset -i i=0 typeset opts="" @@ -69,17 +70,15 @@ while (( $i < ${#RW_FS_PROP[*]} )); do done log_must zfs create $opts $TESTPOOL/$TESTFS1 -datasetexists $TESTPOOL/$TESTFS1 || \ - log_fail "zfs create $TESTPOOL/$TESTFS1 fail." +log_must datasetexists $TESTPOOL/$TESTFS1 i=0 while (( $i < ${#RW_FS_PROP[*]} )); do if [[ ${RW_FS_PROP[$i]} != *"checksum"* ]]; then - propertycheck $TESTPOOL/$TESTFS1 ${RW_FS_PROP[i]} || \ - log_fail "${RW_FS_PROP[i]} is failed to set." + log_must propertycheck $TESTPOOL/$TESTFS1 ${RW_FS_PROP[i]} fi (( i = i + 1 )) done -log_pass "'zfs create -o property=value filesystem' can successfully create \ - a ZFS filesystem with multiple properties set." +log_pass "'zfs create -o property=value filesystem' can successfully create" \ + "a ZFS filesystem with multiple properties set." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_008_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_008_neg.ksh index a905e50dfaa2..d82f10f71f71 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_008_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_008_neg.ksh @@ -56,7 +56,7 @@ set -A args "ab" "-?" "-cV" "-Vc" "-c -V" "c" "V" "--c" "-e" "-s" \ "-blah" "-cV 12k" "-s -cV 1P" "-sc" "-Vs 5g" "-o" "--o" "-O" "--O" \ "-o QuOta=none" "-o quota=non" "-o quota=abcd" "-o quota=0" "-o quota=" \ "-o ResErVaTi0n=none" "-o reserV=none" "-o reservation=abcd" "-o reserv=" \ - "-o recorDSize=64k" "-o recordsize=2048K" "-o recordsize=2M" \ + "-o recorDSize=64k" "-o recordsize=32768K" "-o recordsize=32M" \ "-o recordsize=256" "-o recsize=" "-o recsize=zero" "-o recordsize=0" \ "-o mountPoint=/tmp/tmpfile$$" "-o mountpoint=non0" "-o mountpoint=" \ "-o mountpoint=LEGACY" "-o mounpoint=none" \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_009_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_009_neg.ksh index 63f5e595ea38..6722a659eb65 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_009_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_009_neg.ksh @@ -62,8 +62,7 @@ function cleanup # check to see if there is any new fs created during the test # if so destroy it. # - for dset in $(zfs list -H | \ - awk '{print $1}' | grep / ); do + for dset in $(zfs list -H | awk '$1 ~ /\/ {print $1}'); do found=false i=0 while (( $i < ${#existed_fs[*]} )); do @@ -99,7 +98,7 @@ log_assert "Verify 'zfs create ' fails with bad argumen datasetexists $TESTPOOL/$TESTFS || \ log_must zfs create $TESTPOOL/$TESTFS -set -A existed_fs $(zfs list -H | awk '{print $1}' | grep / ) +set -A existed_fs $(zfs list -H | awk '$1 ~ /\// {print $1}') log_mustnot zfs create $TESTPOOL log_mustnot zfs create $TESTPOOL/$TESTFS diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_010_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_010_neg.ksh index 4b1401d8649b..d4784d6530e5 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_010_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_010_neg.ksh @@ -62,8 +62,7 @@ function cleanup # check to see if there is any new fs created during the test # if so destroy it. # - for dset in $(zfs list -H | \ - awk '{print $1}' | grep / ); do + for dset in $(zfs list -H | awk '$1 ~ /\// {print $1}'); do found=false i=0 while (( $i < ${#existed_fs[*]} )); do @@ -108,7 +107,7 @@ set -A options "" "-s" datasetexists $TESTPOOL/$TESTVOL || \ log_must zfs create -V $VOLSIZE $TESTPOOL/$TESTVOL -set -A existed_fs $(zfs list -H | awk '{print $1}' | grep / ) +set -A existed_fs $(zfs list -H | awk '$1 ~ /\// {print $1}') log_mustnot zfs create -V $VOLSIZE $TESTPOOL/$TESTVOL log_mustnot zfs create -s -V $VOLSIZE $TESTPOOL/$TESTVOL diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos.ksh index a0b8d52f0c43..2a140d954876 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos.ksh @@ -41,8 +41,7 @@ # 2. Verify only the leaf filesystem to be version=1, others use the current version # -ZFS_VERSION=$(zfs upgrade | head -1 | awk '{print $NF}' \ - | sed -e 's/\.//g') +ZFS_VERSION=$(zfs upgrade | grep -wom1 '[[:digit:]]*') verify_runnable "both" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_013_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_013_pos.ksh index 993c6436a7b1..d3855cb315c1 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_013_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_013_pos.ksh @@ -63,8 +63,7 @@ while (( $j < ${#size[*]} )); do typeset cmdline="zfs create -s -V ${size[j]} \ $TESTPOOL/${LONGFSNAME}${size[j]}" - str=$(eval $cmdline 2>&1) - if (( $? == 0 )); then + if str=$(eval $cmdline 2>&1); then log_note "SUCCESS: $cmdline" log_must datasetexists $TESTPOOL/${LONGFSNAME}${size[j]} elif [[ $str == *${VOL_LIMIT_KEYWORD1}* || \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_common.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_common.kshlib index 4c3f8b908c10..bf8e145e5112 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_common.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_common.kshlib @@ -40,15 +40,12 @@ function propertycheck { typeset dtst=$1 typeset propstr=$2 + typeset prop expect_value - typeset prop=$(echo $propstr | awk -F= '{print $1}') - typeset expect_value=$(echo $propstr | awk -F= '{print $2}') - typeset value=$(zfs get -H -p -o value $prop $dtst) + IFS='=' read -r prop expect_value <<<"$propstr" + + typeset value=$(get_prop $prop $dtst) - if [[ "$expect_value" == "$value" ]]; then - return 0 - else - return 1 - fi + [ "$expect_value" = "$value" ] } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_dryrun.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_dryrun.ksh index 703ae8043d48..1e22da0045c7 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_dryrun.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_dryrun.ksh @@ -87,12 +87,11 @@ function dry_create_parseable typeset found_create=false log_note "$0: ${cmd[@]}" - out=$("${cmd[@]}") - (( $? == 0 )) || + out=$("${cmd[@]}") || log_fail "unexpected failure getting stdout from '${cmd[@]}'" datasetexists "$TESTPOOL/$TESTFS1" && log_fail "$TESTPOOL/$TESTFS1 unexpectedly created by '${cmd[@]}'" - echo "$out" | while IFS=$'\t' read -A toks; do + while IFS=$'\t' read -A toks; do log_note "verifying ${toks[@]}" case ${toks[0]} in create) @@ -118,7 +117,7 @@ function dry_create_parseable log_fail "Unexpected line ${toks[@]}" ;; esac - done + done <<<"$out" log_must test "$found_create" == "yes, I found create" log_must test "extra props: ${!exp[@]}" == "extra props: " diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_nomount.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_nomount.ksh index e1fbbe63ad31..5b0478e855cf 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_nomount.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_nomount.ksh @@ -30,7 +30,7 @@ verify_runnable "both" function cleanup { - local ds + typeset ds for ds in "$fs" "$vol"; do datasetexists "$ds" && destroy_dataset "$ds" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_verbose.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_verbose.ksh index acab500062ca..b18ffa404c42 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_verbose.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_verbose.ksh @@ -58,12 +58,11 @@ function dry_create_parseable done log_note "$0: ${cmd[@]}" - out=$("${cmd[@]}") - (( $? == 0 )) || + out=$("${cmd[@]}") || log_fail "unexpected failure getting stdout from '${cmd[@]}'" datasetexists "$TESTPOOL/$TESTFS1" || log_fail "$TESTPOOL/$TESTFS1 unexpectedly created by '${cmd[@]}'" - echo "$out" | while IFS=$'\t' read -A toks; do + while IFS=$'\t' read -A toks; do log_note "verifying ${toks[@]}" case ${toks[0]} in create_ancestors) @@ -107,7 +106,7 @@ function dry_create_parseable log_fail "Unexpected line ${toks[@]}" ;; esac - done + done <<<"$out" log_must test "$found_create" == "yes, I found create" log_must test "extra props: ${!exp[@]}" == "extra props: " diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/Makefile.am deleted file mode 100644 index 664f3d81aea6..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_destroy -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_clone_livelist_condense_and_disable.ksh \ - zfs_clone_livelist_condense_races.ksh \ - zfs_clone_livelist_dedup.ksh \ - zfs_destroy_001_pos.ksh \ - zfs_destroy_002_pos.ksh \ - zfs_destroy_003_pos.ksh \ - zfs_destroy_004_pos.ksh \ - zfs_destroy_005_neg.ksh \ - zfs_destroy_006_neg.ksh \ - zfs_destroy_007_neg.ksh \ - zfs_destroy_008_pos.ksh \ - zfs_destroy_009_pos.ksh \ - zfs_destroy_010_pos.ksh \ - zfs_destroy_011_pos.ksh \ - zfs_destroy_012_pos.ksh \ - zfs_destroy_013_neg.ksh \ - zfs_destroy_014_pos.ksh \ - zfs_destroy_015_pos.ksh \ - zfs_destroy_016_pos.ksh \ - zfs_destroy_clone_livelist.ksh \ - zfs_destroy_dev_removal.ksh \ - zfs_destroy_dev_removal_condense.ksh - -dist_pkgdata_DATA = \ - zfs_destroy_common.kshlib \ - zfs_destroy.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh index 9a2ff6bea36d..d618f21e9eb5 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh @@ -98,8 +98,7 @@ log_must zfs set mountpoint=$mntp1 $fs1 log_must zfs set mountpoint=$mntp2 $clone for arg in "$fs1 $mntp1" "$clone $mntp2"; do - fs=`echo $arg | awk '{print $1}'` - mntp=`echo $arg | awk '{print $2}'` + read -r fs mntp <<<"$arg" log_note "Verify that 'zfs destroy' fails to" \ "destroy filesystem when it is busy." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/.gitignore deleted file mode 100644 index 7fa74c3575bd..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/socket diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/Makefile.am deleted file mode 100644 index bfb01dcb8f86..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_diff - -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - zfs_diff_changes.ksh \ - zfs_diff_cliargs.ksh \ - zfs_diff_encrypted.ksh \ - zfs_diff_mangle.ksh \ - zfs_diff_timestamp.ksh \ - zfs_diff_types.ksh - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_diff - -pkgexec_PROGRAMS = socket -socket_SOURCES = socket.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_changes.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_changes.ksh index 51a1b4aa1199..ca8df6dab910 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_changes.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_changes.ksh @@ -47,7 +47,7 @@ function verify_object_change # change="$2" log_must eval "zfs diff -F $TESTSNAP1 $TESTSNAP2 > $FILEDIFF" - diffchg="$(awk -v path="$path" '$NF == path { print $1 }' < $FILEDIFF)" + diffchg="$(awk -v path="$path" '$NF == path { print $1 }' $FILEDIFF)" if [[ "$diffchg" != "$change" ]]; then log_fail "Unexpected change for $path ('$diffchg' != '$change')" else diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh index 0d08cf629572..81ee87f8aee9 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh @@ -73,10 +73,8 @@ log_must zfs snapshot "$TESTSNAP2" # 3. Verify 'zfs diff -t' correctly display timestamps typeset -i count=0 log_must eval "zfs diff -t $TESTSNAP1 $TESTSNAP2 > $FILEDIFF" -awk '{print substr($1,1,index($1,".")-1)" "$NF}' < "$FILEDIFF" | while read line +awk '{print substr($1,1,index($1,".")-1) " " $NF}' "$FILEDIFF" | while read -r ctime file do - read ctime file <<< "$line" - # If path from 'zfs diff' is not a file (could be xattr object) skip it if [[ ! -f "$file" ]]; then continue; diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh index 8e521b9f5a1e..414fde336c78 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh @@ -52,7 +52,7 @@ function verify_object_class # symbol="$2" log_must eval "zfs diff -F $TESTSNAP1 $TESTSNAP2 > $FILEDIFF" - diffsym="$(awk -v path="$path" '$NF == path { print $2 }' < $FILEDIFF)" + diffsym="$(awk -v path="$path" '$NF == path { print $2 }' $FILEDIFF)" if [[ "$diffsym" != "$symbol" ]]; then log_fail "Unexpected type for $path ('$diffsym' != '$symbol')" else @@ -111,11 +111,7 @@ verify_object_class "$MNTPOINT/cdev" "C" # 2. | (Named pipe) log_must zfs snapshot "$TESTSNAP1" -if is_freebsd; then - log_must mkfifo "$MNTPOINT/fifo" -else - log_must mknod "$MNTPOINT/fifo" p -fi +log_must mkfifo "$MNTPOINT/fifo" log_must zfs snapshot "$TESTSNAP2" verify_object_class "$MNTPOINT/fifo" "|" @@ -127,7 +123,7 @@ verify_object_class "$MNTPOINT/dir" "/" # 2. = (Socket) log_must zfs snapshot "$TESTSNAP1" -log_must $STF_SUITE/tests/functional/cli_root/zfs_diff/socket "$MNTPOINT/sock" +log_must zfs_diff-socket "$MNTPOINT/sock" log_must zfs snapshot "$TESTSNAP2" verify_object_class "$MNTPOINT/sock" "=" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/Makefile.am deleted file mode 100644 index 22e95907675d..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_get -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_get_001_pos.ksh \ - zfs_get_002_pos.ksh \ - zfs_get_003_pos.ksh \ - zfs_get_004_pos.ksh \ - zfs_get_005_neg.ksh \ - zfs_get_006_neg.ksh \ - zfs_get_007_neg.ksh \ - zfs_get_008_pos.ksh \ - zfs_get_009_pos.ksh \ - zfs_get_010_neg.ksh - -dist_pkgdata_DATA = \ - zfs_get_common.kshlib \ - zfs_get_list_d.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh index 807954a60692..b3286c31e6fa 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh @@ -102,16 +102,15 @@ function check_return_value found=0 while read line; do - typeset item - typeset value + typeset item value _ - item=$(echo $line | awk '{print $2}' 2>&1) + read -r _ item _ <<<"$line" if [[ $item == $p ]]; then ((found += 1)) cols=$(echo $line | awk '{print NF}') fi - value=$(echo $line | awk '{print $3}' 2>&1) + read -r _ _ value _ <<<"$line" if [[ $value == $uint64_max ]]; then log_fail "'zfs get $opt $props $dst' return " \ "UINT64_MAX constant." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_002_pos.ksh index 88822adfc761..6717787d06e6 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_002_pos.ksh @@ -85,7 +85,7 @@ for dst in ${dataset[@]}; do for opt in "" $(gen_option_str "${options[*]}" "-" "" $opt_numb); do for prop in $(gen_option_str "${props[*]}" "" "," $prop_numb) do - log_must eval "zfs get $opt $prop $dst > /dev/null" + log_must eval "zfs get $opt $prop $dst > /dev/null 2>&1" done done done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_003_pos.ksh index 2ea5aa0cb4cf..e96899118a89 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_003_pos.ksh @@ -55,9 +55,8 @@ log_onexit cleanup log_must zfs set atime=on $TESTPOOL/$TESTFS log_must zfs mount -o remount,noatime $TESTPOOL/$TESTFS -value1=$(zfs get -H atime $TESTPOOL/$TESTFS | awk '{print $3}') -value2=$(zfs get -H all $TESTPOOL/$TESTFS | awk '{print $2 " " $3}' | \ - grep ^atime | awk '{print $2}') +read -r _ _ value1 _ < <(zfs get -H atime $TESTPOOL/$TESTFS) +read -r _ value2 < <(zfs get -H all $TESTPOOL/$TESTFS | cut -f2,3 | grep ^atime) if [[ $value1 != $value2 ]]; then log_fail "value1($value1) != value2($value2)" fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh index 3bc4c6240ed3..20597c9a5feb 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh @@ -163,15 +163,12 @@ while (( i < ${#opts[*]} )); do log_must eval "zfs get ${opts[i]} all >$propfile" for ds in $allds; do - grep $ds $propfile >/dev/null 2>&1 - (( $? != 0 )) && \ + grep -q $ds $propfile || \ log_fail "There is no property for" \ "dataset $ds in 'get all' output." - propnum=`cat $propfile | awk '{print $1}' | \ - grep "${ds}$" | wc -l` - ds_type=`zfs get -H -o value type $ds` - case $ds_type in + propnum=$(awk -v ds="${ds}$" '$1 ~ ds {++cnt} END {print cnt}' $propfile) + case $(zfs get -H -o value type $ds) in filesystem ) (( propnum < fspropnum )) && \ (( failflag += 1 )) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_005_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_005_neg.ksh index c527cef087af..13685ef6f4bc 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_005_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_005_neg.ksh @@ -93,7 +93,7 @@ function test_options for dst in ${dataset[@]}; do for opt in $opts; do for prop in $props; do - log_mustnot eval "zfs get $opt -- $prop $dst > /dev/null" + log_mustnot eval "zfs get $opt -- $prop $dst > /dev/null 2>&1" done done done @@ -113,7 +113,7 @@ function test_options_bookmarks for dst in ${bookmark[@]}; do for opt in $opts; do for prop in $props; do - log_mustnot eval "zfs get $opt -- $prop $dst > /dev/null" + log_mustnot eval "zfs get $opt -- $prop $dst > /dev/null 2>&1" done done done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_008_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_008_pos.ksh index 296fe99968c8..9f3dd47cde7d 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_008_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_008_pos.ksh @@ -53,7 +53,7 @@ set -A options " " "-r" "-H" "-p" "-rHp" "-o name" \ set -A props type used available creation volsize referenced compressratio \ mounted origin recordsize quota reservation mountpoint sharenfs \ checksum compression atime devices exec readonly setuid snapdir \ - aclinherit canmount primarycache secondarycache \ + aclinherit canmount primarycache secondarycache version \ usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \ userquota@root groupquota@root userused@root groupused@root if is_freebsd; then @@ -62,11 +62,6 @@ else set -A props ${props[*]} zoned acltype fi -zfs upgrade -v > /dev/null 2>&1 -if [[ $? -eq 0 ]]; then - set -A props ${props[*]} version -fi - set -A dataset $TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \ $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh index 7fd6918b43db..1e80d4d2b7ef 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh @@ -39,7 +39,7 @@ # STRATEGY: # 1. Create a multiple depth filesystem. # 2. 'zfs get -d ' to get the output. -# 3. 'zfs get -r|egrep' to get the expected output. +# 3. 'zfs get -r|grep' to get the expected output. # 4. Compare the two outputs, they should be same. # @@ -55,7 +55,7 @@ log_onexit depth_fs_cleanup set -A all_props type used available creation volsize referenced \ compressratio mounted origin recordsize quota reservation mountpoint \ sharenfs checksum compression atime devices exec readonly setuid \ - snapdir aclinherit canmount primarycache secondarycache \ + snapdir aclinherit canmount primarycache secondarycache version \ usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \ userquota@root groupquota@root userused@root groupused@root if is_freebsd; then @@ -64,11 +64,6 @@ else set -A all_props ${all_props[*]} zoned acltype fi -zfs upgrade -v > /dev/null 2>&1 -if [[ $? -eq 0 ]]; then - set -A all_props ${all_props[*]} version -fi - depth_fs_setup mntpnt=$(get_prop mountpoint $DEPTH_FS) @@ -86,7 +81,7 @@ for dp in ${depth_array[@]}; do done for prop in $(gen_option_str "${all_props[*]}" "" "," $prop_numb); do log_must eval "zfs get -H -d $dp -o name $prop $DEPTH_FS > $DEPTH_OUTPUT" - log_must eval "zfs get -rH -o name $prop $DEPTH_FS | egrep -e '$eg_opt' > $EXPECT_OUTPUT" + log_must eval "zfs get -rH -o name $prop $DEPTH_FS | grep -E '$eg_opt' > $EXPECT_OUTPUT" log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT done (( old_val=dp )) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_ids_to_path/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_ids_to_path/Makefile.am deleted file mode 100644 index 5f5e3858787e..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_ids_to_path/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_ids_to_path -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_ids_to_path_001_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/Makefile.am deleted file mode 100644 index 95a51ec757ea..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_inherit -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - zfs_inherit_001_neg.ksh \ - zfs_inherit_002_neg.ksh \ - zfs_inherit_003_pos.ksh \ - zfs_inherit_mountpoint.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/zfs_inherit_001_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/zfs_inherit_001_neg.ksh index 62f255ca38b7..aba317f54237 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/zfs_inherit_001_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/zfs_inherit_001_neg.ksh @@ -47,14 +47,7 @@ verify_runnable "both" # Define uninherited properties and their short name. typeset props_str="type used available avail creation referenced refer \ compressratio ratio mounted origin quota reservation \ - reserv volsize volblocksize volblock" - -zfs upgrade -v > /dev/null 2>&1 -if [[ $? -eq 0 ]]; then - props_str="$props_str version" -fi - -set -A prop $props_str canmount + reserv volsize volblocksize volblock version canmount" log_assert "'zfs inherit' should return an error when attempting to inherit" \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_jail/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_jail/Makefile.am deleted file mode 100644 index b6dd7721e63e..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_jail/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_jail -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - jail.conf \ - zfs_jail_001_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/Makefile.am deleted file mode 100644 index 7dfec435ce7f..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_load-key -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_load-key.ksh \ - zfs_load-key_all.ksh \ - zfs_load-key_file.ksh \ - zfs_load-key_https.ksh \ - zfs_load-key_location.ksh \ - zfs_load-key_noop.ksh \ - zfs_load-key_recursive.ksh - -dist_pkgdata_DATA = \ - zfs_load-key.cfg \ - zfs_load-key_common.kshlib \ - PASSPHRASE \ - HEXKEY \ - RAWKEY diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key.ksh index 8af9f80cfbd7..11a97a83e25e 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key.ksh @@ -70,7 +70,8 @@ log_must key_available $TESTPOOL/$TESTFS1 log_mustnot eval "echo $PASSPHRASE | zfs load-key $TESTPOOL/$TESTFS1" -typeset DISK2="$(echo $DISKS | awk '{ print $2 }')" +typeset DISK2 _ +read -r _ DISK2 _ <<<"$DISKS" log_must eval "echo $PASSPHRASE | zpool create -O encryption=on" \ "-O keyformat=passphrase -O keylocation=prompt $TESTPOOL1 $DISK2" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_all.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_all.ksh index 3c18e4538d34..515753722d20 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_all.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_all.ksh @@ -56,7 +56,8 @@ log_must zfs create -o encryption=on -o keyformat=passphrase \ log_must zfs create -V 64M -o encryption=on -o keyformat=passphrase \ -o keylocation=file:///$TESTPOOL/pkey $TESTPOOL/zvol -typeset DISK2="$(echo $DISKS | awk '{ print $2}')" +typeset DISK2 _ +read -r _ DISK2 _ <<<"$DISKS" log_must zpool create -O encryption=on -O keyformat=passphrase \ -O keylocation=file:///$TESTPOOL/pkey $TESTPOOL1 $DISK2 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib index f7461437c615..4a85999b4ab8 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib @@ -42,8 +42,7 @@ function key_available function key_unavailable { - key_available $1 && return 1 - return 0 + ! key_available $1 } function verify_keyformat diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/Makefile.am deleted file mode 100644 index 8c90b2e75e5a..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_mount -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_mount_001_pos.ksh \ - zfs_mount_002_pos.ksh \ - zfs_mount_003_pos.ksh \ - zfs_mount_004_pos.ksh \ - zfs_mount_005_pos.ksh \ - zfs_mount_006_pos.ksh \ - zfs_mount_007_pos.ksh \ - zfs_mount_008_pos.ksh \ - zfs_mount_009_neg.ksh \ - zfs_mount_010_neg.ksh \ - zfs_mount_011_neg.ksh \ - zfs_mount_012_pos.ksh \ - zfs_mount_013_pos.ksh \ - zfs_mount_014_neg.ksh \ - zfs_mount_all_001_pos.ksh \ - zfs_mount_all_fail.ksh \ - zfs_mount_all_mountpoints.ksh \ - zfs_mount_encrypted.ksh \ - zfs_mount_remount.ksh \ - zfs_mount_test_race.ksh \ - zfs_multi_mount.ksh - -dist_pkgdata_DATA = \ - zfs_mount.cfg \ - zfs_mount.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib index 85566e565319..23cab2511a41 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib @@ -35,10 +35,7 @@ function force_unmount #dev { typeset dev=$1 - ismounted $dev - if (( $? == 0 )); then - log_must zfs $unmountforce $dev - fi + ismounted $dev && log_must zfs $unmountforce $dev return 0 } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_005_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_005_pos.ksh index c0cb693f6ce6..b42b2496e4b9 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_005_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_005_pos.ksh @@ -77,14 +77,13 @@ cd $TESTDIR || \ zfs $mountcmd $TESTPOOL/$TESTFS ret=$? if is_linux || is_freebsd; then - (( ret == 0 )) || \ - log_fail "'zfs $mountcmd $TESTPOOL/$TESTFS' " \ - "unexpected return code of $ret." + expected=0 else - (( ret == 1 )) || \ - log_fail "'zfs $mountcmd $TESTPOOL/$TESTFS' " \ - "unexpected return code of $ret." + expected=1 fi +(( ret == expected )) || \ + log_fail "'zfs $mountcmd $TESTPOOL/$TESTFS' " \ + "unexpected return code of $ret." log_note "Make sure the filesystem $TESTPOOL/$TESTFS is unmounted" if is_linux || is_freebsd; then diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_007_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_007_pos.ksh index 409dd06d7f88..a11f53d79ba0 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_007_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_007_pos.ksh @@ -112,7 +112,7 @@ function get_reverse_option typeset val typeset -i ind=0 - val=$(get_prop $prop $fs) || log_fail "get_prop $prop $fs" + val=$(get_prop $prop $fs) if [[ $val == "on" ]]; then (( ind = i * 2 )) else @@ -127,7 +127,6 @@ cleanup for property in ${properties[@]}; do orig_val=$(get_prop $property $fs) - (($? != 0)) && log_fail "get_prop $property $fs" # Set filesystem property temporarily reverse_opt=$(get_reverse_option $fs $property) @@ -135,7 +134,6 @@ for property in ${properties[@]}; do log_must zfs mount -o $reverse_opt $fs cur_val=$(get_prop $property $fs) - (($? != 0)) && log_fail "get_prop $property $fs" # In LZ, a user with all zone privileges can never with "devices" if ! is_global_zone && [[ $property == devices ]] ; then @@ -153,7 +151,6 @@ for property in ${properties[@]}; do log_must zfs mount $fs cur_val=$(get_prop $property $fs) - (($? != 0)) && log_fail "get_prop $property $fs" if [[ $orig_val != $cur_val ]]; then log_fail "zfs mount -o $reverse_opt " \ "change the property that is stored on disks" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_multi_mount.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_multi_mount.ksh index bd86eaa16bb4..c4b4f0773137 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_multi_mount.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_multi_mount.ksh @@ -56,7 +56,7 @@ log_must zfs create $TESTDS MNTPFS="$(get_prop mountpoint $TESTDS)" FILENAME="$MNTPFS/file" log_must mkfile 128k $FILENAME -log_must exec 9<> $FILENAME # open file +log_must eval "exec 9<> $FILENAME" # open file # 3. Lazy umount if is_freebsd; then @@ -74,7 +74,7 @@ log_must zfs mount $TESTDS if [ ! -f $FILENAME ]; then log_fail "Lazy remount failed" fi -log_must exec 9>&- # close fd +log_must eval "exec 9>&-" # close fd # 5. Verify multiple mounts of the same dataset are possible MNTPFS2="$MNTPFS-second" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_program/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_program/Makefile.am deleted file mode 100644 index d797a636b347..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_program/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_program -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_program_json.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_promote/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_promote/Makefile.am deleted file mode 100644 index 8a8c56a093d2..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_promote/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_promote -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_promote_001_pos.ksh \ - zfs_promote_002_pos.ksh \ - zfs_promote_003_pos.ksh \ - zfs_promote_004_pos.ksh \ - zfs_promote_005_pos.ksh \ - zfs_promote_006_neg.ksh \ - zfs_promote_007_neg.ksh \ - zfs_promote_008_pos.ksh \ - zfs_promote_encryptionroot.ksh - -dist_pkgdata_DATA = \ - zfs_promote.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_property/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_property/Makefile.am deleted file mode 100644 index d8a5687b1ea2..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_property/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_property -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_written_property_001_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh index f31ff48099e9..f53a4ac71b68 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh @@ -217,12 +217,11 @@ for ds in $datasets; do sync_pool done recursive_output=$(zfs get -p -r written@current $TESTPOOL | \ - grep -v $TESTFS1@ | grep -v $TESTFS2@ | grep -v $TESTFS3@ | \ - grep -v "VALUE" | grep -v "-") + grep -ve $TESTFS1@ -e $TESTFS2@ -e $TESTFS3@ -e "VALUE" | grep -v "-") expected="$((20 * mb_block))" for ds in $datasets; do writtenat=$(echo "$recursive_output" | grep -v $ds/) - writtenat=$(echo "$writtenat" | grep $ds | awk '{print $3}') + writtenat=$(echo "$writtenat" | awk -v ds="$ds" '$0 ~ ds {print $3}') within_percent $writtenat $expected 99.5 || \ log_fail "Unexpected written@ value on $ds" done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/Makefile.am deleted file mode 100644 index cf9490de4e81..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_receive -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_receive_001_pos.ksh \ - zfs_receive_002_pos.ksh \ - zfs_receive_003_pos.ksh \ - zfs_receive_004_neg.ksh \ - zfs_receive_005_neg.ksh \ - zfs_receive_006_pos.ksh \ - zfs_receive_007_neg.ksh \ - zfs_receive_008_pos.ksh \ - zfs_receive_009_neg.ksh \ - zfs_receive_010_pos.ksh \ - zfs_receive_011_pos.ksh \ - zfs_receive_012_pos.ksh \ - zfs_receive_013_pos.ksh \ - zfs_receive_014_pos.ksh \ - zfs_receive_015_pos.ksh \ - zfs_receive_016_pos.ksh \ - receive-o-x_props_override.ksh \ - receive-o-x_props_aliases.ksh \ - zfs_receive_from_encrypted.ksh \ - zfs_receive_from_zstd.ksh \ - zfs_receive_new_props.ksh \ - zfs_receive_to_encrypted.ksh \ - zfs_receive_raw.ksh \ - zfs_receive_raw_incremental.ksh \ - zfs_receive_raw_-d.ksh \ - zfs_receive_-e.ksh \ - zfs_receive_-wR-encrypted-mix.ksh - -dist_pkgdata_DATA = \ - zstd_test_data.txt diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_001_pos.ksh index 8a6cd8c409be..2b4a086965e8 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_001_pos.ksh @@ -105,10 +105,7 @@ for orig_fs in $datasets ; do typeset -i i=0 while (( i < ${#orig_snap[*]} )); do - file_write -o create -f ${orig_data[$i]} -b 512 \ - -c 8 >/dev/null 2>&1 - (( $? != 0 )) && \ - log_fail "Writing data into zfs filesystem fails." + log_must eval "file_write -o create -f ${orig_data[$i]} -b 512 -c 8 >/dev/null 2>&1" log_must zfs snapshot ${orig_snap[$i]} if (( i < 1 )); then log_must eval "zfs send ${orig_snap[$i]} > ${bkup[$i]}" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh index cce387615315..48cebc87f039 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh @@ -62,7 +62,7 @@ log_onexit cleanup ibackup=$TEST_BASE_DIR/ibackup.$$ fs=$TESTPOOL/$TESTFS; snap1=$fs@snap1; snap2=$fs@snap2 -mntpnt=$(get_prop mountpoint $fs) || log_fail "get_prop mountpoint $fs" +mntpnt=$(get_prop mountpoint $fs) log_must mkfile 10m $mntpnt/file1 log_must zfs snapshot $snap1 log_must mkfile 10m $mntpnt/file2 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_005_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_005_neg.ksh index d8c71f2c2877..6a708a45e177 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_005_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_005_neg.ksh @@ -80,8 +80,8 @@ log_must zfs snapshot $init_snap log_must eval "zfs send $init_snap > $full_bkup" log_note "'zfs receive' fails with invalid send streams." -log_mustnot eval "cat /dev/null 2>&1 - if (( $? != 0 )); then - log_mustnot eval "zfs recv ${validopts[i]} $fs2 $fs3 < $bkup" - else + if echo ${validopts[i]} | grep -q "d"; then log_mustnot eval "zfs recv ${validopts[i]} $ctr1 $ctr2 < $bkup" + else + log_mustnot eval "zfs recv ${validopts[i]} $fs2 $fs3 < $bkup" fi (( i += 1 )) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_010_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_010_pos.ksh index 47e23e6ebca7..c91172ee048e 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_010_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_010_pos.ksh @@ -134,8 +134,7 @@ dd if=/dev/urandom of=$mntpnt/f18 bs=128k count=64 touch $mntpnt2/f18 # Remove objects that are intended to be missing. -rm $mntpnt/h17 -rm $mntpnt2/h* +rm $mntpnt/h17 $mntpnt2/h* # Add empty objects to $fs to exercise dmu_traverse code for i in {1..100}; do @@ -145,15 +144,15 @@ done log_must zfs snapshot $fs@s1 log_must zfs snapshot $fs2@s1 -log_must zfs send $fs@s1 > $TESTDIR/zr010p -log_must zfs send $fs2@s1 > $TESTDIR/zr010p2 +log_must eval "zfs send $fs@s1 > $TESTDIR/zr010p" +log_must eval "zfs send $fs2@s1 > $TESTDIR/zr010p2" # # Test that, when we receive a full send as a clone of itself, # nop-write saves us all the space used by data blocks. # -cat $TESTDIR/zr010p | log_must zfs receive -o origin=$fs@s1 $rfs +log_must eval "zfs receive -o origin=$fs@s1 $rfs < $TESTDIR/zr010p" size=$(get_prop used $rfs) size2=$(get_prop used $fs) if [[ $size -ge $(($size2 / 10)) ]] then @@ -163,13 +162,13 @@ fi log_must zfs destroy -fr $rfs # Correctness testing: receive each full send as a clone of the other fiesystem. -cat $TESTDIR/zr010p | log_must zfs receive -o origin=$fs2@s1 $rfs +log_must eval "zfs receive -o origin=$fs2@s1 $rfs < $TESTDIR/zr010p" mntpnt_old=$(get_prop mountpoint $fs) mntpnt_new=$(get_prop mountpoint $rfs) log_must directory_diff $mntpnt_old $mntpnt_new log_must zfs destroy -r $rfs -cat $TESTDIR/zr010p2 | log_must zfs receive -o origin=$fs@s1 $rfs +log_must eval "zfs receive -o origin=$fs@s1 $rfs < $TESTDIR/zr010p2" mntpnt_old=$(get_prop mountpoint $fs2) mntpnt_new=$(get_prop mountpoint $rfs) log_must directory_diff $mntpnt_old $mntpnt_new diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh index e1e93e9d2a3b..87bb63b36e52 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh @@ -52,7 +52,7 @@ log_onexit cleanup truncate -s 100M $tpoolfile log_must zpool create $temppool $tpoolfile log_must zfs create $src_fs -src_mnt=$(get_prop mountpoint $src_fs) || log_fail "get_prop mountpoint $src_fs" +src_mnt=$(get_prop mountpoint $src_fs) echo blah > $src_mnt/blah zfs snapshot $src_fs@base diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh index 72eebb4f9321..05c2ece4654f 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh @@ -58,27 +58,22 @@ log_note "Randomly selected ZSTD level: $random_level" log_must zfs create -o compress=zstd-$random_level $TESTPOOL/$TESTFS1 # Make a 5kb compressible file -log_must cat $src_data $src_data $src_data $src_data $src_data \ - > /$TESTPOOL/$TESTFS1/$TESTFILE0 +log_must eval cat $src_data $src_data $src_data $src_data $src_data \ + "> /$TESTPOOL/$TESTFS1/$TESTFILE0" typeset checksum=$(md5digest /$TESTPOOL/$TESTFS1/$TESTFILE0) log_must zfs snapshot $snap # get object number of file -listing=$(ls -i /$TESTPOOL/$TESTFS1/$TESTFILE0) -set -A array $listing -obj=${array[0]} +read -r obj _ < <(ls -i /$TESTPOOL/$TESTFS1/$TESTFILE0) log_note "file /$TESTPOOL/$TESTFS1/$TESTFILE0 has object number $obj" output=$(zdb -Zddddddbbbbbb $TESTPOOL/$TESTFS1 $obj 2> /dev/null \ - |grep -m 1 "L0 DVA" |head -n1) + | grep -m 1 "L0 DVA") dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output") log_note "block 0 of /$TESTPOOL/$TESTFS1/$TESTFILE0 has a DVA of $dva" -zstd_str=$(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1:\2:\3/p' <<< "$output") -zstd_size1=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[1]}') -zstd_version1=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[2]}') -zstd_level1=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[3]}') +read -r zstd_size1 zstd_version1 zstd_level1 < <(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1 \2 \3/p' <<< "$output") log_note "ZSTD src: size=$zstd_size1 version=$zstd_version1 level=$zstd_level1" log_note "Verify ZFS can receive the ZSTD compressed stream" @@ -89,23 +84,18 @@ typeset cksum1=$(md5digest /$TESTPOOL/$TESTFS2/$TESTFILE0) log_fail "Checksums differ ($cksum1 != $checksum)" # get object number of file -listing=$(ls -i /$TESTPOOL/$TESTFS2/$TESTFILE0) -set -A array $listing -obj=${array[0]} +read -r obj _ < <(ls -i /$TESTPOOL/$TESTFS2/$TESTFILE0) log_note "file /$TESTPOOL/$TESTFS2/$TESTFILE0 has object number $obj" output=$(zdb -Zddddddbbbbbb $TESTPOOL/$TESTFS2 $obj 2> /dev/null \ - |grep -m 1 "L0 DVA" |head -n1) + | grep -m 1 "L0 DVA") dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output") log_note "block 0 of /$TESTPOOL/$TESTFS2/$TESTFILE0 has a DVA of $dva" -zstd_str=$(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1:\2:\3/p' <<< "$output") -zstd_size2=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[1]}') +read -r zstd_size2 zstd_version2 zstd_level2 < <(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1 \2 \3/p' <<< "$output") +log_note "ZSTD dest: size=$zstd_size2 version=$zstd_version2 level=$zstd_level2" (( $zstd_size2 != $zstd_size1 )) && log_fail \ "ZFS recv failed: compressed size differs ($zstd_size2 != $zstd_size1)" -zstd_version2=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[2]}') -zstd_level2=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[3]}') -log_note "ZSTD dest: size=$zstd_size2 version=$zstd_version2 level=$zstd_level2" (( $zstd_level2 != $zstd_level1 )) && log_fail \ "ZFS recv failed: compression level did not match header level ($zstd_level2 != $zstd_level1)" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_new_props.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_new_props.ksh index 54f13355f5e8..ae63f5c6ac1d 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_new_props.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_new_props.ksh @@ -70,8 +70,8 @@ log_must zpool set feature@filesystem_limits=enabled "$rpoolname" log_must zfs create -o filesystem_limit=100 "$sendfs" log_must zfs snapshot "$sendfs@a" -log_must zfs send -R "$sendfs@a" >"$streamfile" -log_must eval "zfs recv -svuF $recvfs <$streamfile" +log_must eval "zfs send -R \"$sendfs@a\" >\"$streamfile\"" +log_must eval "zfs recv -svuF \"$recvfs\" <\"$streamfile\"" log_pass "ZFS can handle receiving streams with filesystem limits on \ pools where the feature was recently enabled" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/Makefile.am deleted file mode 100644 index f8273d72c569..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_rename -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_rename_001_pos.ksh \ - zfs_rename_002_pos.ksh \ - zfs_rename_003_pos.ksh \ - zfs_rename_004_neg.ksh \ - zfs_rename_005_neg.ksh \ - zfs_rename_006_pos.ksh \ - zfs_rename_007_pos.ksh \ - zfs_rename_008_pos.ksh \ - zfs_rename_009_neg.ksh \ - zfs_rename_010_neg.ksh \ - zfs_rename_011_pos.ksh \ - zfs_rename_012_neg.ksh \ - zfs_rename_013_pos.ksh \ - zfs_rename_014_neg.ksh \ - zfs_rename_encrypted_child.ksh \ - zfs_rename_to_encrypted.ksh \ - zfs_rename_mountpoint.ksh \ - zfs_rename_nounmount.ksh - -dist_pkgdata_DATA = \ - zfs_rename.cfg \ - zfs_rename.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/cleanup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/cleanup.ksh index 4638b63d72ea..0a5b6c36111b 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/cleanup.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/cleanup.ksh @@ -33,11 +33,7 @@ default_cleanup_noexit -if [[ -d $TESTDIR2 ]]; then - rm -rf $TESTDIR2 - if (( $? != 0 )); then - log_unresolved Could not remove $TESTDIR2 - fi -fi +rm -rf $TESTDIR2 || + log_unresolved Could not remove $TESTDIR2 log_pass diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/setup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/setup.ksh index 788e093fb2ca..03701d4f5522 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/setup.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/setup.ksh @@ -36,12 +36,9 @@ DISK=${DISKS%% *} default_setup_noexit "$DISK" "true" "true" -if [[ -d $TESTDIR2 ]]; then - rm -rf $TESTDIR2 - if (( $? != 0 )); then - log_unresolved Could not remove $TESTDIR2 - fi -fi +rm -rf $TESTDIR2 || + log_unresolved Could not remove $TESTDIR2 + log_must zfs set compression=off $TESTPOOL/$TESTFS log_must zfs create -o compression=off $TESTPOOL/$DATAFS log_must zfs set mountpoint=$TESTDIR2 $TESTPOOL/$DATAFS diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib index af1c2f7bedaf..cafffbd85266 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib @@ -92,8 +92,7 @@ function cleanup fi if [[ ${dataset[i]}-new != *@* ]] ; then - zfs rename ${dataset[i]}-new ${dataset[i]} - if [[ $? -ne 0 ]]; then + if ! zfs rename ${dataset[i]}-new ${dataset[i]}; then typeset newfs=${dataset[i]}-new typeset oldfs=${dataset[i]} typeset mntp=$(get_prop mountpoint $newfs) @@ -120,8 +119,6 @@ function cmp_data #<$1 src data, $2 tgt data> typeset src=$1 typeset tgt=$2 - cmp $src $tgt >/dev/null 2>&1 - - return $? + cmp $src $tgt >/dev/null } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_014_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_014_neg.ksh index 1c962608d784..57bae24277e1 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_014_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_014_neg.ksh @@ -81,7 +81,7 @@ function nesting_cleanup # before resetting it, it will be left at the modified # value for the remaining tests. That's the reason # we reset it again here just in case. - log_must set_tunable_impl MAX_DATASET_NESTING 50 Z zcommon + log_must set_tunable64 MAX_DATASET_NESTING 50 Z } log_onexit nesting_cleanup @@ -93,13 +93,13 @@ log_must zfs create -p $TESTPOOL/$dsC16 log_mustnot zfs rename $TESTPOOL/$dsA02 $TESTPOOL/$dsB15A # extend limit -log_must set_tunable_impl MAX_DATASET_NESTING 64 Z zcommon +log_must set_tunable64 MAX_DATASET_NESTING 64 Z log_mustnot zfs rename $TESTPOOL/$dsA02 $TESTPOOL/$dsB16A log_must zfs rename $TESTPOOL/$dsA02 $TESTPOOL/$dsB15A # bring back old limit -log_must set_tunable_impl MAX_DATASET_NESTING 50 Z zcommon +log_must set_tunable64 MAX_DATASET_NESTING 50 Z log_mustnot zfs rename $TESTPOOL/$dsC01 $TESTPOOL/$dsB15A47C log_must zfs rename $TESTPOOL/$dsB15A47A $TESTPOOL/$dsB15A47B diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_nounmount.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_nounmount.ksh index 1c707762a72c..96826d814f18 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_nounmount.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_nounmount.ksh @@ -39,7 +39,7 @@ function rename_cleanup zfs destroy -fR $TESTPOOL/renamed } -back=$(pwd) +back=$PWD log_onexit rename_cleanup log_must zfs create $TESTPOOL/rename_test @@ -72,14 +72,15 @@ log_must zfs list $TESTPOOL/renamed log_must zfs list $TESTPOOL/renamed/child log_must zfs list $TESTPOOL/renamed/child/grandchild -missing=$(zfs mount | awk -v pat=$TESTPOOL/renamed '$1 ~ pat' | awk \ +missing=$(zfs mount | awk \ + -v genpat=$TESTPOOL/renamed \ -v mntp_p=$mntp_p \ -v mntp_c=$mntp_c \ -v mntp_g=$mntp_g ' BEGIN { p = c = g = 0 } - $2 == mntp_p { p = 1 } - $2 == mntp_c { c = 1 } - $2 == mntp_g { g = 1 } + $1 ~ genpat && $2 == mntp_p { p = 1 } + $1 ~ genpat && $2 == mntp_c { c = 1 } + $1 ~ genpat && $2 == mntp_g { g = 1 } END { if (p != 1) print mntp_p diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_reservation/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_reservation/Makefile.am deleted file mode 100644 index 5b7b758a056a..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_reservation/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_reservation -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_reservation_001_pos.ksh \ - zfs_reservation_002_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_reservation/zfs_reservation_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_reservation/zfs_reservation_002_pos.ksh index c482f9c3c7df..7f90630360ff 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_reservation/zfs_reservation_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_reservation/zfs_reservation_002_pos.ksh @@ -73,16 +73,8 @@ log_must zfs set reservation=none $TESTPOOL/$RESERVATION2 for FS in $TESTPOOL/$RESERVATION $TESTPOOL/$RESERVATION2 do - - reserve=`zfs get -pH reservation $FS | awk '{print $3}'` - if [[ $reserve -ne 0 ]]; then - log_fail "ZFS get -p reservation did not return 0" - fi - - reserve=`zfs get -H reservation $FS | awk '{print $3}'` - if [[ $reserve != "none" ]]; then - log_fail "ZFS get reservation did not return 'none'" - fi + log_must [ $(zfs get -pHo value reservation $FS) -eq 0 ] + log_must [ $(zfs get -Ho value reservation $FS) = none ] done log_pass "Successfully set reservation to 0 and 'none'" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/Makefile.am deleted file mode 100644 index 4d278f724527..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_rollback -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_rollback_001_pos.ksh \ - zfs_rollback_002_pos.ksh \ - zfs_rollback_003_neg.ksh \ - zfs_rollback_004_neg.ksh - -dist_pkgdata_DATA = \ - zfs_rollback.cfg \ - zfs_rollback_common.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib index 2eadb68c372d..cc1b24697d21 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib @@ -36,9 +36,9 @@ # $1 full file name function getsum #fname { - (( ${#1} == 0 )) && \ - log_fail "Need give file name." - return $(sum $1 | awk '{print $1}') + typeset sum + read -r sum _ < <(cksum "$1") + echo $sum } # Define global variable checksum, get the original file sum. @@ -270,11 +270,7 @@ function check_files typeset sum0=$(getsum $file0) typeset sum1=$(getsum $file1) typeset sum2=$(getsum $file2) - if [[ $sum0 != $origsum || \ - $sum1 != $origsum || sum2 != $origsum ]] - then - log_fail "After rollback, file sum is changed." - fi + log_must [ $sum0 = $origsum \&\& $sum1 = $origsum \&\& sum2 = $origsum ] ;; $TESTSNAP1) log_must files_exist $file0 $file1 @@ -282,19 +278,14 @@ function check_files typeset sum0=$(getsum $file0) typeset sum1=$(getsum $file1) - if [[ $sum0 != $origsum || $sum1 != $origsum ]] - then - log_fail "After rollback, file sum is changed." - fi + log_must [ $sum0 = $origsum \&\& $sum1 = $origsum ] ;; $TESTSNAP) log_must files_exist $file0 log_must files_nonexist $file1 $file2 typeset sum0=$(getsum $file0) - if [[ $sum0 != $origsum ]]; then - log_fail "After rollback, file sum is changed." - fi + log_must [ $sum0 = $origsum ] ;; esac } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/Makefile.am deleted file mode 100644 index 25c7065670f2..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_send -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_send_001_pos.ksh \ - zfs_send_002_pos.ksh \ - zfs_send_003_pos.ksh \ - zfs_send_004_neg.ksh \ - zfs_send_005_pos.ksh \ - zfs_send_006_pos.ksh \ - zfs_send_007_pos.ksh \ - zfs_send_encrypted.ksh \ - zfs_send_encrypted_unloaded.ksh \ - zfs_send_raw.ksh \ - zfs_send_sparse.ksh \ - zfs_send-b.ksh \ - zfs_send_skip_missing.ksh - -dist_pkgdata_DATA = \ - zfs_send.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_001_pos.ksh index b18433085ed5..2c7bac851608 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_001_pos.ksh @@ -96,9 +96,7 @@ log_must zfs set mountpoint=$TESTDIR1 $rst_root file_write -o create -f $init_data -b $BLOCK_SIZE -c $WRITE_COUNT log_must zfs snapshot $init_snap -zfs send $init_snap > $full_bkup -(( $? != 0 )) && \ - log_fail "'zfs send' fails to create full send" +log_must eval "zfs send $init_snap > $full_bkup" log_note "Verify the send stream is valid to receive." @@ -111,9 +109,7 @@ log_note "Verify 'zfs send -i' can create incremental send stream." file_write -o create -f $inc_data -b $BLOCK_SIZE -c $WRITE_COUNT -d 0 log_must zfs snapshot $inc_snap -zfs send -i $init_snap $inc_snap > $inc_bkup -(( $? != 0 )) && \ - log_fail "'zfs send -i' fails to create incremental send" +log_must eval "zfs send -i $init_snap $inc_snap > $inc_bkup" log_note "Verify the incremental send stream is valid to receive." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_002_pos.ksh index 42bdddd2cc18..c55ce08d006e 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_002_pos.ksh @@ -66,12 +66,8 @@ function do_testing # log_must zfs set $property=$prop_val $fs file_write -o create -f $origfile -b $BLOCK_SIZE -c $WRITE_COUNT log_must zfs snapshot $snap - zfs send $snap > $stream - (( $? != 0 )) && \ - log_fail "'zfs send' fails to create send streams." - zfs receive -d $ctr <$stream - (( $? != 0 )) && \ - log_fail "'zfs receive' fails to receive send streams." + log_must eval "zfs send $snap > $stream" + log_must eval "zfs receive -d $ctr <$stream" #verify receive result ! datasetexists $rstfs && \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_006_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_006_pos.ksh index 42628a0512e9..c5dfb89394f4 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_006_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_006_pos.ksh @@ -76,10 +76,10 @@ function verify_size_estimates typeset file_size=$2 typeset refer_diff=$(echo "$refer_size - $estimate_size" | bc) refer_diff=$(echo "$refer_diff / 1" | bc) - refer_diff=$(echo "$refer_diff" | nawk '{print ($1 < 0) ? ($1 * -1): $1'}) + refer_diff=$(echo "$refer_diff" | awk '{print ($1 < 0) ? ($1 * -1): $1'}) typeset file_diff=$(echo "$file_size - $estimate_size" | bc) file_diff=$(echo "$file_diff / 1" | bc) - file_diff=$(echo "$file_diff" | nawk '{print ($1 < 0) ? ($1 * -1):$1'}) + file_diff=$(echo "$file_diff" | awk '{print ($1 < 0) ? ($1 * -1):$1'}) typeset expected_diff=$(cal_percentage $refer_size) [[ -z $refer_diff && -z $file_diff && -z $expected_diff ]] && \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_007_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_007_pos.ksh index 306fabc8cef4..15760398127c 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_007_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_007_pos.ksh @@ -52,12 +52,12 @@ streamfile=$(mktemp $TESTDIR/file.XXXXXX) vdev=$(mktemp $TEST_BASE_DIR/file.XXXXXX) -test_pool () +function test_pool { POOL=$1 log_must zfs create -o recordsize=512 $POOL/fs mntpnt=$(get_prop mountpoint "$POOL/fs") - log_must dd if=/dev/urandom of=${mntpnt}/file bs=512 count=1 2>/dev/null + log_must eval "dd if=/dev/urandom of=${mntpnt}/file bs=512 count=1 2>/dev/null" object=$(ls -i $mntpnt | awk '{print $1}') log_must zfs snapshot $POOL/fs@a while true; do @@ -67,10 +67,7 @@ test_pool () sync_all_pools # check if we started reusing objects object=$(ls -i $mntpnt | sort -n | awk -v object=$object \ - '{if ($1 <= object) {exit 1}} END {print $1}') - if [[ $? -ne 0 ]]; then - break - fi + '{if ($1 <= object) {exit 1}} END {print $1}') || break done dd if=/dev/urandom of=${mntpnt}/$FILE bs=512 count=1 seek=1 2>/dev/null diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/Makefile.am deleted file mode 100644 index f7362ff2556f..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/Makefile.am +++ /dev/null @@ -1,35 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_set -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - cache_001_pos.ksh \ - cache_002_neg.ksh \ - canmount_001_pos.ksh \ - canmount_002_pos.ksh \ - canmount_003_pos.ksh \ - canmount_004_pos.ksh \ - checksum_001_pos.ksh \ - compression_001_pos.ksh \ - mountpoint_001_pos.ksh \ - mountpoint_002_pos.ksh \ - mountpoint_003_pos.ksh \ - onoffs_001_pos.ksh \ - property_alias_001_pos.ksh \ - readonly_001_pos.ksh \ - reservation_001_neg.ksh \ - ro_props_001_pos.ksh \ - share_mount_001_neg.ksh \ - snapdir_001_pos.ksh \ - user_property_001_pos.ksh \ - user_property_002_pos.ksh \ - user_property_003_neg.ksh \ - user_property_004_pos.ksh \ - version_001_neg.ksh \ - zfs_set_001_neg.ksh \ - zfs_set_002_neg.ksh \ - zfs_set_003_neg.ksh \ - zfs_set_keylocation.ksh \ - zfs_set_feature_activation.ksh - -dist_pkgdata_DATA = \ - zfs_set_common.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh index ac5fc8188f5a..fe8aa2fd1e07 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh @@ -81,14 +81,8 @@ function cleanup log_assert "Setting a valid property of canmount to file system, it must be successful." log_onexit cleanup -typeset old_fs_canmount="" old_ctr_canmount="" - -old_fs_canmount=$(get_prop canmount $TESTPOOL/$TESTFS) -[[ $? != 0 ]] && \ - log_fail "Get the $TESTPOOL/$TESTFS canmount error." -old_ctr_canmount=$(get_prop canmount $TESTPOOL/$TESTCTR) -[[ $? != 0 ]] && \ - log_fail "Get the $TESTPOOL/$TESTCTR canmount error." +typeset old_fs_canmount=$(get_prop canmount $TESTPOOL/$TESTFS) +typeset old_ctr_canmount=$(get_prop canmount $TESTPOOL/$TESTCTR) log_must zfs snapshot $TESTPOOL/$TESTFS@$TESTSNAP log_must zfs snapshot $TESTPOOL/$TESTVOL@$TESTSNAP diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh index 55c71f6ca33a..bb7cd4cccc39 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh @@ -77,9 +77,7 @@ function cleanup if datasetexists $ds; then mntp=$(get_prop mountpoint $ds) destroy_dataset $ds - if [[ -d $mntp ]]; then - rm -fr $mntp - fi + [ -d $mntp ] && rm -fr $mntp fi snapexists $TESTPOOL/$TESTFS@$TESTSNAP && \ @@ -91,9 +89,7 @@ function cleanup zfs unmount -a > /dev/null 2>&1 log_must zfs mount -a - if [[ -d $tmpmnt ]]; then - rm -fr $tmpmnt - fi + [ -d $tmpmnt ] && rm -fr $tmpmnt } log_assert "Setting canmount=noauto to file system, it must be successful." @@ -125,7 +121,7 @@ while (( i < ${#dataset_pos[*]} )) ; do set_n_check_prop "noauto" "canmount" "$dataset" log_must zfs set mountpoint=$tmpmnt $dataset log_must zfs set sharenfs=on $dataset - if ismounted $dataset; then + if ismounted $dataset; then zfs unmount -a > /dev/null 2>&1 log_must mounted $dataset log_must zfs unmount $dataset diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_003_pos.ksh index e4664d03b43c..b370118a7f76 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_003_pos.ksh @@ -97,9 +97,9 @@ while (( i < ${#dataset_pos[*]} )); do done i=0 -while (( i < ${#dataset_pos[*]} )) ; do +while (( i < ${#dataset_pos[*]} )); do dataset=${dataset_pos[i]} - if ismounted $dataset; then + if ismounted $dataset; then log_must cd ${old_mnt[i]} set_n_check_prop "noauto" "canmount" "$dataset" log_must mounted $dataset diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_001_pos.ksh index 1255ae5f5666..30efef1c383f 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_001_pos.ksh @@ -69,11 +69,7 @@ log_assert "Setting a valid mountpoint to file system, it must be successful." log_onexit cleanup old_fs_mpt=$(get_prop mountpoint $TESTPOOL/$TESTFS) -[[ $? != 0 ]] && \ - log_fail "Get the $TESTPOOL/$TESTFS mountpoint error." old_ctr_mpt=$(get_prop mountpoint $TESTPOOL/$TESTCTR) -[[ $? != 0 ]] && \ - log_fail "Get the $TESTPOOL/$TESTCTR mountpoint error." if [[ ! -d $TESTDIR2 ]]; then log_must mkdir $TESTDIR2 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_002_pos.ksh index 48580cafdb31..603e84dcd07f 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_002_pos.ksh @@ -66,11 +66,7 @@ log_assert "Setting a valid mountpoint for an unmounted file system, \ log_onexit cleanup old_fs_mpt=$(get_prop mountpoint $TESTPOOL/$TESTFS) -[[ $? != 0 ]] && \ - log_fail "Unable to get the mountpoint property for $TESTPOOL/$TESTFS" old_ctr_mpt=$(get_prop mountpoint $TESTPOOL/$TESTCTR) -[[ $? != 0 ]] && \ - log_fail "Unable to get the mountpoint property for $TESTPOOL/$TESTCTR" if [[ ! -d $TESTDIR2 ]]; then log_must mkdir $TESTDIR2 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_003_pos.ksh index 4d86100c03ef..38bbda0d1fae 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_003_pos.ksh @@ -109,10 +109,8 @@ while ((i < ${#args[@]})); do msg=$(mount | grep "$tmpmnt ") - echo $msg | grep "${args[((i))]}" > /dev/null 2>&1 - if (($? != 0)) ; then - echo $msg | grep "${args[((i-1))]}" > /dev/null 2>&1 - if (($? == 0)) ; then + if ! echo $msg | grep -q "${args[((i))]}"; then + if echo $msg | grep -q "${args[((i-1))]}"; then log_fail "Expected option: ${args[((i))]} \n" \ "Real option: $msg" fi @@ -130,8 +128,7 @@ while ((i < ${#args[@]})); do args[((i+1))]="/nodevices/" fi - echo $msg | grep "${args[((i+1))]}" > /dev/null 2>&1 - if (($? != 0)) ; then + if ! echo $msg | grep -q "${args[((i+1))]}"; then log_fail "Expected option: ${args[((i+1))]} \n" \ "Real option: $msg" fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/property_alias_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/property_alias_001_pos.ksh index f1befe60c373..0ddafe178e3a 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/property_alias_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/property_alias_001_pos.ksh @@ -91,9 +91,7 @@ typeset -i i=0 for ds in $pool $fs $vol; do for propname in ${ro_prop[*]}; do - zfs get -pH -o value $propname $ds >/dev/null 2>&1 - (( $? != 0 )) && \ - log_fail "Get the property $proname of $ds failed." + log_must eval "zfs get -pH -o value $propname $ds >/dev/null 2>&1" done i=0 while (( i < ${#rw_prop[*]} )); do @@ -120,9 +118,7 @@ for ds in $pool $fs $vol; do done if [[ $ds == $vol ]]; then for propname in "volblocksize" "volblock" ; do - zfs get -pH -o value $propname $ds >/dev/null 2>&1 - (( $? != 0 )) && \ - log_fail "Get the property $propname of $ds failed." + log_must eval "zfs get -pH -o value $propname $ds >/dev/null 2>&1" done fi done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/reservation_001_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/reservation_001_neg.ksh index de6d83d2270c..b929047cf129 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/reservation_001_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/reservation_001_neg.ksh @@ -70,15 +70,7 @@ function set_n_check # data-set j=0 while (( $j < ${#suffix[*]} )); do - zfs set \ - reservation=${values[$i]}${suffix[$j]} $obj \ - > /dev/null 2>&1 - if [ $? -eq 0 ] - then - log_note "zfs set \ - reservation=${values[$i]}${suffix[$j]} $obj" - log_fail "The above reservation set returned 0!" - fi + log_mustnot zfs set reservation=${values[$i]}${suffix[$j]} $obj new_resv_val=$(get_prop reservation $obj) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/ro_props_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/ro_props_001_pos.ksh index 7177fac202d0..e24376a2bf74 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/ro_props_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/ro_props_001_pos.ksh @@ -55,18 +55,13 @@ typeset ro_props="type used creation referenced refer compressratio \ mounted origin" typeset snap_ro_props="volsize recordsize recsize quota reservation reserv mountpoint \ sharenfs checksum compression compress atime devices exec readonly rdonly \ - setuid" + setuid version" if is_freebsd; then snap_ro_props+=" jailed" else snap_ro_props+=" zoned" fi -zfs upgrade -v > /dev/null 2>&1 -if [[ $? -eq 0 ]]; then - snap_ro_props="$snap_ro_props version" -fi - function cleanup { datasetexists $TESTPOOL/$TESTVOL@$TESTSNAP && \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/snapdir_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/snapdir_001_pos.ksh index 083a6b1f464f..29a709397422 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/snapdir_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/snapdir_001_pos.ksh @@ -57,22 +57,12 @@ function verify_snapdir_visible # $1 dataset, $2 hidden|visible typeset dataset=$1 typeset value=$2 typeset mtpt=$(get_prop mountpoint $dataset) - typeset name - for name in `ls -a $mtpt`; do - if [[ $name == ".zfs" ]]; then - if [[ $value == "visible" ]]; then - return 0 - else - return 1 - fi - fi - done - - if [[ $value == "visible" ]]; then - return 1 + # $mtpt/.zfs always actually exists so [ -d $mtpt/.zfs ] is always true + if ls -a $mtpt | grep -xFq .zfs; then + [ $value = "visible" ] else - return 0 + [ $value != "visible" ] fi } @@ -95,15 +85,14 @@ log_assert "Setting a valid snapdir property on a dataset succeeds." for dataset in $all_datasets; do for value in hidden visible; do - if [[ $dataset == "$TESTPOOL/$TESTVOL" ]] ; then + if [ "$dataset" = "$TESTPOOL/$TESTVOL" ]; then set_n_check_prop "$value" "snapdir" \ "$dataset" "false" else set_n_check_prop "$value" "snapdir" \ "$dataset" - verify_snapdir_visible $dataset $value - [[ $? -eq 0 ]] || \ - log_fail "$dataset/.zfs is not $value as expect." + verify_snapdir_visible $dataset $value || + log_fail "$dataset/.zfs is not $value as expected." fi done done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/user_property_004_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/user_property_004_pos.ksh index bd11ea088333..8ab52679eb9a 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/user_property_004_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/user_property_004_pos.ksh @@ -68,32 +68,19 @@ function nonexist_user_prop log_assert "User property has no effect to snapshot until 'Snapshot properties' supported." log_onexit cleanup -typeset snap_property= - -zpool upgrade -v | grep "Snapshot properties" > /dev/null 2>&1 -if (( $? == 0 )) ; then - snap_property="true" -fi - for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL ; do typeset fssnap=$fs@snap prop_name=$(valid_user_property 10) value=$(user_property_value 16) - log_must eval "zfs set $prop_name='$value' $fs" - log_must eval "check_user_prop $fs $prop_name '$value'" + log_must zfs set $prop_name="$value" $fs + log_must check_user_prop $fs $prop_name "$value" log_must zfs snapshot $fssnap - if [[ -n $snap_property ]] ; then - log_mustnot nonexist_user_prop $prop_name $fssnap + log_mustnot nonexist_user_prop $prop_name $fssnap - log_must eval "zfs set $prop_name='$value' $fssnap" - log_mustnot nonexist_user_prop $prop_name $fssnap - else - log_must nonexist_user_prop $prop_name $fssnap - log_mustnot eval "zfs set $prop_name='$value' $fssnap" - log_must nonexist_user_prop $prop_name $fssnap - fi + log_must zfs set $prop_name="$value" $fssnap + log_mustnot nonexist_user_prop $prop_name $fssnap done log_pass "User properties has effect upon snapshot." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/version_001_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/version_001_neg.ksh index cf5ef5116e90..318a9aae6b45 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/version_001_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/version_001_neg.ksh @@ -66,11 +66,7 @@ function set_n_check # data-set orig_val=$(get_prop version $obj) while (($i < ${#values[*]})); do - zfs set version=${values[$i]} $obj > /dev/null 2>&1 - if [[ $? -eq 0 ]]; then - log_note "zfs set version=${values[$i]} $obj" - log_fail "The above version set returned 0!" - fi + log_mustnot eval "zfs set version=${values[$i]} $obj > /dev/null 2>&1" new_val=$(get_prop version $obj) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_001_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_001_neg.ksh index c9bc7565abd6..e58fe9bfe93c 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_001_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_001_neg.ksh @@ -77,9 +77,9 @@ while (( i < ${#dataset[@]} )); do done (( j += 1 )) done - # Additional recordsize - set_n_check_prop "recordsize" "2048K" "${dataset[i]}" false - set_n_check_prop "recordsize" "128B" "${dataset[i]}" false + # Additional recordsize + set_n_check_prop "32768K" "recordsize" "${dataset[i]}" false + set_n_check_prop "128B" "recordsize" "${dataset[i]}" false (( i += 1 )) done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib index 7e34341d8526..2858275cf2b9 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib @@ -73,17 +73,17 @@ function set_n_check_prop reservation|reserv|quota ) if [[ $expect_value == "none" ]]; then [[ $cur_value != "0" ]] && \ - log_fail "The '$dataset' '$prop' value \ - '$cur_value' is not expected." + log_fail "The '$dataset' '$prop' value" \ + "'$cur_value' is not expected." elif [[ $cur_value != $expect_value ]]; then - log_fail "The '$dataset' '$prop' value '$cur_value' \ - does not equal the expected value '$expect_value'." + log_fail "The '$dataset' '$prop' value '$cur_value'" \ + "does not equal the expected value '$expect_value'." fi ;; * ) if [[ $cur_value != $expect_value ]]; then - log_fail "The '$dataset' '$prop' value '$cur_value' \ - does not equal the expected value '$expect_value'." + log_fail "The '$dataset' '$prop' value '$cur_value'" \ + "does not equal the expected value '$expect_value'." fi ;; esac @@ -97,8 +97,8 @@ function set_n_check_prop if [[ "$expect_value" != "" && "$cur_value" != "$old_value" ]]; then - log_fail "The '$dataset' '$prop' value '$cur_value' \ - should equal with '$old_value'." + log_fail "The '$dataset' '$prop' value '$cur_value'" \ + "should equal '$old_value'." fi fi } @@ -119,8 +119,8 @@ function cleanup_user_prop typeset prop for prop in $user_prop; do - zfs inherit $prop $dt - (($? != 0)) && log_must zfs inherit $prop $dt + zfs inherit $prop $dt || + log_must zfs inherit $prop $dt done done } @@ -225,9 +225,7 @@ function user_property_value { typeset -i len=${1:-100} - typeset value=$(random_string ALL_CHAR $len) - - echo "$value" + random_string ALL_CHAR $len } # @@ -244,11 +242,7 @@ function check_user_prop typeset expect_value="$3" typeset value=$(zfs get -p -H -o value "$user_prop" $dtst 2>&1) - if [[ "$expect_value" == "$value" ]]; then - return 0 - else - return 1 - fi + [ "$expect_value" = "$value" ] } # @@ -258,14 +252,9 @@ function get_source { typeset prop=$1 typeset dataset=$2 - typeset source - source=$(zfs get -H -o source $prop $dataset) - if (($? != 0)); then + zfs get -H -o source $prop $dataset || log_fail "Unable to get $prop source for dataset $dataset" - fi - - echo "$source" } # @@ -315,15 +304,8 @@ function check_prop_inherit typeset value=$(get_prop "$prop" "$checked_dtst") typeset source=$(get_source "$prop" "$checked_dtst") - if [[ "$value" != "$inherited_value" || \ - "$source" != "inherited from $inherited_dtst" ]] - then - log_note "expected (value '$inherited_value', source 'inherited from $inherited_dtst')," \ - "got (value '$value', source '$source')" - return 1 - else - return 0 - fi + [ "$value" = "$inherited_value" ] && + [ "$source" = "inherited from $inherited_dtst" ] } # @@ -341,17 +323,9 @@ function check_prop_received typeset prop="$2" typeset value="$3" - received=$(zfs get -H -o received "$prop" "$dataset") - if (($? != 0)); then - log_fail "Unable to get $prop received value for dataset" \ - "$dataset" - fi - if [[ "$received" == "$value" ]] - then - return 0 - else - return 1 - fi + received=$(zfs get -H -o received "$prop" "$dataset") || + log_fail "Unable to get $prop received value for dataset $dataset" + [ "$received" = "$value" ] } # @@ -367,14 +341,7 @@ function check_prop_missing typeset dataset="$1" typeset prop="$2" - value=$(zfs get -H -o value "$prop" "$dataset") - if (($? != 0)); then + value=$(zfs get -H -o value "$prop" "$dataset") || log_fail "Unable to get $prop value for dataset $dataset" - fi - if [[ "-" == "$value" ]] - then - return 0 - else - return 1 - fi + [ "$value" = "-" ] } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/Makefile.am deleted file mode 100644 index 35332f822e6c..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_share -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_share_001_pos.ksh \ - zfs_share_002_pos.ksh \ - zfs_share_003_pos.ksh \ - zfs_share_004_pos.ksh \ - zfs_share_005_pos.ksh \ - zfs_share_006_pos.ksh \ - zfs_share_007_neg.ksh \ - zfs_share_008_neg.ksh \ - zfs_share_009_neg.ksh \ - zfs_share_010_neg.ksh \ - zfs_share_011_pos.ksh \ - zfs_share_012_pos.ksh \ - zfs_share_013_pos.ksh \ - zfs_share_concurrent_shares.ksh - -dist_pkgdata_DATA = \ - zfs_share.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_005_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_005_pos.ksh index 013e04ba311f..719dd645028a 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_005_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_005_pos.ksh @@ -72,20 +72,17 @@ while (( i < ${#shareopts[*]} )) do log_must zfs set sharenfs="${shareopts[i]}" $TESTPOOL/$TESTFS - option=`get_prop sharenfs $TESTPOOL/$TESTFS` + option=$(get_prop sharenfs $TESTPOOL/$TESTFS) if [[ $option != ${shareopts[i]} ]]; then log_fail "get sharenfs failed. ($option != ${shareopts[i]})" fi # Verify the single option after the leading 'ro' or 'rw'. if is_linux; then - option=`echo "$option" | cut -f2 -d','` + IFS=',' read -r _ option _ <<<"$option" fi - showshares_nfs | grep $option > /dev/null 2>&1 - if (( $? != 0 )); then - log_fail "The '$option' option was not found in share output." - fi + log_must eval "showshares_nfs | grep -q \"$option\"" ((i = i + 1)) done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_007_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_007_neg.ksh index c64157cee601..553605000d1b 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_007_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_007_neg.ksh @@ -63,10 +63,7 @@ do log_note "Setting sharenfs=${badopts[i]} $i " log_mustnot zfs set sharenfs="${badopts[i]}" $TESTPOOL/$TESTFS - showshares_nfs | grep $option > /dev/null 2>&1 - if (( $? == 0 )); then - log_fail "An invalid setting '$option' was propagated." - fi + log_mustnot eval "showshares_nfs | grep -q ${badopts[i]}" # # To global zone, sharenfs must be set 'off' before malformed testing. diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_009_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_009_neg.ksh index cf8c84cfe301..ddd65e88859b 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_009_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_009_neg.ksh @@ -63,8 +63,7 @@ if [[ $sharenfs_val == off ]]; then log_must zfs set sharenfs=on $fs fi -showshares_nfs | grep $mpt >/dev/null 2>&1 -if (( $? != 0 )); then +if ! showshares_nfs | grep -q $mpt; then log_must zfs share $fs fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_011_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_011_pos.ksh index 131b039e1cd2..efd7a2d0c7bd 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_011_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_011_pos.ksh @@ -67,20 +67,14 @@ typeset origdir=$PWD # unmount fails will not unshare the shared filesystem log_must zfs set sharenfs=on $TESTPOOL/$TESTFS log_must is_shared $TESTDIR -if cd $TESTDIR ; then - log_mustnot zfs umount $TESTPOOL/$TESTFS -else - log_fail "cd $TESTDIR fails" -fi +log_must cd $TESTDIR +log_mustnot zfs umount $TESTPOOL/$TESTFS log_must is_shared $TESTDIR # destroy fails will not unshare the shared filesystem log_must zfs create $TESTPOOL/$TESTFS/fs2 -if cd $TESTDIR/fs2 ; then - log_mustnot zfs destroy $TESTPOOL/$TESTFS/fs2 -else - log_fail "cd $TESTDIR/fs2 fails" -fi +log_must cd $TESTDIR/fs2 +log_mustnot zfs destroy $TESTPOOL/$TESTFS/fs2 log_must is_shared $TESTDIR/fs2 log_pass "Verify that umount and destroy fail, and do not unshare the shared" \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_013_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_013_pos.ksh index 150eddac0ebb..e9766de49285 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_013_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_013_pos.ksh @@ -46,35 +46,35 @@ cleanup log_must zfs set sharenfs="rw=[::1]" $TESTPOOL/$TESTFS output=$(showshares_nfs 2>&1) -log_must grep "::1(" <<< "$output" > /dev/null +log_must grep -q "::1(" <<< "$output" log_must zfs set sharenfs="rw=[2::3]" $TESTPOOL/$TESTFS output=$(showshares_nfs 2>&1) -log_must grep "2::3(" <<< "$output" > /dev/null +log_must grep -q "2::3(" <<< "$output" log_must zfs set sharenfs="rw=[::1]:[2::3]" $TESTPOOL/$TESTFS output=$(showshares_nfs 2>&1) -log_must grep "::1(" <<< "$output" > /dev/null -log_must grep "2::3(" <<< "$output" > /dev/null +log_must grep -q "::1(" <<< "$output" +log_must grep -q "2::3(" <<< "$output" log_must zfs set sharenfs="rw=[::1]/64" $TESTPOOL/$TESTFS output=$(showshares_nfs 2>&1) -log_must grep "::1/64(" <<< "$output" > /dev/null +log_must grep -q "::1/64(" <<< "$output" log_must zfs set sharenfs="rw=[2::3]/128" $TESTPOOL/$TESTFS output=$(showshares_nfs 2>&1) -log_must grep "2::3/128(" <<< "$output" > /dev/null +log_must grep -q "2::3/128(" <<< "$output" log_must zfs set sharenfs="rw=[::1]/32:[2::3]/128" $TESTPOOL/$TESTFS output=$(showshares_nfs 2>&1) -log_must grep "::1/32(" <<< "$output" > /dev/null -log_must grep "2::3/128(" <<< "$output" > /dev/null +log_must grep -q "::1/32(" <<< "$output" +log_must grep -q "2::3/128(" <<< "$output" log_must zfs set sharenfs="rw=[::1]:[2::3]/64:[2a01:1234:1234:1234:aa34:234:1234:1234]:1.2.3.4/24" $TESTPOOL/$TESTFS output=$(showshares_nfs 2>&1) -log_must grep "::1(" <<< "$output" > /dev/null -log_must grep "2::3/64(" <<< "$output" > /dev/null -log_must grep "2a01:1234:1234:1234:aa34:234:1234:1234(" <<< "$output" > /dev/null -log_must grep "1\\.2\\.3\\.4/24(" <<< "$output" > /dev/null +log_must grep -q "::1(" <<< "$output" +log_must grep -q "2::3/64(" <<< "$output" +log_must grep -q "2a01:1234:1234:1234:aa34:234:1234:1234(" <<< "$output" +log_must grep -q "1\\.2\\.3\\.4/24(" <<< "$output" log_pass "NFS share ip address propagated correctly." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_concurrent_shares.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_concurrent_shares.ksh index dbaaf39b65d4..22b8af4e89d8 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_concurrent_shares.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_concurrent_shares.ksh @@ -47,31 +47,20 @@ verify_runnable "global" function cleanup { wait - for fs in $(seq 0 50) + for fs in {0..50} do - log_must zfs set sharenfs=off $TESTPOOL/$TESTFS1/$fs - log_must zfs set sharenfs=off $TESTPOOL/$TESTFS2/$fs - log_must zfs set sharenfs=off $TESTPOOL/$TESTFS3/$fs - unshare_fs $TESTPOOL/$TESTFS1/$fs - unshare_fs $TESTPOOL/$TESTFS2/$fs - unshare_fs $TESTPOOL/$TESTFS3/$fs + for pfs in $TESTFS1 $TESTFS2 $TESTFS3 + do + log_must zfs set sharenfs=off $TESTPOOL/$pfs/$fs + unshare_fs $TESTPOOL/$pfs/$fs - if mounted $TESTPOOL/$TESTFS1/$fs; then - log_must zfs unmount $TESTPOOL/$TESTFS1/$fs - fi - if mounted $TESTPOOL/$TESTFS2/$fs; then - log_must zfs unmount $TESTPOOL/$TESTFS2/$fs - fi - if mounted $TESTPOOL/$TESTFS3/$fs; then - log_must zfs unmount $TESTPOOL/$TESTFS3/$fs - fi + if mounted $TESTPOOL/$pfs/$fs; then + log_must zfs unmount $TESTPOOL/$pfs/$fs + fi - datasetexists $TESTPOOL/$TESTFS1/$fs && \ - destroy_dataset $TESTPOOL/$TESTFS1/$fs -f - datasetexists $TESTPOOL/$TESTFS2/$fs && \ - destroy_dataset $TESTPOOL/$TESTFS2/$fs -f - datasetexists $TESTPOOL/$TESTFS3/$fs && \ - destroy_dataset $TESTPOOL/$TESTFS3/$fs -f + datasetexists $TESTPOOL/$pfs/$fs && \ + destroy_dataset $TESTPOOL/$pfs/$fs -f + done done log_must zfs share -a @@ -79,7 +68,7 @@ function cleanup function create_filesystems { - for fs in $(seq 0 50) + for fs in {0..50} do log_must zfs create -p $TESTPOOL/$TESTFS1/$fs log_must zfs create -p $TESTPOOL/$TESTFS2/$fs @@ -87,6 +76,12 @@ function create_filesystems done } +function sub_fail +{ + log_note $$: "$@" + exit 1 +} + # # Main test routine. # @@ -99,32 +94,45 @@ function test_share # filesystem typeset mntp=$(get_prop mountpoint $filesystem) not_shared $mntp || \ - log_fail "File system $filesystem is already shared." + sub_fail "File system $filesystem is already shared." zfs set sharenfs=on $filesystem || \ - log_fail "zfs set sharenfs=on $filesystem failed." + sub_fail "zfs set sharenfs=on $filesystem failed." is_shared $mntp || \ - log_fail "File system $filesystem is not shared (set sharenfs)." + sub_fail "File system $filesystem is not shared (set sharenfs)." # # Verify 'zfs share' works as well. # zfs unshare $filesystem || \ - log_fail "zfs unshare $filesystem failed." + sub_fail "zfs unshare $filesystem failed." is_shared $mntp && \ - log_fail "File system $filesystem is still shared." + sub_fail "File system $filesystem is still shared." + zfs share $filesystem || \ - log_fail "zfs share $filesystem failed." + sub_fail "zfs share $filesystem failed." is_shared $mntp || \ - log_fail "file system $filesystem is not shared (zfs share)." + sub_fail "file system $filesystem is not shared (zfs share)." + #log_note "Sharing a shared file system fails." zfs share $filesystem && \ - log_fail "zfs share $filesystem did not fail" + sub_fail "zfs share $filesystem did not fail" + return 0 } +function unshare_fs_nolog +{ + typeset fs=$1 + + if is_shared $fs || is_shared_smb $fs; then + zfs unshare $fs || + sub_fail "zfs unshare $fs: $?" + fi +} + # # Set the main process id so that we know to capture # failures from child processes and allow the parent process @@ -137,20 +145,16 @@ log_onexit cleanup create_filesystems child_pids=() -for fs in $(seq 0 50) +for fs in {0..50} do - test_share $TESTPOOL/$TESTFS1/$fs & - child_pids+=($!) - log_note "$TESTPOOL/$TESTFS1/$fs ==> $!" - test_share $TESTPOOL/$TESTFS2/$fs & - child_pids+=($!) - log_note "$TESTPOOL/$TESTFS2/$fs ==> $!" - test_share $TESTPOOL/$TESTFS3/$fs & - child_pids+=($!) - log_note "$TESTPOOL/$TESTFS3/$fs ==> $!" + for pfs in $TESTFS1 $TESTFS2 $TESTFS3 + do + test_share $TESTPOOL/$pfs/$fs & + child_pids+=($!) + log_note "$TESTPOOL/$pfs/$fs ==> $!" + done done -wait_for_children "${child_pids[@]}" || - log_fail "multithreaded share test failed" +log_must wait_for_children "${child_pids[@]}" log_note "Verify 'zfs share -a' succeeds." @@ -158,17 +162,16 @@ log_note "Verify 'zfs share -a' succeeds." # Unshare each of the file systems. # child_pids=() -for fs in $(seq 0 50) +for fs in {0..50} do - unshare_fs $TESTPOOL/$TESTFS1/$fs & - child_pids+=($!) - unshare_fs $TESTPOOL/$TESTFS2/$fs & - child_pids+=($!) - unshare_fs $TESTPOOL/$TESTFS3/$fs & - child_pids+=($!) + for pfs in $TESTFS1 $TESTFS2 $TESTFS3 + do + unshare_fs_nolog $TESTPOOL/$pfs/$fs & + child_pids+=($!) + log_note "$TESTPOOL/$pfs/$fs (unshare) ==> $!" + done done -wait_for_children "${child_pids[@]}" || - log_fail "multithreaded unshare failed" +log_must wait_for_children "${child_pids[@]}" # # Try a zfs share -a and verify all file systems are shared. @@ -181,21 +184,13 @@ log_must zfs share -a # unset __ZFS_POOL_EXCLUDE -for fs in $(seq 0 50) +for fs in {0..50} do - is_shared $TESTPOOL/$TESTFS1/$fs || \ - log_fail "File system $TESTPOOL/$TESTFS1/$fs is not shared" - is_shared $TESTPOOL/$TESTFS2/$fs || \ - log_fail "File system $TESTPOOL/$TESTFS2/$fs is not shared" - is_shared $TESTPOOL/$TESTFS3/$fs || \ - log_fail "File system $TESTPOOL/$TESTFS3/$fs is not shared" - - is_exported $TESTPOOL/$TESTFS1/$fs || \ - log_fail "File system $TESTPOOL/$TESTFS1/$fs is not exported" - is_exported $TESTPOOL/$TESTFS2/$fs || \ - log_fail "File system $TESTPOOL/$TESTFS2/$fs is not exported" - is_exported $TESTPOOL/$TESTFS3/$fs || \ - log_fail "File system $TESTPOOL/$TESTFS3/$fs is not exported" + for pfs in $TESTFS1 $TESTFS2 $TESTFS3 + do + log_must is_shared $TESTPOOL/$pfs/$fs + log_must is_exported $TESTPOOL/$pfs/$fs + done done -log_pass "'zfs share [ -a ] ' succeeds as root." +log_pass "'zfs share [-a] ' succeeds as root." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/Makefile.am deleted file mode 100644 index bc5b801259c8..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_snapshot -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_snapshot_001_neg.ksh \ - zfs_snapshot_002_neg.ksh \ - zfs_snapshot_003_neg.ksh \ - zfs_snapshot_004_neg.ksh \ - zfs_snapshot_005_neg.ksh \ - zfs_snapshot_006_pos.ksh \ - zfs_snapshot_007_neg.ksh \ - zfs_snapshot_008_neg.ksh \ - zfs_snapshot_009_pos.ksh - -dist_pkgdata_DATA = \ - zfs_snapshot.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_004_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_004_neg.ksh index 16926a48ddc4..62bf71390c70 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_004_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_004_neg.ksh @@ -59,18 +59,18 @@ while ((ret == 0)); do ret=$? if ((ret != 0)); then - len=$(echo $basefs| wc -c) + len=${#basefs} log_note "The deeply-nested filesystem len: $len" # - # Make sure there are at lease 2 characters left + # Make sure there are at least 2 characters left # for snapshot name space, otherwise snapshot name # is incorrect # if ((len >= 255)); then datasetexists $basefs && destroy_dataset $basefs -r basefs=${basefs%/*} - len=$(echo $basefs| wc -c) + len=${#basefs} fi break fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_005_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_005_neg.ksh index c133403ac84a..be5bbc8346d6 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_005_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_005_neg.ksh @@ -60,7 +60,7 @@ while ((ret == 0)); do ret=$? if ((ret != 0)); then - len=$(echo $basefs | wc -c) + len=$(( ${#basefs} + 1 )) # +1 for NUL log_note "The deeply-nested filesystem len: $len" # @@ -71,7 +71,7 @@ while ((ret == 0)); do if ((len >= 255)); then datasetexists $basefs && destroy_dataset $basefs -r basefs=${basefs%/*} - len=$(echo $basefs| wc -c) + len=$(( ${#basefs} + 1 )) fi break fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_007_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_007_neg.ksh index 9499dca21e78..40b936dee977 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_007_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_007_neg.ksh @@ -72,18 +72,13 @@ typeset ro_props="type used available avail creation referenced refer compressra mounted origin" typeset snap_ro_props="volsize recordsize recsize quota reservation reserv mountpoint \ sharenfs checksum compression compress atime devices exec readonly rdonly \ - setuid" + setuid version" if is_freebsd; then snap_ro_props+=" jailed" else snap_ro_props+=" zoned" fi -zfs upgrade -v > /dev/null 2>&1 -if [[ $? -eq 0 ]]; then - snap_ro_props="$snap_ro_props version" -fi - for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do typeset fssnap=$fs@snap diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh index 4ff539a377d4..a81e82ddf546 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh @@ -84,11 +84,11 @@ while (( i < ${#invalid_args[*]} )); do ((i = i + 1)) done log_note "verify multiple snapshot transaction group" -txg_group=$(zdb -Pd $TESTPOOL | grep snap | awk '{print $7}') +txg_group=$(zdb -Pd $TESTPOOL | awk '/snap/ {print $7}') for i in 1 2 3; do - txg_tag=$(echo "$txg_group" | nawk -v j=$i 'FNR == j {print}') + txg_tag=$(echo "$txg_group" | awk -v j=$i 'FNR == j {print}') [[ $txg_tag != $(echo "$txg_group" | \ - nawk -v j=$i 'FNR == j {print}') ]] \ + awk -v j=$i 'FNR == j {print}') ]] \ && log_fail "snapshots belong to different transaction groups" done log_note "verify snapshot contents" @@ -120,7 +120,7 @@ for x in {1..$ITERATIONS}; do for y in {1..$NUM_SNAPS}; do log_must zfs snapshot $TESTPOOL/$MYTEST@$y done; - n=$(ls -1 /$TESTPOOL/$MYTEST/.zfs/snapshot | wc -l) + n=$(ls /$TESTPOOL/$MYTEST/.zfs/snapshot | wc -l) verify_eq $n $NUM_SNAPS "count" zfs destroy -r $TESTPOOL/$MYTEST; done; diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/Makefile.am deleted file mode 100644 index 6a83edf2a443..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_sysfs -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfeature_set_unsupported.ksh \ - zfs_get_unsupported.ksh \ - zfs_set_unsupported.ksh \ - zfs_sysfs_live.ksh \ - zpool_get_unsupported.ksh \ - zpool_set_unsupported.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/Makefile.am deleted file mode 100644 index 74cdf5c2b558..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_unload-key -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_unload-key.ksh \ - zfs_unload-key_all.ksh \ - zfs_unload-key_recursive.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh index 55da68262019..6d3d37bd618a 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh @@ -54,7 +54,8 @@ log_must zfs create $TESTPOOL/$TESTFS1/child log_must zfs create -V 64M -o encryption=on -o keyformat=passphrase \ -o keylocation=file:///$TESTPOOL/pkey $TESTPOOL/zvol -typeset DISK2="$(echo $DISKS | awk '{ print $2}')" +typeset DISK2 _ +read -r _ DISK2 _ <<<"$DISKS" log_must zpool create -O encryption=on -O keyformat=passphrase \ -O keylocation=file:///$TESTPOOL/pkey $TESTPOOL1 $DISK2 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/Makefile.am deleted file mode 100644 index 6507b094df47..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_unmount -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_unmount_001_pos.ksh \ - zfs_unmount_002_pos.ksh \ - zfs_unmount_003_pos.ksh \ - zfs_unmount_004_pos.ksh \ - zfs_unmount_005_pos.ksh \ - zfs_unmount_006_pos.ksh \ - zfs_unmount_007_neg.ksh \ - zfs_unmount_008_neg.ksh \ - zfs_unmount_009_pos.ksh \ - zfs_unmount_all_001_pos.ksh \ - zfs_unmount_nested.ksh \ - zfs_unmount_unload_keys.ksh - -dist_pkgdata_DATA = \ - zfs_unmount.cfg \ - zfs_unmount.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount.kshlib index 525dfd162957..3fc5509a612e 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount.kshlib @@ -53,7 +53,7 @@ function do_unmount #cmd #opt #mnt #expect zfs $cmd $opt $mnt ret=$? - if (( ret != expect)); then + if (( ret != expect )); then log_fail "'zfs $cmd $opt $mnt' " \ "unexpected return code of $ret." fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_006_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_006_pos.ksh index 8b70e8868a02..0afb9b6f8501 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_006_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_006_pos.ksh @@ -56,7 +56,6 @@ log_onexit cleanup # Call cleanup to make sure the file system are mounted. cleanup mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS) -(($? != 0)) && log_fail "get_prop mountpoint $TESTPOOL/$TESTFS" typeset -i i=0 while (( i < 10000 )); do diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/Makefile.am deleted file mode 100644 index 0845f1e2f9f6..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_unshare -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_unshare_001_pos.ksh \ - zfs_unshare_002_pos.ksh \ - zfs_unshare_003_pos.ksh \ - zfs_unshare_004_neg.ksh \ - zfs_unshare_005_neg.ksh \ - zfs_unshare_006_pos.ksh \ - zfs_unshare_007_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/setup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/setup.ksh deleted file mode 100755 index 29f38e802c57..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/setup.ksh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -. $STF_SUITE/include/libtest.shlib - -share -s -if [ $? -ne 0 ]; then - log_unsupported "The NFS utilities are not installed" -fi - -# Make sure NFS server is running before testing. -setup_nfs_server - -DISK=${DISKS%% *} -default_container_volume_setup $DISK diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/setup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/setup.ksh new file mode 120000 index 000000000000..b5208415d45c --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/setup.ksh @@ -0,0 +1 @@ +../zfs_share/setup.ksh \ No newline at end of file diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_001_pos.ksh index ac16fe97b928..3955f0ee3590 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_001_pos.ksh @@ -149,7 +149,7 @@ while (( i < ${#mntp_fs[*]} )); do else log_must zfs set sharenfs=on ${mntp_fs[((i+1))]} is_shared ${mntp_fs[i]} || \ - log_fail "'zfs set sharenfs=on' fails to share filesystem." + log_fail "'zfs set sharenfs=on' fails to share filesystem: ${mntp_fs[i]} not shared." fi ((i = i + 2)) @@ -166,7 +166,7 @@ log_must zfs unshare -a i=0 while (( i < ${#mntp_fs[*]} )); do not_shared ${mntp_fs[i]} || \ - log_fail "'zfs unshare -a' fails to unshare all shared zfs filesystems." + log_fail "'zfs unshare -a' fails to unshare all shared zfs filesystems: ${mntp_fs[i]} still shared." ((i = i + 2)) done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh index 1ded1b42c7ec..2fb8ae7814ea 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh @@ -91,7 +91,7 @@ function test_legacy_unshare # log_fail "'zfs set sharenfs=off' fails to make ZFS " \ "filesystem $filesystem unshared." - log_must eval "share_nfs $mntp" + log_must share_nfs $mntp is_shared $mntp || \ log_fail "'share' command fails to share ZFS file system." # @@ -179,4 +179,3 @@ while (( i < ${#mntp_fs[*]} )); do done log_pass "'zfs unshare [-a]' succeeds to be aware of legacy share." - diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_006_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_006_pos.ksh index b4318020cc7f..b6e5178cf2bb 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_006_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_006_pos.ksh @@ -41,9 +41,7 @@ verify_runnable "global" -if is_linux; then - log_unsupported "some distros come with Samba "user shares" disabled" -fi +[ -d "/var/lib/samba/usershares" ] || log_unsupported "Samba usershares disabled" function cleanup { @@ -51,9 +49,10 @@ function cleanup log_must zfs destroy -f $TESTPOOL/$TESTFS/shared1 log_must zfs destroy -f $TESTPOOL/$TESTFS/shared2 log_must zfs destroy -f $TESTPOOL/$TESTFS/shared3 + log_must rm -f /var/lib/samba/usershares/testpool_testfs_shared{2,3} } -log_assert "Verify 'zfs unshare [nfs|smb] -a' only works on the specified "\ +log_assert "Verify 'zfs unshare [nfs|smb] -a' only works on the specified" \ "protocol." log_onexit cleanup @@ -74,19 +73,19 @@ log_must zfs share -a log_must zfs unshare nfs -a # 3. Verify that only nfs filesystems are unshared. -log_must eval "not_shared $TESTPOOL/$TESTFS/shared1" -log_must eval "not_shared $TESTPOOL/$TESTFS/shared2" -log_must eval "is_shared_smb $TESTPOOL/$TESTFS/shared2" -log_must eval "is_shared_smb $TESTPOOL/$TESTFS/shared3" +log_must not_shared $TESTPOOL/$TESTFS/shared1 +log_must not_shared $TESTPOOL/$TESTFS/shared2 +log_must is_shared_smb $TESTPOOL/$TESTFS/shared2 +log_must is_shared_smb $TESTPOOL/$TESTFS/shared3 # 4. Share all filesystems again. log_must zfs share -a # 5. Invoke 'zfs unshare smb -a' and verify only smb filesystems are unshared. log_must zfs unshare smb -a -log_must eval "is_shared $TESTPOOL/$TESTFS/shared1" -log_must eval "is_shared $TESTPOOL/$TESTFS/shared2" -log_must eval "not_shared_smb $TESTPOOL/$TESTFS/shared2" -log_must eval "not_shared_smb $TESTPOOL/$TESTFS/shared3" +log_must is_shared $TESTPOOL/$TESTFS/shared1 +log_must is_shared $TESTPOOL/$TESTFS/shared2 +log_must not_shared_smb $TESTPOOL/$TESTFS/shared2 +log_must not_shared_smb $TESTPOOL/$TESTFS/shared3 log_pass "'zfs unshare [nfs|smb] -a' only works on the specified protocol." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_008_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_008_pos.ksh new file mode 100755 index 000000000000..21d5ac79bbdc --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_008_pos.ksh @@ -0,0 +1,58 @@ +#!/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 +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Verify that datasets mounted at directories with whitespace are properly escaped +# both going in (for mountd consumption) and going out (for removing from export list) +# +# STRATEGY: +# 1. Create and share a dataset with spaces, tabs, and newlines +# 2. Verify it's shared +# 3. Unshare it +# 4. Verify it's not shared +# + +shares_can_have_whitespace || log_unsupported "Platform doesn't permit whitespace in NFS shares" +basename='a + b + c d' +escname='a\040+\040b\012\040c\011d' + +verify_runnable "global" + +function cleanup +{ + datasetexists "$TESTPOOL/$TESTFS/shared1" && \ + destroy_dataset "$TESTPOOL/$TESTFS/shared1" -f +} + +log_assert "Datasets with spaces are properly shared and unshared." +log_onexit cleanup + +log_must zfs create -o sharenfs=on -o mountpoint="$TESTDIR/$basename" "$TESTPOOL/$TESTFS/shared1" +log_must is_shared "$TESTDIR/$escname" +log_must zfs unshare "$TESTPOOL/$TESTFS/shared1" +log_mustnot is_shared "$TESTDIR/$escname" + +log_pass "Datasets with spaces are properly shared and unshared." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/Makefile.am deleted file mode 100644 index 7a71bae4bb42..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_upgrade -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_upgrade_001_pos.ksh \ - zfs_upgrade_002_pos.ksh \ - zfs_upgrade_003_pos.ksh \ - zfs_upgrade_004_pos.ksh \ - zfs_upgrade_005_pos.ksh \ - zfs_upgrade_006_neg.ksh \ - zfs_upgrade_007_neg.ksh - -dist_pkgdata_DATA = \ - zfs_upgrade.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh index ab76461638b9..db8b96f50568 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh @@ -71,8 +71,8 @@ typeset expect_str2="All filesystems are formatted with the current version" typeset expect_str3="The following filesystems are out of date, and can be upgraded" typeset -i COUNT OLDCOUNT -zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $oldoutput -OLDCOUNT=$( wc -l $oldoutput | awk '{print $1}' ) +zfs upgrade | awk '$1 ~ "^[0-9]+$" {print $2}'> $oldoutput +OLDCOUNT=$(wc -l < $oldoutput) old_datasets="" for version in $ZFS_ALL_VERSIONS ; do @@ -98,9 +98,9 @@ log_must eval 'zfs upgrade > $output 2>&1' # we also check that the usage message contains at least a description # of the current ZFS version. -log_must eval 'grep "${expect_str1} $ZFS_VERSION" $output > /dev/null 2>&1' -zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $output -COUNT=$( wc -l $output | awk '{print $1}' ) +log_must grep -q "${expect_str1} $ZFS_VERSION" $output +zfs upgrade | awk '$1 ~ "^[0-9]+$" {print $2}'> $output +COUNT=$(wc -l < $output) typeset -i i=0 for fs in ${old_datasets}; do @@ -118,14 +118,14 @@ for fs in $old_datasets ; do done log_must eval 'zfs upgrade > $output 2>&1' -log_must eval 'grep "${expect_str1} $ZFS_VERSION" $output > /dev/null 2>&1' +log_must grep -q "${expect_str1} $ZFS_VERSION" $output if (( OLDCOUNT == 0 )); then - log_must eval 'grep "${expect_str2}" $output > /dev/null 2>&1' + log_must grep -q "${expect_str2}" $output else - log_must eval 'grep "${expect_str3}" $output > /dev/null 2>&1' + log_must grep -q "${expect_str3}" $output fi -zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $output -COUNT=$( wc -l $output | awk '{print $1}' ) +zfs upgrade | awk '$1 ~ "^[0-9]+$" {print $2}'> $output +COUNT=$(wc -l < $output) if (( COUNT != OLDCOUNT )); then cat $output diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_002_pos.ksh index ba6e7c483edd..994ee2b3475a 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_002_pos.ksh @@ -60,8 +60,8 @@ typeset expect_str2="Enhanced directory entries" log_must eval 'zfs upgrade -v > /dev/null 2>&1' -zfs upgrade -v | nawk '$1 ~ "^[0-9]+$" {print $0}'> $output -log_must eval 'grep "${expect_str1}" $output > /dev/null 2>&1' -log_must eval 'grep "${expect_str2}" $output > /dev/null 2>&1' +zfs upgrade -v | awk '$1 ~ "^[0-9]+$" {print $0}'> $output +log_must grep -q "${expect_str1}" $output +log_must grep -q "${expect_str2}" $output log_pass "Executing 'zfs upgrade -v' command succeeds." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_wait/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_wait/Makefile.am deleted file mode 100644 index 5d385d915720..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zfs_wait/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_wait -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_wait_deleteq.ksh \ - zfs_wait_getsubopt.ksh - -dist_pkgdata_DATA = \ - zfs_wait.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zhack/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zhack/Makefile.am deleted file mode 100644 index 931dacde6beb..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zhack/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zhack -dist_pkgdata_SCRIPTS = \ - zhack_label_checksum.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool/Makefile.am deleted file mode 100644 index 327f23621158..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_001_neg.ksh \ - zpool_002_pos.ksh \ - zpool_003_pos.ksh \ - zpool_colors.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_002_pos.ksh index e4ffa2a6c028..ef88925dc92f 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_002_pos.ksh @@ -47,33 +47,27 @@ function cleanup { unset ZFS_ABORT - if is_freebsd && [ -n "$old_corefile" ]; then - sysctl kern.corefile=$old_corefile - fi + log_must pop_coredump_pattern "$coresavepath" + log_must rm -rf $corepath $vdev1 $vdev2 $vdev3 # Clean up the pool created if we failed to abort. poolexists $pool && destroy_pool $pool - - rm -rf $corepath $vdev1 $vdev2 $vdev3 } log_assert "With ZFS_ABORT set, all zpool commands can abort and generate a core file." log_onexit cleanup corepath=$TESTDIR/core -corefile=$corepath/zpool.core -if [[ -d $corepath ]]; then - log_must rm -rf $corepath -fi +corefile=$corepath/core.zpool +coresavepath=$corepath/save +log_must rm -rf $corepath log_must mkdir $corepath pool=pool.$$ vdev1=$TESTDIR/file1 vdev2=$TESTDIR/file2 vdev3=$TESTDIR/file3 -for vdev in $vdev1 $vdev2 $vdev3; do - log_must mkfile $MINVDEVSIZE $vdev -done +log_must mkfile $MINVDEVSIZE $vdev1 $vdev2 $vdev3 set -A cmds "create $pool mirror $vdev1 $vdev2" "list $pool" "iostat $pool" \ "status $pool" "upgrade $pool" "get delegation $pool" "set delegation=off $pool" \ @@ -86,25 +80,12 @@ set -A badparams "" "create" "destroy" "add" "remove" "list *" "iostat" "status" "online" "offline" "clear" "attach" "detach" "replace" "scrub" \ "import" "export" "upgrade" "history -?" "get" "set" -if is_linux; then - echo $corefile >/proc/sys/kernel/core_pattern - echo 0 >/proc/sys/kernel/core_uses_pid -elif is_freebsd; then - old_corefile=$(sysctl -n kern.corefile) - log_must sysctl kern.corefile=$corefile -fi -ulimit -c unlimited - -export ZFS_ABORT=yes +log_must eval "push_coredump_pattern \"$corepath\" > \"$coresavepath\"" +log_must export ZFS_ABORT=yes for subcmd in "${cmds[@]}" "${badparams[@]}"; do - zpool $subcmd >/dev/null 2>&1 - if [[ ! -e $corefile ]]; then - log_fail "zpool $subcmd cannot generate core file with ZFS_ABORT set." - fi - rm -f $corefile + log_mustnot eval "zpool $subcmd" + log_must rm "$corefile" done -unset ZFS_ABORT - log_pass "With ZFS_ABORT set, zpool command can abort and generate core file as expected." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_003_pos.ksh index 6f15c09a5229..00f24bdff020 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_003_pos.ksh @@ -46,15 +46,12 @@ function cleanup { unset ZFS_ABORT - if is_freebsd && [ -n "$old_corefile" ]; then - sysctl kern.corefile=$old_corefile - fi - - rm -rf $corepath + log_must pop_coredump_pattern "$coresavepath" + log_must rm -rf $corepath # Don't leave the pool frozen. - destroy_pool $TESTPOOL - default_mirror_setup $DISKS + log_must destroy_pool $TESTPOOL + log_must default_mirror_setup $DISKS } verify_runnable "both" @@ -63,15 +60,14 @@ log_assert "Debugging features of zpool should succeed." log_onexit cleanup corepath=$TESTDIR/core -corefile=$corepath/zpool.core -if [[ -d $corepath ]]; then - log_must rm -rf $corepath -fi +corefile=$corepath/core.zpool +coresavepath=$corepath/save +log_must rm -rf $corepath log_must mkdir $corepath log_must eval "zpool -? >/dev/null 2>&1" -if is_global_zone ; then +if is_global_zone; then log_must zpool freeze $TESTPOOL else log_mustnot zpool freeze $TESTPOOL @@ -80,21 +76,10 @@ fi log_mustnot zpool freeze fakepool -if is_linux; then - echo $corefile >/proc/sys/kernel/core_pattern - echo 0 >/proc/sys/kernel/core_uses_pid -elif is_freebsd; then - old_corefile=$(sysctl -n kern.corefile) - log_must sysctl kern.corefile=$corefile -fi -ulimit -c unlimited +log_must eval "push_coredump_pattern \"$corepath\" > \"$coresavepath\"" +log_must export ZFS_ABORT=yes -export ZFS_ABORT=yes - -zpool >/dev/null 2>&1 - -unset ZFS_ABORT - -[[ -f $corefile ]] || log_fail "zpool did not dump core by request." +log_mustnot eval "zpool >/dev/null 2>&1" +log_must [ -f "$corefile" ] log_pass "Debugging features of zpool succeed." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_colors.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_colors.ksh index 8c7f40ba9c0b..b131bc708dbc 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_colors.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_colors.ksh @@ -39,8 +39,7 @@ log_onexit cleanup log_assert "Test colorized zpool status output" -DISK2="$(echo $DISKS | cut -d' ' -f2)" -DISK3="$(echo $DISKS | cut -d' ' -f3)" +read -r _ DISK2 DISK3 _ <<<"$DISKS" log_must dd if=/dev/urandom of=/$TESTDIR/testfile bs=10M count=1 @@ -62,16 +61,15 @@ log_note "$(faketty TERM=xterm-256color ZFS_COLOR=1 zpool status)" # Replace the escape codes with "ESC" so they're easier to grep out="$(faketty TERM=xterm-256color ZFS_COLOR=1 zpool status | \ - grep -E 'pool:|DEGRADED' | \ - sed -r 's/[[:space:]]+//g;'$(echo -e 's/\033/ESC/g'))" + sed -E '/pool:|DEGRADED/!d;s/[[:space:]]+//g;'$(printf 's/\033/ESC/g'))" log_note "$(echo $out)" log_note "Look for 'pool:' in bold" -log_must eval "echo \"$out\" | grep -q 'ESC\[1mpool:ESC\[0m' " +log_must grep -q 'ESC\[1mpool:ESC\[0m' <<<"$out" log_note "Look for 'DEGRADED' in yellow" -log_must eval "echo \"$out\" | grep -q 'ESC\[0;33mDEGRADEDESC\[0m'" +log_must grep -q 'ESC\[0;33mDEGRADEDESC\[0m' <<<"$out" # # The escape code for 'FAULTED' is a little more tricky. The line starts like @@ -83,9 +81,11 @@ log_must eval "echo \"$out\" | grep -q 'ESC\[0;33mDEGRADEDESC\[0m'" # we can easily remove the vdev field to get what we want. # out="$(faketty TERM=xterm-256color ZFS_COLOR=1 zpool status \ - | awk '/FAULTED/{print $1$3$4}' | sed -r $(echo -e 's/\033/ESC/g'))" + | awk '/FAULTED/ {print $1$3$4}' | sed -E $(printf 's/\033/ESC/g'))" + +log_note "$(echo $out)" log_note "Look for 'FAULTED' in red" -log_must eval "echo \"$out\" | grep -q 'ESC\[0;31mFAULTEDESC\[0m'" +log_must grep -q 'ESC\[0;31mFAULTEDESC\[0m' <<<"$out" log_pass "zpool status displayed colors" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/Makefile.am deleted file mode 100644 index 8d54d13f7207..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_add -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_add_001_pos.ksh \ - zpool_add_002_pos.ksh \ - zpool_add_003_pos.ksh \ - zpool_add_004_pos.ksh \ - zpool_add_005_pos.ksh \ - zpool_add_006_pos.ksh \ - zpool_add_007_neg.ksh \ - zpool_add_008_neg.ksh \ - zpool_add_009_neg.ksh \ - zpool_add_010_pos.ksh \ - add-o_ashift.ksh \ - add_prop_ashift.ksh \ - add_nested_replacing_spare.ksh \ - zpool_add_dryrun_output.ksh - -dist_pkgdata_DATA = \ - zpool_add.cfg \ - zpool_add.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh index 89cc4b0d3082..80a2213d9aa8 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh @@ -64,12 +64,8 @@ for ashift in ${ashifts[@]} do log_must zpool create $TESTPOOL $disk1 log_must zpool add -o ashift=$ashift $TESTPOOL $disk2 - verify_ashift $disk2 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Device was added without setting ashift value to "\ - "$ashift" - fi + log_must verify_ashift $disk2 $ashift + # clean things for the next run log_must zpool destroy $TESTPOOL log_must zpool labelclear $disk1 @@ -81,12 +77,8 @@ do log_must zpool create $TESTPOOL $disk1 log_must set_tunable64 VDEV_FILE_PHYSICAL_ASHIFT $ashift log_must zpool add $TESTPOOL $disk2 - verify_ashift $disk2 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Device was added without setting ashift value to "\ - "$ashift" - fi + log_must verify_ashift $disk2 $ashift + # clean things for the next run log_must set_tunable64 VDEV_FILE_PHYSICAL_ASHIFT $orig_ashift log_must zpool destroy $TESTPOOL diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh index 61f5f6d1ceed..677d0762eecb 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh @@ -90,10 +90,8 @@ do log_must wait_vdev_state $TESTPOOL $REPLACE_DEV "ONLINE" 60 zpool status | awk -v poolname="$TESTPOOL" -v type="$type" 'BEGIN {s=""} $1 ~ poolname {c=4}; (c && c--) { s=s$1":" } - END { if (s != poolname":"type"-0:spare-0:replacing-0:") exit 1; }' - if [[ $? -ne 0 ]]; then + END { if (s != poolname":"type"-0:spare-0:replacing-0:") exit 1; }' || log_fail "Pool does not contain nested replacing/spare vdevs" - fi # 3. Verify 'zpool add' is able to add new devices log_must zpool add $TESTPOOL spare $SPARE_DEV2 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_prop_ashift.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_prop_ashift.ksh index 4637fe0d84a3..df04ecc5b89e 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_prop_ashift.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_prop_ashift.ksh @@ -70,12 +70,8 @@ for ashift in ${ashifts[@]} do log_must zpool create -o ashift=$ashift $TESTPOOL $disk1 log_must zpool add $TESTPOOL $disk2 - verify_ashift $disk2 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Device was added without setting ashift value to "\ - "$ashift" - fi + log_must verify_ashift $disk2 $ashift + # clean things for the next run log_must zpool destroy $TESTPOOL log_must zpool labelclear $disk1 @@ -88,12 +84,8 @@ do do log_must zpool create -o ashift=$ashift $TESTPOOL $disk1 log_must zpool add -o ashift=$cmdval $TESTPOOL $disk2 - verify_ashift $disk2 $cmdval - if [[ $? -ne 0 ]] - then - log_fail "Device was added without setting ashift " \ - "value to $cmdval" - fi + log_must verify_ashift $disk2 $cmdval + # clean things for the next run log_must zpool destroy $TESTPOOL log_must zpool labelclear $disk1 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib index c64b4a35aa03..e10357340b40 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib @@ -50,9 +50,8 @@ function find_vfstab_dev # function find_mnttab_dev { - typeset mnttabdev + typeset mnttabdev _ typeset mnttabdevs="" - typeset line if is_freebsd; then # FreeBSD doesn't have a mnttab file. @@ -61,21 +60,16 @@ function find_mnttab_dev return 0 elif is_linux; then typeset mnttab="/etc/mtab" - typeset tmpfile="$TEST_BASE_DIR/mtab.tmp" else typeset mnttab="/etc/mnttab" - typeset tmpfile="$TEST_BASE_DIR/mnttab.tmp" fi - cat $mnttab | grep "^${DEV_DSKDIR}" >$tmpfile - while read -r line + while read -r mnttabdev _ do - mnttabdev=`echo "$line" | awk '{print $1}'` mnttabdev=${mnttabdev%%:} mnttabdevs="$mnttabdev $mnttabdevs" - done <$tmpfile + done < <(grep "^${DEV_DSKDIR}" $mnttab) - rm -f $tmpfile echo $mnttabdevs } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_003_pos.ksh index a6b03ff3257f..3816444667cf 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_003_pos.ksh @@ -90,8 +90,8 @@ done log_must zpool add -f $TESTPOOL $config zpool status $TESTPOOL | awk 'NR == 1, /NAME/ { next } /^$/ {exit} {print $1}' > "$TMPFILE_PREFIX-vdevtree" -cat "$TMPFILE_PREFIX-dryrun" | awk 'NR == 1, /would/ {next} - /^$/ {next} {print $1}' > "$TMPFILE_PREFIX-vdevtree-n" -log_must eval "diff $TMPFILE_PREFIX-vdevtree-n $TMPFILE_PREFIX-vdevtree" +awk 'NR == 1, /would/ {next} + /^$/ {next} {print $1}' "$TMPFILE_PREFIX-dryrun" > "$TMPFILE_PREFIX-vdevtree-n" +log_must diff $TMPFILE_PREFIX-vdevtree-n $TMPFILE_PREFIX-vdevtree log_pass "'zpool add -n ...' executes successfully." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_attach/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_attach/Makefile.am deleted file mode 100644 index cc742f33d2aa..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_attach/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_attach -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_attach_001_neg.ksh \ - attach-o_ashift.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_attach/attach-o_ashift.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_attach/attach-o_ashift.ksh index 618c6992edb4..745f60507bed 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_attach/attach-o_ashift.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_attach/attach-o_ashift.ksh @@ -69,23 +69,14 @@ do for cmdval in ${ashifts[@]} do log_must zpool create -o ashift=$ashift $TESTPOOL1 $disk1 - verify_ashift $disk1 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Pool was created without setting ashift " \ - "value to $ashift" - fi + log_must verify_ashift $disk1 $ashift + # ashift_of(attached_disk) <= ashift_of(existing_vdev) if [[ $cmdval -le $ashift ]] then log_must zpool attach -o ashift=$cmdval $TESTPOOL1 \ $disk1 $disk2 - verify_ashift $disk2 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Device was attached without " \ - "setting ashift value to $ashift" - fi + log_must verify_ashift $disk2 $ashift else log_mustnot zpool attach -o ashift=$cmdval $TESTPOOL1 \ $disk1 $disk2 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_clear/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_clear/Makefile.am deleted file mode 100644 index 6986d38efc9d..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_clear/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_clear -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_clear_001_pos.ksh \ - zpool_clear_002_neg.ksh \ - zpool_clear_003_neg.ksh \ - zpool_clear_readonly.ksh - -dist_pkgdata_DATA = \ - zpool_clear.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_001_pos.ksh index 1188ca10d14d..f1f926831baa 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_001_pos.ksh @@ -50,9 +50,7 @@ function cleanup poolexists $TESTPOOL1 && \ log_must zpool destroy -f $TESTPOOL1 - for file in `ls $TEST_BASE_DIR/file.*`; do - log_must rm -f $file - done + log_must rm -f $fbase.{0..2} } @@ -60,14 +58,8 @@ log_assert "Verify 'zpool clear' can clear errors of a storage pool." log_onexit cleanup #make raw files to create various configuration pools -typeset -i i=0 -while (( i < 3 )); do - log_must truncate -s $FILESIZE $TEST_BASE_DIR/file.$i - - (( i = i + 1 )) -done - fbase=$TEST_BASE_DIR/file +log_must truncate -s $FILESIZE $fbase.{0..2} set -A poolconf "mirror $fbase.0 $fbase.1 $fbase.2" \ "raidz1 $fbase.0 $fbase.1 $fbase.2" \ "raidz2 $fbase.0 $fbase.1 $fbase.2" @@ -75,59 +67,24 @@ set -A poolconf "mirror $fbase.0 $fbase.1 $fbase.2" \ function check_err # [] { typeset pool=$1 - shift - if (( $# > 0 )); then - typeset checkvdev=$1 - else - typeset checkvdev="" - fi - typeset -i errnum=0 - typeset c_read=0 - typeset c_write=0 - typeset c_cksum=0 - typeset tmpfile=$TEST_BASE_DIR/file.$$ - typeset healthstr="pool '$pool' is healthy" - typeset output="`zpool status -x $pool`" + typeset checkvdev=$2 - [[ "$output" == "$healthstr" ]] && return $errnum + [ "$(zpool status -x $pool)" = "pool '$pool' is healthy" ] && return - zpool status -x $pool | grep -v "^$" | grep -v "pool:" \ - | grep -v "state:" | grep -v "config:" \ - | grep -v "errors:" > $tmpfile - typeset line - typeset -i fetchbegin=1 - while read line; do - if (( $fetchbegin != 0 )); then - echo $line | grep "NAME" >/dev/null 2>&1 - (( $? == 0 )) && (( fetchbegin = 0 )) - continue + typeset -i skipstart=1 + typeset vdev _ c_read c_write c_cksum rest + while read -r vdev _ c_read c_write c_cksum rest; do + if [ $skipstart -ne 0 ]; then + [ "$vdev" = "NAME" ] && skipstart=0 + continue fi - if [[ -n $checkvdev ]]; then - echo $line | grep $checkvdev >/dev/null 2>&1 - (( $? != 0 )) && continue - c_read=`echo $line | awk '{print $3}'` - c_write=`echo $line | awk '{print $4}'` - c_cksum=`echo $line | awk '{print $5}'` - if [ $c_read != 0 ] || [ $c_write != 0 ] || \ - [ $c_cksum != 0 ] - then - (( errnum = errnum + 1 )) - fi - break + if [ -n "$checkvdev" ]; then + [ "$vdev" = "$checkvdev" ] || continue fi - c_read=`echo $line | awk '{print $3}'` - c_write=`echo $line | awk '{print $4}'` - c_cksum=`echo $line | awk '{print $5}'` - if [ $c_read != 0 ] || [ $c_write != 0 ] || \ - [ $c_cksum != 0 ] - then - (( errnum = errnum + 1 )) - fi - done <$tmpfile - - return $errnum + [ $c_read$c_write$c_cksum = 000 ] || return + done < <(zpool status -x $pool | grep -ve "^$" -e "pool:" -e "state:" -e "config:" -e "errors:") } function do_testing # @@ -137,6 +94,7 @@ function do_testing # typeset type=$1 shift typeset vdev="$@" + (( i = $RANDOM % 3 )) log_must zpool create -f $TESTPOOL1 $vdev log_must zfs create $FS @@ -146,14 +104,13 @@ function do_testing # # avail=$(get_prop available $FS) fill_mb=$(((avail / 1024 / 1024) * 25 / 100)) - log_must dd if=/dev/urandom of=$file.$i bs=$BLOCKSZ count=$fill_mb + log_must dd if=/dev/urandom of=$file bs=$BLOCKSZ count=$fill_mb # # Make errors to the testing pool by overwrite the vdev device with # dd command. We do not want to have a full overwrite. That # may cause the system panic. So, we should skip the vdev label space. # - (( i = $RANDOM % 3 )) typeset -i wcount=0 typeset -i size case $FILESIZE in @@ -173,25 +130,19 @@ function do_testing # (( wcount = FILESIZE/1024 - 512 )) ;; esac - dd if=/dev/zero of=$fbase.$i seek=512 bs=1024 count=$wcount conv=notrunc \ - > /dev/null 2>&1 + dd if=/dev/zero of=$fbase.$i seek=512 bs=1024 count=$wcount conv=notrunc 2>/dev/null sync_all_pools log_must sync #ensure the vdev files are written out log_must zpool scrub -w $TESTPOOL1 - check_err $TESTPOOL1 && \ - log_fail "No error generated." - if [[ $type == "device" ]]; then - log_must zpool clear $TESTPOOL1 $fbase.$i - ! check_err $TESTPOOL1 $fbase.$i && \ - log_fail "'zpool clear' fails to clear error for $fbase.$i device." + log_mustnot check_err $TESTPOOL1 + typeset dev= + if [ "$type" = "device" ]; then + dev=$fbase.$i fi - if [[ $type == "pool" ]]; then - log_must zpool clear $TESTPOOL1 - ! check_err $TESTPOOL1 && \ - log_fail "'zpool clear' fails to clear error for pool $TESTPOOL1." - fi + log_must zpool clear $TESTPOOL1 $dev + log_must check_err $TESTPOOL1 $dev log_must zpool destroy $TESTPOOL1 } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile.am deleted file mode 100644 index 5ffaae5b152c..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile.am +++ /dev/null @@ -1,50 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_create -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_create_001_pos.ksh \ - zpool_create_002_pos.ksh \ - zpool_create_003_pos.ksh \ - zpool_create_004_pos.ksh \ - zpool_create_005_pos.ksh \ - zpool_create_006_pos.ksh \ - zpool_create_007_neg.ksh \ - zpool_create_008_pos.ksh \ - zpool_create_009_neg.ksh \ - zpool_create_010_neg.ksh \ - zpool_create_011_neg.ksh \ - zpool_create_012_neg.ksh \ - zpool_create_014_neg.ksh \ - zpool_create_015_neg.ksh \ - zpool_create_016_pos.ksh \ - zpool_create_017_neg.ksh \ - zpool_create_018_pos.ksh \ - zpool_create_019_pos.ksh \ - zpool_create_020_pos.ksh \ - zpool_create_021_pos.ksh \ - zpool_create_022_pos.ksh \ - zpool_create_023_neg.ksh \ - zpool_create_024_pos.ksh \ - zpool_create_encrypted.ksh \ - zpool_create_crypt_combos.ksh \ - zpool_create_draid_001_pos.ksh \ - zpool_create_draid_002_pos.ksh \ - zpool_create_draid_003_pos.ksh \ - zpool_create_draid_004_pos.ksh \ - zpool_create_features_001_pos.ksh \ - zpool_create_features_002_pos.ksh \ - zpool_create_features_003_pos.ksh \ - zpool_create_features_004_neg.ksh \ - zpool_create_features_005_pos.ksh \ - zpool_create_features_006_pos.ksh \ - zpool_create_features_007_pos.ksh \ - zpool_create_features_008_pos.ksh \ - zpool_create_features_009_pos.ksh \ - create-o_ashift.ksh \ - zpool_create_tempname.ksh \ - zpool_create_dryrun_output.ksh - -dist_pkgdata_DATA = \ - draidcfg.gz \ - zpool_create.cfg \ - zpool_create.shlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/create-o_ashift.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/create-o_ashift.ksh index 2c1f6e0ca659..426321db06d6 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/create-o_ashift.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/create-o_ashift.ksh @@ -59,8 +59,7 @@ function write_device_uberblocks # typeset device=$1 typeset pool=$2 - while [ "$(zdb -quuul $device | grep -c 'invalid')" -ne 0 ] - do + while zdb -quuul $device | grep -q 'invalid'; do sync_pool $pool true done } @@ -89,8 +88,6 @@ function verify_device_uberblocks # exit 1 } }' - - return $? } log_assert "zpool create -o ashift=' works with different ashift values" @@ -114,11 +111,8 @@ do "$ashift (current = $pprop)" fi write_device_uberblocks $disk $TESTPOOL - verify_device_uberblocks $disk ${ubcount[$i]} - if [[ $? -ne 0 ]] - then - log_fail "Pool was created with unexpected number of uberblocks" - fi + log_must verify_device_uberblocks $disk ${ubcount[$i]} + # clean things for the next run log_must zpool destroy $TESTPOOL log_must zpool labelclear $disk diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib index 005cf979befa..9954bc23fc9f 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib @@ -83,14 +83,9 @@ function find_vfstab_dev # function save_dump_dev { - typeset dumpdev="" - if is_illumos; then - typeset fnd="Dump device" - dumpdev=`dumpadm | grep "$fnd" | cut -f2 -d : | \ - awk '{print $1}'` + dumpadm | grep "Dump device" | cut -f2 -d : | awk '{print $1}' fi - echo $dumpdev } # diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh index e1d8cc474545..98f469108b15 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh @@ -90,8 +90,8 @@ do $file.1 $file.2 $file.3 $file.4 ! poolexists $TESTPOOL && \ log_fail "Creating pool with $opt fails." - mpt=`zfs mount | egrep "^$TESTPOOL[^/]" | awk '{print $2}'` - (( ${#mpt} == 0 )) && \ + mpt=`zfs mount | awk -v pat="^$TESTPOOL[^/]" '$0 ~ pat {print $2}'` + [ -z "$mpt" ] && \ log_fail "$TESTPOOL created with $opt is not mounted." mpt_val=$(get_prop "mountpoint" $TESTPOOL) [[ "$mpt" != "$mpt_val" ]] && \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_012_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_012_neg.ksh index 36888e497369..b9274c08b2ab 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_012_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_012_neg.ksh @@ -51,12 +51,11 @@ function cleanup } if is_freebsd; then - typeset swap_disks=$(swapinfo -l | grep "/dev" | awk '{print $1}') + typeset swap_disks=$(swapinfo -l | awk '/\/dev/ {print $1}') elif is_linux; then - typeset swap_disks=`swapon -s | grep "/dev" | awk '{print $1}'` + typeset swap_disks=$(swapon -s | awk '/\/dev/ {print $1}') else - typeset swap_disks=`swap -l | grep "c[0-9].*d[0-9].*s[0-9]" | \ - awk '{print $1}'` + typeset swap_disks=$(swap -l | awk '/c[0-9].*d[0-9].*s[0-9]/ {print $1}') fi log_assert "'zpool create' should fail with disk slice in swap." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh index 1fa205b0f253..b3dd2cefc76c 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh @@ -67,19 +67,17 @@ function cleanup fi } -typeset swap_disks=$(swap -l | grep -v "swapfile" | awk '{print $1}') -typeset dump_device=$(dumpadm | grep "Dump device" | awk '{print $3}') +typeset swap_disks=$(swap -l | awk '!/swapfile/ {print $1}') +typeset dump_device=$(dumpadm | awk '/Dump device/ {print $3}') log_assert "'zpool create' should success with no device in swap." log_onexit cleanup for sdisk in $swap_disks; do log_note "Executing: swap -d $sdisk" - swap -d $sdisk >/dev/null 2>&1; - if [[ $? != 0 ]]; then + swap -d $sdisk >/dev/null 2>&1 || log_untested "Unable to delete swap device $sdisk because of" \ "insufficient RAM" - fi done log_must zpool create $TESTPOOL $DISK0 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_020_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_020_pos.ksh index 104b5ec9868a..39097df2fb59 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_020_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_020_pos.ksh @@ -75,25 +75,16 @@ log_must zpool get all $TESTPOOL zpool get all $TESTPOOL > $values # check for the cachefile property, verifying that it's set to 'none' -grep "$TESTPOOL[ ]*cachefile[ ]*none" $values > /dev/null 2>&1 -if [ $? -ne 0 ] -then - log_fail "zpool property \'cachefile\' was not set to \'none\'." -fi +log_must grep -q "$TESTPOOL[ ]*cachefile[ ]*none" $values # check that the root = /mountpoint property is set correctly -grep "$TESTPOOL[ ]*altroot[ ]*/${TESTPOOL}.root" $values > /dev/null 2>&1 -if [ $? -ne 0 ] -then - log_fail "zpool property root was not found in pool output." -fi +log_must grep -q "$TESTPOOL[ ]*altroot[ ]*/${TESTPOOL}.root" $values rm $values # finally, check that the pool has no reference in /etc/zfs/zpool.cache if [[ -f /etc/zfs/zpool.cache ]] ; then - REF=$(strings /etc/zfs/zpool.cache | grep ${TESTPOOL}) - if [ ! -z "$REF" ] + if strings /etc/zfs/zpool.cache | grep -q ${TESTPOOL} then strings /etc/zfs/zpool.cache log_fail "/etc/zfs/zpool.cache appears to have a reference to $TESTPOOL" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_021_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_021_pos.ksh index 655f887b60ad..264c75279d17 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_021_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_021_pos.ksh @@ -49,12 +49,13 @@ verify_runnable "global" function cleanup { datasetexists $TESTPOOL && destroy_pool $TESTPOOL + log_must rm -df "/tmp/mnt$$" } log_onexit cleanup -log_assert "'zpool create -O property=value pool' can successfully create a pool \ - with correct filesystem property set." +log_assert "'zpool create -O property=value pool' can successfully create a pool" \ + "with correct filesystem property set." set -A RW_FS_PROP "quota=536870912" \ "reservation=536870912" \ @@ -80,14 +81,11 @@ fi typeset -i i=0 while (( $i < ${#RW_FS_PROP[*]} )); do log_must zpool create -O ${RW_FS_PROP[$i]} -f $TESTPOOL $DISKS - datasetexists $TESTPOOL || \ - log_fail "zpool create $TESTPOOL fail." - propertycheck $TESTPOOL ${RW_FS_PROP[i]} || \ - log_fail "${RW_FS_PROP[i]} is failed to set." + log_must datasetexists $TESTPOOL + log_must propertycheck $TESTPOOL ${RW_FS_PROP[i]} log_must zpool destroy $TESTPOOL (( i = i + 1 )) done -log_pass "'zpool create -O property=value pool' can successfully create a pool \ - with correct filesystem property set." - +log_pass "'zpool create -O property=value pool' can successfully create a pool" \ + "with correct filesystem property set." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_022_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_022_pos.ksh index 4a918c0a683a..717fcaa6ec51 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_022_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_022_pos.ksh @@ -49,12 +49,13 @@ verify_runnable "global" function cleanup { poolexists $TESTPOOL && destroy_pool $TESTPOOL + log_must rm -df "/tmp/mnt$$" } log_onexit cleanup -log_assert "'zpool create -O property=value pool' can successfully create a pool \ - with multiple filesystem properties set." +log_assert "'zpool create -O property=value pool' can successfully create a pool" \ + "with multiple filesystem properties set." set -A RW_FS_PROP "quota=536870912" \ "reservation=536870912" \ @@ -81,15 +82,13 @@ while (( $i < ${#RW_FS_PROP[*]} )); do done log_must zpool create $opts -f $TESTPOOL $DISKS -datasetexists $TESTPOOL || log_fail "zpool create $TESTPOOL fail." +log_must datasetexists $TESTPOOL i=0 while (( $i < ${#RW_FS_PROP[*]} )); do - propertycheck $TESTPOOL ${RW_FS_PROP[i]} || \ - log_fail "${RW_FS_PROP[i]} is failed to set." + log_must propertycheck $TESTPOOL ${RW_FS_PROP[i]} (( i = i + 1 )) done -log_pass "'zpool create -O property=value pool' can successfully create a pool \ - with multiple filesystem properties set." - +log_pass "'zpool create -O property=value pool' can successfully create a pool" \ + "with multiple filesystem properties set." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_023_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_023_neg.ksh index f101521bd3e8..780cf86d6c5e 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_023_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_023_neg.ksh @@ -52,7 +52,7 @@ log_onexit cleanup set -A args "QuOta=none" "quota=non" "quota=abcd" "quota=0" "quota=" \ "ResErVaTi0n=none" "reserV=none" "reservation=abcd" "reserv=" \ - "recorDSize=64k" "recordsize=2M" "recordsize=2048K" \ + "recorDSize=64k" "recordsize=32M" "recordsize=32768K" \ "recordsize=256" "recsize=" "recsize=zero" "recordsize=0" \ "mountPoint=/tmp/tmpfile$$" "mountpoint=non0" "mountpoint=" \ "mountpoint=LEGACY" "mounpoint=none" \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_024_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_024_pos.ksh index 5b464c3c248b..3e3c9ce942b5 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_024_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_024_pos.ksh @@ -74,24 +74,20 @@ child_pools="" function zpool_stress { - typeset pool=$1 + typeset pool="$1-$$" typeset vdev0="$TEST_BASE_DIR/$pool-vdev0.img" typeset vdev1="$TEST_BASE_DIR/$pool-vdev1.img" typeset -i iters=$2 typeset retry=10 typeset j=0 - truncate -s $FILESIZE $vdev0 - truncate -s $FILESIZE $vdev1 + truncate -s $FILESIZE $vdev0 $vdev1 while [[ $j -lt $iters ]]; do ((j = j + 1)) sleep 1 - zpool create $pool $vdev0 $vdev1 - if [ $? -ne 0 ]; then - return 1; - fi + zpool create $pool $vdev0 $vdev1 || return 1 # The 'zfs destroy' command is retried because it can # transiently return EBUSY when blkid is concurrently @@ -100,13 +96,8 @@ function zpool_stress while [[ $k -lt $retry ]]; do ((k = k + 1)) - zpool destroy $pool - if [ $? -eq 0 ]; then - break; - elif [ $k -eq $retry ]; then - return 1; - fi - + zpool destroy $pool && break + [ $k -eq $retry ] && return 1 sleep 3 done done @@ -118,13 +109,11 @@ function zpool_stress # 1. Create 128 process each of which create/destroy a pool 5 times. typeset i=0 while [[ $i -lt 128 ]]; do - typeset uuid=$(uuidgen | cut -c1-13) - - zpool_stress $TESTPOOL-$uuid 5 & + zpool_stress $TESTPOOL-$i 5 & typeset pid=$! child_pids="$child_pids $pid" - child_pools="$child_pools $TESTPOOL-$uuid" + child_pools="$child_pools $TESTPOOL-$i-$pid" ((i = i + 1)) done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh index 8fd1cea36e28..a75bdecff475 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh @@ -55,11 +55,9 @@ for poolprop in "${poolprops[@]}"; do # 2. Verify the pool is created with the specified temporary name log_must poolexists $TEMPPOOL log_mustnot poolexists $TESTPOOL - propname="$(awk -F= '{print $1}' <<< $fsprop)" - propval="$(awk -F= '{print $2}' <<< $fsprop)" + IFS='=' read -r propname propval <<<"$fsprop" log_must test "$(get_prop $propname $TEMPPOOL)" == "$propval" - propname="$(awk -F= '{print $1}' <<< $poolprop)" - propval="$(awk -F= '{print $2}' <<< $poolprop)" + IFS='=' read -r propname propval <<<"$poolprop" log_must test "$(get_pool_prop $propname $TEMPPOOL)" == "$propval" # Cleanup destroy_pool $TEMPPOOL diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/Makefile.am deleted file mode 100644 index 7f9e00d5826f..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_destroy -dist_pkgdata_SCRIPTS = \ - zpool_destroy_001_pos.ksh \ - zpool_destroy_002_pos.ksh \ - zpool_destroy_003_neg.ksh - -dist_pkgdata_DATA = \ - zpool_destroy.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy.cfg index bf6026747f9a..906cba700573 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy.cfg @@ -28,7 +28,7 @@ # Copyright (c) 2012 by Delphix. All rights reserved. # -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') export DISKSARRAY=$DISKS echo $DISKS | read DISK0 DISK1 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_detach/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_detach/Makefile.am deleted file mode 100644 index b22018c1d550..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_detach/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_detach -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_detach_001_neg.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/.gitignore deleted file mode 100644 index a1f8c14838fa..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/ereports diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/Makefile.am deleted file mode 100644 index 765df102229d..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_events -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_events - -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_events_clear.ksh \ - zpool_events_cliargs.ksh \ - zpool_events_follow.ksh \ - zpool_events_poolname.ksh \ - zpool_events_errors.ksh \ - zpool_events_duplicates.ksh \ - zpool_events_clear_retained.ksh - -dist_pkgdata_DATA = \ - zpool_events.cfg \ - zpool_events.kshlib - -ereports_LDADD = \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la \ - $(abs_top_builddir)/lib/libzfs/libzfs.la - -pkgexec_PROGRAMS = ereports -ereports_SOURCES = ereports.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_clear_retained.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_clear_retained.ksh index 22212a8f50a5..c16094f54038 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_clear_retained.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_clear_retained.ksh @@ -55,8 +55,6 @@ OLD_LEN_MAX=$(get_tunable ZEVENT_LEN_MAX) RETAIN_MAX=$(get_tunable ZEVENT_RETAIN_MAX) OLD_CHECKSUMS=$(get_tunable CHECKSUM_EVENTS_PER_SECOND) -EREPORTS="$STF_SUITE/tests/functional/cli_root/zpool_events/ereports" - function cleanup { log_must set_tunable64 CHECKSUM_EVENTS_PER_SECOND $OLD_CHECKSUMS @@ -66,7 +64,7 @@ function cleanup if poolexists $POOL ; then zpool export $POOL fi - log_must rm -f $VDEV1 $VDEV2 $VDEV3 + log_must rm -fd $VDEV1 $VDEV2 $VDEV3 $SUPPLY $MOUNTDIR } function damage_and_repair @@ -78,9 +76,9 @@ function damage_and_repair log_must dd conv=notrunc if=$SUPPLY of=$VDEV1 bs=1M seek=4 count=$DAMAGEBLKS log_must zpool scrub $POOL log_must zpool wait -t scrub $POOL - log_note "pass $1 observed $($EREPORTS | grep -c checksum) checksum ereports" + log_note "pass $1 observed $(ereports | grep -c checksum) checksum ereports" - repaired=$(zpool status $POOL | grep "scan: scrub repaired" | awk '{print $4}') + repaired=$(zpool status $POOL | awk '/scan: scrub repaired/ {print $4}') if [ "$repaired" == "0B" ]; then log_fail "INVALID TEST -- expected scrub to repair some blocks" else @@ -90,7 +88,7 @@ function damage_and_repair function checksum_error_count { - zpool status -p $POOL | grep $VDEV1 | awk '{print $5}' + zpool status -p $POOL | awk -v dev=$VDEV1 '$0 ~ dev {print $5}' } assertion="Damage to recently repaired blocks should be reported/counted" @@ -132,4 +130,3 @@ else log_note observed $errcnt new checksum errors after a scrub log_pass "$assertion" fi - diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_cliargs.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_cliargs.ksh index 1623a18e4740..27e2cf0ba472 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_cliargs.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_cliargs.ksh @@ -37,7 +37,7 @@ function log_must_follow # sleep 3 kill $pid if [[ $? -ne 0 ]]; then - log_fail "'$command' does not work as expected." + log_fail "'$command' exited early." else log_note "'$command' works successfully." fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh index 7023c49e51f2..9097ac008334 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh @@ -46,8 +46,6 @@ FILESIZE="10M" OLD_LEN_MAX=$(get_tunable ZEVENT_LEN_MAX) RETAIN_MAX=$(get_tunable ZEVENT_RETAIN_MAX) -EREPORTS="$STF_SUITE/tests/functional/cli_root/zpool_events/ereports" - duplicates=false function cleanup @@ -58,7 +56,7 @@ function cleanup if poolexists $POOL ; then destroy_pool $POOL fi - log_must rm -f $VDEV1 $VDEV2 + log_must rm -fd $VDEV1 $VDEV2 $MOUNTDIR } log_assert "Duplicate I/O ereport errors are not posted" @@ -103,7 +101,7 @@ function do_dup_test # Read the file a few times to generate some # duplicate errors of the same blocks for _ in {1..15}; do - dd if=$FILEPATH of=/dev/null bs=128K > /dev/null 2>&1 + dd if=$FILEPATH of=/dev/null bs=128K 2>/dev/null done log_must zinject -c all fi @@ -117,7 +115,7 @@ function do_dup_test log_must zinject -c all - ereports="$($EREPORTS | sort)" + ereports="$(ereports | sort)" actual=$(echo "$ereports" | wc -l) unique=$(echo "$ereports" | uniq | wc -l) log_note "$actual total $ERR $RW ereports where $unique were unique" @@ -140,4 +138,3 @@ if $duplicates; then else log_pass "Duplicate I/O ereport errors are not posted" fi - diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_errors.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_errors.ksh index f26c65f9db2c..82a1a1131f06 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_errors.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_errors.ksh @@ -59,7 +59,7 @@ function cleanup if poolexists $POOL ; then log_must destroy_pool $POOL fi - log_must rm -f $VDEV1 $VDEV2 $VDEV3 + log_must rm -fd $VDEV1 $VDEV2 $VDEV3 $MOUNTDIR } log_assert "Check that the number of zpool errors match the number of events" @@ -115,7 +115,7 @@ function do_test out="$(zpool status -p | grep $VDEV1)" if [ "$ERR" == "corrupt" ] ; then - events=$(zpool events | grep checksum | wc -l) + events=$(zpool events | grep -c checksum) val=$(echo "$out" | awk '{print $5}') str="checksum" elif [ "$ERR" == "io" ] ; then diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_follow.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_follow.ksh index 258de033b86c..3311eb546676 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_follow.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_follow.ksh @@ -49,14 +49,14 @@ log_must eval "zpool events -H -f > $EVENTS_FILE &" pid=$! # 3. Generate some ZFS events -for i in `seq 1 $EVENTS_NUM`; do +for i in {1..$EVENTS_NUM}; do log_must zpool clear $TESTPOOL done # wait a bit to allow the kernel module to process new events zpool_events_settle # 4. Verify 'zpool events -f' successfully recorded these new events -EVENTS_LOG=$(cat $EVENTS_FILE | wc -l) +EVENTS_LOG=$(wc -l < $EVENTS_FILE) if [[ $EVENTS_LOG -ne $EVENTS_NUM ]]; then log_fail "Unexpected number of events: $EVENTS_LOG != $EVENTS_NUM" fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_poolname.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_poolname.ksh index 42c46712f3d9..0e3829fcc8d8 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_poolname.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_poolname.ksh @@ -50,10 +50,8 @@ log_must zpool create $NEWPOOL $DISK log_must zpool events -c # 3. Generate some ZFS events on both pools -for i in `seq 1 $EVENTS_NUM`; do +for i in {1..$EVENTS_NUM}; do log_must zpool clear $TESTPOOL -done -for i in `seq 1 $EVENTS_NUM`; do log_must zpool clear $NEWPOOL done # wait a bit to allow the kernel module to process new events @@ -61,14 +59,11 @@ zpool_events_settle # 4. Verify 'zpool events poolname' successfully display events zpool events -v $TESTPOOL | - awk -v POOL=$TESTPOOL '/pool = / {if ($3 != "\""POOL"\"") exit 1}' -if [[ $? -ne 0 ]]; then + awk -v POOL=$TESTPOOL '/pool = / && $3 != "\""POOL"\"" {exit 1}' || log_fail "Unexpected events for pools other than $TESTPOOL" -fi + zpool events -v $NEWPOOL | - awk -v POOL=$NEWPOOL '/pool = / {if ($3 != "\""POOL"\"") exit 1}' -if [[ $? -ne 0 ]]; then + awk -v POOL=$NEWPOOL '/pool = / && $3 != "\""POOL"\"" {exit 1}' || log_fail "Unexpected events for pools other than $NEWPOOL" -fi log_pass "'zpool events poolname' display events only from the chosen pool." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_expand/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_expand/Makefile.am deleted file mode 100644 index beaa411e37cb..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_expand/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_expand -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_expand_001_pos.ksh \ - zpool_expand_002_pos.ksh \ - zpool_expand_003_neg.ksh \ - zpool_expand_004_pos.ksh \ - zpool_expand_005_pos.ksh - -dist_pkgdata_DATA = \ - zpool_expand.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_001_pos.ksh index 6bbd46289f7c..c49777e6b3c4 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_001_pos.ksh @@ -128,7 +128,7 @@ for type in " " mirror raidz draid:1s; do typeset size_addition=$(zpool history -il $TESTPOOL1 |\ grep "pool '$TESTPOOL1' size:" | \ grep "vdev online" | \ - grep "(+${expansion_size}" | wc -l) + grep -c "(+${expansion_size}") if [[ $size_addition -ne 3 ]]; then log_fail "pool $TESTPOOL1 has not expanded, " \ @@ -139,31 +139,22 @@ for type in " " mirror raidz draid:1s; do zpool history -il $TESTPOOL1 | \ grep "pool '$TESTPOOL1' size:" | \ grep "vdev online" | \ - grep "(+${expansion_size})" >/dev/null 2>&1 - - if [[ $? -ne 0 ]] ; then + grep -q "(+${expansion_size})" || log_fail "pool $TESTPOOL1 has not expanded" - fi elif [[ $type == "draid:1s" ]]; then typeset expansion_size=$((2*($exp_size-$org_size))) zpool history -il $TESTPOOL1 | \ grep "pool '$TESTPOOL1' size:" | \ grep "vdev online" | \ - grep "(+${expansion_size})" >/dev/null 2>&1 - - if [[ $? -ne 0 ]]; then - log_fail "pool $TESTPOOL has not expanded" - fi + grep -q "(+${expansion_size})" || + log_fail "pool $TESTPOOL has not expanded" else typeset expansion_size=$((3*($exp_size-$org_size))) zpool history -il $TESTPOOL1 | \ grep "pool '$TESTPOOL1' size:" | \ grep "vdev online" | \ - grep "(+${expansion_size})" >/dev/null 2>&1 - - if [[ $? -ne 0 ]]; then - log_fail "pool $TESTPOOL has not expanded" - fi + grep -q "(+${expansion_size})" || + log_fail "pool $TESTPOOL has not expanded" fi else log_fail "pool $TESTPOOL1 is not autoexpanded after vdev " \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_002_pos.ksh index 62843b062291..ccd266c727be 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_002_pos.ksh @@ -131,7 +131,7 @@ for type in " " mirror raidz draid:1s; do typeset size_addition=$(zpool history -il $TESTPOOL1 \ | grep "pool '$TESTPOOL1' size:" | \ grep "vdev online" | \ - grep "(+${expansion_size}" | wc -l) + grep -c "(+${expansion_size}") if [[ $size_addition -ne $i ]]; then log_fail "pool $TESTPOOL1 has not expanded " \ @@ -143,34 +143,25 @@ for type in " " mirror raidz draid:1s; do zpool history -il $TESTPOOL1 | \ grep "pool '$TESTPOOL1' size:" | \ grep "vdev online" | \ - grep "(+${expansion_size})" >/dev/null 2>&1 - - if [[ $? -ne 0 ]]; then - log_fail "pool $TESTPOOL1 has not expanded " \ - "after zpool online -e" - fi + grep -q "(+${expansion_size})" || + log_fail "pool $TESTPOOL1 has not expanded " \ + "after zpool online -e" elif [[ $type == "draid:1s" ]]; then typeset expansion_size=$((2*($exp_size-$org_size))) zpool history -il $TESTPOOL1 | \ grep "pool '$TESTPOOL1' size:" | \ grep "vdev online" | \ - grep "(+${expansion_size})" >/dev/null 2>&1 - - if [[ $? -ne 0 ]] ; then - log_fail "pool $TESTPOOL1 has not expanded " \ - "after zpool online -e" - fi + grep -q "(+${expansion_size})" || + log_fail "pool $TESTPOOL1 has not expanded " \ + "after zpool online -e" else typeset expansion_size=$((3*($exp_size-$org_size))) zpool history -il $TESTPOOL1 | \ grep "pool '$TESTPOOL1' size:" | \ grep "vdev online" | \ - grep "(+${expansion_size})" >/dev/null 2>&1 - - if [[ $? -ne 0 ]] ; then - log_fail "pool $TESTPOOL1 has not expanded " \ - "after zpool online -e" - fi + grep -q "(+${expansion_size})" || + log_fail "pool $TESTPOOL1 has not expanded " \ + "after zpool online -e" fi else log_fail "pool $TESTPOOL1 did not expand after vdev " \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_003_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_003_neg.ksh index b3c71b666a59..5bd8b56ffd0d 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_003_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_003_neg.ksh @@ -39,7 +39,6 @@ # Once set zpool autoexpand=off, zpool can *NOT* autoexpand by # Dynamic VDEV Expansion # -# # STRATEGY: # 1) Create three vdevs (loopback, scsi_debug, and file) # 2) Create pool by using the different devices and set autoexpand=off @@ -73,7 +72,7 @@ log_onexit cleanup log_assert "zpool can not expand if set autoexpand=off after vdev expansion" -for type in " " mirror raidz draid; do +for type in "" mirror raidz draid; do log_note "Setting up loopback, scsi_debug, and file vdevs" log_must truncate -s $org_size $FILE_LO DEV1=$(losetup -f) @@ -89,11 +88,7 @@ for type in " " mirror raidz draid; do # The -f is required since we're mixing disk and file vdevs. log_must zpool create -f $TESTPOOL1 $type $DEV1 $DEV2 $DEV3 - typeset autoexp=$(get_pool_prop autoexpand $TESTPOOL1) - if [[ $autoexp != "off" ]]; then - log_fail "zpool $TESTPOOL1 autoexpand should be off but is " \ - "$autoexp" - fi + log_must [ "$(get_pool_prop autoexpand $TESTPOOL1)" = "off" ] typeset prev_size=$(get_pool_prop size $TESTPOOL1) @@ -107,8 +102,8 @@ for type in " " mirror raidz draid; do log_must losetup -c $DEV1 sleep 3 - echo "2" > /sys/bus/pseudo/drivers/scsi_debug/virtual_gb - echo "1" > /sys/class/block/$DEV2/device/rescan + log_must eval "echo 2 > /sys/bus/pseudo/drivers/scsi_debug/virtual_gb" + log_must eval "echo 1 > /sys/class/block/$DEV2/device/rescan" block_device_wait sleep 3 @@ -118,19 +113,11 @@ for type in " " mirror raidz draid; do sleep 5 # check for zpool history for the pool size expansion - zpool history -il $TESTPOOL1 | grep "pool '$TESTPOOL1' size:" | \ - grep "vdev online" >/dev/null 2>&1 + zpool history -il $TESTPOOL1 | grep "pool '$TESTPOOL1' size:" | + grep "vdev online" && + log_fail "pool $TESTPOOL1 is not autoexpand after vdev expansion" - if [[ $? -eq 0 ]]; then - log_fail "pool $TESTPOOL1 is not autoexpand after vdev " \ - "expansion" - fi - - typeset expand_size=$(get_pool_prop size $TESTPOOL1) - - if [[ "$prev_size" != "$expand_size" ]]; then - log_fail "pool $TESTPOOL1 size changed after vdev expansion" - fi + log_must [ "$(get_pool_prop size $TESTPOOL1)" = "$prev_size" ] cleanup done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_export/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_export/Makefile.am deleted file mode 100644 index 1c06d5b59e9b..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_export/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_export -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_export_001_pos.ksh \ - zpool_export_002_pos.ksh \ - zpool_export_003_neg.ksh \ - zpool_export_004_pos.ksh - -dist_pkgdata_DATA = \ - zpool_export.cfg \ - zpool_export.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg index 8bfb067c7aac..349399263da8 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg @@ -30,9 +30,9 @@ . $STF_SUITE/include/libtest.shlib -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') -export DISK1=$(echo $DISKS | awk '{print $1}') -export DISK2=$(echo $DISKS | awk '{print $3}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') +read -r DISK1 _ DISK2 _ <<<"$DISKS" +export DISK1 DISK2 if is_linux; then set_slice_prefix diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_002_pos.ksh index 8040d12b92d2..913a4cd6a34c 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_002_pos.ksh @@ -45,9 +45,7 @@ verify_runnable "global" function cleanup { - cd $olddir || \ - log_fail "Couldn't cd back to $olddir" - + log_must cd $olddir zpool_export_cleanup } @@ -57,16 +55,9 @@ log_onexit cleanup log_assert "Verify a busy ZPOOL cannot be exported." -ismounted "$TESTPOOL/$TESTFS" -(( $? != 0 )) && \ - log_fail "$TESTDIR not mounted. Unable to continue." - -cd $TESTDIR || \ - log_fail "Couldn't cd to $TESTDIR" - +log_must ismounted "$TESTPOOL/$TESTFS" +log_must cd $TESTDIR log_mustnot zpool export $TESTPOOL - -poolexists $TESTPOOL || \ - log_fail "$TESTPOOL not found in 'zpool list' output." +log_must poolexists $TESTPOOL log_pass "Unable to export a busy ZPOOL as expected." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/Makefile.am deleted file mode 100644 index 0c87c9b37763..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_get -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_get_001_pos.ksh \ - zpool_get_002_pos.ksh \ - zpool_get_003_pos.ksh \ - zpool_get_004_neg.ksh \ - zpool_get_005_pos.ksh - -dist_pkgdata_DATA = \ - zpool_get.cfg zpool_get_parsable.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get.cfg index fac96e26e460..4ea5725e040e 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get.cfg @@ -98,5 +98,6 @@ if is_linux || is_freebsd; then "feature@livelist" "feature@zstd_compress" "feature@zilsaxattr" + "feature@head_errlog" ) -fi \ No newline at end of file +fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_002_pos.ksh index ba83fadb06f1..de39aa260f61 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_002_pos.ksh @@ -66,29 +66,20 @@ log_must zpool get all $TESTPOOL zpool get all $TESTPOOL > $values log_note "Checking zpool get all output for a header." -grep ^"NAME " $values > /dev/null 2>&1 -if [ $? -ne 0 ] -then - log_fail "The header was not printed from zpool get all" -fi +log_must grep -q ^"NAME " $values while [ $i -lt "${#properties[@]}" ] do log_note "Checking for ${properties[$i]} property" - grep "$TESTPOOL *${properties[$i]}" $values > /dev/null 2>&1 - if [ $? -ne 0 ] - then - log_fail "zpool property ${properties[$i]} was not found\ - in pool output." - fi + log_must grep -q "$TESTPOOL *${properties[$i]}" $values i=$(( $i + 1 )) done # increment the counter to include the header line i=$(( $i + 1 )) -COUNT=$(wc $values | awk '{print $1}') +COUNT=$(wc -l < $values) if [ $i -ne $COUNT ] then log_fail "Found zpool features not in the zpool_get test config $i/$COUNT." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_003_pos.ksh index 89fca9cbd485..7c2e214b7da0 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_003_pos.ksh @@ -60,14 +60,10 @@ while [ $i -lt "${#properties[@]}" ] do log_note "Checking for ${properties[$i]} property" log_must eval "zpool get ${properties[$i]} $TESTPOOL > $values" - grep "${properties[$i]}" $values > /dev/null 2>&1 - if [ $? -ne 0 ] - then - log_fail "${properties[$i]} not seen in output" - fi - grep "^NAME " $values > /dev/null 2>&1 + log_must grep -q "${properties[$i]}" $values + # only need to check this once. - if [ $i -eq 0 ] && [ $? -ne 0 ] + if [ $i -eq 0 ] && ! grep -q "^NAME " $values then log_fail "Header not seen in zpool get output" fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_005_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_005_pos.ksh index ad27d180fdb1..4481dab69f7b 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_005_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_005_pos.ksh @@ -50,14 +50,9 @@ typeset -i i=0 while [[ $i -lt "${#properties[@]}" ]]; do log_note "Checking for parsable ${properties[$i]} property" log_must eval "zpool get -p ${properties[$i]} $TESTPOOL >/tmp/value.$$" - grep "${properties[$i]}" /tmp/value.$$ >/dev/null 2>&1 - if [[ $? -ne 0 ]]; then - log_fail "${properties[$i]} not seen in output" - fi + log_must grep -q "${properties[$i]}" /tmp/value.$$ - typeset v=$(grep "${properties[$i]}" /tmp/value.$$ | awk '{print $3}') - - log_note "${properties[$i]} has a value of $v" + typeset v=$(awk -v p="${properties[$i]}" '$0 ~ p {print $3}' /tmp/value.$$) # Determine if this value is a valid number, result in return code log_must test -n "$v" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_history/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_history/Makefile.am deleted file mode 100644 index 8755f8f6c8a9..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_history/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_history -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_history_001_neg.ksh \ - zpool_history_002_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/Makefile.am deleted file mode 100644 index a8c9a31dcfdc..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/Makefile.am +++ /dev/null @@ -1,51 +0,0 @@ -SUBDIRS = blockfiles - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_import -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - import_cachefile_device_added.ksh \ - import_cachefile_device_removed.ksh \ - import_cachefile_device_replaced.ksh \ - import_cachefile_mirror_attached.ksh \ - import_cachefile_mirror_detached.ksh \ - import_cachefile_paths_changed.ksh \ - import_cachefile_shared_device.ksh \ - import_devices_missing.ksh \ - import_paths_changed.ksh \ - import_rewind_config_changed.ksh \ - import_rewind_device_replaced.ksh \ - zpool_import_001_pos.ksh \ - zpool_import_002_pos.ksh \ - zpool_import_003_pos.ksh \ - zpool_import_004_pos.ksh \ - zpool_import_005_pos.ksh \ - zpool_import_006_pos.ksh \ - zpool_import_007_pos.ksh \ - zpool_import_008_pos.ksh \ - zpool_import_009_neg.ksh \ - zpool_import_010_pos.ksh \ - zpool_import_011_neg.ksh \ - zpool_import_012_pos.ksh \ - zpool_import_013_neg.ksh \ - zpool_import_014_pos.ksh \ - zpool_import_015_pos.ksh \ - zpool_import_016_pos.ksh \ - zpool_import_017_pos.ksh \ - zpool_import_all_001_pos.ksh \ - zpool_import_features_001_pos.ksh \ - zpool_import_features_002_neg.ksh \ - zpool_import_features_003_pos.ksh \ - zpool_import_missing_001_pos.ksh \ - zpool_import_missing_002_pos.ksh \ - zpool_import_missing_003_pos.ksh \ - zpool_import_rename_001_pos.ksh \ - zpool_import_encrypted.ksh \ - zpool_import_encrypted_load.ksh \ - zpool_import_errata3.ksh \ - zpool_import_errata4.ksh - -dist_pkgdata_DATA = \ - zpool_import.cfg \ - zpool_import.kshlib - diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/blockfiles/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/blockfiles/Makefile.am deleted file mode 100644 index dc3685e4b9cc..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/blockfiles/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_import/blockfiles -dist_pkgdata_DATA = \ - unclean_export.dat.bz2 \ - cryptv0.dat.bz2 \ - missing_ivset.dat.bz2 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_cachefile_shared_device.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_cachefile_shared_device.ksh index 87942b4a52e4..ce9885904b01 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_cachefile_shared_device.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_cachefile_shared_device.ksh @@ -50,14 +50,8 @@ function dev_checksum log_note "Compute checksum of '$dev'" - checksum=$(md5digest $dev) - if [[ $? -ne 0 ]]; then + md5digest $dev || log_fail "Failed to compute checksum of '$dev'" - return 1 - fi - - echo "$checksum" - return 0 } function test_shared_device diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_config_changed.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_config_changed.ksh index d79c757d2406..4b6fcbd80af1 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_config_changed.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_config_changed.ksh @@ -133,12 +133,8 @@ function test_common log_must zpool export $TESTPOOL1 - zpool import -d $DEVICE_DIR -T $txg $TESTPOOL1 - if (( $? == 0 )); then - verify_data_md5sums $MD5FILE - if (( $? == 0 )); then - retval=0 - fi + if zpool import -d $DEVICE_DIR -T $txg $TESTPOOL1; then + verify_data_md5sums $MD5FILE && retval=0 log_must check_pool_config $TESTPOOL1 "$poolcheck" log_must zpool destroy $TESTPOOL1 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib index 8bbd668a9317..559810ff0e30 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib @@ -22,7 +22,7 @@ function cleanup { # clear any remaining zinjections - log_must zinject -c all > /dev/null + log_must eval "zinject -c all > /dev/null" destroy_pool $TESTPOOL1 @@ -64,17 +64,13 @@ function write_some_data typeset files10mb=${2:-10} typeset ds="$pool/fillerds" - zfs create $ds - [[ $? -ne 0 ]] && return 1 + zfs create $ds || return 1 # Create 100 MB of data typeset file="/$ds/fillerfile" for i in {1..$files10mb}; do - dd if=/dev/urandom of=$file.$i bs=128k count=80 - [[ $? -ne 0 ]] && return 1 + dd if=/dev/urandom of=$file.$i bs=128k count=80 || return 1 done - - return 0 } # @@ -143,13 +139,12 @@ function verify_data_md5sums return 1 fi - cat $md5file | \ - while read digest file; do + while read -r digest file; do typeset digest1=$(md5digest $file) if [[ "$digest1" != "$digest" ]]; then return 1 fi - done + done < $md5file return 0 } @@ -181,20 +176,20 @@ function _translate_vdev # typeset keywords="mirror replacing raidz1 raidz2 raidz3 indirect draid1 draid2 draid3" for word in $keywords; do - echo $vdev | egrep -qE \ - "^${word}-[0-9]+\$|^${word}:[0-9]+d:[0-9]c:[0-9]+s-[0-9]+\$" - if [[ $? -eq 0 ]]; then + if echo $vdev | + grep -qE "^${word}-[0-9]+\$|^${word}:[0-9]+d:[0-9]c:[0-9]+s-[0-9]+\$" + then vdev=$word break fi done - [[ $vdev == "logs" ]] && echo "log" && return 0 - [[ $vdev == "raidz1" ]] && echo "raidz" && return 0 - [[ $vdev == "draid1" ]] && echo "draid" && return 0 - - echo $vdev - return 0 + case "$vdev" in + logs) echo "log" ;; + raidz1) echo "raidz" ;; + draid1) echo "draid" ;; + *) echo $vdev ;; + esac } # @@ -217,9 +212,8 @@ function check_pool_config typeset expected=$2 typeset status - status=$(zpool status $poolname 2>&1) - if [[ $? -ne 0 ]]; then - if ( $logfailure ); then + if ! status=$(zpool status $poolname 2>&1); then + if $logfailure; then log_note "zpool status $poolname failed: $status" fi return 1 @@ -227,8 +221,7 @@ function check_pool_config typeset actual="" typeset began=false - printf "$status\n" | while read line; do - typeset vdev=$(echo "$line" | awk '{printf $1}') + while read -r vdev _; do if ( ! $began ) && [[ $vdev == NAME ]]; then began=true continue @@ -240,12 +233,12 @@ function check_pool_config vdev=$(_translate_vdev $vdev) actual="$actual $vdev" fi - done + done <<<"$status" expected="$poolname $expected" if [[ "$actual" != "$expected" ]]; then - if ( $logfailure ); then + if $logfailure; then log_note "expected pool vdevs:" log_note "> '$expected'" log_note "actual pool vdevs:" @@ -272,13 +265,11 @@ function wait_for_pool_config timeout=$(( $timeout + $(date +%s) )) while (( $(date +%s) < $timeout )); do - check_pool_config -q $poolname "$expectedconfig" - [[ $? -eq 0 ]] && return 0 + check_pool_config -q $poolname "$expectedconfig" && return 0 sleep 3 done check_pool_config $poolname "$expectedconfig" - return $? } # @@ -287,16 +278,14 @@ function wait_for_pool_config function check_pool_healthy { typeset pool=$1 - typeset status - status=$(zpool status $pool 2>&1) - if [[ $? -ne 0 ]]; then + + if ! status=$(zpool status $pool 2>&1); then log_note "zpool status $pool failed: $status" return 1 fi - status=$(echo "$status" | grep "$pool" | grep -v "pool:" | \ - awk '{print $2}') + status=$(echo "$status" | awk -v p="$pool" '!/pool:/ && $0 ~ p {print $2}') if [[ $status != "ONLINE" ]]; then log_note "Invalid zpool status for '$pool': '$status'" \ @@ -314,9 +303,7 @@ function pool_is_replacing { typeset pool=$1 - zpool status $pool | grep "replacing" | grep "ONLINE" > /dev/null - - return $? + zpool status $pool | grep "replacing" | grep -q "ONLINE" } function set_vdev_validate_skip diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_001_pos.ksh index 6369a297c17d..e159c1a04195 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_001_pos.ksh @@ -79,7 +79,7 @@ function cleanup cleanup_filesystem $TESTPOOL1 $TESTFS - destroy_pool $TESTPOOL1 + destroy_pool $TESTPOOL1 [[ -d $ALTER_ROOT ]] && \ log_must rm -rf $ALTER_ROOT @@ -91,7 +91,7 @@ log_assert "Verify that an exported pool can be imported." setup_filesystem "$DEVICE_FILES" $TESTPOOL1 $TESTFS $TESTDIR1 -checksum1=$(sum $MYTESTFILE | awk '{print $1}') +read -r checksum1 _ < <(cksum $MYTESTFILE) typeset -i i=0 typeset -i j=0 @@ -125,9 +125,8 @@ while (( i < ${#pools[*]} )); do [[ ! -e $basedir/$TESTFILE0 ]] && \ log_fail "$basedir/$TESTFILE0 missing after import." - checksum2=$(sum $basedir/$TESTFILE0 | awk '{print $1}') - [[ "$checksum1" != "$checksum2" ]] && \ - log_fail "Checksums differ ($checksum1 != $checksum2)" + read -r checksum2 _ < <(cksum $basedir/$TESTFILE0) + log_must [ "$checksum1" = "$checksum2" ] ((j = j + 1)) done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_002_pos.ksh index 898f93cc9062..95ebe0ae294d 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_002_pos.ksh @@ -90,7 +90,7 @@ log_assert "Verify that an exported pool cannot be imported more than once." setup_filesystem "$DEVICE_FILES" $TESTPOOL1 $TESTFS $TESTDIR1 -checksum1=$(sum $MYTESTFILE | awk '{print $1}') +read -r checksum1 _ < <(cksum $MYTESTFILE) typeset -i i=0 typeset -i j=0 @@ -126,9 +126,8 @@ while (( i < ${#pools[*]} )); do [[ ! -e $basedir/$TESTFILE0 ]] && \ log_fail "$basedir/$TESTFILE0 missing after import." - checksum2=$(sum $basedir/$TESTFILE0 | awk '{print $1}') - [[ "$checksum1" != "$checksum2" ]] && \ - log_fail "Checksums differ ($checksum1 != $checksum2)" + read -r checksum2 _ < <(cksum $basedir/$TESTFILE0) + log_must [ "$checksum1" = "$checksum2" ] log_mustnot zpool import ${devs[i]} $target diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_012_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_012_pos.ksh index ec387b225665..a9d5e2b319a4 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_012_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_012_pos.ksh @@ -165,10 +165,9 @@ for option in "" "-Df"; do fi log_note "Import with $nfs_flag and " \ "$guid_flag" - zpool import $option ${devs[i]} \ - ${options[j]} $target - #import by GUID if import by pool name fails - if [[ $? != 0 ]]; then + if ! zpool import $option ${devs[i]} \ + ${options[j]} $target; then + # import by GUID if import by pool name fails log_note "Possible pool name" \ "duplicates. Try GUID import" target=$guid diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_all_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_all_001_pos.ksh index b384ec9b1fce..9f5503454d95 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_all_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_all_001_pos.ksh @@ -76,11 +76,11 @@ function cleanup_all # # Try import individually if 'import -a' failed. # - for pool in `zpool import | grep "pool:" | awk '{print $2}'`; do + for pool in $(zpool import | awk '/pool:/ {print $2}'); do zpool import -f $pool done - for pool in `zpool import -d $DEVICE_DIR | grep "pool:" | awk '{print $2}'`; do + for pool in $(zpool import -d $DEVICE_DIR | awk '/pool:/ {print $2}'); do log_must zpool import -d $DEVICE_DIR -f $pool done @@ -108,9 +108,8 @@ function checksum_all #alter_root [[ ! -e $file ]] && \ log_fail "$file missing after import." - checksum2=$(sum $file | awk '{print $1}') - [[ "$checksum1" != "$checksum2" ]] && \ - log_fail "Checksums differ ($checksum1 != $checksum2)" + read -r checksum2 _ < <(cksum $file) + log_must [ "$checksum1" = "$checksum2" ] (( id = id + 1 )) done @@ -122,7 +121,7 @@ function checksum_all #alter_root log_assert "Verify that 'zpool import -a' succeeds as root." log_onexit cleanup_all -checksum1=$(sum $MYTESTFILE | awk '{print $1}') +read -r checksum1 _ < <(cksum $MYTESTFILE) number=1 # diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata3.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata3.ksh index 40b6ca1c1897..c5e578d79edb 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata3.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata3.ksh @@ -44,17 +44,15 @@ POOL_FILE=cryptv0.dat function uncompress_pool { log_note "Creating pool from $POOL_FILE" - log_must bzcat \ + log_must eval bzcat \ $STF_SUITE/tests/functional/cli_root/zpool_import/blockfiles/$POOL_FILE.bz2 \ - > /$TESTPOOL/$POOL_FILE - return 0 + "> /$TESTPOOL/$POOL_FILE" } function cleanup { poolexists $POOL_NAME && log_must zpool destroy $POOL_NAME - [[ -e /$TESTPOOL/$POOL_FILE ]] && rm /$TESTPOOL/$POOL_FILE - return 0 + log_must rm -f /$TESTPOOL/$POOL_FILE } log_onexit cleanup diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata4.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata4.ksh index a199c2a7fb9d..e450d9a6222c 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata4.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata4.ksh @@ -43,18 +43,16 @@ POOL_FILE=missing_ivset.dat function uncompress_pool { log_note "Creating pool from $POOL_FILE" - log_must bzcat \ + log_must eval bzcat \ $STF_SUITE/tests/functional/cli_root/zpool_import/blockfiles/$POOL_FILE.bz2 \ - > /$TESTPOOL/$POOL_FILE - return 0 + "> /$TESTPOOL/$POOL_FILE" } function cleanup { log_must set_tunable32 DISABLE_IVSET_GUID_CHECK 0 poolexists $POOL_NAME && log_must zpool destroy $POOL_NAME - [[ -e /$TESTPOOL/$POOL_FILE ]] && rm /$TESTPOOL/$POOL_FILE - return 0 + log_must rm -rf /$TESTPOOL/$POOL_FILE } log_onexit cleanup @@ -65,11 +63,7 @@ function has_ivset_guid # dataset ds="$1" ivset_guid=$(get_prop ivsetguid $ds) - if [ "$ivset_guid" == "-" ]; then - return 1 - else - return 0 - fi + [ "$ivset_guid" != "-" ] } # 1. Import a pre-packaged pool with Errata #4 and verify its state @@ -78,9 +72,7 @@ log_must zpool import -d /$TESTPOOL/ $POOL_NAME log_must eval "zpool status $POOL_NAME | grep -q 'Errata #4'" log_must eval "zpool status $POOL_NAME | grep -q ZFS-8000-ER" bm2_value=$(zpool get -H -o value feature@bookmark_v2 $POOL_NAME) -if [ "$bm2_value" != "disabled" ]; then - log_fail "initial pool's bookmark_v2 feature is not disabled" -fi +log_must [ "$bm2_value" = "disabled" ] log_mustnot has_ivset_guid $POOL_NAME/testfs@snap1 log_mustnot has_ivset_guid $POOL_NAME/testfs@snap2 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_features_002_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_features_002_neg.ksh index d16ef217a444..88fde66adf04 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_features_002_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_features_002_neg.ksh @@ -69,18 +69,18 @@ done log_mustnot zpool import -d $DEVICE_DIR $TESTPOOL1 # error message should not mention "readonly" -log_mustnot eval "zpool import -d $DEVICE_DIR $TESTPOOL1 | grep readonly" +log_mustnot eval "zpool import -d $DEVICE_DIR $TESTPOOL1 | grep -q readonly" log_mustnot poolexists $TESTPOOL1 for feature in $active_features; do log_must eval "zpool import -d $DEVICE_DIR $TESTPOOL1 \ - | grep $feature" + | grep -q $feature" log_mustnot poolexists $TESTPOOL1 done for feature in $enabled_features; do log_mustnot eval "zpool import -d $DEVICE_DIR $TESTPOOL1 \ - | grep $feature" + | grep -q $feature" log_mustnot poolexists $TESTPOOL1 done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_001_pos.ksh index 3b5167ff0374..22cec24ff457 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_001_pos.ksh @@ -111,7 +111,7 @@ log_assert "Verify that import could handle damaged or missing device." CWD=$PWD cd $DEVICE_DIR || log_fail "Unable change directory to $DEVICE_DIR" -checksum1=$(sum $MYTESTFILE | awk '{print $1}') +read -r checksum1 _ < <(cksum $MYTESTFILE) typeset -i i=0 typeset -i j=0 @@ -199,10 +199,8 @@ while (( i < ${#vdevs[*]} )); do [[ ! -e $basedir/$TESTFILE0 ]] && \ log_fail "$basedir/$TESTFILE0 missing after import." - checksum2=$(sum $basedir/$TESTFILE0 | awk '{print $1}') - [[ "$checksum1" != "$checksum2" ]] && \ - log_fail "Checksums differ ($checksum1 != $checksum2)" - + read -r checksum2 _ < <(cksum $basedir/$TESTFILE0) + log_must [ "$checksum1" = "$checksum2" ] done ((j = j + 1)) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_003_pos.ksh index 9d4629a77912..ac76f879c2e8 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_003_pos.ksh @@ -97,9 +97,8 @@ function verify [[ ! -e $mtpt/$file ]] && \ log_fail "$mtpt/$file missing after import." - checksum2=$(sum $mymtpt/$file | awk '{print $1}') - [[ "$checksum1" != "$checksum2" ]] && \ - log_fail "Checksums differ ($checksum1 != $checksum2)" + read -r checksum2 _ < <(cksum $mymtpt/$file) + log_must [ "$checksum1" = "$checksum2" ] return 0 @@ -107,7 +106,7 @@ function verify function cleanup { - cd $DEVICE_DIR || log_fail "Unable change directory to $DEVICE_DIR" + log_must cd $DEVICE_DIR for pool in $TESTPOOL1 $TESTPOOL2; do if poolexists "$pool" ; then @@ -136,7 +135,7 @@ function cleanup_all done log_must rm -f $DEVICE_DIR/$DEVICE_ARCHIVE - cd $CWD || log_fail "Unable change directory to $CWD" + log_must cd $CWD } @@ -146,10 +145,10 @@ log_assert "Verify that import could handle device overlapped." CWD=$PWD -cd $DEVICE_DIR || log_fail "Unable change directory to $DEVICE_DIR" +log_must cd $DEVICE_DIR log_must tar cf $DEVICE_DIR/$DEVICE_ARCHIVE ${DEVICE_FILE}* -checksum1=$(sum $MYTESTFILE | awk '{print $1}') +read -r checksum1 < <(cksum $MYTESTFILE) typeset -i i=0 typeset -i j=0 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_rename_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_rename_001_pos.ksh index bb6bf86d7881..4e49e8d01d88 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_rename_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_rename_001_pos.ksh @@ -101,7 +101,7 @@ log_onexit cleanup log_assert "Verify that an imported pool can be renamed." setup_filesystem "$DEVICE_FILES" $TESTPOOL1 $TESTFS $TESTDIR1 -checksum1=$(sum $MYTESTFILE | awk '{print $1}') +read -r checksum1 _ < <(cksum $MYTESTFILE) typeset -i i=0 typeset -i j=0 @@ -140,9 +140,8 @@ while (( i < ${#pools[*]} )); do [[ ! -e $basedir/$TESTFILE0 ]] && \ log_fail "$basedir/$TESTFILE0 missing after import." - checksum2=$(sum $basedir/$TESTFILE0 | awk '{print $1}') - [[ "$checksum1" != "$checksum2" ]] && \ - log_fail "Checksums differ ($checksum1 != $checksum2)" + read -r checksum2 _ < <(cksum $basedir/$TESTFILE0) + log_must [ "$checksum1" = "$checksum2" ] log_must zpool export "${pools[i]}-new" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/Makefile.am deleted file mode 100644 index 3968902ec36d..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_initialize -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - zpool_initialize_attach_detach_add_remove.ksh \ - zpool_initialize_fault_export_import_online.ksh \ - zpool_initialize_import_export.ksh \ - zpool_initialize_offline_export_import_online.ksh \ - zpool_initialize_online_offline.ksh \ - zpool_initialize_split.ksh \ - zpool_initialize_start_and_cancel_neg.ksh \ - zpool_initialize_start_and_cancel_pos.ksh \ - zpool_initialize_suspend_resume.ksh \ - zpool_initialize_unsupported_vdevs.ksh \ - zpool_initialize_verify_checksums.ksh \ - zpool_initialize_verify_initialized.ksh - -dist_pkgdata_DATA = \ - zpool_initialize.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh index f774970a71be..5e40eee4b83e 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh @@ -65,10 +65,7 @@ log_must zpool export $TESTPOOL metaslabs=0 bs=512 zdb -p $TESTDIR -Pme $TESTPOOL | awk '/metaslab[ ]+[0-9]+/ { print $4, $8 }' | -while read -r offset_size; do - typeset offset=$(echo $offset_size | cut -d ' ' -f1) - typeset size=$(echo $offset_size | cut -d ' ' -f2) - +while read -r offset size; do log_note "offset: '$offset'" log_note "size: '$size'" @@ -79,7 +76,7 @@ while read -r offset_size; do # Note we use '-t x4' instead of '-t x8' here because x8 is not # a supported format on FreeBSD. dd if=$SMALLFILE skip=$((offset / bs)) count=$((size / bs)) bs=$bs | - od -t x4 -Ad | egrep -q "deadbeef +deadbeef +deadbeef +deadbeef" || + od -t x4 -Ad | grep -qE "deadbeef +deadbeef +deadbeef +deadbeef" || log_fail "Pattern not found in metaslab free space" done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/Makefile.am deleted file mode 100644 index c258f0c929d4..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_labelclear/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_labelclear -dist_pkgdata_SCRIPTS = \ - zpool_labelclear_active.ksh \ - zpool_labelclear_exported.ksh \ - zpool_labelclear_removed.ksh \ - zpool_labelclear_valid.ksh - -dist_pkgdata_DATA = \ - labelclear.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_offline/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_offline/Makefile.am deleted file mode 100644 index 33fbb18d66f3..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_offline/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_offline -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_offline_001_pos.ksh \ - zpool_offline_002_neg.ksh \ - zpool_offline_003_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_001_pos.ksh index 6f4c2e3182d1..4f3c187b91d5 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_001_pos.ksh @@ -55,10 +55,7 @@ function cleanup # for disk in $DISKLIST; do log_must zpool online $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "Unable to online $disk" - fi + log_must check_state $TESTPOOL $disk "online" done } @@ -79,16 +76,10 @@ for disk in $DISKLIST; do while [[ $i -lt ${#args[*]} ]]; do if (( j < num )) ; then log_must zpool offline ${args[$i]} $TESTPOOL $disk - check_state $TESTPOOL $disk "offline" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL did not match offline state" - fi + log_must check_state $TESTPOOL $disk "offline" else log_mustnot zpool offline ${args[$i]} $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL did not match online state" - fi + log_must check_state $TESTPOOL $disk "online" fi (( i = i + 1 )) @@ -106,19 +97,13 @@ for disk in $DISKLIST; do while [[ $i -lt $iters ]]; do index=`expr $RANDOM % ${#args[*]}` log_must zpool offline ${args[$index]} $TESTPOOL $disk - check_state $TESTPOOL $disk "offline" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL is not offline." - fi + log_must check_state $TESTPOOL $disk "offline" (( i = i + 1 )) done log_must zpool online $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL did not match online state" - fi + log_must check_state $TESTPOOL $disk "online" done log_pass "'zpool offline -f' succeeded" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_003_pos.ksh index 7b5d21cba208..ceef4cc3161d 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_003_pos.ksh @@ -54,10 +54,7 @@ function cleanup # Ensure we don't leave disks in the offline state for disk in $DISKLIST; do log_must zpool online $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "Unable to online $disk" - fi + log_must check_state $TESTPOOL $disk "online" done } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_online/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_online/Makefile.am deleted file mode 100644 index 12681e3c4141..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_online/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_online -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_online_001_pos.ksh \ - zpool_online_002_neg.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_online/zpool_online_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_online/zpool_online_001_pos.ksh index 8489fddb4109..e104a9323f27 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_online/zpool_online_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_online/zpool_online_001_pos.ksh @@ -54,10 +54,7 @@ function cleanup # for disk in $DISKLIST; do log_must zpool online $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "Unable to online $disk" - fi + log_must check_state $TESTPOOL $disk "online" done } @@ -79,16 +76,10 @@ for disk in $DISKLIST; do sync_pool $TESTPOOL log_must zpool offline $TESTPOOL $disk - check_state $TESTPOOL $disk "offline" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL did not match offline state" - fi + log_must check_state $TESTPOOL $disk "offline" log_must zpool online ${args[$i]} $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL did not match online state" - fi + log_must check_state $TESTPOOL $disk "online" while [[ $j -lt 20 ]]; do is_pool_resilvered $TESTPOOL && break @@ -112,10 +103,7 @@ for disk in $DISKLIST; do while [[ $i -lt $iters ]]; do index=`expr $RANDOM % ${#args[*]}` log_must zpool online ${args[$index]} $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL did not match online state" - fi + log_must check_state $TESTPOOL $disk "online" (( i = i + 1 )) done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_remove/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_remove/Makefile.am deleted file mode 100644 index e30e3f60c2d6..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_remove/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_remove -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_remove_001_neg.ksh \ - zpool_remove_002_pos.ksh \ - zpool_remove_003_pos.ksh - -dist_pkgdata_DATA = \ - zpool_remove.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/Makefile.am deleted file mode 100644 index 01ad68c817f2..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_reopen -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_reopen_001_pos.ksh \ - zpool_reopen_002_pos.ksh \ - zpool_reopen_003_pos.ksh \ - zpool_reopen_004_pos.ksh \ - zpool_reopen_005_pos.ksh \ - zpool_reopen_006_neg.ksh \ - zpool_reopen_007_pos.ksh - -dist_pkgdata_DATA = \ - zpool_reopen.cfg \ - zpool_reopen.shlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.cfg index 7451ffd8c53f..35beb568cb40 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.cfg @@ -18,7 +18,7 @@ verify_runnable "global" -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') export DISKSARRAY=$DISKS export SMALL_FILE_SIZE=10 export LARGE_FILE_SIZE=80 @@ -29,9 +29,8 @@ export SDHOSTS=1 export SDTGTS=1 export SDLUNS=1 -export DISK1=$(echo $DISKS | nawk '{print $1}') -export DISK2=$(echo $DISKS | nawk '{print $2}') -export DISK3=$(echo $DISKS | nawk '{print $3}') +read -r DISK1 DISK2 DISK3 _ <<<"$DISKS" +export DISK1 DISK2 DISK3 if is_linux; then set_slice_prefix diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib index 3d142fdf70ca..9b3bc1432270 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib @@ -20,7 +20,7 @@ function clear_labels #disks { for disk in $@; do - if ( is_loop_device $disk ) || ( is_mpath_device $disk ); then + if is_loop_device $disk || is_mpath_device $disk; then zpool labelclear -f /dev/$disk else zpool labelclear -f /dev/${disk}1 @@ -90,19 +90,16 @@ function wait_for_action #pool timeout function function wait_for_resilver_start #pool timeout { wait_for_action $1 $2 is_pool_resilvering - return $? } function wait_for_resilver_end #pool timeout { wait_for_action $1 $2 is_pool_resilvered - return $? } function wait_for_scrub_end #pool timeout { wait_for_action $1 $2 is_pool_scrubbed - return $? } # @@ -111,14 +108,10 @@ function wait_for_scrub_end #pool timeout function is_scan_restarted #pool { - typeset pool=$1 - zpool history -i $pool | grep -q "scan aborted, restarting" - return $? + zpool history -i $1 | grep -q "scan aborted, restarting" } function is_deferred_scan_started #pool { - typeset pool=$1 - zpool history -i $pool | grep -q "starting deferred resilver" - return $? + zpool history -i $1 | grep -q "starting deferred resilver" } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_replace/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_replace/Makefile.am deleted file mode 100644 index 2e3ea69f2ca9..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_replace/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_replace -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_replace_001_neg.ksh \ - replace-o_ashift.ksh \ - replace_prop_ashift.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace-o_ashift.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace-o_ashift.ksh index 1b18b1297a78..f1b957e620c9 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace-o_ashift.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace-o_ashift.ksh @@ -69,23 +69,13 @@ do for cmdval in ${ashifts[@]} do log_must zpool create -o ashift=$ashift $TESTPOOL1 $disk1 - verify_ashift $disk1 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Pool was created without setting ashift " \ - "value to $ashift" - fi + log_must verify_ashift $disk1 $ashift # ashift_of(replacing_disk) <= ashift_of(existing_vdev) if [[ $cmdval -le $ashift ]] then log_must zpool replace -o ashift=$cmdval $TESTPOOL1 \ $disk1 $disk2 - verify_ashift $disk2 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Device was replaced without " \ - "setting ashift value to $ashift" - fi + log_must verify_ashift $disk2 $ashift wait_replacing $TESTPOOL1 else log_mustnot zpool replace -o ashift=$cmdval $TESTPOOL1 \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace_prop_ashift.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace_prop_ashift.ksh index f076f26818eb..a524c4b17ae5 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace_prop_ashift.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace_prop_ashift.ksh @@ -77,12 +77,7 @@ do then log_must zpool replace $TESTPOOL1 $disk1 $disk2 wait_replacing $TESTPOOL1 - verify_ashift $disk2 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Device was replaced without " \ - "setting ashift value to $ashift" - fi + log_must verify_ashift $disk2 $ashift else # cannot replace if pool prop ashift > vdev ashift log_mustnot zpool replace $TESTPOOL1 $disk1 $disk2 @@ -90,12 +85,7 @@ do log_must zpool replace -o ashift=$ashift $TESTPOOL1 \ $disk1 $disk2 wait_replacing $TESTPOOL1 - verify_ashift $disk2 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Device was replaced without " \ - "setting ashift value to $ashift" - fi + log_must verify_ashift $disk2 $ashift fi # clean things for the next run log_must zpool destroy $TESTPOOL1 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_resilver/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_resilver/Makefile.am deleted file mode 100644 index 2cec5335fbae..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_resilver/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_resilver -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_resilver_bad_args.ksh \ - zpool_resilver_restart.ksh - -dist_pkgdata_DATA = \ - zpool_resilver.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_resilver/zpool_resilver.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_resilver/zpool_resilver.cfg index 2a942d69f6d0..2b8c9e954ad7 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_resilver/zpool_resilver.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_resilver/zpool_resilver.cfg @@ -23,8 +23,7 @@ # Copyright (c) 2018 by Datto. All rights reserved. # -export DISK1=$(echo $DISKS | nawk '{print $1}') -export DISK2=$(echo $DISKS | nawk '{print $2}') -export DISK3=$(echo $DISKS | nawk '{print $3}') +read -r DISK1 DISK2 DISK3 _ <<<"$DISKS" +export DISK1 DISK2 DISK3 export MAXTIMEOUT=300 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/Makefile.am deleted file mode 100644 index e2dfd9d64c40..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_scrub -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_scrub_001_neg.ksh \ - zpool_scrub_002_pos.ksh \ - zpool_scrub_003_pos.ksh \ - zpool_scrub_004_pos.ksh \ - zpool_scrub_005_pos.ksh \ - zpool_scrub_encrypted_unloaded.ksh \ - zpool_scrub_offline_device.ksh \ - zpool_scrub_print_repairing.ksh \ - zpool_scrub_multiple_copies.ksh - -dist_pkgdata_DATA = \ - zpool_scrub.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg index fdf2f428477f..f98b1c0613f6 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg @@ -28,8 +28,8 @@ # Copyright (c) 2012, 2016 by Delphix. All rights reserved. # -export DISK1=${DISKS%% *} -export DISK2=$(echo $DISKS | awk '{print $2}') +read -r DISK1 DISK2 _ <<<"$DISKS" +export DISK1 DISK2 export ZFS_SCAN_VDEV_LIMIT_SLOW=$((128*1024)) export ZFS_SCAN_VDEV_LIMIT_DEFAULT=$((4*1024*1024)) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_set/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_set/Makefile.am deleted file mode 100644 index 916e8bb8d20e..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_set/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_set -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_set_001_pos.ksh \ - zpool_set_002_neg.ksh \ - zpool_set_003_neg.ksh \ - zpool_set_ashift.ksh \ - zpool_set_features.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_set/zpool_set_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_set/zpool_set_001_pos.ksh index f08fdfab7fd6..6e4e6be6a18e 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_set/zpool_set_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_set/zpool_set_001_pos.ksh @@ -51,7 +51,7 @@ then log_fail "\"zpool set\" exit status $RET should be equal to 2." fi -OUTPUT=$(zpool set 2>&1 | grep -i usage) +zpool set 2>&1 | grep -qi usage if [ $? != 0 ] then log_fail "Usage message for zpool set did not contain the word 'usage'." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/Makefile.am deleted file mode 100644 index aac5e0d6e7b1..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_split - -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - zpool_split_cliargs.ksh \ - zpool_split_devices.ksh \ - zpool_split_encryption.ksh \ - zpool_split_props.ksh \ - zpool_split_vdevs.ksh \ - zpool_split_resilver.ksh \ - zpool_split_wholedisk.ksh \ - zpool_split_indirect.ksh \ - zpool_split_dryrun_output.ksh - -dist_pkgdata_DATA = \ - zpool_split.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split.cfg index 5833a420c87c..a441a7dff0d6 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split.cfg @@ -14,5 +14,5 @@ # export DISKSARRAY=$DISKS -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') set_device_dir diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_devices.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_devices.ksh index d64c30d5c561..83b12ab784cd 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_devices.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_devices.ksh @@ -33,7 +33,7 @@ function cleanup { destroy_pool $TESTPOOL destroy_pool $TESTPOOL2 - rm -f $FILEDEV_PREFIX* + rm -fd $FILEDEV_PREFIX* $altroot } function setup_mirror # diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_indirect.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_indirect.ksh index 13f0d08b7f20..e6e5d245793f 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_indirect.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_indirect.ksh @@ -43,7 +43,7 @@ function cleanup if poolexists $TESTPOOL2 ; then destroy_pool $TESTPOOL2 fi - rm -f $VDEV_TEMP $VDEV_M1 $VDEV_M2 + rm -fd $VDEV_TEMP $VDEV_M1 $VDEV_M2 $altroot } log_onexit cleanup @@ -64,6 +64,6 @@ log_must zpool remove $TESTPOOL $VDEV_TEMP log_must wait_for_removal $TESTPOOL log_must zpool split -R $altroot $TESTPOOL $TESTPOOL2 log_must poolexists $TESTPOOL2 -log_must test "$(get_pool_prop 'altroot' $TESTPOOL2)" == "$altroot" +log_must test "$(get_pool_prop 'altroot' $TESTPOOL2)" = "$altroot" log_pass "'zpool split' works on pools with indirect VDEVs." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_props.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_props.ksh index 1aff8d31d91c..39ae1c9d56f9 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_props.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_props.ksh @@ -71,12 +71,11 @@ fi # Verify we can set a combination of valid property values on the new pool for prop in "${good_props[@]}" do - propname="$(awk -F= '{print $1}' <<< $prop)" - propval="$(awk -F= '{print $2}' <<< $prop)" + IFS='=' read -r propname propval <<<"$prop" setup_mirror log_must zpool split -o $prop $TESTPOOL $TESTPOOL2 log_must zpool import -N -d $TEST_BASE_DIR $TESTPOOL2 - log_must test "$(get_pool_prop $propname $TESTPOOL2)" == "$propval" + log_must test "$(get_pool_prop $propname $TESTPOOL2)" = "$propval" destroy_pool $TESTPOOL destroy_pool $TESTPOOL2 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh index 9866cf7a5a58..fff98cf83e84 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh @@ -33,7 +33,7 @@ function cleanup { destroy_pool $TESTPOOL destroy_pool $TESTPOOL2 - rm -f $FILEDEV_PREFIX* + rm -fd $FILEDEV_PREFIX* $altroot } # @@ -122,7 +122,7 @@ typeset altroot="$TESTDIR/altroot-$TESTPOOL2" for config in "${goodconfs[@]}" do create_config="${config%% *}" - add_config="$(awk '{$1= "";print $0}' <<< $config)" + add_config="$(awk '{$1=""; print $0}' <<< $config)" log_must zpool create $TESTPOOL $(pool_config $create_config) for vdev in $add_config; do log_must zpool add -f $TESTPOOL $(pool_config $vdev) @@ -137,7 +137,7 @@ done for config in "${badconfs[@]}" do create_config="${config%% *}" - add_config="$(awk '{$1= "";print $0}' <<< $config)" + add_config="$(awk '{$1=""; print $0}' <<< $config)" log_must zpool create $TESTPOOL $(pool_config $create_config) for vdev in $add_config; do log_must zpool add -f $TESTPOOL $(pool_config $vdev) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_wholedisk.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_wholedisk.ksh index 085856c428ad..0725b77a3db2 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_wholedisk.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_wholedisk.ksh @@ -44,7 +44,7 @@ function cleanup destroy_pool $TESTPOOL destroy_pool $TESTPOOL2 unload_scsi_debug - rm -f "$FILE_DEVICE" + rm -fd "$FILE_DEVICE" "$ALTROOT" } function setup_mirror diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_status/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_status/Makefile.am deleted file mode 100644 index 5553061c67b3..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_status/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_status -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_status_001_pos.ksh \ - zpool_status_002_pos.ksh \ - zpool_status_features_001_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_003_pos.ksh new file mode 100755 index 000000000000..e0c2ed669e32 --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_003_pos.ksh @@ -0,0 +1,70 @@ +#!/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) 2019, Delphix. All rights reserved. +# Copyright (c) 2021, George Amanakis. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Verify correct output with 'zpool status -v' after corrupting a file +# +# STRATEGY: +# 1. Create a pool and a file +# 2. zinject checksum errors +# 3. Read the file +# 4. Take a snapshot and make a clone +# 5. Verify we see "snapshot, clone and filesystem" output in 'zpool status -v' + +function cleanup +{ + log_must zinject -c all + datasetexists $TESTPOOL2 && log_must zpool destroy $TESTPOOL2 + rm -f $TESTDIR/vdev_a +} + +verify_runnable "both" + +log_assert "Verify correct 'zpool status -v' output with a corrupted file" +log_onexit cleanup + +truncate -s $MINVDEVSIZE $TESTDIR/vdev_a +log_must zpool create -f $TESTPOOL2 $TESTDIR/vdev_a + +log_must fio --rw=write --name=job --size=10M --filename=/$TESTPOOL2/10m_file +log_must zinject -t data -e checksum -f 100 -am /$TESTPOOL2/10m_file + +# Try to read the 2nd megabyte of 10m_file +dd if=/$TESTPOOL2/10m_file bs=1M || true + +log_must zfs snapshot $TESTPOOL2@snap +log_must zfs clone $TESTPOOL2@snap $TESTPOOL2/clone + +# Look to see that snapshot, clone and filesystem our files report errors +log_must eval "zpool status -v | grep '$TESTPOOL2@snap:/10m_file'" +log_must eval "zpool status -v | grep '$TESTPOOL2/clone/10m_file'" +log_must eval "zpool status -v | grep '$TESTPOOL2/10m_file'" + +log_pass "'zpool status -v' outputs affected filesystem, snapshot & clone" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_004_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_004_pos.ksh new file mode 100755 index 000000000000..6d8571950eec --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_004_pos.ksh @@ -0,0 +1,81 @@ +#!/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) 2019, by Delphix. All rights reserved. +# Copyright (c) 2021, George Amanakis. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Verify feature@head_errlog=disabled works. +# +# STRATEGY: +# 1. Create a pool with feature@head_errlog=disabled and a file +# 2. zinject checksum errors +# 3. Read the file +# 4. Take a snapshot and make a clone +# 5. Verify that zpool status displays the old behaviour. + +function cleanup +{ + log_must zinject -c all + datasetexists $TESTPOOL2 && log_must zpool destroy $TESTPOOL2 + rm -f $TESTDIR/vdev_a +} + +verify_runnable "both" + +log_assert "Verify 'zpool status -v' with feature@head_errlog=disabled works" +log_onexit cleanup + +truncate -s $MINVDEVSIZE $TESTDIR/vdev_a +log_must zpool create -f -o feature@head_errlog=disabled $TESTPOOL2 $TESTDIR/vdev_a + +state=$(zpool list -Ho feature@head_errlog $TESTPOOL2) +if [[ "$state" != "disabled" ]]; then + log_fail "head_errlog has state $state" +fi + +log_must fio --rw=write --name=job --size=10M --filename=/$TESTPOOL2/10m_file +log_must zinject -t data -e checksum -f 100 -am /$TESTPOOL2/10m_file + +# Try to read the file +dd if=/$TESTPOOL2/10m_file bs=1M || true + +log_must zfs snapshot $TESTPOOL2@snap +log_must zfs clone $TESTPOOL2@snap $TESTPOOL2/clone + +# Check that snapshot and clone do not report the error. +log_mustnot eval "zpool status -v | grep '$TESTPOOL2@snap:/10m_file'" +log_mustnot eval "zpool status -v | grep '$TESTPOOL2/clone/10m_file'" +log_must eval "zpool status -v | grep '$TESTPOOL2/10m_file'" + +# Check that enabling the feature reports the error properly. +log_must zpool set feature@head_errlog=enabled $TESTPOOL2 +log_must eval "zpool status -v | grep '$TESTPOOL2@snap:/10m_file'" +log_must eval "zpool status -v | grep '$TESTPOOL2/clone/10m_file'" +log_must eval "zpool status -v | grep '$TESTPOOL2/10m_file'" + +log_pass "'zpool status -v' with feature@head_errlog=disabled works" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_sync/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_sync/Makefile.am deleted file mode 100644 index 7f5f67d1f343..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_sync/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_sync -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - zpool_sync_001_pos.ksh \ - zpool_sync_002_neg.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_trim/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_trim/Makefile.am deleted file mode 100644 index 0411ab4e0070..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_trim/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_trim -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_trim_attach_detach_add_remove.ksh \ - zpool_trim_fault_export_import_online.ksh \ - zpool_trim_import_export.ksh \ - zpool_trim_multiple.ksh \ - zpool_trim_neg.ksh \ - zpool_trim_offline_export_import_online.ksh \ - zpool_trim_online_offline.ksh \ - zpool_trim_partial.ksh \ - zpool_trim_rate.ksh \ - zpool_trim_rate_neg.ksh \ - zpool_trim_secure.ksh \ - zpool_trim_split.ksh \ - zpool_trim_start_and_cancel_neg.ksh \ - zpool_trim_start_and_cancel_pos.ksh \ - zpool_trim_suspend_resume.ksh \ - zpool_trim_unsupported_vdevs.ksh \ - zpool_trim_verify_checksums.ksh \ - zpool_trim_verify_trimmed.ksh - -dist_pkgdata_DATA = \ - zpool_trim.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/Makefile.am deleted file mode 100644 index c7f321a2f61d..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -SUBDIRS = blockfiles - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_upgrade -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_upgrade_001_pos.ksh \ - zpool_upgrade_002_pos.ksh \ - zpool_upgrade_003_pos.ksh \ - zpool_upgrade_004_pos.ksh \ - zpool_upgrade_005_neg.ksh \ - zpool_upgrade_006_neg.ksh \ - zpool_upgrade_007_pos.ksh \ - zpool_upgrade_008_pos.ksh \ - zpool_upgrade_009_neg.ksh \ - zpool_upgrade_features_001_pos.ksh - -dist_pkgdata_DATA = \ - zpool_upgrade.cfg \ - zpool_upgrade.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/blockfiles/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/blockfiles/Makefile.am deleted file mode 100644 index ce8da278e9f0..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/blockfiles/Makefile.am +++ /dev/null @@ -1,54 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_upgrade/blockfiles -dist_pkgdata_DATA = \ - zfs-broken-mirror1.dat.bz2 \ - zfs-broken-mirror2.dat.bz2 \ - zfs-pool-v1.dat.bz2 \ - zfs-pool-v10.dat.bz2 \ - zfs-pool-v11.dat.bz2 \ - zfs-pool-v12.dat.bz2 \ - zfs-pool-v13.dat.bz2 \ - zfs-pool-v14.dat.bz2 \ - zfs-pool-v15.dat.bz2 \ - zfs-pool-v1mirror1.dat.bz2 \ - zfs-pool-v1mirror2.dat.bz2 \ - zfs-pool-v1mirror3.dat.bz2 \ - zfs-pool-v1raidz1.dat.bz2 \ - zfs-pool-v1raidz2.dat.bz2 \ - zfs-pool-v1raidz3.dat.bz2 \ - zfs-pool-v1stripe1.dat.bz2 \ - zfs-pool-v1stripe2.dat.bz2 \ - zfs-pool-v1stripe3.dat.bz2 \ - zfs-pool-v2.dat.bz2 \ - zfs-pool-v2mirror1.dat.bz2 \ - zfs-pool-v2mirror2.dat.bz2 \ - zfs-pool-v2mirror3.dat.bz2 \ - zfs-pool-v2raidz1.dat.bz2 \ - zfs-pool-v2raidz2.dat.bz2 \ - zfs-pool-v2raidz3.dat.bz2 \ - zfs-pool-v2stripe1.dat.bz2 \ - zfs-pool-v2stripe2.dat.bz2 \ - zfs-pool-v2stripe3.dat.bz2 \ - zfs-pool-v3.dat.bz2 \ - zfs-pool-v3hotspare1.dat.bz2 \ - zfs-pool-v3hotspare2.dat.bz2 \ - zfs-pool-v3hotspare3.dat.bz2 \ - zfs-pool-v3mirror1.dat.bz2 \ - zfs-pool-v3mirror2.dat.bz2 \ - zfs-pool-v3mirror3.dat.bz2 \ - zfs-pool-v3raidz1.dat.bz2 \ - zfs-pool-v3raidz2.dat.bz2 \ - zfs-pool-v3raidz21.dat.bz2 \ - zfs-pool-v3raidz22.dat.bz2 \ - zfs-pool-v3raidz23.dat.bz2 \ - zfs-pool-v3raidz3.dat.bz2 \ - zfs-pool-v3stripe1.dat.bz2 \ - zfs-pool-v3stripe2.dat.bz2 \ - zfs-pool-v3stripe3.dat.bz2 \ - zfs-pool-v4.dat.bz2 \ - zfs-pool-v5.dat.bz2 \ - zfs-pool-v6.dat.bz2 \ - zfs-pool-v7.dat.bz2 \ - zfs-pool-v8.dat.bz2 \ - zfs-pool-v9.dat.bz2 \ - zfs-pool-v999.dat.bz2 \ - zfs-pool-vBROKEN.dat.bz2 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib index 783ae54e717b..0bc2cfab0470 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib @@ -132,8 +132,7 @@ function check_poolversion fi # check version using zpool upgrade - actual=$(zpool upgrade | grep $pool$ | \ - awk '{print $1}' | sed -e 's/ //g') + actual=$(zpool upgrade | awk -v p="$pool$" '$0 ~ p {gsub(/ /, "", $1); print $1}') if [[ $actual != $vers ]] ; then log_fail "$pool: zpool reported version $actual, expected $vers" fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade_008_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade_008_pos.ksh index d930919652bf..71d59b93a4ca 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade_008_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade_008_pos.ksh @@ -71,7 +71,7 @@ for ver_old in $VERSIONS; do typeset -i ver_new=$(random_int_between $ver_old $MAX_VER) create_old_pool $ver_old - log_must zpool upgrade -V $ver_new $pool_name > /dev/null + log_must eval 'zpool upgrade -V $ver_new $pool_name > /dev/null' check_poolversion $pool_name $ver_new destroy_upgraded_pool $ver_old done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_wait/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_wait/Makefile.am deleted file mode 100644 index 45ab8e3d4f18..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_wait/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_wait -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_wait_discard.ksh \ - zpool_wait_freeing.ksh \ - zpool_wait_initialize_basic.ksh \ - zpool_wait_initialize_cancel.ksh \ - zpool_wait_initialize_flag.ksh \ - zpool_wait_multiple.ksh \ - zpool_wait_no_activity.ksh \ - zpool_wait_remove.ksh \ - zpool_wait_remove_cancel.ksh \ - zpool_wait_trim_basic.ksh \ - zpool_wait_trim_cancel.ksh \ - zpool_wait_trim_flag.ksh \ - zpool_wait_usage.ksh - -dist_pkgdata_DATA = \ - zpool_wait.kshlib - -SUBDIRS = scan diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_wait/scan/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_wait/scan/Makefile.am deleted file mode 100644 index 451d83a79aa6..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_wait/scan/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_wait/scan -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_wait_replace.ksh \ - zpool_wait_replace_cancel.ksh \ - zpool_wait_rebuild.ksh \ - zpool_wait_resilver.ksh \ - zpool_wait_scrub_basic.ksh \ - zpool_wait_scrub_cancel.ksh \ - zpool_wait_scrub_flag.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_wait/zpool_wait.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_wait/zpool_wait.kshlib index b413f6e9f98d..ccb97914968a 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_wait/zpool_wait.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_wait/zpool_wait.kshlib @@ -120,5 +120,5 @@ function check_while_waiting # Whether any vdev in the given pool is initializing function is_vdev_initializing # pool { - zpool status -i "$1" | grep 'initialized, started' >/dev/null + zpool status -i "$1" | grep -q 'initialized, started' } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/Makefile.am deleted file mode 100644 index 119f8ee187f6..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -SUBDIRS = \ - misc \ - zfs_list \ - zpool_iostat \ - zpool_list \ - zpool_status diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/Makefile.am deleted file mode 100644 index 2d38e65777f7..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/Makefile.am +++ /dev/null @@ -1,52 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_user/misc -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zdb_001_neg.ksh \ - zfs_001_neg.ksh \ - zfs_allow_001_neg.ksh \ - zfs_clone_001_neg.ksh \ - zfs_create_001_neg.ksh \ - zfs_destroy_001_neg.ksh \ - zfs_get_001_neg.ksh \ - zfs_inherit_001_neg.ksh \ - zfs_mount_001_neg.ksh \ - zfs_promote_001_neg.ksh \ - zfs_receive_001_neg.ksh \ - zfs_rename_001_neg.ksh \ - zfs_rollback_001_neg.ksh \ - zfs_send_001_neg.ksh \ - zfs_set_001_neg.ksh \ - zfs_share_001_neg.ksh \ - zfs_snapshot_001_neg.ksh \ - zfs_unallow_001_neg.ksh \ - zfs_unmount_001_neg.ksh \ - zfs_unshare_001_neg.ksh \ - zfs_upgrade_001_neg.ksh \ - zpool_001_neg.ksh \ - zpool_add_001_neg.ksh \ - zpool_attach_001_neg.ksh \ - zpool_clear_001_neg.ksh \ - zpool_create_001_neg.ksh \ - zpool_destroy_001_neg.ksh \ - zpool_detach_001_neg.ksh \ - zpool_export_001_neg.ksh \ - zpool_get_001_neg.ksh \ - zpool_history_001_neg.ksh \ - zpool_import_001_neg.ksh \ - zpool_import_002_neg.ksh \ - zpool_offline_001_neg.ksh \ - zpool_online_001_neg.ksh \ - zpool_remove_001_neg.ksh \ - zpool_replace_001_neg.ksh \ - zpool_scrub_001_neg.ksh \ - zpool_set_001_neg.ksh \ - zpool_status_001_neg.ksh \ - zpool_upgrade_001_neg.ksh \ - arcstat_001_pos.ksh \ - arc_summary_001_pos.ksh \ - arc_summary_002_neg.ksh \ - zpool_wait_privilege.ksh - -dist_pkgdata_DATA = \ - misc.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_001_pos.ksh index befbea986e1b..5c3d06f228ce 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_001_pos.ksh @@ -27,34 +27,15 @@ . $STF_SUITE/include/libtest.shlib -log_assert "arc_summary generates output and doesn't return an error code" +is_freebsd && ! python3 -c 'import sysctl' 2>/dev/null && log_unsupported "python3 sysctl module missing" -# Depending on which version of arc_summary is installed some command -# line options may not be available. The python3 version includes -# several additional flags. -python3 -V 2>&1 > /dev/null -if (( $? )); then - # Some systems have Python 3 installed, but only older versions - # that don't have the subprocess.run() functionality. We catch - # these with a separate test. Remove this when all systems have - # reached 3.5 or greater - VERSIONPYTEST=$(python3 -V) - if [[ ${VERSIONPYTEST:9:1} -lt 5 ]]; then - set -A args "" "-a" "-d" "-p 1" - else - set -A args "" "-a" "-d" "-p 1" "-g" "-s arc" "-r" - fi -else - set -A args "" "-a" "-d" "-p 1" -fi +log_assert "arc_summary generates output and doesn't return an error code" # Without this, the below checks aren't going to work the way we hope... set -o pipefail -typeset -i i=0 -while [[ $i -lt ${#args[*]} ]]; do - log_must eval "arc_summary ${args[i]} > /dev/null" - ((i = i + 1)) +for arg in "" "-a" "-d" "-p 1" "-g" "-s arc" "-r"; do + log_must eval "arc_summary $arg > /dev/null" done log_must eval "arc_summary | head > /dev/null" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_002_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_002_neg.ksh index de747fba89d1..59fe057e8ca6 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_002_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_002_neg.ksh @@ -27,11 +27,11 @@ . $STF_SUITE/include/libtest.shlib -typeset args=("-x" "-5" "-p 7" "--err" "-@") +is_freebsd && ! python3 -c 'import sysctl' 2>/dev/null && log_unsupported "python3 sysctl module missing" log_assert "arc_summary generates an error code with invalid options" -for arg in "${args[@]}"; do +for arg in "-x" "-5" "-p 7" "--err" "-@"; do log_mustnot eval "arc_summary $arg > /dev/null" done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/arcstat_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/arcstat_001_pos.ksh index ab574731fed9..af301829c196 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/arcstat_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/arcstat_001_pos.ksh @@ -1,4 +1,4 @@ -#! /bin/ksh -p +#!/bin/ksh -p # # CDDL HEADER START # @@ -27,6 +27,8 @@ . $STF_SUITE/include/libtest.shlib +is_freebsd && ! python3 -c 'import sysctl' 2>/dev/null && log_unsupported "python3 sysctl module missing" + set -A args "" "-s \",\"" "-x" "-v" \ "-f time,hit%,dh%,ph%,mh%" @@ -38,4 +40,3 @@ while [[ $i -lt ${#args[*]} ]]; do ((i = i + 1)) done log_pass "arcstat generates output and doesn't return an error code" - diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zdb_001_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zdb_001_neg.ksh index 3adfc59f51ce..490da6c8caa7 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zdb_001_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zdb_001_neg.ksh @@ -44,19 +44,13 @@ function check_zdb { - $@ > $TEST_BASE_DIR/zdb.$$ - grep "Dataset mos" $TEST_BASE_DIR/zdb.$$ - if [ $? -eq 0 ] - then - log_fail "$@ exited 0 when run as a non root user!" - fi - rm $TEST_BASE_DIR/zdb.$$ + log_mustnot eval "$* | grep -q 'Dataset mos'" } function cleanup { - rm -f $TEST_BASE_DIR/zdb_001_neg.$$.txt $TEST_BASE_DIR/zdb.$$ + rm -f $TEST_BASE_DIR/zdb_001_neg.$$.txt } verify_runnable "global" @@ -66,7 +60,7 @@ log_onexit cleanup log_must eval "zdb > $TEST_BASE_DIR/zdb_001_neg.$$.txt" # verify the output looks okay -log_must grep pool_guid $TEST_BASE_DIR/zdb_001_neg.$$.txt +log_must grep -q pool_guid $TEST_BASE_DIR/zdb_001_neg.$$.txt log_must rm $TEST_BASE_DIR/zdb_001_neg.$$.txt # we shouldn't able to run it on any dataset diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh index bfe8cf4bb29a..ec91ded976ff 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh @@ -55,6 +55,6 @@ TEMPFILE="$TEST_BASE_DIR/zfs_001_neg.$$.txt" zfs > $TEMPFILE 2>&1 log_must grep "usage: zfs command args" "$TEMPFILE" -log_must eval "awk '{if (length(\$0) > 80) exit 1}' < $TEMPFILE" +log_must awk 'length($0) > 80 {print; ++err} END {exit err}' $TEMPFILE log_pass "zfs shows a usage message when run as a user" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_allow_001_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_allow_001_neg.ksh index 56a74e4ae427..ce474657b42c 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_allow_001_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_allow_001_neg.ksh @@ -44,22 +44,15 @@ # # -# check to see if we have zfs allow -zfs 2>&1 | grep "allow" > /dev/null -if (($? != 0)) then - log_unsupported "ZFS allow not supported on this machine." -fi - log_assert "zfs allow returns an error when run as a user" log_must zfs allow $TESTPOOL/$TESTFS -log_mustnot zfs allow $(logname) create $TESTPOOL/$TESTFS +log_mustnot zfs allow $(id -un) create $TESTPOOL/$TESTFS # now verify that the above command actually did nothing by # checking for any allow output. ( if no allows are granted, # nothing should be output ) -OUTPUT=$(zfs allow $TESTPOOL/$TESTFS | grep "Local+Descendent" ) -if [ -n "$OUTPUT" ] +if zfs allow $TESTPOOL/$TESTFS | grep -q "Local+Descendent" then log_fail "zfs allow permissions were granted on $TESTPOOL/$TESTFS" fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh index 14c35b3da664..0d15c0c8e5ae 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh @@ -41,7 +41,6 @@ # 1. Attempt to share a dataset # 2. Verify the dataset was not shared. # -# verify_runnable "global" @@ -51,17 +50,11 @@ fi log_assert "zfs share returns an error when run as a user" -if is_shared $TESTDIR/unshared -then - log_fail "$TESTPOOL/$TESTFS/unshared was incorrectly shared initially!" -fi +log_mustnot is_shared $TESTDIR/unshared log_mustnot zfs share $TESTPOOL/$TESTFS/unshared # Now verify that the above command didn't actually do anything -if is_shared $TESTDIR/unshared -then - log_fail "$TESTPOOL/$TESTFS/unshared was actually shared!" -fi +log_mustnot is_shared $TESTDIR/unshared log_pass "zfs share returns an error when run as a user" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unallow_001_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unallow_001_neg.ksh index 98383a08762e..604887f6a2d8 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unallow_001_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unallow_001_neg.ksh @@ -43,19 +43,12 @@ # # -# check to see if we have zfs unallow -zfs 2>&1 | grep "unallow" > /dev/null -if (($? != 0)) then - log_unsupported "ZFS unallow not supported on this machine." -fi - log_assert "zfs unallow returns an error when run as a user" log_mustnot zfs unallow everyone $TESTPOOL/$TESTFS/allowed # now check with zfs allow to see if the permissions are still there -OUTPUT=$(zfs allow $TESTPOOL/$TESTFS/allowed | grep "Local+Descendent" ) -if [ -z "$OUTPUT" ] +if ! zfs allow $TESTPOOL/$TESTFS/allowed | grep -q "Local+Descendent" then log_fail "Error - create permissions were unallowed on \ $TESTPOOL/$TESTFS/allowed" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh index 7ae86fc4ec76..62b5bf39f43c 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh @@ -52,17 +52,13 @@ fi log_assert "zfs unshare returns an error when run as a user" # verify that the filesystem was shared initially -if not_shared $TESTDIR/shared -then - log_fail "$TESTPOOL/$TESTFS/shared was not shared initially at all!" -fi +log_mustnot not_shared $TESTDIR/shared +log_fail "$TESTPOOL/$TESTFS/shared was not shared initially at all!" log_mustnot zfs unshare $TESTPOOL/$TESTFS/shared # now verify that the above command didn't do anything -if not_shared $TESTDIR/shared -then - log_fail "$TESTPOOL/$TESTFS/shared was actually unshared!" -fi +log_mustnot not_shared $TESTDIR/shared +log_fail "$TESTPOOL/$TESTFS/shared was actually unshared!" log_pass "zfs unshare returns an error when run as a user" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh index 0fddc08b25db..00a86eebafe6 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh @@ -59,6 +59,6 @@ log_assert "zpool shows a usage message when run as a user" eval "zpool > $TEMPFILE 2>&1" log_must grep "usage: zpool command args" "$TEMPFILE" -log_must eval "awk '{if (length(\$0) > 80) exit 1}' < $TEMPFILE" +log_must awk '{if (length($0) > 80) exit 1}' $TEMPFILE log_pass "zpool shows a usage message when run as a user" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh index 7415cebf236b..c8abf4da58e6 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh @@ -54,12 +54,12 @@ while [[ $i -lt ${#args[*]} ]] do PROP=${props[$i]} EXPECTED=${prop_vals[$i]} - ACTUAL=$( zpool get $PROP $TESTPOOL | grep $PROP | awk '{print $1}' ) + ACTUAL=$( zpool get $PROP $TESTPOOL | awk -v p=$PROP '$0 ~ p {print $1}' ) if [ "$ACTUAL" != "$EXPECTED" ] then log_fail "Property $PROP value was $ACTUAL, expected $EXPECTED" fi - i=$(( $i + 1 )) + i=$(( $i + 1 )) done log_must zpool get all $TESTPOOL diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh index 941e20c0010e..03d01f20e959 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh @@ -59,7 +59,7 @@ do log_mustnot $POOL set $PROP=$NEW $TESTPOOL # Now verify that the above command did nothing - ACTUAL=$( zpool get $PROP $TESTPOOL | grep $PROP | awk '{print $1}' ) + ACTUAL=$( zpool get $PROP $TESTPOOL | awk -v p=$PROP '$0 ~ p {print $1}' ) if [ "$ACTUAL" != "$EXPECTED" ] then log_fail "Property $PROP was set to $ACTUAL, expected $EXPECTED" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zfs_list/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zfs_list/Makefile.am deleted file mode 100644 index 81754f401595..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zfs_list/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_user/zfs_list -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zfs_list_001_pos.ksh \ - zfs_list_002_pos.ksh \ - zfs_list_003_pos.ksh \ - zfs_list_004_neg.ksh \ - zfs_list_005_neg.ksh \ - zfs_list_007_pos.ksh \ - zfs_list_008_neg.ksh - -dist_pkgdata_DATA = \ - zfs_list.cfg \ - zfs_list.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib index 889ae46fb932..d993c3037444 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib @@ -120,7 +120,7 @@ function verify_reverse_sort { # command list name function is_fs_type_zfs { typeset dirname=$1 - typeset fs="$(df $dirname | tail -1 | awk '{print $NF}')" + typeset fs="$(df $dirname | awk 'END {print $NF}')" if is_freebsd; then fs_type=$(mount | awk -v fs=$fs '{if ($3 == fs) print $4}' \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_003_pos.ksh index 43cfd0cf2101..8e3a5680d34d 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_003_pos.ksh @@ -66,10 +66,7 @@ cd /tmp for path in $TESTPOOL/$TESTFS $TESTDIR ./../$TESTDIR ; do zfs list -rH -o name $path > $tmpfile for fs in $children ; do - grep "^${fs}$" $tmpfile > /dev/null 2>&1 - if (( $? != 0 )); then - log_fail "$fs not shown in the output list." - fi + log_must grep -qxF "$fs" $tmpfile done done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_007_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_007_pos.ksh index 8e9009bd5500..0f60113b76fe 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_007_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_007_pos.ksh @@ -37,7 +37,7 @@ # # STRATEGY: # 1. 'zfs list -d ' to get the output. -# 2. 'zfs list -r|egrep' to get the expected output. +# 2. 'zfs list -r|grep' to get the expected output. # 3. Compare the two outputs, they should be same. # @@ -50,8 +50,7 @@ fi function cleanup { - log_must rm -f $DEPTH_OUTPUT - log_must rm -f $EXPECT_OUTPUT + log_must rm -f $DEPTH_OUTPUT $EXPECT_OUTPUT } log_onexit cleanup @@ -76,10 +75,10 @@ for dp in ${depth_array[@]}; do log_must eval "zfs list -H -d $dp -o name -t ${fs_type[$fs]} $DEPTH_FS > $DEPTH_OUTPUT" [[ -s "$DEPTH_OUTPUT" ]] && \ log_fail "$DEPTH_OUTPUT should be null." - log_mustnot zfs list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | egrep -e '$eg_opt' + log_mustnot zfs list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | grep -E "$eg_opt" else log_must eval "zfs list -H -d $dp -o name -t ${fs_type[$fs]} $DEPTH_FS > $DEPTH_OUTPUT" - log_must eval "zfs list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | egrep -e '$eg_opt' > $EXPECT_OUTPUT" + log_must eval "zfs list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | grep -E '$eg_opt' > $EXPECT_OUTPUT" log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT fi (( fs+=1 )) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/Makefile.am deleted file mode 100644 index 5ee30eafc358..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_user/zpool_iostat -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_iostat_001_neg.ksh \ - zpool_iostat_002_pos.ksh \ - zpool_iostat_003_neg.ksh \ - zpool_iostat_004_pos.ksh \ - zpool_iostat_005_pos.ksh \ - zpool_iostat_-c_disable.ksh \ - zpool_iostat_-c_searchpath.ksh \ - zpool_iostat_-c_homedir.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_002_pos.ksh index 49be7d0701c2..333177accbe5 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_002_pos.ksh @@ -62,7 +62,7 @@ fi zpool iostat $TESTPOOL 1 4 > $tmpfile 2>&1 & sleep 4 -stat_count=$(grep $TESTPOOL $tmpfile | wc -l) +stat_count=$(grep -c $TESTPOOL $tmpfile) if [[ $stat_count -ne 4 ]]; then log_fail "zpool iostat [pool_name] [interval] [count] failed" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zpool_list/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zpool_list/Makefile.am deleted file mode 100644 index de8cb366924d..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zpool_list/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_user/zpool_list -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_list_001_pos.ksh \ - zpool_list_002_neg.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zpool_status/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zpool_status/Makefile.am deleted file mode 100644 index e1b339657749..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_user/zpool_status/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_user/zpool_status -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - zpool_status_003_pos.ksh \ - zpool_status_-c_disable.ksh \ - zpool_status_-c_homedir.ksh \ - zpool_status_-c_searchpath.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/Makefile.am deleted file mode 100644 index 817bd41e8075..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/compression -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - compress_001_pos.ksh \ - compress_002_pos.ksh \ - compress_003_pos.ksh \ - compress_004_pos.ksh \ - compress_zstd_bswap.ksh \ - l2arc_compressed_arc.ksh \ - l2arc_compressed_arc_disabled.ksh \ - l2arc_encrypted.ksh \ - l2arc_encrypted_no_compressed_arc.ksh - -dist_pkgdata_DATA = \ - compress.cfg \ - testpool_zstd.tar.gz diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/compress_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/compress_001_pos.ksh index fe3a3acacc04..fb3bae3b6725 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/compress_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/compress_001_pos.ksh @@ -60,8 +60,8 @@ log_must file_write -o $OP -f $TESTDIR/$TESTFILE1 -b $BLOCKSZ \ sleep 60 -FILE0_BLKS=`du -k $TESTDIR/$TESTFILE0 | awk '{ print $1}'` -FILE1_BLKS=`du -k $TESTDIR/$TESTFILE1 | awk '{ print $1}'` +FILE0_BLKS=`du -k $TESTDIR/$TESTFILE0 | awk '{print $1}'` +FILE1_BLKS=`du -k $TESTDIR/$TESTFILE1 | awk '{print $1}'` if [[ $FILE0_BLKS -le $FILE1_BLKS ]]; then log_fail "$TESTFILE0 is smaller than $TESTFILE1" \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/compress_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/compress_002_pos.ksh index a07d70824042..e7c6d6c6e57e 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/compress_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/compress_002_pos.ksh @@ -65,8 +65,8 @@ log_must file_write -o $OP -f $TESTDIR1/$TESTFILE1 -b $BLOCKSZ \ sleep 60 -FILE0_BLKS=`du -k $TESTDIR1/$TESTFILE0 | awk '{ print $1}'` -FILE1_BLKS=`du -k $TESTDIR1/$TESTFILE1 | awk '{ print $1}'` +FILE0_BLKS=`du -k $TESTDIR1/$TESTFILE0 | awk '{print $1}'` +FILE1_BLKS=`du -k $TESTDIR1/$TESTFILE1 | awk '{print $1}'` if [[ $FILE0_BLKS -le $FILE1_BLKS ]]; then log_fail "$TESTFILE0 is smaller than $TESTFILE1" \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc.ksh index 5980ce156934..57f6b6a0242b 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc.ksh @@ -52,6 +52,8 @@ export DIRECT=1 verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "L2ARC with compressed_arc enabled succeeds." origin_carc_setting=$(get_tunable COMPRESSED_ARC_ENABLED) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc_disabled.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc_disabled.ksh index 4c3b6a61c25f..c8f4111744eb 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc_disabled.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc_disabled.ksh @@ -52,6 +52,8 @@ export DIRECT=1 verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "L2ARC with compressed_arc disabled succeeds." origin_carc_setting=$(get_tunable COMPRESSED_ARC_ENABLED) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/l2arc_encrypted.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/l2arc_encrypted.ksh index fb460daf6837..f7b8a4b950d5 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/l2arc_encrypted.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/l2arc_encrypted.ksh @@ -53,6 +53,8 @@ export DIRECT=1 verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "L2ARC with encryption enabled succeeds." origin_carc_setting=$(get_tunable COMPRESSED_ARC_ENABLED) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/l2arc_encrypted_no_compressed_arc.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/l2arc_encrypted_no_compressed_arc.ksh index 45ef489c3145..0838b2c93e68 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/l2arc_encrypted_no_compressed_arc.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/compression/l2arc_encrypted_no_compressed_arc.ksh @@ -53,6 +53,8 @@ export DIRECT=1 verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "L2ARC with compressed_arc disabled succeeds." origin_carc_setting=$(get_tunable COMPRESSED_ARC_ENABLED) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cp_files/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cp_files/.gitignore deleted file mode 100644 index eac05e155378..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cp_files/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/cp_files diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cp_files/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cp_files/Makefile.am deleted file mode 100644 index 06c31f5f3f92..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cp_files/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cp_files - -dist_pkgdata_SCRIPTS = \ - cp_files_001_pos.ksh \ - cleanup.ksh \ - setup.ksh - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cp_files - -pkgexec_PROGRAMS = cp_files -cp_files_SOURCES= cp_files.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cp_files/cp_files_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cp_files/cp_files_001_pos.ksh index 3e138cfc9f72..3a814ca3621f 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cp_files/cp_files_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cp_files/cp_files_001_pos.ksh @@ -55,10 +55,9 @@ log_onexit cleanup NR_FILES=60000 BATCH=1000 -log_must mkdir $TESTDIR/src -log_must mkdir $TESTDIR/dst +log_must mkdir $TESTDIR/src $TESTDIR/dst -WD=$(pwd) +WD=$PWD cd $TESTDIR/src # create NR_FILES in BATCH at a time to prevent overflowing argument buffer for i in $(seq $(($NR_FILES/$BATCH))); do touch $(seq $((($i-1)*$BATCH+1)) $(($i*$BATCH))); done @@ -67,7 +66,7 @@ cd $WD log_must test $NR_FILES -eq $(ls -U $TESTDIR/src | wc -l) # copy files from src to dst, use cp_files to make sure we copy in readdir order -log_must $STF_SUITE/tests/functional/cp_files/cp_files $TESTDIR/src $TESTDIR/dst +log_must cp_files $TESTDIR/src $TESTDIR/dst log_must test $NR_FILES -eq $(ls -U $TESTDIR/dst | wc -l) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/crtime/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/crtime/Makefile.am deleted file mode 100644 index 13e1c2dde31b..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/crtime/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/crtime -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - crtime_001_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/ctime/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/ctime/.gitignore deleted file mode 100644 index 9e4539d5fee0..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/ctime/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/ctime diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/ctime/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/ctime/Makefile.am deleted file mode 100644 index e7479ae81056..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/ctime/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/ctime - -dist_pkgdata_SCRIPTS = \ - ctime_001_pos.ksh \ - cleanup.ksh \ - setup.ksh - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/ctime - -pkgexec_PROGRAMS = ctime -ctime_SOURCES = ctime.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/ctime/ctime_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/ctime/ctime_001_pos.ksh index de12efe46bc0..035785772db4 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/ctime/ctime_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/ctime/ctime_001_pos.ksh @@ -38,7 +38,7 @@ log_note "Verify [acm]time is modified appropriately." for arg in ${args[*]}; do log_note "Testing with xattr set to $arg" log_must zfs set xattr=$arg $TESTPOOL - log_must $STF_SUITE/tests/functional/ctime/ctime + log_must ctime done log_pass "PASS" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/deadman/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/deadman/Makefile.am deleted file mode 100644 index 097f23e88404..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/deadman/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/deadman -dist_pkgdata_SCRIPTS = \ - deadman_ratelimit.ksh \ - deadman_sync.ksh \ - deadman_zio.ksh - -dist_pkgdata_DATA = \ - deadman.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/delegate/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/delegate/Makefile.am deleted file mode 100644 index c33da3374d88..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/delegate/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/delegate -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - zfs_allow_001_pos.ksh \ - zfs_allow_002_pos.ksh \ - zfs_allow_003_pos.ksh \ - zfs_allow_004_pos.ksh \ - zfs_allow_005_pos.ksh \ - zfs_allow_006_pos.ksh \ - zfs_allow_007_pos.ksh \ - zfs_allow_008_pos.ksh \ - zfs_allow_009_neg.ksh \ - zfs_allow_010_pos.ksh \ - zfs_allow_011_neg.ksh \ - zfs_allow_012_neg.ksh \ - zfs_unallow_001_pos.ksh \ - zfs_unallow_002_pos.ksh \ - zfs_unallow_003_pos.ksh \ - zfs_unallow_004_pos.ksh \ - zfs_unallow_005_pos.ksh \ - zfs_unallow_006_pos.ksh \ - zfs_unallow_007_neg.ksh \ - zfs_unallow_008_neg.ksh - -dist_pkgdata_DATA = \ - delegate.cfg \ - delegate_common.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib index a78b390aa18e..90045f0b3e55 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib @@ -161,38 +161,29 @@ function common_perm typeset perm=$2 typeset dtst=$3 - typeset -i ret=1 case $perm in send) verify_send $user $perm $dtst - ret=$? ;; allow) verify_allow $user $perm $dtst - ret=$? ;; userprop) verify_userprop $user $perm $dtst - ret=$? ;; compression|checksum|readonly) verify_ccr $user $perm $dtst - ret=$? ;; copies) verify_copies $user $perm $dtst - ret=$? ;; reservation) verify_reservation $user $perm $dtst - ret=$? ;; *) - ret=1 + return 1 ;; esac - - return $ret } function check_fs_perm @@ -201,99 +192,74 @@ function check_fs_perm typeset perm=$2 typeset fs=$3 - typeset -i ret=1 case $perm in create) verify_fs_create $user $perm $fs - ret=$? ;; destroy) verify_fs_destroy $user $perm $fs - ret=$? ;; snapshot) verify_fs_snapshot $user $perm $fs - ret=$? ;; rollback) verify_fs_rollback $user $perm $fs - ret=$? ;; clone) verify_fs_clone $user $perm $fs - ret=$? ;; rename) verify_fs_rename $user $perm $fs - ret=$? ;; mount) verify_fs_mount $user $perm $fs - ret=$? ;; share) verify_fs_share $user $perm $fs - ret=$? ;; mountpoint) verify_fs_mountpoint $user $perm $fs - ret=$? ;; promote) verify_fs_promote $user $perm $fs - ret=$? ;; canmount) verify_fs_canmount $user $perm $fs - ret=$? ;; dnodesize) verify_fs_dnodesize $user $perm $fs - ret=$? ;; recordsize) verify_fs_recordsize $user $perm $fs - ret=$? ;; quota) verify_fs_quota $user $perm $fs - ret=$? ;; aclmode) verify_fs_aclmode $user $perm $fs - ret=$? ;; aclinherit) verify_fs_aclinherit $user $perm $fs - ret=$? ;; snapdir) verify_fs_snapdir $user $perm $fs - ret=$? ;; atime|exec|devices|setuid|xattr) verify_fs_aedsx $user $perm $fs - ret=$? ;; zoned) verify_fs_zoned $user $perm $fs - ret=$? ;; sharenfs) verify_fs_sharenfs $user $perm $fs - ret=$? ;; receive) verify_fs_receive $user $perm $fs - ret=$? ;; *) common_perm $user $perm $fs - ret=$? ;; esac - - return $ret } function check_vol_perm @@ -302,43 +268,32 @@ function check_vol_perm typeset perm=$2 typeset vol=$3 - typeset -i ret=1 case $perm in destroy) verify_vol_destroy $user $perm $vol - ret=$? ;; snapshot) verify_vol_snapshot $user $perm $vol - ret=$? ;; rollback) verify_vol_rollback $user $perm $vol - ret=$? ;; clone) verify_vol_clone $user $perm $vol - ret=$? ;; rename) verify_vol_rename $user $perm $vol - ret=$? ;; promote) verify_vol_promote $user $perm $vol - ret=$? ;; volsize) verify_vol_volsize $user $perm $vol - ret=$? ;; *) common_perm $user $perm $vol - ret=$? ;; esac - - return $ret } function setup_unallow_testenv @@ -362,8 +317,6 @@ function setup_unallow_testenv log_must verify_perm $SUBFS $LOCAL_DESC_SET $OTHER2 fi done - - return 0 } # @@ -391,12 +344,11 @@ function verify_send user_run $user eval "zfs send $snap > $bak_user" log_must eval "zfs send $snap > $bak_root" - if [[ $(checksum $bak_user) == $(checksum $bak_root) ]]; then + if [ "$(cksum < $bak_user)" = "$(cksum < $bak_root)" ]; then ret=0 fi - rm -rf $bak_user > /dev/null - rm -rf $bak_root > /dev/null + rm -rf $bak_user $bak_root return $ret } @@ -462,12 +414,11 @@ function verify_fs_receive log_must eval "zfs receive $dtst < $bak_root" log_must eval "zfs send $dtstsnap > $bak_root" log_must_busy zfs destroy -rf $dtst - if [[ $(checksum $bak_user) != $(checksum $bak_root) ]]; then + if [ "$(cksum < $bak_user)" != "$(cksum < $bak_root)" ]; then return 1 fi - rm -rf $bak_user > /dev/null - rm -rf $bak_root > /dev/null + rm -rf $bak_user $bak_root done @@ -1694,20 +1645,12 @@ function verify_allow typeset -i ret - user_run $user zfs allow $user allow $dtst - ret=$? - if [[ $ret -eq 0 ]]; then - return 1 - fi + user_run $user zfs allow $user allow $dtst && return 1 log_must zfs allow $user copies $dtst user_run $user zfs allow $user copies $dtst ret=$? log_must zfs unallow $user copies $dtst - if [[ $ret -eq 1 ]]; then - return 1 - fi - - return 0 + [ $ret -ne 1 ] } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/delegate/setup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/delegate/setup.ksh index 2f13da750436..d783b417346a 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/delegate/setup.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/delegate/setup.ksh @@ -68,10 +68,8 @@ log_must add_user $OTHER_GROUP $OTHER2 # # chmod 0750 $HOME # -user_run $STAFF1 zfs list -if [ $? -ne 0 ]; then +user_run $STAFF1 zfs list || log_unsupported "Test user $STAFF1 cannot execute zfs utilities" -fi DISK=${DISKS%% *} diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/delegate/zfs_allow_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/delegate/zfs_allow_001_pos.ksh index 1e0ed80d3203..22e52ccc90b7 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/delegate/zfs_allow_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/delegate/zfs_allow_001_pos.ksh @@ -57,7 +57,7 @@ function cleanup restore_root_datasets } -log_assert "everyone' is interpreted as a keyword even if a user " \ +log_assert "'everyone' is interpreted as a keyword even if a user " \ "or group named 'everyone' exists." log_onexit cleanup @@ -79,9 +79,7 @@ if [[ $user_added == "TRUE" ]]; then fi log_note "Created a group called 'everyone'." -if ! cat /etc/group | awk -F: '{print $1}' | \ - grep -w 'everyone' > /dev/null 2>&1 -then +if ! grep -q '^everyone:' /etc/group; then group_added="TRUE" log_must add_group everyone fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/devices/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/devices/Makefile.am deleted file mode 100644 index 42f59428d4ca..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/devices/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/devices -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - devices_001_pos.ksh \ - devices_002_neg.ksh \ - devices_003_pos.ksh - -dist_pkgdata_DATA = \ - devices.cfg \ - devices_common.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/dos_attributes/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/dos_attributes/Makefile.am deleted file mode 100644 index 436bcdb1f31e..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/dos_attributes/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/dos_attributes -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - read_dos_attrs_001.ksh \ - write_dos_attrs_001.ksh \ - setup.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/.gitignore deleted file mode 100644 index ed5af03a1095..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zed_fd_spill-zedlet diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/Makefile.am deleted file mode 100644 index 92ce5dbc3825..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/events -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - events_001_pos.ksh \ - events_002_pos.ksh \ - zed_rc_filter.ksh \ - zed_fd_spill.ksh - -dist_pkgdata_DATA = \ - events.cfg \ - events_common.kshlib - -pkgexecdir = $(pkgdatadir) -pkgexec_PROGRAMS = zed_fd_spill-zedlet -zed_fd_spill_zedlet_SOURCES = zed_fd_spill-zedlet.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/events.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/events.cfg index 1405dab6f989..27046c1b0c6b 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/events.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/events.cfg @@ -33,6 +33,4 @@ VDEV4=$TEST_BASE_DIR/vdev4 export TMP_EVENTS=$TEST_BASE_DIR/tmp_events.$$ export TMP_EVENTS_FULL=$TEST_BASE_DIR/tmp_events_full.$$ -export TMP_EVENT_FULL=$TEST_BASE_DIR/tmp_event_full.$$ export TMP_EVENTS_ZED=$TEST_BASE_DIR/tmp_events_zed.$$ -export TMP_EVENT_ZED=$TEST_BASE_DIR/tmp_event_zed.$$ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/events_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/events_002_pos.ksh index 9407656b6e6b..42088fc0905f 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/events_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/events_002_pos.ksh @@ -42,15 +42,8 @@ verify_runnable "both" function cleanup { - if poolexists $MPOOL; then - destroy_pool $MPOOL - fi - - for file in $VDEV1 $VDEV2; do - [[ -f $file ]] && rm -f $file - done - - log_must rm -f $TMP_EVENTS_ZED + poolexists $MPOOL && log_must destroy_pool $MPOOL + log_must rm -f $VDEV1 $VDEV2 $TMP_EVENTS_ZED log_must zed_stop } @@ -69,10 +62,9 @@ log_must zed_start log_must file_wait_event $ZED_DEBUG_LOG 'sysevent\.fs\.zfs\.config_sync' 150 log_must cp $ZED_DEBUG_LOG $TMP_EVENTS_ZED -awk -v event="sysevent.fs.zfs.pool_create" \ - 'BEGIN{FS="\n"; RS=""} $0 ~ event { print $0 }' \ - $TMP_EVENTS_ZED >$TMP_EVENT_ZED -log_must grep -q "^ZEVENT_POOL=$MPOOL" $TMP_EVENT_ZED +log_mustnot awk -v event="sysevent.fs.zfs.pool_create" -v crit="\\nZEVENT_POOL=$MPOOL" \ + 'BEGIN{FS="\n"; RS=""} $0 ~ event && $0 ~ crit { exit 1 }' \ + $TMP_EVENTS_ZED # 3. Stop the ZED zed_stop diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/events_common.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/events_common.kshlib index cc600c4ed510..73bf4cf357b5 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/events_common.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/events_common.kshlib @@ -94,7 +94,7 @@ function run_and_verify pool=${pool:-$TESTPOOL} fullcmd="$1" - cmd=$(echo $fullcmd | awk '{print $1}') + read -r cmd _ <<<"$fullcmd" # If we aren't running zpool or zfs, something is wrong [[ $cmd == "zpool" || $cmd == "zfs" ]] || \ @@ -147,23 +147,20 @@ function run_and_verify log_must grep -q "$event" $TMP_EVENTS # Verify the event is in the verbose output with pool name. - awk -v event="$event" \ - 'BEGIN{FS="\n"; RS=""} $0 ~ event { print $0 }' \ - $TMP_EVENTS_FULL >$TMP_EVENT_FULL - log_must grep -q "pool = \"$pool\"" $TMP_EVENT_FULL + log_mustnot awk -v event="$event" -v crit="pool = \"$pool\"" \ + 'BEGIN{FS="\n"; RS=""} $0 ~ event && $0 ~ crit { exit 1 }' \ + $TMP_EVENTS_FULL # all-debug.sh filters history events (seen in ZED_DEBUG_LOG) - if [[ "$event" == "sysevent.fs.zfs.history_event" ]]; then + if [ "$event" = "sysevent.fs.zfs.history_event" ]; then continue fi # Verify the event was received by the ZED and logged. - awk -v event="$event" \ - 'BEGIN{FS="\n"; RS=""} $0 ~ event { print $0 }' \ - $TMP_EVENTS_ZED >$TMP_EVENT_ZED - log_must grep -q "^ZEVENT_POOL=$pool" $TMP_EVENT_ZED + log_mustnot awk -v event="$event" -v crit="\\nZEVENT_POOL=$pool" \ + 'BEGIN{FS="\n"; RS=""} $0 ~ event && $0 ~ crit { exit 1 }' \ + $TMP_EVENTS_ZED done - rm -f $TMP_EVENTS $TMP_EVENTS_FULL $TMP_EVENT_FULL \ - $TMP_EVENTS_ZED $TMP_EVENT_ZED + rm -f $TMP_EVENTS $TMP_EVENTS_FULL $TMP_EVENTS_ZED } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/zed_fd_spill.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/zed_fd_spill.ksh index 4ae136d0f36c..d70dd0c7b445 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/zed_fd_spill.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/events/zed_fd_spill.ksh @@ -48,13 +48,12 @@ logdir="$(mktemp -d)" log_must ln -s "$logdir" /tmp/zts-zed_fd_spill-logdir -self="$(readlink -f "$0")" -zedlet="${self%/*}/zed_fd_spill-zedlet" -log_must ln -s $zedlet "${ZEDLET_DIR}/all-dumpfds" +zedlet="$(command -v zed_fd_spill-zedlet)" +log_must ln -s "$zedlet" "${ZEDLET_DIR}/all-dumpfds" # zed will cry foul and refuse to run it if this isn't true -sudo chown root $zedlet -sudo chmod 700 $zedlet +sudo chown root "$zedlet" +sudo chmod 700 "$zedlet" log_must zpool events -c log_must zed_stop diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/exec/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/exec/Makefile.am deleted file mode 100644 index 524bf2734f73..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/exec/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/exec - -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - exec_001_pos.ksh \ - exec_002_neg.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/exec/exec_002_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/exec/exec_002_neg.ksh index c11bf8442bcd..2082659a3010 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/exec/exec_002_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/exec/exec_002_neg.ksh @@ -60,18 +60,12 @@ function cleanup function exec_n_check { typeset expect_value=$1 - shift - $@ - ret=$? - if [[ $ret != $expect_value ]]; then - log_fail "Unexpected return code: '$ret'" - fi - - return 0 + "$@" + log_must [ $? = $expect_value ] } -log_assert "Setting exec=off on a filesystem, processes can not be executed " \ +log_assert "Setting exec=off on a filesystem, processes can not be executed" \ "from this file system." log_onexit cleanup @@ -79,11 +73,11 @@ log_must cp $STF_PATH/ls $TESTDIR/myls log_must zfs set exec=off $TESTPOOL/$TESTFS if is_linux; then - log_must exec_n_check 126 $TESTDIR/myls - log_must exec_n_check 1 mmap_exec $TESTDIR/myls # EPERM + exp=1 # EPERM else - log_must exec_n_check 126 $TESTDIR/myls - log_must exec_n_check 13 mmap_exec $TESTDIR/myls # EACCES + exp=13 # EACCES fi +log_must exec_n_check 126 $TESTDIR/myls +log_must exec_n_check $exp mmap_exec $TESTDIR/myls log_pass "Setting exec=off on filesystem testing passed." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fallocate/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fallocate/Makefile.am deleted file mode 100644 index 5ff366d2482c..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fallocate/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/fallocate -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - fallocate_prealloc.ksh \ - fallocate_punch-hole.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fallocate/fallocate_punch-hole.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fallocate/fallocate_punch-hole.ksh index ed83561bd556..92f4552f5bd7 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fallocate/fallocate_punch-hole.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fallocate/fallocate_punch-hole.ksh @@ -60,13 +60,17 @@ function cleanup [[ -e $TESTDIR ]] && log_must rm -f $FILE } -function check_disk_size +function check_reported_size { typeset expected_size=$1 - disk_size=$(du $TESTDIR/file | awk '{print $1}') - if [ $disk_size -ne $expected_size ]; then - log_fail "Incorrect size: $disk_size != $expected_size" + if ! [ -e "${FILE}" ]; then + log_fail "$FILE does not exist" + fi + + reported_size=$(du "${FILE}" | awk '{print $1}') + if [ "$reported_size" != "$expected_size" ]; then + log_fail "Incorrect reported size: $reported_size != $expected_size" fi } @@ -74,9 +78,9 @@ function check_apparent_size { typeset expected_size=$1 - apparent_size=$(stat_size) - if [ $apparent_size -ne $expected_size ]; then - log_fail "Incorrect size: $apparent_size != $expected_size" + apparent_size=$(stat_size "${FILE}") + if [ "$apparent_size" != "$expected_size" ]; then + log_fail "Incorrect apparent size: $apparent_size != $expected_size" fi } @@ -86,25 +90,30 @@ log_onexit cleanup # Create a dense file and check it is the correct size. log_must file_write -o create -f $FILE -b $BLKSZ -c 8 -log_must check_disk_size $((131072 * 8)) +sync_pool $TESTPOOL +log_must check_reported_size 1027 # Punch a hole for the first full block. log_must punch_hole 0 $BLKSZ $FILE -log_must check_disk_size $((131072 * 7)) +sync_pool $TESTPOOL +log_must check_reported_size 899 # Partially punch a hole in the second block. log_must punch_hole $BLKSZ $((BLKSZ / 2)) $FILE -log_must check_disk_size $((131072 * 7)) +sync_pool $TESTPOOL +log_must check_reported_size 899 -# Punch a hole which overlaps the third and forth block. +# Punch a hole which overlaps the third and fourth block. log_must punch_hole $(((BLKSZ * 2) + (BLKSZ / 2))) $((BLKSZ)) $FILE -log_must check_disk_size $((131072 * 7)) +sync_pool $TESTPOOL +log_must check_reported_size 899 # Punch a hole from the fifth block past the end of file. The apparent # file size should not change since --keep-size is implied. apparent_size=$(stat_size $FILE) log_must punch_hole $((BLKSZ * 4)) $((BLKSZ * 10)) $FILE -log_must check_disk_size $((131072 * 4)) +sync_pool $TESTPOOL +log_must check_reported_size 387 log_must check_apparent_size $apparent_size log_pass "Ensure holes can be punched in files making them sparse" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fallocate/fallocate_zero-range.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fallocate/fallocate_zero-range.ksh new file mode 100755 index 000000000000..e907b0f5d4c4 --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fallocate/fallocate_zero-range.ksh @@ -0,0 +1,119 @@ +#!/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) 2020 by Lawrence Livermore National Security, LLC. +# Copyright (c) 2021 by The FreeBSD Foundation. +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# Test FALLOC_FL_ZERO_RANGE functionality +# +# STRATEGY: +# 1. Create a dense file +# 2. Zero various ranges in the file and verify the result. +# + +verify_runnable "global" + +if is_freebsd; then + log_unsupported "FreeBSD does not implement an analogue to ZERO_RANGE." +fi + +FILE=$TESTDIR/$TESTFILE0 +BLKSZ=$(get_prop recordsize $TESTPOOL) + +function cleanup +{ + [[ -e $TESTDIR ]] && log_must rm -f $FILE +} + +# Helpfully, this function expects kilobytes, and check_apparent_size expects bytes. +function check_reported_size +{ + typeset expected_size=$1 + + if ! [ -e "${FILE}" ]; then + log_fail "$FILE does not exist" + fi + + reported_size=$(du "${FILE}" | awk '{print $1}') + if [ "$reported_size" != "$expected_size" ]; then + log_fail "Incorrect reported size: $reported_size != $expected_size" + fi +} + +function check_apparent_size +{ + typeset expected_size=$1 + + apparent_size=$(stat_size "${FILE}") + if [ "$apparent_size" != "$expected_size" ]; then + log_fail "Incorrect apparent size: $apparent_size != $expected_size" + fi +} + +log_assert "Ensure ranges can be zeroed in files" + +log_onexit cleanup + +# Create a dense file and check it is the correct size. +log_must file_write -o create -f $FILE -b $BLKSZ -c 8 +sync_pool $TESTPOOL +log_must check_reported_size 1027 + +# Zero a range covering the first full block. +log_must zero_range 0 $BLKSZ $FILE +sync_pool $TESTPOOL +log_must check_reported_size 899 + +# Partially zero a range in the second block. +log_must zero_range $BLKSZ $((BLKSZ / 2)) $FILE +sync_pool $TESTPOOL +log_must check_reported_size 899 + +# Zero range which overlaps the third and fourth block. +log_must zero_range $(((BLKSZ * 2) + (BLKSZ / 2))) $((BLKSZ)) $FILE +sync_pool $TESTPOOL +log_must check_reported_size 899 + +# Zero range from the fifth block past the end of file, with --keep-size. +# The apparent file size must not change, since we did specify --keep-size. +apparent_size=$(stat_size $FILE) +log_must fallocate --keep-size --zero-range --offset $((BLKSZ * 4)) --length $((BLKSZ * 10)) "$FILE" +sync_pool $TESTPOOL +log_must check_reported_size 387 +log_must check_apparent_size $apparent_size + +# Zero range from the fifth block past the end of file. The apparent +# file size should change since --keep-size is not implied, unlike +# with PUNCH_HOLE. +apparent_size=$(stat_size $FILE) +log_must zero_range $((BLKSZ * 4)) $((BLKSZ * 10)) $FILE +sync_pool $TESTPOOL +log_must check_reported_size 387 +log_must check_apparent_size $((BLKSZ * 14)) + +log_pass "Ensure ranges can be zeroed in files" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fallocate/setup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fallocate/setup.ksh index 32334d396865..586ac026aa43 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fallocate/setup.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fallocate/setup.ksh @@ -26,4 +26,7 @@ . $STF_SUITE/include/libtest.shlib DISK=${DISKS%% *} -default_setup $DISK +default_setup_noexit $DISK +log_must zfs set compression=off $TESTPOOL +log_pass + diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/Makefile.am deleted file mode 100644 index ba0d7d6992c6..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/fault -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - auto_offline_001_pos.ksh \ - auto_online_001_pos.ksh \ - auto_online_002_pos.ksh \ - auto_replace_001_pos.ksh \ - auto_spare_001_pos.ksh \ - auto_spare_002_pos.ksh \ - auto_spare_ashift.ksh \ - auto_spare_multiple.ksh \ - auto_spare_shared.ksh \ - decrypt_fault.ksh \ - decompress_fault.ksh \ - scrub_after_resilver.ksh \ - zpool_status_-s.ksh - -dist_pkgdata_DATA = \ - fault.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/auto_offline_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/auto_offline_001_pos.ksh index ef2ce24e097b..17bde9a70636 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/auto_offline_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/auto_offline_001_pos.ksh @@ -96,8 +96,7 @@ do log_must zpool create -f $TESTPOOL $conf block_device_wait ${DEV_DSKDIR}/${removedev} - mntpnt=$(get_prop mountpoint /$TESTPOOL) || - log_fail "get_prop mountpoint /$TESTPOOL" + mntpnt=$(get_prop mountpoint /$TESTPOOL) # 2. Simulate physical removal of one device remove_disk $removedev @@ -128,8 +127,7 @@ do block_device_wait ${DEV_DSKDIR}/${removedev} log_must zpool add $TESTPOOL spare $sparedev - mntpnt=$(get_prop mountpoint /$TESTPOOL) || - log_fail "get_prop mountpoint /$TESTPOOL" + mntpnt=$(get_prop mountpoint /$TESTPOOL) # 2. Simulate physical removal of one device remove_disk $removedev @@ -161,8 +159,7 @@ do block_device_wait ${DEV_DSKDIR}/${removedev} log_must zpool add $TESTPOOL spare $sparedev - mntpnt=$(get_prop mountpoint /$TESTPOOL) || - log_fail "get_prop mountpoint /$TESTPOOL" + mntpnt=$(get_prop mountpoint /$TESTPOOL) # 2. Fault the spare device making it unavailable log_must zpool offline -f $TESTPOOL $sparedev diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh index 03fc15a8a7cb..3a1a610b8daf 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh @@ -114,10 +114,7 @@ do # Reimport pool with drive missing log_must zpool import $TESTPOOL - check_state $TESTPOOL "" "degraded" - if (($? != 0)); then - log_fail "$TESTPOOL is not degraded" - fi + log_must check_state $TESTPOOL "" "degraded" # Clear zpool events log_must zpool events -c @@ -134,9 +131,8 @@ do ((timeout++)) sleep 1 - zpool events $TESTPOOL \ - | egrep sysevent.fs.zfs.resilver_finish > /dev/null - if (($? == 0)); then + if zpool events $TESTPOOL \ + | grep -qF sysevent.fs.zfs.resilver_finish; then log_note "Auto-online of $offline_disk is complete" sleep 1 break @@ -144,10 +140,7 @@ do done # Validate auto-online was successful - check_state $TESTPOOL "" "online" - if (($? != 0)); then - log_fail "$TESTPOOL is not back online" - fi + log_must check_state $TESTPOOL "" "online" sleep 2 done log_must zpool destroy $TESTPOOL diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh index 0302c45373fa..57180cdc1860 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh @@ -72,8 +72,8 @@ echo "alias scsidebug /dev/disk/by-id/$SD_DEVICE_ID" >>$VDEVID_CONF block_device_wait SD_DEVICE=$(udevadm info -q all -n $DEV_DSKDIR/$SD | \ - awk -F'=' '/ID_VDEV=/{print $2; exit}') -[[ -z $SD_DEVICE ]] && log_fail "vdev rule was not registered properly" + awk -F'=' '/ID_VDEV=/ {print $2; exit}') +[ -z $SD_DEVICE ] && log_fail "vdev rule was not registered properly" log_must zpool events -c log_must zpool create -f $TESTPOOL raidz1 $SD_DEVICE $DISK1 $DISK2 $DISK3 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/auto_spare_shared.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/auto_spare_shared.ksh index 4229537b3953..1cfa84a930bc 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/auto_spare_shared.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/auto_spare_shared.ksh @@ -70,10 +70,7 @@ FAIL_FILEDEVPOOL2="$TEST_BASE_DIR/file-fail-dev2" SPARE_FILEDEV="$TEST_BASE_DIR/file-spare-dev" SPARE_DISKDEV="$(get_debug_device)" -for vdev in $SAFE_FILEDEVPOOL1 $SAFE_FILEDEVPOOL2 $FAIL_FILEDEVPOOL1 \ - $FAIL_FILEDEVPOOL2 $SPARE_FILEDEV; do - log_must truncate -s $MINVDEVSIZE $vdev -done +log_must truncate -s $MINVDEVSIZE $SAFE_FILEDEVPOOL1 $SAFE_FILEDEVPOOL2 $FAIL_FILEDEVPOOL1 $FAIL_FILEDEVPOOL2 $SPARE_FILEDEV for spare in $SPARE_FILEDEV $SPARE_DISKDEV; do # 1. Create two pools diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/fault.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/fault.cfg index 839330ed47dd..108406e3e171 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/fault.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/fault.cfg @@ -26,7 +26,7 @@ verify_runnable "global" -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') export DISKSARRAY=$DISKS export FSIZE=10M export MAXTIMEOUT=30 @@ -36,9 +36,8 @@ export SDHOSTS=1 export SDTGTS=1 export SDLUNS=1 -export DISK1=$(echo $DISKS | nawk '{print $1}') -export DISK2=$(echo $DISKS | nawk '{print $2}') -export DISK3=$(echo $DISKS | nawk '{print $3}') +read -r DISK1 DISK2 DISK3 _ <<<"$DISKS" +export DISK1 DISK2 DISK3 if is_linux; then set_slice_prefix diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh index a290053fd269..4fe00e2c7195 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh @@ -67,11 +67,10 @@ log_must mkfile 1048576 /$TESTPOOL/testfile sync_pool $TESTPOOL log_must zinject -c all -SLOW_IOS=$(zpool status -sp | grep "$DISK" | awk '{print $6}') -DELAY_EVENTS=$(zpool events | grep delay | wc -l) +SLOW_IOS=$(zpool status -sp | awk -v d="$DISK" '$0 ~ d {print $6}') +DELAY_EVENTS=$(zpool events | grep -c delay) -if [ $SLOW_IOS -gt 0 ] && [ $DELAY_EVENTS -gt 0 ] ; then - log_pass "Correctly saw $SLOW_IOS slow IOs and $DELAY_EVENTS delay events" -else - log_fail "Only saw $SLOW_IOS slow IOs and $DELAY_EVENTS delay events" -fi +log_must [ $SLOW_IOS -gt 0 ] +log_must [ $DELAY_EVENTS -gt 0 ] + +log_pass "Correctly saw $SLOW_IOS slow IOs and $DELAY_EVENTS delay events" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/Makefile.am deleted file mode 100644 index 3657461e6604..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIRS = \ - async_destroy \ - large_dnode diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/async_destroy/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/async_destroy/Makefile.am deleted file mode 100644 index 4c777878d689..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/async_destroy/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/features/async_destroy -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - async_destroy_001_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/large_dnode/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/large_dnode/Makefile.am deleted file mode 100644 index 13ba3ab33d9e..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/large_dnode/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/features/large_dnode -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - large_dnode_001_pos.ksh \ - large_dnode_002_pos.ksh \ - large_dnode_003_pos.ksh \ - large_dnode_004_neg.ksh \ - large_dnode_005_pos.ksh \ - large_dnode_006_pos.ksh \ - large_dnode_007_neg.ksh \ - large_dnode_008_pos.ksh \ - large_dnode_009_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh index cb1e940a7d73..c00b3b6c719a 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh @@ -73,7 +73,7 @@ log_must zfs umount $TEST_FS for ((i=0; i < ${#dnsizes[*]}; i++)) ; do dnsize=$(zdb -dddd $TEST_FS ${inodes[$i]} | - awk '/ZFS plain file/ {print $6}' | tr K k) + awk '/ZFS plain file/ {gsub(/K/, "k", $6); print $6}') if [[ "$dnsize" != "${dnsizes[$i]}" ]]; then log_fail "dnode size is $dnsize (expected ${dnsizes[$i]})" fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_005_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_005_pos.ksh index 03e2db4b8082..1d167e3ae59f 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_005_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_005_pos.ksh @@ -54,11 +54,11 @@ log_assert "zfs send stream with large dnodes accepted by new pool" log_must zfs create -o dnodesize=1k $TEST_SEND_FS log_must touch /$TEST_SEND_FS/$TEST_FILE log_must zfs snap $TEST_SNAP -log_must zfs send $TEST_SNAP > $TEST_STREAM +log_must eval "zfs send $TEST_SNAP > $TEST_STREAM" log_must rm -f /$TEST_SEND_FS/$TEST_FILE log_must touch /$TEST_SEND_FS/$TEST_FILEINCR log_must zfs snap $TEST_SNAPINCR -log_must zfs send -i $TEST_SNAP $TEST_SNAPINCR > $TEST_STREAMINCR +log_must eval "zfs send -i $TEST_SNAP $TEST_SNAPINCR > $TEST_STREAMINCR" log_must eval "zfs recv $TEST_RECV_FS < $TEST_STREAM" inode=$(ls -li /$TEST_RECV_FS/$TEST_FILE | awk '{print $1}') diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_009_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_009_pos.ksh index 1e42202069eb..0b61e1df2226 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_009_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_009_pos.ksh @@ -66,6 +66,6 @@ log_must wait log_must_busy zpool export $TESTPOOL log_must zpool import $TESTPOOL -log_must ls -lR "/$TEST_FS/" >/dev/null 2>&1 +log_must eval "ls -lR /$TEST_FS/ >/dev/null 2>&1" log_must zdb -d $TESTPOOL log_pass diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/grow/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/grow/Makefile.am deleted file mode 100644 index 807610a067d8..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/grow/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/grow -dist_pkgdata_SCRIPTS = \ - grow_pool_001_pos.ksh \ - grow_replicas_001_pos.ksh - -dist_pkgdata_DATA = \ - grow.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/Makefile.am deleted file mode 100644 index b865a319a430..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/history -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - history_001_pos.ksh \ - history_002_pos.ksh \ - history_003_pos.ksh \ - history_004_pos.ksh \ - history_005_neg.ksh \ - history_006_neg.ksh \ - history_007_pos.ksh \ - history_008_pos.ksh \ - history_009_pos.ksh \ - history_010_pos.ksh - -dist_pkgdata_DATA = \ - history.cfg \ - history_common.kshlib \ - i386.migratedpool.DAT.Z \ - i386.orig_history.txt \ - sparc.migratedpool.DAT.Z \ - sparc.orig_history.txt \ - zfs-pool-v4.dat.Z diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_001_pos.ksh index f33265185d5c..5b576b8a12aa 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_001_pos.ksh @@ -59,7 +59,6 @@ log_assert "Verify zpool sub-commands which modify state are logged." log_onexit cleanup mntpnt=$(get_prop mountpoint $TESTPOOL) -(( $? != 0)) && log_fail "get_prop($TESTPOOL mountpoint)" VDEV1=$mntpnt/vdev1; VDEV2=$mntpnt/vdev2; VDEV3=$mntpnt/vdev3; VDEV4=$mntpnt/vdev4; diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_003_pos.ksh index 46af53f8af90..1bebd4039746 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_003_pos.ksh @@ -55,7 +55,6 @@ log_assert "zpool history limitation test." log_onexit cleanup mntpnt=$(get_prop mountpoint $TESTPOOL) -(( $? != 0 )) && log_fail "get_prop mountpoint $TESTPOOL" VDEV0=$mntpnt/vdev0 log_must mkfile $MINVDEVSIZE $VDEV0 @@ -79,16 +78,16 @@ done TMPFILE=$TEST_BASE_DIR/spool.$$ zpool history $spool >$TMPFILE -typeset -i entry_count=$(wc -l $TMPFILE | awk '{print $1}') +typeset -i entry_count=$(wc -l < $TMPFILE) typeset final_md5=$(head -2 $TMPFILE | md5digest) -grep 'zpool create' $TMPFILE >/dev/null 2>&1 || +grep -q 'zpool create' $TMPFILE || log_fail "'zpool create' was not found in pool history" -grep 'zfs create' $TMPFILE >/dev/null 2>&1 && +grep -q 'zfs create' $TMPFILE && log_fail "'zfs create' was found in pool history" -grep 'zfs set compress' $TMPFILE >/dev/null 2>&1 || +grep -q 'zfs set compress' $TMPFILE || log_fail "'zfs set compress' was found in pool history" # Verify that the creation of the pool was preserved in the history. diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_004_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_004_pos.ksh index 1b8e7dfe02ec..8bdc38f26d67 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_004_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_004_pos.ksh @@ -46,7 +46,7 @@ verify_runnable "global" log_assert "'zpool history' can cope with simultaneous commands." -typeset -i orig_count=$(zpool history $spool | wc -l | awk '{print $1}') +typeset -i orig_count=$(zpool history $spool | wc -l) typeset -i i=0 while ((i < 10)); do @@ -90,7 +90,7 @@ while ((i < 10)); do ((i += 1)) done -typeset -i entry_count=$(zpool history $spool | wc -l | awk '{print $1}') +typeset -i entry_count=$(zpool history $spool | wc -l) if ((entry_count - orig_count != 200)); then log_fail "The entries count error: entry_count=$entry_count " \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_005_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_005_neg.ksh index 297a701cc567..5038af4a7c79 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_005_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_005_neg.ksh @@ -54,10 +54,10 @@ log_assert "Verify 'zpool get|history|list|status|iostat' will not be logged." # Save initial TESTPOOL history log_must eval "zpool history $TESTPOOL >$OLD_HISTORY" -log_must zpool get all $TESTPOOL >/dev/null -log_must zpool list $TESTPOOL >/dev/null -log_must zpool status $TESTPOOL >/dev/null -log_must zpool iostat $TESTPOOL >/dev/null +log_must eval "zpool get all $TESTPOOL >/dev/null" +log_must eval "zpool list $TESTPOOL >/dev/null" +log_must eval "zpool status $TESTPOOL >/dev/null" +log_must eval "zpool iostat $TESTPOOL >/dev/null" log_must eval "zpool history $TESTPOOL >$NEW_HISTORY" log_must diff $OLD_HISTORY $NEW_HISTORY diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_006_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_006_neg.ksh index 19b7114faf5b..a1e76e68b802 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_006_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_006_neg.ksh @@ -67,15 +67,15 @@ log_must zfs snapshot $snap2 # Save initial TESTPOOL history log_must eval "zpool history $TESTPOOL > $OLD_HISTORY" -log_must zfs list $fs > /dev/null -log_must zfs get mountpoint $fs > /dev/null +log_must eval "zfs list $fs > /dev/null" +log_must eval "zfs get mountpoint $fs > /dev/null" log_must zfs unmount $fs log_must zfs mount $fs if ! is_linux; then log_must zfs share $fs log_must zfs unshare $fs fi -log_must zfs send -i $snap1 $snap2 > /dev/null +log_must eval "zfs send -i $snap1 $snap2 > /dev/null" log_must zfs holds $snap1 log_must eval "zpool history $TESTPOOL > $NEW_HISTORY" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_007_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_007_pos.ksh index f187b88f056e..3d785183d094 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_007_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_007_pos.ksh @@ -70,7 +70,7 @@ for arch in "i386" "sparc"; do orig_cmds_f=$import_dir/${arch}.orig_history.txt # remove blank line orig_cmds_f1=$import_dir/${arch}.orig_history_1.txt - cat $orig_cmds_f | grep -v "^$" > $orig_cmds_f1 + grep -v "^$" $orig_cmds_f > $orig_cmds_f1 log_must cp $tst_dir/${arch}.migratedpool.DAT.Z $import_dir log_must uncompress -f $import_dir/${arch}.migratedpool.DAT.Z @@ -80,7 +80,7 @@ for arch in "i386" "sparc"; do log_must zpool destroy -f $migratedpoolname log_must zpool import -d $import_dir $migratedpoolname - log_must eval "TZ=$TIMEZONE zpool history $migratedpoolname | grep -v "^\$" >$migrated_cmds_f" + log_must eval "TZ=$TIMEZONE zpool history $migratedpoolname | grep -v \"^\$\" >$migrated_cmds_f" # The migrated history file should differ with original history file on # two commands -- 'export' and 'import', which are included in migrated @@ -89,20 +89,20 @@ for arch in "i386" "sparc"; do # then compare this filtered file with the original history file. They # should be identical at this time. for subcmd in "export" "import"; do - grep -q "$subcmd" $migrated_cmds_f || \ - log_fail "zpool $subcmd is not logged for" \ - "the imported pool $migratedpoolname." + grep -q "$subcmd" $migrated_cmds_f || + log_fail "zpool $subcmd is not logged for" \ + "the imported pool $migratedpoolname." done tmpfile=$import_dir/cmds_tmp.$$ - linenum=`wc -l < $migrated_cmds_f` + linenum=$(wc -l < $migrated_cmds_f) (( linenum = linenum - 2 )) head -n $linenum $migrated_cmds_f > $tmpfile log_must diff $tmpfile $orig_cmds_f1 # cleanup for next loop testing log_must zpool destroy -f $migratedpoolname - log_must rm -f `ls $import_dir` + log_must rm -f $(ls $import_dir) done log_pass "Verify command history moves with migrated pool." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_008_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_008_pos.ksh index 8e174dcb7ebf..26f728bb1779 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_008_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_008_pos.ksh @@ -55,8 +55,7 @@ log_assert "Pool history records all recursive operations." log_onexit cleanup root_testfs=$TESTPOOL/$TESTFS -fs1=$root_testfs/fs1; fs2=$root_testfs/fs2; fs3=$root_testfs/fs3 -for fs in $fs1 $fs2 $fs3; do +for fs in $root_testfs/fs{1..3}; do log_must zfs create $fs done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_010_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_010_pos.ksh index 2c32b1b6cefa..57a7cb4466d0 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_010_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_010_pos.ksh @@ -66,10 +66,8 @@ add_user $HIST_GROUP $HIST_USER # # chmod 0750 $HOME # -user_run $HIST_USER zfs list -if [ $? -ne 0 ]; then - log_unsupported "Test user $HIST_USER cannot execute zfs utilities" -fi +user_run $HIST_USER zfs list || + log_unsupported "Test user $HIST_USER cannot execute zfs utilities" run_and_verify "zfs create $root_testfs" "-l" run_and_verify "zfs allow $HIST_GROUP snapshot,mount $root_testfs" "-l" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_common.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_common.kshlib index ff3260f3c0f2..95f9441bf692 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_common.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/history/history_common.kshlib @@ -52,14 +52,12 @@ function run_and_verify flags="$2" if is_illumos; then - histcmd=$(echo $fullcmd | sed 's/\/usr\/sbin\///g') + histcmd=$(echo $fullcmd | sed 's=/usr/sbin/==g') else - histcmd=$(echo $fullcmd | sed 's/^.*\/\(zpool .*\).*$/\1/') - histcmd=$(echo $histcmd | sed 's/^.*\/\(zfs .*\).*$/\1/') + histcmd=$(echo $fullcmd | sed -E 's=^.*/(zpool|zfs)$=\1=') fi - cmd=$(echo $histcmd | awk '{print $1}') - subcmd=$(echo $histcmd | awk '{print $2}') + read -r cmd subcmd _ <<<"$histcmd" # If we aren't running zpool or zfs, something is wrong [[ $cmd == "zpool" || $cmd == "zfs" ]] || \ @@ -77,11 +75,10 @@ function run_and_verify 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' \ - > $NEW_HISTORY + diff $OLD_HISTORY $TMP_HISTORY | sed -n 's/^> //gp' > $NEW_HISTORY # Verify what's common to every case, regardless of zpool history flags. - grep "$histcmd" $NEW_HISTORY >/dev/null 2>&1 || \ + grep -q "$histcmd" $NEW_HISTORY || \ log_fail "Didn't find \"$histcmd\" in pool history" # If 'zpool history' was called without any flags, then we're done. @@ -116,8 +113,7 @@ function verify_long suffix=":freebsd" fi - grep -q "$cmd \[user $uid ($user) on $hname$suffix\]" $NEW_HISTORY - if [[ $? != 0 ]]; then + if ! grep -q "$cmd \[user $uid ($user) on $hname$suffix\]" $NEW_HISTORY; then log_note "Couldn't find long information for \"$cmd\"" return 1 fi @@ -133,7 +129,8 @@ function verify_hold [[ $flags =~ "i" ]] || return 1 - typeset tag=$(echo $cmd | awk '{print $4}') + typeset tag _ + read -r _ _ _ tag _ <<<"$cmd" typeset fullname=${cmd##* } typeset dsname=${fullname%%@*} typeset snapname=${fullname##*@} @@ -141,9 +138,7 @@ function verify_hold # This works whether or not the hold was recursive for ds in $(zfs list -r -Ho name -t snapshot $dsname | \ grep "@$snapname"); do - grep "$subcmd $ds ([0-9]*) tag=$tag" $NEW_HISTORY \ - >/dev/null 2>&1 - if [[ $? != 0 ]]; then + if ! grep -q "$subcmd $ds ([0-9]*) tag=$tag" $NEW_HISTORY; then log_note "Didn't find hold on $ds with $tag" return 1 fi @@ -172,15 +167,12 @@ function verify_rollback typeset rb_fs=${dsname}/%rollback typeset snapname=${fullname##*@} - grep "clone swap $rb_fs ([0-9]*) parent=$parent_fs" $NEW_HISTORY \ - >/dev/null 2>&1 - if [[ $? != 0 ]]; then + if ! grep -q "clone swap $rb_fs ([0-9]*) parent=$parent_fs" $NEW_HISTORY ; then log_note "Didn't find rollback clone swap in pool history" return 1 fi - grep "destroy $rb_fs" $NEW_HISTORY >/dev/null 2>&1 - if [[ $? != 0 ]]; then + if ! grep -q "destroy $rb_fs" $NEW_HISTORY; then log_note "Didn't find rollback destroy in pool history" return 1 fi @@ -201,9 +193,7 @@ function verify_inherit # This works whether or not the inherit was recursive for ds in $(zfs list -r -Ho name -t filesystem $dsname); do - grep "$subcmd $ds ([0-9]*) ${prop}=" $NEW_HISTORY >/dev/null \ - 2>&1 - if [[ $? != 0 ]]; then + if ! grep -q "$subcmd $ds ([0-9]*) ${prop}=" $NEW_HISTORY; then log_note "Didn't find inherit history for $ds" return 1 fi @@ -231,8 +221,7 @@ function verify_allow # - Whether the operation applies locally or to descendent datasets (or # both) # - echo $cmd | awk '{i = NF - 1; print $i}' | grep '@' >/dev/null \ - 2>&1 && is_set=1 + echo $cmd | awk '$(NF - 1) ~ /@/ {exit 1}' || is_set=1 dsname=${cmd##* } [[ $cmd =~ "-l " ]] && lflag=1 [[ $cmd =~ "-d " ]] && dflag=1 @@ -254,9 +243,7 @@ function verify_allow [[ -n $is_set ]] && str="S-\$@" tmp=${cmd#*@} code="$str${tmp% *}" - grep "permission $subcmd $dsname ([0-9]*) $code" \ - $NEW_HISTORY >/dev/null 2>&1 - if [[ $? != 0 ]]; then + if ! grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then log_note "Couldn't find $code in $NEW_HISTORY" return 1 fi @@ -265,9 +252,7 @@ function verify_allow [[ -n $is_set ]] && str="C-\$" tmp=${cmd#*-c} code="$str${tmp% *}" - grep "permission $subcmd $dsname ([0-9]*) $code" \ - $NEW_HISTORY >/dev/null 2>&1 - if [ $? != 0 ]]; then + if ! grep "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then log_note "Couldn't find $code in $NEW_HISTORY" return 1 fi @@ -275,22 +260,18 @@ function verify_allow str="u" [[ -n $is_set ]] && str="U" tmp=${cmd##*-u } - opt=$(echo $tmp | awk '{print $2}') + read -r _ opt _ <<<"$opt" uid=$(id -u ${tmp%% *}) if [[ -n $lflag ]]; then code="${str}l\$$uid $opt" - grep "permission $subcmd $dsname ([0-9]*) $code" \ - $NEW_HISTORY >/dev/null 2>&1 - if [ $? != 0 ]]; then + if grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY]; then log_note "Couldn't find $code in $NEW_HISTORY" return 1 fi fi if [[ -n $dflag ]]; then code="${str}d\$$uid $opt" - grep "permission $subcmd $dsname ([0-9]*) $code" \ - $NEW_HISTORY >/dev/null 2>&1 - if [ $? != 0 ]]; then + if grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY]; then log_note "Couldn't find $code in $NEW_HISTORY" return 1 fi @@ -299,22 +280,18 @@ function verify_allow str="g" [[ -n $is_set ]] && str="G" tmp=${cmd##*-g } - opt=$(echo $tmp | awk '{print $2}') + read -r _ opt _ <<<"$opt" gid=$(awk -F: "/^${tmp%% *}:/ {print \$3}" /etc/group) if [[ -n $lflag ]]; then code="${str}l\$$gid $opt" - grep "permission $subcmd $dsname ([0-9]*) $code" \ - $NEW_HISTORY >/dev/null 2>&1 - if [ $? != 0 ]]; then + if ! grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then log_note "Couldn't find $code in $NEW_HISTORY" return 1 fi fi if [[ -n $dflag ]]; then code="${str}d\$$gid $opt" - grep "permission $subcmd $dsname ([0-9]*) $code" \ - $NEW_HISTORY >/dev/null 2>&1 - if [ $? != 0 ]]; then + if ! grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then log_note "Couldn't find $code in $NEW_HISTORY" return 1 fi @@ -326,18 +303,14 @@ function verify_allow opt=${opt%% *} if [[ -n $lflag ]]; then code="${str}l\$ $opt" - grep "permission $subcmd $dsname ([0-9]*) $code" \ - $NEW_HISTORY >/dev/null 2>&1 - if [ $? != 0 ]]; then + if ! grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then log_note "Couldn't find $code in $NEW_HISTORY" return 1 fi fi if [[ -n $dflag ]]; then code="${str}d\$ $opt" - grep "permission $subcmd $dsname ([0-9]*) $code" \ - $NEW_HISTORY >/dev/null 2>&1 - if [ $? != 0 ]]; then + if ! grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then log_note "Couldn't find $code in $NEW_HISTORY" return 1 fi @@ -373,16 +346,14 @@ function verify_destroy [[ $dsname =~ "@" ]] && typeset is_snap=1 if [[ -n $is_snap ]]; then - grep "ioctl destroy_snaps" $NEW_HISTORY >/dev/null 2>&1 - if [[ $? != 0 ]]; then + if ! grep -q "ioctl destroy_snaps" $NEW_HISTORY; then log_note "Didn't find ioctl while destroying $dsname" return 1 fi fi # This should be present for datasets and snapshots alike - grep "destroy $dsname" $NEW_HISTORY >/dev/null 2>&1 - if [[ $? != 0 ]]; then + if ! grep -q "destroy $dsname" $NEW_HISTORY; then log_note "Didn't find \"destroy\" for $dsname" return 1 fi @@ -401,9 +372,7 @@ function verify_snapshot typeset dsname=${fullname%%@*} typeset snapname=${fullname##*@} - grep "\[txg:[0-9]*\] $subcmd $fullname ([0-9]*)" $NEW_HISTORY \ - >/dev/null 2>&1 - if [[ $? != 0 ]]; then + if ! grep -q "\[txg:[0-9]*\] $subcmd $fullname ([0-9]*)" $NEW_HISTORY; then log_note "Didn't find snapshot command for $fullname" return 1 fi @@ -411,8 +380,7 @@ function verify_snapshot # This works whether or not the snapshot was recursive for ds in $(zfs list -r -Ho name -t snapshot $dsname | \ grep "@$snapname"); do - grep "^[ ]* $ds$" $NEW_HISTORY >/dev/null 2>&1 - if [[ $? != 0 ]]; then + if ! grep -q "^[ ]* $ds$" $NEW_HISTORY; then log_note "Didn't find \"ioctl snapshot\" for $ds" return 1 fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/hkdf/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/hkdf/Makefile.am deleted file mode 100644 index 8ac9053223a4..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/hkdf/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/hkdf - -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - run_hkdf_test.ksh - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/hkdf - -pkgexec_PROGRAMS = \ - hkdf_test - -hkdf_test_SOURCES = hkdf_test.c -hkdf_test_LDADD = \ - $(abs_top_builddir)/lib/libzpool/libzpool.la diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/hkdf/cleanup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/hkdf/cleanup.ksh deleted file mode 100755 index 2bdca1950d37..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/hkdf/cleanup.ksh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/ksh - -# -# This file and its contents are supplied under the terms of the -# Common Development and Distribution License ("CDDL"), version 1.0. -# You may only use this file in accordance with the terms of version -# 1.0 of the CDDL. -# -# A full copy of the text of the CDDL should have accompanied this -# source. A copy of the CDDL is also available via the Internet at -# http://www.illumos.org/license/CDDL. -# - -# -# Copyright (c) 2017 by Datto Inc. All rights reserved. -# - -. $STF_SUITE/include/libtest.shlib - -verify_runnable "global" - -log_pass diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/hkdf/run_hkdf_test.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/hkdf/run_hkdf_test.ksh deleted file mode 100755 index 5fde0b837d0f..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/hkdf/run_hkdf_test.ksh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/ksh - -# -# This file and its contents are supplied under the terms of the -# Common Development and Distribution License ("CDDL"), version 1.0. -# You may only use this file in accordance with the terms of version -# 1.0 of the CDDL. -# -# A full copy of the text of the CDDL should have accompanied this -# source. A copy of the CDDL is also available via the Internet at -# http://www.illumos.org/license/CDDL. -# - -# -# Copyright (c) 2017 by Datto Inc. All rights reserved. -# - -. $STF_SUITE/include/libtest.shlib - -# -# DESCRIPTION: -# Call the hkdf_test tool to test ZFS's HKDF implementation against -# a few test vectors. -# - -log_assert "Run the tests for the HKDF algorithm." - -log_must $STF_SUITE/tests/functional/hkdf/hkdf_test - -log_pass "HKDF tests pass." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/hkdf/setup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/hkdf/setup.ksh deleted file mode 100755 index 2bdca1950d37..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/hkdf/setup.ksh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/ksh - -# -# This file and its contents are supplied under the terms of the -# Common Development and Distribution License ("CDDL"), version 1.0. -# You may only use this file in accordance with the terms of version -# 1.0 of the CDDL. -# -# A full copy of the text of the CDDL should have accompanied this -# source. A copy of the CDDL is also available via the Internet at -# http://www.illumos.org/license/CDDL. -# - -# -# Copyright (c) 2017 by Datto Inc. All rights reserved. -# - -. $STF_SUITE/include/libtest.shlib - -verify_runnable "global" - -log_pass diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inheritance/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inheritance/Makefile.am deleted file mode 100644 index 3c624621f28a..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inheritance/Makefile.am +++ /dev/null @@ -1,57 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/inheritance -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - inherit_001_pos.ksh - -dist_pkgdata_DATA = \ - README.config \ - README.state \ - inherit.kshlib \ - config001.cfg \ - config002.cfg \ - config003.cfg \ - config004.cfg \ - config005.cfg \ - config006.cfg \ - config007.cfg \ - config008.cfg \ - config009.cfg \ - config010.cfg \ - config011.cfg \ - config012.cfg \ - config013.cfg \ - config014.cfg \ - config015.cfg \ - config016.cfg \ - config017.cfg \ - config018.cfg \ - config019.cfg \ - config020.cfg \ - config021.cfg \ - config022.cfg \ - config023.cfg \ - config024.cfg \ - state001.cfg \ - state002.cfg \ - state003.cfg \ - state004.cfg \ - state005.cfg \ - state006.cfg \ - state007.cfg \ - state008.cfg \ - state009.cfg \ - state010.cfg \ - state011.cfg \ - state012.cfg \ - state013.cfg \ - state014.cfg \ - state015.cfg \ - state016.cfg \ - state017.cfg \ - state018.cfg \ - state019.cfg \ - state020.cfg \ - state021.cfg \ - state022.cfg \ - state023.cfg \ - state024.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inheritance/inherit.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inheritance/inherit.kshlib index cd6bd5c027ca..a485d0521d1f 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inheritance/inherit.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inheritance/inherit.kshlib @@ -34,18 +34,12 @@ # function get_prop_src # property dataset { - typeset prop_val typeset prop=$1 typeset dataset=$2 - prop_val=`zfs get -H -o source $prop $dataset` - - if [[ $? -ne 0 ]]; then - log_fail "Unable to determine the source of $prop " \ + zfs get -H -o source $prop $dataset || + log_fail "Unable to determine the source of $prop" \ "property for dataset $dataset" - else - echo $prop_val - fi } # @@ -63,7 +57,7 @@ function verify_prop_src # child_dataset property expected_src typeset prop=$2 typeset expected=$3 - prop_src=`get_prop_src $prop $target` + prop_src=$(get_prop_src $prop $target) # # Rather than just checking if $prop_src == $expected @@ -105,7 +99,7 @@ function set_n_verify_prop #property value dataset typeset dataset=$3 zfs set $prop=$prop_val $dataset - check_val=`get_prop $prop $dataset` + check_val=$(get_prop $prop $dataset) if [[ $check_val != $prop_val ]]; then log_fail "Property $prop of $dataset has value $check_val"\ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inheritance/inherit_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inheritance/inherit_001_pos.ksh index 95dc7359f278..4dfc3a8986a3 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inheritance/inherit_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inheritance/inherit_001_pos.ksh @@ -337,9 +337,7 @@ function scan_state { #state-file for p in ${prop[i]} ${prop[((i+1))]}; do zfs $op $p $target - ret=$? - check_failure $ret "zfs $op $p \ - $target" + check_failure $? "zfs $op $p $target" done fi for check_obj in $list; do @@ -349,16 +347,14 @@ function scan_state { #state-file # check_failure to keep journal small verify_prop_src $check_obj $p \ $final_src - ret=$? - check_failure $ret "verify" \ + check_failure $? "verify" \ "_prop_src $check_obj $p" \ "$final_src" # Again, to keep journal size down. verify_prop_val $p $check_obj \ $final_src $j - ret=$? - check_failure $ret "verify" \ + check_failure $? "verify" \ "_prop_val $check_obj $p" \ "$final_src" done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/Makefile.am deleted file mode 100644 index c541e57eaa31..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/inuse -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - inuse_001_pos.ksh \ - inuse_003_pos.ksh \ - inuse_004_pos.ksh \ - inuse_005_pos.ksh \ - inuse_006_pos.ksh \ - inuse_007_pos.ksh \ - inuse_008_pos.ksh \ - inuse_009_pos.ksh - -dist_pkgdata_DATA = \ - inuse.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_001_pos.ksh index f824661c0067..25a807025c87 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_001_pos.ksh @@ -49,7 +49,7 @@ function cleanup # Remove dump device. # if [[ -n $PREVDUMPDEV ]]; then - log_must dumpadm -u -d $PREVDUMPDEV > /dev/null + log_must eval "dumpadm -u -d $PREVDUMPDEV > /dev/null" fi destroy_pool $TESTPOOL @@ -61,16 +61,16 @@ log_onexit cleanup typeset dumpdev="" -PREVDUMPDEV=`dumpadm | grep "Dump device" | awk '{print $3}'` +PREVDUMPDEV=`dumpadm | awk '/Dump device/ {print $3}'` log_note "Zero $FS_DISK0" log_must cleanup_devices $FS_DISK0 log_note "Configuring $rawdisk0 as dump device" -log_must dumpadm -d $rawdisk0 > /dev/null +log_must eval "dumpadm -d $rawdisk0 > /dev/null" log_note "Confirm that dump device has been setup" -dumpdev=`dumpadm | grep "Dump device" | awk '{print $3}'` +dumpdev=`dumpadm | awk '/Dump device/ {print $3}'` [[ -z "$dumpdev" ]] && log_untested "No dump device has been configured" [[ "$dumpdev" != "$rawdisk0" ]] && \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_003_pos.ksh index 07d6ac17557c..8c984df3089e 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_003_pos.ksh @@ -58,25 +58,21 @@ function cleanup log_note "Kill off ufsdump process if still running" kill -0 $PIDUFSDUMP > /dev/null 2>&1 && \ - log_must kill -9 $PIDUFSDUMP > /dev/null 2>&1 + log_must eval "kill -9 $PIDUFSDUMP" # # Note: It would appear that ufsdump spawns a number of processes # which are not killed when the $PIDUFSDUMP is whacked. So best bet # is to find the rest of the them and deal with them individually. # - for all in `pgrep ufsdump` - do - kill -9 $all > /dev/null 2>&1 - done + kill -9 `pgrep ufsdump` > /dev/null 2>&1 log_note "Kill off ufsrestore process if still running" kill -0 $PIDUFSRESTORE > /dev/null 2>&1 && \ - log_must kill -9 $PIDUFSRESTORE > /dev/null 2>&1 + log_must eval "kill -9 $PIDUFSRESTORE" ismounted $UFSMP ufs && log_must umount $UFSMP - rm -rf $UFSMP - rm -rf $TESTDIR + rm -rf $UFSMP $TESTDIR # # Tidy up the disks we used. @@ -96,8 +92,8 @@ typeset -i filenum=0 typeset cwd="" log_note "Make a ufs filesystem on source $rawdisk1" -new_fs $rawdisk1 > /dev/null 2>&1 -(($? != 0)) && log_untested "Unable to create ufs filesystem on $rawdisk1" +new_fs $rawdisk1 > /dev/null 2>&1 || + log_untested "Unable to create ufs filesystem on $rawdisk1" log_must mkdir -p $UFSMP @@ -108,9 +104,9 @@ log_note "Now create some directories and files to be ufsdump'ed" while (($dirnum <= 2)); do log_must mkdir $bigdir${dirnum} while (( $filenum <= 2 )); do - file_write -o create -f $bigdir${dirnum}/file${filenum} \ + if ! file_write -o create -f $bigdir${dirnum}/file${filenum} \ -b $BLOCK_SIZE -c $BLOCK_COUNT - if [[ $? -ne 0 ]]; then + then if [[ $dirnum -lt 3 ]]; then log_fail "file_write only wrote" \ "<(( $dirnum * 3 + $filenum ))>" \ @@ -139,9 +135,7 @@ log_note "Attempt to take the source device in use by ufsdump as spare device" log_mustnot zpool create $TESTPOOL1 "$FS_DISK2" spare "$disk1" log_mustnot poolexists $TESTPOOL1 -wait $PIDUFSDUMP -typeset -i retval=$? -(($retval != 0)) && log_fail "ufsdump failed with error code $ret_val" +wait $PIDUFSDUMP || log_fail "ufsdump failed with error code $?" log_must mount $disk1 $UFSMP diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_004_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_004_pos.ksh index a9725e06dcf0..8e051d8b6f73 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_004_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_004_pos.ksh @@ -52,10 +52,10 @@ function cleanup # to work correctly. So its reproduced below. Still need to fully # understand why default_cleanup does not work correctly from here. # - log_must zfs umount $TESTPOOL/$TESTFS + log_must zfs umount $TESTPOOL/$TESTFS - rm -rf $TESTDIR || \ - log_unresolved Could not remove $TESTDIR + rm -rf $TESTDIR || + log_unresolved Could not remove $TESTDIR log_must zfs destroy $TESTPOOL/$TESTFS destroy_pool $TESTPOOL @@ -71,21 +71,11 @@ function mini_format if is_linux; then parted $disk -s -- mklabel gpt - typeset -i retval=$? elif is_freebsd; then gpart create -s gpt $disk - typeset -i retval=$? else - typeset format_file=$TEST_BASE_DIR/format_in.$$.1 - echo "partition" > $format_file - echo "modify" >> $format_file - - format -e -s -d $disk -f $format_file - typeset -i retval=$? - - rm -rf $format_file + format -e -s -d $disk -f <(printf '%s\n' partition modify) fi - return $retval } log_assert "format will disallow modification of a mounted zfs disk partition"\ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_006_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_006_pos.ksh index 9657322526e7..2222721afd8d 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_006_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_006_pos.ksh @@ -77,7 +77,7 @@ set -A vdevs "" "mirror" "raidz" "raidz1" "raidz2" typeset -i i=0 -PREVDUMPDEV=`dumpadm | grep "Dump device" | awk '{print $3}'` +PREVDUMPDEV=`dumpadm | awk '/Dump device/ {print $3}'` unset NOINUSE_CHECK while (( i < ${#vdevs[*]} )); do diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_007_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_007_pos.ksh index b96b80890ed8..775f1af63bf1 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_007_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/inuse/inuse_007_pos.ksh @@ -82,7 +82,7 @@ set -A vdevs "" "mirror" "raidz" "raidz1" "raidz2" typeset -i i=0 -PREVDUMPDEV=`dumpadm | grep "Dump device" | awk '{print $3}'` +PREVDUMPDEV=`dumpadm | awk '/Dump device/ {print $3}'` while (( i < ${#vdevs[*]} )); do typeset spare="spare $sdisks" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/Makefile.am deleted file mode 100644 index 44c0d02d6efe..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/io -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - sync.ksh \ - psync.ksh \ - libaio.ksh \ - io_uring.ksh \ - posixaio.ksh \ - mmap.ksh - -dist_pkgdata_DATA = \ - io.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/io_uring.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/io_uring.ksh index 2d2b18f8bb5b..1ee5cee52227 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/io_uring.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/io_uring.ksh @@ -44,7 +44,7 @@ if [[ $(linux_version) -lt $(linux_version "5.1") ]]; then log_unsupported "Requires io_uring support" fi -fio --ioengine=io_uring --parse-only || log_unsupported "io_uring support required" +fio --ioengine=io_uring --parse-only || log_unsupported "fio io_uring support required" function cleanup { diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/libaio.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/libaio.ksh index c434ad90ddd7..ef100209beac 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/libaio.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/libaio.ksh @@ -39,6 +39,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { log_must rm -f "$mntpnt/rw*" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/mmap.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/mmap.ksh index e9600787a8bc..742c1f08f1c7 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/mmap.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/mmap.ksh @@ -37,7 +37,7 @@ # 2. Repeat the test with additional fio(1) options. # -if ! compare_version_gte $(fio --version) "fio-2.3"; then +if ! compare_version_gte "$(fio --version)" "fio-2.3"; then log_unsupported "Requires fio-2.3 or newer" fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/posixaio.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/posixaio.ksh index 0758164c1673..c720aef9535f 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/posixaio.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/posixaio.ksh @@ -39,6 +39,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { log_must rm -f "$mntpnt/rw*" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/psync.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/psync.ksh index efeb1103d8bb..8feb87d93a7c 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/psync.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/psync.ksh @@ -39,6 +39,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { log_must rm -f "/$TESTPOOL/rw*" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/sync.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/sync.ksh index 83f346c6972a..aaaa126efb1f 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/sync.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/sync.ksh @@ -39,6 +39,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { log_must rm -f "$mntpnt/rw*" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/Makefile.am deleted file mode 100644 index 09f4c1d0d74f..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/l2arc -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - l2arc_arcstats_pos.ksh \ - l2arc_l2miss_pos.ksh \ - l2arc_mfuonly_pos.ksh \ - persist_l2arc_001_pos.ksh \ - persist_l2arc_002_pos.ksh \ - persist_l2arc_003_neg.ksh \ - persist_l2arc_004_pos.ksh \ - persist_l2arc_005_pos.ksh - -dist_pkgdata_DATA = \ - l2arc.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh index 3e76347b029a..69d60ab8bb90 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh @@ -40,6 +40,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "L2ARC MFU/MRU arcstats do not leak." function cleanup diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/l2arc_l2miss_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/l2arc_l2miss_pos.ksh index 783484f52c13..c9d5d7ffe1f1 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/l2arc_l2miss_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/l2arc_l2miss_pos.ksh @@ -38,6 +38,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "l2arc_misses does not increment upon reads from a pool without l2arc." function cleanup diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/l2arc_mfuonly_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/l2arc_mfuonly_pos.ksh index 5d0198c90c16..f2bada0ebbec 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/l2arc_mfuonly_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/l2arc_mfuonly_pos.ksh @@ -39,6 +39,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "l2arc_mfuonly does not cache MRU buffers." function cleanup diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh index 0a9049490c71..6f7b9aff7c38 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh @@ -49,6 +49,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "Persistent L2ARC with an unencrypted ZFS file system succeeds." function cleanup @@ -87,8 +89,7 @@ arcstat_quiescence_noecho l2_size log_must zpool export $TESTPOOL arcstat_quiescence_noecho l2_feeds -typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ - awk '{print $2}') +typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | awk '/log_blk_count/ {print $2}') typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh index 93982e6c605b..3b893d28da6a 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh @@ -52,6 +52,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "Persistent L2ARC with an encrypted ZFS file system succeeds." function cleanup @@ -90,8 +92,7 @@ arcstat_quiescence_noecho l2_size log_must zpool export $TESTPOOL arcstat_quiescence_noecho l2_feeds -typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ - awk '{print $2}') +typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | awk '/log_blk_count/ {print $2}') typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_003_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_003_neg.ksh index fe35c8fc4500..f8dc2b108f0d 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_003_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_003_neg.ksh @@ -38,6 +38,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "Persistent L2ARC fails as expected when L2ARC_REBUILD_ENABLED = 0." function cleanup diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh index b40703180687..8a572c26469c 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh @@ -40,6 +40,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "Off/onlining an L2ARC device results in rebuilding L2ARC, vdev not present." function cleanup @@ -78,8 +80,7 @@ log_must zpool export $TESTPOOL arcstat_quiescence_noecho l2_feeds typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) -typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ - awk '{print $2}') +typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | awk '/log_blk_count/ {print $2}') log_must zpool import -d $VDIR $TESTPOOL log_must zpool online $TESTPOOL $VDEV_CACHE diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh index 8ad648519f5c..9663437c6597 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh @@ -39,6 +39,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "Off/onlining an L2ARC device results in rebuilding L2ARC, vdev present." function cleanup @@ -75,8 +77,7 @@ log_must zpool offline $TESTPOOL $VDEV_CACHE arcstat_quiescence_noecho l2_size typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) -typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ - awk '{print $2}') +typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | awk '/log_blk_count/ {print $2}') log_must zpool online $TESTPOOL $VDEV_CACHE arcstat_quiescence_noecho l2_size diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/large_files/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/large_files/Makefile.am deleted file mode 100644 index 0e471533090c..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/large_files/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/large_files -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - large_files_001_pos.ksh \ - large_files_002_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/largest_pool/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/largest_pool/Makefile.am deleted file mode 100644 index 5f1473dede70..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/largest_pool/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/largest_pool -dist_pkgdata_SCRIPTS = \ - largest_pool_001_pos.ksh - -dist_pkgdata_DATA = \ - largest_pool.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/largest_pool/largest_pool_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/largest_pool/largest_pool_001_pos.ksh index 6f6acdafafe5..7955478502d1 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/largest_pool/largest_pool_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/largest_pool/largest_pool_001_pos.ksh @@ -117,15 +117,12 @@ log_onexit cleanup # units for 'df'. It must be greater than one. # ----------------------------------------------------------------------- typeset str -typeset -i ret for volsize in $VOLSIZES; do log_note "Create a pool which will contain a volume device" log_must create_pool $TESTPOOL2 "$DISKS" log_note "Create a volume device of desired sizes: $volsize" - str=$(zfs create -sV $volsize $TESTPOOL2/$TESTVOL 2>&1) - ret=$? - if (( ret != 0 )); then + if ! str=$(zfs create -sV $volsize $TESTPOOL2/$TESTVOL 2>&1); then if [[ is_32bit && \ $str == *${VOL_LIMIT_KEYWORD1}* || \ $str == *${VOL_LIMIT_KEYWORD2}* || \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/libzfs/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/libzfs/Makefile.am deleted file mode 100644 index 53cb635444ab..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/libzfs/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/libzfs - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/libzfs - -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - libzfs_input.ksh - -many_fds_LDADD = \ - $(abs_top_builddir)/lib/libzfs/libzfs.la - -pkgexec_PROGRAMS = many_fds -many_fds_SOURCES = many_fds.c - diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/libzfs/many_fds.c b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/libzfs/many_fds.c index 6def57c5a51a..34029e0e32d0 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/libzfs/many_fds.c +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/libzfs/many_fds.c @@ -22,15 +22,13 @@ /* * Copyright (C) 2015 STRATO AG. */ -#include -#include -#include -#include -#include +#include #include #include #include -#include +#include +#include +#include /* * Check if libzfs works with more than 255 held file handles. @@ -38,35 +36,23 @@ int main(void) { - int i; - struct rlimit limit; - libzfs_handle_t *h; + struct rlimit limit = { + .rlim_cur = 64 * 1024, + .rlim_max = 64 * 1024, + }; + if (setrlimit(RLIMIT_NOFILE, &limit) != 0) + err(1, "setrlimit()"); - limit.rlim_cur = 65535; - limit.rlim_max = 65535; + int fd = open("/dev/null", O_RDONLY); + if (fd == -1) + err(1, "open()"); + for (int i = 0; i < limit.rlim_cur / 2; ++i) + if (dup(fd) == -1) + err(1, "dup()"); - if (setrlimit(RLIMIT_NOFILE, &limit) != 0) { - (void) printf("many_fds: setrlimit() failed with errno=%d\n", - errno); - exit(1); - } + libzfs_handle_t *h = libzfs_init(); + if (h == NULL) + err(1, "libzfs_init()"); - for (i = 0; i < 255; ++i) { - int fd = open("/dev/null", O_RDONLY); - if (fd == -1) { - (void) printf("open failed with errno=%d\n", errno); - return (1); - } - } - - h = libzfs_init(); - - if (h != NULL) { - libzfs_fini(h); - return (0); - } else { - (void) printf("many_fds: libzfs_init() failed with errno=%d\n", - errno); - return (1); - } + libzfs_fini(h); } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/limits/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/limits/Makefile.am deleted file mode 100644 index 72455922485d..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/limits/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/limits -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - filesystem_count.ksh \ - filesystem_limit.ksh \ - snapshot_count.ksh \ - snapshot_limit.ksh - diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/link_count/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/link_count/Makefile.am deleted file mode 100644 index bfb7154a6518..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/link_count/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/link_count -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - link_count_001.ksh \ - link_count_root_inode.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/log_spacemap/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/log_spacemap/Makefile.am deleted file mode 100644 index a1e523426c6a..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/log_spacemap/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/log_spacemap -dist_pkgdata_SCRIPTS = log_spacemap_import_logs.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/log_spacemap/log_spacemap_import_logs.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/log_spacemap/log_spacemap_import_logs.ksh index d1d283376bbb..d16574d3a8f7 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/log_spacemap/log_spacemap_import_logs.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/log_spacemap/log_spacemap_import_logs.ksh @@ -57,7 +57,7 @@ function cleanup log_onexit cleanup LOGSM_POOL="logsm_import" -TESTDISK="$(echo $DISKS | cut -d' ' -f1)" +read -r TESTDISK _ <<<"$DISKS" log_must zpool create -o cachefile=none -f $LOGSM_POOL $TESTDISK log_must zfs create $LOGSM_POOL/fs @@ -70,10 +70,7 @@ sync_all_pools log_must set_tunable64 KEEP_LOG_SPACEMAPS_AT_EXPORT 1 log_must zpool export $LOGSM_POOL -LOGSM_COUNT=$(zdb -m -e $LOGSM_POOL | grep "Log Spacemap object" | wc -l) -if (( LOGSM_COUNT == 0 )); then - log_fail "Pool does not have any log spacemaps after being exported" -fi +log_must eval "zdb -m -e $LOGSM_POOL | grep -q \"Log Spacemap object\"" log_must set_tunable64 METASLAB_DEBUG_LOAD 1 log_must zpool import $LOGSM_POOL diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/Makefile.am deleted file mode 100644 index 9c4f244156ce..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/migration -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - migration_001_pos.ksh \ - migration_002_pos.ksh \ - migration_003_pos.ksh \ - migration_004_pos.ksh \ - migration_005_pos.ksh \ - migration_006_pos.ksh \ - migration_007_pos.ksh \ - migration_008_pos.ksh \ - migration_009_pos.ksh \ - migration_010_pos.ksh \ - migration_011_pos.ksh \ - migration_012_pos.ksh - -dist_pkgdata_DATA = \ - migration.cfg \ - migration.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/cleanup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/cleanup.ksh index 1a1f3f42731e..79676d79e6fd 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/cleanup.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/cleanup.ksh @@ -34,11 +34,9 @@ verify_runnable "global" -ismounted $NONZFS_TESTDIR $NEWFS_DEFAULT_FS -(( $? == 0 )) && log_must umount -f $NONZFS_TESTDIR +ismounted $NONZFS_TESTDIR $NEWFS_DEFAULT_FS && log_must umount -f $NONZFS_TESTDIR -ismounted $TESTPOOL/$TESTFS -[[ $? == 0 ]] && log_must zfs umount -f $TESTDIR +ismounted $TESTPOOL/$TESTFS && log_must zfs umount -f $TESTDIR destroy_pool $TESTPOOL DISK=${DISKS%% *} diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration.cfg index 12a5a7799b7a..308891b86d01 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration.cfg @@ -31,7 +31,7 @@ . $STF_SUITE/include/libtest.shlib export DISKSARRAY=$DISKS -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') set -A disk_array $(find_disks $DISKS) case "${#disk_array[*]}" in 0) @@ -102,9 +102,8 @@ export DISK_COUNT ZFS_DISK NONZFS_DISK SINGLE_DISK ZFSSIDE_DISK NONZFSSIDE_DISK export TESTFILE=/etc/passwd export NONZFS_TESTDIR=$TESTDIR/nonzfstestdir -tmp=`sum $TESTFILE` -export SUMA=`echo $tmp | awk '{print $1}'` -export SUMB=`echo $tmp | awk '{print $2}'` +read -r SUMA SUMB _ < <(cksum $TESTFILE) +export SUMA SUMB export FS_SIZE=1g export BNAME=`basename $TESTFILE` export DNAME=`dirname $TESTFILE` diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration.kshlib index a2b4ed99b11e..0362f0644f6f 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration.kshlib @@ -49,19 +49,11 @@ function prepare #srcdir cmd { typeset srcdir=$1 typeset cmd=$2 - typeset -i retval=0 cwd=$PWD - cd $srcdir - (( $? != 0 )) && return 1 - - $cmd - (( $? != 0 )) && return 1 - - cd $cwd - (( $? != 0 )) && return 1 - - return 0 + cd $srcdir || return 1 + $cmd || return 1 + cd $cwd || return 1 } # @@ -90,32 +82,22 @@ function migrate #destdir oldsuma oldsumb cmd typeset oldsuma=$2 typeset oldsumb=$3 typeset cmd=$4 - typeset -i retval=0 cwd=$PWD - cd $destdir - (( $? != 0 )) && return 1 - - $cmd - (( $? != 0 )) && return 1 - - sumy=`sum ./$BNAME` - suma=`echo $sumy | awk '{print $1}'` - sumb=`echo $sumy | awk '{print $2}'` + cd $destdir || return 1 + $cmd || return 1 + read -r suma sumb _ < <(cksum ./$BNAME) + cd $cwd || return 1 if (( $oldsuma != $suma )); then log_note "sum values are not the same" - retval=1 + return 1 fi if (( $oldsumb != $sumb )); then log_note "sum values are not the same" - retval=1 + return 1 fi - - cd $cwd - (( $? != 0 )) && return 1 - return $retval } function migrate_cpio @@ -124,30 +106,20 @@ function migrate_cpio typeset archive=$2 typeset oldsuma=$3 typeset oldsumb=$4 - typeset -i retval=0 cwd=$PWD - cd $destdir - (( $? != 0 )) && return 1 - - cpio -iv < $archive - (( $? != 0 )) && return 1 - - sumy=`sum ./$BNAME` - suma=`echo $sumy | awk '{print $1}'` - sumb=`echo $sumy | awk '{print $2}'` + cd $destdir || return 1 + cpio -iv < $archive || return 1 + read -r suma sumb _ < <(cksum ./$BNAME) + cd $cwd if (( $oldsuma != $suma )); then log_note "sum values are not the same" - retval=1 + return 1 fi if (( $oldsumb != $sumb )); then log_note "sum values are not the same" - retval=1 + return 1 fi - - cd $cwd - (( $? != 0 )) && return 1 - return $retval } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_001_pos.ksh index 875d2f7c78be..3a4a4b7f8f74 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_001_pos.ksh @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/tar$$.tar - rm -rf $TESTDIR/$BNAME + rm -rf $TESTDIR/tar$$.tar $TESTDIR/$BNAME } log_assert "Migrating test file from ZFS fs to ZFS fs using tar" log_onexit cleanup -prepare $DNAME "tar cf $TESTDIR/tar$$.tar $BNAME" -(( $? != 0 )) && log_fail "Unable to create src archive" - -migrate $TESTDIR $SUMA $SUMB "tar xf $TESTDIR/tar$$.tar" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to ZFS fs" +log_must prepare $DNAME "tar cf $TESTDIR/tar$$.tar $BNAME" +log_must migrate $TESTDIR $SUMA $SUMB "tar xf $TESTDIR/tar$$.tar" log_pass "Successfully migrated test file from ZFS fs to ZFS fs". diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_002_pos.ksh index 6b97e2a4071b..a522174f11aa 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_002_pos.ksh @@ -34,12 +34,12 @@ # # DESCRIPTION: -# Migrating test file from ZFS fs to UFS fs using tar. +# Migrating test file from ZFS fs to platform native fs using tar. # # STRATEGY: # 1. Calculate chksum of testfile # 2. Tar up test file and place on a ZFS filesystem -# 3. Extract tar contents to a UFS file system +# 3. Extract tar contents to a platform native file system # 4. Calculate chksum of extracted file # 5. Compare old and new chksums. # @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/tar$$.tar - rm -rf $NONZFS_TESTDIR/$BNAME + rm -rf $TESTDIR/tar$$.tar $NONZFS_TESTDIR/$BNAME } -log_assert "Migrating test file from ZFS fs to UFS fs using tar" +log_assert "Migrating test file from ZFS fs to $NEWFS_DEFAULT_FS fs using tar" log_onexit cleanup -prepare $DNAME "tar cf $TESTDIR/tar$$.tar $BNAME" -(( $? != 0 )) && log_fail "Unable to create src archive" +log_must prepare $DNAME "tar cf $TESTDIR/tar$$.tar $BNAME" +log_must migrate $NONZFS_TESTDIR $SUMA $SUMB "tar xf $TESTDIR/tar$$.tar" -migrate $NONZFS_TESTDIR $SUMA $SUMB "tar xf $TESTDIR/tar$$.tar" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to UFS fs" - -log_pass "Successfully migrated test file from ZFS fs to UFS fs". +log_pass "Successfully migrated test file from ZFS fs to $NEWFS_DEFAULT_FS fs". diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_003_pos.ksh index dd0baeaa9b78..c83883d356c3 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_003_pos.ksh @@ -34,11 +34,11 @@ # # DESCRIPTION: -# Migrating test file from UFS fs to ZFS fs using tar. +# Migrating test file from platform native fs to ZFS fs using tar. # # STRATEGY: # 1. Calculate chksum of testfile -# 2. Tar up test file and place on a UFS filesystem +# 2. Tar up test file and place on a platform native filesystem # 3. Extract tar contents to a ZFS file system # 4. Calculate chksum of extracted file # 5. Compare old and new chksums. @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $NONZFS_TESTDIR/tar$$.tar - rm -rf $TESTDIR/$BNAME + rm -rf $NONZFS_TESTDIR/tar$$.tar $TESTDIR/$BNAME } -log_assert "Migrating test file from UFS fs to ZFS fs using tar" +log_assert "Migrating test file from $NEWFS_DEFAULT_FS fs to ZFS fs using tar" log_onexit cleanup -prepare $DNAME "tar cf $NONZFS_TESTDIR/tar$$.tar $BNAME" -(( $? != 0 )) && log_fail "Unable to create src archive" +log_must prepare $DNAME "tar cf $NONZFS_TESTDIR/tar$$.tar $BNAME" +log_must migrate $TESTDIR $SUMA $SUMB "tar xvf $NONZFS_TESTDIR/tar$$.tar" -migrate $TESTDIR $SUMA $SUMB "tar xvf $NONZFS_TESTDIR/tar$$.tar" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "UFS fs to ZFS fs" - -log_pass "Successfully migrated test file from UFS fs to ZFS fs". +log_pass "Successfully migrated test file from $NEWFS_DEFAULT_FS fs to ZFS fs". diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_004_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_004_pos.ksh index 00a6cc172ab6..5a4375410e65 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_004_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_004_pos.ksh @@ -48,8 +48,7 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/cpio$$.cpio - rm -rf $TESTDIR/$BNAME + rm -rf $TESTDIR/cpio$$.cpio $TESTDIR/$BNAME } log_assert "Migrating test file from ZFS fs to ZFS fs using cpio" @@ -57,17 +56,9 @@ log_assert "Migrating test file from ZFS fs to ZFS fs using cpio" log_onexit cleanup cwd=$PWD -cd $DNAME -(( $? != 0 )) && log_untested "Could not change directory to $DNAME" - -ls $BNAME | cpio -oc > $TESTDIR/cpio$$.cpio -(( $? != 0 )) && log_fail "Unable to create cpio archive" - -cd $cwd -(( $? != 0 )) && log_untested "Could not change directory to $cwd" - -migrate_cpio $TESTDIR "$TESTDIR/cpio$$.cpio" $SUMA $SUMB -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to ZFS fs" +log_must cd $DNAME +log_must eval "find $BNAME | cpio -oc > $TESTDIR/cpio$$.cpio" +log_must cd $cwd +log_must migrate_cpio $TESTDIR "$TESTDIR/cpio$$.cpio" $SUMA $SUMB log_pass "Successfully migrated test file from ZFS fs to ZFS fs". diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_005_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_005_pos.ksh index 4386596f777d..f282c37b7a1c 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_005_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_005_pos.ksh @@ -34,12 +34,12 @@ # # DESCRIPTION: -# Migrating test file from ZFS fs to UFS fs using cpio +# Migrating test file from ZFS fs to platform native fs using cpio # # STRATEGY: # 1. Calculate chksum of testfile # 2. Cpio up test file and place on a ZFS filesystem -# 3. Extract cpio contents to a UFS file system +# 3. Extract cpio contents to a platform native file system # 4. Calculate chksum of extracted file # 5. Compare old and new chksums. # @@ -48,26 +48,17 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/cpio$$.cpio - rm -rf $NONZFS_TESTDIR/$BNAME + rm -rf $TESTDIR/cpio$$.cpio $NONZFS_TESTDIR/$BNAME } -log_assert "Migrating test file from ZFS fs to uFS fs using cpio" +log_assert "Migrating test file from ZFS fs to $NEWFS_DEFAULT_FS fs using cpio" log_onexit cleanup cwd=$PWD -cd $DNAME -(( $? != 0 )) && log_untested "Could not change directory to $DNAME" +log_must cd $DNAME +log_must eval "find $BNAME | cpio -oc > $TESTDIR/cpio$$.cpio" +log_must cd $cwd +log_must migrate_cpio $NONZFS_TESTDIR "$TESTDIR/cpio$$.cpio" $SUMA $SUMB -ls $BNAME | cpio -oc > $TESTDIR/cpio$$.cpio -(( $? != 0 )) && log_fail "Unable to create cpio archive" - -cd $cwd -(( $? != 0 )) && log_untested "Could not change directory to $cwd" - -migrate_cpio $NONZFS_TESTDIR "$TESTDIR/cpio$$.cpio" $SUMA $SUMB -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to UFS fs" - -log_pass "Successfully migrated test file from ZFS fs to UFS fs". +log_pass "Successfully migrated test file from ZFS fs to $NEWFS_DEFAULT_FS fs". diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_006_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_006_pos.ksh index 9b5c9166ed97..a2ebd1f3f2c8 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_006_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_006_pos.ksh @@ -48,8 +48,7 @@ verify_runnable "both" function cleanup { - rm -rf $NONZFS_TESTDIR/cpio$$.cpio - rm -rf $TESTDIR/$BNAME + rm -rf $NONZFS_TESTDIR/cpio$$.cpio $TESTDIR/$BNAME } log_assert "Migrating test file from UFS fs to ZFS fs using cpio" @@ -57,17 +56,9 @@ log_assert "Migrating test file from UFS fs to ZFS fs using cpio" log_onexit cleanup cwd=$PWD -cd $DNAME -(( $? != 0 )) && log_untested "Could not change directory to $DNAME" - -ls $BNAME | cpio -oc > $NONZFS_TESTDIR/cpio$$.cpio -(( $? != 0 )) && log_fail "Unable to create cpio archive" - -cd $cwd -(( $? != 0 )) && log_untested "Could not change directory to $cwd" - -migrate_cpio $TESTDIR "$NONZFS_TESTDIR/cpio$$.cpio" $SUMA $SUMB -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to ZFS fs" +log_must cd $DNAME +log_must eval "find $BNAME | cpio -oc > $NONZFS_TESTDIR/cpio$$.cpio" +log_must cd $cwd +log_must migrate_cpio $TESTDIR "$NONZFS_TESTDIR/cpio$$.cpio" $SUMA $SUMB log_pass "Successfully migrated test file from UFS fs to ZFS fs". diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_007_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_007_pos.ksh index 0d136550f740..40839ecc00a5 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_007_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_007_pos.ksh @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/dd$$.dd - rm -rf $TESTDIR/$BNAME + rm -rf $TESTDIR/dd$$.dd $TESTDIR/$BNAME } log_assert "Migrating test file from ZFS fs to ZFS fs using dd" log_onexit cleanup -prepare $DNAME "dd if=$BNAME obs=128k of=$TESTDIR/dd$$.dd" -(( $? != 0 )) && log_fail "Unable to create src archive" - -migrate $TESTDIR $SUMA $SUMB "dd if=$TESTDIR/dd$$.dd obs=128k of=$BNAME" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to ZFS fs" +log_must prepare $DNAME "dd if=$BNAME obs=128k of=$TESTDIR/dd$$.dd" +log_must migrate $TESTDIR $SUMA $SUMB "dd if=$TESTDIR/dd$$.dd obs=128k of=$BNAME" log_pass "Successfully migrated test file from ZFS fs to ZFS fs". diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_008_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_008_pos.ksh index f62b1f33a3e5..af60e4bc1f4e 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_008_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_008_pos.ksh @@ -34,12 +34,12 @@ # # DESCRIPTION: -# Migrating test file from ZFS fs to UFS fs using dd. +# Migrating test file from ZFS fs to platform native fs using dd. # # STRATEGY: # 1. Calculate chksum of testfile # 2. Dd up test file and place on a ZFS filesystem -# 3. Extract dd contents to a UFS file system +# 3. Extract dd contents to a platform native file system # 4. Calculate chksum of extracted file # 5. Compare old and new chksums. # @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/dd$$.dd - rm -rf $NONZFS_TESTDIR/$BNAME + rm -rf $TESTDIR/dd$$.dd $NONZFS_TESTDIR/$BNAME } -log_assert "Migrating test file from ZFS fs to UFS fs using dd" +log_assert "Migrating test file from ZFS fs to $NEWFS_DEFAULT_FS fs using dd" log_onexit cleanup -prepare $DNAME "dd if=$BNAME obs=128k of=$TESTDIR/dd$$.dd" -(( $? != 0 )) && log_fail "Unable to create src archive" +log_must prepare $DNAME "dd if=$BNAME obs=128k of=$TESTDIR/dd$$.dd" +log_must migrate $NONZFS_TESTDIR $SUMA $SUMB "dd if=$TESTDIR/dd$$.dd obs=128k of=$BNAME" -migrate $NONZFS_TESTDIR $SUMA $SUMB "dd if=$TESTDIR/dd$$.dd obs=128k of=$BNAME" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to ZFS fs" - -log_pass "Successfully migrated test file from ZFS fs to UFS fs". +log_pass "Successfully migrated test file from ZFS fs to $NEWFS_DEFAULT_FS fs". diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_009_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_009_pos.ksh index 907be39eb4dd..e24cfdc96db1 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_009_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_009_pos.ksh @@ -34,11 +34,11 @@ # # DESCRIPTION: -# Migrating test file from UFS fs to ZFS fs using dd. +# Migrating test file from platform native fs to ZFS fs using dd. # # STRATEGY: # 1. Calculate chksum of testfile -# 2. Dd up test file and place on a UFS filesystem +# 2. Dd up test file and place on a platform native filesystem # 3. Extract dd contents to a ZFS file system # 4. Calculate chksum of extracted file # 5. Compare old and new chksums. @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/dd$$.dd - rm -rf $NONZFS_TESTDIR/$BNAME + rm -rf $TESTDIR/dd$$.dd $NONZFS_TESTDIR/$BNAME } -log_assert "Migrating test file from UFS fs to ZFS fs using dd" +log_assert "Migrating test file from $NEWFS_DEFAULT_FS fs to ZFS fs using dd" log_onexit cleanup -prepare $DNAME "dd if=$BNAME obs=128k of=$NONZFS_TESTDIR/dd$$.dd" -(( $? != 0 )) && log_fail "Unable to create src archive" +log_must prepare $DNAME "dd if=$BNAME obs=128k of=$NONZFS_TESTDIR/dd$$.dd" +log_must migrate $TESTDIR $SUMA $SUMB "dd if=$NONZFS_TESTDIR/dd$$.dd obs=128k of=$BNAME" -migrate $TESTDIR $SUMA $SUMB "dd if=$NONZFS_TESTDIR/dd$$.dd obs=128k of=$BNAME" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to ZFS fs" - -log_pass "Successfully migrated test file from UFS fs to ZFS fs". +log_pass "Successfully migrated test file from $NEWFS_DEFAULT_FS fs to ZFS fs". diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_010_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_010_pos.ksh index e80dd67cdc21..f090fed3d83c 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_010_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_010_pos.ksh @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/cp$$.cp - rm -rf $TESTDIR/$BNAME + rm -rf $TESTDIR/cp$$.cp $TESTDIR/$BNAME } log_assert "Migrating test file from ZFS fs to ZFS fs using cp" log_onexit cleanup -prepare $DNAME "cp $BNAME $TESTDIR/cp$$.cp" -(( $? != 0 )) && log_fail "Unable to create src archive" - -migrate $TESTDIR $SUMA $SUMB "cp $TESTDIR/cp$$.cp $BNAME" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to ZFS fs" +log_must prepare $DNAME "cp $BNAME $TESTDIR/cp$$.cp" +log_must migrate $TESTDIR $SUMA $SUMB "cp $TESTDIR/cp$$.cp $BNAME" log_pass "Successfully migrated test file from ZFS fs to ZFS fs". diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_011_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_011_pos.ksh index 2d7ecb45eadb..4293c8d8bdc2 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_011_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_011_pos.ksh @@ -34,12 +34,12 @@ # # DESCRIPTION: -# Migrating test file from ZFS fs to UFS fs using cp +# Migrating test file from ZFS fs to platform native fs using cp # # STRATEGY: # 1. Calculate chksum of testfile # 2. CP up test file and place on a ZFS filesystem -# 3. Extract cp contents to a UFS file system +# 3. Extract cp contents to a platform native file system # 4. Calculate chksum of extracted file # 5. Compare old and new chksums. # @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $NONZFS_TESTDIR/cp$$.cp - rm -rf $TESTDIR/$BNAME + rm -rf $NONZFS_TESTDIR/cp$$.cp $TESTDIR/$BNAME } -log_assert "Migrating test file from ZFS fs to UFS fs using cp" +log_assert "Migrating test file from ZFS fs to $NEWFS_DEFAULT_FS fs using cp" log_onexit cleanup -prepare $DNAME "cp $BNAME $TESTDIR/cp$$.cp" -(( $? != 0 )) && log_fail "Unable to create src archive" +log_must prepare $DNAME "cp $BNAME $TESTDIR/cp$$.cp" +log_must migrate $NONZFS_TESTDIR $SUMA $SUMB "cp $TESTDIR/cp$$.cp $BNAME" -migrate $NONZFS_TESTDIR $SUMA $SUMB "cp $TESTDIR/cp$$.cp $BNAME" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to UFS fs" - -log_pass "Successfully migrated test file from ZFS fs to UFS fs". +log_pass "Successfully migrated test file from ZFS fs to $NEWFS_DEFAULT_FS fs". diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_012_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_012_pos.ksh index fd9c4549164a..675b4a159b68 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_012_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/migration_012_pos.ksh @@ -34,11 +34,11 @@ # # DESCRIPTION: -# Migrating test file from UFS fs to ZFS fs using cp +# Migrating test file from platform native fs to ZFS fs using cp # # STRATEGY: # 1. Calculate chksum of testfile -# 2. CP up test file and place on a UFS filesystem +# 2. CP up test file and place on a platform native filesystem # 3. Extract cp contents to a ZFS file system # 4. Calculate chksum of extracted file # 5. Compare old and new chksums. @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/cp$$.cp - rm -rf $NONZFS_TESTDIR/$BNAME + rm -rf $TESTDIR/cp$$.cp $NONZFS_TESTDIR/$BNAME } -log_assert "Migrating test file from UFS fs to ZFS fs using cp" +log_assert "Migrating test file from $NEWFS_DEFAULT_FS fs to ZFS fs using cp" log_onexit cleanup -prepare $DNAME "cp $BNAME $NONZFS_TESTDIR/cp$$.cp" -(( $? != 0 )) && log_fail "Unable to create src archive" +log_mustprepare $DNAME "cp $BNAME $NONZFS_TESTDIR/cp$$.cp" +log_mustmigrate $TESTDIR $SUMA $SUMB "cp $NONZFS_TESTDIR/cp$$.cp $BNAME" -migrate $TESTDIR $SUMA $SUMB "cp $NONZFS_TESTDIR/cp$$.cp $BNAME" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "UFS fs to ZFS fs" - -log_pass "Successfully migrated test file from UFS fs to ZFS fs". +log_pass "Successfully migrated test file from $NEWFS_DEFAULT_FS fs to ZFS fs". diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/setup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/setup.ksh index 58edc0a9291d..4992f954eeee 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/setup.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/migration/setup.ksh @@ -57,8 +57,7 @@ log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS rm -rf $NONZFS_TESTDIR || log_unresolved Could not remove $NONZFS_TESTDIR mkdir -p $NONZFS_TESTDIR || log_unresolved Could not create $NONZFS_TESTDIR -new_fs ${DEV_DSKDIR}/$NONZFS_DISK -(( $? != 0 )) && +new_fs ${DEV_DSKDIR}/$NONZFS_DISK || log_untested "Unable to setup a $NEWFS_DEFAULT_FS file system" log_must mount ${DEV_DSKDIR}/$NONZFS_DISK $NONZFS_TESTDIR diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmap/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmap/Makefile.am deleted file mode 100644 index b26791ee7ce0..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmap/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/mmap -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - mmap_read_001_pos.ksh \ - mmap_write_001_pos.ksh \ - mmap_libaio_001_pos.ksh \ - mmap_seek_001_pos.ksh - -dist_pkgdata_DATA = \ - mmap.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmap/mmap_libaio_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmap/mmap_libaio_001_pos.ksh index 36a7e76f9f3d..031d90c3838b 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmap/mmap_libaio_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmap/mmap_libaio_001_pos.ksh @@ -42,9 +42,7 @@ verify_runnable "global" log_assert "verify mmap'd pages work with libaio" # mmap_libaio is built when the libaio-devel package is installed. -if ! which mmap_libaio; then - log_unsupported "This test requires mmap_libaio." -fi +command -v mmap_libaio > /dev/null || log_unsupported "This test requires mmap_libaio." log_must chmod 777 $TESTDIR diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmap/mmap_sync_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmap/mmap_sync_001_pos.ksh new file mode 100755 index 000000000000..b764d6607ba6 --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmap/mmap_sync_001_pos.ksh @@ -0,0 +1,63 @@ +#!/bin/ksh -p + +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2015, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# msync()s of mmap()'ed file should complete quickly during +# background dirty page writebacks by the kernel. +# + +function cleanup +{ + log_must eval "echo $saved_vm_dirty_expire_centisecs > /proc/sys/vm/dirty_expire_centisecs" + log_must eval "echo $saved_vm_dirty_background_ratio > /proc/sys/vm/dirty_background_ratio" + log_must eval "echo $saved_vm_dirty_writeback_centisecs > /proc/sys/vm/dirty_writeback_centisecs" + + # revert to some sensible defaults if the values we saved + # were incorrect due to a previous run being interrupted + if [ $( /proc/sys/vm/dirty_expire_centisecs" + fi + + if [ $( /proc/sys/vm/dirty_background_ratio" + fi + + if [ $( /proc/sys/vm/dirty_writeback_centisecs" + fi +} + +if ! is_linux; then + log_unsupported "Only supported on Linux, requires /proc/sys/vm/ tunables" +fi + +log_onexit cleanup +log_assert "Run the tests for mmap_sync" + +read -r saved_vm_dirty_expire_centisecs < /proc/sys/vm/dirty_expire_centisecs +read -r saved_vm_dirty_background_ratio < /proc/sys/vm/dirty_background_ratio +read -r saved_vm_dirty_writeback_centisecs < /proc/sys/vm/dirty_writeback_centisecs + +log_must eval "echo 1 > /proc/sys/vm/dirty_expire_centisecs" +log_must eval "echo 1 > /proc/sys/vm/dirty_background_bytes" +log_must eval "echo 1 > /proc/sys/vm/dirty_writeback_centisecs" + +log_must mmap_sync +log_pass "mmap_sync tests passed." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/Makefile.am deleted file mode 100644 index 2848fd4ce692..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/mmp -dist_pkgdata_SCRIPTS = \ - multihost_history.ksh \ - mmp_on_thread.ksh \ - mmp_on_uberblocks.ksh \ - mmp_on_off.ksh \ - mmp_interval.ksh \ - mmp_active_import.ksh \ - mmp_inactive_import.ksh \ - mmp_exported_import.ksh \ - mmp_write_uberblocks.ksh \ - mmp_reset_interval.ksh \ - mmp_on_zdb.ksh \ - mmp_write_distribution.ksh \ - mmp_hostid.ksh \ - setup.ksh \ - cleanup.ksh - -dist_pkgdata_DATA = \ - mmp.kshlib \ - mmp.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/mmp.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/mmp.kshlib index 661cbf3a52e7..9dd6f4d53f4a 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/mmp.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/mmp.kshlib @@ -36,10 +36,8 @@ function check_pool_import # pool opts token keyword typeset keyword=$4 zpool import $opts 2>&1 | \ - nawk -v token="$token:" '($1==token) {print $0}' | \ - grep -i "$keyword" > /dev/null 2>&1 - - return $? + awk -v token="$token:" '($1==token) {print}' | \ + grep -iq "$keyword" } function is_pool_imported # pool opts @@ -49,7 +47,6 @@ function is_pool_imported # pool opts check_pool_import "$pool" "$opts" "status" \ "The pool is currently imported" - return $? } function wait_pool_imported # pool opts @@ -60,8 +57,6 @@ function wait_pool_imported # pool opts while is_pool_imported "$pool" "$opts"; do log_must sleep 5 done - - return 0 } function try_pool_import # pool opts message @@ -71,8 +66,6 @@ function try_pool_import # pool opts message typeset msg=$3 zpool import $opts $pool 2>&1 | grep -i "$msg" - - return $? } function mmp_set_hostid @@ -81,11 +74,7 @@ function mmp_set_hostid zgenhostid $1 - if [ $(hostid) != "$hostid" ]; then - return 1 - fi - - return 0 + [ $(hostid) = "$hostid" ] } function mmp_clear_hostid @@ -162,45 +151,6 @@ function mmp_pool_set_hostid # pool hostid return 0 } -# Return the number of seconds the activity check portion of the import process -# will take. Does not include the time to find devices and assemble a config. -# Note that the activity check may be skipped, e.g. if the pool and host -# hostid's match, but this will return non-zero because mmp_* are populated. -function seconds_mmp_waits_for_activity -{ - typeset pool=$1 - typeset devpath=$2 - - typeset seconds=0 - typeset devices=${#DISK[@]} - typeset import_intervals=$(get_tunable MULTIHOST_IMPORT_INTERVALS) - typeset import_interval=$(get_tunable MULTIHOST_INTERVAL) - typeset tmpfile=$(mktemp) - typeset mmp_fail - typeset mmp_write - typeset mmp_delay - - log_must zdb -e -p $devpath $pool >$tmpfile 2>/dev/null - mmp_fail=$(awk '/mmp_fail/ {print $NF}' $tmpfile) - mmp_write=$(awk '/mmp_write/ {print $NF}' $tmpfile) - mmp_delay=$(awk '/mmp_delay/ {print $NF}' $tmpfile) - if [ -f $tmpfile ]; then - rm $tmpfile - fi - - # In order of preference: - if [ -n $mmp_fail -a -n $mmp_write ]; then - seconds=$((2*mmp_fail*mmp_write/1000)) - elif [ -n $mmp_delay ]; then - # MMP V0: Based on mmp_delay from the best Uberblock - seconds=$((import_intervals*devices*mmp_delay/1000000000)) - else - # Non-MMP aware: Based on zfs_multihost_interval and import_intervals - seconds=$((import_intervals*import_interval/1000)) - fi - - echo $seconds -} function import_no_activity_check # pool opts { diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/mmp_on_off.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/mmp_on_off.ksh index 29d771de8f8b..513b7d31f9cd 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/mmp_on_off.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/mmp_on_off.ksh @@ -60,9 +60,9 @@ log_must mmp_set_hostid $HOSTID1 default_setup_noexit $DISK log_must zpool set multihost=off $TESTPOOL -log_must zdb -u $TESTPOOL > $PREV_UBER +log_must eval "zdb -u $TESTPOOL > $PREV_UBER" log_must sleep 5 -log_must zdb -u $TESTPOOL > $CURR_UBER +log_must eval "zdb -u $TESTPOOL > $CURR_UBER" if ! diff "$CURR_UBER" "$PREV_UBER"; then log_fail "mmp thread has updated an uberblock" @@ -70,7 +70,7 @@ fi log_must zpool set multihost=on $TESTPOOL log_must sleep 5 -log_must zdb -u $TESTPOOL > $CURR_UBER +log_must eval "zdb -u $TESTPOOL > $CURR_UBER" if diff "$CURR_UBER" "$PREV_UBER"; then log_fail "mmp failed to update uberblocks" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/mmp_on_thread.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/mmp_on_thread.ksh index 01cca61c3c3e..cd82fa47e23f 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/mmp_on_thread.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/mmp_on_thread.ksh @@ -53,9 +53,9 @@ log_must mmp_set_hostid $HOSTID1 default_setup_noexit $DISK log_must zpool set multihost=on $TESTPOOL -log_must zdb -u $TESTPOOL > $PREV_UBER +log_must eval "zdb -u $TESTPOOL > $PREV_UBER" log_must sleep 5 -log_must zdb -u $TESTPOOL > $CURR_UBER +log_must eval "zdb -u $TESTPOOL > $CURR_UBER" if diff -u "$CURR_UBER" "$PREV_UBER"; then log_fail "mmp failed to update uberblocks" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/mmp_write_distribution.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/mmp_write_distribution.ksh index b6bdc6811634..1ac254aa1dab 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/mmp_write_distribution.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mmp/mmp_write_distribution.ksh @@ -37,7 +37,7 @@ verify_runnable "both" function cleanup { log_must zpool destroy $MMP_POOL - log_must rm $MMP_DIR/file.{0,1,2,3,4,5,6,7} + log_must rm $MMP_DIR/file.{0..7} log_must rm $MMP_HISTORY_TMP log_must rmdir $MMP_DIR log_must mmp_clear_hostid @@ -51,8 +51,8 @@ MMP_HISTORY=/proc/spl/kstat/zfs/$MMP_POOL/multihost # Step 1 log_must mkdir -p $MMP_DIR -log_must truncate -s 128M $MMP_DIR/file.{0,1,2,3,4,5,6,7} -log_must zpool create -f $MMP_POOL mirror $MMP_DIR/file.{0,1} mirror $MMP_DIR/file.{2,3,4,5,6,7} +log_must truncate -s 128M $MMP_DIR/file.{0..7} +log_must zpool create -f $MMP_POOL mirror $MMP_DIR/file.{0..1} mirror $MMP_DIR/file.{2..7} # Step 2 log_must mmp_set_hostid $HOSTID1 @@ -69,8 +69,8 @@ typeset -i min_writes=999 typeset -i max_writes=0 typeset -i write_count # copy to get as close to a consistent view as possible -cat $MMP_HISTORY > $MMP_HISTORY_TMP -for x in $(seq 0 7); do +cp $MMP_HISTORY $MMP_HISTORY_TMP +for x in {0..7}; do write_count=$(grep -c file.${x} $MMP_HISTORY_TMP) if [ $write_count -lt $min_writes ]; then min_writes=$write_count diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mount/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mount/Makefile.am deleted file mode 100644 index bdafa69badd8..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mount/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/mount -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - umount_001.ksh \ - umount_unlinked_drain.ksh \ - umountall_001.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mount/umount_unlinked_drain.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mount/umount_unlinked_drain.ksh index 6130e2c82893..40045a7a96b5 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mount/umount_unlinked_drain.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mount/umount_unlinked_drain.ksh @@ -47,8 +47,8 @@ function unlinked_size_is last_usize=0 while [[ $iters -le $MAX_ITERS ]]; do kstat_file=$(grep -nrwl /proc/spl/kstat/zfs/$2/objset-0x* -e $3) - nunlinks=`cat $kstat_file | grep nunlinks | awk '{print $3}'` - nunlinked=`cat $kstat_file | grep nunlinked | awk '{print $3}'` + nunlinks=$(awk '/nunlinks/ {print $3}' $kstat_file) + nunlinked=$(awk '/nunlinked/ {print $3}' $kstat_file) usize=$(($nunlinks - $nunlinked)) if [[ $iters == $MAX_ITERS && $usize == $1 ]]; then return 0 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mount/umountall_001.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mount/umountall_001.ksh index 814c831e408c..40c94593ba2d 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mount/umountall_001.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mount/umountall_001.ksh @@ -44,11 +44,11 @@ zfs_list="/ /lib /sbin /tmp /usr /var /var/adm /var/run" # Append our ZFS filesystems to the list, not worrying about duplicates. if is_linux; then - typeset mounts=$(mount | awk '{if ($5 == "zfs") print $3}') + typeset mounts=$(mount | awk '$5 == "zfs" {print $3}') elif is_freebsd; then - typeset mounts=$(mount -p | awk '{if ($3 == "zfs") print $2}') + typeset mounts=$(mount -p | awk '$3 == "zfs" {print $2}') else - typeset mounts=$(mount -p | awk '{if ($4 == "zfs") print $3}') + typeset mounts=$(mount -p | awk '$4 == "zfs" {print $3}') fi for fs in $mounts; do @@ -56,8 +56,7 @@ for fs in $mounts; do done if is_linux; then - mounts=$(umount --fake -av -t zfs 2>&1 | \ - grep "successfully umounted" | awk '{print $1}') + mounts=$(umount --fake -av -t zfs 2>&1 | awk '/successfully umounted/ {print $1}') # Fallback to /proc/mounts for umount(8) (util-linux-ng 2.17.2) if [[ -z $mounts ]]; then mounts=$(awk '/zfs/ { print $2 }' /proc/mounts) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/Makefile.am deleted file mode 100644 index cec02140e307..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/mv_files -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - mv_files_001_pos.ksh \ - mv_files_002_pos.ksh \ - random_creation.ksh - -dist_pkgdata_DATA = \ - mv_files.cfg \ - mv_files_common.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/cleanup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/cleanup.ksh index a664433743af..1c170208b574 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/cleanup.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/cleanup.ksh @@ -34,13 +34,12 @@ verify_runnable "global" -[[ -f $TEST_BASE_DIR/exitsZero.ksh ]] && \ +[[ -f $TEST_BASE_DIR/exitsZero.ksh ]] && log_must rm -f $TEST_BASE_DIR/exitsZero.ksh -[[ -f $TEST_BASE_DIR/testbackgprocs.ksh ]] && \ +[[ -f $TEST_BASE_DIR/testbackgprocs.ksh ]] && log_must rm -f $TEST_BASE_DIR/testbackgprocs.ksh -ismounted $TESTPOOL/$TESTFS_TGT -(( $? == 0 )) && log_must zfs umount $TESTPOOL/$TESTFS_TGT +ismounted $TESTPOOL/$TESTFS_TGT ||log_must zfs umount $TESTPOOL/$TESTFS_TGT log_must zfs destroy $TESTPOOL/$TESTFS_TGT [[ -d $TESTDIR_TGT ]] && log_must rm -rf $TESTDIR_TGT diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/mv_files.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/mv_files.cfg index ed28ff1efd27..fbab8f6dad7b 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/mv_files.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/mv_files.cfg @@ -30,7 +30,7 @@ export DISK=${DISKS%% *} export DISKSARRAY=$DISKS -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') set_device_dir export TESTFILE=testfile diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/mv_files_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/mv_files_001_pos.ksh index c49b19c6c3a3..209c3509a347 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/mv_files_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/mv_files_001_pos.ksh @@ -53,8 +53,7 @@ verify_runnable "global" function cleanup { - rm -f $OLDDIR/* >/dev/null 2>&1 - rm -f $NEWDIR_IN_FS/* >/dev/null 2>&1 + rm -f $OLDDIR/* $NEWDIR_IN_FS/* >/dev/null 2>&1 } log_assert "Doing a 'mv' of a large amount of files within a zfs filesystem" \ @@ -62,7 +61,6 @@ log_assert "Doing a 'mv' of a large amount of files within a zfs filesystem" \ log_onexit cleanup -mv_test $OLDDIR $NEWDIR_IN_FS -(($? != 0 )) && log_fail "'mv' test failed to complete." +log_must mv_test $OLDDIR $NEWDIR_IN_FS log_pass diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/mv_files_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/mv_files_002_pos.ksh index fdadac32d59b..c20831babfab 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/mv_files_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/mv_files_002_pos.ksh @@ -54,8 +54,7 @@ verify_runnable "global" function cleanup { - rm -f $OLDDIR/* >/dev/null 2>&1 - rm -f $NEWDIR_ACROSS_FS/* >/dev/null 2>&1 + rm -f $OLDDIR/* $NEWDIR_ACROSS_FS/* >/dev/null 2>&1 } log_assert "Doing a 'mv' of a large amount of files across two zfs filesystems" \ @@ -63,8 +62,6 @@ log_assert "Doing a 'mv' of a large amount of files across two zfs filesystems" log_onexit cleanup -mv_test $OLDDIR $NEWDIR_ACROSS_FS -(($? != 0 )) && \ - log_fail "'mv' test failed to complete." +log_must mv_test $OLDDIR $NEWDIR_ACROSS_FS log_pass diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib index 3ddd8f113a3b..26c2e84ce4ed 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib @@ -114,9 +114,7 @@ function mv_files # function count_files { - typeset -i file_num - file_num=$(find $1 -type f -print | wc -l | tr -d ' ') - (( file_num != $2 )) && \ + (( $(find $1 -type f -print | wc -l) != $2 )) && \ log_fail "The file number of target directory"\ "$2 is not equal to that of the source "\ "directory $1" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/nestedfs/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/nestedfs/Makefile.am deleted file mode 100644 index 6a5ecf2d9a7f..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/nestedfs/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/nestedfs -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - nestedfs_001_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/no_space/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/no_space/Makefile.am deleted file mode 100644 index 31584fb17583..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/no_space/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/no_space -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - enospc_001_pos.ksh \ - enospc_002_pos.ksh \ - enospc_003_pos.ksh \ - enospc_df.ksh \ - enospc_rm.ksh - -dist_pkgdata_DATA = \ - enospc.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/no_space/enospc_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/no_space/enospc_002_pos.ksh index 2fb3fb46c44c..0aecbea7eb27 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/no_space/enospc_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/no_space/enospc_002_pos.ksh @@ -62,8 +62,8 @@ done log_mustnot_expect space zfs create $TESTPOOL/$TESTFS/subfs log_mustnot_expect space zfs clone $TESTPOOL/$TESTFS@snap $TESTPOOL/clone -log_must zfs send $TESTPOOL/$TESTFS@snap > $TEST_BASE_DIR/stream.$$ -log_mustnot_expect space zfs receive $TESTPOOL/$TESTFS/recvd < $TEST_BASE_DIR/stream.$$ +log_must eval "zfs send $TESTPOOL/$TESTFS@snap > $TEST_BASE_DIR/stream.$$" +log_mustnot_expect space eval "zfs receive $TESTPOOL/$TESTFS/recvd < $TEST_BASE_DIR/stream.$$" log_must rm $TEST_BASE_DIR/stream.$$ log_must zfs rename $TESTPOOL/$TESTFS@snap $TESTPOOL/$TESTFS@snap_newname diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/no_space/enospc_df.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/no_space/enospc_df.ksh index b1eeaf2cc569..cf788ca7fdf0 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/no_space/enospc_df.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/no_space/enospc_df.ksh @@ -64,8 +64,8 @@ log_must zfs umount $TESTPOOL/$TESTFS log_must eval "df -h | grep $TESTPOOL" # Confirm df size and used are non-zero. -size=$(df -h /$TESTPOOL | grep $TESTPOOL | awk '{print $2}') -used=$(df -h /$TESTPOOL | grep $TESTPOOL | awk '{print $3}') +size=$(df -h /$TESTPOOL | awk -v p=$TESTPOOL '$0 ~ p {print $2}') +used=$(df -h /$TESTPOOL | awk -v p=$TESTPOOL '$0 ~ p {print $3}') if [[ "$size" = "0" ]] || [[ "$used" = "0" ]] then log_fail "df failed with size $size and used $used." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/no_space/enospc_rm.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/no_space/enospc_rm.ksh index 065abc75977e..d0f4ff4a08fe 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/no_space/enospc_rm.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/no_space/enospc_rm.ksh @@ -30,6 +30,8 @@ verify_runnable "both" +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { destroy_pool $TESTPOOL diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/nopwrite/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/nopwrite/Makefile.am deleted file mode 100644 index 3f893c6382e6..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/nopwrite/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/nopwrite -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - nopwrite_copies.ksh \ - nopwrite_mtime.ksh \ - nopwrite_negative.ksh \ - nopwrite_promoted_clone.ksh \ - nopwrite_recsize.ksh \ - nopwrite_sync.ksh \ - nopwrite_varying_compression.ksh \ - nopwrite_volume.ksh - -dist_pkgdata_DATA = \ - nopwrite.shlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/online_offline/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/online_offline/Makefile.am deleted file mode 100644 index bd23f89e538a..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/online_offline/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/online_offline -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - online_offline_001_pos.ksh \ - online_offline_002_neg.ksh \ - online_offline_003_neg.ksh - -dist_pkgdata_DATA = \ - online_offline.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/online_offline/online_offline.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/online_offline/online_offline.cfg index ae4cb69adcb0..6f1121c5e99e 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/online_offline/online_offline.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/online_offline/online_offline.cfg @@ -38,5 +38,5 @@ export HOLES_COUNT=${HOLES_COUNT-"16384"} # FILESIZE/BLKSIZE/8 export STF_TIMEOUT=3600 export DISKSARRAY=$DISKS -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') set_device_dir diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/online_offline/online_offline_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/online_offline/online_offline_001_pos.ksh index 5050447c000a..1d1b1c944cc0 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/online_offline/online_offline_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/online_offline/online_offline_001_pos.ksh @@ -54,10 +54,7 @@ function cleanup # for disk in $DISKLIST; do log_must zpool online $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "Unable to online $disk" - fi + log_must check_state $TESTPOOL $disk "online" done @@ -73,17 +70,11 @@ typeset killpid="$! " for disk in $DISKLIST; do for i in 'do_offline' 'do_offline_while_already_offline'; do log_must zpool offline $TESTPOOL $disk - check_state $TESTPOOL $disk "offline" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL is not offline." - fi + log_must check_state $TESTPOOL $disk "offline" done log_must zpool online $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL did not match online state" - fi + log_must check_state $TESTPOOL $disk "online" # Delay for resilver to complete sleep 3 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/online_offline/online_offline_002_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/online_offline/online_offline_002_neg.ksh index e66e7e10fedc..a2427f2e1822 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/online_offline/online_offline_002_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/online_offline/online_offline_002_neg.ksh @@ -55,11 +55,7 @@ function cleanup # for disk in $DISKLIST; do log_must zpool online $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "Unable to online $disk" - fi - + log_must check_state $TESTPOOL $disk "online" done kill $killpid >/dev/null 2>&1 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/.gitignore new file mode 100644 index 000000000000..ae55292b08d6 --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/.gitignore @@ -0,0 +1 @@ +/utilities.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/Makefile.am deleted file mode 100644 index be881faccf3b..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/pam -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - pam_basic.ksh \ - pam_nounmount.ksh \ - pam_short_password.ksh \ - utilities.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/cleanup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/cleanup.ksh index e41622d771b4..8ea9c848b0ab 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/cleanup.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/cleanup.ksh @@ -26,8 +26,4 @@ rmconfig destroy_pool $TESTPOOL del_user ${username} del_group pamtestgroup - -rm -rf "$runstatedir" -for dir in $TESTDIRS; do - rm -rf $dir -done +log_must rm -rf "$runstatedir" $TESTDIRS diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/setup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/setup.ksh index 23515a598e72..82370a211fcd 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/setup.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/setup.ksh @@ -22,9 +22,8 @@ . $STF_SUITE/tests/functional/pam/utilities.kshlib -if ! which pamtester; then - log_unsupported "pam tests require the pamtester utility to be installed" -fi +command -v pamtester > /dev/null || log_unsupported "pam tests require the pamtester utility to be installed" +[ -f "$pammodule" ] || log_unsupported "$pammodule missing" DISK=${DISKS%% *} create_pool $TESTPOOL "$DISK" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/utilities.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/utilities.kshlib.in similarity index 70% rename from sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/utilities.kshlib rename to sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/utilities.kshlib.in index d328034300b1..29c6ada3dbf3 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/utilities.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pam/utilities.kshlib.in @@ -24,24 +24,25 @@ username="pamtestuser" runstatedir="${TESTDIR}_run" +pammodule="@pammoduledir@/pam_zfs_key.so" pamservice="pam_zfs_key_test" pamconfig="/etc/pam.d/${pamservice}" function keystatus { - log_must [ "$(zfs list -Ho keystatus "$TESTPOOL/pam/${username}")" == "$1" ] + log_must [ "$(get_prop keystatus "$TESTPOOL/pam/${username}")" = "$1" ] } function genconfig { - for i in password auth session; do - printf "%s\trequired\tpam_permit.so\n%s\toptional\tpam_zfs_key.so\t%s\n" "$i" "$i" "$1" - done > "${pamconfig}" + printf '%s\trequired\tpam_permit.so\n%s\toptional\t%s\t%s\n' \ + password password "$pammodule" "$1" \ + auth auth "$pammodule" "$1" \ + session session "$pammodule" "$1" > "${pamconfig}" } function rmconfig { - log_must rm "${pamconfig}" + log_must rm -f "${pamconfig}" } function references { - log_must [ "$(cat "${runstatedir}/$(id -u ${username})")" == "$1" ] + log_must [ "$(<"${runstatedir}/$(id -u ${username})")" = "$1" ] } - diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pool_checkpoint/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pool_checkpoint/Makefile.am deleted file mode 100644 index cc1c1183db79..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pool_checkpoint/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/pool_checkpoint -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - checkpoint_after_rewind.ksh \ - checkpoint_big_rewind.ksh \ - checkpoint_capacity.ksh \ - checkpoint_conf_change.ksh \ - checkpoint_discard_busy.ksh \ - checkpoint_discard.ksh \ - checkpoint_discard_many.ksh \ - checkpoint_indirect.ksh \ - checkpoint_invalid.ksh \ - checkpoint_lun_expsz.ksh \ - checkpoint_open.ksh \ - checkpoint_removal.ksh \ - checkpoint_rewind.ksh \ - checkpoint_ro_rewind.ksh \ - checkpoint_sm_scale.ksh \ - checkpoint_twice.ksh \ - checkpoint_vdev_add.ksh \ - checkpoint_zdb.ksh \ - checkpoint_zhack_feat.ksh - -dist_pkgdata_DATA = \ - pool_checkpoint.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_lun_expsz.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_lun_expsz.ksh index a18e634cefa7..7cfc3b1829bc 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_lun_expsz.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_lun_expsz.ksh @@ -42,13 +42,13 @@ setup_nested_pools log_onexit cleanup_nested_pools populate_nested_pool -INITSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $2}') +INITSZ=$(zpool list -v | awk -v d="$FILEDISK1" '$0 ~ d {print $2}') log_must zpool checkpoint $NESTEDPOOL log_must truncate -s $EXPSZ $FILEDISK1 log_must zpool online -e $NESTEDPOOL $FILEDISK1 -NEWSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $2}') -DEXPSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $6}') +NEWSZ=$(zpool list -v | awk -v d="$FILEDISK1" '$0 ~ d {print $2}') +DEXPSZ=$(zpool list -v | awk -v d="$FILEDISK1" '$0 ~ d {print $6}') nested_change_state_after_checkpoint log_mustnot [ "$INITSZ" = "$NEWSZ" ] log_must [ "$DEXPSZ" = "-" ] @@ -57,8 +57,8 @@ log_must zpool export $NESTEDPOOL log_must zpool import -d $FILEDISKDIR --rewind-to-checkpoint $NESTEDPOOL nested_verify_pre_checkpoint_state -FINSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $2}') -DEXPSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $6}') +FINSZ=$(zpool list -v | awk -v d="$FILEDISK1" '$0 ~ d {print $2}') +DEXPSZ=$(zpool list -v | awk -v d="$FILEDISK1" '$0 ~ d {print $6}') log_must [ "$EXPSZ" = "$FINSZ" ] log_must [ "$DEXPSZ" != "-" ] diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_zdb.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_zdb.ksh index fdefc0c3bdbb..18ef2309c605 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_zdb.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_zdb.ksh @@ -47,8 +47,8 @@ verify_runnable "global" # with the current state. The name of this temporary pool is the # name of the actual pool with the suffix below appended to it. # -CHECKPOINT_SUFFIX="_CHECKPOINTED_UNIVERSE" -CHECKPOINTED_FS1=$TESTPOOL$CHECKPOINT_SUFFIX/$TESTFS1 +BOGUS_SUFFIX="_CHECKPOINTED_UNIVERSE" +CHECKPOINTED_FS1=$TESTPOOL$BOGUS_SUFFIX/$TESTFS1 setup_test_pool log_onexit cleanup_test_pool @@ -58,41 +58,23 @@ log_must zpool checkpoint $TESTPOOL test_change_state_after_checkpoint -zdb $TESTPOOL | grep "Checkpointed uberblock found" || \ - log_fail "zdb could not find checkpointed uberblock" - -zdb -k $TESTPOOL | grep "Checkpointed uberblock found" && \ - log_fail "zdb found checkpointed uberblock in checkpointed state" - -zdb $TESTPOOL | grep "Dataset $FS1" && \ - log_fail "zdb found destroyed dataset in current state" - -zdb -k $TESTPOOL | grep "Dataset $CHECKPOINTED_FS1" || \ - log_fail "zdb could not find destroyed dataset in checkpoint" +log_must eval "zdb $TESTPOOL | grep -q \"Checkpointed uberblock found\"" +log_mustnot eval "zdb -k $TESTPOOL | grep -q \"Checkpointed uberblock found\"" +log_mustnot eval "zdb $TESTPOOL | grep \"Dataset $FS1\"" +log_must eval "zdb -k $TESTPOOL | grep \"Dataset $CHECKPOINTED_FS1\"" log_must zpool export $TESTPOOL -zdb -e $TESTPOOL | grep "Checkpointed uberblock found" || \ - log_fail "zdb could not find checkpointed uberblock" - -zdb -k -e $TESTPOOL | grep "Checkpointed uberblock found" && \ - log_fail "zdb found checkpointed uberblock in checkpointed state" - -zdb -e $TESTPOOL | grep "Dataset $FS1" && \ - log_fail "zdb found destroyed dataset in current state" - -zdb -k -e $TESTPOOL | grep "Dataset $CHECKPOINTED_FS1" || \ - log_fail "zdb could not find destroyed dataset in checkpoint" +log_must eval "zdb -e $TESTPOOL | grep \"Checkpointed uberblock found\"" +log_mustnot eval "zdb -k -e $TESTPOOL | grep \"Checkpointed uberblock found\"" +log_mustnot eval "zdb -e $TESTPOOL | grep \"Dataset $FS1\"" +log_must eval "zdb -k -e $TESTPOOL | grep \"Dataset $CHECKPOINTED_FS1\"" log_must zpool import $TESTPOOL log_must zpool checkpoint -d $TESTPOOL -zdb $TESTPOOL | grep "Checkpointed uberblock found" && \ - log_fail "zdb found checkpointed uberblock after discarding " \ - "the checkpoint" - -zdb -k $TESTPOOL && \ - log_fail "zdb opened checkpointed state that was discarded" +log_mustnot eval "zdb $TESTPOOL | grep \"Checkpointed uberblock found\"" +log_mustnot eval "zdb -k $TESTPOOL" log_pass "zdb can analyze checkpointed pools." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pool_names/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pool_names/Makefile.am deleted file mode 100644 index cd874861f0ac..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pool_names/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/pool_names -dist_pkgdata_SCRIPTS = \ - pool_names_001_pos.ksh \ - pool_names_002_neg.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/poolversion/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/poolversion/Makefile.am deleted file mode 100644 index 51c2046457df..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/poolversion/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/poolversion -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - poolversion_001_pos.ksh \ - poolversion_002_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/poolversion/poolversion_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/poolversion/poolversion_001_pos.ksh index 048cb29e3217..1f4780ccd387 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/poolversion/poolversion_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/poolversion/poolversion_001_pos.ksh @@ -47,8 +47,7 @@ log_assert "zpool set version can upgrade a pool" for version in 1 2 3 4 5 6 7 8 do log_must zpool set version=$version $TESTPOOL - ACTUAL=$(zpool get version $TESTPOOL | grep version \ - | awk '{print $3}') + ACTUAL=$(get_pool_prop version $TESTPOOL) if [ "$ACTUAL" != "$version" ] then log_fail "v. $ACTUAL set for $TESTPOOL, expected v. $version!" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/poolversion/poolversion_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/poolversion/poolversion_002_pos.ksh index 69586473eaab..15cd446b6ea6 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/poolversion/poolversion_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/poolversion/poolversion_002_pos.ksh @@ -50,7 +50,7 @@ log_must zpool set version=6 $TESTPOOL2 # verify it's actually that version - by checking the version property # and also by trying to set bootfs (which should fail if it is not version 6) -VERSION=$(zpool get version $TESTPOOL2| grep version | awk '{print $3}') +VERSION=$(get_pool_prop version $TESTPOOL2) if [ "$VERSION" != "6" ] then log_fail "Version $VERSION set for $TESTPOOL2 expected version 6!" @@ -62,7 +62,7 @@ log_mustnot zpool set version=5 $TESTPOOL2 log_mustnot zpool set version=-1 $TESTPOOL2 # verify the version is still 6 -VERSION=$(zpool get version $TESTPOOL2 | grep version | awk '{print $3}') +VERSION=$(get_pool_prop version $TESTPOOL2) if [ "$VERSION" != "6" ] then log_fail "Version $VERSION set for $TESTPOOL2, expected version 6!" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/privilege/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/privilege/Makefile.am deleted file mode 100644 index ef26a750bb00..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/privilege/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/privilege -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - privilege_001_pos.ksh \ - privilege_002_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/privilege/setup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/privilege/setup.ksh index 4eb069394475..9d48d1961a7b 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/privilege/setup.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/privilege/setup.ksh @@ -36,8 +36,7 @@ USES_NIS=false # if we're running NIS, turn it off until we clean up # (it can cause useradd to take a long time, hitting our TIMEOUT) -svcs svc:/network/nis/client:default | grep online > /dev/null -if [ $? -eq 0 ] +if svcs svc:/network/nis/client:default | grep -q online then svcadm disable svc:/network/nis/client:default USES_NIS=true diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/Makefile.am deleted file mode 100644 index a7f022d9f210..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/procfs -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - procfs_list_basic.ksh \ - procfs_list_concurrent_readers.ksh \ - procfs_list_stale_read.ksh \ - pool_state.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/pool_state.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/pool_state.ksh index 080fdddb2d8f..d29bfd806913 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/pool_state.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/pool_state.ksh @@ -106,7 +106,7 @@ log_assert "Testing /proc/spl/kstat/zfs//state kstat" check_all $TESTPOOL "ONLINE" # Fault one of the disks, and check that pool is degraded -DISK1=$(echo "$DISKS" | awk '{print $2}') +read -r DISK1 _ <<<"$DISKS" log_must zpool offline -tf $TESTPOOL $DISK1 check_all $TESTPOOL "DEGRADED" log_must zpool online $TESTPOOL $DISK1 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh index 9104e4ba2ac3..18caea3c32cc 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh @@ -48,8 +48,8 @@ function cleanup function count_snap_cmds { typeset expected_count=$1 - count=$(grep -E "command: (lt-)?zfs snapshot $FS@testsnapshot" | wc -l) - log_must eval "[[ $count -eq $expected_count ]]" + count=$(grep -cE "command: (lt-)?zfs snapshot $FS@testsnapshot") + log_must [ "$count" -eq "$expected_count" ] } typeset -r ZFS_DBGMSG=/proc/spl/kstat/zfs/dbgmsg @@ -85,7 +85,7 @@ done # Clear out old messages and check that they really are gone echo 0 >$ZFS_DBGMSG || log_fail "failed to write to $ZFS_DBGMSG" -cat $ZFS_DBGMSG | count_snap_cmds 0 +count_snap_cmds 0 < $ZFS_DBGMSG # # Even though we don't expect any messages in the file, reading should still # succeed. diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/procfs_list_concurrent_readers.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/procfs_list_concurrent_readers.ksh index a24452ed5892..fcdd54da3591 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/procfs_list_concurrent_readers.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/procfs_list_concurrent_readers.ksh @@ -41,8 +41,7 @@ function cleanup { - [[ -z $msgs1 ]] || log_must rm $msgs1 - [[ -z $msgs2 ]] || log_must rm $msgs2 + log_must rm -f $msgs1 $msgs2 datasetexists $FS && destroy_dataset $FS -r } @@ -69,7 +68,7 @@ msgs2=$(mktemp) || log_fail # Start reading file, pause and read it from another process, and then finish # reading. # -{ dd bs=512 count=4; cat $ZFS_DBGMSG >$msgs1; cat; } <$ZFS_DBGMSG >$msgs2 +{ dd bs=512 count=4; cp $ZFS_DBGMSG $msgs1; cat; } <$ZFS_DBGMSG >$msgs2 # # Truncate the result of the read that completed second in case it picked up an diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/procfs_list_stale_read.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/procfs_list_stale_read.ksh index b3958b345d2a..dcc71788682d 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/procfs_list_stale_read.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/procfs/procfs_list_stale_read.ksh @@ -74,9 +74,9 @@ function do_test # finish reading. # { - log_must dd bs=512 count=4 >/dev/null + log_must eval "dd bs=512 count=4 >/dev/null" log_must eval "$cmd" - cat 2>&1 >/dev/null | log_must grep "Input/output error" + log_must eval 'cat 2>&1 >/dev/null | grep "Input/output error"' } <$TXG_HIST } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/Makefile.am deleted file mode 100644 index e98c8672802e..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/projectquota -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - projectid_001_pos.ksh \ - projectid_002_pos.ksh \ - projectid_003_pos.ksh \ - projectquota_001_pos.ksh \ - projectquota_002_pos.ksh \ - projectquota_003_pos.ksh \ - projectquota_004_neg.ksh \ - projectquota_005_pos.ksh \ - projectquota_006_pos.ksh \ - projectquota_007_pos.ksh \ - projectquota_008_pos.ksh \ - projectquota_009_pos.ksh \ - projectspace_001_pos.ksh \ - projectspace_002_pos.ksh \ - projectspace_003_pos.ksh \ - projectspace_004_pos.ksh \ - projecttree_001_pos.ksh \ - projecttree_002_pos.ksh \ - projecttree_003_neg.ksh - -dist_pkgdata_DATA = \ - projectquota.cfg \ - projectquota_common.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/projectquota_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/projectquota_003_pos.ksh index 06f360d30b2b..44a5b09f9001 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/projectquota_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/projectquota_003_pos.ksh @@ -54,7 +54,7 @@ log_onexit cleanup log_assert "Check the basic function of project{obj}used" sync_pool -typeset project_used=$(get_value "projectused@$PRJID1" $QFS) +typeset project_used=$(get_prop "projectused@$PRJID1" $QFS) typeset file_size='10m' if [[ $project_used != 0 ]]; then @@ -66,8 +66,8 @@ log_must user_run $PUSER mkdir $PRJDIR log_must chattr +P -p $PRJID1 $PRJDIR log_must user_run $PUSER mkfile $file_size $PRJDIR/qf sync_pool -project_used=$(get_value "projectused@$PRJID1" $QFS) -# get_value() reads the exact byte value which is slightly more than 10m +project_used=$(get_prop "projectused@$PRJID1" $QFS) +# get_prop() reads the exact byte value which is slightly more than 10m if [[ "$(($project_used/1024/1024))m" != "$file_size" ]]; then log_note "project $PRJID1 used is $project_used" log_fail "projectused for project $PRJID1 expected to be $file_size, " \ @@ -75,7 +75,7 @@ if [[ "$(($project_used/1024/1024))m" != "$file_size" ]]; then fi log_must rm -rf $PRJDIR -typeset project_obj_used=$(get_value "projectobjused@$PRJID2" $QFS) +typeset project_obj_used=$(get_prop "projectobjused@$PRJID2" $QFS) typeset file_count=100 if [[ $project_obj_used != 0 ]]; then @@ -88,7 +88,7 @@ log_must chattr +P -p $PRJID2 $PRJDIR # $PRJDIR has already used one object with the $PRJID2 log_must user_run $PUSER mkfiles $PRJDIR/qf_ $((file_count - 1)) sync_pool -project_obj_used=$(get_value "projectobjused@$PRJID2" $QFS) +project_obj_used=$(get_prop "projectobjused@$PRJID2" $QFS) if [[ $project_obj_used != $file_count ]]; then log_note "project $PRJID2 used is $project_obj_used" log_fail "projectobjused for project $PRJID2 expected to be " \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/projectquota_common.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/projectquota_common.kshlib index 0582164f9d6c..a90e001b2407 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/projectquota_common.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/projectquota_common.kshlib @@ -75,21 +75,6 @@ function check_quota fi } -function get_value -{ - typeset prop_val - typeset prop=$1 - typeset dataset=$2 - - prop_val=$(zfs get -H -p -o value $prop $dataset 2>/dev/null) - if [[ $? -ne 0 ]]; then - log_note "Unable to get $prop property for dataset $dataset" - return 1 - fi - - echo $prop_val -} - function project_obj_count { typeset fs=$1 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh index fc4a93f04463..51e790348ca6 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh @@ -65,10 +65,10 @@ log_must chattr +P -p $PRJID1 $PRJDIR log_must user_run $PUSER mkfile 50m $PRJDIR/qf sync_pool -total=$(df $PRJDIR | tail -n 1 | awk '{ print $2 }') +total=$(df $PRJDIR | awk 'END { print $2 }') [[ $total -eq 102400 ]] || log_fail "expect '102400' resource, but got '$total'" -used=$(df -i $PRJDIR | tail -n 1 | awk '{ print $5 }') +used=$(df -i $PRJDIR | awk 'END { print $5 }') [[ "$used" == "2%" ]] || log_fail "expect '2%' used, but got '$used'" log_pass "'df' on the directory with inherit project ID flag pass as expect" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/setup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/setup.ksh index 88906d91cdbb..0402d241b100 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/setup.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/projectquota/setup.ksh @@ -45,10 +45,8 @@ log_must add_user $PGROUP $PUSER # # chmod 0750 $HOME # -user_run $PUSER zfs list -if [ $? -ne 0 ]; then +user_run $PUSER zfs list || log_unsupported "Test user $PUSER cannot execute zfs utilities" -fi DISK=${DISKS%% *} default_setup_noexit $DISK diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pyzfs/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pyzfs/Makefile.am deleted file mode 100644 index 26c5ac595a5d..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pyzfs/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -include $(top_srcdir)/config/Substfiles.am - -pkgpyzfsdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/pyzfs -pkgpyzfs_SCRIPTS = \ - pyzfs_unittest.ksh - -SUBSTFILES += $(pkgpyzfs_SCRIPTS) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pyzfs/pyzfs_unittest.ksh.in b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pyzfs/pyzfs_unittest.ksh.in index 84e20e2e7eba..d55c4f3270ae 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pyzfs/pyzfs_unittest.ksh.in +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/pyzfs/pyzfs_unittest.ksh.in @@ -32,10 +32,8 @@ fi verify_runnable "global" # Verify that the required dependencies for testing are installed. -@PYTHON@ -c "import cffi" 2>/dev/null -if [ $? -eq 1 ]; then +@PYTHON@ -c "import cffi" 2>/dev/null || log_unsupported "python3-cffi not found by Python" -fi # We don't just try to "import libzfs_core" because we want to skip these tests # only if pyzfs was not installed due to missing, build-time, dependencies; if @@ -43,19 +41,16 @@ fi # mismatch, we want to report it. @PYTHON@ -c ' import pkgutil, sys -sys.exit(pkgutil.find_loader("libzfs_core") is None)' -if [ $? -eq 1 ]; then +sys.exit(pkgutil.find_loader("libzfs_core") is None)' || log_unsupported "libzfs_core not found by Python" -fi log_assert "Verify the nvlist and libzfs_core Python unittest run successfully" -# NOTE: don't use log_must() here because it makes output unreadable +# log_must buffers stderr, which interacts badly with +# no-output timeouts on CI runners @PYTHON@ -m unittest --verbose \ libzfs_core.test.test_nvlist.TestNVList \ - libzfs_core.test.test_libzfs_core.ZFSTest -if [ $? -ne 0 ]; then + libzfs_core.test.test_libzfs_core.ZFSTest || log_fail "Python unittest completed with errors" -fi log_pass "Python unittest completed without errors" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/quota/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/quota/Makefile.am deleted file mode 100644 index ba18bff7ecb7..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/quota/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/quota -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - quota_001_pos.ksh \ - quota_002_pos.ksh \ - quota_003_pos.ksh \ - quota_004_pos.ksh \ - quota_005_pos.ksh \ - quota_006_neg.ksh - -dist_pkgdata_DATA = \ - quota.cfg \ - quota.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/quota/quota.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/quota/quota.kshlib index 0ffe6394b54a..12e882d47e34 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/quota/quota.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/quota/quota.kshlib @@ -59,8 +59,8 @@ function fill_quota file_write -o create -f $MNTPT/$TESTFILE1 -b $BLOCK_SIZE \ -c $write_size -d 0 zret=$? - [[ $zret -ne $EDQUOT ]] && \ - log_fail "Returned error code: $zret. Expected: $EDQUOT." + [[ $zret -ne $EDQUOT ]] && \ + log_fail "Returned error code: $zret. Expected: $EDQUOT." typeset -i file_size=`ls -lsk $MNTPT/$TESTFILE1 | awk '{ print $1 }'` typeset -i limit=0 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/raidz/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/raidz/Makefile.am deleted file mode 100644 index d93eb73cf832..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/raidz/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/raidz -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - raidz_001_neg.ksh \ - raidz_002_pos.ksh \ - raidz_003_pos.ksh \ - raidz_004_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/Makefile.am deleted file mode 100644 index 61d0ea21356e..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/redacted_send -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - redacted_compressed.ksh \ - redacted_contents.ksh \ - redacted_deleted.ksh \ - redacted_disabled_feature.ksh \ - redacted_embedded.ksh \ - redacted_holes.ksh \ - redacted_incrementals.ksh \ - redacted_largeblocks.ksh \ - redacted_many_clones.ksh \ - redacted_mixed_recsize.ksh \ - redacted_mounts.ksh \ - redacted_negative.ksh \ - redacted_origin.ksh \ - redacted_panic.ksh \ - redacted_props.ksh \ - redacted_resume.ksh \ - redacted_size.ksh \ - redacted_volume.ksh - -dist_pkgdata_DATA = \ - redacted.cfg \ - redacted.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted.cfg index f964b37bad3b..3b9e1714dfe9 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted.cfg @@ -23,8 +23,8 @@ # Copyright (c) 2018 by Delphix. All rights reserved. # -export DISK1=$(echo $DISKS | awk '{print $1}') -export DISK2=$(echo $DISKS | awk '{print $2}') +read -r DISK1 DISK2 _ <<<"$DISKS" +export DISK1 DISK2 export POOL=$TESTPOOL export POOL2=$TESTPOOL2 @@ -83,4 +83,4 @@ typeset RANGE12="0,2097152" typeset RANGE13="0,16384" typeset RANGE14="" typeset RANGE15="0,4194304" -typeset RANGE16="0,6291456" \ No newline at end of file +typeset RANGE16="0,6291456" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted.kshlib index 30101939db64..a3810d55f97c 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted.kshlib @@ -29,6 +29,10 @@ . $STF_SUITE/tests/functional/rsend/rsend.kshlib . $STF_SUITE/tests/functional/redacted_send/redacted.cfg +if ! is_linux; then + alias udevadm=: +fi + function setup_dataset { typeset ds_name=$1 @@ -227,7 +231,7 @@ function compare_files [[ -f $file2 ]] || log_fail "File $file2 does not exist." log_must eval "get_diff $file1 $file2 >$tmpfile" - typeset range="$(cat $tmpfile)" + typeset range="$(<$tmpfile)" log_must unmount_redacted $recvfs [[ "$expected" = "$range" ]] || log_fail "Unexpected range: $range" } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_embedded.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_embedded.ksh index 1c5b503a9be5..35faf038ad8f 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_embedded.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_embedded.ksh @@ -60,13 +60,10 @@ for recsize in 512 1024 2048 4096 8192 16384; do log_must eval "zdb -ddddd $sendfs $send_obj >$tmpdir/send.zdb" log_must eval "zdb -ddddd $recvfs $recv_obj >$tmpdir/recv.zdb" - grep -q "EMBEDDED" $tmpdir/send.zdb || \ - log_fail "Obj $send_obj not embedded in $sendfs" - grep -q "EMBEDDED" $tmpdir/recv.zdb || \ - log_fail "Obj $recv_obj not embedded in $recvfs" + log_must grep -q "EMBEDDED" $tmpdir/send.zdb + log_must grep -q "EMBEDDED" $tmpdir/recv.zdb - cat $stream | zstream dump -v | log_must grep -q \ - "WRITE_EMBEDDED object = $send_obj offset = 0" + log_must eval "zstream dump -v $stream | grep -q \"WRITE_EMBEDDED object = $send_obj offset = 0\"" done log_must zfs destroy -R $recvfs @@ -91,13 +88,10 @@ for recsize in 1024 4096 16384; do log_must eval "zdb -ddddd $sendfs $send_obj >$tmpdir/send.zdb" log_must eval "zdb -ddddd $recvfs $recv_obj >$tmpdir/recv.zdb" - grep -q "EMBEDDED" $tmpdir/send.zdb || \ - log_fail "Obj $send_obj not embedded in $sendfs" - grep -q "EMBEDDED" $tmpdir/recv.zdb || \ - log_fail "Obj $recv_obj not embedded in $recvfs" + log_must grep -q "EMBEDDED" $tmpdir/send.zdb + log_must grep -q "EMBEDDED" $tmpdir/recv.zdb - cat $stream | zstream dump -v | log_must grep -q \ - "WRITE_EMBEDDED object = $send_obj offset = 0" + log_must eval "zstream dump -v $stream | log_must grep -q \"WRITE_EMBEDDED object = $send_obj offset = 0\"" done log_pass "Embedded blocks and redacted send work correctly together." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_props.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_props.ksh index e4163c4ef8da..74b71cdf6954 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_props.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_props.ksh @@ -66,8 +66,8 @@ get_guid_list $tmpdir/prop_list $sendfs#book1 get_guid_list $tmpdir/zdb_list $sendfs#book1 true get_guid_list $tmpdir/recvd_prop_list $recvfs@snap -count=$(wc -l $tmpdir/prop_list | awk '{print $1}') -[[ $count -eq 16 ]] || log_fail "Found incorrect number of redaction snapshots." +count=$(wc -l < $tmpdir/prop_list) +[ $count -eq 16 ] || log_fail "Found incorrect number of redaction snapshots." diff $tmpdir/prop_list $tmpdir/zdb_list || \ log_fail "Property list differed from zdb output" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_resume.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_resume.ksh index 8118ea59ec8b..31f7b0ada82c 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_resume.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_resume.ksh @@ -53,7 +53,7 @@ log_must mount_redacted -f $recvfs log_must set_tunable32 ALLOW_REDACTED_DATASET_MOUNT 1 log_must diff $send_mnt/f1 $recv_mnt/f1 log_must eval "get_diff $send_mnt/f2 $recv_mnt/f2 >$tmpdir/get_diff.out" -typeset range=$(cat $tmpdir/get_diff.out) +typeset range=$(<$tmpdir/get_diff.out) [[ "$RANGE9" = "$range" ]] || log_fail "Unexpected range: $range" log_must dd if=/dev/urandom of=$send_mnt/f3 bs=1024k count=3 @@ -70,7 +70,7 @@ resume_test "zfs send --redact book2 -i $sendfs#book1 $sendfs@snap2" \ log_must diff $send_mnt/f1 $recv_mnt/f1 log_must diff $send_mnt/f2 $recv_mnt/f2 log_must eval "get_diff $send_mnt/f3 $recv_mnt/f3 >$tmpdir/get_diff.out" -range=$(cat $tmpdir/get_diff.out) +range=$(<$tmpdir/get_diff.out) [[ "$RANGE10" = "$range" ]] || log_fail "Unexpected range: $range" # Test recv -A works properly and verify saved sends are not allowed diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_size.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_size.ksh index 7456084b04bc..1634ffe06463 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_size.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redacted_send/redacted_size.ksh @@ -43,22 +43,19 @@ typeset clone_mnt="$(get_prop mountpoint $clone)" log_must rm -rf $clone_mnt/* log_must zfs snapshot $clone@snap log_must zfs redact $sendfs@snap book $clone@snap -log_must eval "zfs send -nvP --redact book $sendfs@snap | \ - grep '^size' | awk '{print \$2}' >$size" -log_must eval "zfs send --redact book $sendfs@snap | wc -c \ - >$size2" -bytes1=$(cat $size | tr -d '[[:space:]]') -bytes2=$(cat $size2 | tr -d '[[:space:]]') -[[ "$bytes1" -eq "$bytes2" ]] || \ +log_must eval "zfs send -nvP --redact book $sendfs@snap | awk '/^size/ {print \$2}' >$size" +log_must eval "zfs send --redact book $sendfs@snap | wc -c >$size2" +read -r bytes1 < $size +read -r bytes2 < $size2 +[ "$bytes1" -eq "$bytes2" ] || \ log_fail "Full sizes differ: estimate $bytes1 and actual $bytes2" log_must zfs snapshot $sendfs@snap2 -log_must eval "zfs send -nvP -i $sendfs#book $sendfs@snap2 | \ - grep '^size' | awk '{print \$2}' >$size" +log_must eval "zfs send -nvP -i $sendfs#book $sendfs@snap2 | awk '/^size/ {print \$2}' >$size" log_must eval "zfs send -i $sendfs#book $sendfs@snap2 | wc -c >$size2" -bytes1=$(cat $size | tr -d '[[:space:]]') -bytes2=$(cat $size2 | tr -d '[[:space:]]') -[[ "$bytes1" -eq "$bytes2" ]] || \ +read -r bytes1 < $size +read -r bytes2 < $size2 +[ "$bytes1" -eq "$bytes2" ] || \ log_fail "Incremental sizes differ: estimate $bytes1 and actual $bytes2" log_pass "Size estimates of redacted sends estimate accurately." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/Makefile.am deleted file mode 100644 index 42c11c4aa957..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/redundancy -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - redundancy_draid.ksh \ - redundancy_draid1.ksh \ - redundancy_draid2.ksh \ - redundancy_draid3.ksh \ - redundancy_draid_damaged.ksh \ - redundancy_draid_spare1.ksh \ - redundancy_draid_spare2.ksh \ - redundancy_draid_spare3.ksh \ - redundancy_mirror.ksh \ - redundancy_raidz.ksh \ - redundancy_raidz1.ksh \ - redundancy_raidz2.ksh \ - redundancy_raidz3.ksh \ - redundancy_stripe.ksh - -dist_pkgdata_DATA = \ - redundancy.cfg \ - redundancy.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib index 55816b451612..78c33d81db26 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib @@ -142,7 +142,6 @@ function setup_test_env log_must zpool create -O compression=off -f -m $TESTDIR $pool $keyword $vdevs log_note "Filling up the filesystem ..." - typeset -i ret=0 typeset -i i=0 typeset file=$TESTDIR/file typeset -i limit @@ -150,9 +149,7 @@ function setup_test_env while true ; do [[ $(get_prop available $pool) -lt $limit ]] && break - file_write -o create -f $file.$i -b $BLOCKSZ -c $NUM_WRITES - ret=$? - (( $ret != 0 )) && break + file_write -o create -f $file.$i -b $BLOCKSZ -c $NUM_WRITES || break (( i = i + 1 )) done @@ -163,16 +160,13 @@ function refill_test_env { log_note "Re-filling the filesystem ..." typeset pool=$1 - typeset -i ret=0 typeset -i i=0 typeset mntpnt mntpnt=$(get_prop mountpoint $pool) typeset file=$mntpnt/file while [[ -e $file.$i ]]; do log_must rm -f $file.$i - file_write -o create -f $file.$i -b $BLOCKSZ -c $NUM_WRITES - ret=$? - (( $ret != 0 )) && break + file_write -o create -f $file.$i -b $BLOCKSZ -c $NUM_WRITES || break (( i = i + 1 )) done @@ -195,15 +189,12 @@ function is_healthy return 0 else typeset -i ret - zpool status -x $pool | grep "state:" | \ - grep "FAULTED" >/dev/null 2>&1 - ret=$? - (( $ret == 0 )) && return 1 + zpool status -x $pool | grep "state:" | grep -q "FAULTED" && return 1 typeset l_scan - typeset errnum + typeset errnum _ l_scan=$(zpool status -x $pool | grep "scan:") l_scan=${l_scan##*"with"} - errnum=$(echo $l_scan | awk '{print $1}') + read -r errnum _ <<<"$l_scan" return $errnum fi @@ -221,7 +212,7 @@ function is_data_valid log_must zpool scrub -w $pool record_data $pool $PST_RECORD_FILE - if ! diff $PRE_RECORD_FILE $PST_RECORD_FILE > /dev/null 2>&1; then + if ! cmp $PRE_RECORD_FILE $PST_RECORD_FILE > /dev/null; then log_must cat $PRE_RECORD_FILE log_must cat $PST_RECORD_FILE diff -u $PRE_RECORD_FILE $PST_RECORD_FILE @@ -242,13 +233,14 @@ function get_vdevs #pool cnt typeset pool=$1 typeset -i cnt=$2 - typeset all_devs=$(zpool iostat -v $pool | awk '{print $1}'| \ - egrep -v "^pool$|^capacity$|^mirror\-[0-9]$|^raidz[1-3]\-[0-9]$|^draid[1-3].*\-[0-9]$|---" | \ - egrep -v "/old$|^$pool$") + typeset all_devs=$(zpool iostat -v $pool | awk '{print $1}' | \ + grep -vEe "^pool$|^capacity$|^mirror\-[0-9]$|^raidz[1-3]\-[0-9]$|^draid[1-3].*\-[0-9]$|---" \ + -e "/old$|^$pool$") typeset -i i=0 typeset vdevs while ((i < cnt)); do - typeset dev=$(echo $all_devs | awk '{print $1}') + typeset dev _ + read -r dev _ <<<"$all_devs" eval all_devs=\${all_devs##*$dev} vdevs="$dev $vdevs" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/redundancy_draid.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/redundancy_draid.ksh index b2721707cb75..285318853a9e 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/redundancy_draid.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/redundancy_draid.ksh @@ -77,7 +77,7 @@ function test_selfheal # log_must zpool import -o cachefile=none -d $dir $pool typeset mntpnt=$(get_prop mountpoint $pool/fs) - log_must find $mntpnt -type f -exec cksum {} + >> /dev/null 2>&1 + log_must eval "find $mntpnt -type f -exec cksum {} + >> /dev/null 2>&1" log_must check_pool_status $pool "errors" "No known data errors" # @@ -100,7 +100,7 @@ function test_selfheal # log_must zpool import -o cachefile=none -d $dir $pool typeset mntpnt=$(get_prop mountpoint $pool/fs) - log_must find $mntpnt -type f -exec cksum {} + >> /dev/null 2>&1 + log_must eval "find $mntpnt -type f -exec cksum {} + >> /dev/null 2>&1" log_must check_pool_status $pool "errors" "No known data errors" log_must zpool scrub -w $pool diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/redundancy_draid_spare3.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/redundancy_draid_spare3.ksh index 28e8e3c6d707..dd4bca2795b9 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/redundancy_draid_spare3.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/redundancy_draid_spare3.ksh @@ -48,10 +48,6 @@ function cleanup_tunable log_onexit cleanup_tunable -if is_kmemleak; then - log_unsupported "Test case runs slowly when kmemleak is enabled" -fi - # # Disable scrubbing after a sequential resilver to verify the resilver # alone is able to reconstruct the data without the help of a scrub. diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/redundancy_raidz.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/redundancy_raidz.ksh index 7351cfaae5ed..a3ea3e53cb75 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/redundancy_raidz.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/redundancy/redundancy_raidz.ksh @@ -77,7 +77,7 @@ function test_selfheal # log_must zpool import -o cachefile=none -d $dir $pool typeset mntpnt=$(get_prop mountpoint $pool/fs) - log_must find $mntpnt -type f -exec cksum {} + >> /dev/null 2>&1 + log_must eval "find $mntpnt -type f -exec cksum {} + >> /dev/null 2>&1" log_must check_pool_status $pool "errors" "No known data errors" # @@ -100,7 +100,7 @@ function test_selfheal # log_must zpool import -o cachefile=none -d $dir $pool typeset mntpnt=$(get_prop mountpoint $pool/fs) - log_must find $mntpnt -type f -exec cksum {} + >> /dev/null 2>&1 + log_must eval "find $mntpnt -type f -exec cksum {} + >> /dev/null 2>&1" log_must check_pool_status $pool "errors" "No known data errors" log_must zpool scrub -w $pool diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/refquota/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/refquota/Makefile.am deleted file mode 100644 index 1d8418fbbec5..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/refquota/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/refquota -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - refquota_001_pos.ksh \ - refquota_002_pos.ksh \ - refquota_003_pos.ksh \ - refquota_004_pos.ksh \ - refquota_005_pos.ksh \ - refquota_006_neg.ksh \ - refquota_007_neg.ksh \ - refquota_008_neg.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/refreserv/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/refreserv/Makefile.am deleted file mode 100644 index bd760a1f0697..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/refreserv/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/refreserv -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - refreserv_001_pos.ksh \ - refreserv_002_pos.ksh \ - refreserv_003_pos.ksh \ - refreserv_004_pos.ksh \ - refreserv_005_pos.ksh \ - refreserv_multi_raidz.ksh \ - refreserv_raidz.ksh - -dist_pkgdata_DATA = \ - refreserv.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/refreserv/refreserv_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/refreserv/refreserv_002_pos.ksh index a8f58631f7b6..6b096f5d2010 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/refreserv/refreserv_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/refreserv/refreserv_002_pos.ksh @@ -68,8 +68,7 @@ function max_refreserv log_must zfs set refreserv=$rr $ds while :; do - zfs set refreserv=$((rr + incsize)) $ds >/dev/null 2>&1 - if [[ $? == 0 ]]; then + if zfs set refreserv=$((rr + incsize)) $ds >/dev/null 2>&1; then ((rr += incsize)) continue else diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/removal/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/removal/Makefile.am deleted file mode 100644 index 878935b96d3c..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/removal/Makefile.am +++ /dev/null @@ -1,38 +0,0 @@ -# -# This file and its contents are supplied under the terms of the -# Common Development and Distribution License ("CDDL"), version 1.0. -# You may only use this file in accordance with the terms of version -# 1.0 of the CDDL. -# -# A full copy of the text of the CDDL should have accompanied this -# source. A copy of the CDDL is also available via the Internet at -# http://www.illumos.org/license/CDDL. -# - -# -# Copyright (c) 2014, 2019 by Delphix. All rights reserved. -# - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/removal - -dist_pkgdata_SCRIPTS = \ - cleanup.ksh removal_all_vdev.ksh removal_cancel.ksh \ - removal_check_space.ksh removal_condense_export.ksh \ - removal_multiple_indirection.ksh \ - removal_nopwrite.ksh removal_remap_deadlists.ksh \ - removal_reservation.ksh removal_resume_export.ksh \ - removal_sanity.ksh removal_with_add.ksh removal_with_create_fs.ksh \ - removal_with_dedup.ksh removal_with_errors.ksh \ - removal_with_export.ksh removal_with_faulted.ksh \ - removal_with_ganging.ksh \ - removal_with_remove.ksh removal_with_scrub.ksh \ - removal_with_send.ksh removal_with_send_recv.ksh \ - removal_with_snapshot.ksh removal_with_write.ksh \ - removal_with_zdb.ksh remove_mirror.ksh remove_mirror_sanity.ksh \ - remove_raidz.ksh remove_expanded.ksh remove_indirect.ksh \ - remove_attach_mirror.ksh - -dist_pkgdata_DATA = \ - removal.kshlib - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/removal diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/removal/removal.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/removal/removal.kshlib index 5752575a8bb1..664cafd9f39e 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/removal/removal.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/removal/removal.kshlib @@ -88,13 +88,6 @@ function attempt_during_removal # pool disk callback [args] return 0 } -function indirect_vdev_mapping_size # pool -{ - typeset pool=$1 - zdb -P $pool | grep 'indirect vdev' | \ - sed -E 's/.*\(([0-9]+) in memory\).*/\1/g' -} - function random_write # file write_size { typeset file=$1 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/removal/remove_attach_mirror.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/removal/remove_attach_mirror.ksh index 9bbb07cd9419..cdbd962025cf 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/removal/remove_attach_mirror.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/removal/remove_attach_mirror.ksh @@ -32,6 +32,8 @@ # 4. Reattach it to make a mirror # +command -v fio > /dev/null || log_unsupported "fio missing" + TMPDIR=${TMPDIR:-$TEST_BASE_DIR} DISK1="$TMPDIR/dsk1" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/removal/remove_mirror_sanity.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/removal/remove_mirror_sanity.ksh index 4473771521ba..21af3965ae79 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/removal/remove_mirror_sanity.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/removal/remove_mirror_sanity.ksh @@ -21,9 +21,7 @@ . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/functional/removal/removal.kshlib -DISK1=$(echo $DISKS | awk '{print $1}') -DISK2=$(echo $DISKS | awk '{print $2}') -DISK3=$(echo $DISKS | awk '{print $3}') +read -r DISK1 DISK2 DISK3 _ <<<"$DISKS" DISKS="$DISK1 $DISK2 $DISK3" log_must default_setup_noexit "$DISK1 mirror $DISK2 $DISK3" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rename_dirs/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rename_dirs/Makefile.am deleted file mode 100644 index 029daf1f564b..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rename_dirs/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/rename_dirs -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - rename_dirs_001_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rename_dirs/rename_dirs_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rename_dirs/rename_dirs_001_pos.ksh index d7b6de1a2e01..938a7d391ab5 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rename_dirs/rename_dirs_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rename_dirs/rename_dirs_001_pos.ksh @@ -61,10 +61,7 @@ mkdir -p 1/2/3/4/5 a/b/c/d/e rename_dir & sleep 10 -typeset -i retval=1 -pgrep -x rename_dir >/dev/null 2>&1 -retval=$? -if (( $retval == 0 )); then +if pgrep -x rename_dir >/dev/null 2>&1; then pkill -9 -x rename_dir >/dev/null 2>&1 fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/Makefile.am deleted file mode 100644 index fe6e4912198d..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/replacement -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - attach_import.ksh \ - attach_multiple.ksh \ - attach_rebuild.ksh \ - attach_resilver.ksh \ - detach.ksh \ - rebuild_disabled_feature.ksh \ - rebuild_multiple.ksh \ - rebuild_raidz.ksh \ - replace_import.ksh \ - replace_rebuild.ksh \ - replace_resilver.ksh \ - resilver_restart_001.ksh \ - resilver_restart_002.ksh \ - scrub_cancel.ksh - -dist_pkgdata_DATA = \ - replacement.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/attach_rebuild.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/attach_rebuild.ksh index 998d3eec7c71..384a588064b1 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/attach_rebuild.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/attach_rebuild.ksh @@ -142,10 +142,7 @@ for op in "" "-f"; do attach_test "$opt" $TESTDIR/$TESTFILE1.1 $TESTDIR/$REPLACEFILE - zpool iostat -v $TESTPOOL1 | grep "$REPLACEFILE" - if [[ $? -ne 0 ]]; then - log_fail "$REPLACEFILE is not present." - fi + log_must eval "zpool iostat -v $TESTPOOL1 | grep \"$REPLACEFILE\"" destroy_pool $TESTPOOL1 done @@ -161,10 +158,7 @@ for type in "" "raidz" "raidz1" "draid" "draid1"; do log_mustnot zpool attach -s "$opt" $TESTDIR/$TESTFILE1.1 \ $TESTDIR/$REPLACEFILE - zpool iostat -v $TESTPOOL1 | grep "$REPLACEFILE" - if [[ $? -eq 0 ]]; then - log_fail "$REPLACEFILE should not be present." - fi + log_mustnot eval "zpool iostat -v $TESTPOOL1 | grep \"$REPLACEFILE\"" destroy_pool $TESTPOOL1 done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/attach_resilver.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/attach_resilver.ksh index e99d681bb21d..d855ad928b60 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/attach_resilver.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/attach_resilver.ksh @@ -141,10 +141,7 @@ for op in "" "-f"; do attach_test "$opt" $TESTDIR/$TESTFILE1.1 $TESTDIR/$REPLACEFILE - zpool iostat -v $TESTPOOL1 | grep "$REPLACEFILE" - if [[ $? -ne 0 ]]; then - log_fail "$REPLACEFILE is not present." - fi + log_must eval "zpool iostat -v $TESTPOOL1 | grep \"$REPLACEFILE\"" destroy_pool $TESTPOOL1 done @@ -160,10 +157,7 @@ for type in "" "raidz" "raidz1" "draid"; do log_mustnot zpool attach "$opt" $TESTDIR/$TESTFILE1.1 \ $TESTDIR/$REPLACEFILE - zpool iostat -v $TESTPOOL1 | grep "$REPLACEFILE" - if [[ $? -eq 0 ]]; then - log_fail "$REPLACEFILE should not be present." - fi + log_mustnot eval "zpool iostat -v $TESTPOOL1 | grep \"$REPLACEFILE\"" destroy_pool $TESTPOOL1 done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/detach.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/detach.ksh index f049c639d8a6..8c8eb1e88331 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/detach.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/detach.ksh @@ -134,10 +134,7 @@ log_must zfs set mountpoint=$TESTDIR1 $TESTPOOL1/$TESTFS1 detach_test $TESTDIR/$TESTFILE1.1 -zpool iostat -v $TESTPOOL1 | grep "$TESTFILE1.1" -if [[ $? -eq 0 ]]; then - log_fail "$TESTFILE1.1 should no longer be present." -fi +log_mustnot eval "zpool iostat -v $TESTPOOL1 | grep \"$TESTFILE1.1\"" destroy_pool $TESTPOOL1 @@ -150,10 +147,7 @@ for type in "" "raidz" "raidz1" "draid"; do log_mustnot zpool detach $TESTDIR/$TESTFILE1.1 - zpool iostat -v $TESTPOOL1 | grep "$TESTFILE1.1" - if [[ $? -ne 0 ]]; then - log_fail "$TESTFILE1.1 is not present." - fi + log_must eval "zpool iostat -v $TESTPOOL1 | grep \"$TESTFILE1.1\"" destroy_pool $TESTPOOL1 done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/rebuild_disabled_feature.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/rebuild_disabled_feature.ksh index d17d83b78333..5e86a8ccb8ac 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/rebuild_disabled_feature.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/rebuild_disabled_feature.ksh @@ -45,8 +45,7 @@ function check_feature_flag pool=$2 expected_value=$3 - value="$(zpool get -H -o property,value all $pool | \ - egrep "$feature" | awk '{print $2}')" + value="$(zpool get -H -o property,value all $pool | awk -v f="$feature" '$0 ~ f {print $2}')" if [ "$value" = "$expected_value" ]; then log_note "$feature verified to be $value" else diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/replace_rebuild.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/replace_rebuild.ksh index b3c7995fd62a..19823de1240d 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/replace_rebuild.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/replace_rebuild.ksh @@ -145,10 +145,7 @@ for type in "" "mirror" "draid"; do replace_test "$opt" $TESTDIR/$TESTFILE1.1 $TESTDIR/$REPLACEFILE - zpool iostat -v $TESTPOOL1 | grep "$REPLACEFILE" - if [[ $? -ne 0 ]]; then - log_fail "$REPLACEFILE is not present." - fi + log_must eval "zpool iostat -v $TESTPOOL1 | grep \"$REPLACEFILE\"" destroy_pool $TESTPOOL1 log_must rm -rf /$TESTPOOL1 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/replace_resilver.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/replace_resilver.ksh index 2585397bba88..f25e8f548b72 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/replace_resilver.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/replace_resilver.ksh @@ -142,10 +142,7 @@ for type in "" "raidz" "mirror" "draid"; do replace_test "$opt" $TESTDIR/$TESTFILE1.1 $TESTDIR/$REPLACEFILE - zpool iostat -v $TESTPOOL1 | grep "$REPLACEFILE" - if [[ $? -ne 0 ]]; then - log_fail "$REPLACEFILE is not present." - fi + log_must eval "zpool iostat -v $TESTPOOL1 | grep \"$REPLACEFILE\"" destroy_pool $TESTPOOL1 log_must rm -rf /$TESTPOOL1 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/resilver_restart_001.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/resilver_restart_001.ksh index 269d31bf8905..b498ba4af730 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/resilver_restart_001.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/resilver_restart_001.ksh @@ -162,7 +162,7 @@ do # inject read io errors on vdev and verify resilver does not restart log_must zinject -a -d ${VDEV_FILES[2]} -e io -T read -f 0.25 $TESTPOOL1 - log_must cat ${DATAPATHS[1]} > /dev/null + log_must cp ${DATAPATHS[1]} /dev/null log_must zinject -c all # there should still be 2 resilver starts w/o defer, 1 with defer diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh index 4f2707693d13..bc5bc017768c 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh @@ -57,14 +57,14 @@ log_must set_tunable32 SCAN_LEGACY 1 # create the pool and a 32M file (32k blocks) log_must truncate -s $VDEV_FILE_SIZE ${VDEV_FILES[0]} $SPARE_VDEV_FILE log_must zpool create -f -O recordsize=1k $TESTPOOL1 ${VDEV_FILES[0]} -log_must dd if=/dev/urandom of=/$TESTPOOL1/file bs=1M count=32 > /dev/null 2>&1 +log_must eval "dd if=/dev/urandom of=/$TESTPOOL1/file bs=1M count=32 2>/dev/null" # determine objset/object objset=$(zdb -d $TESTPOOL1/ | sed -ne 's/.*ID \([0-9]*\).*/\1/p') object=$(ls -i /$TESTPOOL1/file | awk '{print $1}') # inject event to cause error during resilver -log_must zinject -b `printf "%x:%x:0:3fff" $objset $object` $TESTPOOL1 +log_must zinject -b $(printf "%x:%x:0:3fff" $objset $object) $TESTPOOL1 # clear events and start resilver log_must zpool events -c @@ -74,7 +74,7 @@ log_note "waiting for read errors to start showing up" for iter in {0..59} do sync_pool $TESTPOOL1 - err=$(zpool status $TESTPOOL1 | grep ${VDEV_FILES[0]} | awk '{print $3}') + err=$(zpool status $TESTPOOL1 | awk -v dev=${VDEV_FILES[0]} '$0 ~ dev {print $3}') (( $err > 0 )) && break sleep 1 done @@ -84,7 +84,7 @@ done log_note "waiting for resilver to finish" for iter in {0..59} do - finish=$(zpool events | grep "sysevent.fs.zfs.resilver_finish" | wc -l) + finish=$(zpool events | grep -cF "sysevent.fs.zfs.resilver_finish") (( $finish > 0 )) && break sleep 1 done @@ -96,7 +96,7 @@ sync_pool $TESTPOOL1 sync_pool $TESTPOOL1 # check if resilver was restarted -start=$(zpool events | grep "sysevent.fs.zfs.resilver_start" | wc -l) +start=$(zpool events | grep -cF "sysevent.fs.zfs.resilver_start") (( $start != 1 )) && log_fail "resilver restarted unnecessarily" log_pass "Resilver did not restart unnecessarily from scan errors" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/reservation/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/reservation/Makefile.am deleted file mode 100644 index 8eaf09861551..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/reservation/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/reservation -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - reservation_001_pos.ksh \ - reservation_002_pos.ksh \ - reservation_003_pos.ksh \ - reservation_004_pos.ksh \ - reservation_005_pos.ksh \ - reservation_006_pos.ksh \ - reservation_007_pos.ksh \ - reservation_008_pos.ksh \ - reservation_009_pos.ksh \ - reservation_010_pos.ksh \ - reservation_011_pos.ksh \ - reservation_012_pos.ksh \ - reservation_013_pos.ksh \ - reservation_014_pos.ksh \ - reservation_015_pos.ksh \ - reservation_016_pos.ksh \ - reservation_017_pos.ksh \ - reservation_018_pos.ksh \ - reservation_019_pos.ksh \ - reservation_020_pos.ksh \ - reservation_021_neg.ksh \ - reservation_022_pos.ksh - -dist_pkgdata_DATA = \ - reservation.cfg \ - reservation.shlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/reservation/reservation.shlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/reservation/reservation.shlib index 47bd70f7cbcc..9bac794a9784 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/reservation/reservation.shlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/reservation/reservation.shlib @@ -38,25 +38,15 @@ # function zero_reservation { - typeset resv_val dataset=$1 log_must zfs set reservation=none $dataset - resv_val=`zfs get -H reservation $dataset | awk '{print $3}'` - if [[ $? -ne 0 ]]; then - log_fail "Unable to get reservation prop on $dataset" - elif [[ $resv_val != "none" ]]; then - log_fail "Reservation not 'none' ($resv_val) as expected" - fi + log_must eval 'resv_val="$(zfs get -Ho value reservation $dataset)"' + log_must [ $resv_val = "none" ] - - resv_val=`zfs get -pH reservation $dataset | awk '{print $3}'` - if [[ $? -ne 0 ]]; then - log_fail "Unable to get reservation prop on $dataset" - elif [[ $resv_val -ne 0 ]]; then - log_fail "Reservation not 0 ($resv_val) as expected" - fi + log_must eval 'resv_val="$(zfs get -pHo value reservation $dataset)"' + log_must [ $resv_val -eq 0 ] return 0 } diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/reservation/reservation_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/reservation/reservation_001_pos.ksh index b8220791f1d4..4f151ef15c1d 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/reservation/reservation_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/reservation/reservation_001_pos.ksh @@ -60,10 +60,10 @@ function cleanup log_onexit cleanup -log_assert "Verify that to set a reservation on a filesystem or volume must " \ +log_assert "Verify that to set a reservation on a filesystem or volume must" \ "use value smaller than space available property of pool" -space_avail=`get_prop available $TESTPOOL` +space_avail=$(get_prop available $TESTPOOL) if ! is_global_zone ; then OBJ_LIST="" @@ -103,7 +103,7 @@ for obj in $TESTPOOL/$TESTFS $OBJ_LIST; do log_must zfs set reservation=$resv_size_set $obj - resv_size_get=`get_prop reservation $obj` + resv_size_get=$(get_prop reservation $obj) if [[ $resv_size_set != $resv_size_get ]]; then log_fail "Reservation not the expected value " \ "($resv_size_set != $resv_size_get)" @@ -111,7 +111,7 @@ for obj in $TESTPOOL/$TESTFS $OBJ_LIST; do log_must zero_reservation $obj - new_space_avail=`get_prop available $obj` + new_space_avail=$(get_prop available $obj) # # Due to the way space is consumed and released by metadata we diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/reservation/reservation_013_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/reservation/reservation_013_pos.ksh index bf0955223490..786d5d4d3008 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/reservation/reservation_013_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/reservation/reservation_013_pos.ksh @@ -72,8 +72,6 @@ log_must zfs create $TESTPOOL/$TESTFS1 log_must zfs create $TESTPOOL/$TESTFS1/$TESTFS2 space_avail=$(get_prop available $TESTPOOL) -[[ $? -ne 0 ]] && \ - log_fail "Unable to get space available property for $TESTPOOL" typeset -il resv_set=space_avail/5 resv_set=$(floor_volsize $resv_set) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rootpool/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rootpool/Makefile.am deleted file mode 100644 index ca5ad14fdbb1..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rootpool/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/rootpool -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - rootpool_002_neg.ksh \ - rootpool_003_neg.ksh \ - rootpool_007_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rootpool/rootpool_002_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rootpool/rootpool_002_neg.ksh index 32bacf753a0e..0d592ad33e58 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rootpool/rootpool_002_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rootpool/rootpool_002_neg.ksh @@ -54,7 +54,7 @@ typeset tmpfile="$TEST_BASE_DIR/mounted-datasets.$$" # damage done by the attempted pool destroy. The destroy itself should fail, # but some filesystems can become unmounted in the process, and aren't # automatically remounted. -mount -p | awk '{if ($4 == "zfs") print $1}' > $tmpfile +mount -p | awk '$4 == "zfs" {print $1}' > $tmpfile log_mustnot zpool destroy $rootpool diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rootpool/setup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rootpool/setup.ksh index 8d8097108190..d81b3dfbdd40 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rootpool/setup.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rootpool/setup.ksh @@ -35,7 +35,7 @@ verify_runnable "global" # # This functionality is supported under Linux, but these test cases -# are disabled by default since they manipulate the systems root pool. +# are disabled by default since they manipulate the system's root pool. # if is_linux || is_freebsd; then log_unsupported "Supported but disabled by default" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/Makefile.am deleted file mode 100644 index 305fc0d517d2..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/Makefile.am +++ /dev/null @@ -1,73 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/rsend -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - recv_dedup.ksh \ - recv_dedup_encrypted_zvol.ksh \ - rsend_001_pos.ksh \ - rsend_002_pos.ksh \ - rsend_003_pos.ksh \ - rsend_004_pos.ksh \ - rsend_005_pos.ksh \ - rsend_006_pos.ksh \ - rsend_007_pos.ksh \ - rsend_008_pos.ksh \ - rsend_009_pos.ksh \ - rsend_010_pos.ksh \ - rsend_011_pos.ksh \ - rsend_012_pos.ksh \ - rsend_013_pos.ksh \ - rsend_014_pos.ksh \ - rsend_016_neg.ksh \ - rsend_019_pos.ksh \ - rsend_020_pos.ksh \ - rsend_021_pos.ksh \ - rsend_022_pos.ksh \ - rsend_024_pos.ksh \ - rsend_025_pos.ksh \ - rsend_026_neg.ksh \ - rsend_027_pos.ksh \ - rsend_028_neg.ksh \ - rsend_029_neg.ksh \ - send_encrypted_files.ksh \ - send_encrypted_hierarchy.ksh \ - send_encrypted_props.ksh \ - send_encrypted_truncated_files.ksh \ - send-c_embedded_blocks.ksh \ - send-c_incremental.ksh \ - send-c_lz4_disabled.ksh \ - send-c_mixed_compression.ksh \ - send-c_props.ksh \ - send-c_recv_dedup.ksh \ - send-c_recv_lz4_disabled.ksh \ - send-c_resume.ksh \ - send-c_stream_size_estimate.ksh \ - send-c_verify_contents.ksh \ - send-c_verify_ratio.ksh \ - send-c_volume.ksh \ - send-c_zstreamdump.ksh \ - send-cpL_varied_recsize.ksh \ - send-L_toggle.ksh \ - send_freeobjects.ksh \ - send_partial_dataset.ksh \ - send_realloc_dnode_size.ksh \ - send_realloc_files.ksh \ - send_realloc_encrypted_files.ksh \ - send_spill_block.ksh \ - send_raw_spill_block.ksh \ - send_raw_ashift.ksh \ - send_holds.ksh \ - send_hole_birth.ksh \ - send_invalid.ksh \ - send_mixed_raw.ksh \ - send-wR_encrypted_zvol.ksh \ - send_doall.ksh - -dist_pkgdata_DATA = \ - dedup.zsend.bz2 \ - dedup_encrypted_zvol.bz2 \ - dedup_encrypted_zvol.zsend.bz2 \ - fs.tar.gz \ - rsend.cfg \ - rsend.kshlib - diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend.cfg index 8400ecfe35b4..99e87d9369ed 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend.cfg @@ -29,9 +29,8 @@ export BACKDIR=${TEST_BASE_DIR%%/}/backdir-rsend -export DISK1=$(echo $DISKS | awk '{print $1}') -export DISK2=$(echo $DISKS | awk '{print $2}') -export DISK3=$(echo $DISKS | awk '{print $3}') +read -r DISK1 DISK2 DISK3 _ <<<"$DISKS" +export DISK1 DISK2 DISK3 export POOL=$TESTPOOL export POOL2=$TESTPOOL2 diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend.kshlib index 8d704ee36876..06886131cf83 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend.kshlib @@ -128,7 +128,7 @@ function cleanup_pool # # https://github.com/openzfs/zfs/issues/6143 # - log_must df >/dev/null + log_must eval "df >/dev/null" log_must_busy zfs destroy -Rf $pool else typeset list=$(zfs list -H -r -t all -o name $pool) @@ -153,23 +153,13 @@ function cleanup_pool if [[ -d $mntpnt ]]; then rm -rf $mntpnt/* fi - - return 0 -} - -function cleanup_pools -{ - cleanup_pool $POOL2 - destroy_pool $POOL3 } function cmp_md5s { typeset file1=$1 typeset file2=$2 - typeset sum1=$(md5digest $file1) - typeset sum2=$(md5digest $file2) - test "$sum1" = "$sum2" + [ "$(md5digest $file1)" = "$(md5digest $file2)" ] } # @@ -183,18 +173,9 @@ function cmp_ds_subs typeset src_fs=$1 typeset dst_fs=$2 - zfs list -r -H -t all -o name $src_fs > $BACKDIR/src1 - zfs list -r -H -t all -o name $dst_fs > $BACKDIR/dst1 - - eval sed -e 's:^$src_fs:PREFIX:g' < $BACKDIR/src1 > $BACKDIR/src - eval sed -e 's:^$dst_fs:PREFIX:g' < $BACKDIR/dst1 > $BACKDIR/dst - - diff $BACKDIR/src $BACKDIR/dst - typeset -i ret=$? - - rm -f $BACKDIR/src $BACKDIR/dst $BACKDIR/src1 $BACKDIR/dst1 - - return $ret + diff \ + <(zfs list -rHt all -o name $src_fs | sed "s:^$src_fs:PREFIX:g") \ + <(zfs list -rHt all -o name $dst_fs | sed "s:^$dst_fs:PREFIX:g") } # @@ -213,7 +194,6 @@ function cmp_ds_cont dstdir=$(get_prop mountpoint $dst_fs) replay_directory_diff $srcdir $dstdir - return $? } # @@ -221,39 +201,30 @@ function cmp_ds_cont # # $1 dataset 1 # $2 dataset 2 +# $3 -n == don't track property source +# $4 -n == don't track the origin property # function cmp_ds_prop { typeset dtst1=$1 typeset dtst2=$2 - typeset -a props=("type" "origin" "volblocksize" "acltype" "dnodesize" \ - "atime" "canmount" "checksum" "compression" "copies" "devices" \ - "exec" "quota" "readonly" "recordsize" "reservation" "setuid" \ - "snapdir" "version" "volsize" "xattr" "mountpoint"); + typeset nosource=$3 + typeset noorigin=$4 + typeset source=",source"; [ -n "$nosource" ] && source= + typeset origin=",origin"; [ -n "$noorigin" ] && origin= + typeset props="type$origin,volblocksize,acltype,dnodesize" + props+=",atime,canmount,checksum,compression,copies,devices" + props+=",exec,quota,readonly,recordsize,reservation,setuid" + props+=",snapdir,version,volsize,xattr,mountpoint" if is_freebsd; then - props+=("jailed") + props+=",jailed" else - props+=("zoned") + props+=",zoned" fi - for prop in $props; - do - zfs get -H -o property,value,source $prop $dtst1 >> \ - $BACKDIR/dtst1 - zfs get -H -o property,value,source $prop $dtst2 >> \ - $BACKDIR/dtst2 - done - - eval sed -e 's:$dtst1:PREFIX:g' < $BACKDIR/dtst1 > $BACKDIR/dtst1 - eval sed -e 's:$dtst2:PREFIX:g' < $BACKDIR/dtst2 > $BACKDIR/dtst2 - - diff $BACKDIR/dtst1 $BACKDIR/dtst2 - typeset -i ret=$? - - rm -f $BACKDIR/dtst1 $BACKDIR/dtst2 - - return $ret - + diff \ + <(zfs get -Ho property,value$source $props $dtst1 | sed -e "s:$dtst1:PREFIX:g" -e 's/^origin [^@]*/origin POOL/' -e 's/ inherited from [^/]*/ inherited from POOL/') \ + <(zfs get -Ho property,value$source $props $dtst2 | sed -e "s:$dtst2:PREFIX:g" -e 's/^origin [^@]*/origin POOL/' -e 's/ inherited from [^/]*/ inherited from POOL/') } # @@ -295,7 +266,6 @@ function snapshot_tree typeset -i ret=0 if [[ $type == "filesystem" ]]; then typeset mntpnt=$(get_prop mountpoint $ds) - ((ret |= $?)) if ((ret == 0)) ; then eval random_tree $mntpnt/${snap##$ds} @@ -347,9 +317,7 @@ function getds_with_suffix typeset ds=$1 typeset suffix=$2 - typeset list=$(zfs list -r -H -t all -o name $ds | grep "$suffix$") - - echo $list + zfs list -rHt all -o name $ds | grep "$suffix$" } # @@ -366,8 +334,7 @@ function fs_inherit_prop fi else fs_prop=$(zfs inherit 2>&1 | \ - awk '$2=="YES" && $3=="YES" {print $1}'| - egrep -v "devices|mlslabel|sharenfs|sharesmb|zoned") + awk '$2=="YES" && $3=="YES" && !/devices|mlslabel|sharenfs|sharesmb|zoned/ {print $1}') fi echo $fs_prop @@ -378,7 +345,7 @@ function fs_inherit_prop # function vol_inherit_prop { - echo "checksum readonly" + echo checksum readonly } # @@ -597,8 +564,8 @@ function mess_send_file # We use zstream dump to verify there is an intact DRR_BEGIN record. offset=$(((($RANDOM * $RANDOM) % ($filesize - $minsize)) + $minsize)) nr_begins=$(head -c $offset $file | zstream dump | \ - grep DRR_BEGIN | awk '{ print $5 }') - log_must test "$nr_begins" -eq 1 + awk '/DRR_BEGIN/ { print $5 }') + log_must [ "$nr_begins" -eq 1 ] if (($RANDOM % 7 <= 1)); then # @@ -625,13 +592,11 @@ function file_check if [[ -d /$recvfs/.zfs/snapshot/a && -d \ /$sendfs/.zfs/snapshot/a ]]; then - directory_diff /$recvfs/.zfs/snapshot/a /$sendfs/.zfs/snapshot/a - [[ $? -eq 0 ]] || log_fail "Differences found in snap a" + log_must directory_diff /$recvfs/.zfs/snapshot/a /$sendfs/.zfs/snapshot/a fi if [[ -d /$recvfs/.zfs/snapshot/b && -d \ /$sendfs/.zfs/snapshot/b ]]; then - directory_diff /$recvfs/.zfs/snapshot/b /$sendfs/.zfs/snapshot/b - [[ $? -eq 0 ]] || log_fail "Differences found in snap b" + log_must directory_diff /$recvfs/.zfs/snapshot/b /$sendfs/.zfs/snapshot/b fi } @@ -655,20 +620,18 @@ function resume_test for ((i=0; i<2; i=i+1)); do mess_send_file /$streamfs/$stream_num - log_mustnot zfs recv -suv $recvfs /dev/null" log_must eval "zfs send -t $token >/$streamfs/$stream_num" - [[ -f /$streamfs/$stream_num ]] || \ - log_fail "NO FILE /$streamfs/$stream_num" done - log_must zfs recv -suv $recvfs /$streamfs/1" mess_send_file /$streamfs/1 - log_mustnot zfs recv -suv $recvfs < /$streamfs/1 2>&1 - token=$(zfs get -Hp -o value receive_resume_token $recvfs) - echo "$token" > /$streamfs/resume_token - - return 0 + log_mustnot eval "zfs recv -suv $recvfs < /$streamfs/1 2>&1" + get_prop receive_resume_token $recvfs > /$streamfs/resume_token } # @@ -747,7 +707,7 @@ function stream_has_features shift [[ -f $file ]] || log_fail "Couldn't find file: $file" - typeset flags=$(cat $file | zstream dump | \ + typeset flags=$(zstream dump $file | \ awk '/features =/ {features = $3} END {print features}') typeset -A feature feature[dedup]="1" @@ -797,7 +757,7 @@ function verify_stream_size [[ -f $stream ]] || log_fail "No such file: $stream" datasetexists $ds || log_fail "No such dataset: $ds" - typeset stream_size=$(cat $stream | zstream dump | sed -n \ + typeset stream_size=$(zstream dump $stream | sed -n \ 's/ Total payload size = \(.*\) (0x.*)/\1/p') typeset inc_size=0 @@ -815,8 +775,7 @@ function verify_stream_size fi ds_size=$((ds_size - inc_size)) - within_percent $stream_size $ds_size $percent || log_fail \ - "$stream_size $ds_size differed by too much" + log_must within_percent $stream_size $ds_size $percent } # Cleanup function for tests involving resumable send diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend_011_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend_011_pos.ksh index f2df0ed03460..88f79f3e921a 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend_011_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend_011_pos.ksh @@ -65,13 +65,13 @@ done # # Inherit properties in sub-datasets # -for ds in "$POOL/$FS/fs1" "$POOL/$FS/fs1/fs2" "$POOL/$FS/fs1/fclone" ; do - for prop in $(fs_inherit_prop) ; do +for ds in "$POOL/$FS/fs1" "$POOL/$FS/fs1/fs2" "$POOL/$FS/fs1/fclone"; do + for prop in $(fs_inherit_prop); do log_must zfs inherit $prop $ds done done -if is_global_zone ; then - for prop in $(vol_inherit_prop) ; do +if is_global_zone; then + for prop in $(vol_inherit_prop); do log_must zfs inherit $prop $POOL/$FS/vol done fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh index 694dd15b44f6..0608598b8333 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh @@ -47,29 +47,21 @@ function edited_prop typeset behaviour=$1 typeset ds=$2 typeset backfile=$TESTDIR/edited_prop_$ds + typeset te=0 case $behaviour in "get") + is_te_enabled && te=1 typeset props=$(zfs inherit 2>&1 | \ - awk '$2=="YES" {print $1}' | \ - grep -Ev "^vol|\.\.\.$") - for item in $props ; do - if [[ $item == "mlslabel" ]] && \ - ! is_te_enabled ; then - continue - fi - log_must eval "zfs get -H -o property,value $item $ds >> $backfile" - done + awk -v te=$te '$2=="YES" && $1 !~ /^vol|\.\.\.$/ && (te || $1 != "mlslabel") {printf("%s,", $1)}') + log_must eval "zfs get -Ho property,value ${props%,} $ds >> $backfile" ;; "set") if [[ ! -f $backfile ]] ; then log_fail "$ds need backup properties firstly." fi - typeset prop value - while read -r prop value; do - log_must zfs set "$prop=$value" "$ds" - done < $backfile + log_must zfs set $(tr '\t' '=' < $backfile) "$ds" ;; *) log_fail "Unrecognized behaviour: $behaviour" @@ -159,20 +151,16 @@ set -A pair "$POOL" "$POOL2" \ typeset -i i=0 while ((i < ${#pair[@]})); do - log_must cmp_ds_prop ${pair[$i]} ${pair[((i+1))]} - + log_must cmp_ds_prop ${pair[$i]} ${pair[((i+1))]} nosource ((i += 2)) done -zpool upgrade -v | grep "Snapshot properties" > /dev/null 2>&1 -if (( $? == 0 )) ; then - i=0 - while ((i < ${#pair[@]})); do - log_must cmp_ds_prop ${pair[$i]}@final ${pair[((i+1))]}@final - ((i += 2)) - done -fi +i=0 +while ((i < ${#pair[@]})); do + log_must cmp_ds_prop ${pair[$i]}@final ${pair[((i+1))]}@final + ((i += 2)) +done -log_pass "Verify zfs send -R will backup all the filesystem properties " \ +log_pass "Verify zfs send -R will backup all the filesystem properties" \ "correctly." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_props.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_props.ksh index 6e95c2c30b67..82a2eb91e825 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_props.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_props.ksh @@ -52,16 +52,27 @@ for opt in "-p" "-R"; do randomize_ds_props $POOL$ds done - log_must eval "zfs send -c $opt $POOL@final > $BACKDIR/pool-final$opt" - log_must eval "zfs receive -d -F $POOL2 < $BACKDIR/pool-final$opt" + if [ $opt = "-p" ]; then + for ds in ${datasets[@]}; do + log_must eval "zfs send -c $opt $POOL$ds@final > $BACKDIR/pool-final$opt" + log_must eval "zfs receive -dF $POOL2 < $BACKDIR/pool-final$opt" + done + else + log_must eval "zfs send -c $opt $POOL@final > $BACKDIR/pool-final$opt" + log_must eval "zfs receive -dF $POOL2 < $BACKDIR/pool-final$opt" + fi for ds in ${datasets[@]}; do - log_must cmp_ds_prop $POOL$ds $POOL2$ds + typeset origin= + if [ $opt = "-p" ] && [ ${ds/clone//} != $ds ]; then + origin=noorigin + fi + log_must cmp_ds_prop $POOL$ds $POOL2$ds nosource $origin log_must cmp_ds_prop $POOL$ds@final $POOL2$ds@final done # Don't cleanup the second time, since we do that on exit anyway. - [[ $opt = "-p" ]] && cleanup + [ $opt = "-p" ] && cleanup done log_pass "Compressed send doesn't interfere with preservation of properties" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh index 056fc2cc2584..5d308d8f6574 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh @@ -40,19 +40,11 @@ function get_estimated_size { typeset cmd=$1 typeset ds=${cmd##* } - if is_freebsd; then - mkdir -p $BACKDIR - typeset tmpfile=$(TMPDIR=$BACKDIR mktemp) - else - typeset tmpfile=$(mktemp -p $BACKDIR) - fi + typeset tmpfile=$(mktemp $BACKDIR/size_estimate.XXXXXXXX) - eval "$cmd >$tmpfile" - [[ $? -eq 0 ]] || log_fail "get_estimated_size: $cmd" - typeset size=$(eval "awk '\$2 == \"$ds\" {print \$3}' $tmpfile") + eval "$cmd >$tmpfile" || log_fail "$cmd: $?" + awk -v ds="$ds" '$2 == ds {print $3}' $tmpfile rm -f $tmpfile - - echo $size } log_assert "Verify the stream size given by -P accounts for compressed send." @@ -75,23 +67,19 @@ for compress in "${compress_prop_vals[@]}"; do typeset ds_size=$(get_estimated_size "zfs send -nP $send_ds@snap") typeset ds_lrefer=$(get_prop lrefer $send_ds) - within_percent $ds_size $ds_lrefer 90 || log_fail \ - "$ds_size and $ds_lrefer differed by too much" + log_must within_percent $ds_size $ds_lrefer 90 typeset vol_size=$(get_estimated_size "zfs send -nP $send_vol@snap") typeset vol_lrefer=$(get_prop lrefer $send_vol) - within_percent $vol_size $vol_lrefer 90 || log_fail \ - "$vol_size and $vol_lrefer differed by too much" + log_must within_percent $vol_size $vol_lrefer 90 typeset ds_csize=$(get_estimated_size "zfs send -nP -c $send_ds@snap") typeset ds_refer=$(get_prop refer $send_ds) - within_percent $ds_csize $ds_refer 90 || log_fail \ - "$ds_csize and $ds_refer differed by too much" + log_must within_percent $ds_csize $ds_refer 90 typeset vol_csize=$(get_estimated_size "zfs send -nP -c $send_vol@snap") typeset vol_refer=$(get_prop refer $send_vol) - within_percent $vol_csize $vol_refer 90 || log_fail \ - "$vol_csize and $vol_refer differed by too much" + log_must within_percent $vol_csize $vol_refer 90 done log_pass "The stream size given by -P accounts for compressed send." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_zstreamdump.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_zstreamdump.ksh index 5b9939c6a64c..82d15c68ec47 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_zstreamdump.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send-c_zstreamdump.ksh @@ -49,7 +49,7 @@ log_must zfs snapshot $sendfs@full log_must eval "zfs send -c $sendfs@full >$BACKDIR/full" log_must stream_has_features $BACKDIR/full lz4 compressed -cat $BACKDIR/full | zstream dump -v > $BACKDIR/dump.out +zstream dump -v $BACKDIR/full > $BACKDIR/dump.out lsize=$(awk '/^WRITE [^0]/ {lsize += $24} END {printf("%d", lsize)}' \ $BACKDIR/dump.out) @@ -63,8 +63,8 @@ csize_prop=$(get_prop used $sendfs) within_percent $csize $csize_prop 90 || log_fail \ "$csize and $csize_prop differed by too much" -x=$(get_resume_token "zfs send -c $sendfs@full" $streamfs $recvfs) -resume_token=$(cat /$streamfs/resume_token) +get_resume_token "zfs send -c $sendfs@full" $streamfs $recvfs +resume_token=$($stream" $verify eval "zfs recv $recv_ds <$stream" - typeset stream_size=$(cat $stream | zstream dump | sed -n \ + typeset stream_size=$(zstream dump $stream | sed -n \ 's/ Total write size = \(.*\) (0x.*)/\1/p') # diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send_doall.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send_doall.ksh index e5c3490b32cd..55b8c002e61a 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send_doall.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send_doall.ksh @@ -46,12 +46,7 @@ log_must zfs create $POOL/fs/child # Create 3 files and a snapshot between each file creation. for i in {1..3}; do - file="/$POOL/fs/file$i" - log_must mkfile 16384 $file - - file="/$POOL/fs/child/file$i" - log_must mkfile 16384 $file - + log_must mkfile 16384 "/$POOL/fs/file$i" "/$POOL/fs/child/file$i" log_must zfs snapshot -r $POOL/fs@snap$i done @@ -59,9 +54,6 @@ done log_must eval "send_doall $POOL/fs@snap3 >$BACKDIR/fs@snap3" log_must eval "zfs recv $POOL/newfs < $BACKDIR/fs@snap3" -zfs list $POOL/newfs/child -if [[ $? -eq 0 ]]; then - log_fail "Children dataset should not have been received" -fi +log_mustnot datasetexists $POOL/newfs/child log_pass "Verify send_doall stream is correct" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh index aa19847e0695..aff54e3a7d69 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh @@ -54,11 +54,11 @@ function recursive_cksum { case "$(uname)" in FreeBSD) - find $1 -type f -exec sha256 -q {} \; | \ + find $1 -type f -exec sha256 -q {} + | \ sort | sha256digest ;; *) - find $1 -type f -exec sha256sum {} \; | \ + find $1 -type f -exec sha256sum {} + | \ sort -k 2 | awk '{ print $1 }' | sha256digest ;; esac diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/scrub_mirror/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/scrub_mirror/Makefile.am deleted file mode 100644 index bc657fbf2ad9..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/scrub_mirror/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/scrub_mirror -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - scrub_mirror_001_pos.ksh \ - scrub_mirror_002_pos.ksh \ - scrub_mirror_003_pos.ksh \ - scrub_mirror_004_pos.ksh - -dist_pkgdata_DATA = \ - default.cfg \ - scrub_mirror_common.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/simd/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/simd/Makefile.am deleted file mode 100644 index bfc28868024a..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/simd/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/simd -dist_pkgdata_SCRIPTS = simd_supported.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/simd/simd_supported.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/simd/simd_supported.ksh index d88bc582bf08..1c89824e02fd 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/simd/simd_supported.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/simd/simd_supported.ksh @@ -32,20 +32,20 @@ # # STRATEGY: # 1. Test if we are running on a Linux x86 system with SSE support -# 2. If so, check if the zfs_fletcher_4_impl module parameter contains +# 2. If so, check if the zfs_fletcher_4_impl module parameter contains # a sse implementation # 3. If not fail the test, otherwise pass it log_note "Testing if we support SIMD instructions (Linux x86 only)" -if !is_linux; then +if ! is_linux; then log_unsupported "Not a Linux System" fi case "$(uname -m)" in -i386|i686|x86_64) - typeset -R modparam="/sys/module/zcommon/parameters/zfs_fletcher_4_impl" - if cat /proc/cpuinfo | awk '/^flags/ {print; exit;}' | grep -q sse; then +i?86|x86_64) + typeset -R modparam="/sys/module/zfs/parameters/zfs_fletcher_4_impl" + if awk '/^flags/ {exit !/sse/}' /proc/cpuinfo; then log_must grep -q sse "$modparam" log_pass "SIMD instructions supported" else diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/slog/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/slog/Makefile.am deleted file mode 100644 index 92c3fd6c8e75..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/slog/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/slog -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - slog_001_pos.ksh \ - slog_002_pos.ksh \ - slog_003_pos.ksh \ - slog_004_pos.ksh \ - slog_005_pos.ksh \ - slog_006_pos.ksh \ - slog_007_pos.ksh \ - slog_008_neg.ksh \ - slog_009_neg.ksh \ - slog_010_neg.ksh \ - slog_011_neg.ksh \ - slog_012_neg.ksh \ - slog_013_pos.ksh \ - slog_014_pos.ksh \ - slog_015_neg.ksh \ - slog_replay_fs_001.ksh \ - slog_replay_fs_002.ksh \ - slog_replay_volume.ksh \ - slog_016_pos.ksh - -dist_pkgdata_DATA = \ - slog.cfg \ - slog.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/slog/slog.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/slog/slog.kshlib index 75cfec2d832d..8bc34d0dac32 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/slog/slog.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/slog/slog.kshlib @@ -101,7 +101,7 @@ function verify_slog_device # # mirror:/disks/d ONLINE mirror:/disks/e ONLINE stripe:/disks/f ONLINE # - set -A dev_stat_tab $(zpool status -v $pool | nawk 'BEGIN {start=0} \ + set -A dev_stat_tab $(zpool status -v $pool | awk 'BEGIN {start=0} \ /\tlogs/ {start=1} /\tmirror/ || /\tspares/ || /^$/ {start=0} (start==1) && /\t (\/|[a-zA-Z])/ \ diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/slog/slog_014_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/slog/slog_014_pos.ksh index dbdf1f1ce527..9d9bcf885d50 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/slog/slog_014_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/slog/slog_014_pos.ksh @@ -76,11 +76,7 @@ for type in "mirror" "raidz" "raidz2"; do log_must zpool offline $TESTPOOL $VDIR/a log_must wait_for_degraded $TESTPOOL - zpool status -v $TESTPOOL | grep logs | \ - grep "DEGRADED" 2>&1 >/dev/null - if (( $? == 0 )); then - log_fail "log device should display correct status" - fi + log_mustnot eval "zpool status -v $TESTPOOL | grep logs | grep -q \"DEGRADED\"" log_must zpool online $TESTPOOL $VDIR/a log_must zpool destroy -f $TESTPOOL diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/slog/slog_015_neg.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/slog/slog_015_neg.ksh index 04fb225ed4ae..464be019dac3 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/slog/slog_015_neg.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/slog/slog_015_neg.ksh @@ -31,6 +31,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { # diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/Makefile.am deleted file mode 100644 index 783133a643a1..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/snapshot -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - clone_001_pos.ksh \ - rollback_001_pos.ksh \ - rollback_002_pos.ksh \ - rollback_003_pos.ksh \ - snapshot_001_pos.ksh \ - snapshot_002_pos.ksh \ - snapshot_003_pos.ksh \ - snapshot_004_pos.ksh \ - snapshot_005_pos.ksh \ - snapshot_006_pos.ksh \ - snapshot_007_pos.ksh \ - snapshot_008_pos.ksh \ - snapshot_009_pos.ksh \ - snapshot_010_pos.ksh \ - snapshot_011_pos.ksh \ - snapshot_012_pos.ksh \ - snapshot_013_pos.ksh \ - snapshot_014_pos.ksh \ - snapshot_015_pos.ksh \ - snapshot_016_pos.ksh \ - snapshot_017_pos.ksh - -dist_pkgdata_DATA = \ - snapshot.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh index 1c8a3b2a6c20..819e263b1c5b 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh @@ -113,8 +113,7 @@ log_onexit cleanup_all setup_all -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* typeset -i COUNT=10 typeset -i i=0 @@ -143,8 +142,7 @@ while (( i < ${#args[*]} )); do if [[ -n ${args[i+3]} ]] ; then log_must zfs set mountpoint=${args[i+3]} ${args[i+2]} - FILE_COUNT=`ls -Al ${args[i+3]} | grep -v "total" \ - | grep -v "\.zfs" | wc -l` + FILE_COUNT=$(ls -A ${args[i+3]} | grep -cvF ".zfs") if [[ $FILE_COUNT -ne $COUNT ]]; then ls -Al ${args[i+3]} log_fail "AFTER: ${args[i+3]} contains $FILE_COUNT files(s)." @@ -158,7 +156,7 @@ while (( i < ${#args[*]} )); do (( j = j + 1 )) done - FILE_COUNT=`ls -Al ${args[i+3]}/after* | grep -v "total" | wc -l` + FILE_COUNT=$(ls -A ${args[i+3]}/after* | wc -l) if [[ $FILE_COUNT -ne $COUNT ]]; then ls -Al ${args[i+3]} log_fail "${args[i+3]} contains $FILE_COUNT after* files(s)." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh index 97194f4fe4a0..38db22fdfe17 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh @@ -51,20 +51,17 @@ verify_runnable "both" function cleanup { - snapexists $SNAPFS - [[ $? -eq 0 ]] && \ + snapexists $SNAPFS && log_must zfs destroy $SNAPFS - [[ -e $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + [ -e $TESTDIR ] && log_must rm -rf $TESTDIR/* } log_assert "Verify that a rollback to a previous snapshot succeeds." log_onexit cleanup -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* typeset -i COUNT=10 @@ -79,7 +76,7 @@ done log_must zfs snapshot $SNAPFS -FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $SNAPDIR | wc -l) if [[ $FILE_COUNT -ne $COUNT ]]; then ls -Al $SNAPDIR log_fail "AFTER: $SNAPFS contains $FILE_COUNT files(s)." @@ -100,14 +97,13 @@ sync_pool $TESTPOOL # log_must zfs rollback $SNAPFS -FILE_COUNT=`ls -Al $TESTDIR/after* 2> /dev/null | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/after* 2> /dev/null | wc -l) if [[ $FILE_COUNT -ne 0 ]]; then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT after* files(s)." fi -FILE_COUNT=`ls -Al $TESTDIR/before* 2> /dev/null \ - | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/before* 2> /dev/null | wc -l) if [[ $FILE_COUNT -ne $COUNT ]]; then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT before* files(s)." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh index c424a69f0a7e..571065fdd69b 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh @@ -51,24 +51,20 @@ verify_runnable "both" function cleanup { - snapexists $SNAPFS.1 - [[ $? -eq 0 ]] && \ + snapexists $SNAPFS.1 && log_must zfs destroy $SNAPFS.1 - snapexists $SNAPFS - [[ $? -eq 0 ]] && \ + snapexists $SNAPFS && log_must zfs destroy $SNAPFS - [[ -e $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + [ -e $TESTDIR ] && log_must rm -rf $TESTDIR/* } log_assert "Verify rollback is with respect to latest snapshot." log_onexit cleanup -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* typeset -i COUNT=10 @@ -83,7 +79,7 @@ done log_must zfs snapshot $SNAPFS -FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $SNAPDIR | wc -l) if [[ $FILE_COUNT -ne $COUNT ]]; then ls -Al $SNAPDIR log_fail "AFTER: $SNAPFS contains $FILE_COUNT files(s)." @@ -109,22 +105,20 @@ while [[ $i -le $COUNT ]]; do (( i = i + 1 )) done -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/original_file* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -f $TESTDIR/original_file* # # Now rollback to latest snapshot # log_must zfs rollback $SNAPFS.1 -FILE_COUNT=`ls -Al $TESTDIR/aftersecond* 2> /dev/null \ - | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/aftersecond* 2> /dev/null | wc -l) if [[ $FILE_COUNT -ne 0 ]]; then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT aftersecond* files(s)." fi -FILE_COUNT=`ls -Al $TESTDIR/original* $TESTDIR/afterfirst*| grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/original* $TESTDIR/afterfirst* | wc -l) if [[ $FILE_COUNT -ne 20 ]]; then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT original* files(s)." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/rollback_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/rollback_003_pos.ksh index 766de990ecdb..e707640acd14 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/rollback_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/rollback_003_pos.ksh @@ -100,7 +100,7 @@ log_must zfs snapshot $SNAPPOOL.1 # # https://github.com/openzfs/zfs/issues/6143 # -log_must df >/dev/null +log_must eval "df >/dev/null" export __ZFS_POOL_RESTRICT="$TESTPOOL" log_must zfs unmount -a @@ -110,6 +110,6 @@ unset __ZFS_POOL_RESTRICT log_must touch /$TESTPOOL/$TESTFILE/$TESTFILE.1 log_must zfs rollback $SNAPPOOL.1 -log_must df >/dev/null +log_must eval "df >/dev/null" log_pass "Rollbacks succeed when nested file systems are present." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_001_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_001_pos.ksh index 8b8c118d9dfb..9a677b036ead 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_001_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_001_pos.ksh @@ -35,8 +35,8 @@ # # DESCRIPTION: # A zfs file system snapshot is identical to -# the originally snapshot'd file system, after the file -# system has been changed. Uses 'sum -r'. +# the originally snapshotted file system, after the file +# system has been changed. Uses 'cksum'. # # STRATEGY: # 1. Create a file in the zfs file system @@ -50,18 +50,11 @@ verify_runnable "both" function cleanup { - snapexists $SNAPFS - if [[ $? -eq 0 ]]; then + if snapexists $SNAPFS; then log_must zfs destroy $SNAPFS fi - if [[ -e $SNAPDIR ]]; then - log_must rm -rf $SNAPDIR > /dev/null 2>&1 - fi - - if [[ -e $TESTDIR ]]; then - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 - fi + log_must rm -rf $SNAPDIR $TESTDIR/* } log_assert "Verify a file system snapshot is identical to original." @@ -73,7 +66,7 @@ log_must file_write -o create -f $TESTDIR/$TESTFILE -b $BLOCKSZ \ -c $NUM_WRITES -d $DATA log_note "Sum the file, save for later comparison..." -FILE_SUM=`sum -r $TESTDIR/$TESTFILE | awk '{ print $1 }'` +read -r FILE_SUM _ < <(cksum $TESTDIR/$TESTFILE) log_note "FILE_SUM = $FILE_SUM" log_note "Create a snapshot and mount it..." @@ -83,7 +76,7 @@ log_note "Append to the original file..." log_must file_write -o append -f $TESTDIR/$TESTFILE -b $BLOCKSZ \ -c $NUM_WRITES -d $DATA -SNAP_FILE_SUM=`sum -r $SNAPDIR/$TESTFILE | awk '{ print $1 }'` +read -r SNAP_FILE_SUM _ < <(cksum $SNAPDIR/$TESTFILE) if [[ $SNAP_FILE_SUM -ne $FILE_SUM ]]; then log_fail "Sums do not match, aborting!! ($SNAP_FILE_SUM != $FILE_SUM)" fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_002_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_002_pos.ksh index 42fbbd9a7a2b..a3ed1b548210 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_002_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_002_pos.ksh @@ -51,26 +51,13 @@ verify_runnable "both" function cleanup { - if [[ -d $CWD ]]; then - cd $CWD || log_fail "Could not cd $CWD" - fi + [ -d $CWD ] && log_must cd $CWD - snapexists $SNAPFS - if [[ $? -eq 0 ]]; then - log_must zfs destroy $SNAPFS - fi + snapexists $SNAPFS && log_must zfs destroy $SNAPFS - if [[ -e $SNAPDIR ]]; then - log_must rm -rf $SNAPDIR > /dev/null 2>&1 - fi - - if [[ -e $TESTDIR ]]; then - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 - fi - - if [[ -d "$SNAPSHOT_TARDIR" ]]; then - log_must rm -rf $SNAPSHOT_TARDIR > /dev/null 2>&1 - fi + [ -e $SNAPDIR ] && log_must rm -rf $SNAPDIR + [ -e $TESTDIR ] && log_must rm -rf $TESTDIR/* + [ -d "$SNAPSHOT_TARDIR" ] && log_must rm -rf $SNAPSHOT_TARDIR } log_assert "Verify an archive of a file system is identical to " \ @@ -82,8 +69,7 @@ log_onexit cleanup typeset -i COUNT=21 typeset OP=create -[[ -n $TESTDIR ]] && \ - rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && rm -rf $TESTDIR/* log_note "Create files in the zfs filesystem..." @@ -96,33 +82,32 @@ done log_note "Create a tarball from $TESTDIR contents..." CWD=$PWD -cd $TESTDIR || log_fail "Could not cd $TESTDIR" +log_must cd $TESTDIR log_must tar cf $SNAPSHOT_TARDIR/original.tar . -cd $CWD || log_fail "Could not cd $CWD" +log_must cd $CWD log_note "Create a snapshot and mount it..." log_must zfs snapshot $SNAPFS log_note "Remove all of the original files..." -log_must rm -f $TESTDIR/file* > /dev/null 2>&1 +log_must rm -f $TESTDIR/file* log_note "Create tarball of snapshot..." CWD=$PWD -cd $SNAPDIR || log_fail "Could not cd $SNAPDIR" +log_must cd $SNAPDIR log_must tar cf $SNAPSHOT_TARDIR/snapshot.tar . -cd $CWD || log_fail "Could not cd $CWD" +log_must cd $CWD -log_must mkdir $TESTDIR/original -log_must mkdir $TESTDIR/snapshot +log_must mkdir $TESTDIR/original $TESTDIR/snapshot CWD=$PWD -cd $TESTDIR/original || log_fail "Could not cd $TESTDIR/original" +log_must cd $TESTDIR/original log_must tar xf $SNAPSHOT_TARDIR/original.tar -cd $TESTDIR/snapshot || log_fail "Could not cd $TESTDIR/snapshot" +log_must cd $TESTDIR/snapshot log_must tar xf $SNAPSHOT_TARDIR/snapshot.tar -cd $CWD || log_fail "Could not cd $CWD" +log_must cd $CWD log_must directory_diff $TESTDIR/original $TESTDIR/snapshot log_pass "Directory structures match." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_003_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_003_pos.ksh index 054b58cd5590..a1357b1551e6 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_003_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_003_pos.ksh @@ -49,20 +49,17 @@ function cleanup { typeset -i i=1 while [ $i -lt $COUNT ]; do - snapexists $SNAPFS.$i - if [[ $? -eq 0 ]]; then - log_must zfs destroy $SNAPFS.$i - fi + snapexists $SNAPFS.$i && log_must zfs destroy $SNAPFS.$i - if [[ -e $SNAPDIR.$i ]]; then - log_must rm -rf $SNAPDIR.$i > /dev/null 2>&1 + if [ -e $SNAPDIR.$i ]; then + log_must rm -rf $SNAPDIR.$i fi (( i = i + 1 )) done - if [[ -e $TESTDIR ]]; then - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + if [ -e $TESTDIR ]; then + log_must rm -rf $TESTDIR/* fi } @@ -70,8 +67,7 @@ log_assert "Verify many snapshots of a file system can be taken." log_onexit cleanup -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* typeset -i COUNT=10 @@ -86,12 +82,11 @@ while [[ $i -lt $COUNT ]]; do done log_note "Remove all of the original files" -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/file* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/file* i=1 while [[ $i -lt $COUNT ]]; do - FILECOUNT=`ls $SNAPDIR.$i/file* | wc -l` + FILECOUNT=$(ls $SNAPDIR.$i/file* | wc -l) typeset j=1 while [ $j -lt $FILECOUNT ]; do log_must file_check $SNAPDIR.$i/file$j $j diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_004_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_004_pos.ksh index 9d3b3de1adc0..683afb5e1a3f 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_004_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_004_pos.ksh @@ -48,23 +48,19 @@ verify_runnable "both" function cleanup { - snapexists $SNAPFS - [[ $? -eq 0 ]] && \ - log_must zfs destroy $SNAPFS + snapexists $SNAPFS && log_must zfs destroy $SNAPFS - [[ -e $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + [ -e $TESTDIR ] && log_must rm -rf $TESTDIR/* } log_assert "Verify that a snapshot of an empty file system remains empty." log_onexit cleanup -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* log_must zfs snapshot $SNAPFS -FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total 0" | wc -l` +FILE_COUNT=$(ls -A $SNAPDIR | wc -l) if [[ $FILE_COUNT -ne 0 ]]; then ls $SNAPDIR log_fail "BEFORE: $SNAPDIR contains $FILE_COUNT files(s)." @@ -81,7 +77,7 @@ while [[ $i -lt $COUNT ]]; do (( i = i + 1 )) done -FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total 0" | wc -l` +FILE_COUNT=$(ls -A $SNAPDIR | wc -l) if [[ $FILE_COUNT -ne 0 ]]; then ls $SNAPDIR log_fail "AFTER: $SNAPDIR contains $FILE_COUNT files(s)." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_005_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_005_pos.ksh index c1917dff1299..a5667badf53a 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_005_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_005_pos.ksh @@ -35,7 +35,7 @@ # # DESCRIPTION: # to the originally snapshot'd file system, after the file -# system has been changed. Uses 'sum -r'. +# system has been changed. Uses 'cksum'. # # STRATEGY: # 1) Create a file in the zfs dataset @@ -49,17 +49,14 @@ verify_runnable "both" function cleanup { - snapexists $SNAPCTR - if [[ $? -eq 0 ]]; then - log_must zfs destroy $SNAPCTR + snapexists $SNAPCTR && log_must zfs destroy $SNAPCTR + + if [ -e $SNAPDIR1 ]; then + log_must rm -rf $SNAPDIR1 fi - if [[ -e $SNAPDIR1 ]]; then - log_must rm -rf $SNAPDIR1 > /dev/null 2>&1 - fi - - if [[ -e $TESTDIR ]]; then - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + if [ -e $TESTDIR ]; then + log_must rm -rf $TESTDIR/* fi } @@ -72,7 +69,7 @@ log_must file_write -o create -f $TESTDIR1/$TESTFILE -b $BLOCKSZ \ -c $NUM_WRITES -d $DATA log_note "Sum the file, save for later comparison..." -FILE_SUM=`sum -r $TESTDIR1/$TESTFILE | awk '{ print $1 }'` +read -r FILE_SUM _ < <(cksum $TESTDIR1/$TESTFILE) log_note "FILE_SUM = $FILE_SUM" log_note "Create a snapshot and mount it..." @@ -82,8 +79,8 @@ log_note "Append to the original file..." log_must file_write -o append -f $TESTDIR1/$TESTFILE -b $BLOCKSZ \ -c $NUM_WRITES -d $DATA -SNAP_FILE_SUM=`sum -r $SNAPDIR1/$TESTFILE | awk '{ print $1 }'` -if [[ $SNAP_FILE_SUM -ne $FILE_SUM ]]; then +read -r SNAP_FILE_SUM _ < <(cksum $SNAPDIR1/$TESTFILE) +if [ $SNAP_FILE_SUM -ne $FILE_SUM ]; then log_fail "Sums do not match, aborting!! ($SNAP_FILE_SUM != $FILE_SUM)" fi diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_006_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_006_pos.ksh index d2a304670981..2130ff8901cd 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_006_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_006_pos.ksh @@ -51,24 +51,21 @@ verify_runnable "both" function cleanup { if [[ -d $CWD ]]; then - cd $CWD || log_fail "Could not cd $CWD" + log_must cd $CWD fi - snapexists $SNAPCTR - if [[ $? -eq 0 ]]; then - log_must zfs destroy $SNAPCTR + snapexists $SNAPCTR && log_must zfs destroy $SNAPCTR + + if [ -e $SNAPDIR1 ]; then + log_must rm -rf $SNAPDIR1 fi - if [[ -e $SNAPDIR1 ]]; then - log_must rm -rf $SNAPDIR1 > /dev/null 2>&1 + if [ -e $TESTDIR1 ]; then + log_must rm -rf $TESTDIR1/* fi - if [[ -e $TESTDIR1 ]]; then - log_must rm -rf $TESTDIR1/* > /dev/null 2>&1 - fi - - if [[ -d "$SNAPSHOT_TARDIR" ]]; then - log_must rm -rf $SNAPSHOT_TARDIR > /dev/null 2>&1 + if [ -d "$SNAPSHOT_TARDIR" ]; then + log_must rm -rf $SNAPSHOT_TARDIR fi } @@ -81,7 +78,7 @@ log_onexit cleanup typeset -i COUNT=21 typeset OP=create -[[ -n $TESTDIR1 ]] && rm -rf $TESTDIR1/* > /dev/null 2>&1 +[ -n $TESTDIR1 ] && rm -rf $TESTDIR1/* log_note "Create files in the zfs dataset ..." @@ -94,33 +91,32 @@ done log_note "Create a tarball from $TESTDIR1 contents..." CWD=$PWD -cd $TESTDIR1 || log_fail "Could not cd $TESTDIR1" +log_must cd $TESTDIR1 log_must tar cf $SNAPSHOT_TARDIR/original.tar . -cd $CWD || log_fail "Could not cd $CWD" +log_must cd $CWD log_note "Create a snapshot and mount it..." log_must zfs snapshot $SNAPCTR log_note "Remove all of the original files..." -log_must rm -f $TESTDIR1/file* > /dev/null 2>&1 +log_must rm -f $TESTDIR1/file* log_note "Create tarball of snapshot..." CWD=$PWD -cd $SNAPDIR1 || log_fail "Could not cd $SNAPDIR1" +log_must cd $SNAPDIR1 log_must tar cf $SNAPSHOT_TARDIR/snapshot.tar . -cd $CWD || log_fail "Could not cd $CWD" +log_must cd $CWD -log_must mkdir $TESTDIR1/original -log_must mkdir $TESTDIR1/snapshot +log_must mkdir $TESTDIR1/original mkdir $TESTDIR1/snapshot CWD=$PWD -cd $TESTDIR1/original || log_fail "Could not cd $TESTDIR1/original" +log_must cd $TESTDIR1/original log_must tar xf $SNAPSHOT_TARDIR/original.tar -cd $TESTDIR1/snapshot || log_fail "Could not cd $TESTDIR1/snapshot" +log_must cd $TESTDIR1/snapshot log_must tar xf $SNAPSHOT_TARDIR/snapshot.tar -cd $CWD || log_fail "Could not cd $CWD" +log_must cd $CWD log_must directory_diff $TESTDIR1/original $TESTDIR1/snapshot log_pass "Directory structures match." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_007_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_007_pos.ksh index 7ed1fdb6e7ad..bcca2a04a7c4 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_007_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_007_pos.ksh @@ -49,24 +49,21 @@ function cleanup { typeset -i i=1 while [ $i -lt $COUNT ]; do - snapexists $SNAPCTR.$i - if [[ $? -eq 0 ]]; then - log_must zfs destroy $SNAPCTR.$i - fi + snapexists $SNAPCTR.$i && log_must zfs destroy $SNAPCTR.$i - if [[ -e $SNAPDIR.$i ]]; then - log_must rm -rf $SNAPDIR1.$i > /dev/null 2>&1 + if [ -e $SNAPDIR.$i ]; then + log_must rm -rf $SNAPDIR1.$i fi (( i = i + 1 )) done - if [[ -e $SNAPDIR1 ]]; then - log_must rm -rf $SNAPDIR1 > /dev/null 2>&1 + if [ -e $SNAPDIR1 ]; then + log_must rm -rf $SNAPDIR1 fi - if [[ -e $TESTDIR ]]; then - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + if [ -e $TESTDIR ]; then + log_must rm -rf $TESTDIR/* fi } @@ -74,8 +71,7 @@ log_assert "Verify that many snapshots can be made on a zfs dataset." log_onexit cleanup -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* typeset -i COUNT=10 @@ -90,12 +86,11 @@ while [[ $i -lt $COUNT ]]; do done log_note "Remove all of the original files" -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR1/file* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -f $TESTDIR1/file* i=1 while [[ $i -lt $COUNT ]]; do - FILECOUNT=`ls $SNAPDIR1.$i/file* | wc -l` + FILECOUNT=$(ls $SNAPDIR1.$i/file* 2>/dev/null | wc -l) typeset j=1 while [ $j -lt $FILECOUNT ]; do log_must file_check $SNAPDIR1.$i/file$j $j diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_008_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_008_pos.ksh index d0ecb77fe0a0..560e846cee9d 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_008_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_008_pos.ksh @@ -48,23 +48,20 @@ function cleanup { typeset -i i=1 while [[ $i -lt $COUNT ]]; do - snapexists $SNAPFS.$i - [[ $? -eq 0 ]] && \ + snapexists $SNAPFS.$i && log_must zfs destroy $SNAPFS.$i (( i = i + 1 )) done - [[ -e $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + [ -e $TESTDIR ] && log_must rm -rf $TESTDIR/* } log_assert "Verify that destroying snapshots returns space to the pool." log_onexit cleanup -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* typeset -i COUNT=10 @@ -82,7 +79,7 @@ done typeset -i i=1 while [[ $i -lt $COUNT ]]; do - log_must rm -rf $TESTDIR/file$i > /dev/null 2>&1 + log_must rm -f $TESTDIR/file$i log_must zfs destroy $SNAPFS.$i (( i = i + 1 )) diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh index 7e0a7f4ce1d8..7fa7aec22d6f 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh @@ -53,15 +53,13 @@ function cleanup { snapexists $SNAPPOOL && destroy_dataset $SNAPPOOL -r - [[ -e $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + [ -e $TESTDIR ] && log_must rm -rf $TESTDIR/* } log_assert "Verify that rollback to a snapshot created by snapshot -r succeeds." log_onexit cleanup -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* typeset -i COUNT=10 @@ -76,7 +74,7 @@ done log_must zfs snapshot -r $SNAPPOOL -FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $SNAPDIR | wc -l) if (( FILE_COUNT != COUNT )); then ls -Al $SNAPDIR log_fail "AFTER: $SNAPFS contains $FILE_COUNT files(s)." @@ -96,14 +94,13 @@ done # log_must zfs rollback $SNAPFS -FILE_COUNT=`ls -Al $TESTDIR/after* 2> /dev/null | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/after* 2> /dev/null | wc -l) if (( FILE_COUNT != 0 )); then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT after* files(s)." fi -FILE_COUNT=`ls -Al $TESTDIR/before* 2> /dev/null \ - | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/before* 2> /dev/null | wc -l) if (( FILE_COUNT != $COUNT )); then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT before* files(s)." diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh index e02f6eb30042..27408222c80e 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh @@ -51,8 +51,7 @@ function cleanup datasetexists $ctrfs && destroy_dataset $ctrfs -r snapexists $snappool && destroy_dataset $snappool -r - [[ -e $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + [ -e $TESTDIR ] && log_must rm -rf $TESTDIR/* } log_assert "Verify snapshots from 'snapshot -r' can be used for zfs send/recv" @@ -67,8 +66,7 @@ snapctrfs=$ctrfs@$TESTSNAP fsdir=/$ctrfs snapdir=$fsdir/.zfs/snapshot/$TESTSNAP -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* typeset -i COUNT=10 @@ -89,7 +87,7 @@ if ! datasetexists $ctrfs || ! snapexists $snapctrfs; then fi for dir in $fsdir $snapdir; do - FILE_COUNT=`ls -Al $dir | grep -v "total" | wc -l` + FILE_COUNT=$(ls -A $dir | wc -l) (( FILE_COUNT != COUNT )) && log_fail "Got $FILE_COUNT expected $COUNT" done diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_014_pos.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_014_pos.ksh index 384377c7f64b..55188960b7e3 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_014_pos.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapshot/snapshot_014_pos.ksh @@ -48,8 +48,7 @@ verify_runnable "both" function cleanup { - [[ -e $TESTDIR1 ]] && \ - log_must rm -rf $TESTDIR1/* > /dev/null 2>&1 + [ -e $TESTDIR1 ] && log_must rm -rf $TESTDIR1/* snapexists $SNAPCTR && destroy_dataset $SNAPCTR diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapused/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapused/Makefile.am deleted file mode 100644 index d6551b7c41b1..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/snapused/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/snapused -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - snapused_001_pos.ksh \ - snapused_002_pos.ksh \ - snapused_003_pos.ksh \ - snapused_004_pos.ksh \ - snapused_005_pos.ksh - -dist_pkgdata_DATA = \ - snapused.kshlib diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/sparse/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/sparse/Makefile.am deleted file mode 100644 index f1b9e04dcefe..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/sparse/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/sparse -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - sparse_001_pos.ksh - -dist_pkgdata_DATA = \ - sparse.cfg diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/sparse/sparse.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/sparse/sparse.cfg index 0fc669148aa1..b7e403bce5f1 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/sparse/sparse.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/sparse/sparse.cfg @@ -39,5 +39,5 @@ export HOLES_COUNT=${HOLES_COUNT-"16384"} # FILESIZE/BLKSIZE/8 export STF_TIMEOUT=3600 export DISKSARRAY=$DISKS -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') set_device_dir diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/stat/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/stat/Makefile.am deleted file mode 100644 index 1a861a655cb1..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/stat/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/stat - -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - stat_001_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/.gitignore deleted file mode 100644 index a9a3db79ba44..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/suid_write_to_file diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/Makefile.am deleted file mode 100644 index 0145c1205fb3..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/suid - -dist_pkgdata_SCRIPTS = \ - suid_write_to_suid.ksh \ - suid_write_to_sgid.ksh \ - suid_write_to_suid_sgid.ksh \ - suid_write_to_none.ksh \ - suid_write_zil_replay.ksh \ - cleanup.ksh \ - setup.ksh - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/suid - -pkgexec_PROGRAMS = suid_write_to_file -suid_write_to_file_SOURCES = suid_write_to_file.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_none.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_none.ksh index 470350f960cf..907c94e3fd9c 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_none.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_none.ksh @@ -47,6 +47,6 @@ function cleanup log_onexit cleanup log_note "Verify write(2) to regular file by non-owner" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "NONE" "PRECRASH" +log_must suid_write_to_file "NONE" "PRECRASH" log_pass "Verify write(2) to regular file by non-owner passed" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_sgid.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_sgid.ksh index 3c95a402658e..4554bc3c00a4 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_sgid.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_sgid.ksh @@ -47,6 +47,6 @@ function cleanup log_onexit cleanup log_note "Verify write(2) to SGID file by non-owner" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SGID" "PRECRASH" +log_must suid_write_to_file "SGID" "PRECRASH" log_pass "Verify write(2) to SGID file by non-owner passed" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_suid.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_suid.ksh index 4183cbeefc20..541e1125d539 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_suid.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_suid.ksh @@ -47,6 +47,6 @@ function cleanup log_onexit cleanup log_note "Verify write(2) to SUID file by non-owner" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID" "PRECRASH" +log_must suid_write_to_file "SUID" "PRECRASH" log_pass "Verify write(2) to SUID file by non-owner passed" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_suid_sgid.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_suid_sgid.ksh index f7a08a55fc4b..57361d2e39a9 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_suid_sgid.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_to_suid_sgid.ksh @@ -47,6 +47,6 @@ function cleanup log_onexit cleanup log_note "Verify write(2) to SUID/SGID file by non-owner" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID_SGID" "PRECRASH" +log_must suid_write_to_file "SUID_SGID" "PRECRASH" log_pass "Verify write(2) to SUID/SGID file by non-owner passed" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_zil_replay.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_zil_replay.ksh index 81f431f6b68b..8843e67da24b 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_zil_replay.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/suid/suid_write_zil_replay.ksh @@ -65,10 +65,10 @@ log_must zpool freeze $TESTPOOL # # 3. Unprivileged write to a setuid file # -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "NONE" "PRECRASH" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID" "PRECRASH" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SGID" "PRECRASH" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID_SGID" "PRECRASH" +log_must suid_write_to_file "NONE" "PRECRASH" +log_must suid_write_to_file "SUID" "PRECRASH" +log_must suid_write_to_file "SGID" "PRECRASH" +log_must suid_write_to_file "SUID_SGID" "PRECRASH" # # 4. Unmount filesystem and export the pool @@ -91,9 +91,9 @@ log_must zpool export $TESTPOOL # log_must zpool import -f -d $VDIR $TESTPOOL -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "NONE" "REPLAY" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID" "REPLAY" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SGID" "REPLAY" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID_SGID" "REPLAY" +log_must suid_write_to_file "NONE" "REPLAY" +log_must suid_write_to_file "SUID" "REPLAY" +log_must suid_write_to_file "SGID" "REPLAY" +log_must suid_write_to_file "SUID_SGID" "REPLAY" log_pass diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/threadsappend/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/threadsappend/.gitignore deleted file mode 100644 index 4c8c8cdf34c1..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/threadsappend/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/threadsappend diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/threadsappend/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/threadsappend/Makefile.am deleted file mode 100644 index 80f7788c8d86..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/threadsappend/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/threadsappend - -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh \ - threadsappend_001_pos.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/tmpfile/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/tmpfile/Makefile.am deleted file mode 100644 index 35a1f44c1693..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/tmpfile/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/tmpfile - -dist_pkgdata_SCRIPTS = \ - cleanup.ksh \ - setup.ksh - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/tmpfile - -pkgexec_PROGRAMS = tmpfile_test tmpfile_001_pos tmpfile_002_pos \ - tmpfile_003_pos tmpfile_stat_mode -tmpfile_test_SOURCES= tmpfile_test.c -tmpfile_001_pos_SOURCES = tmpfile_001_pos.c -tmpfile_002_pos_SOURCES = tmpfile_002_pos.c -tmpfile_003_pos_SOURCES = tmpfile_003_pos.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/trim/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/trim/Makefile.am deleted file mode 100644 index 8917ed726e90..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/trim/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/trim -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - trim.kshlib \ - trim.cfg \ - autotrim_integrity.ksh \ - autotrim_config.ksh \ - autotrim_trim_integrity.ksh \ - trim_integrity.ksh \ - trim_config.ksh \ - trim_l2arc.ksh diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/trim/trim.kshlib b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/trim/trim.kshlib index dc1a60a5ee9d..f36f3870fc4e 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/trim/trim.kshlib +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/trim/trim.kshlib @@ -22,8 +22,7 @@ # function get_size_mb { - typeset rval=$(du --block-size 1048576 -s "$1" | awk '{print $1}') - echo -n "$rval" + du --block-size 1048576 -s "$1" | cut -f1 } # @@ -39,14 +38,12 @@ function get_trim_io # Sum the ind or agg columns of the trim request size histogram. case "$type" in "ind") - rval=$(zpool iostat -pr $pool $vdev | awk \ - '$1 ~ /[0-9].*/ { sum += $12 } END { print sum }') - echo -n "$rval" + zpool iostat -pr $pool $vdev | + awk '$1 ~ /[0-9].*/ { sum += $12 } END { print sum }' ;; "agg") - rval=$(zpool iostat -pr $pool $vdev | awk \ - '$1 ~ /[0-9].*/ { sum += $13 } END { print sum }') - echo -n "$rval" + zpool iostat -pr $pool $vdev | + awk '$1 ~ /[0-9].*/ { sum += $13 } END { print sum }' ;; *) log_fail "Type must be 'ind' or 'agg'" diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh index ecf9f3424eb5..0bbd08acdd3f 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh @@ -36,6 +36,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "Trim of L2ARC succeeds." function cleanup @@ -95,8 +97,8 @@ done verify_trim_io $TESTPOOL "ind" 5 $TRIM_VDEV2 -typeset cache_size=$(zpool list -vp | grep $TRIM_VDEV2 | awk '{print $2}') -typeset cache_alloc=$(zpool list -vp | grep $TRIM_VDEV2 | awk '{print $3}') +typeset cache_size cache_alloc _ +read -r _ cache_size cache_alloc _ < <(zpool list -vp | grep $TRIM_VDEV2) log_must test $cache_alloc -lt $cache_size diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/truncate/.gitignore b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/truncate/.gitignore deleted file mode 100644 index f28d93573c51..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/truncate/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/truncate_test diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/truncate/Makefile.am b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/truncate/Makefile.am deleted file mode 100644 index b2d804b5d4c2..000000000000 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/truncate/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/truncate - -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - truncate_001_pos.ksh \ - truncate_002_pos.ksh \ - truncate_timestamps.ksh - -dist_pkgdata_DATA = \ - truncate.cfg - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/truncate - -pkgexec_PROGRAMS = truncate_test -truncate_test_SOURCES = truncate_test.c diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/truncate/truncate.cfg b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/truncate/truncate.cfg index 13cdafab133b..d852ee63abb5 100644 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/truncate/truncate.cfg +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/truncate/truncate.cfg @@ -34,6 +34,6 @@ export TRUNC_FILEOFFSET=${TRUNC_FILEOFFSET-""} export TRUNC_COUNT=${TRUNC_COUNT-"16384"} # FILESIZE/BLKSIZE/8 export DISKSARRAY=$DISKS -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') set_device_dir diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/truncate/truncate_timestamps.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/truncate/truncate_timestamps.ksh index 27b28e82eb5b..3793178701d8 100755 --- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/truncate/truncate_timestamps.ksh +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/truncate/truncate_timestamps.ksh @@ -42,7 +42,7 @@ function verify_truncate #