diff options
Diffstat (limited to 'usr/src')
42 files changed, 616 insertions, 135 deletions
diff --git a/usr/src/cmd/fs.d/nfs/mount/mount.c b/usr/src/cmd/fs.d/nfs/mount/mount.c index b3b255d098..e1206e186a 100644 --- a/usr/src/cmd/fs.d/nfs/mount/mount.c +++ b/usr/src/cmd/fs.d/nfs/mount/mount.c @@ -1978,7 +1978,7 @@ get_fh_via_pub(struct nfs_args *args, char *fshost, char *fspath, bool_t url, break; case NFS_V3: fstype = MNTTYPE_NFS3; - /* fall through to pick up llock option */ + /* FALLTHROUGH */ default: args->flags |= NFSMNT_LLOCK; break; diff --git a/usr/src/cmd/fs.d/nfs/mountd/rmtab.c b/usr/src/cmd/fs.d/nfs/mountd/rmtab.c index 8d44cd3932..bcbe4ae80b 100644 --- a/usr/src/cmd/fs.d/nfs/mountd/rmtab.c +++ b/usr/src/cmd/fs.d/nfs/mountd/rmtab.c @@ -379,6 +379,7 @@ host_part: } else *tmp = ']'; } + /* FALLTHROUGH */ default: continue; } diff --git a/usr/src/cmd/fs.d/nfs/rquotad/rpc.rquotad.c b/usr/src/cmd/fs.d/nfs/rquotad/rpc.rquotad.c index da94792505..1d56de0b70 100644 --- a/usr/src/cmd/fs.d/nfs/rquotad/rpc.rquotad.c +++ b/usr/src/cmd/fs.d/nfs/rquotad/rpc.rquotad.c @@ -79,7 +79,7 @@ void getquota(); int hasquota(); void log_cant_reply(); void setupfs(); -static void zexit(); +static void zexit(int) __NORETURN; static libzfs_handle_t *(*_libzfs_init)(void); static void (*_libzfs_fini)(libzfs_handle_t *); diff --git a/usr/src/cmd/pfexecd/Makefile b/usr/src/cmd/pfexecd/Makefile index 262bef7054..56f922541c 100644 --- a/usr/src/cmd/pfexecd/Makefile +++ b/usr/src/cmd/pfexecd/Makefile @@ -28,7 +28,6 @@ PROG= pfexecd MANIFEST= pfexecd.xml SRCS= $(PROG:%=%.c) -lint: lint_SRCS include ../Makefile.cmd diff --git a/usr/src/cmd/pfexecd/pfexecd.c b/usr/src/cmd/pfexecd/pfexecd.c index 1d25c09188..ae04a5fe4c 100644 --- a/usr/src/cmd/pfexecd/pfexecd.c +++ b/usr/src/cmd/pfexecd/pfexecd.c @@ -118,6 +118,7 @@ init_isa_regex(void) case '}': case '\\': regexpr[len++] = '\\'; + /* FALLTHROUGH */ default: regexpr[len++] = *p; break; diff --git a/usr/src/cmd/sgs/lex/common/parser.y b/usr/src/cmd/sgs/lex/common/parser.y index 00465f4522..9b1f173bf2 100644 --- a/usr/src/cmd/sgs/lex/common/parser.y +++ b/usr/src/cmd/sgs/lex/common/parser.y @@ -30,7 +30,6 @@ %{ -#pragma ident "%Z%%M% %I% %E% SMI" /* * Lint is unable to properly handle formats with wide strings @@ -898,6 +897,7 @@ Character range specified between different codesets."); break; case '\\': c = usescape(c=gch()); + /* FALLTHROUGH */ default: character: if(iter){ /* second part of an iteration */ diff --git a/usr/src/cmd/sgs/libld/common/map_core.c b/usr/src/cmd/sgs/libld/common/map_core.c index 6d0bef174d..8cc1753722 100644 --- a/usr/src/cmd/sgs/libld/common/map_core.c +++ b/usr/src/cmd/sgs/libld/common/map_core.c @@ -1592,7 +1592,7 @@ restart: } } - assert(mf->mf_next == '\0'); + assert(*mf->mf_next == '\0'); return (TRUE); /* diff --git a/usr/src/cmd/sgs/unifdef/common/unifdef.c b/usr/src/cmd/sgs/unifdef/common/unifdef.c index 9e6b82cc14..fbb0d27008 100644 --- a/usr/src/cmd/sgs/unifdef/common/unifdef.c +++ b/usr/src/cmd/sgs/unifdef/common/unifdef.c @@ -29,8 +29,6 @@ /* Copyright (c) 1982 Regents of the University of California */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * unifdef - remove ifdef'ed lines */ @@ -524,6 +522,7 @@ ent: while (--tmp); break; } + /* FALLTHROUGH */ default: *line++ = chr; num++; diff --git a/usr/src/cmd/sgs/yacc/common/y2.c b/usr/src/cmd/sgs/yacc/common/y2.c index ca8dcc61f5..0d97f4260f 100644 --- a/usr/src/cmd/sgs/yacc/common/y2.c +++ b/usr/src/cmd/sgs/yacc/common/y2.c @@ -1187,8 +1187,8 @@ begin: case L'=': return (PREC); case L'{': return (LCURLY); default: reserve = 1; - } - + } + /* FALLTHROUGH */ default: if (iswdigit(c)) { /* number */ diff --git a/usr/src/cmd/zpool/zpool_vdev.c b/usr/src/cmd/zpool/zpool_vdev.c index 369b150390..28d81b9493 100644 --- a/usr/src/cmd/zpool/zpool_vdev.c +++ b/usr/src/cmd/zpool/zpool_vdev.c @@ -628,9 +628,11 @@ get_replication(nvlist_t *nvroot, boolean_t fatal) /* * If this is a replacing or spare vdev, then - * get the real first child of the vdev. + * get the real first child of the vdev: do this + * in a loop because replacing and spare vdevs + * can be nested. */ - if (strcmp(childtype, + while (strcmp(childtype, VDEV_TYPE_REPLACING) == 0 || strcmp(childtype, VDEV_TYPE_SPARE) == 0) { nvlist_t **rchild; diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile index 935ed2edc5..2d2c096b3f 100644 --- a/usr/src/lib/Makefile +++ b/usr/src/lib/Makefile @@ -27,7 +27,7 @@ # Copyright 2014 Garrett D'Amore <garrett@damore.org> # Copyright (c) 2015 Gary Mills # Copyright 2016 Toomas Soome <tsoome@me.com> -# Copyright 2017 Nexenta Systems, Inc. +# Copyright 2018 Nexenta Systems, Inc. # Copyright (c) 2016, Chris Fraire <cfraire@me.com>. # Copyright 2017 RackTop Systems. # @@ -590,7 +590,7 @@ auditd_plugins: libbsm libsecdb libgss libmtmalloc brand: libzonecfg libmapmalloc libipadm libcmdutils libproc librpcsvc cfgadm_plugins: libdevice libdevinfo libhotplug librcm hbaapi libkstat libscf fm: libexacct libipmi libzfs scsi libdevinfo libdevid libcfgadm \ - libcontract libsysevent ../cmd/sgs/libelf libdladm + libcontract libsysevent ../cmd/sgs/libelf libdladm libsff $(SPARC_BLD)fm: libpri gss_mechs/mech_dh: libgss gss_mechs/mech_dummy: libgss @@ -694,7 +694,7 @@ libvscan: libscf libsecdb libwanboot: libresolv2 libdevinfo libinetutil libdhcputil libzdoor: libc libzonecfg libcontract libzfs: libdevid libgen libuutil libadm libavl libefi libidmap \ - libumem libtsol libzfs_core + libumem libtsol libzfs_core libcmdutils libzfs_jni: libdiskmgt libzfs libzonecfg: libuuid libsysevent libsec libbrand libpool libscf libproc \ libuutil libbsm libsecdb diff --git a/usr/src/lib/libnsl/rpc/xdr_sizeof.c b/usr/src/lib/libnsl/rpc/xdr_sizeof.c index 29d9f7d275..ca22f6ed99 100644 --- a/usr/src/lib/libnsl/rpc/xdr_sizeof.c +++ b/usr/src/lib/libnsl/rpc/xdr_sizeof.c @@ -25,8 +25,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * General purpose routine to see how much space something will use * when serialized using XDR. @@ -130,7 +128,9 @@ xdr_sizeof(xdrproc_t func, void *data) /* to stop ANSI-C compiler from complaining */ typedef bool_t (* dummyfunc1)(XDR *, long *); typedef bool_t (* dummyfunc2)(XDR *, caddr_t, int); +#if defined(_LP64) typedef bool_t (* dummyfunc3)(XDR *, int32_t *); +#endif ops.x_putlong = x_putlong; ops.x_getlong = (dummyfunc1) harmless; diff --git a/usr/src/lib/libzfs/common/libzfs_dataset.c b/usr/src/lib/libzfs/common/libzfs_dataset.c index b41794868e..3a6d56add4 100644 --- a/usr/src/lib/libzfs/common/libzfs_dataset.c +++ b/usr/src/lib/libzfs/common/libzfs_dataset.c @@ -3757,6 +3757,9 @@ zfs_promote(zfs_handle_t *zhp) return (zfs_error(hdl, EZFS_BADTYPE, errbuf)); } + if (!zfs_validate_name(hdl, zhp->zfs_name, zhp->zfs_type, B_TRUE)) + return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf)); + ret = lzc_promote(zhp->zfs_name, snapname, sizeof (snapname)); if (ret != 0) { @@ -4043,17 +4046,31 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force) * a new snapshot is created before this request is processed. */ err = lzc_rollback_to(zhp->zfs_name, snap->zfs_name); - if (err == EXDEV) { - zfs_error_aux(zhp->zfs_hdl, dgettext(TEXT_DOMAIN, - "'%s' is not the latest snapshot"), snap->zfs_name); - (void) zfs_error_fmt(zhp->zfs_hdl, EZFS_BUSY, - dgettext(TEXT_DOMAIN, "cannot rollback '%s'"), - zhp->zfs_name); - return (err); - } else if (err != 0) { - (void) zfs_standard_error_fmt(zhp->zfs_hdl, errno, + if (err != 0) { + char errbuf[1024]; + + (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, "cannot rollback '%s'"), zhp->zfs_name); + switch (err) { + case EEXIST: + zfs_error_aux(zhp->zfs_hdl, dgettext(TEXT_DOMAIN, + "there is a snapshot or bookmark more recent " + "than '%s'"), snap->zfs_name); + (void) zfs_error(zhp->zfs_hdl, EZFS_EXISTS, errbuf); + break; + case ESRCH: + zfs_error_aux(zhp->zfs_hdl, dgettext(TEXT_DOMAIN, + "'%s' is not found among snapshots of '%s'"), + snap->zfs_name, zhp->zfs_name); + (void) zfs_error(zhp->zfs_hdl, EZFS_NOENT, errbuf); + break; + case EINVAL: + (void) zfs_error(zhp->zfs_hdl, EZFS_BADTYPE, errbuf); + break; + default: + (void) zfs_standard_error(zhp->zfs_hdl, err, errbuf); + } return (err); } @@ -4100,6 +4117,10 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive, (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, "cannot rename to '%s'"), target); + /* make sure source name is valid */ + if (!zfs_validate_name(hdl, zhp->zfs_name, zhp->zfs_type, B_TRUE)) + return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf)); + /* * Make sure the target name is valid */ diff --git a/usr/src/pkg/manifests/system-test-zfstest.mf b/usr/src/pkg/manifests/system-test-zfstest.mf index 7650a8eb47..56ce7e7391 100644 --- a/usr/src/pkg/manifests/system-test-zfstest.mf +++ b/usr/src/pkg/manifests/system-test-zfstest.mf @@ -944,6 +944,9 @@ file \ file \ path=opt/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos \ mode=0555 +file \ + path=opt/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_014_pos \ + mode=0555 file path=opt/zfs-tests/tests/functional/cli_root/zfs_rename/cleanup mode=0555 file path=opt/zfs-tests/tests/functional/cli_root/zfs_rename/setup mode=0555 file path=opt/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.cfg \ @@ -1250,6 +1253,9 @@ file path=opt/zfs-tests/tests/functional/cli_root/zpool/zpool_002_pos \ mode=0555 file path=opt/zfs-tests/tests/functional/cli_root/zpool/zpool_003_pos \ mode=0555 +file \ + path=opt/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare \ + mode=0555 file path=opt/zfs-tests/tests/functional/cli_root/zpool_add/cleanup mode=0555 file path=opt/zfs-tests/tests/functional/cli_root/zpool_add/setup mode=0555 file path=opt/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.cfg \ @@ -1294,6 +1300,9 @@ file \ file \ path=opt/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_003_neg \ mode=0555 +file \ + path=opt/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_readonly \ + mode=0555 file path=opt/zfs-tests/tests/functional/cli_root/zpool_create/cleanup \ mode=0555 file path=opt/zfs-tests/tests/functional/cli_root/zpool_create/setup mode=0555 diff --git a/usr/src/test/zfs-tests/include/commands.cfg b/usr/src/test/zfs-tests/include/commands.cfg index 6d87b7ebeb..7f16b799e4 100644 --- a/usr/src/test/zfs-tests/include/commands.cfg +++ b/usr/src/test/zfs-tests/include/commands.cfg @@ -10,7 +10,7 @@ # # -# Copyright (c) 2016 by Delphix. All rights reserved. +# Copyright (c) 2016, 2018 by Delphix. All rights reserved. # # @@ -22,6 +22,7 @@ # and maintenance. # export USR_BIN_FILES='awk + base64 basename bc bunzip2 diff --git a/usr/src/test/zfs-tests/include/libtest.shlib b/usr/src/test/zfs-tests/include/libtest.shlib index 734bc4f7c7..d77b04baa0 100644 --- a/usr/src/test/zfs-tests/include/libtest.shlib +++ b/usr/src/test/zfs-tests/include/libtest.shlib @@ -264,6 +264,41 @@ function create_bookmark log_must zfs bookmark $fs_vol@$snap $fs_vol#$bkmark } +# +# Create a temporary clone result of an interrupted resumable 'zfs receive' +# $1 Destination filesystem name. Must not exist, will be created as the result +# of this function along with its %recv temporary clone +# $2 Source filesystem name. Must not exist, will be created and destroyed +# +function create_recv_clone +{ + typeset recvfs="$1" + typeset sendfs="${2:-$TESTPOOL/create_recv_clone}" + typeset snap="$sendfs@snap1" + typeset incr="$sendfs@snap2" + typeset mountpoint="$TESTDIR/create_recv_clone" + typeset sendfile="$TESTDIR/create_recv_clone.zsnap" + + [[ -z $recvfs ]] && log_fail "Recv filesystem's name is undefined." + + datasetexists $recvfs && log_fail "Recv filesystem must not exist." + datasetexists $sendfs && log_fail "Send filesystem must not exist." + + log_must zfs create -o mountpoint="$mountpoint" $sendfs + log_must zfs snapshot $snap + log_must eval "zfs send $snap | zfs recv -u $recvfs" + log_must mkfile 1m "$mountpoint/data" + log_must zfs snapshot $incr + log_must eval "zfs send -i $snap $incr | dd bs=10k count=1 > $sendfile" + log_mustnot eval "zfs recv -su $recvfs < $sendfile" + log_must zfs destroy -r $sendfs + log_must rm -f "$sendfile" + + if [[ $(get_prop 'inconsistent' "$recvfs/%recv") -ne 1 ]]; then + log_fail "Error creating temporary $recvfs/%recv clone" + fi +} + function default_mirror_setup { default_mirror_setup_noexit $1 $2 $3 @@ -1471,6 +1506,31 @@ function check_hotspare_state # pool disk state{inuse,avail} } # +# Wait until a hotspare transitions to a given state or times out. +# +# Return 0 when pool/disk matches expected state, 1 on timeout. +# +function wait_hotspare_state # pool disk state timeout +{ + typeset pool=$1 + typeset disk=${2#$/DEV_DSKDIR/} + typeset state=$3 + typeset timeout=${4:-60} + typeset -i i=0 + + while [[ $i -lt $timeout ]]; do + if check_hotspare_state $pool $disk $state; then + return 0 + fi + + i=$((i+1)) + sleep 1 + done + + return 1 +} + +# # Verify a given slog disk is inuse or avail # # Return 0 is pool/disk matches expected state, 1 otherwise @@ -1509,6 +1569,31 @@ function check_vdev_state # pool disk state{online,offline,unavail} } # +# Wait until a vdev transitions to a given state or times out. +# +# Return 0 when pool/disk matches expected state, 1 on timeout. +# +function wait_vdev_state # pool disk state timeout +{ + typeset pool=$1 + typeset disk=${2#$/DEV_DSKDIR/} + typeset state=$3 + typeset timeout=${4:-60} + typeset -i i=0 + + while [[ $i -lt $timeout ]]; do + if check_vdev_state $pool $disk $state; then + return 0 + fi + + i=$((i+1)) + sleep 1 + done + + return 1 +} + +# # Check the output of 'zpool status -v <pool>', # and to see if the content of <token> contain the <keyword> specified. # diff --git a/usr/src/test/zfs-tests/runfiles/delphix.run b/usr/src/test/zfs-tests/runfiles/delphix.run index f38254aa79..88d6e368ab 100644 --- a/usr/src/test/zfs-tests/runfiles/delphix.run +++ b/usr/src/test/zfs-tests/runfiles/delphix.run @@ -159,7 +159,7 @@ tests = ['zfs_receive_001_pos', 'zfs_receive_002_pos', 'zfs_receive_003_pos', 'zfs_receive_005_neg', 'zfs_receive_006_pos', 'zfs_receive_007_neg', 'zfs_receive_008_pos', 'zfs_receive_009_neg', 'zfs_receive_010_pos', 'zfs_receive_011_pos', 'zfs_receive_012_pos', - 'zfs_receive_013_pos'] + 'zfs_receive_013_pos', 'zfs_receive_014_pos'] [/opt/zfs-tests/tests/functional/cli_root/zfs_rename] tests = ['zfs_rename_001_pos', 'zfs_rename_002_pos', 'zfs_rename_003_pos', @@ -224,13 +224,15 @@ tests = ['zpool_001_neg', 'zpool_002_pos', 'zpool_003_pos'] [/opt/zfs-tests/tests/functional/cli_root/zpool_add] tests = ['zpool_add_001_pos', 'zpool_add_002_pos', 'zpool_add_003_pos', 'zpool_add_004_pos', 'zpool_add_005_pos', 'zpool_add_006_pos', - 'zpool_add_007_neg', 'zpool_add_008_neg', 'zpool_add_009_neg'] + 'zpool_add_007_neg', 'zpool_add_008_neg', 'zpool_add_009_neg', + 'add_nested_replacing_spare'] [/opt/zfs-tests/tests/functional/cli_root/zpool_attach] tests = ['zpool_attach_001_neg'] [/opt/zfs-tests/tests/functional/cli_root/zpool_clear] -tests = ['zpool_clear_001_pos', 'zpool_clear_002_neg', 'zpool_clear_003_neg'] +tests = ['zpool_clear_001_pos', 'zpool_clear_002_neg', 'zpool_clear_003_neg', + 'zpool_clear_readonly'] [/opt/zfs-tests/tests/functional/cli_root/zpool_create] tests = ['zpool_create_001_pos', 'zpool_create_002_pos', diff --git a/usr/src/test/zfs-tests/runfiles/omnios.run b/usr/src/test/zfs-tests/runfiles/omnios.run index df7dbb2d0e..7570bc5851 100644 --- a/usr/src/test/zfs-tests/runfiles/omnios.run +++ b/usr/src/test/zfs-tests/runfiles/omnios.run @@ -151,7 +151,8 @@ tests = ['zfs_written_property_001_pos'] tests = ['zfs_receive_001_pos', 'zfs_receive_002_pos', 'zfs_receive_003_pos', 'zfs_receive_005_neg', 'zfs_receive_006_pos', 'zfs_receive_007_neg', 'zfs_receive_008_pos', 'zfs_receive_009_neg', - 'zfs_receive_010_pos', 'zfs_receive_011_pos', 'zfs_receive_012_pos'] + 'zfs_receive_010_pos', 'zfs_receive_011_pos', 'zfs_receive_012_pos', + 'zfs_receive_014_pos'] [/opt/zfs-tests/tests/functional/cli_root/zfs_rename] tests = ['zfs_rename_001_pos', 'zfs_rename_002_pos', 'zfs_rename_003_pos', @@ -215,13 +216,15 @@ tests = ['zpool_001_neg', 'zpool_002_pos', 'zpool_003_pos'] [/opt/zfs-tests/tests/functional/cli_root/zpool_add] tests = ['zpool_add_001_pos', 'zpool_add_002_pos', 'zpool_add_003_pos', 'zpool_add_004_pos', 'zpool_add_005_pos', 'zpool_add_006_pos', - 'zpool_add_007_neg', 'zpool_add_008_neg', 'zpool_add_009_neg'] + 'zpool_add_007_neg', 'zpool_add_008_neg', 'zpool_add_009_neg', + 'add_nested_replacing_spare'] [/opt/zfs-tests/tests/functional/cli_root/zpool_attach] tests = ['zpool_attach_001_neg'] [/opt/zfs-tests/tests/functional/cli_root/zpool_clear] -tests = ['zpool_clear_001_pos', 'zpool_clear_002_neg', 'zpool_clear_003_neg'] +tests = ['zpool_clear_001_pos', 'zpool_clear_002_neg', 'zpool_clear_003_neg', + 'zpool_clear_readonly'] [/opt/zfs-tests/tests/functional/cli_root/zpool_create] tests = ['zpool_create_001_pos', 'zpool_create_002_pos', diff --git a/usr/src/test/zfs-tests/runfiles/openindiana.run b/usr/src/test/zfs-tests/runfiles/openindiana.run index 81672aac69..6508dedac9 100644 --- a/usr/src/test/zfs-tests/runfiles/openindiana.run +++ b/usr/src/test/zfs-tests/runfiles/openindiana.run @@ -151,7 +151,8 @@ tests = ['zfs_written_property_001_pos'] tests = ['zfs_receive_001_pos', 'zfs_receive_002_pos', 'zfs_receive_003_pos', 'zfs_receive_005_neg', 'zfs_receive_006_pos', 'zfs_receive_007_neg', 'zfs_receive_008_pos', 'zfs_receive_009_neg', - 'zfs_receive_010_pos', 'zfs_receive_011_pos', 'zfs_receive_012_pos'] + 'zfs_receive_010_pos', 'zfs_receive_011_pos', 'zfs_receive_012_pos', + 'zfs_receive_014_pos'] [/opt/zfs-tests/tests/functional/cli_root/zfs_rename] tests = ['zfs_rename_001_pos', 'zfs_rename_002_pos', 'zfs_rename_003_pos', @@ -215,13 +216,15 @@ tests = ['zpool_001_neg', 'zpool_002_pos', 'zpool_003_pos'] [/opt/zfs-tests/tests/functional/cli_root/zpool_add] tests = ['zpool_add_001_pos', 'zpool_add_002_pos', 'zpool_add_003_pos', 'zpool_add_004_pos', 'zpool_add_005_pos', 'zpool_add_006_pos', - 'zpool_add_007_neg', 'zpool_add_008_neg', 'zpool_add_009_neg'] + 'zpool_add_007_neg', 'zpool_add_008_neg', 'zpool_add_009_neg', + 'add_nested_replacing_spare'] [/opt/zfs-tests/tests/functional/cli_root/zpool_attach] tests = ['zpool_attach_001_neg'] [/opt/zfs-tests/tests/functional/cli_root/zpool_clear] -tests = ['zpool_clear_001_pos', 'zpool_clear_002_neg', 'zpool_clear_003_neg'] +tests = ['zpool_clear_001_pos', 'zpool_clear_002_neg', 'zpool_clear_003_neg', + 'zpool_clear_readonly'] [/opt/zfs-tests/tests/functional/cli_root/zpool_create] tests = ['zpool_create_001_pos', 'zpool_create_002_pos', diff --git a/usr/src/test/zfs-tests/tests/functional/acl/acl_common.kshlib b/usr/src/test/zfs-tests/tests/functional/acl/acl_common.kshlib index f6b1e80cbe..a67f1b0683 100644 --- a/usr/src/test/zfs-tests/tests/functional/acl/acl_common.kshlib +++ b/usr/src/test/zfs-tests/tests/functional/acl/acl_common.kshlib @@ -25,7 +25,7 @@ # # -# Copyright (c) 2016 by Delphix. All rights reserved. +# Copyright (c) 2016, 2018 by Delphix. All rights reserved. # . $STF_SUITE/tests/functional/acl/acl.cfg @@ -185,7 +185,7 @@ function plus_sign_check_l #<obj> return 1 fi - ls -ld $obj | awk '{print $1}' | grep "+\>" > /dev/null + ls -ld $obj | awk '{print $1}' | grep "+$" > /dev/null return $? } @@ -202,7 +202,7 @@ function plus_sign_check_v #<obj> return 1 fi - ls -vd $obj | nawk '(NR == 1) {print $1}' | grep "+\>" > /dev/null + ls -vd $obj | awk '(NR == 1) {print $1}' | grep "+$" > /dev/null return $? } diff --git a/usr/src/test/zfs-tests/tests/functional/acl/nontrivial/zfs_acl_cp_002_pos.ksh b/usr/src/test/zfs-tests/tests/functional/acl/nontrivial/zfs_acl_cp_002_pos.ksh index 6f122607a4..27e9752f01 100644 --- a/usr/src/test/zfs-tests/tests/functional/acl/nontrivial/zfs_acl_cp_002_pos.ksh +++ b/usr/src/test/zfs-tests/tests/functional/acl/nontrivial/zfs_acl_cp_002_pos.ksh @@ -26,7 +26,7 @@ # # -# Copyright (c) 2016 by Delphix. All rights reserved. +# Copyright (c) 2016, 2018 by Delphix. All rights reserved. # . $STF_SUITE/tests/functional/acl/acl_common.kshlib @@ -53,8 +53,7 @@ function cleanup if datasetexists $TESTPOOL/$TESTFS1; then log_must zfs destroy -f $TESTPOOL/$TESTFS1 fi - [[ -d $TESTDIR1 ]] && log_must rm -rf $TESTDIR1 - [[ -d $TESTDIR ]] && log_must rm -rf $TESTDIR/* + log_must rm -rf $TESTDIR1 $TESTDIR/* $mytestfile } log_assert "Verify that 'cp [-p]' supports ZFS ACLs." @@ -68,7 +67,9 @@ log_must chmod 777 $TESTDIR1 # Define target directory. dstdir=$TESTDIR1/dstdir.$$ -mytestfile=/kernel/drv/zfs +mytestfile=$(mktemp -t file.XXXX) +log_must dd if=/dev/urandom of=$mytestfile bs=1024k count=1 +log_must chmod 644 $mytestfile for user in root $ZFS_ACL_STAFF1; do # Set the current user diff --git a/usr/src/test/zfs-tests/tests/functional/acl/nontrivial/zfs_acl_cpio_002_pos.ksh b/usr/src/test/zfs-tests/tests/functional/acl/nontrivial/zfs_acl_cpio_002_pos.ksh index f66781d22b..160a620059 100644 --- a/usr/src/test/zfs-tests/tests/functional/acl/nontrivial/zfs_acl_cpio_002_pos.ksh +++ b/usr/src/test/zfs-tests/tests/functional/acl/nontrivial/zfs_acl_cpio_002_pos.ksh @@ -28,7 +28,7 @@ # # -# Copyright (c) 2016 by Delphix. All rights reserved. +# Copyright (c) 2016, 2018 by Delphix. All rights reserved. # . $STF_SUITE/tests/functional/acl/acl_common.kshlib @@ -57,8 +57,7 @@ function cleanup if (( ${#orig_dir} != 0 )); then cd $orig_dir fi - [[ -d $TESTDIR1 ]] && log_must rm -rf $TESTDIR1 - [[ -d $TESTDIR ]] && log_must rm -rf $TESTDIR/* + log_must rm -rf $TESTDIR1 $TESTDIR/* $mytestfile } log_assert "Verify that 'cpio' command supports to archive ZFS ACLs & xattrs." @@ -81,7 +80,9 @@ CPIOFILE=cpiofile.$$ file=$TESTFILE0 dir=dir.$$ orig_dir=$PWD -mytestfile=/kernel/drv/zfs +mytestfile=$(mktemp -t file.XXXX) +log_must dd if=/dev/urandom of=$mytestfile bs=1024k count=1 +log_must chmod 644 $mytestfile typeset user for user in root $ZFS_ACL_STAFF1; do diff --git a/usr/src/test/zfs-tests/tests/functional/acl/nontrivial/zfs_acl_tar_002_pos.ksh b/usr/src/test/zfs-tests/tests/functional/acl/nontrivial/zfs_acl_tar_002_pos.ksh index 4fae77709c..9a911fccb0 100644 --- a/usr/src/test/zfs-tests/tests/functional/acl/nontrivial/zfs_acl_tar_002_pos.ksh +++ b/usr/src/test/zfs-tests/tests/functional/acl/nontrivial/zfs_acl_tar_002_pos.ksh @@ -28,7 +28,7 @@ # # -# Copyright (c) 2016 by Delphix. All rights reserved. +# Copyright (c) 2016, 2018 by Delphix. All rights reserved. # . $STF_SUITE/tests/functional/acl/acl_common.kshlib @@ -57,8 +57,7 @@ function cleanup fi (( ${#cwd} != 0 )) && cd $cwd - [[ -d $TESTDIR1 ]] && log_must rm -rf $TESTDIR1 - [[ -d $TESTDIR/ ]] && log_must rm -rf $TESTDIR/* + log_must rm -rf $TESTDIR1 $TESTDIR/* $mytestfile } log_assert "Verify that 'tar' command supports to archive ZFS ACLs & xattrs." @@ -67,7 +66,9 @@ log_onexit cleanup set -A ops " A+user:other1:add_file:allow" "A+everyone@:execute:allow" "a-x" \ "777" -mytestfile=/kernel/drv/zfs +mytestfile=$(mktemp -t file.XXXX) +log_must dd if=/dev/urandom of=$mytestfile bs=1024k count=1 +log_must chmod 644 $mytestfile TARFILE=tarfile.$$.tar cwd=$PWD diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_006_neg.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_006_neg.ksh index cedfa676a1..af61f071cd 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_006_neg.ksh +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_promote/zfs_promote_006_neg.ksh @@ -40,6 +40,7 @@ # pool, fs, snapshot,volume # (4) too many arguments. # (5) invalid options +# (6) temporary %recv datasets # # STRATEGY: # 1. Create an array of invalid arguments @@ -50,11 +51,14 @@ verify_runnable "both" snap=$TESTPOOL/$TESTFS@$TESTSNAP +clone=$TESTPOOL/$TESTCLONE +recvfs=$TESTPOOL/recvfs set -A args "" \ "$TESTPOOL/blah" \ "$TESTPOOL" "$TESTPOOL/$TESTFS" "$snap" \ "$TESTPOOL/$TESTVOL" "$TESTPOOL $TESTPOOL/$TESTFS" \ - "$clone $TESTPOOL/$TESTFS" "- $clone" "-? $clone" + "$clone $TESTPOOL/$TESTFS" "- $clone" "-? $clone" \ + "$recvfs/%recv" function cleanup { @@ -62,6 +66,10 @@ function cleanup log_must zfs destroy $clone fi + if datasetexists $recvfs; then + log_must zfs destroy -r $recvfs + fi + if snapexists $snap; then destroy_snapshot $snap fi @@ -70,10 +78,9 @@ function cleanup log_assert "'zfs promote' will fail with invalid arguments. " log_onexit cleanup -snap=$TESTPOOL/$TESTFS@$TESTSNAP -clone=$TESTPOOL/$TESTCLONE log_must zfs snapshot $snap log_must zfs clone $snap $clone +create_recv_clone $recvfs typeset -i i=0 while (( i < ${#args[*]} )); do diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_014_pos.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_014_pos.ksh new file mode 100644 index 0000000000..f303581a09 --- /dev/null +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_014_pos.ksh @@ -0,0 +1,122 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# 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. +# +# CDDL HEADER END +# + +# +# Copyright 2017, loli10K. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib + +# +# DESCRIPTION: +# Verify ZFS successfully receive and restore properties. +# +# STRATEGY: +# 1. Create a filesystem. +# 2. Create a full stream with properties and receive it. +# 3. Create also an incremental stream without some properties and a truncated +# stream. +# 4. Fail to receive the truncated incremental stream and verify previously +# received properties are still present. +# 5. Receive the complete incremental send stream and verify that sent +# properties are successfully received. +# + +verify_runnable "both" + +orig=$TESTPOOL/$TESTFS1 +dest=$TESTPOOL/$TESTFS2 +typeset userprop=$(valid_user_property 8) +typeset userval=$(user_property_value 8) +typeset streamfile_full=$TESTDIR/streamfile_full.$$ +typeset streamfile_incr=$TESTDIR/streamfile_incr.$$ +typeset streamfile_trun=$TESTDIR/streamfile_trun.$$ + +function cleanup +{ + log_must rm $streamfile_full + log_must rm $streamfile_incr + log_must rm $streamfile_trun + log_must zfs destroy -rf $orig + log_must zfs destroy -rf $dest +} + +# +# Verify property $2 is set from source $4 on dataset $1 and has value $3. +# +# $1 checked dataset +# $2 user property +# $3 property value +# $4 source +# +function check_prop_source +{ + typeset dataset=$1 + typeset prop=$2 + typeset value=$3 + typeset source=$4 + typeset chk_value=$(get_prop "$prop" "$dataset") + typeset chk_source=$(get_source "$prop" "$dataset") + if [[ "$chk_value" != "$value" || \ + "$chk_source" != "$4" ]] + then + return 1 + else + return 0 + fi +} + +log_assert "ZFS successfully receive and restore properties." +log_onexit cleanup + +# 1. Create a filesystem. +log_must eval "zfs create $orig" +mntpnt=$(get_prop mountpoint $orig) + +# 2. Create a full stream with properties and receive it. +log_must eval "zfs set compression='gzip-1' $orig" +log_must eval "zfs set '$userprop'='$userval' $orig" +log_must eval "zfs snapshot $orig@snap1" +log_must eval "zfs send -p $orig@snap1 > $streamfile_full" +log_must eval "zfs recv $dest < $streamfile_full" +log_must eval "check_prop_source $dest compression 'gzip-1' received" +log_must eval "check_prop_source $dest '$userprop' '$userval' received" + +# 3. Create also an incremental stream without some properties and a truncated +# stream. +log_must eval "zfs set compression='gzip-2' $orig" +log_must eval "zfs inherit '$userprop' $orig" +log_must eval "dd if=/dev/urandom of=$mntpnt/file bs=1024k count=10" +log_must eval "zfs snapshot $orig@snap2" +log_must eval "zfs send -p -i $orig@snap1 $orig@snap2 > $streamfile_incr" +log_must eval "dd if=$streamfile_incr of=$streamfile_trun bs=1024k count=9" +log_must eval "zfs snapshot $orig@snap3" +log_must eval "zfs send -p -i $orig@snap1 $orig@snap3 > $streamfile_incr" + +# 4. Fail to receive the truncated incremental stream and verify previously +# received properties are still present. +log_mustnot eval "zfs recv -F $dest < $streamfile_trun" +log_must eval "check_prop_source $dest compression 'gzip-1' received" +log_must eval "check_prop_source $dest '$userprop' '$userval' received" + +# 5. Receive the complete incremental send stream and verify that sent +# properties are successfully received. +log_must eval "zfs recv -F $dest < $streamfile_incr" +log_must eval "check_prop_source $dest compression 'gzip-2' received" +log_must eval "check_prop_source $dest '$userprop' '-' '-'" + +log_pass "ZFS properties are successfully received and restored." diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.cfg b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.cfg index 26ff69b1bb..bf3a39363e 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.cfg +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.cfg @@ -36,3 +36,4 @@ export BS=512 export CNT=2048 export VOL_R_PATH=/dev/zvol/rdsk/$TESTPOOL/$TESTVOL export VOLDATA=$TESTDIR2/voldata.rename +export RECVFS=recvfs diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib index bb40bc1989..a60d7cf0f1 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib @@ -63,6 +63,8 @@ function additional_setup log_must cp $DATA $(get_prop mountpoint $TESTPOOL/$TESTVOL)/$TESTFILE0 fi + # Create temporary %recv clone + create_recv_clone $TESTPOOL/$RECVFS } function rename_dataset # src dest @@ -109,6 +111,9 @@ function cleanup log_must zfs destroy -fR $TESTPOOL/$TESTFS@snapshot fi + if datasetexists $TESTPOOL/$RECVFS; then + log_must zfs destroy -r $TESTPOOL/$RECVFS + fi } function cmp_data #<$1 src data, $2 tgt data> diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_004_neg.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_004_neg.ksh index cafa74366d..b1438e8663 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_004_neg.ksh +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_004_neg.ksh @@ -77,8 +77,8 @@ set -A bad_dataset $TESTPOOL/$TESTFS1 $TESTPOOL/$TESTCTR1 \ $TESTPOOL/$TESTFS1 $TESTPOOL/${TESTFS1}%x \ $TESTPOOL/$TESTFS1 $TESTPOOL/${TESTFS1}%p \ $TESTPOOL/$TESTFS1 $TESTPOOL/${TESTFS1}%s \ - $TESTPOOL/$TESTFS@snapshot \ - $TESTPOOL/$TESTFS@snapshot/fs + $TESTPOOL/$TESTFS@snapshot $TESTPOOL/$TESTFS@snapshot/fs \ + $TESTPOOL/$RECVFS/%recv $TESTPOOL/renamed.$$ # # cleanup defined in zfs_rename.kshlib diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh new file mode 100644 index 0000000000..54193db866 --- /dev/null +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh @@ -0,0 +1,103 @@ +#!/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 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib + +# +# DESCRIPTION: +# 'zpool add' works with nested replacing/spare vdevs +# +# STRATEGY: +# 1. Create a redundant pool with a spare device +# 2. Manually fault a device, wait for the hot-spare and then replace it: +# this creates a situation where replacing and spare vdevs are nested. +# 3. Verify 'zpool add' is able to add new devices to the pool. +# + +verify_runnable "global" + +function cleanup +{ + log_must zinject -c all + poolexists $TESTPOOL && \ + destroy_pool $TESTPOOL + log_must rm -f $DATA_DEVS $SPARE_DEVS +} + +log_assert "'zpool add' works with nested replacing/spare vdevs" +log_onexit cleanup + +TMPDIR='/var/tmp' +FAULT_DEV="$TMPDIR/fault-dev" +SAFE_DEV1="$TMPDIR/safe-dev1" +SAFE_DEV2="$TMPDIR/safe-dev2" +SAFE_DEV3="$TMPDIR/safe-dev3" +SAFE_DEVS="$SAFE_DEV1 $SAFE_DEV2 $SAFE_DEV3" +REPLACE_DEV="$TMPDIR/replace-dev" +ADD_DEV="$TMPDIR/add-dev" +DATA_DEVS="$FAULT_DEV $SAFE_DEVS $REPLACE_DEV $ADD_DEV" +SPARE_DEV1="$TMPDIR/spare-dev1" +SPARE_DEV2="$TMPDIR/spare-dev2" +SPARE_DEVS="$SPARE_DEV1 $SPARE_DEV2" + +for type in "mirror" "raidz1" "raidz2" "raidz3" +do + # 1. Create a redundant pool with a spare device + truncate -s $SPA_MINDEVSIZE $DATA_DEVS $SPARE_DEVS + log_must zpool create $TESTPOOL $type $FAULT_DEV $SAFE_DEVS + log_must zpool add $TESTPOOL spare $SPARE_DEV1 + + # 2.1 Fault a device, verify the spare is kicked in + log_must zinject -d $FAULT_DEV -e nxio -T all -f 100 $TESTPOOL + log_must zpool scrub $TESTPOOL + log_must wait_vdev_state $TESTPOOL $FAULT_DEV "UNAVAIL" 60 + log_must wait_vdev_state $TESTPOOL $SPARE_DEV1 "ONLINE" 60 + log_must wait_hotspare_state $TESTPOOL $SPARE_DEV1 "INUSE" + log_must check_state $TESTPOOL "$type-0" "DEGRADED" + + # 2.2 Replace the faulted device: this creates a replacing vdev inside a + # spare vdev + log_must zpool replace $TESTPOOL $FAULT_DEV $REPLACE_DEV + log_must wait_vdev_state $TESTPOOL $REPLACE_DEV "ONLINE" 60 + zpool status | nawk -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 + 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 + log_must wait_hotspare_state $TESTPOOL $SPARE_DEV2 "AVAIL" + log_must zpool add -f $TESTPOOL $ADD_DEV + log_must wait_vdev_state $TESTPOOL $ADD_DEV "ONLINE" 60 + + # Cleanup + cleanup +done + +log_pass "'zpool add' works with nested replacing/spare vdevs" diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_readonly.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_readonly.ksh new file mode 100644 index 0000000000..9eb2a3608f --- /dev/null +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_readonly.ksh @@ -0,0 +1,71 @@ +#!/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 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_root/zpool_clear/zpool_clear.cfg + +# +# DESCRIPTION: +# Verify 'zpool clear' cannot be used on readonly pools. +# +# STRATEGY: +# 1. Create a pool. +# 2. Export the pool and import it readonly. +# 3. Verify 'zpool clear' on the pool (and each device) returns an error. +# + +verify_runnable "global" + +function cleanup +{ + destroy_pool $TESTPOOL1 + rm -f $TESTDIR/file.* +} + +log_assert "Verify 'zpool clear' cannot be used on readonly pools." +log_onexit cleanup + +# 1. Create a pool. +log_must truncate -s $FILESIZE $TESTDIR/file.{1,2,3} +log_must zpool create $TESTPOOL1 raidz $TESTDIR/file.* + +# 2. Export the pool and import it readonly. +log_must zpool export $TESTPOOL1 +log_must zpool import -d $TESTDIR -o readonly=on $TESTPOOL1 +if [[ "$(get_pool_prop readonly $TESTPOOL1)" != 'on' ]]; then + log_fail "Pool $TESTPOOL1 was not imported readonly." +fi + +# 3. Verify 'zpool clear' on the pool (and each device) returns an error. +log_mustnot zpool clear $TESTPOOL1 +for i in {1..3}; do + # Device must be online + log_must check_state $TESTPOOL1 $TESTDIR/file.$i 'online' + # Device cannot be cleared if the pool was imported readonly + log_mustnot zpool clear $TESTPOOL1 $TESTDIR/file.$i +done + +log_pass "'zpool clear' fails on readonly pools as expected." diff --git a/usr/src/test/zfs-tests/tests/functional/removal/remove_mirror.ksh b/usr/src/test/zfs-tests/tests/functional/removal/remove_mirror.ksh index eb2ef6f6aa..c01e5210e9 100644 --- a/usr/src/test/zfs-tests/tests/functional/removal/remove_mirror.ksh +++ b/usr/src/test/zfs-tests/tests/functional/removal/remove_mirror.ksh @@ -15,7 +15,7 @@ # # -# Copyright (c) 2014, 2017 by Delphix. All rights reserved. +# Copyright (c) 2014, 2018 by Delphix. All rights reserved. # . $STF_SUITE/include/libtest.shlib @@ -25,7 +25,8 @@ TMPDIR=${TMPDIR:-/tmp} log_must mkfile $(($MINVDEVSIZE * 2)) $TMPDIR/dsk1 log_must mkfile $(($MINVDEVSIZE * 2)) $TMPDIR/dsk2 log_must mkfile $(($MINVDEVSIZE * 2)) $TMPDIR/dsk3 -DISKS="$TMPDIR/dsk1 mirror $TMPDIR/dsk2 $TMPDIR/dsk3" +DISKS="$TMPDIR/dsk1 $TMPDIR/dsk2 $TMPDIR/dsk3" +VDEVS="$TMPDIR/dsk1 mirror $TMPDIR/dsk2 $TMPDIR/dsk3" function cleanup { @@ -33,11 +34,12 @@ function cleanup log_must rm -f $DISKS } -log_must default_setup_noexit "$DISKS" +log_must default_setup_noexit "$VDEVS" log_onexit cleanup # Attempt to remove the non mirrored disk. log_must zpool remove $TESTPOOL $TMPDIR/dsk1 +log_must wait_for_removal $TESTPOOL # Attempt to remove one of the disks in the mirror. log_mustnot zpool remove $TESTPOOL $TMPDIR/dsk2 diff --git a/usr/src/test/zfs-tests/tests/functional/rsend/send-cD.ksh b/usr/src/test/zfs-tests/tests/functional/rsend/send-cD.ksh index 25dc46b3c3..9cbe3d5a59 100644 --- a/usr/src/test/zfs-tests/tests/functional/rsend/send-cD.ksh +++ b/usr/src/test/zfs-tests/tests/functional/rsend/send-cD.ksh @@ -12,7 +12,7 @@ # # -# Copyright (c) 2015 by Delphix. All rights reserved. +# Copyright (c) 2015, 2018 by Delphix. All rights reserved. # . $STF_SUITE/tests/functional/rsend/rsend.kshlib @@ -46,7 +46,7 @@ log_must zfs create -o compress=lz4 $sendfs log_must zfs create -o compress=lz4 $recvfs typeset dir=$(get_prop mountpoint $sendfs) # Don't use write_compressible: we want compressible but undedupable data here. -log_must cp /kernel/genunix $dir/file +log_must eval "dd if=/dev/urandom bs=1024k count=4 | base64 >$dir/file" log_must zfs snapshot $sendfs@snap0 log_must eval "zfs send -D -c $sendfs@snap0 >$stream0" diff --git a/usr/src/tools/scripts/nightly.sh b/usr/src/tools/scripts/nightly.sh index 7efa53e1f7..906c2b6e92 100644 --- a/usr/src/tools/scripts/nightly.sh +++ b/usr/src/tools/scripts/nightly.sh @@ -488,54 +488,6 @@ function build_tools { return 0 } -# -# Set up to use locally installed tools. -# -# usage: use_tools TOOLSROOT -# -function use_tools { - TOOLSROOT=$1 - - # - # If we're not building ON workspace, then the TOOLSROOT - # settings here are clearly ignored by the workspace - # makefiles, prepending nonexistent directories to PATH is - # harmless, and we clearly do not wish to override - # ONBLD_TOOLS. - # - # If we're building an ON workspace, then the prepended PATH - # elements should supercede the preexisting ONBLD_TOOLS paths, - # and we want to override ONBLD_TOOLS to catch the tools that - # don't have specific path env vars here. - # - # So the only conditional behavior is overriding ONBLD_TOOLS, - # and we check for "an ON workspace" by looking for - # ${TOOLSROOT}/opt/onbld. - # - - STABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/stabs - export STABS - CTFSTABS=${TOOLSROOT}/opt/onbld/bin/${MACH}/ctfstabs - export CTFSTABS - GENOFFSETS=${TOOLSROOT}/opt/onbld/bin/genoffsets - export GENOFFSETS - - PATH="${TOOLSROOT}/opt/onbld/bin/${MACH}:${PATH}" - PATH="${TOOLSROOT}/opt/onbld/bin:${PATH}" - export PATH - - if [ -d "${TOOLSROOT}/opt/onbld" ]; then - ONBLD_TOOLS=${TOOLSROOT}/opt/onbld - export ONBLD_TOOLS - fi - - echo "\n==== New environment settings. ====\n" >> $LOGFILE - echo "STABS=${STABS}" >> $LOGFILE - echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE - echo "PATH=${PATH}" >> $LOGFILE - echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE -} - function staffer { if [ $ISUSER -ne 0 ]; then "$@" @@ -1666,6 +1618,21 @@ fi [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory." [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found." +if [[ "$t_FLAG" = "y" ]]; then + echo "\n==== Bootstrapping cw ====\n" >> $LOGFILE + ( cd ${TOOLS} + set_non_debug_build_flags + rm -f $TMPDIR/make-state + $MAKE -K $TMPDIR/make-state -e TARGET=install cw 2>&1 >> $LOGFILE + [[ "$?" -ne 0 ]] && fatal_error "Error: could not bootstrap cw" + ) + + # Switch ONBLD_TOOLS early if -t is specified so that + # we could use bootstrapped cw for compiler checks. + ONBLD_TOOLS=${TOOLS_PROTO}/opt/onbld + export ONBLD_TOOLS +fi + echo "\n==== Build environment ====\n" | tee -a $build_environ_file >> $LOGFILE # System @@ -1742,7 +1709,29 @@ if [[ "$t_FLAG" = "y" ]]; then if (( $? != 0 )); then build_ok=n else - use_tools $TOOLS_PROTO + STABS=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs + export STABS + CTFSTABS=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs + export CTFSTABS + GENOFFSETS=${TOOLS_PROTO}/opt/onbld/bin/genoffsets + export GENOFFSETS + + CTFCONVERT=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert + export CTFCONVERT + CTFMERGE=${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfmerge + export CTFMERGE + + PATH="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}" + PATH="${TOOLS_PROTO}/opt/onbld/bin:${PATH}" + export PATH + + echo "\n==== New environment settings. ====\n" >> $LOGFILE + echo "STABS=${STABS}" >> $LOGFILE + echo "CTFSTABS=${CTFSTABS}" >> $LOGFILE + echo "CTFCONVERT=${CTFCONVERT}" >> $LOGFILE + echo "CTFMERGE=${CTFMERGE}" >> $LOGFILE + echo "PATH=${PATH}" >> $LOGFILE + echo "ONBLD_TOOLS=${ONBLD_TOOLS}" >> $LOGFILE fi fi diff --git a/usr/src/uts/common/fs/zfs/dsl_dataset.c b/usr/src/uts/common/fs/zfs/dsl_dataset.c index dd522e13c6..5a2cee7b4e 100644 --- a/usr/src/uts/common/fs/zfs/dsl_dataset.c +++ b/usr/src/uts/common/fs/zfs/dsl_dataset.c @@ -2539,7 +2539,7 @@ dsl_dataset_rollback_check(void *arg, dmu_tx_t *tx) /* must have a most recent snapshot */ if (dsl_dataset_phys(ds)->ds_prev_snap_txg < TXG_INITIAL) { dsl_dataset_rele(ds, FTAG); - return (SET_ERROR(EINVAL)); + return (SET_ERROR(ESRCH)); } /* @@ -2559,11 +2559,46 @@ dsl_dataset_rollback_check(void *arg, dmu_tx_t *tx) * the latest snapshot is it. */ if (ddra->ddra_tosnap != NULL) { - char namebuf[ZFS_MAX_DATASET_NAME_LEN]; + dsl_dataset_t *snapds; + + /* Check if the target snapshot exists at all. */ + error = dsl_dataset_hold(dp, ddra->ddra_tosnap, FTAG, &snapds); + if (error != 0) { + /* + * ESRCH is used to signal that the target snapshot does + * not exist, while ENOENT is used to report that + * the rolled back dataset does not exist. + * ESRCH is also used to cover other cases where the + * target snapshot is not related to the dataset being + * rolled back such as being in a different pool. + */ + if (error == ENOENT || error == EXDEV) + error = SET_ERROR(ESRCH); + dsl_dataset_rele(ds, FTAG); + return (error); + } + ASSERT(snapds->ds_is_snapshot); - dsl_dataset_name(ds->ds_prev, namebuf); - if (strcmp(namebuf, ddra->ddra_tosnap) != 0) - return (SET_ERROR(EXDEV)); + /* Check if the snapshot is the latest snapshot indeed. */ + if (snapds != ds->ds_prev) { + /* + * Distinguish between the case where the only problem + * is intervening snapshots (EEXIST) vs the snapshot + * not being a valid target for rollback (ESRCH). + */ + if (snapds->ds_dir == ds->ds_dir || + (dsl_dir_is_clone(ds->ds_dir) && + dsl_dir_phys(ds->ds_dir)->dd_origin_obj == + snapds->ds_object)) { + error = SET_ERROR(EEXIST); + } else { + error = SET_ERROR(ESRCH); + } + dsl_dataset_rele(snapds, FTAG); + dsl_dataset_rele(ds, FTAG); + return (error); + } + dsl_dataset_rele(snapds, FTAG); } /* must not have any bookmarks after the most recent snapshot */ @@ -2572,8 +2607,10 @@ dsl_dataset_rollback_check(void *arg, dmu_tx_t *tx) nvlist_t *bookmarks = fnvlist_alloc(); error = dsl_get_bookmarks_impl(ds, proprequest, bookmarks); fnvlist_free(proprequest); - if (error != 0) + if (error != 0) { + dsl_dataset_rele(ds, FTAG); return (error); + } for (nvpair_t *pair = nvlist_next_nvpair(bookmarks, NULL); pair != NULL; pair = nvlist_next_nvpair(bookmarks, pair)) { nvlist_t *valuenv = diff --git a/usr/src/uts/common/fs/zfs/dsl_prop.c b/usr/src/uts/common/fs/zfs/dsl_prop.c index aeefbf39fa..ce0cd9b0fe 100644 --- a/usr/src/uts/common/fs/zfs/dsl_prop.c +++ b/usr/src/uts/common/fs/zfs/dsl_prop.c @@ -855,11 +855,15 @@ dsl_props_set_sync_impl(dsl_dataset_t *ds, zprop_source_t source, while ((elem = nvlist_next_nvpair(props, elem)) != NULL) { nvpair_t *pair = elem; + const char *name = nvpair_name(pair); if (nvpair_type(pair) == DATA_TYPE_NVLIST) { /* - * dsl_prop_get_all_impl() returns properties in this - * format. + * This usually happens when we reuse the nvlist_t data + * returned by the counterpart dsl_prop_get_all_impl(). + * For instance we do this to restore the original + * received properties when an error occurs in the + * zfs_ioc_recv() codepath. */ nvlist_t *attrs = fnvpair_value_nvlist(pair); pair = fnvlist_lookup_nvpair(attrs, ZPROP_VALUE); @@ -867,14 +871,14 @@ dsl_props_set_sync_impl(dsl_dataset_t *ds, zprop_source_t source, if (nvpair_type(pair) == DATA_TYPE_STRING) { const char *value = fnvpair_value_string(pair); - dsl_prop_set_sync_impl(ds, nvpair_name(pair), + dsl_prop_set_sync_impl(ds, name, source, 1, strlen(value) + 1, value, tx); } else if (nvpair_type(pair) == DATA_TYPE_UINT64) { uint64_t intval = fnvpair_value_uint64(pair); - dsl_prop_set_sync_impl(ds, nvpair_name(pair), + dsl_prop_set_sync_impl(ds, name, source, sizeof (intval), 1, &intval, tx); } else if (nvpair_type(pair) == DATA_TYPE_BOOLEAN) { - dsl_prop_set_sync_impl(ds, nvpair_name(pair), + dsl_prop_set_sync_impl(ds, name, source, 0, 0, NULL, tx); } else { panic("invalid nvpair type"); diff --git a/usr/src/uts/common/fs/zfs/lua/lgc.c b/usr/src/uts/common/fs/zfs/lua/lgc.c index 9c98630574..4a7d25af20 100644 --- a/usr/src/uts/common/fs/zfs/lua/lgc.c +++ b/usr/src/uts/common/fs/zfs/lua/lgc.c @@ -677,7 +677,7 @@ static void freeobj (lua_State *L, GCObject *o) { case LUA_TUSERDATA: luaM_freemem(L, o, sizeudata(gco2u(o))); break; case LUA_TSHRSTR: G(L)->strt.nuse--; - /* go through */ + /* FALLTHROUGH */ case LUA_TLNGSTR: { luaM_freemem(L, o, sizestring(gco2ts(o))); break; diff --git a/usr/src/uts/common/fs/zfs/lua/llex.c b/usr/src/uts/common/fs/zfs/lua/llex.c index c84844aec5..dfac7aef86 100644 --- a/usr/src/uts/common/fs/zfs/lua/llex.c +++ b/usr/src/uts/common/fs/zfs/lua/llex.c @@ -475,6 +475,7 @@ static int llex (LexState *ls, SemInfo *seminfo) { else if (!lisdigit(ls->current)) return '.'; /* else go through */ } + /* FALLTHROUGH */ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { read_numeral(ls, seminfo); diff --git a/usr/src/uts/common/fs/zfs/lua/lstrlib.c b/usr/src/uts/common/fs/zfs/lua/lstrlib.c index 86d0ff2654..eef8508c4d 100644 --- a/usr/src/uts/common/fs/zfs/lua/lstrlib.c +++ b/usr/src/uts/common/fs/zfs/lua/lstrlib.c @@ -514,7 +514,7 @@ static const char *match (MatchState *ms, const char *s, const char *p) { } case '+': /* 1 or more repetitions */ s++; /* 1 match already done */ - /* go through */ + /* FALLTHROUGH */ case '*': /* 0 or more repetitions */ s = max_expand(ms, s, p, ep); break; diff --git a/usr/src/uts/common/fs/zfs/lua/ltable.c b/usr/src/uts/common/fs/zfs/lua/ltable.c index a5279011c4..4f8ab1b167 100644 --- a/usr/src/uts/common/fs/zfs/lua/ltable.c +++ b/usr/src/uts/common/fs/zfs/lua/ltable.c @@ -490,6 +490,7 @@ const TValue *luaH_get (Table *t, const TValue *key) { return luaH_getint(t, k); /* use specialized version */ /* else go through */ } + /* FALLTHROUGH */ default: { Node *n = mainposition(t, key); do { /* check whether `key' is somewhere in the chain */ diff --git a/usr/src/uts/common/fs/zfs/vdev_indirect_mapping.c b/usr/src/uts/common/fs/zfs/vdev_indirect_mapping.c index b350ee59fa..ea80fbc473 100644 --- a/usr/src/uts/common/fs/zfs/vdev_indirect_mapping.c +++ b/usr/src/uts/common/fs/zfs/vdev_indirect_mapping.c @@ -133,8 +133,8 @@ vdev_indirect_mapping_size(vdev_indirect_mapping_t *vim) static int dva_mapping_overlap_compare(const void *v_key, const void *v_array_elem) { - const uint64_t const *key = v_key; - const vdev_indirect_mapping_entry_phys_t const *array_elem = + const uint64_t *key = v_key; + const vdev_indirect_mapping_entry_phys_t *array_elem = v_array_elem; uint64_t src_offset = DVA_MAPPING_GET_SRC_OFFSET(array_elem); diff --git a/usr/src/uts/common/fs/zfs/zfs_ioctl.c b/usr/src/uts/common/fs/zfs/zfs_ioctl.c index dcad1b47b1..71695873a3 100644 --- a/usr/src/uts/common/fs/zfs/zfs_ioctl.c +++ b/usr/src/uts/common/fs/zfs/zfs_ioctl.c @@ -3739,11 +3739,14 @@ zfs_ioc_rollback(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl) (void) nvlist_lookup_string(innvl, "target", &target); if (target != NULL) { - int fslen = strlen(fsname); + const char *cp = strchr(target, '@'); - if (strncmp(fsname, target, fslen) != 0) - return (SET_ERROR(EINVAL)); - if (target[fslen] != '@') + /* + * The snap name must contain an @, and the part after it must + * contain only valid characters. + */ + if (cp == NULL || + zfs_component_namecheck(cp + 1, NULL, NULL) != 0) return (SET_ERROR(EINVAL)); } @@ -3793,9 +3796,12 @@ zfs_ioc_rename(zfs_cmd_t *zc) boolean_t recursive = zc->zc_cookie & 1; char *at; + /* "zfs rename" from and to ...%recv datasets should both fail */ + zc->zc_name[sizeof (zc->zc_name) - 1] = '\0'; zc->zc_value[sizeof (zc->zc_value) - 1] = '\0'; - if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 || - strchr(zc->zc_value, '%')) + if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0 || + dataset_namecheck(zc->zc_value, NULL, NULL) != 0 || + strchr(zc->zc_name, '%') || strchr(zc->zc_value, '%')) return (SET_ERROR(EINVAL)); at = strchr(zc->zc_name, '@'); @@ -4818,6 +4824,11 @@ zfs_ioc_promote(zfs_cmd_t *zc) char *cp; int error; + zc->zc_name[sizeof (zc->zc_name) - 1] = '\0'; + if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0 || + strchr(zc->zc_name, '%')) + return (SET_ERROR(EINVAL)); + error = dsl_pool_hold(zc->zc_name, FTAG, &dp); if (error != 0) return (error); @@ -5935,7 +5946,7 @@ zfs_ioctl_init(void) zfs_secpolicy_config, B_TRUE, POOL_CHECK_NONE); zfs_ioctl_register_pool(ZFS_IOC_CLEAR, zfs_ioc_clear, - zfs_secpolicy_config, B_TRUE, POOL_CHECK_NONE); + zfs_secpolicy_config, B_TRUE, POOL_CHECK_READONLY); zfs_ioctl_register_pool(ZFS_IOC_POOL_REOPEN, zfs_ioc_pool_reopen, zfs_secpolicy_config, B_TRUE, POOL_CHECK_SUSPENDED); diff --git a/usr/src/uts/common/io/cxgbe/common/t4_hw.c b/usr/src/uts/common/io/cxgbe/common/t4_hw.c index df67ccd270..0f3ebc7da8 100644 --- a/usr/src/uts/common/io/cxgbe/common/t4_hw.c +++ b/usr/src/uts/common/io/cxgbe/common/t4_hw.c @@ -348,7 +348,6 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, const void *cmd, #ifdef T4_OS_NEEDS_MBOX_LOCKING u16 access = 0; #endif - u16 execute = 0; u32 v; u64 res; int i, ret; @@ -509,8 +508,7 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, const void *cmd, T4_OS_MBOX_LOCKING(t4_os_atomic_list_del(&entry, &adap->mbox_lock)); - execute = i + 1; - T4_RECORD_MBOX(adap, cmd_rpl, size, access, execute); + T4_RECORD_MBOX(adap, cmd_rpl, size, access, i + 1); /* * XXX It's not clear that we need this anymore now @@ -519,7 +517,7 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int mbox, const void *cmd, CH_DUMP_MBOX(adap, mbox, data_reg, size / 8); CH_MSG(adap, INFO, HW, "command completed in %d ms (%ssleeping)\n", - execute, sleep_ok ? "" : "non-"); + i + 1, sleep_ok ? "" : "non-"); res = be64_to_cpu(cmd_rpl[0]); if (G_FW_CMD_OP(res >> 32) == FW_DEBUG_CMD) { |