From 1747d793b5742aae99af6a1caf438bbb5e76b892 Mon Sep 17 00:00:00 2001 From: delphij Date: Tue, 29 Jul 2014 08:42:22 +0000 Subject: MFV r269223: Change dn->dn_dbufs from linked list to AVL tree. Illumos issues: 4873 zvol unmap calls can take a very long time for larger datasets MFC after: 2 weeks --- cddl/contrib/opensolaris/common/avl/avl.c | 39 +++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/common/avl/avl.c b/cddl/contrib/opensolaris/common/avl/avl.c index dd39c12..4223da4 100644 --- a/cddl/contrib/opensolaris/common/avl/avl.c +++ b/cddl/contrib/opensolaris/common/avl/avl.c @@ -24,6 +24,10 @@ */ /* + * Copyright (c) 2014 by Delphix. All rights reserved. + */ + +/* * AVL - generic AVL tree implementation for kernel use * * A complete description of AVL trees can be found in many CS textbooks. @@ -37,7 +41,7 @@ * insertion and deletion relatively efficiently. Searching the tree is * still a fast operation, roughly O(log(N)). * - * The key to insertion and deletion is a set of tree maniuplations called + * The key to insertion and deletion is a set of tree manipulations called * rotations, which bring unbalanced subtrees back into the semi-balanced state. * * This implementation of AVL trees has the following peculiarities: @@ -45,7 +49,7 @@ * - The AVL specific data structures are physically embedded as fields * in the "using" data structures. To maintain generality the code * must constantly translate between "avl_node_t *" and containing - * data structure "void *"s by adding/subracting the avl_offset. + * data structure "void *"s by adding/subtracting the avl_offset. * * - Since the AVL data is always embedded in other structures, there is * no locking or memory allocation in the AVL routines. This must be @@ -85,6 +89,12 @@ * is a modified "avl_node_t *". The bottom bit (normally 0 for a * pointer) is set to indicate if that the new node has a value greater * than the value of the indicated "avl_node_t *". + * + * Note - in addition to userland (e.g. libavl and libutil) and the kernel + * (e.g. genunix), avl.c is compiled into ld.so and kmdb's genunix module, + * which each have their own compilation environments and subsequent + * requirements. Each of these environments must be considered when adding + * dependencies from avl.c. */ #include @@ -94,7 +104,7 @@ #include /* - * Small arrays to translate between balance (or diff) values and child indeces. + * Small arrays to translate between balance (or diff) values and child indices. * * Code that deals with binary tree data structures will randomly use * left and right children when examining a tree. C "if()" statements @@ -114,7 +124,8 @@ static const int avl_balance2child[] = {0, 0, 1}; * * - If there is a left child, go to it, then to it's rightmost descendant. * - * - otherwise we return thru parent nodes until we've come from a right child. + * - otherwise we return through parent nodes until we've come from a right + * child. * * Return Value: * NULL - if at the end of the nodes @@ -863,6 +874,24 @@ avl_update(avl_tree_t *t, void *obj) return (B_FALSE); } +void +avl_swap(avl_tree_t *tree1, avl_tree_t *tree2) +{ + avl_node_t *temp_node; + ulong_t temp_numnodes; + + ASSERT3P(tree1->avl_compar, ==, tree2->avl_compar); + ASSERT3U(tree1->avl_offset, ==, tree2->avl_offset); + ASSERT3U(tree1->avl_size, ==, tree2->avl_size); + + temp_node = tree1->avl_root; + temp_numnodes = tree1->avl_numnodes; + tree1->avl_root = tree2->avl_root; + tree1->avl_numnodes = tree2->avl_numnodes; + tree2->avl_root = temp_node; + tree2->avl_numnodes = temp_numnodes; +} + /* * initialize a new AVL tree */ @@ -919,7 +948,7 @@ avl_is_empty(avl_tree_t *tree) /* * Post-order tree walk used to visit all tree nodes and destroy the tree - * in post order. This is used for destroying a tree w/o paying any cost + * in post order. This is used for destroying a tree without paying any cost * for rebalancing it. * * example: -- cgit v1.1 From 37b25c29bfd52a1cdd190bd39514786ebc8da152 Mon Sep 17 00:00:00 2001 From: gnn Date: Thu, 31 Jul 2014 23:19:01 +0000 Subject: Update shellsnoop to work on FreeBSD. Contributed by: skreuzer --- cddl/contrib/dtracetoolkit/Apps/shellsnoop | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/dtracetoolkit/Apps/shellsnoop b/cddl/contrib/dtracetoolkit/Apps/shellsnoop index 95f42c0..69ff379 100755 --- a/cddl/contrib/dtracetoolkit/Apps/shellsnoop +++ b/cddl/contrib/dtracetoolkit/Apps/shellsnoop @@ -1,4 +1,4 @@ -#!/usr/bin/sh +#!/bin/sh # # shellsnoop - A program to print read/write details from shells, # such as keystrokes and command outputs. @@ -140,18 +140,14 @@ dtrace -n ' /* * Remember this PID is a shell child */ - syscall::exec:entry, syscall::exece:entry + syscall::execve:entry /execname == "sh" || execname == "ksh" || execname == "csh" || execname == "tcsh" || execname == "zsh" || execname == "bash"/ { child[pid] = 1; - /* debug */ - this->parent = (char *)curthread->t_procp->p_parent->p_user.u_comm; - OPT_debug == 1 ? printf("PID %d CMD %s started. (%s)\n", - pid, execname, stringof(this->parent)) : 1; } - syscall::exec:entry, syscall::exece:entry + syscall::execve:entry /(OPT_pid == 1 && PID != ppid) || (OPT_uid == 1 && UID != uid)/ { /* forget if filtered */ @@ -256,12 +252,12 @@ dtrace -n ' /* * Cleanup */ - syscall::rexit:entry + syscall::exit:entry { child[pid] = 0; /* debug */ - this->parent = (char *)curthread->t_procp->p_parent->p_user.u_comm; + this->parent = (char *)curthread->td_proc->p_pptr->p_comm; OPT_debug == 1 ? printf("PID %d CMD %s exited. (%s)\n", pid, execname, stringof(this->parent)) : 1; } -- cgit v1.1 From ca4ba484c17369a26e4d5ae216e4d95bda9a8997 Mon Sep 17 00:00:00 2001 From: delphij Date: Sat, 2 Aug 2014 07:47:52 +0000 Subject: MFV r269426: Double test device size for ztest(1). Illumos issue: 5039 ztest should default to larger device sizes Author: Matthew Ahrens MFC after: 2 weeks --- cddl/contrib/opensolaris/cmd/ztest/ztest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/ztest/ztest.c b/cddl/contrib/opensolaris/cmd/ztest/ztest.c index 3327161..5ed87ce 100644 --- a/cddl/contrib/opensolaris/cmd/ztest/ztest.c +++ b/cddl/contrib/opensolaris/cmd/ztest/ztest.c @@ -172,7 +172,7 @@ static const ztest_shared_opts_t ztest_opts_defaults = { .zo_mirrors = 2, .zo_raidz = 4, .zo_raidz_parity = 1, - .zo_vdev_size = SPA_MINDEVSIZE, + .zo_vdev_size = SPA_MINDEVSIZE * 2, .zo_datasets = 7, .zo_threads = 23, .zo_passtime = 60, /* 60 seconds */ -- cgit v1.1 From 99b1d997d7c2bea95649a6e3f27953035684bd24 Mon Sep 17 00:00:00 2001 From: markj Date: Mon, 4 Aug 2014 18:52:26 +0000 Subject: Preserve the errno value of an ioctl before calling free(3). Previously, errno was very occasionally being clobbered, resulting in a bogus error from dt_consume() and thus an error from dtrace(1). MFC after: 2 weeks --- cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c | 11 ++++++----- cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c | 5 +++-- cddl/contrib/opensolaris/lib/libdtrace/common/dt_work.c | 9 +++++---- 3 files changed, 14 insertions(+), 11 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c index ae1ed00..072cb05 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c @@ -2944,7 +2944,7 @@ dt_get_buf(dtrace_hdl_t *dtp, int cpu, dtrace_bufdesc_t **bufp) { dtrace_optval_t size; dtrace_bufdesc_t *buf = dt_zalloc(dtp, sizeof (*buf)); - int error; + int error, rval; if (buf == NULL) return (-1); @@ -2963,7 +2963,6 @@ dt_get_buf(dtrace_hdl_t *dtp, int cpu, dtrace_bufdesc_t **bufp) #else if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, &buf) == -1) { #endif - dt_put_buf(dtp, buf); /* * If we failed with ENOENT, it may be because the * CPU was unconfigured -- this is okay. Any other @@ -2971,10 +2970,12 @@ dt_get_buf(dtrace_hdl_t *dtp, int cpu, dtrace_bufdesc_t **bufp) */ if (errno == ENOENT) { *bufp = NULL; - return (0); - } + rval = 0; + } else + rval = dt_set_errno(dtp, errno); - return (dt_set_errno(dtp, errno)); + dt_put_buf(dtp, buf); + return (rval); } error = dt_unring_buf(dtp, buf); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c index c6d92c8..6ab7cd9 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c @@ -39,7 +39,7 @@ static int dt_strdata_add(dtrace_hdl_t *dtp, dtrace_recdesc_t *rec, void ***data, int *max) { - int maxformat; + int maxformat, rval; dtrace_fmtdesc_t fmt; void *result; @@ -63,8 +63,9 @@ dt_strdata_add(dtrace_hdl_t *dtp, dtrace_recdesc_t *rec, void ***data, int *max) return (dt_set_errno(dtp, EDT_NOMEM)); if (dt_ioctl(dtp, DTRACEIOC_FORMAT, &fmt) == -1) { + rval = dt_set_errno(dtp, errno); free(fmt.dtfd_string); - return (dt_set_errno(dtp, errno)); + return (rval); } while (rec->dtrd_format > (maxformat = *max)) { diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_work.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_work.c index 68e64bb..d19fb88 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_work.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_work.c @@ -184,7 +184,7 @@ dtrace_go(dtrace_hdl_t *dtp) { dtrace_enable_io_t args; void *dof; - int err; + int error, r; if (dtp->dt_active) return (dt_set_errno(dtp, EINVAL)); @@ -206,11 +206,12 @@ dtrace_go(dtrace_hdl_t *dtp) args.dof = dof; args.n_matched = 0; - err = dt_ioctl(dtp, DTRACEIOC_ENABLE, &args); + r = dt_ioctl(dtp, DTRACEIOC_ENABLE, &args); + error = errno; dtrace_dof_destroy(dtp, dof); - if (err == -1 && (errno != ENOTTY || dtp->dt_vector == NULL)) - return (dt_set_errno(dtp, errno)); + if (r == -1 && (error != ENOTTY || dtp->dt_vector == NULL)) + return (dt_set_errno(dtp, error)); if (dt_ioctl(dtp, DTRACEIOC_GO, &dtp->dt_beganon) == -1) { if (errno == EACCES) -- cgit v1.1 From fc46ec7e361751a16ece4de656d289c08e1d27a5 Mon Sep 17 00:00:00 2001 From: sbruno Date: Fri, 8 Aug 2014 18:00:23 +0000 Subject: Quiesce a printf warning from clang, %ul -> %lu Phabric: https://phabric.freebsd.org/D472 Reviewed by: mahrens delphij --- cddl/contrib/opensolaris/lib/libzpool/common/kernel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c b/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c index c61c5c2..1a2c2ac 100644 --- a/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c +++ b/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c @@ -687,7 +687,7 @@ __dprintf(const char *file, const char *func, int line, const char *fmt, ...) if (dprintf_find_string("pid")) (void) printf("%d ", getpid()); if (dprintf_find_string("tid")) - (void) printf("%ul ", thr_self()); + (void) printf("%lu ", thr_self()); #if 0 if (dprintf_find_string("cpu")) (void) printf("%u ", getcpuid()); -- cgit v1.1 From 18059e8e63641d7d915ef4dddc33c240ec212729 Mon Sep 17 00:00:00 2001 From: rpaulo Date: Sun, 10 Aug 2014 06:56:43 +0000 Subject: Remove the BROKEN_LIBELF section. This problem was fixed by Kai Wang in 2011. MFC after: 3 days --- .../opensolaris/lib/libdtrace/common/dt_link.c | 52 ---------------------- 1 file changed, 52 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c index 2a43211..13300b0 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c @@ -1895,7 +1895,6 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, goto done; } #if !defined(sun) -#define BROKEN_LIBELF /* * FreeBSD's ld(1) is not instructed to interpret and add * correctly the SUNW_dof section present in tfile. @@ -1919,9 +1918,6 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, /* * Add the string '.SUWN_dof' to the shstrtab section. */ -#ifdef BROKEN_LIBELF - elf_flagelf(e, ELF_C_SET, ELF_F_LAYOUT); -#endif elf_getshdrstrndx(e, &stridx); scn = elf_getscn(e, stridx); gelf_getshdr(scn, &shdr); @@ -1933,54 +1929,6 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, loc = shdr.sh_size; shdr.sh_size += data->d_size; gelf_update_shdr(scn, &shdr); -#ifdef BROKEN_LIBELF - off = shdr.sh_offset; - rc = shdr.sh_offset + shdr.sh_size; - gelf_getehdr(e, &ehdr); - if (ehdr.e_shoff > off) { - off = ehdr.e_shoff + ehdr.e_shnum * ehdr.e_shentsize; - rc = roundup(rc, 8); - ehdr.e_shoff = rc; - gelf_update_ehdr(e, &ehdr); - rc += ehdr.e_shnum * ehdr.e_shentsize; - } - for (;;) { - scn0 = NULL; - scn = NULL; - while ((scn = elf_nextscn(e, scn)) != NULL) { - gelf_getshdr(scn, &shdr); - if (shdr.sh_type == SHT_NOBITS || - shdr.sh_offset < off) - continue; - /* Find the immediately adjcent section. */ - if (scn0 == NULL || - shdr.sh_offset < shdr0.sh_offset) { - scn0 = scn; - gelf_getshdr(scn0, &shdr0); - } - } - if (scn0 == NULL) - break; - /* Load section data to work around another bug */ - elf_getdata(scn0, NULL); - /* Update section header, assure section alignment */ - off = shdr0.sh_offset + shdr0.sh_size; - rc = roundup(rc, shdr0.sh_addralign); - shdr0.sh_offset = rc; - gelf_update_shdr(scn0, &shdr0); - rc += shdr0.sh_size; - } - if (elf_update(e, ELF_C_WRITE) < 0) { - ret = dt_link_error(dtp, NULL, -1, NULL, - "failed to add append the shstrtab section: %s", - elf_errmsg(elf_errno())); - elf_end(e); - close(efd); - goto done; - } - elf_end(e); - e = elf_begin(efd, ELF_C_RDWR, NULL); -#endif /* * Construct the .SUNW_dof section. */ -- cgit v1.1 From a407cae160e9e635d915a6c35df42361d2cea6ec Mon Sep 17 00:00:00 2001 From: delphij Date: Thu, 21 Aug 2014 22:53:14 +0000 Subject: Include two headers to provide prototype for modfind(2) and kldload(2). MFC after: 2 weeks --- cddl/contrib/opensolaris/cmd/lockstat/sym.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/lockstat/sym.c b/cddl/contrib/opensolaris/cmd/lockstat/sym.c index 1aa77ad..5940c93 100644 --- a/cddl/contrib/opensolaris/cmd/lockstat/sym.c +++ b/cddl/contrib/opensolaris/cmd/lockstat/sym.c @@ -50,6 +50,9 @@ /* FreeBSD */ #include #include +#include +#include +#include #endif #include -- cgit v1.1 From 746cb605d6fcbc1f45b38cb0471dbfab2e3c16a7 Mon Sep 17 00:00:00 2001 From: delphij Date: Fri, 22 Aug 2014 01:23:38 +0000 Subject: Fix powerpc build: Chase r270227 and compile lockstat with C99 standard. Suggested by: bde --- cddl/usr.sbin/lockstat/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'cddl') diff --git a/cddl/usr.sbin/lockstat/Makefile b/cddl/usr.sbin/lockstat/Makefile index 0668758..499b23d 100644 --- a/cddl/usr.sbin/lockstat/Makefile +++ b/cddl/usr.sbin/lockstat/Makefile @@ -18,6 +18,7 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \ -I${.CURDIR}/../../../sys CFLAGS+= -DNEED_ERRLOC -g +CSTD?= gnu99 #YFLAGS+= -d -- cgit v1.1 From b684263996bac87616c81145b204e1e34cd88dea Mon Sep 17 00:00:00 2001 From: delphij Date: Fri, 22 Aug 2014 20:04:51 +0000 Subject: Make DTrace stuff compile with C99 standard. --- cddl/Makefile.inc | 1 - cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h | 5 +++++ cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c | 5 +++++ cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c | 1 + cddl/contrib/opensolaris/lib/libgen/common/gmatch.c | 1 + cddl/lib/libdtrace/libproc_compat.h | 1 + cddl/usr.sbin/lockstat/Makefile | 1 - 7 files changed, 13 insertions(+), 2 deletions(-) (limited to 'cddl') diff --git a/cddl/Makefile.inc b/cddl/Makefile.inc index 9ebb86b..94a4249 100644 --- a/cddl/Makefile.inc +++ b/cddl/Makefile.inc @@ -8,7 +8,6 @@ IGNORE_PRAGMA= YES CFLAGS+= -DNEED_SOLARIS_BOOLEAN WARNS?= 6 -CSTD?= gnu89 # Do not lint the CDDL stuff. It is all externally maintained and # lint output is wasteful noise here. diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h index b7abbc2..8cf5fe2 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h @@ -723,6 +723,11 @@ extern int _dtrace_argmax; /* default maximum probe arguments */ extern const char *_dtrace_libdir; /* default library directory */ extern const char *_dtrace_moddir; /* default kernel module directory */ +#ifdef __FreeBSD__ +extern int gmatch(const char *, const char *); +extern int yylex(void); +#endif + #ifdef __cplusplus } #endif diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c index f6c140b..0eb2a2c 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c @@ -29,6 +29,11 @@ #if defined(sun) #include #include +#else +/* FreeBSD */ +#include +#include +#include #endif #include diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c index 760c2f6..7f49f64 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c @@ -36,6 +36,7 @@ #include #include +#include #include #include diff --git a/cddl/contrib/opensolaris/lib/libgen/common/gmatch.c b/cddl/contrib/opensolaris/lib/libgen/common/gmatch.c index fe4a382..199fbb3 100644 --- a/cddl/contrib/opensolaris/lib/libgen/common/gmatch.c +++ b/cddl/contrib/opensolaris/lib/libgen/common/gmatch.c @@ -42,6 +42,7 @@ #include #include "_range.h" #else +#include /* DOODAD */ static int multibyte = 0; #define WCHAR_CSMASK 0x30000000 #define valid_range(c1, c2) \ diff --git a/cddl/lib/libdtrace/libproc_compat.h b/cddl/lib/libdtrace/libproc_compat.h index 7e54ada..8443336 100644 --- a/cddl/lib/libdtrace/libproc_compat.h +++ b/cddl/lib/libdtrace/libproc_compat.h @@ -43,6 +43,7 @@ #define Pcreate_error strerror #define Pdelbkpt proc_bkptdel #define Pgrab_error strerror +#define Plmid(p, a, l) (-1) #define Plmid_to_map(p, l, o) proc_obj2map((p), (o)) #define Plookup_by_addr proc_addr2sym #define Pname_to_ctf(p, obj) NULL diff --git a/cddl/usr.sbin/lockstat/Makefile b/cddl/usr.sbin/lockstat/Makefile index 499b23d..0668758 100644 --- a/cddl/usr.sbin/lockstat/Makefile +++ b/cddl/usr.sbin/lockstat/Makefile @@ -18,7 +18,6 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \ -I${.CURDIR}/../../../sys CFLAGS+= -DNEED_ERRLOC -g -CSTD?= gnu99 #YFLAGS+= -d -- cgit v1.1 From 626a49e1d6e2322242208e872046c6f5d7b742b4 Mon Sep 17 00:00:00 2001 From: delphij Date: Fri, 22 Aug 2014 22:13:36 +0000 Subject: MFV r270197: Illumos issue: 5066 remove support for non-ANSI compilation 5068 Remove SCCSID() macro from MFC after: 2 weeks --- cddl/contrib/opensolaris/head/libintl.h | 32 ++--------------- cddl/contrib/opensolaris/head/nlist.h | 9 ++--- cddl/contrib/opensolaris/head/synch.h | 61 +-------------------------------- cddl/contrib/opensolaris/head/thread.h | 4 +-- 4 files changed, 8 insertions(+), 98 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/head/libintl.h b/cddl/contrib/opensolaris/head/libintl.h index e649668..262fa89 100644 --- a/cddl/contrib/opensolaris/head/libintl.h +++ b/cddl/contrib/opensolaris/head/libintl.h @@ -19,6 +19,8 @@ * CDDL HEADER END */ /* + * Copyright 2014 Garrett D'Amore + * * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -27,8 +29,6 @@ #ifndef _LIBINTL_H #define _LIBINTL_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include #ifdef __cplusplus @@ -64,7 +64,6 @@ typedef long wchar_t; #define __GNU_GETTEXT_SUPPORTED_REVISION(m) \ ((((m) == 0) || ((m) == 1)) ? 1 : -1) -#ifdef __STDC__ extern char *dcgettext(const char *, const char *, const int); extern char *dgettext(const char *, const char *); extern char *gettext(const char *); @@ -91,33 +90,6 @@ extern wchar_t *wddelim(wchar_t, wchar_t, int); extern wchar_t mcfiller(void); extern int mcwrap(void); -#else -extern char *dcgettext(); -extern char *dgettext(); -extern char *gettext(); -extern char *textdomain(); -extern char *bindtextdomain(); - -/* - * LI18NUX 2000 Globalization Specification Version 1.0 - * with Amendment 2 - */ -extern char *dcngettext(); -extern char *dngettext(); -extern char *ngettext(); -extern char *bind_textdomain_codeset(); - -/* Word handling functions --- requires dynamic linking */ -/* Warning: these are experimental and subject to change. */ -extern int wdinit(); -extern int wdchkind(); -extern int wdbindf(); -extern wchar_t *wddelim(); -extern wchar_t mcfiller(); -extern int mcwrap(); - -#endif - #ifdef __cplusplus } #endif diff --git a/cddl/contrib/opensolaris/head/nlist.h b/cddl/contrib/opensolaris/head/nlist.h index ea1bd203..de6be5e 100644 --- a/cddl/contrib/opensolaris/head/nlist.h +++ b/cddl/contrib/opensolaris/head/nlist.h @@ -19,6 +19,9 @@ * * CDDL HEADER END */ +/* + * Copyright 2014 Garrett D'Amore + */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ @@ -26,8 +29,6 @@ #ifndef _NLIST_H #define _NLIST_H -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.8.2.4 */ - #ifdef __cplusplus extern "C" { #endif @@ -41,11 +42,7 @@ struct nlist { char n_numaux; /* number of aux. entries */ }; -#if defined(__STDC__) extern int nlist(const char *, struct nlist *); -#else /* __STDC__ */ -extern int nlist(); -#endif /* __STDC__ */ #ifdef __cplusplus } diff --git a/cddl/contrib/opensolaris/head/synch.h b/cddl/contrib/opensolaris/head/synch.h index 89efe9c..c0f68f1 100644 --- a/cddl/contrib/opensolaris/head/synch.h +++ b/cddl/contrib/opensolaris/head/synch.h @@ -20,6 +20,7 @@ */ /* + * Copyright 2014 Garrett D'Amore * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -86,7 +87,6 @@ typedef struct _rwlock { cond_t writercv; /* used only to indicate ownership */ } rwlock_t; -#ifdef __STDC__ int _lwp_mutex_lock(lwp_mutex_t *); int _lwp_mutex_unlock(lwp_mutex_t *); int _lwp_mutex_trylock(lwp_mutex_t *); @@ -127,50 +127,6 @@ int sema_reltimedwait(sema_t *, const timespec_t *); int sema_post(sema_t *); int sema_trywait(sema_t *); -#else /* __STDC__ */ - -int _lwp_mutex_lock(); -int _lwp_mutex_unlock(); -int _lwp_mutex_trylock(); -int _lwp_cond_wait(); -int _lwp_cond_timedwait(); -int _lwp_cond_reltimedwait(); -int _lwp_cond_signal(); -int _lwp_cond_broadcast(); -int _lwp_sema_init(); -int _lwp_sema_wait(); -int _lwp_sema_trywait(); -int _lwp_sema_post(); -int cond_init(); -int cond_destroy(); -int cond_wait(); -int cond_timedwait(); -int cond_reltimedwait(); -int cond_signal(); -int cond_broadcast(); -int mutex_init(); -int mutex_destroy(); -int mutex_consistent(); -int mutex_lock(); -int mutex_trylock(); -int mutex_unlock(); -int rwlock_init(); -int rwlock_destroy(); -int rw_rdlock(); -int rw_wrlock(); -int rw_unlock(); -int rw_tryrdlock(); -int rw_trywrlock(); -int sema_init(); -int sema_destroy(); -int sema_wait(); -int sema_timedwait(); -int sema_reltimedwait(); -int sema_post(); -int sema_trywait(); - -#endif /* __STDC__ */ - #endif /* _ASM */ /* "Magic numbers" tagging synchronization object types */ @@ -238,8 +194,6 @@ int sema_trywait(); #ifndef _ASM -#ifdef __STDC__ - /* * The *_held() functions apply equally well to Solaris threads * and to Posix threads synchronization objects, but the formal @@ -252,21 +206,8 @@ int _rw_read_held(void *); /* rwlock_t or pthread_rwlock_t */ int _rw_write_held(void *); /* rwlock_t or pthread_rwlock_t */ int _mutex_held(void *); /* mutex_t or pthread_mutex_t */ -#else /* __STDC__ */ - -int _sema_held(); -int _rw_read_held(); -int _rw_write_held(); -int _mutex_held(); - -#endif /* __STDC__ */ - /* Pause API */ -#ifdef __STDC__ void smt_pause(void); -#else /* __STDC__ */ -void smt_pause(); -#endif /* __STDC__ */ #endif /* _ASM */ diff --git a/cddl/contrib/opensolaris/head/thread.h b/cddl/contrib/opensolaris/head/thread.h index d813a25..be58e1c 100644 --- a/cddl/contrib/opensolaris/head/thread.h +++ b/cddl/contrib/opensolaris/head/thread.h @@ -20,6 +20,8 @@ */ /* + * Copyright 2014 Garrett D'Amore + * * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -27,8 +29,6 @@ #ifndef _THREAD_H #define _THREAD_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include #include #include -- cgit v1.1 From ebf4cb37730ee5d005f7e1929036d19ffc0a7e3a Mon Sep 17 00:00:00 2001 From: delphij Date: Sun, 7 Sep 2014 11:57:08 +0000 Subject: Fix typo. Submitted by: Dmitry Morozovsky MFC after: 3 days --- cddl/contrib/opensolaris/cmd/zpool/zpool-features.7 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7 b/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7 index 437b374..27e63a9 100644 --- a/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7 +++ b/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7 @@ -414,7 +414,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 .Po a misnomer in this case, as it contains -the compresseed data, rather than a pointer to its location on disk +the compressed data, rather than a pointer to its location on disk .Pc . Thus the space of the block -- cgit v1.1 From 3cb2e6de7466d95fa66bded91cb1f52f4f0bcada Mon Sep 17 00:00:00 2001 From: delphij Date: Sun, 7 Sep 2014 13:22:14 +0000 Subject: MFV r271225: Iterate through all the children instead of returning error when we hit the first error. This makes the error message give more information rather than just the first device that causes problem. Illumos issue: 5118 When verifying or creating a storage pool, error messages only show one device MFC after: 2 weeks --- cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c | 35 +++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c index 374798b..a7747f6 100644 --- a/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c +++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ /* @@ -1068,8 +1069,8 @@ is_spare(nvlist_t *config, const char *path) * Go through and find any devices that are in use. We rely on libdiskmgt for * the majority of this task. */ -static int -check_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force, +static boolean_t +is_device_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force, boolean_t replacing, boolean_t isspare) { nvlist_t **child; @@ -1078,6 +1079,7 @@ check_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force, int ret; char buf[MAXPATHLEN]; uint64_t wholedisk; + boolean_t anyinuse = B_FALSE; verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &type) == 0); @@ -1102,38 +1104,37 @@ check_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force, (void) strlcpy(buf, path, sizeof (buf)); if (is_spare(config, buf)) - return (0); + return (B_FALSE); } if (strcmp(type, VDEV_TYPE_DISK) == 0) ret = check_device(path, force, isspare); - - if (strcmp(type, VDEV_TYPE_FILE) == 0) + else if (strcmp(type, VDEV_TYPE_FILE) == 0) ret = check_file(path, force, isspare); - return (ret); + return (ret != 0); } for (c = 0; c < children; c++) - if ((ret = check_in_use(config, child[c], force, - replacing, B_FALSE)) != 0) - return (ret); + if (is_device_in_use(config, child[c], force, replacing, + B_FALSE)) + anyinuse = B_TRUE; if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_SPARES, &child, &children) == 0) for (c = 0; c < children; c++) - if ((ret = check_in_use(config, child[c], force, - replacing, B_TRUE)) != 0) - return (ret); + if (is_device_in_use(config, child[c], force, replacing, + B_TRUE)) + anyinuse = B_TRUE; if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_L2CACHE, &child, &children) == 0) for (c = 0; c < children; c++) - if ((ret = check_in_use(config, child[c], force, - replacing, B_FALSE)) != 0) - return (ret); + if (is_device_in_use(config, child[c], force, replacing, + B_FALSE)) + anyinuse = B_TRUE; - return (0); + return (anyinuse); } static const char * @@ -1487,7 +1488,7 @@ make_root_vdev(zpool_handle_t *zhp, int force, int check_rep, * uses (such as a dedicated dump device) that even '-f' cannot * override. */ - if (check_in_use(poolconfig, newroot, force, replacing, B_FALSE) != 0) { + if (is_device_in_use(poolconfig, newroot, force, replacing, B_FALSE)) { nvlist_free(newroot); return (NULL); } -- cgit v1.1 From b4971501637a88d7c7d1f0eeb9b569903ddf1c95 Mon Sep 17 00:00:00 2001 From: markj Date: Thu, 11 Sep 2014 01:04:56 +0000 Subject: Use the linker to perform relocations in the SUNW_dof section rather than doing them in drti during startup. This fixes a number of problems with using USDT probes in stripped executables and shared libraries, and with USDT probes in static functions. Reviewed by: rpaulo MFC after: 1 month Sponsored by: EMC / Isilon Storage Division Phabric: D751 --- .../opensolaris/lib/libdtrace/common/drti.c | 114 +------------------ .../opensolaris/lib/libdtrace/common/dt_link.c | 121 ++++----------------- 2 files changed, 23 insertions(+), 212 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c b/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c index bb02d8c..3c64f87 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c @@ -90,36 +90,6 @@ dprintf(int debug, const char *fmt, ...) va_end(ap); } -#if !defined(sun) -static void -fixsymbol(Elf *e, Elf_Data *data, size_t idx, int nprobes, char *buf, - dof_sec_t *sec, int *fixedprobes, char *dofstrtab) -{ - GElf_Sym sym; - char *s; - unsigned char *funcname; - dof_probe_t *prb; - int j = 0; - int ndx; - - while (gelf_getsym(data, j++, &sym) != NULL) { - prb = (dof_probe_t *)(void *)(buf + sec->dofs_offset); - - for (ndx = nprobes; ndx; ndx--, prb += 1) { - funcname = dofstrtab + prb->dofpr_func; - s = elf_strptr(e, idx, sym.st_name); - if (strcmp(s, funcname) == 0) { - dprintf(1, "fixing %s() symbol\n", s); - prb->dofpr_addr = sym.st_value; - (*fixedprobes)++; - } - } - if (*fixedprobes == nprobes) - break; - } -} -#endif - #if defined(sun) #pragma init(dtrace_dof_init) #else @@ -145,9 +115,6 @@ dtrace_dof_init(void) Lmid_t lmid; #else u_long lmid = 0; - dof_sec_t *sec, *secstart, *dofstrtab, *dofprobes; - dof_provider_t *dofprovider; - size_t i; #endif int fd; const char *p; @@ -157,12 +124,9 @@ dtrace_dof_init(void) Elf_Data *symtabdata = NULL, *dynsymdata = NULL, *dofdata = NULL; dof_hdr_t *dof_next = NULL; GElf_Shdr shdr; - int efd, nprobes; + int efd; char *s; - char *dofstrtabraw; size_t shstridx, symtabidx = 0, dynsymidx = 0; - unsigned char *buf; - int fixedprobes; #endif if (getenv("DTRACE_DOF_INIT_DISABLE") != NULL) @@ -183,7 +147,6 @@ dtrace_dof_init(void) } #endif - if ((modname = strrchr(lmp->l_name, '/')) == NULL) modname = lmp->l_name; else @@ -209,9 +172,9 @@ dtrace_dof_init(void) } else if (shdr.sh_type == SHT_DYNSYM) { dynsymidx = shdr.sh_link; dynsymdata = elf_getdata(scn, NULL); - } else if (shdr.sh_type == SHT_PROGBITS) { + } else if (shdr.sh_type == SHT_SUNW_dof) { s = elf_strptr(e, shstridx, shdr.sh_name); - if (s && strcmp(s, ".SUNW_dof") == 0) { + if (s != NULL && strcmp(s, ".SUNW_dof") == 0) { dofdata = elf_getdata(scn, NULL); dof = dofdata->d_buf; } @@ -225,7 +188,6 @@ dtrace_dof_init(void) } while ((char *) dof < (char *) dofdata->d_buf + dofdata->d_size) { - fixedprobes = 0; dof_next = (void *) ((char *) dof + dof->dofh_filesz); #endif @@ -273,76 +235,6 @@ dtrace_dof_init(void) return; #endif } -#if !defined(sun) - /* - * We need to fix the base address of each probe since this wasn't - * done by ld(1). (ld(1) needs to grow support for parsing the - * SUNW_dof section). - * - * The complexity of this is not that great. The first for loop - * iterates over the sections inside the DOF file. There are usually - * 10 sections here. We asume the STRTAB section comes first and the - * PROBES section comes after. Since we are only interested in fixing - * data inside the PROBES section we quit the for loop after processing - * the PROBES section. It's usually the case that the first section - * is the STRTAB section and the second section is the PROBES section, - * so this for loop is not meaningful when doing complexity analysis. - * - * After finding the probes section, we iterate over the symbols - * in the symtab section. When we find a symbol name that matches - * the probe function name, we fix it. If we have fixed all the - * probes, we exit all the loops and we are done. - * The number of probes is given by the variable 'nprobes' and this - * depends entirely on the user, but some optimizations were done. - * - * We are assuming the number of probes is less than the number of - * symbols (libc can have 4k symbols, for example). - */ - secstart = sec = (dof_sec_t *)(dof + 1); - buf = (char *)dof; - for (i = 0; i < dof->dofh_secnum; i++, sec++) { - if (sec->dofs_type != DOF_SECT_PROVIDER) - continue; - - dofprovider = (void *) (buf + sec->dofs_offset); - dofstrtab = secstart + dofprovider->dofpv_strtab; - dofprobes = secstart + dofprovider->dofpv_probes; - - if (dofstrtab->dofs_type != DOF_SECT_STRTAB) { - fprintf(stderr, "WARNING: expected STRTAB section, but got %d\n", - dofstrtab->dofs_type); - break; - } - if (dofprobes->dofs_type != DOF_SECT_PROBES) { - fprintf(stderr, "WARNING: expected PROBES section, but got %d\n", - dofprobes->dofs_type); - break; - } - - dprintf(1, "found provider %p\n", dofprovider); - dofstrtabraw = (char *)(buf + dofstrtab->dofs_offset); - nprobes = dofprobes->dofs_size / dofprobes->dofs_entsize; - fixsymbol(e, symtabdata, symtabidx, nprobes, buf, dofprobes, &fixedprobes, - dofstrtabraw); - if (fixedprobes != nprobes) { - /* - * If we haven't fixed all the probes using the - * symtab section, look inside the dynsym - * section. - */ - fixsymbol(e, dynsymdata, dynsymidx, nprobes, buf, dofprobes, - &fixedprobes, dofstrtabraw); - } - if (fixedprobes != nprobes) { - fprintf(stderr, "WARNING: number of probes " - "fixed does not match the number of " - "defined probes (%d != %d, " - "respectively)\n", fixedprobes, nprobes); - fprintf(stderr, "WARNING: some probes might " - "not fire or your program might crash\n"); - } - } -#endif if ((gen = ioctl(fd, DTRACEHIOC_ADDDOF, &dh)) == -1) dprintf(1, "DTrace ioctl failed for DOF at %p", dof); else { diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c index 13300b0..106878c 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c @@ -322,7 +322,11 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep) char *strtab; int i, j, nrel; size_t strtabsz = 1; +#if defined(sun) uint32_t count = 0; +#else + uint64_t count = 0; +#endif size_t base; Elf64_Sym *sym; Elf64_Rela *rel; @@ -418,7 +422,6 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep) s = &dofs[dofrh->dofr_tgtsec]; for (j = 0; j < nrel; j++) { -#ifdef DOODAD #if defined(__arm__) /* XXX */ #elif defined(__mips__) @@ -431,8 +434,13 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep) #elif defined(__i386) || defined(__amd64) rel->r_offset = s->dofs_offset + dofr[j].dofr_offset; +#if defined(sun) rel->r_info = ELF64_R_INFO(count + dep->de_global, R_AMD64_64); +#else + rel->r_info = ELF64_R_INFO(count + dep->de_global, + R_X86_64_RELATIVE); +#endif #elif defined(__sparc) rel->r_offset = s->dofs_offset + dofr[j].dofr_offset; @@ -441,7 +449,6 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep) #else #error unknown ISA #endif -#endif sym->st_name = base + dofr[j].dofr_name - 1; sym->st_value = 0; @@ -704,7 +711,11 @@ dump_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd) shp = &elf_file.shdr[ESHDR_DOF]; shp->sh_name = 11; /* DTRACE_SHSTRTAB64[11] = ".SUNW_dof" */ +#if defined(sun) shp->sh_flags = SHF_ALLOC; +#else + shp->sh_flags = SHF_WRITE | SHF_ALLOC; +#endif shp->sh_type = SHT_SUNW_dof; shp->sh_offset = off; shp->sh_size = dof->dofh_filesz; @@ -1662,19 +1673,6 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, { #if !defined(sun) char tfile[PATH_MAX]; - Elf *e; - Elf_Scn *scn; - Elf_Data *data; - GElf_Shdr shdr; - int efd; - size_t stridx; - unsigned char *buf; - char *s; - int loc; - GElf_Ehdr ehdr; - Elf_Scn *scn0; - GElf_Shdr shdr0; - uint64_t off, rc; #endif char drti[PATH_MAX]; dof_hdr_t *dof; @@ -1810,21 +1808,22 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, (void) unlink(file); #endif -#if defined(sun) if (dtp->dt_oflags & DTRACE_O_LP64) status = dump_elf64(dtp, dof, fd); else status = dump_elf32(dtp, dof, fd); +#if defined(sun) if (status != 0 || lseek(fd, 0, SEEK_SET) != 0) { return (dt_link_error(dtp, NULL, -1, NULL, "failed to write %s: %s", file, strerror(errno))); } #else - /* We don't write the ELF header, just the DOF section */ - if (dt_write(dtp, fd, dof, dof->dofh_filesz) < dof->dofh_filesz) + (void)close(fd); + if (status != 0) return (dt_link_error(dtp, NULL, -1, NULL, - "failed to write %s: %s", tfile, strerror(errno))); + "failed to write %s: %s", tfile, + strerror(dtrace_errno(dtp)))); #endif if (!dtp->dt_lazyload) { @@ -1846,7 +1845,7 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, (void) snprintf(cmd, len, fmt, dtp->dt_ld_path, file, fd, drti); #else - const char *fmt = "%s -o %s -r %s"; + const char *fmt = "%s -o %s -r %s %s"; #if defined(__amd64__) /* @@ -1868,10 +1867,9 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, len = snprintf(&tmp, 1, fmt, dtp->dt_ld_path, file, tfile, drti) + 1; - len *= 2; cmd = alloca(len); - (void) snprintf(cmd, len, fmt, dtp->dt_ld_path, file, + (void) snprintf(cmd, len, fmt, dtp->dt_ld_path, file, tfile, drti); #endif if ((status = system(cmd)) == -1) { @@ -1894,85 +1892,6 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, file, dtp->dt_ld_path, WEXITSTATUS(status)); goto done; } -#if !defined(sun) - /* - * FreeBSD's ld(1) is not instructed to interpret and add - * correctly the SUNW_dof section present in tfile. - * We use libelf to add this section manually and hope the next - * ld invocation won't remove it. - */ - elf_version(EV_CURRENT); - if ((efd = open(file, O_RDWR, 0)) < 0) { - ret = dt_link_error(dtp, NULL, -1, NULL, - "failed to open file %s: %s", - file, strerror(errno)); - goto done; - } - if ((e = elf_begin(efd, ELF_C_RDWR, NULL)) == NULL) { - close(efd); - ret = dt_link_error(dtp, NULL, -1, NULL, - "failed to open elf file: %s", - elf_errmsg(elf_errno())); - goto done; - } - /* - * Add the string '.SUWN_dof' to the shstrtab section. - */ - elf_getshdrstrndx(e, &stridx); - scn = elf_getscn(e, stridx); - gelf_getshdr(scn, &shdr); - data = elf_newdata(scn); - data->d_off = shdr.sh_size; - data->d_buf = ".SUNW_dof"; - data->d_size = 10; - data->d_type = ELF_T_BYTE; - loc = shdr.sh_size; - shdr.sh_size += data->d_size; - gelf_update_shdr(scn, &shdr); - /* - * Construct the .SUNW_dof section. - */ - scn = elf_newscn(e); - data = elf_newdata(scn); - buf = mmap(NULL, dof->dofh_filesz, PROT_READ, MAP_SHARED, - fd, 0); - if (buf == MAP_FAILED) { - ret = dt_link_error(dtp, NULL, -1, NULL, - "failed to mmap buffer %s", strerror(errno)); - elf_end(e); - close(efd); - goto done; - } - data->d_buf = buf; - data->d_align = 4; - data->d_size = dof->dofh_filesz; - data->d_version = EV_CURRENT; - gelf_getshdr(scn, &shdr); - shdr.sh_name = loc; - shdr.sh_flags = SHF_ALLOC; - /* - * Actually this should be SHT_SUNW_dof, but FreeBSD's ld(1) - * will remove this 'unknown' section when we try to create an - * executable using the object we are modifying, so we stop - * playing by the rules and use SHT_PROGBITS. - * Also, note that our drti has modifications to handle this. - */ - shdr.sh_type = SHT_PROGBITS; - shdr.sh_addralign = 4; - gelf_update_shdr(scn, &shdr); - if (elf_update(e, ELF_C_WRITE) < 0) { - ret = dt_link_error(dtp, NULL, -1, NULL, - "failed to add the SUNW_dof section: %s", - elf_errmsg(elf_errno())); - munmap(buf, dof->dofh_filesz); - elf_end(e); - close(efd); - goto done; - } - munmap(buf, dof->dofh_filesz); - elf_end(e); - close(efd); -#endif (void) close(fd); /* release temporary file */ } else { (void) close(fd); -- cgit v1.1 From a0dafe3a3cb5713720456aea2ab6c5445a26d208 Mon Sep 17 00:00:00 2001 From: delphij Date: Sat, 13 Sep 2014 16:41:39 +0000 Subject: MFV r271511: Use fnvlist_* to make code more readable. Illumos issue: 5135 zpool_find_import_cached() can use fnvlist_* MFC after: 2 weeks --- .../opensolaris/lib/libzfs/common/libzfs_import.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c index 868961d..49a4385 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. * Copyright 2014 Nexenta Systems, Inc. All rights reserved. */ @@ -1426,21 +1426,15 @@ zpool_find_import_cached(libzfs_handle_t *hdl, const char *cachefile, elem = NULL; while ((elem = nvlist_next_nvpair(raw, elem)) != NULL) { - verify(nvpair_value_nvlist(elem, &src) == 0); + src = fnvpair_value_nvlist(elem); - verify(nvlist_lookup_string(src, ZPOOL_CONFIG_POOL_NAME, - &name) == 0); + name = fnvlist_lookup_string(src, ZPOOL_CONFIG_POOL_NAME); if (poolname != NULL && strcmp(poolname, name) != 0) continue; - verify(nvlist_lookup_uint64(src, ZPOOL_CONFIG_POOL_GUID, - &this_guid) == 0); - if (guid != 0) { - verify(nvlist_lookup_uint64(src, ZPOOL_CONFIG_POOL_GUID, - &this_guid) == 0); - if (guid != this_guid) - continue; - } + this_guid = fnvlist_lookup_uint64(src, ZPOOL_CONFIG_POOL_GUID); + if (guid != 0 && guid != this_guid) + continue; if (pool_active(hdl, name, this_guid, &active) != 0) { nvlist_free(raw); -- cgit v1.1 From b157123631b928ffeb6fd3a56c3aed0ef7b09cef Mon Sep 17 00:00:00 2001 From: delphij Date: Sat, 13 Sep 2014 17:30:46 +0000 Subject: MFV r271516: Enable debug printf's when ZFS_DEBUG or debug= is set. Illumos issue: 5134 if ZFS_DEBUG or debug= is set, libzpool should enable debug prints MFC after: 2 weeks --- cddl/contrib/opensolaris/lib/libzpool/common/kernel.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c b/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c index 1a2c2ac..ef38696 100644 --- a/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c +++ b/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c @@ -650,6 +650,9 @@ dprintf_setup(int *argc, char **argv) */ if (dprintf_find_string("on")) dprintf_print_all = 1; + + if (dprintf_string != NULL) + zfs_flags |= ZFS_DEBUG_DPRINTF; } int -- cgit v1.1 From 65bccd5b546490ed3e9ef43ce93d5a573d366801 Mon Sep 17 00:00:00 2001 From: markj Date: Tue, 16 Sep 2014 22:54:15 +0000 Subject: Fix elfdump(1) usage in the userland CTF tests. PR: 193110 MFC after: 1 week Sponsored by: EMC / Isilon Storage Division --- .../opensolaris/cmd/dtrace/test/tst/common/uctf/err.user64mode.ksh | 2 +- .../opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh | 2 +- .../opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh | 2 +- .../contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh | 2 +- .../opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprint.ksh | 2 +- .../opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprinttarg.ksh | 2 +- .../opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh | 2 +- .../opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtypetarg.ksh | 2 +- .../opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh | 2 +- .../opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.user64mode.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.user64mode.ksh index d987c8d..4eaf169 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.user64mode.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.user64mode.ksh @@ -31,7 +31,7 @@ dtrace=$1 t="zelda_info_t" exe="tst.chasestrings.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -ne 0 ]]; then echo "CTF does not exist in $exe, that's a bug" >&2 exit 1 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh index 151a936..3a842af 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh @@ -28,7 +28,7 @@ dtrace=$1 t="season_7_lisa_the_vegetrian_t *" exe="tst.aouttype.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -ne 0 ]]; then echo "CTF does not exist in $exe, that's a bug" >&2 exit 1 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh index 2502846..d754c19 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.chasestrings.ksh @@ -29,7 +29,7 @@ dtrace=$1 t="zelda_info_t" exe="tst.chasestrings.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -ne 0 ]]; then echo "CTF does not exist in $exe, that's a bug" >&2 exit 1 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh index af7c6c8..5b9ce91 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh @@ -29,7 +29,7 @@ dtrace=$1 t="int" exe="tst.libtype.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -eq 0 ]]; then echo "CTF exists in $exe, that's a bug" >&2 exit 1 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprint.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprint.ksh index febb015..e5902fa 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprint.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprint.ksh @@ -28,7 +28,7 @@ dtrace=$1 t="final_fantasy_info_t" exe="tst.printtype.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -ne 0 ]]; then echo "CTF does not exist in $exe, that's a bug" >&2 exit 1 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprinttarg.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprinttarg.ksh index 7398dc4..5e92cf9 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprinttarg.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.pidprinttarg.ksh @@ -29,7 +29,7 @@ dtrace=$1 t="final_fantasy_info_t" exe="tst.printtype.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -ne 0 ]]; then echo "CTF does not exist in $exe, that's a bug" >&2 exit 1 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh index dfc1535..a93a3b8 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtype.ksh @@ -28,7 +28,7 @@ dtrace=$1 t="final_fantasy_info_t" exe="tst.printtype.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -ne 0 ]]; then echo "CTF does not exist in $exe, that's a bug" >&2 exit 1 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtypetarg.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtypetarg.ksh index 025d4a8..fa080a5 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtypetarg.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.printtypetarg.ksh @@ -29,7 +29,7 @@ dtrace=$1 t="final_fantasy_info_t" exe="tst.printtype.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -ne 0 ]]; then echo "CTF does not exist in $exe, that's a bug" >&2 exit 1 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh index 58811ff..072fca7 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh @@ -29,7 +29,7 @@ dtrace=$1 t="zelda_info_t" exe="tst.chasestrings.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -ne 0 ]]; then echo "CTF does not exist in $exe, that's a bug" >&2 exit 1 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh index 79d79de..c5a105b 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userstrings.ksh @@ -28,7 +28,7 @@ fi dtrace=$1 exe="tst.chasestrings.exe" -elfdump "./$exe" | grep -q '.SUNW_ctf' +elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' if [[ $? -ne 0 ]]; then echo "CTF does not exist in $exe, that's a bug" >&2 exit 1 -- cgit v1.1 From 1642671ec5727db3d568e4db1c8e6b9fd2063208 Mon Sep 17 00:00:00 2001 From: markj Date: Wed, 17 Sep 2014 00:54:00 +0000 Subject: Fix some incorrect endianness checks. MFC after: 1 week Sponsored by: EMC / Isilon Storage Division --- cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c | 2 +- cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c b/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c index 0df44cf..5822267 100644 --- a/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c +++ b/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c @@ -274,7 +274,7 @@ ctf_fdopen(int fd, int *errp) */ if (nbytes >= (ssize_t) sizeof (Elf32_Ehdr) && bcmp(&hdr.e32.e_ident[EI_MAG0], ELFMAG, SELFMAG) == 0) { -#ifdef _BIG_ENDIAN +#if BYTE_ORDER == _BIG_ENDIAN uchar_t order = ELFDATA2MSB; #else uchar_t order = ELFDATA2LSB; diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c index fb8ea16..4be0f03 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c @@ -167,7 +167,7 @@ print_bitfield(dt_printarg_t *pap, ulong_t off, ctf_encoding_t *ep) * to the lowest 'size' bytes in 'value', and we need to shift based on * the offset from the end of the data, not the offset of the start. */ -#ifdef _BIG_ENDIAN +#if BYTE_ORDER == _BIG_ENDIAN buf += sizeof (value) - size; off += ep->cte_bits; #endif @@ -178,7 +178,7 @@ print_bitfield(dt_printarg_t *pap, ulong_t off, ctf_encoding_t *ep) * Offsets are counted from opposite ends on little- and * big-endian machines. */ -#ifdef _BIG_ENDIAN +#if BYTE_ORDER == _BIG_ENDIAN shift = NBBY - shift; #endif -- cgit v1.1 From d46a293b8b28fbd74a968c42a0852485189980ad Mon Sep 17 00:00:00 2001 From: markj Date: Wed, 17 Sep 2014 03:40:49 +0000 Subject: Fix a number of typos and programming errors in the userland CTF tests. It seems that they would only pass by chance on illumos; on FreeBSD, they still fail since userland CTF is not yet supported. MFC after: 1 week Sponsored by: EMC / Isilon Storage Division --- .../opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype.ksh | 3 ++- .../opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype2.ksh | 3 ++- .../opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh | 5 +++-- .../opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype.ksh index 978cde3..432a9fc 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype.ksh @@ -29,6 +29,7 @@ dtrace=$1 t="season_8_mountain_of_madness_t" pid=$$ -rc=`$dtrace -n "BEGIN{ trace(pid$pid`$t)0); }"` +$dtrace -n "BEGIN{ trace(pid$pid\`$t)0); }" +rc=$? exit $rc diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype2.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype2.ksh index e64ed52..d1b4876 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype2.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/err.invalidtype2.ksh @@ -30,6 +30,7 @@ dtrace=$1 t="season_8_mountain_of_madness_t" pid=$$ -rc=`$dtrace -n "BEGIN{ trace(pid`$t)0); }"` -p $pid +$dtrace -n "BEGIN{ trace(pid$pid\`$t)0); }" -p $pid +rc=$? exit $rc diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh index 3a842af..95b26c8 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.aouttype.ksh @@ -25,7 +25,7 @@ if [ $# != 1 ]; then fi dtrace=$1 -t="season_7_lisa_the_vegetrian_t *" +t="season_7_lisa_the_vegetarian_t *" exe="tst.aouttype.exe" elfdump -c "./$exe" | grep -Fq 'sh_name: .SUNW_ctf' @@ -37,7 +37,8 @@ fi ./$exe & pid=$! -rc=`$dtrace -n "BEGIN{ trace((pid$pid\`$t)0); exit(0); }"` +$dtrace -n "BEGIN{ trace((pid$pid\`$t)0); exit(0); }" +rc=$? kill -9 $pid diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh index 5b9ce91..2336166 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.libtype.ksh @@ -38,7 +38,8 @@ fi ./$exe & pid=$! -rc=`$dtrace -n "BEGIN{ trace((pid$pid\`$t)0); exit(0); }"` +$dtrace -n "BEGIN{ trace((pid$pid\`$t)0); exit(0); }" +rc=$? kill -9 $pid -- cgit v1.1 From 0958b711f945bea1613ed62102119bc488983e1a Mon Sep 17 00:00:00 2001 From: markj Date: Wed, 17 Sep 2014 04:02:56 +0000 Subject: Implement a workaround to allow this test program to be compiled with clang. It seems that if a pragma is used to define a weak alias for a local function, the pragma must appear after the function is defined. PR: 193056 MFC after: 1 week Sponsored by: EMC / Isilon Storage Division --- cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c index 8dabbe6..bb571d2 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.weak2.c @@ -34,14 +34,14 @@ * leading underscores. */ -#pragma weak _go = go - static int go(int a) { return (a + 1); } +#pragma weak _go = go + static void handle(int sig) { -- cgit v1.1 From 0d43f1eace874851639945f51d8e2d44ba4d4ba3 Mon Sep 17 00:00:00 2001 From: will Date: Thu, 18 Sep 2014 14:02:25 +0000 Subject: Fix an assert to tolerate spare parents with more than 2 children. This can occur if a spare is being spared, which would yield three children: the original pool drive, the previous spare, and the spare that is replacing it. MFC after: 1 week Sponsored by: Spectra Logic Affects: All ZFS versions starting 7 Jun 2006 (illumos 94de1d4c) MFSpectraBSD: r668345 on 2013/06/04 17:10:43 --- cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c index a7747f6..e974b75 100644 --- a/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c +++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c @@ -653,6 +653,7 @@ get_replication(nvlist_t *nvroot, boolean_t fatal) dontreport = 0; vdev_size = -1ULL; for (c = 0; c < children; c++) { + boolean_t is_replacing, is_spare; nvlist_t *cnv = child[c]; char *path; struct stat64 statbuf; @@ -669,16 +670,19 @@ 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. */ - if (strcmp(childtype, - VDEV_TYPE_REPLACING) == 0 || - strcmp(childtype, VDEV_TYPE_SPARE) == 0) { + is_replacing = strcmp(childtype, + VDEV_TYPE_REPLACING) == 0; + is_spare = strcmp(childtype, + VDEV_TYPE_SPARE) == 0; + if (is_replacing || is_spare) { nvlist_t **rchild; uint_t rchildren; verify(nvlist_lookup_nvlist_array(cnv, ZPOOL_CONFIG_CHILDREN, &rchild, &rchildren) == 0); - assert(rchildren == 2); + assert((is_replacing && rchildren == 2) + || (is_spare && rchildren >= 2)); cnv = rchild[0]; verify(nvlist_lookup_string(cnv, -- cgit v1.1 From cc4139ffebe82bc65f885722c3019ff63bfb7e33 Mon Sep 17 00:00:00 2001 From: will Date: Thu, 18 Sep 2014 14:09:42 +0000 Subject: zfs_setprop_error(): Handle errno value E2BIG. This errno value is emitted by dsl_props_set_check() in sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c, and is used to mean that the property value is too long. For the record, the maximum length is ZAP_MAXVALUELEN, which is 8*1024 bytes. Instead of claiming an unknown error (and abort()ing), provide something more specific to the scenario involved. As far as I can tell, E2BIG is not emitted for any other scenario. MFC after: 1 week Sponsored by: Spectra Logic Affects: All ZFS versions starting 27 Feb 2009 (illumos ccba0801) This change modified the value returned by dsl_props_set_check(), so that it can distinguish between a name that's too long and a value that's too long, but libzfs was not updated accordingly. MFSpectraBSD: r1051499 on 2014/03/28 11:07:59 --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c index d7126bf..265038a 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c @@ -1457,6 +1457,12 @@ zfs_setprop_error(libzfs_handle_t *hdl, zfs_prop_t prop, int err, (void) zfs_error(hdl, EZFS_DSREADONLY, errbuf); break; + case E2BIG: + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "property value too long")); + (void) zfs_error(hdl, EZFS_BADPROP, errbuf); + break; + case ENOTSUP: zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "pool and or dataset must be upgraded to set this " -- cgit v1.1 From 601ace4f2b96848dc77d5d380baee2b7602a0119 Mon Sep 17 00:00:00 2001 From: smh Date: Sun, 21 Sep 2014 19:31:19 +0000 Subject: Output boot code warning when zpool upgrade -a is used to add features. In the case where new features where enabled by a zpool upgrade -a the boot code warning wasn't output. Submitted by: Jan Kokemueller MFC after: 3 days --- cddl/contrib/opensolaris/cmd/zpool/zpool_main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c index fe73169..8cb8091 100644 --- a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c +++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c @@ -4524,7 +4524,8 @@ is_root_pool(zpool_handle_t *zhp) } static void -root_pool_upgrade_check(zpool_handle_t *zhp, char *poolname, int size) { +root_pool_upgrade_check(zpool_handle_t *zhp, char *poolname, int size) +{ if (poolname[0] == '\0' && is_root_pool(zhp)) (void) strlcpy(poolname, zpool_get_name(zhp), size); @@ -4623,7 +4624,7 @@ upgrade_cb(zpool_handle_t *zhp, void *arg) #ifdef __FreeBSD__ root_pool_upgrade_check(zhp, cbp->cb_poolname, sizeof(cbp->cb_poolname)); -#endif /* ___FreeBSD__ */ +#endif /* __FreeBSD__ */ printnl = B_TRUE; #ifdef illumos @@ -4647,6 +4648,10 @@ upgrade_cb(zpool_handle_t *zhp, void *arg) if (count > 0) { cbp->cb_first = B_FALSE; printnl = B_TRUE; +#ifdef __FreeBSD__ + root_pool_upgrade_check(zhp, cbp->cb_poolname, + sizeof(cbp->cb_poolname)); +#endif /* __FreeBSD__ */ /* * If they did "zpool upgrade -a", then we could * be doing ioctls to different pools. We need @@ -4788,7 +4793,7 @@ upgrade_one(zpool_handle_t *zhp, void *data) #ifdef __FreeBSD__ root_pool_upgrade_check(zhp, cbp->cb_poolname, sizeof(cbp->cb_poolname)); -#endif /* ___FreeBSD__ */ +#endif /* __FreeBSD__ */ } if (cbp->cb_version >= SPA_VERSION_FEATURES) { -- cgit v1.1 From 855d72feb3103c28b70b54b056a4b1d97d888ec3 Mon Sep 17 00:00:00 2001 From: markj Date: Mon, 22 Sep 2014 21:02:38 +0000 Subject: Remove some variables that are no longer used as of r271413. Reported by: Coverity CID: 1238924 X-MFC-With: r271413 --- cddl/contrib/opensolaris/lib/libdtrace/common/drti.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c b/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c index 3c64f87..ccd4f9b 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c @@ -121,12 +121,12 @@ dtrace_dof_init(void) #if !defined(sun) Elf *e; Elf_Scn *scn = NULL; - Elf_Data *symtabdata = NULL, *dynsymdata = NULL, *dofdata = NULL; + Elf_Data *dofdata = NULL; dof_hdr_t *dof_next = NULL; GElf_Shdr shdr; int efd; char *s; - size_t shstridx, symtabidx = 0, dynsymidx = 0; + size_t shstridx; #endif if (getenv("DTRACE_DOF_INIT_DISABLE") != NULL) @@ -166,15 +166,9 @@ dtrace_dof_init(void) dof = NULL; while ((scn = elf_nextscn(e, scn)) != NULL) { gelf_getshdr(scn, &shdr); - if (shdr.sh_type == SHT_SYMTAB) { - symtabidx = shdr.sh_link; - symtabdata = elf_getdata(scn, NULL); - } else if (shdr.sh_type == SHT_DYNSYM) { - dynsymidx = shdr.sh_link; - dynsymdata = elf_getdata(scn, NULL); - } else if (shdr.sh_type == SHT_SUNW_dof) { + if (shdr.sh_type == SHT_SUNW_dof) { s = elf_strptr(e, shstridx, shdr.sh_name); - if (s != NULL && strcmp(s, ".SUNW_dof") == 0) { + if (s != NULL && strcmp(s, ".SUNW_dof") == 0) { dofdata = elf_getdata(scn, NULL); dof = dofdata->d_buf; } -- cgit v1.1 From 06bee38d37ce7a0db0ac605a748fc025de393327 Mon Sep 17 00:00:00 2001 From: markj Date: Mon, 22 Sep 2014 21:09:30 +0000 Subject: Remove an incorrect close(2) call that was added in r271413. Reported by: Coverity CID: 1238923 X-MFC-With: r271413 --- cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c | 1 - 1 file changed, 1 deletion(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c index 106878c..597fef4 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c @@ -1819,7 +1819,6 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, "failed to write %s: %s", file, strerror(errno))); } #else - (void)close(fd); if (status != 0) return (dt_link_error(dtp, NULL, -1, NULL, "failed to write %s: %s", tfile, -- cgit v1.1 From e450f0c2dd75e4ac7ab1f3e2636474df001d871b Mon Sep 17 00:00:00 2001 From: rpaulo Date: Tue, 23 Sep 2014 18:22:40 +0000 Subject: Build plockstat if WITH_PLOCKSTAT is defined. --- cddl/usr.sbin/Makefile | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cddl') diff --git a/cddl/usr.sbin/Makefile b/cddl/usr.sbin/Makefile index 537b8e5..0d34afd 100644 --- a/cddl/usr.sbin/Makefile +++ b/cddl/usr.sbin/Makefile @@ -5,6 +5,7 @@ SUBDIR= ${_dtrace} \ ${_dtruss} \ ${_lockstat} \ + ${_plockstat} \ ${_tests} \ ${_zdb} \ ${_zhack} @@ -24,6 +25,9 @@ _zhack= zhack _dtrace= dtrace _dtruss= dtruss _lockstat= lockstat +.if defined(WITH_PLOCKSTAT) +_plockstat= plockstat +.endif .endif .if ${MACHINE_CPUARCH} == "mips" -- cgit v1.1 From 02e9fe98be7b0c37b9c5448a8e9bece162ffb616 Mon Sep 17 00:00:00 2001 From: markj Date: Fri, 26 Sep 2014 07:01:27 +0000 Subject: Fix the description of the -h option. Reported by: swills MFC after: 3 days --- cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 index cc3a311..2d210a2 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 +++ b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 @@ -277,6 +277,19 @@ Generate a header file containing macros that correspond to probes in the specified provider definitions. This option should be used to generate a header file that is included by other source files for later use with the +.Fl G +option. +If the +.Fl o +option is present, the header file is saved using the pathname specified as the +argument for that option. +If the +.Fl o +option is not present and the DTrace program is contained within a file whose +name is +.Ar filename.d , +then the header file is saved using the name +.Ar filename.h . .It Fl H Print the pathnames of included files when invoking .Xr cpp 1 @@ -289,20 +302,6 @@ option to each .Xr cpp 1 invocation, causing it to display the list of pathnames, one for each line, to standard error. -.Fl G -option. -If the -.Fl o -option -is present, the header file is saved using the pathname specified as the -argument for that option. -If the -.Fl o -option is not present and the DTrace program is contained with a file whose -name is -.Ar filename.d , -then the header file is saved using the name -.Ar filename.h . .It Fl i Ar probe-id Op Oo Ar predicate Oc Ar action Specify probe identifier .Ar ( probe-id ) -- cgit v1.1 From 2a1bf3161bcde0d19f55d20f60591584023f628e Mon Sep 17 00:00:00 2001 From: delphij Date: Fri, 26 Sep 2014 21:46:32 +0000 Subject: Add libuutil to dependency list. Noticed by: sef MFC after: 3 days --- cddl/lib/libzfs/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cddl') diff --git a/cddl/lib/libzfs/Makefile b/cddl/lib/libzfs/Makefile index 4010ac1..6937806 100644 --- a/cddl/lib/libzfs/Makefile +++ b/cddl/lib/libzfs/Makefile @@ -7,8 +7,8 @@ LIB= zfs DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBUMEM} ${LIBUTIL} ${LIBM} ${LIBNVPAIR} \ - ${LIBAVL} ${LIBZFS_CORE} -LDADD= -lmd -lpthread -lumem -lutil -lm -lnvpair -lavl -lzfs_core + ${LIBUUTIL} ${LIBAVL} ${LIBZFS_CORE} +LDADD= -lmd -lpthread -lumem -lutil -lm -lnvpair -luutil -lavl -lzfs_core SRCS= deviceid.c \ fsshare.c \ -- cgit v1.1 From 60288efc68ed411c5fe62ca7161ad3f5dafa3b84 Mon Sep 17 00:00:00 2001 From: delphij Date: Sat, 27 Sep 2014 09:39:19 +0000 Subject: Revert r272189, the committed version was an old version and breaks build. Pointy hat to: delphij --- cddl/lib/libzfs/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cddl') diff --git a/cddl/lib/libzfs/Makefile b/cddl/lib/libzfs/Makefile index 6937806..4010ac1 100644 --- a/cddl/lib/libzfs/Makefile +++ b/cddl/lib/libzfs/Makefile @@ -7,8 +7,8 @@ LIB= zfs DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBUMEM} ${LIBUTIL} ${LIBM} ${LIBNVPAIR} \ - ${LIBUUTIL} ${LIBAVL} ${LIBZFS_CORE} -LDADD= -lmd -lpthread -lumem -lutil -lm -lnvpair -luutil -lavl -lzfs_core + ${LIBAVL} ${LIBZFS_CORE} +LDADD= -lmd -lpthread -lumem -lutil -lm -lnvpair -lavl -lzfs_core SRCS= deviceid.c \ fsshare.c \ -- cgit v1.1 From 765b323768964937867b15f47061b42fe5cdd6f6 Mon Sep 17 00:00:00 2001 From: markj Date: Thu, 2 Oct 2014 22:33:35 +0000 Subject: Have dtrace(1) handle SIGPIPE by cleaning up and exiting. Additionally, install signal handlers when running in list mode (-l), and acknowledge interrupts by cleaning up and exiting. This ensures that a command like $ dtrace -l -P 'pid$target' -p | less won't cause the ptrace(2)d target process to be killed if less(1) exits before all dtrace output is consumed. Reported by: Anton Yuzhaninov Differential Revision: https://reviews.freebsd.org/D880 Reviewed by: rpaulo MFC after: 1 month Sponsored by: EMC / Isilon Storage Division --- cddl/contrib/opensolaris/cmd/dtrace/dtrace.c | 45 ++++++++++++++++++---------- 1 file changed, 30 insertions(+), 15 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c index 4cbb866..3a954ed 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c @@ -710,6 +710,9 @@ list_probe(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, void *arg) if (g_verbose && dtrace_probe_info(dtp, pdp, &p) == 0) print_probe_info(&p); + if (g_intr != 0) + return (1); + return (0); } @@ -1220,11 +1223,34 @@ intr(int signo) g_impatient = 1; } +static void +installsighands(void) +{ + struct sigaction act, oact; + + (void) sigemptyset(&act.sa_mask); + act.sa_flags = 0; + act.sa_handler = intr; + + if (sigaction(SIGINT, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN) + (void) sigaction(SIGINT, &act, NULL); + + if (sigaction(SIGTERM, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN) + (void) sigaction(SIGTERM, &act, NULL); + +#if !defined(sun) + if (sigaction(SIGPIPE, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN) + (void) sigaction(SIGPIPE, &act, NULL); + + if (sigaction(SIGUSR1, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN) + (void) sigaction(SIGUSR1, &act, NULL); +#endif +} + int main(int argc, char *argv[]) { dtrace_bufdesc_t buf; - struct sigaction act, oact; dtrace_status_t status[2]; dtrace_optval_t opt; dtrace_cmd_t *dcp; @@ -1776,6 +1802,8 @@ main(int argc, char *argv[]) if (g_ofile != NULL && (g_ofp = fopen(g_ofile, "a")) == NULL) fatal("failed to open output file '%s'", g_ofile); + installsighands(); + oprintf("%5s %10s %17s %33s %s\n", "ID", "PROVIDER", "MODULE", "FUNCTION", "NAME"); @@ -1861,20 +1889,7 @@ main(int argc, char *argv[]) if (opt != DTRACEOPT_UNSET) notice("allowing destructive actions\n"); - (void) sigemptyset(&act.sa_mask); - act.sa_flags = 0; - act.sa_handler = intr; - - if (sigaction(SIGINT, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN) - (void) sigaction(SIGINT, &act, NULL); - - if (sigaction(SIGTERM, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN) - (void) sigaction(SIGTERM, &act, NULL); - -#if !defined(sun) - if (sigaction(SIGUSR1, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN) - (void) sigaction(SIGUSR1, &act, NULL); -#endif + installsighands(); /* * Now that tracing is active and we are ready to consume trace data, -- cgit v1.1 From 5a6c8bb01b9c63a9f82583cd78595b13cc20d4d6 Mon Sep 17 00:00:00 2001 From: delphij Date: Fri, 3 Oct 2014 20:36:09 +0000 Subject: Add dependencies to various libraries to libzfs and libzpool. Submitted by: sef --- cddl/lib/libzfs/Makefile | 7 +++++-- cddl/lib/libzpool/Makefile | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'cddl') diff --git a/cddl/lib/libzfs/Makefile b/cddl/lib/libzfs/Makefile index 4010ac1..b2f4352 100644 --- a/cddl/lib/libzfs/Makefile +++ b/cddl/lib/libzfs/Makefile @@ -7,8 +7,11 @@ LIB= zfs DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBUMEM} ${LIBUTIL} ${LIBM} ${LIBNVPAIR} \ - ${LIBAVL} ${LIBZFS_CORE} -LDADD= -lmd -lpthread -lumem -lutil -lm -lnvpair -lavl -lzfs_core + ${LIBAVL} ${LIBZFS_CORE} ${LIBUUTIL} ${LIBBSDXML} ${LIBGEOM} \ + ${LIBNVPAIR} + +LDADD= -lmd -lpthread -lumem -lutil -luutil -lm -lnvpair -lavl \ + -lbsdxml -lgeom -lnvpair -lzfs_core SRCS= deviceid.c \ fsshare.c \ diff --git a/cddl/lib/libzpool/Makefile b/cddl/lib/libzpool/Makefile index 8f60a20..b80af04 100644 --- a/cddl/lib/libzpool/Makefile +++ b/cddl/lib/libzpool/Makefile @@ -56,8 +56,9 @@ CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/thread CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/sys CFLAGS+= -I${.CURDIR}/../../../lib/libthr/arch/${MACHINE_CPUARCH}/include -DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBZ} -LDADD= -lmd -lpthread -lz +DPADD= ${LIBMD} ${LIBPTHREAD} ${LIBZ} ${LIBNVPAIR} \ + ${LIBAVL} ${LIBUMEM} +LDADD= -lmd -lpthread -lz -lnvpair -lavl -lumem # atomic.S doesn't like profiling. MK_PROFILE= no -- cgit v1.1 From 91d5d12d67db05be29b36096bcb90e39e1541fae Mon Sep 17 00:00:00 2001 From: markj Date: Fri, 3 Oct 2014 23:20:37 +0000 Subject: Hook up support for userland CTF support in DTrace. This required some modifications to libproc to support fetching the CTF info for a given file. With this change, dtrace(1) is able to resolve type info for function and USDT probe arguments, and function return values. In particular, the args[n] syntax should now work for referencing arguments of userland probes, provided that the requisite CTF info is available. The uctf tests pass if the test programs are compiled with CTF info. The current infrastructure around the DTrace test suite doesn't support this yet. Differential Revision: https://reviews.freebsd.org/D891 MFC after: 1 month Relnotes: yes Sponsored by: EMC / Isilon Storage Division --- .../dtrace/test/tst/common/uctf/tst.userlandkey.ksh | 2 +- .../opensolaris/lib/libdtrace/common/dt_pid.c | 20 +------------------- cddl/lib/libdtrace/libproc_compat.h | 6 +++--- 3 files changed, 5 insertions(+), 23 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh index 072fca7..54d975f 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/uctf/tst.userlandkey.ksh @@ -38,7 +38,7 @@ fi ./$exe & pid=$! -$dtrace -32 -qs /dev/stdin <dtpd_mod; } -#else - obj = pdp->dtpd_mod; -#endif if ((pmp = Plmid_to_map(P, lmid, obj)) == NULL) return (NULL); -#if defined(sun) (void) Pobjname(P, pmp->pr_vaddr, m, sizeof (m)); if ((obj = strrchr(m, '/')) == NULL) obj = &m[0]; else obj++; +#if defined(sun) (void) Plmid(P, pmp->pr_vaddr, &lmid); #endif @@ -571,9 +563,7 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname) { struct ps_prochandle *P = data; GElf_Sym sym; -#if defined(sun) prsyminfo_t sip; -#endif dof_helper_t dh; GElf_Half e_type; const char *mname; @@ -852,11 +842,7 @@ dt_pid_get_types(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, ctf_funcinfo_t f; ctf_id_t argv[32]; GElf_Sym sym; -#if defined(sun) prsyminfo_t si; -#else - void *si; -#endif struct ps_prochandle *p; int i, args; char buf[DTRACE_ARGTYPELEN]; @@ -941,13 +927,11 @@ dt_pid_get_types(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, pdp->dtpd_func, pdp->dtpd_provider, pdp->dtpd_mod); goto out; } -#if defined(sun) if (ctf_func_info(fp, si.prs_id, &f) == CTF_ERR) { dt_dprintf("failed to get ctf information for %s in %s`%s\n", pdp->dtpd_func, pdp->dtpd_provider, pdp->dtpd_mod); goto out; } -#endif (void) snprintf(buf, sizeof (buf), "%s`%s", pdp->dtpd_provider, pdp->dtpd_mod); @@ -977,7 +961,6 @@ dt_pid_get_types(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, (void) ctf_type_qname(fp, f.ctc_return, adp->dtargd_native + ret, DTRACE_ARGTYPELEN - ret, buf); *nargs = 2; -#if defined(sun) } else { if (ctf_func_args(fp, si.prs_id, argc, argv) == CTF_ERR) goto out; @@ -993,7 +976,6 @@ dt_pid_get_types(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, (void) ctf_type_qname(fp, argv[i], adp->dtargd_native + ret, DTRACE_ARGTYPELEN - ret, buf); } -#endif } out: dt_proc_unlock(dtp, p); diff --git a/cddl/lib/libdtrace/libproc_compat.h b/cddl/lib/libdtrace/libproc_compat.h index 8443336..0d99d96 100644 --- a/cddl/lib/libdtrace/libproc_compat.h +++ b/cddl/lib/libdtrace/libproc_compat.h @@ -38,7 +38,7 @@ #define Pxlookup_by_addr(p, a, n, s, sym, i) \ proc_addr2sym(p, a, n, s, sym) #define Pxlookup_by_name(p, l, s1, s2, sym, a) \ - proc_name2sym((p), (s1), (s2), (sym)) + proc_name2sym(p, s1, s2, sym, a) #define Paddr_to_map proc_addr2map #define Pcreate_error strerror #define Pdelbkpt proc_bkptdel @@ -46,10 +46,10 @@ #define Plmid(p, a, l) (-1) #define Plmid_to_map(p, l, o) proc_obj2map((p), (o)) #define Plookup_by_addr proc_addr2sym -#define Pname_to_ctf(p, obj) NULL +#define Pname_to_ctf(p, obj) (ctf_file_t *)proc_name2ctf(p, obj) #define Pname_to_map proc_name2map #define Pobject_iter proc_iter_objs -#define Pobject_iter_resolved(p, f, arg) 1 +#define Pobject_iter_resolved(p, f, arg) proc_iter_objs(p, f, arg) #define Pobjname proc_objname #define Pread proc_read #define Prd_agent proc_rdagent -- cgit v1.1 From 33caf06b8f97faa86800b3207971b177f5a78fc5 Mon Sep 17 00:00:00 2001 From: delphij Date: Sat, 4 Oct 2014 07:56:50 +0000 Subject: MFV r272493: Show individual disk capacity when doing zpool list -v. Illumos issue: 5147 zpool list -v should show individual disk capacity MFC after: 1 week --- cddl/contrib/opensolaris/cmd/zpool/zpool_main.c | 83 +++++++++++++--------- .../opensolaris/lib/libzfs/common/libzfs_pool.c | 16 +++-- 2 files changed, 62 insertions(+), 37 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c index 8cb8091..31340b0 100644 --- a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c +++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c @@ -2857,10 +2857,7 @@ print_pool(zpool_handle_t *zhp, list_cbdata_t *cb) right_justify = B_FALSE; if (pl->pl_prop != ZPROP_INVAL) { - if (pl->pl_prop == ZPOOL_PROP_EXPANDSZ && - zpool_get_prop_int(zhp, pl->pl_prop, NULL) == 0) - propstr = "-"; - else if (zpool_get_prop(zhp, pl->pl_prop, property, + if (zpool_get_prop(zhp, pl->pl_prop, property, sizeof (property), NULL, cb->cb_literal) != 0) propstr = "-"; else @@ -2894,21 +2891,37 @@ print_pool(zpool_handle_t *zhp, list_cbdata_t *cb) } static void -print_one_column(zpool_prop_t prop, uint64_t value, boolean_t scripted) +print_one_column(zpool_prop_t prop, uint64_t value, boolean_t scripted, + boolean_t valid) { char propval[64]; boolean_t fixed; size_t width = zprop_width(prop, &fixed, ZFS_TYPE_POOL); - - if (prop == ZPOOL_PROP_EXPANDSZ && value == 0) - (void) strlcpy(propval, "-", sizeof (propval)); - else if (prop == ZPOOL_PROP_FRAGMENTATION && value == ZFS_FRAG_INVALID) - (void) strlcpy(propval, "-", sizeof (propval)); - else if (prop == ZPOOL_PROP_FRAGMENTATION) + switch (prop) { + case ZPOOL_PROP_EXPANDSZ: + if (value == 0) + (void) strlcpy(propval, "-", sizeof (propval)); + else + zfs_nicenum(value, propval, sizeof (propval)); + break; + case ZPOOL_PROP_FRAGMENTATION: + if (value == ZFS_FRAG_INVALID) { + (void) strlcpy(propval, "-", sizeof (propval)); + } else { + (void) snprintf(propval, sizeof (propval), "%llu%%", + value); + } + break; + case ZPOOL_PROP_CAPACITY: (void) snprintf(propval, sizeof (propval), "%llu%%", value); - else + break; + default: zfs_nicenum(value, propval, sizeof (propval)); + } + + if (!valid) + (void) strlcpy(propval, "-", sizeof (propval)); if (scripted) (void) printf("\t%s", propval); @@ -2930,6 +2943,9 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv, (uint64_t **)&vs, &c) == 0); if (name != NULL) { + boolean_t toplevel = (vs->vs_space != 0); + uint64_t cap; + if (scripted) (void) printf("\t%s", name); else if (strlen(name) + depth > cb->cb_namewidth) @@ -2938,24 +2954,26 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv, (void) printf("%*s%s%*s", depth, "", name, (int)(cb->cb_namewidth - strlen(name) - depth), ""); - /* only toplevel vdevs have capacity stats */ - if (vs->vs_space == 0) { - if (scripted) - (void) printf("\t-\t-\t-\t-"); - else - (void) printf(" - - - -"); - } else { - print_one_column(ZPOOL_PROP_SIZE, vs->vs_space, - scripted); - print_one_column(ZPOOL_PROP_CAPACITY, vs->vs_alloc, - scripted); - print_one_column(ZPOOL_PROP_FREE, - vs->vs_space - vs->vs_alloc, scripted); - print_one_column(ZPOOL_PROP_FRAGMENTATION, - vs->vs_fragmentation, scripted); - } - print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize, - scripted); + /* + * Print the properties for the individual vdevs. Some + * properties are only applicable to toplevel vdevs. The + * 'toplevel' boolean value is passed to the print_one_column() + * to indicate that the value is valid. + */ + print_one_column(ZPOOL_PROP_SIZE, vs->vs_space, scripted, + toplevel); + print_one_column(ZPOOL_PROP_ALLOCATED, vs->vs_alloc, scripted, + toplevel); + print_one_column(ZPOOL_PROP_FREE, vs->vs_space - vs->vs_alloc, + scripted, toplevel); + print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize, scripted, + B_TRUE); + print_one_column(ZPOOL_PROP_FRAGMENTATION, + vs->vs_fragmentation, scripted, + (vs->vs_fragmentation != ZFS_FRAG_INVALID && toplevel)); + cap = (vs->vs_space == 0) ? 0 : + (vs->vs_alloc * 100 / vs->vs_space); + print_one_column(ZPOOL_PROP_CAPACITY, cap, scripted, toplevel); (void) printf("\n"); } @@ -3024,7 +3042,8 @@ list_callback(zpool_handle_t *zhp, void *data) * -H Scripted mode. Don't display headers, and separate properties * by a single tab. * -o List of properties to display. Defaults to - * "name,size,allocated,free,capacity,health,altroot" + * "name,size,allocated,free,expandsize,fragmentation,capacity," + * "dedupratio,health,altroot" * -p Diplay values in parsable (exact) format. * -T Display a timestamp in date(1) or Unix format * @@ -3038,7 +3057,7 @@ zpool_do_list(int argc, char **argv) int ret; list_cbdata_t cb = { 0 }; static char default_props[] = - "name,size,allocated,free,fragmentation,expandsize,capacity," + "name,size,allocated,free,expandsize,fragmentation,capacity," "dedupratio,health,altroot"; char *props = default_props; unsigned long interval = 0, count = 0; diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c index 30b2d87..e09417a 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c @@ -22,7 +22,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2012, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2014 by Delphix. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. */ @@ -304,7 +304,6 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len, case ZPOOL_PROP_FREE: case ZPOOL_PROP_FREEING: case ZPOOL_PROP_LEAKED: - case ZPOOL_PROP_EXPANDSZ: if (literal) { (void) snprintf(buf, len, "%llu", (u_longlong_t)intval); @@ -312,7 +311,16 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len, (void) zfs_nicenum(intval, buf, len); } break; - + case ZPOOL_PROP_EXPANDSZ: + if (intval == 0) { + (void) strlcpy(buf, "-", len); + } else if (literal) { + (void) snprintf(buf, len, "%llu", + (u_longlong_t)intval); + } else { + (void) zfs_nicenum(intval, buf, len); + } + break; case ZPOOL_PROP_CAPACITY: if (literal) { (void) snprintf(buf, len, "%llu", @@ -330,13 +338,11 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len, (u_longlong_t)intval); } break; - case ZPOOL_PROP_DEDUPRATIO: (void) snprintf(buf, len, "%llu.%02llux", (u_longlong_t)(intval / 100), (u_longlong_t)(intval % 100)); break; - case ZPOOL_PROP_HEALTH: verify(nvlist_lookup_nvlist(zpool_get_config(zhp, NULL), ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); -- cgit v1.1 From 3f54b74af40b22333965b536b8a9aad1dba482e9 Mon Sep 17 00:00:00 2001 From: delphij Date: Mon, 6 Oct 2014 07:03:17 +0000 Subject: MFV r272585: Split the godfather zio into CPU number's to reduce lock contention. Illumos issue: 5176 lock contention on godfather zio MFC after: 2 weeks --- cddl/contrib/opensolaris/cmd/zdb/zdb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/zdb/zdb.c b/cddl/contrib/opensolaris/cmd/zdb/zdb.c index 04970fc..f7cacaa 100644 --- a/cddl/contrib/opensolaris/cmd/zdb/zdb.c +++ b/cddl/contrib/opensolaris/cmd/zdb/zdb.c @@ -2594,10 +2594,12 @@ dump_block_stats(spa_t *spa) * all async I/Os to complete. */ if (dump_opt['c']) { - (void) zio_wait(spa->spa_async_zio_root); - spa->spa_async_zio_root = zio_root(spa, NULL, NULL, - ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE | - ZIO_FLAG_GODFATHER); + for (int i = 0; i < max_ncpus; i++) { + (void) zio_wait(spa->spa_async_zio_root[i]); + spa->spa_async_zio_root[i] = zio_root(spa, NULL, NULL, + ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE | + ZIO_FLAG_GODFATHER); + } } if (zcb.zcb_haderrors) { -- cgit v1.1 From 72b086c52ce1483b4a1a258fce3db32ce687df75 Mon Sep 17 00:00:00 2001 From: delphij Date: Mon, 6 Oct 2014 07:09:47 +0000 Subject: MFV r272588: Handle old format deadlist. Illumos issue: 5178 zdb -vvvvv on old-format pool fails in dump_deadlist() MFC after: 2 weeks --- cddl/contrib/opensolaris/cmd/zdb/zdb.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/zdb/zdb.c b/cddl/contrib/opensolaris/cmd/zdb/zdb.c index f7cacaa..b82b034 100644 --- a/cddl/contrib/opensolaris/cmd/zdb/zdb.c +++ b/cddl/contrib/opensolaris/cmd/zdb/zdb.c @@ -1461,6 +1461,11 @@ dump_deadlist(dsl_deadlist_t *dl) if (dump_opt['d'] < 3) return; + if (dl->dl_oldfmt) { + dump_bpobj(&dl->dl_bpobj, "old-format deadlist", 0); + return; + } + zdb_nicenum(dl->dl_phys->dl_used, bytes); zdb_nicenum(dl->dl_phys->dl_comp, comp); zdb_nicenum(dl->dl_phys->dl_uncomp, uncomp); -- cgit v1.1 From a1e6db42da46ee181d41769f03e9d361096c4eab Mon Sep 17 00:00:00 2001 From: markj Date: Mon, 6 Oct 2014 21:52:40 +0000 Subject: Treat D keywords as identifiers in certain postfix expressions. This allows one to, for example, access the "provider" field of a struct g_consumer, even though "provider" is a D keyword. PR: 169657 MFC after: 2 months Discussed with: Bryan Cantrill Sponsored by: EMC / Isilon Storage Division --- .../opensolaris/lib/libdtrace/common/dt_grammar.y | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_grammar.y b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_grammar.y index 07790f4..6321b65 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_grammar.y +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_grammar.y @@ -207,6 +207,8 @@ %type unary_operator %type struct_or_union +%type dtrace_keyword_ident + %% dtrace_program: d_expression DT_TOK_EOF { return (dt_node_root($1)); } @@ -391,12 +393,18 @@ postfix_expression: | postfix_expression DT_TOK_DOT DT_TOK_TNAME { $$ = OP2(DT_TOK_DOT, $1, dt_node_ident($3)); } + | postfix_expression DT_TOK_DOT dtrace_keyword_ident { + $$ = OP2(DT_TOK_DOT, $1, dt_node_ident($3)); + } | postfix_expression DT_TOK_PTR DT_TOK_IDENT { $$ = OP2(DT_TOK_PTR, $1, dt_node_ident($3)); } | postfix_expression DT_TOK_PTR DT_TOK_TNAME { $$ = OP2(DT_TOK_PTR, $1, dt_node_ident($3)); } + | postfix_expression DT_TOK_PTR dtrace_keyword_ident { + $$ = OP2(DT_TOK_PTR, $1, dt_node_ident($3)); + } | postfix_expression DT_TOK_ADDADD { $$ = OP1(DT_TOK_POSTINC, $1); } @@ -411,6 +419,10 @@ postfix_expression: DT_TOK_TNAME DT_TOK_RPAR { $$ = dt_node_offsetof($3, $5); } + | DT_TOK_OFFSETOF DT_TOK_LPAR type_name DT_TOK_COMMA + dtrace_keyword_ident DT_TOK_RPAR { + $$ = dt_node_offsetof($3, $5); + } | DT_TOK_XLATE DT_TOK_LT type_name DT_TOK_GT DT_TOK_LPAR expression DT_TOK_RPAR { $$ = OP2(DT_TOK_XLATE, dt_node_type($3), $6); @@ -835,4 +847,15 @@ function_parameters: | parameter_type_list { $$ = $1; } ; +dtrace_keyword_ident: + DT_KEY_PROBE { $$ = DUP("probe"); } + | DT_KEY_PROVIDER { $$ = DUP("provider"); } + | DT_KEY_SELF { $$ = DUP("self"); } + | DT_KEY_STRING { $$ = DUP("string"); } + | DT_TOK_STRINGOF { $$ = DUP("stringof"); } + | DT_KEY_USERLAND { $$ = DUP("userland"); } + | DT_TOK_XLATE { $$ = DUP("xlate"); } + | DT_KEY_XLATOR { $$ = DUP("translator"); } + ; + %% -- cgit v1.1 From 80ce4ebd6fc32e4da5926785ee81126f7bdb4a25 Mon Sep 17 00:00:00 2001 From: delphij Date: Thu, 9 Oct 2014 06:02:53 +0000 Subject: MFV r272802: - Limit ARC for zdb at 256MB. zdb do not typically revisit data in the ARC. - Increase default max_inflight from 200 to 1000 (can be overriden by -I) so we can queue more I/Os when doing scrubbing. - Print status while loading meataslabs for leak detection. Illumos issues: 5169 zdb should limit its ARC size 5170 zdb -c should create more scrub i/os by default 5171 zdb should print status while loading metaslabs for leak detection MFC after: 2 weeks --- cddl/contrib/opensolaris/cmd/zdb/zdb.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/zdb/zdb.c b/cddl/contrib/opensolaris/cmd/zdb/zdb.c index b82b034..1fce5b6 100644 --- a/cddl/contrib/opensolaris/cmd/zdb/zdb.c +++ b/cddl/contrib/opensolaris/cmd/zdb/zdb.c @@ -76,8 +76,10 @@ #ifndef lint extern boolean_t zfs_recover; +extern uint64_t zfs_arc_max, zfs_arc_meta_limit; #else boolean_t zfs_recover; +uint64_t zfs_arc_max, zfs_arc_meta_limit; #endif const char cmdname[] = "zdb"; @@ -89,7 +91,7 @@ extern void dump_intent_log(zilog_t *); uint64_t *zopt_object = NULL; int zopt_objects = 0; libzfs_handle_t *g_zfs; -uint64_t max_inflight = 200; +uint64_t max_inflight = 1000; /* * These libumem hooks provide a reasonable set of defaults for the allocator's @@ -2382,7 +2384,7 @@ zdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, zcb->zcb_readfails = 0; - if (dump_opt['b'] < 5 && isatty(STDERR_FILENO) && + if (dump_opt['b'] < 5 && gethrtime() > zcb->zcb_lastprint + NANOSEC) { uint64_t now = gethrtime(); char buf[10]; @@ -2467,9 +2469,9 @@ zdb_leak_init(spa_t *spa, zdb_cb_t *zcb) if (!dump_opt['L']) { vdev_t *rvd = spa->spa_root_vdev; - for (int c = 0; c < rvd->vdev_children; c++) { + for (uint64_t c = 0; c < rvd->vdev_children; c++) { vdev_t *vd = rvd->vdev_child[c]; - for (int m = 0; m < vd->vdev_ms_count; m++) { + for (uint64_t m = 0; m < vd->vdev_ms_count; m++) { metaslab_t *msp = vd->vdev_ms[m]; mutex_enter(&msp->ms_lock); metaslab_unload(msp); @@ -2482,6 +2484,15 @@ zdb_leak_init(spa_t *spa, zdb_cb_t *zcb) * interfaces. */ if (msp->ms_sm != NULL) { + (void) fprintf(stderr, + "\rloading space map for " + "vdev %llu of %llu, " + "metaslab %llu of %llu ...", + (longlong_t)c, + (longlong_t)rvd->vdev_children, + (longlong_t)m, + (longlong_t)vd->vdev_ms_count); + msp->ms_ops = &zdb_metaslab_ops; VERIFY0(space_map_load(msp->ms_sm, msp->ms_tree, SM_ALLOC)); @@ -2490,6 +2501,7 @@ zdb_leak_init(spa_t *spa, zdb_cb_t *zcb) mutex_exit(&msp->ms_lock); } } + (void) fprintf(stderr, "\n"); } spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER); @@ -3490,6 +3502,12 @@ main(int argc, char **argv) usage(); } + /* + * ZDB does not typically re-read blocks; therefore limit the ARC + * to 256 MB, which can be used entirely for metadata. + */ + zfs_arc_max = zfs_arc_meta_limit = 256 * 1024 * 1024; + kernel_init(FREAD); g_zfs = libzfs_init(); ASSERT(g_zfs != NULL); -- cgit v1.1 From 676e30ae51658b12ca2fb5b6a81cc4c501ef35ac Mon Sep 17 00:00:00 2001 From: markj Date: Thu, 9 Oct 2014 17:45:58 +0000 Subject: Document the CPU+Pri_Class column rather than CPU+PRI, as the latter isn't used or implemented on FreeBSD. Reported by: kmacy Reviewed by: kmacy, rpaulo MFC after: 1 week Sponsored by: EMC / Isilon Storage Division --- cddl/contrib/opensolaris/cmd/lockstat/lockstat.1 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/lockstat/lockstat.1 b/cddl/contrib/opensolaris/cmd/lockstat/lockstat.1 index b634d45..a725c8b 100644 --- a/cddl/contrib/opensolaris/cmd/lockstat/lockstat.1 +++ b/cddl/contrib/opensolaris/cmd/lockstat/lockstat.1 @@ -21,7 +21,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 24, 2013 +.Dd October 8, 2014 .Dt LOCKSTAT 1 .Os .Sh NAME @@ -238,10 +238,11 @@ Average duration of the events in nanoseconds, as appropriate for the event. For the profiling event, duration means interrupt latency. .It Lock Address of the lock; displayed symbolically if possible. -.It CPU+PIL -CPU plus processor interrupt level (PIL). -For example, if CPU 4 is interrupted while at PIL 6, this will be reported as -cpu[4]+6. +.It CPU+Pri_Class +CPU plus the priority class of the interrupted thread. +For example, if CPU 4 is interrupted while running a timeshare thread, this +will be reported as +.Ql cpu[4]+TShar . .It Caller Address of the caller; displayed symbolically if possible. .El -- cgit v1.1 From c661f55b6cde9fc28d360a94d6e80c699d662bcc Mon Sep 17 00:00:00 2001 From: markj Date: Wed, 15 Oct 2014 03:15:46 +0000 Subject: Remove a build artifact of the USDT tests. MFC after: 3 days --- .../opensolaris/cmd/dtrace/test/tst/common/usdt/main.c | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/main.c (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/main.c b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/main.c deleted file mode 100644 index 9dc0a0e..0000000 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/main.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include "prov.h" - -int -main(int argc, char **argv, char **envp) -{ - envp[0] = (char*)0xff; - TESTER_ENTRY(); - return 0; -} -- cgit v1.1 From 0a28893572e896d12d1f833c89bf1dc0fcd64a47 Mon Sep 17 00:00:00 2001 From: gnn Date: Sun, 19 Oct 2014 23:13:16 +0000 Subject: Update the TCP structure used by DTrace to show the smoothed RTT. This will allow similar functionality to SIFTR to be built with DTrace. Submitted by: Grenville Armitage MFC after: 2 weeks --- cddl/lib/libdtrace/tcp.d | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cddl') diff --git a/cddl/lib/libdtrace/tcp.d b/cddl/lib/libdtrace/tcp.d index 7695e22..bf687a2 100644 --- a/cddl/lib/libdtrace/tcp.d +++ b/cddl/lib/libdtrace/tcp.d @@ -116,6 +116,7 @@ typedef struct tcpsinfo { uint32_t tcps_rto; /* round-trip timeout, msec */ uint32_t tcps_mss; /* max segment size */ int tcps_retransmit; /* retransmit send event, boolean */ + int tcps_srtt; /* smoothed RTT in units of (TCP_RTT_SCALE*hz) */ } tcpsinfo_t; /* @@ -200,6 +201,7 @@ translator tcpsinfo_t < struct tcpcb *p > { tcps_rto = p == NULL ? -1 : p->t_rxtcur / 1000; /* XXX */ tcps_mss = p == NULL ? -1 : p->t_maxseg; tcps_retransmit = p == NULL ? -1 : p->t_rxtshift > 0 ? 1 : 0; + tcps_srtt = p == NULL ? -1 : p->t_srtt; /* smoothed RTT in units of (TCP_RTT_SCALE*hz) */ }; #pragma D binding "1.6.3" translator -- cgit v1.1 From 78d7824866f39c18fed915795deed451f98af260 Mon Sep 17 00:00:00 2001 From: markj Date: Tue, 21 Oct 2014 05:19:08 +0000 Subject: Correct the calculation of tcps_rto in the struct tcpcb -> tcpsinfo_t translator. Submitted by: Grenville Armitage MFC after: 1 week --- cddl/lib/libdtrace/tcp.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cddl') diff --git a/cddl/lib/libdtrace/tcp.d b/cddl/lib/libdtrace/tcp.d index bf687a2..4b826f1 100644 --- a/cddl/lib/libdtrace/tcp.d +++ b/cddl/lib/libdtrace/tcp.d @@ -198,7 +198,7 @@ translator tcpsinfo_t < struct tcpcb *p > { tcps_cwnd_ssthresh = p == NULL ? -1 : p->snd_ssthresh; tcps_sack_fack = p == NULL ? 0 : p->snd_fack; tcps_sack_snxt = p == NULL ? 0 : p->sack_newdata; - tcps_rto = p == NULL ? -1 : p->t_rxtcur / 1000; /* XXX */ + tcps_rto = p == NULL ? -1 : (p->t_rxtcur * 1000) / `hz; tcps_mss = p == NULL ? -1 : p->t_maxseg; tcps_retransmit = p == NULL ? -1 : p->t_rxtshift > 0 ? 1 : 0; tcps_srtt = p == NULL ? -1 : p->t_srtt; /* smoothed RTT in units of (TCP_RTT_SCALE*hz) */ -- cgit v1.1 From e284683f7403722e686c812dc2003488e2ada9e0 Mon Sep 17 00:00:00 2001 From: delphij Date: Sat, 8 Nov 2014 07:30:40 +0000 Subject: MFV r274271: Improve zdb -b performance: - Reduce gethrtime() call to 1/100th of blkptr's; - Skip manipulating the size-ordered tree; - Issue more (10, previously 3) async reads; - Use lighter weight testing in traverse_visitbp(); Illumos issue: 5243 zdb -b could be much faster MFC after: 2 weeks --- cddl/contrib/opensolaris/cmd/zdb/zdb.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/zdb/zdb.c b/cddl/contrib/opensolaris/cmd/zdb/zdb.c index 1fce5b6..c2c47d5 100644 --- a/cddl/contrib/opensolaris/cmd/zdb/zdb.c +++ b/cddl/contrib/opensolaris/cmd/zdb/zdb.c @@ -77,9 +77,11 @@ #ifndef lint extern boolean_t zfs_recover; extern uint64_t zfs_arc_max, zfs_arc_meta_limit; +extern int zfs_vdev_async_read_max_active; #else boolean_t zfs_recover; uint64_t zfs_arc_max, zfs_arc_meta_limit; +int zfs_vdev_async_read_max_active; #endif const char cmdname[] = "zdb"; @@ -2384,8 +2386,14 @@ zdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, zcb->zcb_readfails = 0; - if (dump_opt['b'] < 5 && - gethrtime() > zcb->zcb_lastprint + NANOSEC) { + /* only call gethrtime() every 100 blocks */ + static int iters; + if (++iters > 100) + iters = 0; + else + return (0); + + if (dump_opt['b'] < 5 && gethrtime() > zcb->zcb_lastprint + NANOSEC) { uint64_t now = gethrtime(); char buf[10]; uint64_t bytes = zcb->zcb_type[ZB_TOTAL][ZDB_OT_TOTAL].zb_asize; @@ -2494,6 +2502,14 @@ zdb_leak_init(spa_t *spa, zdb_cb_t *zcb) (longlong_t)vd->vdev_ms_count); msp->ms_ops = &zdb_metaslab_ops; + + /* + * We don't want to spend the CPU + * manipulating the size-ordered + * tree, so clear the range_tree + * ops. + */ + msp->ms_tree->rt_ops = NULL; VERIFY0(space_map_load(msp->ms_sm, msp->ms_tree, SM_ALLOC)); msp->ms_loaded = B_TRUE; @@ -3508,6 +3524,13 @@ main(int argc, char **argv) */ zfs_arc_max = zfs_arc_meta_limit = 256 * 1024 * 1024; + /* + * "zdb -c" uses checksum-verifying scrub i/os which are async reads. + * "zdb -b" uses traversal prefetch which uses async reads. + * For good performance, let several of them be active at once. + */ + zfs_vdev_async_read_max_active = 10; + kernel_init(FREAD); g_zfs = libzfs_init(); ASSERT(g_zfs != NULL); -- cgit v1.1 From ce17e1128b9651166225d52c6f3a52b89a048716 Mon Sep 17 00:00:00 2001 From: delphij Date: Sun, 9 Nov 2014 01:42:28 +0000 Subject: Apply upstream 13597:3eac1e8e0f4c (git: illumos-gate@aa846ad9): Initialize tqent_flags in the userland taskq implementation. Without this the assertion of tq->tq_freelist != NULL may fail in taskq_destroy. The problem is that tqent_flags is never initialized in the userland implementation while the kernel one does initialize it. Without proper initialization, the flag may have its lowest bit set, making it treated as TQENT_FLAG_PREALLOC and never removing taskq_ent_t from tq_freelist. MFC after: 2 weeks --- cddl/contrib/opensolaris/lib/libzpool/common/taskq.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c b/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c index d4036d0..785f106 100644 --- a/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c +++ b/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c @@ -24,6 +24,7 @@ */ /* * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + * Copyright 2012 Garrett D'Amore . All rights reserved. */ #include @@ -136,6 +137,7 @@ taskq_dispatch(taskq_t *tq, task_func_t func, void *arg, uint_t tqflags) t->tqent_prev->tqent_next = t; t->tqent_func = func; t->tqent_arg = arg; + t->tqent_flags = 0; cv_signal(&tq->tq_dispatch_cv); mutex_exit(&tq->tq_lock); return (1); -- cgit v1.1 From 0d7beefb910ec2b91d59cdbd90c0073e466f36c4 Mon Sep 17 00:00:00 2001 From: delphij Date: Sun, 9 Nov 2014 07:37:00 +0000 Subject: MFV r274272 and diff reduction with upstream. Illumos issue: 5244 zio pipeline callers should explicitly invoke next stage Tested with: ztest plus ZFS over GELI configuration MFC after: 1 month --- cddl/contrib/opensolaris/lib/libzpool/common/taskq.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c b/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c index 785f106..26d9f36 100644 --- a/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c +++ b/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c @@ -25,6 +25,7 @@ /* * Copyright 2011 Nexenta Systems, Inc. All rights reserved. * Copyright 2012 Garrett D'Amore . All rights reserved. + * Copyright (c) 2014 by Delphix. All rights reserved. */ #include @@ -33,8 +34,10 @@ int taskq_now; taskq_t *system_taskq; #define TASKQ_ACTIVE 0x00010000 +#define TASKQ_NAMELEN 31 struct taskq { + char tq_name[TASKQ_NAMELEN + 1]; kmutex_t tq_lock; krwlock_t tq_threadlock; kcondvar_t tq_dispatch_cv; @@ -247,6 +250,7 @@ taskq_create(const char *name, int nthreads, pri_t pri, cv_init(&tq->tq_dispatch_cv, NULL, CV_DEFAULT, NULL); cv_init(&tq->tq_wait_cv, NULL, CV_DEFAULT, NULL); cv_init(&tq->tq_maxalloc_cv, NULL, CV_DEFAULT, NULL); + (void) strncpy(tq->tq_name, name, TASKQ_NAMELEN + 1); tq->tq_flags = flags | TASKQ_ACTIVE; tq->tq_active = nthreads; tq->tq_nthreads = nthreads; -- cgit v1.1 From fe03d9b9d26fcae476fe7e7fa57516b0fa684089 Mon Sep 17 00:00:00 2001 From: delphij Date: Mon, 10 Nov 2014 08:20:21 +0000 Subject: MFV r274273: ZFS large block support. Please note that booting from datasets that have recordsize greater than 128KB is not supported (but it's Okay to enable the feature on the pool). This *may* remain unchanged because of memory constraint. Limited safety belt is provided for mounted root filesystem but use caution is advised. Illumos issue: 5027 zfs large block support MFC after: 1 month --- cddl/contrib/opensolaris/cmd/zdb/zdb.c | 32 +++++++++++++-- cddl/contrib/opensolaris/cmd/zfs/zfs.8 | 48 +++++++++++++++++++--- cddl/contrib/opensolaris/cmd/zfs/zfs_main.c | 11 +++-- .../contrib/opensolaris/cmd/zpool/zpool-features.7 | 29 ++++++++++++- .../opensolaris/cmd/zstreamdump/zstreamdump.c | 19 +++++++-- cddl/contrib/opensolaris/cmd/ztest/ztest.c | 14 +++++-- .../contrib/opensolaris/lib/libzfs/common/libzfs.h | 3 ++ .../opensolaris/lib/libzfs/common/libzfs_dataset.c | 39 ++++++++++++------ .../lib/libzfs/common/libzfs_sendrecv.c | 15 ++++--- .../lib/libzfs_core/common/libzfs_core.c | 6 +++ .../lib/libzfs_core/common/libzfs_core.h | 3 +- 11 files changed, 180 insertions(+), 39 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/zdb/zdb.c b/cddl/contrib/opensolaris/cmd/zdb/zdb.c index c2c47d5..47ab7bf 100644 --- a/cddl/contrib/opensolaris/cmd/zdb/zdb.c +++ b/cddl/contrib/opensolaris/cmd/zdb/zdb.c @@ -2147,6 +2147,8 @@ dump_label(const char *dev) (void) close(fd); } +static uint64_t num_large_blocks; + /*ARGSUSED*/ static int dump_one_dir(const char *dsname, void *arg) @@ -2159,6 +2161,8 @@ dump_one_dir(const char *dsname, void *arg) (void) printf("Could not open %s, error %d\n", dsname, error); return (0); } + if (dmu_objset_ds(os)->ds_large_blocks) + num_large_blocks++; dump_dir(os); dmu_objset_disown(os, FTAG); fuid_table_destroy(); @@ -2169,7 +2173,7 @@ dump_one_dir(const char *dsname, void *arg) /* * Block statistics. */ -#define PSIZE_HISTO_SIZE (SPA_MAXBLOCKSIZE / SPA_MINBLOCKSIZE + 1) +#define PSIZE_HISTO_SIZE (SPA_OLD_MAXBLOCKSIZE / SPA_MINBLOCKSIZE + 2) typedef struct zdb_blkstats { uint64_t zb_asize; uint64_t zb_lsize; @@ -2234,7 +2238,15 @@ zdb_count_block(zdb_cb_t *zcb, zilog_t *zilog, const blkptr_t *bp, zb->zb_lsize += BP_GET_LSIZE(bp); zb->zb_psize += BP_GET_PSIZE(bp); zb->zb_count++; - zb->zb_psize_histogram[BP_GET_PSIZE(bp) >> SPA_MINBLOCKSHIFT]++; + + /* + * The histogram is only big enough to record blocks up to + * SPA_OLD_MAXBLOCKSIZE; larger blocks go into the last, + * "other", bucket. + */ + int idx = BP_GET_PSIZE(bp) >> SPA_MINBLOCKSHIFT; + idx = MIN(idx, SPA_OLD_MAXBLOCKSIZE / SPA_MINBLOCKSIZE + 1); + zb->zb_psize_histogram[idx]++; zb->zb_gangs += BP_COUNT_GANG(bp); @@ -2946,6 +2958,7 @@ dump_zpool(spa_t *spa) dump_metaslab_groups(spa); if (dump_opt['d'] || dump_opt['i']) { + uint64_t refcount; dump_dir(dp->dp_meta_objset); if (dump_opt['d'] >= 3) { dump_bpobj(&spa->spa_deferred_bpobj, @@ -2965,8 +2978,21 @@ dump_zpool(spa_t *spa) } (void) dmu_objset_find(spa_name(spa), dump_one_dir, NULL, DS_FIND_SNAPSHOTS | DS_FIND_CHILDREN); + + (void) feature_get_refcount(spa, + &spa_feature_table[SPA_FEATURE_LARGE_BLOCKS], &refcount); + if (num_large_blocks != refcount) { + (void) printf("large_blocks feature refcount mismatch: " + "expected %lld != actual %lld\n", + (longlong_t)num_large_blocks, + (longlong_t)refcount); + rc = 2; + } else { + (void) printf("Verified large_blocks feature refcount " + "is correct (%llu)\n", (longlong_t)refcount); + } } - if (dump_opt['b'] || dump_opt['c']) + if (rc == 0 && (dump_opt['b'] || dump_opt['c'])) rc = dump_block_stats(spa); if (rc == 0) diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs.8 b/cddl/contrib/opensolaris/cmd/zfs/zfs.8 index 2315e05..065497f 100644 --- a/cddl/contrib/opensolaris/cmd/zfs/zfs.8 +++ b/cddl/contrib/opensolaris/cmd/zfs/zfs.8 @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 30, 2014 +.Dd November 10, 2014 .Dt ZFS 8 .Os .Sh NAME @@ -179,12 +179,12 @@ .Ar bookmark .Nm .Cm send -.Op Fl DnPpRve +.Op Fl DnPpRveL .Op Fl i Ar snapshot | Fl I Ar snapshot .Ar snapshot .Nm .Cm send -.Op Fl e +.Op Fl eL .Op Fl i Ar snapshot Ns | Ns bookmark .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot .Nm @@ -1187,6 +1187,12 @@ systems is strongly discouraged, and may adversely affect performance. .Pp The size specified must be a power of two greater than or equal to 512 and less than or equal to 128 Kbytes. +If the +.Sy large_blocks +feature is enabled on the pool, the size may be up to 1 Mbyte. +See +.Xr zpool-features 7 +for details on ZFS feature flags. .Pp Changing the file system's .Sy recordsize @@ -2477,7 +2483,7 @@ feature. .It Xo .Nm .Cm send -.Op Fl DnPpRve +.Op Fl DnPpRveL .Op Fl i Ar snapshot | Fl I Ar snapshot .Ar snapshot .Xc @@ -2549,6 +2555,22 @@ be used regardless of the dataset's property, but performance will be much better if the filesystem uses a dedup-capable checksum (eg. .Sy sha256 ) . +.It Fl L +Generate a stream which may contain blocks larger than 128KB. +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. +The receiving system must have the +.Sy large_blocks +pool feature enabled as well. +See +.Xr zpool-features 7 +for details on ZFS feature flags and the +.Sy large_blocks +feature. .It Fl e Generate a more compact stream by using WRITE_EMBEDDED records for blocks which are stored more compactly on disk by the @@ -2596,7 +2618,7 @@ on future versions of .It Xo .Nm .Cm send -.Op Fl e +.Op Fl eL .Op Fl i Ar snapshot Ns | Ns Ar bookmark .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot .Xc @@ -2622,6 +2644,22 @@ specified as the last component of the name If the incremental target is a clone, the incremental source can be the origin snapshot, or an earlier snapshot in the origin's filesystem, or the origin's origin, etc. +.It Fl L +Generate a stream which may contain blocks larger than 128KB. +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. +The receiving system must have the +.Sy large_blocks +pool feature enabled as well. +See +.Xr zpool-features 7 +for details on ZFS feature flags and the +.Sy large_blocks +feature. .It Fl e Generate a more compact stream by using WRITE_EMBEDDED records for blocks which are stored more compactly on disk by the diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c b/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c index a3b461e..baac993 100644 --- a/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c +++ b/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c @@ -274,9 +274,9 @@ get_usage(zfs_help_t idx) case HELP_ROLLBACK: return (gettext("\trollback [-rRf] \n")); case HELP_SEND: - return (gettext("\tsend [-DnPpRve] [-[iI] snapshot] " + return (gettext("\tsend [-DnPpRvLe] [-[iI] snapshot] " "\n" - "\tsend [-e] [-i snapshot|bookmark] " + "\tsend [-Le] [-i snapshot|bookmark] " "\n")); case HELP_SET: return (gettext("\tset " @@ -3709,7 +3709,7 @@ zfs_do_send(int argc, char **argv) boolean_t extraverbose = B_FALSE; /* check options */ - while ((c = getopt(argc, argv, ":i:I:RDpvnPe")) != -1) { + while ((c = getopt(argc, argv, ":i:I:RDpvnPLe")) != -1) { switch (c) { case 'i': if (fromname) @@ -3744,6 +3744,9 @@ zfs_do_send(int argc, char **argv) case 'n': flags.dryrun = B_TRUE; break; + case 'L': + flags.largeblock = B_TRUE; + break; case 'e': flags.embed_data = B_TRUE; break; @@ -3800,6 +3803,8 @@ zfs_do_send(int argc, char **argv) if (zhp == NULL) return (1); + if (flags.largeblock) + lzc_flags |= LZC_SEND_FLAG_LARGE_BLOCK; if (flags.embed_data) lzc_flags |= LZC_SEND_FLAG_EMBED_DATA; diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7 b/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7 index 27e63a9..d855f16 100644 --- a/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7 +++ b/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7 @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 1, 2014 +.Dd November 10, 2014 .Dt ZPOOL-FEATURES 7 .Os .Sh NAME @@ -427,6 +427,33 @@ This feature becomes as soon as it is enabled and will never return to being .Sy enabled . +.It Sy large_blocks +.Bl -column "READ\-ONLY COMPATIBLE" "org.open-zfs:large_block" +.It GUID Ta org.open-zfs:large_block +.It READ\-ONLY COMPATIBLE Ta no +.It DEPENDENCIES Ta extensible_dataset +.El +.Pp +The +.Sy large_block +feature allows the record size on a dataset to be +set larger than 128KB. +.Pp +This feature becomes +.Sy active +once a +.Sy recordsize +property has been set larger than 128KB, and will return to being +.Sy enabled +once all filesystems that have ever had their recordsize larger than 128KB +are destroyed. +.Pp +Please note that booting from datasets that have recordsize greater than +128KB is +.Em NOT +supported by the +.Fx +boot loader. .El .Sh SEE ALSO .Xr zpool 8 diff --git a/cddl/contrib/opensolaris/cmd/zstreamdump/zstreamdump.c b/cddl/contrib/opensolaris/cmd/zstreamdump/zstreamdump.c index dce1cb3..d99d801 100644 --- a/cddl/contrib/opensolaris/cmd/zstreamdump/zstreamdump.c +++ b/cddl/contrib/opensolaris/cmd/zstreamdump/zstreamdump.c @@ -54,7 +54,6 @@ uint64_t total_stream_len = 0; FILE *send_stream = 0; boolean_t do_byteswap = B_FALSE; boolean_t do_cksum = B_TRUE; -#define INITIAL_BUFLEN (1<<20) static void usage(void) @@ -67,6 +66,18 @@ usage(void) exit(1); } +static void * +safe_malloc(size_t size) +{ + void *rv = malloc(size); + if (rv == NULL) { + (void) fprintf(stderr, "ERROR; failed to allocate %zu bytes\n", + size); + abort(); + } + return (rv); +} + /* * ssread - send stream read. * @@ -158,7 +169,7 @@ print_block(char *buf, int length) int main(int argc, char *argv[]) { - char *buf = malloc(INITIAL_BUFLEN); + char *buf = safe_malloc(SPA_MAXBLOCKSIZE); uint64_t drr_record_count[DRR_NUMTYPES] = { 0 }; uint64_t total_records = 0; dmu_replay_record_t thedrr; @@ -307,9 +318,9 @@ main(int argc, char *argv[]) nvlist_t *nv; int sz = drr->drr_payloadlen; - if (sz > INITIAL_BUFLEN) { + if (sz > SPA_MAXBLOCKSIZE) { free(buf); - buf = malloc(sz); + buf = safe_malloc(sz); } (void) ssread(buf, sz, &zc); if (ferror(send_stream)) diff --git a/cddl/contrib/opensolaris/cmd/ztest/ztest.c b/cddl/contrib/opensolaris/cmd/ztest/ztest.c index 5ed87ce..ab69154 100644 --- a/cddl/contrib/opensolaris/cmd/ztest/ztest.c +++ b/cddl/contrib/opensolaris/cmd/ztest/ztest.c @@ -987,9 +987,15 @@ ztest_spa_get_ashift() { static int ztest_random_blocksize(void) { - // Choose a block size >= the ashift. - uint64_t block_shift = - ztest_random(SPA_MAXBLOCKSHIFT - ztest_spa_get_ashift() + 1); + uint64_t block_shift; + /* + * Choose a block size >= the ashift. + * If the SPA supports new MAXBLOCKSIZE, test up to 1MB blocks. + */ + int maxbs = SPA_OLD_MAXBLOCKSHIFT; + if (spa_maxblocksize(ztest_spa) == SPA_MAXBLOCKSIZE) + maxbs = 20; + block_shift = ztest_random(maxbs - ztest_spa_get_ashift() + 1); return (1 << (SPA_MINBLOCKSHIFT + block_shift)); } @@ -4789,7 +4795,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id) char path0[MAXPATHLEN]; char pathrand[MAXPATHLEN]; size_t fsize; - int bshift = SPA_MAXBLOCKSHIFT + 2; /* don't scrog all labels */ + int bshift = SPA_OLD_MAXBLOCKSHIFT + 2; /* don't scrog all labels */ int iters = 1000; int maxfaults; int mirror_save; diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h index ef18b45..8a707d1 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h @@ -609,6 +609,9 @@ typedef struct sendflags { /* show progress (ie. -v) */ boolean_t progress; + /* large blocks (>128K) are permitted */ + boolean_t largeblock; + /* WRITE_EMBEDDED records of type DATA are permitted */ boolean_t embed_data; } sendflags_t; diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c index 265038a..063df4a 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c @@ -1080,21 +1080,36 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl, break; } - case ZFS_PROP_RECORDSIZE: case ZFS_PROP_VOLBLOCKSIZE: - /* must be power of two within SPA_{MIN,MAX}BLOCKSIZE */ + case ZFS_PROP_RECORDSIZE: + { + int maxbs = SPA_MAXBLOCKSIZE; + if (zhp != NULL) { + maxbs = zpool_get_prop_int(zhp->zpool_hdl, + ZPOOL_PROP_MAXBLOCKSIZE, NULL); + } + /* + * Volumes are limited to a volblocksize of 128KB, + * because they typically service workloads with + * small random writes, which incur a large performance + * penalty with large blocks. + */ + if (prop == ZFS_PROP_VOLBLOCKSIZE) + maxbs = SPA_OLD_MAXBLOCKSIZE; + /* + * The value must be a power of two between + * SPA_MINBLOCKSIZE and maxbs. + */ if (intval < SPA_MINBLOCKSIZE || - intval > SPA_MAXBLOCKSIZE || !ISP2(intval)) { + intval > maxbs || !ISP2(intval)) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "'%s' must be power of 2 from %u " - "to %uk"), propname, - (uint_t)SPA_MINBLOCKSIZE, - (uint_t)SPA_MAXBLOCKSIZE >> 10); + "'%s' must be power of 2 from 512B " + "to %uKB"), propname, maxbs >> 10); (void) zfs_error(hdl, EZFS_BADPROP, errbuf); goto error; } break; - + } case ZFS_PROP_MLSLABEL: { #ifdef sun @@ -1471,7 +1486,9 @@ zfs_setprop_error(libzfs_handle_t *hdl, zfs_prop_t prop, int err, break; case ERANGE: - if (prop == ZFS_PROP_COMPRESSION) { + case EDOM: + if (prop == ZFS_PROP_COMPRESSION || + prop == ZFS_PROP_RECORDSIZE) { (void) zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "property setting is not allowed on " "bootable datasets")); @@ -3197,9 +3214,7 @@ zfs_create(libzfs_handle_t *hdl, const char *path, zfs_type_t type, case EDOM: zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "volume block size must be power of 2 from " - "%u to %uk"), - (uint_t)SPA_MINBLOCKSIZE, - (uint_t)SPA_MAXBLOCKSIZE >> 10); + "512B to 128KB")); return (zfs_error(hdl, EZFS_BADPROP, errbuf)); diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c index 97f18d7..91857b6 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c @@ -215,7 +215,7 @@ static void * cksummer(void *arg) { dedup_arg_t *dda = arg; - char *buf = malloc(1<<20); + char *buf = zfs_alloc(dda->dedup_hdl, SPA_MAXBLOCKSIZE); dmu_replay_record_t thedrr; dmu_replay_record_t *drr = &thedrr; struct drr_begin *drrb = &thedrr.drr_u.drr_begin; @@ -280,9 +280,9 @@ cksummer(void *arg) DMU_COMPOUNDSTREAM && drr->drr_payloadlen != 0) { int sz = drr->drr_payloadlen; - if (sz > 1<<20) { - free(buf); - buf = malloc(sz); + if (sz > SPA_MAXBLOCKSIZE) { + buf = zfs_realloc(dda->dedup_hdl, buf, + SPA_MAXBLOCKSIZE, sz); } (void) ssread(buf, sz, ofp); if (ferror(stdin)) @@ -815,7 +815,7 @@ typedef struct send_dump_data { char prevsnap[ZFS_MAXNAMELEN]; uint64_t prevsnap_obj; boolean_t seenfrom, seento, replicate, doall, fromorigin; - boolean_t verbose, dryrun, parsable, progress, embed_data; + boolean_t verbose, dryrun, parsable, progress, embed_data, large_block; int outfd; boolean_t err; nvlist_t *fss; @@ -1163,6 +1163,8 @@ dump_snapshot(zfs_handle_t *zhp, void *arg) } enum lzc_send_flags flags = 0; + if (sdd->large_block) + flags |= LZC_SEND_FLAG_LARGE_BLOCK; if (sdd->embed_data) flags |= LZC_SEND_FLAG_EMBED_DATA; @@ -1511,6 +1513,7 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap, sdd.parsable = flags->parsable; sdd.progress = flags->progress; sdd.dryrun = flags->dryrun; + sdd.large_block = flags->largeblock; sdd.embed_data = flags->embed_data; sdd.filter_cb = filter_func; sdd.filter_cb_arg = cb_arg; @@ -2545,7 +2548,7 @@ static int recv_skip(libzfs_handle_t *hdl, int fd, boolean_t byteswap) { dmu_replay_record_t *drr; - void *buf = malloc(1<<20); + void *buf = zfs_alloc(hdl, SPA_MAXBLOCKSIZE); char errbuf[1024]; (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, diff --git a/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c b/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c index cb38dc2..52bd580 100644 --- a/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c +++ b/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c @@ -502,6 +502,10 @@ lzc_get_holds(const char *snapname, nvlist_t **holdsp) * * "fd" is the file descriptor to write the send stream to. * + * If "flags" contains LZC_SEND_FLAG_LARGE_BLOCK, the stream is permitted + * to contain DRR_WRITE records with drr_length > 128K, and DRR_OBJECT + * records with drr_blksz > 128K. + * * If "flags" contains LZC_SEND_FLAG_EMBED_DATA, the stream is permitted * to contain DRR_WRITE_EMBEDDED records with drr_etype==BP_EMBEDDED_TYPE_DATA, * which the receiving system must support (as indicated by support @@ -518,6 +522,8 @@ lzc_send(const char *snapname, const char *from, int fd, fnvlist_add_int32(args, "fd", fd); if (from != NULL) fnvlist_add_string(args, "fromsnap", from); + if (flags & LZC_SEND_FLAG_LARGE_BLOCK) + fnvlist_add_boolean(args, "largeblockok"); if (flags & LZC_SEND_FLAG_EMBED_DATA) fnvlist_add_boolean(args, "embedok"); err = lzc_ioctl(ZFS_IOC_SEND_NEW, snapname, args, NULL); diff --git a/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h b/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h index 99883fe..b6a4c12 100644 --- a/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h +++ b/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h @@ -54,7 +54,8 @@ int lzc_release(nvlist_t *, nvlist_t **); int lzc_get_holds(const char *, nvlist_t **); enum lzc_send_flags { - LZC_SEND_FLAG_EMBED_DATA = 1 << 0 + LZC_SEND_FLAG_EMBED_DATA = 1 << 0, + LZC_SEND_FLAG_LARGE_BLOCK = 1 << 1 }; int lzc_send(const char *, const char *, int, enum lzc_send_flags); -- cgit v1.1 From 14548525ed746ca00565a8c2f499c9659d2650f2 Mon Sep 17 00:00:00 2001 From: gjb Date: Wed, 12 Nov 2014 08:36:42 +0000 Subject: Fix an mdoc(7) macro that is not an option in the provided description. Bump Dd. As CDDL License dictates, update the Copyright accordingly. Sponsored by: The FreeBSD Foundation --- cddl/contrib/opensolaris/cmd/zfs/zfs.8 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs.8 b/cddl/contrib/opensolaris/cmd/zfs/zfs.8 index 065497f..e37b148 100644 --- a/cddl/contrib/opensolaris/cmd/zfs/zfs.8 +++ b/cddl/contrib/opensolaris/cmd/zfs/zfs.8 @@ -27,10 +27,11 @@ .\" Copyright (c) 2014, Joyent, Inc. All rights reserved. .\" Copyright (c) 2013, Steven Hartland .\" Copyright (c) 2014, Xin LI +.\" Copyright (c) 2014, The FreeBSD Foundation, All Rights Reserved. .\" .\" $FreeBSD$ .\" -.Dd November 10, 2014 +.Dd November 12, 2014 .Dt ZFS 8 .Os .Sh NAME @@ -1791,7 +1792,7 @@ descendent file systems. Recursively destroy all clones of these snapshots, including the clones, snapshots, and children. If this flag is specified, the -.Op fl d +.Fl d flag will have no effect. .It Fl n Do a dry-run ("No-op") deletion. No data will be deleted. This is useful in -- cgit v1.1 From cf680a80e86f94a7c5c40aea2c8ffc1b8a5581b7 Mon Sep 17 00:00:00 2001 From: markj Date: Sun, 16 Nov 2014 04:07:53 +0000 Subject: Fix a couple of bugs around the handling of structs and unions of size zero. These would cause ctfconvert(1) to return an error when attempting to resolve valid C types. Reviewed by: Robert Mustacchi MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Division --- cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c b/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c index 55ce7b2..5dfeab3 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c @@ -766,7 +766,8 @@ die_array_resolve(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private) debug(3, "trying to resolve array %d (cont %d)\n", tdp->t_id, tdp->t_ardef->ad_contents->t_id); - if ((sz = tdesc_size(tdp->t_ardef->ad_contents)) == 0) { + if ((sz = tdesc_size(tdp->t_ardef->ad_contents)) == 0 && + (tdp->t_ardef->ad_contents->t_flags & TDESC_F_RESOLVED) == 0) { debug(3, "unable to resolve array %s (%d) contents %d\n", tdesc_name(tdp), tdp->t_id, tdp->t_ardef->ad_contents->t_id); @@ -1138,12 +1139,17 @@ die_sou_resolve(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private) /* * For empty members, or GCC/C99 flexible array - * members, a size of 0 is correct. + * members, a size of 0 is correct. Structs and unions + * consisting of flexible array members will also have + * size 0. */ if (mt->t_members == NULL) continue; if (mt->t_type == ARRAY && mt->t_ardef->ad_nelems == 0) continue; + if ((mt->t_flags & TDESC_F_RESOLVED) != 0 && + (mt->t_type == STRUCT || mt->t_type == UNION)) + continue; dw->dw_nunres++; return (1); -- cgit v1.1 From e37e6f308b66649e54d5a5dce66e115059110639 Mon Sep 17 00:00:00 2001 From: markj Date: Sun, 16 Nov 2014 04:10:23 +0000 Subject: Remove an incorrect optimization. The type IDs of each member of a struct or union must be checked when determine whether two types are equivalent. This bug could cause ctfmerge(1) to incorrectly merge distinct types. Reviewed by: Robert Mustacchi MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Division --- cddl/contrib/opensolaris/tools/ctf/cvt/merge.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c b/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c index 2ef37d4..27966af 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c @@ -287,19 +287,11 @@ equiv_su(tdesc_t *stdp, tdesc_t *ttdp, equiv_data_t *ed) while (ml1 && ml2) { if (ml1->ml_offset != ml2->ml_offset || - strcmp(ml1->ml_name, ml2->ml_name) != 0) + strcmp(ml1->ml_name, ml2->ml_name) != 0 || + ml1->ml_size != ml2->ml_size || + !equiv_node(ml1->ml_type, ml2->ml_type, ed)) return (0); - /* - * Don't do the recursive equivalency checking more than - * we have to. - */ - if (olm1 == NULL || olm1->ml_type->t_id != ml1->ml_type->t_id) { - if (ml1->ml_size != ml2->ml_size || - !equiv_node(ml1->ml_type, ml2->ml_type, ed)) - return (0); - } - olm1 = ml1; ml1 = ml1->ml_next; ml2 = ml2->ml_next; -- cgit v1.1 From bafd3cee870206d940f33ef3db01ad0413ef40ae Mon Sep 17 00:00:00 2001 From: markj Date: Sun, 16 Nov 2014 04:13:42 +0000 Subject: Only compare visitation counters if they've both been set for the current type graph walk. Reviewed by: Robert Mustacchi MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Division --- cddl/contrib/opensolaris/tools/ctf/cvt/merge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c b/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c index 27966af..d366f31 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/merge.c @@ -349,7 +349,7 @@ equiv_node(tdesc_t *ctdp, tdesc_t *mtdp, equiv_data_t *ed) int (*equiv)(tdesc_t *, tdesc_t *, equiv_data_t *); int mapping; - if (ctdp->t_emark > ed->ed_clear_mark || + if (ctdp->t_emark > ed->ed_clear_mark && mtdp->t_emark > ed->ed_clear_mark) return (ctdp->t_emark == mtdp->t_emark); -- cgit v1.1 From 3b8560b96524208c042013355ce68add2f05f8b0 Mon Sep 17 00:00:00 2001 From: markj Date: Mon, 17 Nov 2014 22:22:16 +0000 Subject: DTrace imposes a 128-byte limit on the length of the function component of a probe name. When dtrace -G builds up a DOF section for the specified provider(s), the probe function names are truncated to fit in this limit. The DOF is later used to build the symbol table for the generated object file, so the table can end up with truncated references, causing link errors. Instead of potentially truncating symbol table entries, write the full function name to the DOF string table and allow the kernel to enforce the 128-byte function name limit when a process attempts to load its DOF. PR: 194757 Differential Revision: https://reviews.freebsd.org/D1175 Reviewed by: rpaulo MFC after: 2 weeks --- .../opensolaris/lib/libdtrace/common/dt_dof.c | 2 +- .../opensolaris/lib/libdtrace/common/dt_provider.c | 37 +++++++++++----------- .../opensolaris/lib/libdtrace/common/dt_provider.h | 4 +-- 3 files changed, 21 insertions(+), 22 deletions(-) (limited to 'cddl') diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c index 5442683..0b531c5 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c @@ -469,7 +469,7 @@ dof_add_probe(dt_idhash_t *dhp, dt_ident_t *idp, void *data) * locally so an alternate symbol is added for the purpose * of this relocation. */ - if (pip->pi_rname[0] == '\0') + if (pip->pi_rname == NULL) dofr.dofr_name = dofpr.dofpr_func; else dofr.dofr_name = dof_add_string(ddo, pip->pi_rname); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c index 0f1bfe0..6acb86b 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c @@ -520,6 +520,8 @@ dt_probe_destroy(dt_probe_t *prp) for (pip = prp->pr_inst; pip != NULL; pip = pip_next) { pip_next = pip->pi_next; + dt_free(dtp, pip->pi_rname); + dt_free(dtp, pip->pi_fname); dt_free(dtp, pip->pi_offs); dt_free(dtp, pip->pi_enoffs); dt_free(dtp, pip); @@ -552,28 +554,18 @@ dt_probe_define(dt_provider_t *pvp, dt_probe_t *prp, if ((pip = dt_zalloc(dtp, sizeof (*pip))) == NULL) return (-1); - if ((pip->pi_offs = dt_zalloc(dtp, - sizeof (uint32_t))) == NULL) { - dt_free(dtp, pip); - return (-1); - } + if ((pip->pi_offs = dt_zalloc(dtp, sizeof (uint32_t))) == NULL) + goto nomem; if ((pip->pi_enoffs = dt_zalloc(dtp, - sizeof (uint32_t))) == NULL) { - dt_free(dtp, pip->pi_offs); - dt_free(dtp, pip); - return (-1); - } + sizeof (uint32_t))) == NULL) + goto nomem; - (void) strlcpy(pip->pi_fname, fname, sizeof (pip->pi_fname)); - if (rname != NULL) { - if (strlen(rname) + 1 > sizeof (pip->pi_rname)) { - dt_free(dtp, pip->pi_offs); - dt_free(dtp, pip); - return (dt_set_errno(dtp, EDT_COMPILER)); - } - (void) strcpy(pip->pi_rname, rname); - } + if ((pip->pi_fname = strdup(fname)) == NULL) + goto nomem; + + if (rname != NULL && (pip->pi_rname = strdup(rname)) == NULL) + goto nomem; pip->pi_noffs = 0; pip->pi_maxoffs = 1; @@ -618,6 +610,13 @@ dt_probe_define(dt_provider_t *pvp, dt_probe_t *prp, (*offs)[(*noffs)++] = offset; return (0); + +nomem: + dt_free(dtp, pip->pi_fname); + dt_free(dtp, pip->pi_enoffs); + dt_free(dtp, pip->pi_offs); + dt_free(dtp, pip); + return (dt_set_errno(dtp, EDT_NOMEM)); } /* diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.h index af4ec33..2752baa 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.h +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.h @@ -64,8 +64,8 @@ typedef struct dt_probe_iter { } dt_probe_iter_t; typedef struct dt_probe_instance { - char pi_fname[DTRACE_FUNCNAMELEN]; /* function name */ - char pi_rname[DTRACE_FUNCNAMELEN + 20]; /* mangled relocation name */ + char *pi_fname; /* function name */ + char *pi_rname; /* mangled relocation name */ uint32_t *pi_offs; /* offsets into the function */ uint32_t *pi_enoffs; /* is-enabled offsets */ uint_t pi_noffs; /* number of offsets */ -- cgit v1.1