diff options
| author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2017-01-16 15:38:08 +0000 |
|---|---|---|
| committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2017-01-16 15:38:08 +0000 |
| commit | 70258efd7c8fc86cc2d1e081256b5e5edbdf7ec7 (patch) | |
| tree | b54080a3e58f448cbfb8f1c3dbdcdbb52ca6732a | |
| parent | 89604c6d5bf9b0d8361322d21c4aa656db64c425 (diff) | |
| parent | ab2e2ee8084b5368a6eff4d96fbad03a661c8ace (diff) | |
| download | illumos-joyent-70258efd7c8fc86cc2d1e081256b5e5edbdf7ec7.tar.gz | |
[illumos-gate merge]
commit ab2e2ee8084b5368a6eff4d96fbad03a661c8ace
7687 mdb cross-module dcmd calls fail in CTF lookup
commit 19f5167cc175d745bf9d9a007352b8784d628ac9
7767 6464's call to mount() is incomplete
commit 8a154f4f3d77e2c2fd480e445935132f13370372
7765 hal and policykit need to list libdbus dependencies
commit 8c8556f95acedca484319abaeb0eb9287d31f991
6923 ipadm show-prop output is ugly when property doesn't exist
commit c95076cee9c3910b6b803dc213adbf74a57acf8e
6865 want zfs-tests cases for zpool labelclear command
commit 64723e361134b2a2c45341334174f9d34002f8d0
6866 zdb -l should return non-zero if it fails to find any label
commit 105686550ee9cbf5d033166a8a2a5a763667d436
7730 libzfs`add_config() leaks config nvl when reading spare/l2cache devices
commit f5fb56de308f70aaa788d3921c1177fad4183232
7629 Fix for 7290 neglected to remove some escape sequences
22 files changed, 384 insertions, 251 deletions
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c b/usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c index 5f86ebcc10..c4b7fd225f 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c @@ -18,10 +18,12 @@ * * CDDL HEADER END */ + /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright 2012 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 Nexenta Systems, Inc. */ + #include <arpa/inet.h> #include <errno.h> #include <getopt.h> @@ -495,8 +497,7 @@ do_disable_if(int argc, char *argv[], const char *use) } /* - * called in from print_prop_cb() and does the job of printing each - * individual column in the 'ipadm show-*prop' output. + * Print individual columns for the show-*prop subcommands. */ static void print_prop(show_prop_state_t *statep, uint_t flags, char *buf, size_t bufsize) @@ -524,22 +525,8 @@ print_prop(show_prop_state_t *statep, uint_t flags, char *buf, size_t bufsize) } if (status != IPADM_SUCCESS) { - if (status == IPADM_PROP_UNKNOWN || - status == IPADM_INVALID_ARG) { - warn_ipadmerr(status, "cannot get property '%s' for " - "'%s'", prop_name, object); - } else if (status == IPADM_NOTSUP) { - warn_ipadmerr(status, "'%s'", object); - } else if (status == IPADM_NOTFOUND) { - if (flags & IPADM_OPT_PERSIST) { - propval[0] = '\0'; - goto cont; - } else { - warn_ipadmerr(status, "no such object '%s'", - object); - } - } else if (status == IPADM_ENXIO) { - /* the interface is probably disabled */ + if ((status == IPADM_NOTFOUND && (flags & IPADM_OPT_PERSIST)) || + status == IPADM_ENXIO) { propval[0] = '\0'; goto cont; } @@ -553,8 +540,7 @@ cont: } /* - * callback function which displays output for set-prop, set-ifprop and - * set-addrprop subcommands. + * Callback function for show-*prop subcommands. */ static boolean_t print_prop_cb(ofmt_arg_t *ofarg, char *buf, size_t bufsize) @@ -2083,9 +2069,13 @@ do_show_addrprop(int argc, char *argv[], const char *use) ofmt_handle_t ofmt; ofmt_status_t oferr; uint_t ofmtflags = 0; - char *aobjname; + char *aobjname = NULL; char *ifname = NULL; char *cp; + ipadm_addr_info_t *ainfop = NULL; + ipadm_addr_info_t *ptr; + ipadm_status_t status; + boolean_t found = _B_FALSE; opterr = 0; bzero(&state, sizeof (state)); @@ -2100,7 +2090,7 @@ do_show_addrprop(int argc, char *argv[], const char *use) case 'p': if (ipadm_str2nvlist(optarg, &proplist, IPADM_NORVAL) != 0) - die("invalid interface properties specified"); + die("invalid addrobj properties specified"); break; case 'c': state.sps_parsable = _B_TRUE; @@ -2117,15 +2107,13 @@ do_show_addrprop(int argc, char *argv[], const char *use) aobjname = argv[optind]; cp = strchr(aobjname, '/'); if (cp == NULL) - die("Invalid address object name provided"); + die("invalid addrobj name provided"); if (*(cp + 1) == '\0') { ifname = aobjname; *cp = '\0'; aobjname = NULL; } - } else if (optind == argc) { - aobjname = NULL; - } else { + } else if (optind != argc) { die("Usage: %s", use); } state.sps_proplist = proplist; @@ -2135,38 +2123,41 @@ do_show_addrprop(int argc, char *argv[], const char *use) ipadm_ofmt_check(oferr, state.sps_parsable, ofmt); state.sps_ofmt = ofmt; - if (aobjname != NULL) { - (void) strlcpy(state.sps_aobjname, aobjname, - sizeof (state.sps_aobjname)); - show_properties(&state, IPADMPROP_CLASS_ADDR); - } else { - ipadm_addr_info_t *ainfop = NULL; - ipadm_addr_info_t *ptr; - ipadm_status_t status; + status = ipadm_addr_info(iph, ifname, &ainfop, 0, LIFC_DEFAULT); + /* Return without printing any error, if no addresses were found */ + if (status == IPADM_NOTFOUND) + return; + if (status != IPADM_SUCCESS) + die("error retrieving address: %s", ipadm_status2str(status)); - status = ipadm_addr_info(iph, ifname, &ainfop, 0, LIFC_DEFAULT); - /* - * Return without printing any error, if no addresses were - * found. - */ - if (status == IPADM_NOTFOUND) - return; - if (status != IPADM_SUCCESS) { - die("Error retrieving address: %s", - ipadm_status2str(status)); + for (ptr = ainfop; ptr != NULL; ptr = IA_NEXT(ptr)) { + char *taobjname = ptr->ia_aobjname; + + if (taobjname[0] == '\0') + continue; + if (aobjname != NULL) { + if (strcmp(aobjname, taobjname) == 0) + found = _B_TRUE; + else + continue; } - for (ptr = ainfop; ptr; ptr = IA_NEXT(ptr)) { - aobjname = ptr->ia_aobjname; - if (aobjname[0] == '\0' || - ptr->ia_atype == IPADM_ADDR_IPV6_ADDRCONF) { + if (ptr->ia_atype == IPADM_ADDR_IPV6_ADDRCONF) { + if (found) + break; + else continue; - } - (void) strlcpy(state.sps_aobjname, aobjname, - sizeof (state.sps_aobjname)); - show_properties(&state, IPADMPROP_CLASS_ADDR); } - ipadm_free_addr_info(ainfop); + (void) strlcpy(state.sps_aobjname, taobjname, + sizeof (state.sps_aobjname)); + show_properties(&state, IPADMPROP_CLASS_ADDR); + if (found) + break; } + ipadm_free_addr_info(ainfop); + + if (aobjname != NULL && !found) + die("addrobj not found: %s", aobjname); + nvlist_free(proplist); ofmt_close(ofmt); if (state.sps_retstatus != IPADM_SUCCESS) { diff --git a/usr/src/cmd/mdb/common/mdb/mdb_modapi.c b/usr/src/cmd/mdb/common/mdb/mdb_modapi.c index e58391b72c..45f161aed6 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_modapi.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_modapi.c @@ -22,7 +22,7 @@ /* * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013 by Delphix. All rights reserved. - * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * Copyright 2016 Nexenta Systems, Inc. All rights reserved. */ #include <mdb/mdb_modapi.h> @@ -54,6 +54,10 @@ int mdb_prop_postmortem = FALSE; /* Are we examining a dump? */ int mdb_prop_kernel = FALSE; /* Are we examining a kernel? */ int mdb_prop_datamodel = 0; /* Data model (see mdb_target_impl.h) */ +static int +call_idcmd(mdb_idcmd_t *idcp, uintmax_t addr, uintmax_t count, + uint_t flags, mdb_argvec_t *argv); + ssize_t mdb_vread(void *buf, size_t nbytes, uintptr_t addr) { @@ -584,8 +588,8 @@ walk_dcmd(uintptr_t addr, const void *ignored, dcmd_walk_arg_t *dwp) int status; mdb.m_frame->f_cbactive = B_TRUE; - status = mdb_call_idcmd(dwp->dw_dcmd, addr, 1, dwp->dw_flags, - &dwp->dw_argv, NULL, NULL); + status = call_idcmd(dwp->dw_dcmd, addr, 1, dwp->dw_flags, + &dwp->dw_argv); mdb.m_frame->f_cbactive = B_FALSE; if (status == DCMD_USAGE || status == DCMD_ABORT) @@ -710,7 +714,7 @@ mdb_call_dcmd(const char *name, uintptr_t dot, uint_t flags, args.a_data = (mdb_arg_t *)argv; args.a_nelems = args.a_size = argc; - status = mdb_call_idcmd(idcp, dot, 1, flags, &args, NULL, NULL); + status = call_idcmd(idcp, dot, 1, flags, &args); if (status == DCMD_ERR || status == DCMD_ABORT) return (set_errno(EMDB_DCFAIL)); @@ -721,6 +725,35 @@ mdb_call_dcmd(const char *name, uintptr_t dot, uint_t flags, return (0); } +/* + * When dcmds or walkers call a dcmd that might be in another module, + * we need to set mdb.m_frame->f_cp to an mdb_cmd that represents the + * dcmd we're currently executing, otherwise mdb_get_module gets the + * module of the caller instead of the module for the current dcmd. + */ +static int +call_idcmd(mdb_idcmd_t *idcp, uintmax_t addr, uintmax_t count, + uint_t flags, mdb_argvec_t *argv) +{ + mdb_cmd_t *save_cp; + mdb_cmd_t cmd; + int ret; + + bzero(&cmd, sizeof (cmd)); + cmd.c_dcmd = idcp; + cmd.c_argv = *argv; + + save_cp = mdb.m_frame->f_cp; + mdb.m_frame->f_cp = &cmd; + + ret = mdb_call_idcmd(cmd.c_dcmd, addr, count, flags, + &cmd.c_argv, NULL, NULL); + + mdb.m_frame->f_cp = save_cp; + + return (ret); +} + int mdb_add_walker(const mdb_walker_t *wp) { diff --git a/usr/src/cmd/zdb/zdb.c b/usr/src/cmd/zdb/zdb.c index bd9c5c2408..ecf63568ab 100644 --- a/usr/src/cmd/zdb/zdb.c +++ b/usr/src/cmd/zdb/zdb.c @@ -23,6 +23,7 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2016 by Delphix. All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2016 Nexenta Systems, Inc. */ #include <stdio.h> @@ -119,7 +120,7 @@ static void usage(void) { (void) fprintf(stderr, - "Usage: %s [-CumMdibcsDvhLXFPAG] [-t txg] [-e [-p path...]] " + "Usage: %s [-CmMdibcsDvhLXFPAG] [-t txg] [-e [-p path...]] " "[-U config] [-I inflight I/Os] [-x dumpdir] [-o var=value] " "poolname [object...]\n" " %s [-divPA] [-e -p path...] [-U config] dataset " @@ -129,7 +130,7 @@ usage(void) " %s -R [-A] [-e [-p path...]] poolname " "vdev:offset:size[:flags]\n" " %s -S [-PA] [-e [-p path...]] [-U config] poolname\n" - " %s -l [-uA] device\n" + " %s -l [-Aqu] device\n" " %s -C [-A] [-U config]\n\n", cmdname, cmdname, cmdname, cmdname, cmdname, cmdname, cmdname); @@ -140,7 +141,6 @@ usage(void) (void) fprintf(stderr, " If object numbers are specified, only " "those objects are dumped\n\n"); (void) fprintf(stderr, " Options to control amount of output:\n"); - (void) fprintf(stderr, " -u uberblock\n"); (void) fprintf(stderr, " -d dataset(s)\n"); (void) fprintf(stderr, " -i intent logs\n"); (void) fprintf(stderr, " -C config (or cachefile if alone)\n"); @@ -154,7 +154,7 @@ usage(void) (void) fprintf(stderr, " -D dedup statistics\n"); (void) fprintf(stderr, " -S simulate dedup to measure effect\n"); (void) fprintf(stderr, " -v verbose (applies to all others)\n"); - (void) fprintf(stderr, " -l dump label contents\n"); + (void) fprintf(stderr, " -l read label contents\n"); (void) fprintf(stderr, " -L disable leak tracking (do not " "load spacemaps)\n"); (void) fprintf(stderr, " -R read and display block from a " @@ -185,6 +185,8 @@ usage(void) "exiting\n"); (void) fprintf(stderr, " -o <variable>=<value> set global " "variable to an unsigned 32-bit integer value\n"); + (void) fprintf(stderr, " -q don't print label contents\n"); + (void) fprintf(stderr, " -u uberblock\n"); (void) fprintf(stderr, "Specify an option more than once (e.g. -bb) " "to make only that option verbose\n"); (void) fprintf(stderr, "Default is to dump everything non-verbosely\n"); @@ -2139,45 +2141,48 @@ dump_label_uberblocks(vdev_label_t *lbl, uint64_t ashift) } } -static void +static int dump_label(const char *dev) { int fd; vdev_label_t label; - char *path, *buf = label.vl_vdev_phys.vp_nvlist; + char path[MAXPATHLEN]; + char *buf = label.vl_vdev_phys.vp_nvlist; size_t buflen = sizeof (label.vl_vdev_phys.vp_nvlist); struct stat64 statbuf; uint64_t psize, ashift; - int len = strlen(dev) + 1; - - if (strncmp(dev, ZFS_DISK_ROOTD, strlen(ZFS_DISK_ROOTD)) == 0) { - len++; - path = malloc(len); - (void) snprintf(path, len, "%s%s", ZFS_RDISK_ROOTD, - dev + strlen(ZFS_DISK_ROOTD)); - } else { - path = strdup(dev); - } + boolean_t label_found = B_FALSE; + + (void) strlcpy(path, dev, sizeof (path)); + if (dev[0] == '/') { + if (strncmp(dev, ZFS_DISK_ROOTD, + strlen(ZFS_DISK_ROOTD)) == 0) { + (void) snprintf(path, sizeof (path), "%s%s", + ZFS_RDISK_ROOTD, dev + strlen(ZFS_DISK_ROOTD)); + } + } else if (stat64(path, &statbuf) != 0) { + char *s; - if ((fd = open64(path, O_RDONLY)) < 0) { - (void) printf("cannot open '%s': %s\n", path, strerror(errno)); - free(path); - exit(1); + (void) snprintf(path, sizeof (path), "%s%s", ZFS_RDISK_ROOTD, + dev); + if ((s = strrchr(dev, 's')) == NULL || !isdigit(*(s + 1))) + (void) strlcat(path, "s0", sizeof (path)); } - if (fstat64(fd, &statbuf) != 0) { + if (stat64(path, &statbuf) != 0) { (void) printf("failed to stat '%s': %s\n", path, strerror(errno)); - free(path); - (void) close(fd); exit(1); } if (S_ISBLK(statbuf.st_mode)) { (void) printf("cannot use '%s': character device required\n", path); - free(path); - (void) close(fd); + exit(1); + } + + if ((fd = open64(path, O_RDONLY)) < 0) { + (void) printf("cannot open '%s': %s\n", path, strerror(errno)); exit(1); } @@ -2187,36 +2192,43 @@ dump_label(const char *dev) for (int l = 0; l < VDEV_LABELS; l++) { nvlist_t *config = NULL; - (void) printf("--------------------------------------------\n"); - (void) printf("LABEL %d\n", l); - (void) printf("--------------------------------------------\n"); + if (!dump_opt['q']) { + (void) printf("------------------------------------\n"); + (void) printf("LABEL %d\n", l); + (void) printf("------------------------------------\n"); + } if (pread64(fd, &label, sizeof (label), vdev_label_offset(psize, l, 0)) != sizeof (label)) { - (void) printf("failed to read label %d\n", l); + if (!dump_opt['q']) + (void) printf("failed to read label %d\n", l); continue; } if (nvlist_unpack(buf, buflen, &config, 0) != 0) { - (void) printf("failed to unpack label %d\n", l); + if (!dump_opt['q']) + (void) printf("failed to unpack label %d\n", l); ashift = SPA_MINBLOCKSHIFT; } else { nvlist_t *vdev_tree = NULL; - dump_nvlist(config, 4); + if (!dump_opt['q']) + dump_nvlist(config, 4); if ((nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, &vdev_tree) != 0) || (nvlist_lookup_uint64(vdev_tree, ZPOOL_CONFIG_ASHIFT, &ashift) != 0)) ashift = SPA_MINBLOCKSHIFT; nvlist_free(config); + label_found = B_TRUE; } if (dump_opt['u']) dump_label_uberblocks(&label, ashift); } - free(path); (void) close(fd); + + return (label_found ? 0 : 2); } static uint64_t dataset_feature_count[SPA_FEATURES]; @@ -3587,7 +3599,7 @@ main(int argc, char **argv) spa_config_path = spa_config_path_env; while ((c = getopt(argc, argv, - "bcdhilmMI:suCDRSAFLXx:evp:t:U:PGo:")) != -1) { + "bcdhilmMI:suCDRSAFLXx:evp:t:U:PGo:q")) != -1) { switch (c) { case 'b': case 'c': @@ -3613,6 +3625,7 @@ main(int argc, char **argv) case 'X': case 'e': case 'P': + case 'q': dump_opt[c]++; break; case 'I': @@ -3720,10 +3733,8 @@ main(int argc, char **argv) usage(); } - if (dump_opt['l']) { - dump_label(argv[0]); - return (0); - } + if (dump_opt['l']) + return (dump_label(argv[0])); if (dump_opt['X'] || dump_opt['F']) rewind = ZPOOL_DO_REWIND | diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile index eee088c5a9..9226a01e89 100644 --- a/usr/src/lib/Makefile +++ b/usr/src/lib/Makefile @@ -26,8 +26,8 @@ # Copyright (c) 2013 Gary Mills # Copyright 2014 Garrett D'Amore <garrett@damore.org> # Copyright (c) 2015 Gary Mills -# Copyright 2015 Nexenta Systems, Inc. All rights reserved. # Copyright 2016 Toomas Soome <tsoome@me.com> +# Copyright 2017 Nexenta Systems, Inc. # include ../Makefile.master @@ -572,6 +572,10 @@ libsocket: libc libnsl basedeps: libc libm libmd libmp libnsl libnvpair libsocket basedeps := TARGET=install +# The following dependencies are currently required by libdbus-1 and should +# be used for anything linking against it. +dbusdeps: libsecdb libtsol libinetutil libscf libuutil libgen libsmbios + # The following dependencies don't need to be listed below as they are built # before everything else: # libc libm libmd libmp libnsl libnvpair libsocket @@ -586,6 +590,7 @@ gss_mechs/mech_dh: libgss gss_mechs/mech_dummy: libgss gss_mechs/mech_krb5: libgss libresolv2 pkcs11 libkstat gss_mechs/mech_spnego: gss_mechs/mech_krb5 +hal: dbusdeps krb5: gss_mechs/mech_krb5 libtecla libldap5 libadt_jni: libbsm libadutils: libldap5 libresolv2 @@ -695,7 +700,7 @@ nsswitch: libadutils libidmap libdns_sd libscf libldap5 libsldap \ pam_modules: libproject passwdutil smbsrv libtsnet libpam libbsm libsecdb passwdutil: libsldap pkcs11: libcryptoutil libgen libuuid -policykit: libsecdb +policykit: dbusdeps print: libldap5 libmd5 libsendfile pylibbe: libbe libzfs pysolaris: libsec libidmap diff --git a/usr/src/lib/libbe/common/be_mount.c b/usr/src/lib/libbe/common/be_mount.c index a081df62ed..98c861fca4 100644 --- a/usr/src/lib/libbe/common/be_mount.c +++ b/usr/src/lib/libbe/common/be_mount.c @@ -2697,9 +2697,12 @@ mount_zfs(zfs_handle_t *zhp, char *altroot) char mountpoint[MAXPATHLEN]; char real_mountpoint[MAXPATHLEN]; char source[MAXNAMELEN]; + char optstr[MAX_MNTOPT_STR]; zprop_source_t sourcetype; struct stat buf; + optstr[0] = '\0'; + /* Get dataset's mountpoint and source values */ if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mountpoint, sizeof (mountpoint), &sourcetype, source, sizeof (source), @@ -2738,8 +2741,8 @@ mount_zfs(zfs_handle_t *zhp, char *altroot) } } - if (mount(zfs_get_name(zhp), real_mountpoint, flags, MNTTYPE_ZFS, - NULL, 0, NULL, 0)) { + if (mount(zfs_get_name(zhp), real_mountpoint, MS_OPTIONSTR | flags, + MNTTYPE_ZFS, NULL, 0, optstr, sizeof (optstr))) { be_print_err(gettext("mount_zfs: failed to " "mount dataset %s at %s\n"), zfs_get_name(zhp), real_mountpoint); diff --git a/usr/src/lib/libzfs/common/libzfs_import.c b/usr/src/lib/libzfs/common/libzfs_import.c index b73a71e94c..3b6a6d468e 100644 --- a/usr/src/lib/libzfs/common/libzfs_import.c +++ b/usr/src/lib/libzfs/common/libzfs_import.c @@ -237,9 +237,12 @@ add_config(libzfs_handle_t *hdl, pool_list_t *pl, const char *path, free(ne); return (-1); } + ne->ne_guid = vdev_guid; ne->ne_next = pl->names; pl->names = ne; + + nvlist_free(config); return (0); } diff --git a/usr/src/man/man1m/zdb.1m b/usr/src/man/man1m/zdb.1m index ed74d510d0..eaa615a3fc 100644 --- a/usr/src/man/man1m/zdb.1m +++ b/usr/src/man/man1m/zdb.1m @@ -12,14 +12,15 @@ .\" .\" Copyright 2012, Richard Lowe. .\" Copyright (c) 2012, 2016 by Delphix. All rights reserved. +.\" Copyright 2016 Nexenta Systems, Inc. .\" -.TH "ZDB" "1M" "Feb 4, 2016" "" "" +.TH "ZDB" "1M" "April 9, 2016" .SH "NAME" \fBzdb\fR - Display zpool debugging and consistency information .SH "SYNOPSIS" -\fBzdb\fR [-CumdibcsDvhLMXFPAG] [-e [-p \fIpath\fR...]] [-t \fItxg\fR] +\fBzdb\fR [-CmdibcsDvhLMXFPAG] [-e [-p \fIpath\fR...]] [-t \fItxg\fR] [-U \fIcache\fR] [-I \fIinflight I/Os\fR] [-x \fIdumpdir\fR] [-o \fIvar\fR=\fIvalue\fR] ... [\fIpoolname\fR [\fIobject\fR ...]] @@ -39,7 +40,7 @@ \fBzdb\fR -S [-AP] [-e [-p \fIpath\fR...]] [-U \fIcache\fR] \fIpoolname\fR .P -\fBzdb\fR -l [-uA] \fIdevice\fR +\fBzdb\fR -l [-Aqu] \fIdevice\fR .P \fBzdb\fR -C [-A] [-U \fIcache\fR] @@ -176,8 +177,13 @@ transaction type. .ad .sp .6 .RS 4n -Display the vdev labels from the specified device. If the \fB-u\fR option is -also specified, also display the uberblocks on this device. +Read the vdev labels from the specified device. \fBzdb -l\fR will return 0 if +valid label was found, 1 if error occured, and 2 if no valid labels were found. +.P +If the \fB-u\fR option is also specified, also display the uberblocks on this +device. +.P +If the \fB-q\fR option is also specified, don't print the labels. .RE .sp diff --git a/usr/src/pkg/manifests/system-test-zfstest.mf b/usr/src/pkg/manifests/system-test-zfstest.mf index fc7bbb8235..0a6c645807 100644 --- a/usr/src/pkg/manifests/system-test-zfstest.mf +++ b/usr/src/pkg/manifests/system-test-zfstest.mf @@ -11,8 +11,8 @@ # # Copyright (c) 2012, 2016 by Delphix. All rights reserved. -# Copyright 2015 Nexenta Systems, Inc. All rights reserved. # Copyright 2016, OmniTI Computer Consulting, Inc. All rights reserved. +# Copyright 2016 Nexenta Systems, Inc. # set name=pkg.fmri value=pkg:/system/test/zfstest@$(PKGVERS) @@ -75,6 +75,7 @@ dir path=opt/zfs-tests/tests/functional/cli_root/zpool_get dir path=opt/zfs-tests/tests/functional/cli_root/zpool_history dir path=opt/zfs-tests/tests/functional/cli_root/zpool_import dir path=opt/zfs-tests/tests/functional/cli_root/zpool_import/blockfiles +dir path=opt/zfs-tests/tests/functional/cli_root/zpool_labelclear dir path=opt/zfs-tests/tests/functional/cli_root/zpool_offline dir path=opt/zfs-tests/tests/functional/cli_root/zpool_online dir path=opt/zfs-tests/tests/functional/cli_root/zpool_remove @@ -1296,6 +1297,15 @@ file \ file \ path=opt/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_rename_001_pos \ mode=0555 +file \ + path=opt/zfs-tests/tests/functional/cli_root/zpool_labelclear/labelclear.cfg \ + mode=0444 +file \ + path=opt/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active \ + mode=0555 +file \ + path=opt/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported \ + mode=0555 file path=opt/zfs-tests/tests/functional/cli_root/zpool_offline/cleanup \ mode=0555 file path=opt/zfs-tests/tests/functional/cli_root/zpool_offline/setup \ diff --git a/usr/src/test/zfs-tests/include/libtest.shlib b/usr/src/test/zfs-tests/include/libtest.shlib index 4c97362b71..3a3c1c466d 100644 --- a/usr/src/test/zfs-tests/include/libtest.shlib +++ b/usr/src/test/zfs-tests/include/libtest.shlib @@ -28,9 +28,6 @@ . ${STF_TOOLS}/contrib/include/logapi.shlib -ZFS=${ZFS:-/usr/sbin/zfs} -ZPOOL=${ZPOOL:-/usr/sbin/zpool} - # Determine whether a dataset is mounted # # $1 dataset name @@ -263,7 +260,7 @@ function create_bookmark snapexists $fs_vol@$snap || \ log_fail "$fs_vol@$snap must exist." - log_must $ZFS bookmark $fs_vol@$snap $fs_vol#$bkmark + log_must zfs bookmark $fs_vol@$snap $fs_vol#$bkmark } function default_mirror_setup @@ -558,7 +555,7 @@ function destroy_bookmark log_fail "'$bkmarkp' does not existed." fi - log_must $ZFS destroy $bkmark + log_must zfs destroy $bkmark } # Return 0 if a snapshot exists; $? otherwise @@ -578,7 +575,7 @@ function snapexists # function bkmarkexists { - $ZFS list -H -t bookmark "$1" > /dev/null 2>&1 + zfs list -H -t bookmark "$1" > /dev/null 2>&1 return $? } @@ -1585,136 +1582,6 @@ function cleanup_devices #vdevs return 0 } -# -# Verify the rsh connectivity to each remote host in RHOSTS. -# -# Return 0 if remote host is accessible; otherwise 1. -# $1 remote host name -# $2 username -# -function verify_rsh_connect #rhost, username -{ - typeset rhost=$1 - typeset username=$2 - typeset rsh_cmd="rsh -n" - typeset cur_user= - - getent hosts $rhost >/dev/null 2>&1 - if (($? != 0)); then - log_note "$rhost cannot be found from" \ - "administrative database." - return 1 - fi - - ping $rhost 3 >/dev/null 2>&1 - if (($? != 0)); then - log_note "$rhost is not reachable." - return 1 - fi - - if ((${#username} != 0)); then - rsh_cmd="$rsh_cmd -l $username" - cur_user="given user \"$username\"" - else - cur_user="current user \"`logname`\"" - fi - - if ! $rsh_cmd $rhost true; then - log_note "rsh to $rhost is not accessible" \ - "with $cur_user." - return 1 - fi - - return 0 -} - -# -# Verify the remote host connection via rsh after rebooting -# $1 remote host -# -function verify_remote -{ - rhost=$1 - - # - # The following loop waits for the remote system rebooting. - # Each iteration will wait for 150 seconds. there are - # total 5 iterations, so the total timeout value will - # be 12.5 minutes for the system rebooting. This number - # is an approxiate number. - # - typeset -i count=0 - while ! verify_rsh_connect $rhost; do - sleep 150 - ((count = count + 1)) - if ((count > 5)); then - return 1 - fi - done - return 0 -} - -# -# Replacement function for /usr/bin/rsh. This function will include -# the /usr/bin/rsh and meanwhile return the execution status of the -# last command. -# -# $1 usrname passing down to -l option of /usr/bin/rsh -# $2 remote machine hostname -# $3... command string -# - -function rsh_status -{ - typeset ruser=$1 - typeset rhost=$2 - typeset -i ret=0 - typeset cmd_str="" - typeset rsh_str="" - - shift; shift - cmd_str="$@" - - err_file=/tmp/${rhost}.$$.err - if ((${#ruser} == 0)); then - rsh_str="rsh -n" - else - rsh_str="rsh -n -l $ruser" - fi - - $rsh_str $rhost /usr/bin/ksh -c "'$cmd_str; \ - print -u 2 \"status=\$?\"'" \ - >/dev/null 2>$err_file - ret=$? - if (($ret != 0)); then - cat $err_file - rm -f $std_file $err_file - log_fail "rsh itself failed with exit code $ret..." - fi - - ret=$(grep -v 'print -u 2' $err_file | grep 'status=' | \ - cut -d= -f2) - (($ret != 0)) && cat $err_file >&2 - - rm -f $err_file >/dev/null 2>&1 - return $ret -} - -# -# Get the SUNWstc-fs-zfs package installation path in a remote host -# $1 remote host name -# -function get_remote_pkgpath -{ - typeset rhost=$1 - typeset pkgpath="" - - pkgpath=$(rsh -n $rhost "pkginfo -l SUNWstc-fs-zfs | grep BASEDIR: |\ - cut -d: -f2") - - echo $pkgpath -} - #/** # A function to find and locate free disks on a system or from given # disks as the parameter. It works by locating disks that are in use diff --git a/usr/src/test/zfs-tests/runfiles/delphix.run b/usr/src/test/zfs-tests/runfiles/delphix.run index 3067f09138..5f6972b6fb 100644 --- a/usr/src/test/zfs-tests/runfiles/delphix.run +++ b/usr/src/test/zfs-tests/runfiles/delphix.run @@ -272,6 +272,11 @@ tests = ['zpool_import_001_pos', 'zpool_import_002_pos', 'zpool_import_missing_002_pos', 'zpool_import_missing_003_pos', 'zpool_import_rename_001_pos'] +[/opt/zfs-tests/tests/functional/cli_root/zpool_labelclear] +tests = ['zpool_labelclear_active', 'zpool_labelclear_exported'] +pre = +post = + [/opt/zfs-tests/tests/functional/cli_root/zpool_offline] tests = ['zpool_offline_001_pos', 'zpool_offline_002_neg'] diff --git a/usr/src/test/zfs-tests/runfiles/omnios.run b/usr/src/test/zfs-tests/runfiles/omnios.run index 4f8f0d7787..3696f98b63 100644 --- a/usr/src/test/zfs-tests/runfiles/omnios.run +++ b/usr/src/test/zfs-tests/runfiles/omnios.run @@ -269,6 +269,11 @@ tests = ['zpool_import_001_pos', 'zpool_import_002_pos', 'zpool_import_missing_002_pos', 'zpool_import_missing_003_pos', 'zpool_import_rename_001_pos'] +[/opt/zfs-tests/tests/functional/cli_root/zpool_labelclear] +tests = ['zpool_labelclear_active', 'zpool_labelclear_exported'] +pre = +post = + [/opt/zfs-tests/tests/functional/cli_root/zpool_offline] tests = ['zpool_offline_001_pos', 'zpool_offline_002_neg'] diff --git a/usr/src/test/zfs-tests/runfiles/openindiana.run b/usr/src/test/zfs-tests/runfiles/openindiana.run index 4e6ac6d29d..9377e702e8 100644 --- a/usr/src/test/zfs-tests/runfiles/openindiana.run +++ b/usr/src/test/zfs-tests/runfiles/openindiana.run @@ -269,6 +269,11 @@ tests = ['zpool_import_001_pos', 'zpool_import_002_pos', 'zpool_import_missing_002_pos', 'zpool_import_missing_003_pos', 'zpool_import_rename_001_pos'] +[/opt/zfs-tests/tests/functional/cli_root/zpool_labelclear] +tests = ['zpool_labelclear_active', 'zpool_labelclear_exported'] +pre = +post = + [/opt/zfs-tests/tests/functional/cli_root/zpool_offline] tests = ['zpool_offline_001_pos', 'zpool_offline_002_neg'] diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zdb/zdb_001_neg.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zdb/zdb_001_neg.ksh index 8205ec3104..9776447097 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zdb/zdb_001_neg.ksh +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zdb/zdb_001_neg.ksh @@ -56,8 +56,8 @@ set -A args "create" "add" "destroy" "import fakepool" \ "add mirror fakepool" "add raidz fakepool" \ "add raidz1 fakepool" "add raidz2 fakepool" \ "setvprop" "blah blah" "-%" "--?" "-*" "-=" \ - "-a" "-f" "-g" "-h" "-j" "-k" "-m" "-n" "-o" "-p" "-p /tmp" \ - "-q" "-r" "-t" "-w" "-x" "-y" "-z" \ + "-a" "-f" "-g" "-h" "-j" "-k" "-m" "-n" "-o" "-p" \ + "-p /tmp" "-r" "-t" "-w" "-x" "-y" "-z" \ "-D" "-E" "-G" "-H" "-I" "-J" "-K" "-M" \ "-N" "-Q" "-R" "-S" "-T" "-V" "-W" "-Y" "-Z" diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh index d12b1dc9a5..45f44be179 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh @@ -142,11 +142,11 @@ i=0 while ((i < ${#bookmark[@]})); do for opt in "${options[@]}"; do for prop in ${bookmark_props[@]}; do - eval "$ZFS get $opt $prop ${bookmark[i]} > \ + eval "zfs get $opt $prop ${bookmark[i]} > \ $TESTDIR/$TESTFILE0" ret=$? if [[ $ret != 0 ]]; then - log_fail "$ZFS get returned: $ret" + log_fail "zfs get returned: $ret" fi check_return_value ${bookmark[i]} "$prop" "$opt" done diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_005_neg.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_005_neg.ksh index 0d70fba54e..0341d4dc2d 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_005_neg.ksh +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_005_neg.ksh @@ -112,10 +112,10 @@ function test_options_bookmarks for dst in ${bookmark[@]}; do for opt in $opts; do for prop in $props; do - $ZFS get $opt -- $prop $dst > /dev/null 2>&1 + zfs get $opt -- $prop $dst > /dev/null 2>&1 ret=$? if [[ $ret == 0 ]]; then - log_fail "$ZFS get $opt -- $prop " \ + log_fail "zfs get $opt -- $prop " \ "$dst unexpectedly succeeded." fi done diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_008_pos.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_008_pos.ksh index b81a974370..800d7ac5bd 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_008_pos.ksh +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_008_pos.ksh @@ -103,7 +103,7 @@ for dst in ${bookmark[@]}; do while (( i < opt_numb )); do (( item = $RANDOM % ${#options[@]} )) (( depth_item = $RANDOM % ${#depth_options[@]} )) - log_must eval "$ZFS get -${depth_options[depth_item]} ${options[item]} $bookmark_props $dst > /dev/null 2>&1" + log_must eval "zfs get -${depth_options[depth_item]} ${options[item]} $bookmark_props $dst > /dev/null 2>&1" (( i += 1 )) done done diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib index f08ae1abdd..15921201c7 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib @@ -122,7 +122,7 @@ function setup_snap_env # before taking a snapshot. # if [[ $dtst == $VOL ]]; then - log_must /usr/sbin/lockfs -f $TESTDIR1 + log_must lockfs -f $TESTDIR1 fi log_must zfs snapshot $snap fi diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/Makefile b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/Makefile new file mode 100644 index 0000000000..dc62d6f3bb --- /dev/null +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/Makefile @@ -0,0 +1,21 @@ +# +# 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 2016 Nexenta Systems, Inc. +# + +include $(SRC)/Makefile.master + +ROOTOPTPKG= $(ROOT)/opt/zfs-tests +TARGETDIR= $(ROOTOPTPKG)/tests/functional/cli_root/zpool_labelclear + +include $(SRC)/test/zfs-tests/Makefile.com diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/labelclear.cfg b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/labelclear.cfg new file mode 100644 index 0000000000..6ae5395635 --- /dev/null +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/labelclear.cfg @@ -0,0 +1,26 @@ +#! /usr/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 2016 Nexenta Systems, Inc. +# + +. $STF_SUITE/include/libtest.shlib + +typeset LABELCLEAR="zpool labelclear" +typeset LABELREAD="zdb -lq" + +typeset disks=(${DISKS[*]}) +typeset disk1=${disks[0]} +typeset disk2=${disks[1]} +typeset disk3=${disks[2]} diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active.ksh new file mode 100644 index 0000000000..a29c09095f --- /dev/null +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_active.ksh @@ -0,0 +1,68 @@ +#! /usr/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 2016 Nexenta Systems, Inc. +# + +. $STF_SUITE/tests/functional/cli_root/zpool_labelclear/labelclear.cfg + +# DESCRIPTION: +# Check that zpool labelclear will refuse to clear the label +# (with or without -f) on any vdevs of the imported pool. +# +# STRATEGY: +# 1. Create the pool with log device. +# 2. Try clearing the label on data and log devices. +# 3. Add auxilary (cache/spare) vdevs. +# 4. Try clearing the label on auxilary vdevs. +# 5. Check that zpool labelclear will return non-zero and +# labels are intact. + +verify_runnable "global" + +function cleanup +{ + poolexists $TESTPOOL && destroy_pool $TESTPOOL +} + +log_onexit cleanup +log_assert "zpool labelclear will fail on all vdevs of imported pool" + +# Create simple pool, skip any mounts +log_must zpool create -O mountpoint=none -f $TESTPOOL $disk1 log $disk2 + +# Check that labelclear [-f] will fail on ACTIVE pool vdevs +log_mustnot $LABELCLEAR $disk1 +log_must $LABELREAD $disk1 +log_mustnot $LABELCLEAR -f $disk1 +log_must $LABELREAD $disk1 +log_mustnot $LABELCLEAR $disk2 +log_must $LABELREAD $disk2 +log_mustnot $LABELCLEAR -f $disk2 +log_must $LABELREAD $disk2 + +# Add a cache/spare to the pool, check that labelclear [-f] will fail +# on the vdev and will succeed once it's removed from pool config +for vdevtype in "cache" "spare"; do + log_must zpool add $TESTPOOL $vdevtype $disk3 + log_mustnot $LABELCLEAR $disk3 + log_must $LABELREAD $disk3 + log_mustnot $LABELCLEAR -f $disk3 + log_must $LABELREAD $disk3 + log_must zpool remove $TESTPOOL $disk3 + log_must $LABELCLEAR $disk3 + log_mustnot $LABELREAD $disk3 +done + +log_pass "zpool labelclear will fail on all vdevs of imported pool" diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported.ksh new file mode 100644 index 0000000000..82df8216eb --- /dev/null +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_labelclear/zpool_labelclear_exported.ksh @@ -0,0 +1,74 @@ +#! /usr/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 2016 Nexenta Systems, Inc. +# + +. $STF_SUITE/tests/functional/cli_root/zpool_labelclear/labelclear.cfg + +# DESCRIPTION: +# Check that zpool labelclear will refuse to clear the label +# on ACTIVE vdevs of exported pool without -f, and will succeeded with -f. +# +# STRATEGY: +# 1. Create a pool with log device. +# 2. Export the pool. +# 3. Check that zpool labelclear returns non-zero when trying to +# clear the label on ACTIVE vdevs, and succeeds with -f. +# 4. Add auxilary vdevs (cache/spare). +# 5. Check that zpool labelclear succeeds on auxilary vdevs of +# exported pool. + +verify_runnable "global" + +function cleanup +{ + poolexists $TESTPOOL && destroy_pool $TESTPOOL +} + +log_onexit cleanup +log_assert "zpool labelclear will fail on ACTIVE vdevs of exported pool and" \ + "succeed with -f" + +for vdevtype in "" "cache" "spare"; do + # Create simple pool, skip any mounts + log_must zpool create -O mountpoint=none -f $TESTPOOL $disk1 log $disk2 + # Add auxilary vdevs (cache/spare) + if [[ -n $vdevtype ]]; then + log_must zpool add $TESTPOOL $vdevtype $disk3 + fi + # Export the pool + log_must zpool export $TESTPOOL + + # Check that labelclear will fail without -f + log_mustnot $LABELCLEAR $disk1 + log_must $LABELREAD $disk1 + log_mustnot $LABELCLEAR $disk2 + log_must $LABELREAD $disk2 + + # Check that labelclear will succeed with -f + log_must $LABELCLEAR -f $disk1 + log_mustnot $LABELREAD $disk1 + log_must $LABELCLEAR -f $disk2 + log_mustnot $LABELREAD $disk2 + + # Check that labelclear on auxilary vdevs will succeed + if [[ -n $vdevtype ]]; then + log_must $LABELCLEAR $disk3 + log_mustnot $LABELREAD $disk3 + fi +done + +log_pass "zpool labelclear will fail on ACTIVE vdevs of exported pool and" \ + "succeed with -f" diff --git a/usr/src/test/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib b/usr/src/test/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib index 4957b8ea92..485e591dc0 100644 --- a/usr/src/test/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib +++ b/usr/src/test/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib @@ -57,11 +57,11 @@ do (( i = i + 1 )) done -\sleep 1 +sleep 1 for pid in \$PIDS do - \wait \$pid + wait \$pid (( \$? == 127 )) && exit 1 done exit 0 |
