summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Otavio O Souza <luiz@netgate.com>2016-03-21 13:24:56 -0500
committerLuiz Otavio O Souza <luiz@netgate.com>2016-03-21 13:24:56 -0500
commit696467e74a4bcf47c2bd3444dd7c1aeedbae50bf (patch)
tree924de18265dc0be51357e1a33f5a92e945044299
parent07def894aa89bea6d85dd76d201343a4a2e73046 (diff)
parentceb7b147e676803c22cf6d815f543f21fd9aa926 (diff)
downloadFreeBSD-src-696467e74a4bcf47c2bd3444dd7c1aeedbae50bf.zip
FreeBSD-src-696467e74a4bcf47c2bd3444dd7c1aeedbae50bf.tar.gz
Merge remote-tracking branch 'origin/stable/10' into devel
-rw-r--r--Makefile2
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/dtrace.c32
-rw-r--r--cddl/contrib/opensolaris/cmd/lockstat/lockstat.c24
-rw-r--r--cddl/contrib/opensolaris/cmd/lockstat/sym.c17
-rw-r--r--cddl/contrib/opensolaris/cmd/mdb/tools/common/die.c8
-rw-r--r--cddl/contrib/opensolaris/cmd/mdb/tools/common/util.h2
-rw-r--r--cddl/contrib/opensolaris/cmd/plockstat/plockstat.c18
-rw-r--r--cddl/contrib/opensolaris/cmd/zdb/zdb.c4
-rw-r--r--cddl/contrib/opensolaris/cmd/zfs/zfs.87
-rw-r--r--cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c6
-rw-r--r--cddl/contrib/opensolaris/cmd/zfs/zfs_main.c70
-rw-r--r--cddl/contrib/opensolaris/cmd/zinject/zinject.c111
-rw-r--r--cddl/contrib/opensolaris/cmd/zpool/zpool_iter.c8
-rw-r--r--cddl/contrib/opensolaris/cmd/zpool/zpool_main.c38
-rw-r--r--cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c28
-rw-r--r--cddl/contrib/opensolaris/cmd/zstreamdump/zstreamdump.c1
-rw-r--r--cddl/contrib/opensolaris/cmd/ztest/ztest.c1
-rw-r--r--cddl/contrib/opensolaris/common/util/strtolctype.h2
-rw-r--r--cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c10
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/drti.c26
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c4
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c10
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c6
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c4
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_error.c2
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_handle.c2
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_ident.c6
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h14
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l10
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c28
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c8
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c38
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c54
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c6
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c2
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c42
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c2
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c18
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c58
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_program.c2
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c4
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_regset.c7
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_strtab.c7
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c16
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_work.c2
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h6
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/i386/dt_isadep.c10
-rw-r--r--cddl/contrib/opensolaris/lib/libgen/common/gmatch.c4
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h7
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.c3
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c9
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c35
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c16
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c21
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c24
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c39
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c49
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c6
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c1
-rw-r--r--cddl/contrib/opensolaris/lib/libzpool/common/taskq.c4
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c8
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h2
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c4
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c12
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c4
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/output.c6
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c2
-rw-r--r--cddl/contrib/opensolaris/tools/ctf/cvt/util.c2
-rw-r--r--lib/libc++/Makefile1
-rw-r--r--sbin/geom/core/geom.c3
-rw-r--r--share/man/man5/rc.conf.522
-rw-r--r--share/man/man9/sx.912
-rw-r--r--sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c1
-rw-r--r--sys/cddl/compat/opensolaris/sys/callo.h37
-rw-r--r--sys/cddl/compat/opensolaris/sys/systm.h3
-rw-r--r--sys/cddl/compat/opensolaris/sys/time.h3
-rw-r--r--sys/cddl/contrib/opensolaris/common/nvpair/opensolaris_nvpair.c3
-rw-r--r--sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.c1
-rw-r--r--sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.h1
-rw-r--r--sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c493
-rw-r--r--sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.h72
-rw-r--r--sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c1
-rw-r--r--sys/cddl/contrib/opensolaris/common/zfs/zpool_prop.c1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c274
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c110
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c14
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c32
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bpobj.c5
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bptree.c1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c11
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c4
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c167
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c7
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c32
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deadlist.c1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_destroy.c1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c77
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c5
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c105
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c52
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c3
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c42
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h3
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_impl.h3
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_objset.h1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_send.h1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h3
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h4
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h3
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h2
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h4
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h19
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil_impl.h1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h8
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h8
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c5
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c19
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c18
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c153
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c19
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c11
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_missing.c7
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c4
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c16
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c5
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c50
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c2
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fuid.c14
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c168
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_replay.c6
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c33
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c73
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c35
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c84
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_checksum.c6
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_inject.c257
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/os/callb.c4
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/os/fm.c16
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/sys/ctf.h2
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/sys/ctf_api.h2
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h22
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h12
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap.h2
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap_impl.h6
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/sys/isa_defs.h6
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/sys/procset.h2
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/sys/sysevent.h12
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h4
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/sys/u8_textprep.h4
-rw-r--r--sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c42
-rw-r--r--sys/cddl/dev/dtrace/amd64/instr_size.c6
-rw-r--r--sys/cddl/dev/dtrace/dtrace_ioctl.c10
-rw-r--r--sys/cddl/dev/dtrace/i386/instr_size.c6
-rw-r--r--sys/cddl/dev/dtrace/x86/regset.h12
-rw-r--r--sys/dev/cxgbe/t4_main.c6
-rw-r--r--sys/dev/drm2/drm_drv.c4
-rw-r--r--sys/dev/mrsas/mrsas.c18
-rw-r--r--sys/dev/nvd/nvd.c2
-rw-r--r--sys/dev/nvme/nvme.h1
-rw-r--r--sys/dev/nvme/nvme_ns.c18
-rw-r--r--sys/dev/nvme/nvme_sysctl.c16
-rw-r--r--sys/dev/qlxgb/qla_hw.c3
-rw-r--r--sys/fs/ext2fs/ext2_vnops.c8
-rw-r--r--sys/kern/link_elf_obj.c133
-rw-r--r--sys/kern/subr_sglist.c3
-rw-r--r--sys/kern/subr_taskqueue.c32
180 files changed, 2685 insertions, 1426 deletions
diff --git a/Makefile b/Makefile
index ff4c18c..9898df0 100644
--- a/Makefile
+++ b/Makefile
@@ -336,7 +336,7 @@ kernel: buildkernel installkernel
upgrade_checks:
.if ${HAVE_MAKE} != ${WANT_MAKE} || \
(defined(WANT_MAKE_VERSION) && ${MAKE_VERSION} < ${WANT_MAKE_VERSION})
- @(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
+ @${_+_}(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
.elif ${WANT_MAKE} == "fmake"
@if ! (cd ${.CURDIR}/tools/build/make_check && \
PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c
index 3a954ed..d8bdaa6 100644
--- a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c
+++ b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c
@@ -43,11 +43,11 @@
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#endif
#include <libgen.h>
-#if defined(sun)
+#ifdef illumos
#include <libproc.h>
#endif
@@ -101,7 +101,7 @@ static int g_grabanon = 0;
static const char *g_ofile = NULL;
static FILE *g_ofp;
static dtrace_hdl_t *g_dtp;
-#if defined(sun)
+#ifdef illumos
static char *g_etcfile = "/etc/system";
static const char *g_etcbegin = "* vvvv Added by DTrace";
static const char *g_etcend = "* ^^^^ Added by DTrace";
@@ -211,7 +211,7 @@ fatal(const char *fmt, ...)
static void
dfatal(const char *fmt, ...)
{
-#if !defined(sun) && defined(NEED_ERRLOC)
+#if !defined(illumos) && defined(NEED_ERRLOC)
char *p_errfile = NULL;
int errline = 0;
#endif
@@ -232,7 +232,7 @@ dfatal(const char *fmt, ...)
(void) fprintf(stderr, "%s\n",
dtrace_errmsg(g_dtp, dtrace_errno(g_dtp)));
}
-#if !defined(sun) && defined(NEED_ERRLOC)
+#if !defined(illumos) && defined(NEED_ERRLOC)
dt_get_errloc(g_dtp, &p_errfile, &errline);
if (p_errfile != NULL)
printf("File '%s', line %d\n", p_errfile, errline);
@@ -397,7 +397,7 @@ dof_prune(const char *fname)
free(buf);
}
-#if defined(sun)
+#ifdef illumos
static void
etcsystem_prune(void)
{
@@ -508,7 +508,7 @@ etcsystem_add(void)
error("added forceload directives to %s\n", g_ofile);
}
-#endif
+#endif /* illumos */
static void
print_probe_info(const dtrace_probeinfo_t *p)
@@ -643,7 +643,7 @@ anon_prog(const dtrace_cmd_t *dcp, dof_hdr_t *dof, int n)
p = (uchar_t *)dof;
q = p + dof->dofh_loadsz;
-#if defined(sun)
+#ifdef illumos
oprintf("dof-data-%d=0x%x", n, *p++);
while (p < q)
@@ -793,7 +793,7 @@ compile_str(dtrace_cmd_t *dcp)
static void
prochandler(struct ps_prochandle *P, const char *msg, void *arg)
{
-#if defined(sun)
+#ifdef illumos
const psinfo_t *prp = Ppsinfo(P);
int pid = Pstatus(P)->pr_pid;
char name[SIG2STR_MAX];
@@ -807,13 +807,13 @@ prochandler(struct ps_prochandle *P, const char *msg, void *arg)
return;
}
-#if defined(sun)
+#ifdef illumos
switch (Pstate(P)) {
#else
switch (proc_state(P)) {
#endif
case PS_UNDEAD:
-#if defined(sun)
+#ifdef illumos
/*
* Ideally we would like to always report pr_wstat here, but it
* isn't possible given current /proc semantics. If we grabbed
@@ -831,7 +831,7 @@ prochandler(struct ps_prochandle *P, const char *msg, void *arg)
notice("pid %d terminated by %d\n", pid,
WTERMSIG(wstatus));
#endif
-#if defined(sun)
+#ifdef illumos
} else if (prp != NULL && WEXITSTATUS(prp->pr_wstat) != 0) {
notice("pid %d exited with status %d\n",
pid, WEXITSTATUS(prp->pr_wstat));
@@ -1238,7 +1238,7 @@ installsighands(void)
if (sigaction(SIGTERM, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN)
(void) sigaction(SIGTERM, &act, NULL);
-#if !defined(sun)
+#ifndef illumos
if (sigaction(SIGPIPE, NULL, &oact) == 0 && oact.sa_handler != SIG_IGN)
(void) sigaction(SIGPIPE, &act, NULL);
@@ -1720,7 +1720,7 @@ main(int argc, char *argv[])
case DMODE_ANON:
if (g_ofile == NULL)
-#if defined(sun)
+#ifdef illumos
g_ofile = "/kernel/drv/dtrace.conf";
#else
/*
@@ -1732,7 +1732,7 @@ main(int argc, char *argv[])
#endif
dof_prune(g_ofile); /* strip out any old DOF directives */
-#if defined(sun)
+#ifdef illumos
etcsystem_prune(); /* string out any forceload directives */
#endif
@@ -1765,7 +1765,7 @@ main(int argc, char *argv[])
* that itself contains a #pragma D option quiet.
*/
error("saved anonymous enabling in %s\n", g_ofile);
-#if defined(sun)
+#ifdef illumos
etcsystem_add();
error("run update_drv(1M) or reboot to enable changes\n");
#endif
diff --git a/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c b/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c
index 07f7cda..4f2f2c7 100644
--- a/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c
+++ b/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c
@@ -46,10 +46,9 @@
#include <signal.h>
#include <assert.h>
-#if defined(sun)
+#ifdef illumos
#define GETOPT_EOF EOF
#else
-/* FreeBSD */
#include <sys/time.h>
#include <sys/resource.h>
@@ -57,7 +56,7 @@
#define GETOPT_EOF (-1)
typedef uintptr_t pc_t;
-#endif /* defined(sun) */
+#endif
#define LOCKSTAT_OPTSTR "x:bths:n:d:i:l:f:e:ckwWgCHEATID:RpPo:V"
@@ -226,10 +225,9 @@ static ls_event_info_t g_event_info[LS_MAX_EVENTS] = {
{ 'H', "Lock", "Unknown event (type 53)", "units" },
{ 'H', "Lock", "Unknown event (type 54)", "units" },
{ 'H', "Lock", "Unknown event (type 55)", "units" },
-#if defined(sun)
+#ifdef illumos
{ 'I', "CPU+PIL", "Profiling interrupt", "nsec",
#else
- /* FreeBSD */
{ 'I', "CPU+Pri_Class", "Profiling interrupt", "nsec",
#endif
"profile:::profile-97", NULL },
@@ -243,7 +241,7 @@ static ls_event_info_t g_event_info[LS_MAX_EVENTS] = {
{ 'E', "Lock", "Lockstat record failure", "(N/A)" },
};
-#if !defined(sun)
+#ifndef illumos
static char *g_pri_class[] = {
"",
"Intr",
@@ -610,7 +608,7 @@ filter_add(char **filt, char *what, uintptr_t base, uintptr_t size)
*filt[0] = '\0';
}
-#if defined(sun)
+#ifdef illumos
(void) sprintf(c, "%s(%s >= 0x%p && %s < 0x%p)", *filt[0] != '\0' ?
" || " : "", what, (void *)base, what, (void *)(base + size));
#else
@@ -688,7 +686,7 @@ dprog_addevent(int event)
* the number of nanoseconds) is the number of nanoseconds
* late -- and it's stored in arg2.
*/
-#if defined(sun)
+#ifdef illumos
arg0 = "(uintptr_t)curthread->t_cpu + \n"
"\t curthread->t_cpu->cpu_profile_pil";
#else
@@ -836,7 +834,7 @@ dprog_compile()
}
static void
-#if defined(sun)
+#ifdef illumos
status_fire(void)
#else
status_fire(int i)
@@ -1435,7 +1433,7 @@ main(int argc, char **argv)
exit(127);
}
-#if defined(sun)
+#ifdef illumos
while (waitpid(child, &status, WEXITED) != child)
#else
while (waitpid(child, &status, 0) != child)
@@ -1480,7 +1478,7 @@ main(int argc, char **argv)
dfail("failed to walk aggregate");
}
-#if defined(sun)
+#ifdef illumos
if ((data_buf = memalign(sizeof (uint64_t),
(g_nrecs + 1) * g_recsize)) == NULL)
#else
@@ -1512,7 +1510,7 @@ main(int argc, char **argv)
if (g_gflag) {
lsrec_t *newlsp, *oldlsp;
-#if defined(sun)
+#ifdef illumos
newlsp = memalign(sizeof (uint64_t),
g_nrecs_used * LS_TIME * (g_stkdepth + 1));
#else
@@ -1676,7 +1674,7 @@ format_symbol(char *buf, uintptr_t addr, int show_size)
else if (symoff == 0)
(void) sprintf(buf, "%s", symname);
else if (symoff < 16 && bcmp(symname, "cpu[", 4) == 0) /* CPU+PIL */
-#if defined(sun)
+#ifdef illumos
(void) sprintf(buf, "%s+%ld", symname, (long)symoff);
#else
(void) sprintf(buf, "%s+%s", symname, g_pri_class[(int)symoff]);
diff --git a/cddl/contrib/opensolaris/cmd/lockstat/sym.c b/cddl/contrib/opensolaris/cmd/lockstat/sym.c
index 78b27d2..5361607 100644
--- a/cddl/contrib/opensolaris/cmd/lockstat/sym.c
+++ b/cddl/contrib/opensolaris/cmd/lockstat/sym.c
@@ -42,12 +42,11 @@
#include <libelf.h>
#include <link.h>
#include <elf.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/machelf.h>
#include <kstat.h>
#else
-/* FreeBSD */
#include <sys/elf.h>
#include <sys/ksyms.h>
#endif
@@ -63,7 +62,7 @@ static syment_t *symbol_table;
static int nsyms, maxsyms;
static char maxsymname[64];
-#if defined(sun)
+#ifdef illumos
#ifdef _ELF64
#define elf_getshdr elf64_getshdr
#else
@@ -102,7 +101,7 @@ remove_symbol(uintptr_t addr)
sep->addr = 0;
}
-#if defined(sun)
+#ifdef illumos
static void
fake_up_certain_popular_kernel_symbols(void)
{
@@ -130,8 +129,7 @@ fake_up_certain_popular_kernel_symbols(void)
}
(void) kstat_close(kc);
}
-#else
-/* FreeBSD */
+#else /* !illumos */
static void
fake_up_certain_popular_kernel_symbols(void)
{
@@ -148,7 +146,7 @@ fake_up_certain_popular_kernel_symbols(void)
add_symbol(name, addr, sizeof (uintptr_t));
}
}
-#endif /* !defined(sun) */
+#endif /* illumos */
static int
symcmp(const void *p1, const void *p2)
@@ -174,7 +172,7 @@ symtab_init(void)
int fd;
int i;
int strindex = -1;
-#if !defined(sun)
+#ifndef illumos
void *ksyms;
size_t sz;
#endif
@@ -182,12 +180,11 @@ symtab_init(void)
if ((fd = open("/dev/ksyms", O_RDONLY)) == -1)
return (-1);
-#if defined(sun)
+#ifdef illumos
(void) elf_version(EV_CURRENT);
elf = elf_begin(fd, ELF_C_READ, NULL);
#else
- /* FreeBSD */
/*
* XXX - libelf needs to be fixed so it will work with
* non 'ordinary' files like /dev/ksyms. The following
diff --git a/cddl/contrib/opensolaris/cmd/mdb/tools/common/die.c b/cddl/contrib/opensolaris/cmd/mdb/tools/common/die.c
index 602969e..7bfc06b 100644
--- a/cddl/contrib/opensolaris/cmd/mdb/tools/common/die.c
+++ b/cddl/contrib/opensolaris/cmd/mdb/tools/common/die.c
@@ -40,7 +40,7 @@ die(char *format, ...)
{
va_list ap;
int err = errno;
-#if !defined(sun)
+#ifndef illumos
const char *progname = getprogname();
#endif
@@ -54,7 +54,7 @@ die(char *format, ...)
if (format[strlen(format) - 1] != '\n')
(void) fprintf(stderr, ": %s\n", strerror(err));
-#if defined(__FreeBSD__)
+#ifndef illumos
exit(0);
#else
exit(1);
@@ -65,7 +65,7 @@ void
elfdie(char *format, ...)
{
va_list ap;
-#if !defined(sun)
+#ifndef illumos
const char *progname = getprogname();
#endif
@@ -79,7 +79,7 @@ elfdie(char *format, ...)
if (format[strlen(format) - 1] != '\n')
(void) fprintf(stderr, ": %s\n", elf_errmsg(elf_errno()));
-#if defined(__FreeBSD__)
+#ifndef illumos
exit(0);
#else
exit(1);
diff --git a/cddl/contrib/opensolaris/cmd/mdb/tools/common/util.h b/cddl/contrib/opensolaris/cmd/mdb/tools/common/util.h
index a0932ad..737d222 100644
--- a/cddl/contrib/opensolaris/cmd/mdb/tools/common/util.h
+++ b/cddl/contrib/opensolaris/cmd/mdb/tools/common/util.h
@@ -40,7 +40,7 @@ extern int findelfsecidx(Elf *, char *);
extern void die(char *, ...);
extern void elfdie(char *, ...);
-#if defined(sun)
+#ifdef illumos
extern const char *progname;
#endif
diff --git a/cddl/contrib/opensolaris/cmd/plockstat/plockstat.c b/cddl/contrib/opensolaris/cmd/plockstat/plockstat.c
index 1288468..e21567b 100644
--- a/cddl/contrib/opensolaris/cmd/plockstat/plockstat.c
+++ b/cddl/contrib/opensolaris/cmd/plockstat/plockstat.c
@@ -24,7 +24,7 @@
* Use is subject to license terms.
*/
-#if defined(sun)
+#ifdef illumos
#pragma ident "%Z%%M% %I% %E% SMI"
#endif
@@ -505,7 +505,7 @@ getsym(struct ps_prochandle *P, uintptr_t addr, char *buf, size_t size,
{
char name[256];
GElf_Sym sym;
-#if defined(sun)
+#ifdef illumos
prsyminfo_t info;
#else
prmap_t *map;
@@ -515,10 +515,10 @@ getsym(struct ps_prochandle *P, uintptr_t addr, char *buf, size_t size,
if (P == NULL || Pxlookup_by_addr(P, addr, name, sizeof (name),
&sym, &info) != 0) {
- (void) snprintf(buf, size, "%#lx", addr);
+ (void) snprintf(buf, size, "%#lx", (unsigned long)addr);
return (0);
}
-#if defined(sun)
+#ifdef illumos
if (info.prs_object == NULL)
info.prs_object = "<unknown>";
@@ -537,7 +537,7 @@ getsym(struct ps_prochandle *P, uintptr_t addr, char *buf, size_t size,
size -= len;
if (sym.st_value != addr)
- len = snprintf(buf, size, "+%#lx", addr - sym.st_value);
+ len = snprintf(buf, size, "+%#lx", (unsigned long)(addr - sym.st_value));
if (nolocks && strcmp("libc.so.1", map->pr_mapname) == 0 &&
(strstr("mutex", name) == 0 ||
@@ -668,7 +668,7 @@ process_aggregate(const dtrace_aggdata_t **aggsdata, int naggvars, void *arg)
static void
prochandler(struct ps_prochandle *P, const char *msg, void *arg)
{
-#if defined(sun)
+#ifdef illumos
const psinfo_t *prp = Ppsinfo(P);
int pid = Pstatus(P)->pr_pid;
#else
@@ -773,7 +773,7 @@ intr(int signo)
int
main(int argc, char **argv)
{
-#if defined(sun)
+#ifdef illumos
ucred_t *ucp;
#endif
int err;
@@ -785,7 +785,7 @@ main(int argc, char **argv)
g_pname = basename(argv[0]);
argv[0] = g_pname; /* rewrite argv[0] for getopt errors */
-#if defined(sun)
+#ifdef illumos
/*
* Make sure we have the required dtrace_proc privilege.
*/
@@ -988,7 +988,7 @@ main(int argc, char **argv)
if (opt_v)
(void) printf("%s: tracing enabled for pid %d\n", g_pname,
-#if defined(sun)
+#ifdef illumos
(int)Pstatus(g_pr)->pr_pid);
#else
(int)proc_getpid(g_pr));
diff --git a/cddl/contrib/opensolaris/cmd/zdb/zdb.c b/cddl/contrib/opensolaris/cmd/zdb/zdb.c
index 114bfaf..e55272f 100644
--- a/cddl/contrib/opensolaris/cmd/zdb/zdb.c
+++ b/cddl/contrib/opensolaris/cmd/zdb/zdb.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <stdio.h>
@@ -3658,7 +3659,8 @@ main(int argc, char **argv)
kernel_init(FREAD);
g_zfs = libzfs_init();
- ASSERT(g_zfs != NULL);
+ if (g_zfs == NULL)
+ fatal("Fail to initialize zfs");
if (dump_all)
verbose = MAX(verbose, 1);
diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs.8 b/cddl/contrib/opensolaris/cmd/zfs/zfs.8
index f2eaa54..e120d85 100644
--- a/cddl/contrib/opensolaris/cmd/zfs/zfs.8
+++ b/cddl/contrib/opensolaris/cmd/zfs/zfs.8
@@ -2839,8 +2839,11 @@ Do not actually receive the stream. This can be useful in conjunction with the
option to verify the name the receive operation would use.
.It Fl o Sy origin Ns = Ns Ar snapshot
Forces the stream to be received as a clone of the given snapshot.
-This is only valid if the stream is an incremental stream whose source
-is the same as the provided origin.
+If the stream is a full send stream, this will create the filesystem
+described by the stream as a clone of the specified snapshot. Which
+snapshot was specified will not affect the success or failure of the
+receive, as long as the snapshot does exist. If the stream is an
+incremental send stream, all the normal verification will be performed.
.It Fl F
Force a rollback of the file system to the most recent snapshot before
performing the receive operation. If receiving an incremental replication
diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c b/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c
index 626d69c..317063e 100644
--- a/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c
+++ b/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c
@@ -93,7 +93,7 @@ static int
zfs_callback(zfs_handle_t *zhp, void *data)
{
callback_data_t *cb = data;
- boolean_t dontclose = B_FALSE;
+ boolean_t should_close = B_TRUE;
boolean_t include_snaps = zfs_include_snapshots(zhp, cb);
boolean_t include_bmarks = (cb->cb_types & ZFS_TYPE_BOOKMARK);
@@ -121,7 +121,7 @@ zfs_callback(zfs_handle_t *zhp, void *data)
}
}
uu_avl_insert(cb->cb_avl, node, idx);
- dontclose = B_TRUE;
+ should_close = B_FALSE;
} else {
free(node);
}
@@ -147,7 +147,7 @@ zfs_callback(zfs_handle_t *zhp, void *data)
cb->cb_depth--;
}
- if (!dontclose)
+ if (should_close)
zfs_close(zhp);
return (0);
diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c b/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
index 54135f1..402bbe7 100644
--- a/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
+++ b/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
@@ -29,6 +29,8 @@
* Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
+ * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>.
*/
#include <assert.h>
@@ -65,7 +67,7 @@
#include <zfs_prop.h>
#include <zfs_deleg.h>
#include <libuutil.h>
-#ifdef sun
+#ifdef illumos
#include <aclutils.h>
#include <directory.h>
#include <idmap.h>
@@ -750,7 +752,7 @@ zfs_do_create(int argc, char **argv)
{
zfs_type_t type = ZFS_TYPE_FILESYSTEM;
zfs_handle_t *zhp = NULL;
- uint64_t volsize;
+ uint64_t volsize = 0;
int c;
boolean_t noreserve = B_FALSE;
boolean_t bflag = B_FALSE;
@@ -845,14 +847,14 @@ zfs_do_create(int argc, char **argv)
if (type == ZFS_TYPE_VOLUME && !noreserve) {
zpool_handle_t *zpool_handle;
- nvlist_t *real_props;
+ nvlist_t *real_props = NULL;
uint64_t spa_version;
char *p;
zfs_prop_t resv_prop;
char *strval;
char msg[1024];
- if (p = strchr(argv[0], '/'))
+ if ((p = strchr(argv[0], '/')) != NULL)
*p = '\0';
zpool_handle = zpool_open(g_zfs, argv[0]);
if (p != NULL)
@@ -2359,6 +2361,9 @@ us_compare(const void *larg, const void *rarg, void *unused)
if (rv64 != lv64)
rc = (rv64 < lv64) ? 1 : -1;
break;
+
+ default:
+ break;
}
if (rc != 0) {
@@ -2414,7 +2419,7 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
nvlist_t *props;
us_node_t *n;
zfs_sort_column_t *sortcol = cb->cb_sortcol;
- unsigned type;
+ unsigned type = 0;
const char *typestr;
size_t namelen;
size_t typelen;
@@ -2433,7 +2438,7 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
/* SMB */
char sid[ZFS_MAXNAMELEN + 32];
uid_t id;
-#ifdef sun
+#ifdef illumos
int err;
int flag = IDMAP_REQ_FLG_USE_CACHE;
#endif
@@ -2444,17 +2449,17 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
if (prop == ZFS_PROP_GROUPUSED || prop == ZFS_PROP_GROUPQUOTA) {
type = USTYPE_SMB_GRP;
-#ifdef sun
+#ifdef illumos
err = sid_to_id(sid, B_FALSE, &id);
#endif
} else {
type = USTYPE_SMB_USR;
-#ifdef sun
+#ifdef illumos
err = sid_to_id(sid, B_TRUE, &id);
#endif
}
-#ifdef sun
+#ifdef illumos
if (err == 0) {
rid = id;
if (!cb->cb_sid2posix) {
@@ -3972,7 +3977,7 @@ zfs_do_send(int argc, char **argv)
static int
zfs_do_receive(int argc, char **argv)
{
- int c, err;
+ int c, err = 0;
recvflags_t flags = { 0 };
boolean_t abort_resumable = B_FALSE;
@@ -4232,7 +4237,7 @@ deleg_perm_type(zfs_deleg_note_t note)
}
}
-static int inline
+static int
who_type2weight(zfs_deleg_who_type_t who_type)
{
int res;
@@ -4452,7 +4457,7 @@ fs_perm_fini(fs_perm_t *fsperm)
uu_avl_destroy(fsperm->fsp_uge_avl);
}
-static void inline
+static void
set_deleg_perm_node(uu_avl_t *avl, deleg_perm_node_t *node,
zfs_deleg_who_type_t who_type, const char *name, char locality)
{
@@ -4520,7 +4525,7 @@ parse_fs_perm(fs_perm_t *fsperm, nvlist_t *nvl)
nvlist_t *nvl2 = NULL;
const char *name = nvpair_name(nvp);
uu_avl_t *avl = NULL;
- uu_avl_pool_t *avl_pool;
+ uu_avl_pool_t *avl_pool = NULL;
zfs_deleg_who_type_t perm_type = name[0];
char perm_locality = name[1];
const char *perm_name = name + 3;
@@ -4549,6 +4554,9 @@ parse_fs_perm(fs_perm_t *fsperm, nvlist_t *nvl)
avl_pool = fspset->fsps_who_perm_avl_pool;
avl = fsperm->fsp_uge_avl;
break;
+
+ default:
+ assert(!"unhandled zfs_deleg_who_type_t");
}
if (is_set) {
@@ -4584,6 +4592,9 @@ parse_fs_perm(fs_perm_t *fsperm, nvlist_t *nvl)
if (g)
nice_name = g->gr_name;
break;
+
+ default:
+ break;
}
if (nice_name != NULL)
@@ -4852,11 +4863,12 @@ parse_allow_args(int argc, char **argv, boolean_t un, struct allow_opts *opts)
allow_usage(un, B_FALSE,
gettext("-u, -g, and -e are mutually exclusive\n"));
- if (opts->prt_usage)
+ if (opts->prt_usage) {
if (argc == 0 && all_sum == 0)
allow_usage(un, B_TRUE, NULL);
else
usage(B_FALSE);
+ }
if (opts->set) {
if (csuge_sum > 1)
@@ -4905,8 +4917,8 @@ store_allow_perm(zfs_deleg_who_type_t type, boolean_t local, boolean_t descend,
int i;
char ld[2] = { '\0', '\0' };
char who_buf[ZFS_MAXNAMELEN+32];
- char base_type;
- char set_type;
+ char base_type = '\0';
+ char set_type = '\0';
nvlist_t *base_nvl = NULL;
nvlist_t *set_nvl = NULL;
nvlist_t *nvl;
@@ -4955,6 +4967,10 @@ store_allow_perm(zfs_deleg_who_type_t type, boolean_t local, boolean_t descend,
ld[0] = ZFS_DELEG_LOCAL;
if (descend)
ld[1] = ZFS_DELEG_DESCENDENT;
+ break;
+
+ default:
+ assert(set_type != '\0' && base_type != '\0');
}
if (perms != NULL) {
@@ -5059,7 +5075,7 @@ construct_fsacl_list(boolean_t un, struct allow_opts *opts, nvlist_t **nvlp)
while (curr < end) {
const char *who;
- zfs_deleg_who_type_t who_type;
+ zfs_deleg_who_type_t who_type = ZFS_DELEG_WHO_UNKNOWN;
char *endch;
char *delim = strchr(curr, ',');
char errbuf[256];
@@ -5109,12 +5125,13 @@ construct_fsacl_list(boolean_t un, struct allow_opts *opts, nvlist_t **nvlp)
p = getpwuid(rid);
}
- if (p == NULL)
+ if (p == NULL) {
if (*endch != '\0') {
g = getgrnam(curr);
} else {
g = getgrgid(rid);
}
+ }
if (p != NULL) {
who_type = ZFS_DELEG_USER;
@@ -5187,7 +5204,7 @@ print_set_creat_perms(uu_avl_t *who_avl)
}
}
-static void inline
+static void
print_uge_deleg_perms(uu_avl_t *who_avl, boolean_t local, boolean_t descend,
const char *title)
{
@@ -5238,6 +5255,10 @@ print_uge_deleg_perms(uu_avl_t *who_avl, boolean_t local, boolean_t descend,
case ZFS_DELEG_EVERYONE:
who = gettext("everyone");
who_name = NULL;
+ break;
+
+ default:
+ assert(who != NULL);
}
prt_who = B_FALSE;
@@ -5406,8 +5427,7 @@ zfs_do_allow_unallow_impl(int argc, char **argv, boolean_t un)
cleanup0:
nvlist_free(perm_nvl);
- if (update_perm_nvl != NULL)
- nvlist_free(update_perm_nvl);
+ nvlist_free(update_perm_nvl);
cleanup1:
fs_perm_set_fini(&fs_perm_set);
cleanup2:
@@ -5942,7 +5962,7 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol,
shared_nfs = zfs_is_shared_nfs(zhp, NULL);
shared_smb = zfs_is_shared_smb(zhp, NULL);
- if (shared_nfs && shared_smb ||
+ if ((shared_nfs && shared_smb) ||
(shared_nfs && strcmp(shareopts, "on") == 0 &&
strcmp(smbshareopts, "off") == 0) ||
(shared_smb && strcmp(smbshareopts, "on") == 0 &&
@@ -6264,7 +6284,7 @@ unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual)
/*
* Search for the given (major,minor) pair in the mount table.
*/
-#ifdef sun
+#ifdef illumos
rewind(mnttab_file);
while ((ret = getextmntent(mnttab_file, &entry, 0)) == 0) {
if (entry.mnt_major == major(statbuf.st_dev) &&
@@ -6416,7 +6436,7 @@ unshare_unmount(int op, int argc, char **argv)
*/
struct mnttab entry;
uu_avl_pool_t *pool;
- uu_avl_t *tree;
+ uu_avl_t *tree = NULL;
unshare_unmount_node_t *node;
uu_avl_index_t idx;
uu_avl_walk_t *walk;
@@ -6910,7 +6930,7 @@ zfs_do_diff(int argc, char **argv)
if (copy == NULL)
usage(B_FALSE);
- if (atp = strchr(copy, '@'))
+ if ((atp = strchr(copy, '@')) != NULL)
*atp = '\0';
if ((zhp = zfs_open(g_zfs, copy, ZFS_TYPE_FILESYSTEM)) == NULL)
diff --git a/cddl/contrib/opensolaris/cmd/zinject/zinject.c b/cddl/contrib/opensolaris/cmd/zinject/zinject.c
index ddcdb1f..bf42bc4 100644
--- a/cddl/contrib/opensolaris/cmd/zinject/zinject.c
+++ b/cddl/contrib/opensolaris/cmd/zinject/zinject.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) 2012, 2015 by Delphix. All rights reserved.
*/
/*
@@ -229,21 +229,57 @@ usage(void)
"\t\tall records if 'all' is specificed.\n"
"\n"
"\tzinject -p <function name> pool\n"
+ "\n"
"\t\tInject a panic fault at the specified function. Only \n"
"\t\tfunctions which call spa_vdev_config_exit(), or \n"
"\t\tspa_vdev_exit() will trigger a panic.\n"
"\n"
"\tzinject -d device [-e errno] [-L <nvlist|uber|pad1|pad2>] [-F]\n"
"\t [-T <read|write|free|claim|all> pool\n"
+ "\n"
"\t\tInject a fault into a particular device or the device's\n"
"\t\tlabel. Label injection can either be 'nvlist', 'uber',\n "
"\t\t'pad1', or 'pad2'.\n"
"\t\t'errno' can be 'nxio' (the default), 'io', or 'dtl'.\n"
"\n"
"\tzinject -d device -A <degrade|fault> pool\n"
+ "\n"
"\t\tPerform a specific action on a particular device\n"
"\n"
+ "\tzinject -d device -D latency:lanes pool\n"
+ "\n"
+ "\t\tAdd an artificial delay to IO requests on a particular\n"
+ "\t\tdevice, such that the requests take a minimum of 'latency'\n"
+ "\t\tmilliseconds to complete. Each delay has an associated\n"
+ "\t\tnumber of 'lanes' which defines the number of concurrent\n"
+ "\t\tIO requests that can be processed.\n"
+ "\n"
+ "\t\tFor example, with a single lane delay of 10 ms (-D 10:1),\n"
+ "\t\tthe device will only be able to service a single IO request\n"
+ "\t\tat a time with each request taking 10 ms to complete. So,\n"
+ "\t\tif only a single request is submitted every 10 ms, the\n"
+ "\t\taverage latency will be 10 ms; but if more than one request\n"
+ "\t\tis submitted every 10 ms, the average latency will be more\n"
+ "\t\tthan 10 ms.\n"
+ "\n"
+ "\t\tSimilarly, if a delay of 10 ms is specified to have two\n"
+ "\t\tlanes (-D 10:2), then the device will be able to service\n"
+ "\t\ttwo requests at a time, each with a minimum latency of\n"
+ "\t\t10 ms. So, if two requests are submitted every 10 ms, then\n"
+ "\t\tthe average latency will be 10 ms; but if more than two\n"
+ "\t\trequests are submitted every 10 ms, the average latency\n"
+ "\t\twill be more than 10 ms.\n"
+ "\n"
+ "\t\tAlso note, these delays are additive. So two invocations\n"
+ "\t\tof '-D 10:1', is roughly equivalent to a single invocation\n"
+ "\t\tof '-D 10:2'. This also means, one can specify multiple\n"
+ "\t\tlanes with differing target latencies. For example, an\n"
+ "\t\tinvocation of '-D 10:1' followed by '-D 25:2' will\n"
+ "\t\tcreate 3 lanes on the device; one lane with a latency\n"
+ "\t\tof 10 ms and two lanes with a 25 ms latency.\n"
+ "\n"
"\tzinject -I [-s <seconds> | -g <txgs>] pool\n"
+ "\n"
"\t\tCause the pool to stop writing blocks yet not\n"
"\t\treport errors for a duration. Simulates buggy hardware\n"
"\t\tthat fails to honor cache flush requests.\n"
@@ -357,6 +393,9 @@ print_device_handler(int id, const char *pool, zinject_record_t *record,
if (record->zi_guid == 0 || record->zi_func[0] != '\0')
return (0);
+ if (record->zi_cmd == ZINJECT_DELAY_IO)
+ return (0);
+
if (*count == 0) {
(void) printf("%3s %-15s %s\n", "ID", "POOL", "GUID");
(void) printf("--- --------------- ----------------\n");
@@ -371,6 +410,35 @@ print_device_handler(int id, const char *pool, zinject_record_t *record,
}
static int
+print_delay_handler(int id, const char *pool, zinject_record_t *record,
+ void *data)
+{
+ int *count = data;
+
+ if (record->zi_guid == 0 || record->zi_func[0] != '\0')
+ return (0);
+
+ if (record->zi_cmd != ZINJECT_DELAY_IO)
+ return (0);
+
+ if (*count == 0) {
+ (void) printf("%3s %-15s %-15s %-15s %s\n",
+ "ID", "POOL", "DELAY (ms)", "LANES", "GUID");
+ (void) printf("--- --------------- --------------- "
+ "--------------- ----------------\n");
+ }
+
+ *count += 1;
+
+ (void) printf("%3d %-15s %-15llu %-15llu %llx\n", id, pool,
+ (u_longlong_t)NSEC2MSEC(record->zi_timer),
+ (u_longlong_t)record->zi_nlanes,
+ (u_longlong_t)record->zi_guid);
+
+ return (0);
+}
+
+static int
print_panic_handler(int id, const char *pool, zinject_record_t *record,
void *data)
{
@@ -407,6 +475,13 @@ print_all_handlers(void)
count = 0;
}
+ (void) iter_handlers(print_delay_handler, &count);
+ if (count > 0) {
+ total += count;
+ (void) printf("\n");
+ count = 0;
+ }
+
(void) iter_handlers(print_data_handler, &count);
if (count > 0) {
total += count;
@@ -549,6 +624,35 @@ perform_action(const char *pool, zinject_record_t *record, int cmd)
return (1);
}
+static int
+parse_delay(char *str, uint64_t *delay, uint64_t *nlanes)
+{
+ unsigned long scan_delay;
+ unsigned long scan_nlanes;
+
+ if (sscanf(str, "%lu:%lu", &scan_delay, &scan_nlanes) != 2)
+ return (1);
+
+ /*
+ * We explicitly disallow a delay of zero here, because we key
+ * off this value being non-zero in translate_device(), to
+ * determine if the fault is a ZINJECT_DELAY_IO fault or not.
+ */
+ if (scan_delay == 0)
+ return (1);
+
+ /*
+ * The units for the CLI delay parameter is milliseconds, but
+ * the data passed to the kernel is interpreted as nanoseconds.
+ * Thus we scale the milliseconds to nanoseconds here, and this
+ * nanosecond value is used to pass the delay to the kernel.
+ */
+ *delay = MSEC2NSEC(scan_delay);
+ *nlanes = scan_nlanes;
+
+ return (0);
+}
+
int
main(int argc, char **argv)
{
@@ -632,8 +736,9 @@ main(int argc, char **argv)
device = optarg;
break;
case 'D':
- record.zi_timer = strtoull(optarg, &end, 10);
- if (errno != 0 || *end != '\0') {
+ ret = parse_delay(optarg, &record.zi_timer,
+ &record.zi_nlanes);
+ if (ret != 0) {
(void) fprintf(stderr, "invalid i/o delay "
"value: '%s'\n", optarg);
usage();
diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_iter.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_iter.c
index 6ba91b1..2f7de93 100644
--- a/cddl/contrib/opensolaris/cmd/zpool/zpool_iter.c
+++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_iter.c
@@ -22,8 +22,9 @@
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>.
+ */
#include <solaris.h>
#include <libintl.h>
@@ -132,7 +133,8 @@ pool_list_get(int argc, char **argv, zprop_list_t **proplist, int *err)
for (i = 0; i < argc; i++) {
zpool_handle_t *zhp;
- if (zhp = zpool_open_canfail(g_zfs, argv[i])) {
+ if ((zhp = zpool_open_canfail(g_zfs, argv[i])) !=
+ NULL) {
if (add_pool(zhp, zlp) != 0)
*err = B_TRUE;
} else {
diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
index c666263..b979833 100644
--- a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
+++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
@@ -26,6 +26,7 @@
* Copyright (c) 2012 by Frederik Wessels. All rights reserved.
* Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright (c) 2013 by Prasad Joshi (sTec). All rights reserved.
+ * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>.
*/
#include <solaris.h>
@@ -3171,33 +3172,6 @@ zpool_do_list(int argc, char **argv)
return (ret);
}
-static nvlist_t *
-zpool_get_vdev_by_name(nvlist_t *nv, char *name)
-{
- nvlist_t **child;
- uint_t c, children;
- nvlist_t *match;
- char *path;
-
- if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN,
- &child, &children) != 0) {
- verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) == 0);
- if (strncmp(name, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
- name += sizeof(_PATH_DEV) - 1;
- if (strncmp(path, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
- path += sizeof(_PATH_DEV) - 1;
- if (strcmp(name, path) == 0)
- return (nv);
- return (NULL);
- }
-
- for (c = 0; c < children; c++)
- if ((match = zpool_get_vdev_by_name(child[c], name)) != NULL)
- return (match);
-
- return (NULL);
-}
-
static int
zpool_do_attach_or_replace(int argc, char **argv, int replacing)
{
@@ -3413,8 +3387,7 @@ zpool_do_split(int argc, char **argv)
if (add_prop_list(
zpool_prop_to_name(ZPOOL_PROP_ALTROOT), optarg,
&props, B_TRUE) != 0) {
- if (props)
- nvlist_free(props);
+ nvlist_free(props);
usage(B_FALSE);
}
break;
@@ -3427,8 +3400,7 @@ zpool_do_split(int argc, char **argv)
propval++;
if (add_prop_list(optarg, propval,
&props, B_TRUE) != 0) {
- if (props)
- nvlist_free(props);
+ nvlist_free(props);
usage(B_FALSE);
}
} else {
@@ -3928,7 +3900,7 @@ print_scan_status(pool_scan_stat_t *ps)
*/
if (ps->pss_state == DSS_FINISHED) {
uint64_t minutes_taken = (end - start) / 60;
- char *fmt;
+ char *fmt = NULL;
if (ps->pss_func == POOL_SCAN_SCRUB) {
fmt = gettext("scrub repaired %s in %lluh%um with "
@@ -5562,7 +5534,7 @@ find_command_idx(char *command, int *idx)
int
main(int argc, char **argv)
{
- int ret;
+ int ret = 0;
int i;
char *cmdname;
diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c
index a7747f6..1b58f13 100644
--- a/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c
+++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>.
*/
/*
@@ -112,7 +113,7 @@ vdev_error(const char *fmt, ...)
va_end(ap);
}
-#ifdef sun
+#ifdef illumos
static void
libdiskmgt_error(int error)
{
@@ -274,7 +275,7 @@ check_device(const char *path, boolean_t force, boolean_t isspare)
return (check_slice(path, force, B_FALSE, isspare));
}
-#endif /* sun */
+#endif /* illumos */
/*
* Check that a file is valid. All we can do in this case is check that it's
@@ -290,7 +291,7 @@ check_file(const char *file, boolean_t force, boolean_t isspare)
pool_state_t state;
boolean_t inuse;
-#ifdef sun
+#ifdef illumos
if (dm_inuse_swap(file, &err)) {
if (err)
libdiskmgt_error(err);
@@ -377,7 +378,7 @@ check_device(const char *name, boolean_t force, boolean_t isspare)
static boolean_t
is_whole_disk(const char *arg)
{
-#ifdef sun
+#ifdef illumos
struct dk_gpt *label;
int fd;
char path[MAXPATHLEN];
@@ -588,7 +589,9 @@ get_replication(nvlist_t *nvroot, boolean_t fatal)
uint_t c, children;
nvlist_t *nv;
char *type;
- replication_level_t lastrep, rep, *ret;
+ replication_level_t lastrep = {0};
+ replication_level_t rep;
+ replication_level_t *ret;
boolean_t dontreport;
ret = safe_malloc(sizeof (replication_level_t));
@@ -911,7 +914,7 @@ check_replication(nvlist_t *config, nvlist_t *newroot)
return (ret);
}
-#ifdef sun
+#ifdef illumos
/*
* Go through and find any whole disks in the vdev specification, labelling them
* as appropriate. When constructing the vdev spec, we were unable to open this
@@ -1015,7 +1018,7 @@ make_disks(zpool_handle_t *zhp, nvlist_t *nv)
return (0);
}
-#endif /* sun */
+#endif /* illumos */
/*
* Determine if the given path is a hot spare within the given configuration.
@@ -1076,7 +1079,7 @@ is_device_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force,
nvlist_t **child;
uint_t c, children;
char *type, *path;
- int ret;
+ int ret = 0;
char buf[MAXPATHLEN];
uint64_t wholedisk;
boolean_t anyinuse = B_FALSE;
@@ -1094,7 +1097,7 @@ is_device_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force,
* regardless of what libdiskmgt or zpool_in_use() says.
*/
if (replacing) {
-#ifdef sun
+#ifdef illumos
if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_WHOLE_DISK,
&wholedisk) == 0 && wholedisk)
(void) snprintf(buf, sizeof (buf), "%ss0",
@@ -1418,7 +1421,7 @@ split_mirror_vdev(zpool_handle_t *zhp, char *newname, nvlist_t *props,
return (NULL);
}
-#ifdef sun
+#ifdef illumos
if (!flags.dryrun && make_disks(zhp, newroot) != 0) {
nvlist_free(newroot);
return (NULL);
@@ -1445,8 +1448,7 @@ split_mirror_vdev(zpool_handle_t *zhp, char *newname, nvlist_t *props,
}
if (zpool_vdev_split(zhp, newname, &newroot, props, flags) != 0) {
- if (newroot != NULL)
- nvlist_free(newroot);
+ nvlist_free(newroot);
return (NULL);
}
@@ -1503,7 +1505,7 @@ make_root_vdev(zpool_handle_t *zhp, int force, int check_rep,
return (NULL);
}
-#ifdef sun
+#ifdef illumos
/*
* Run through the vdev specification and label any whole disks found.
*/
diff --git a/cddl/contrib/opensolaris/cmd/zstreamdump/zstreamdump.c b/cddl/contrib/opensolaris/cmd/zstreamdump/zstreamdump.c
index 83a5b54..32e370d 100644
--- a/cddl/contrib/opensolaris/cmd/zstreamdump/zstreamdump.c
+++ b/cddl/contrib/opensolaris/cmd/zstreamdump/zstreamdump.c
@@ -26,6 +26,7 @@
/*
* Copyright (c) 2013, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <ctype.h>
diff --git a/cddl/contrib/opensolaris/cmd/ztest/ztest.c b/cddl/contrib/opensolaris/cmd/ztest/ztest.c
index 7cc8d5f..211348c 100644
--- a/cddl/contrib/opensolaris/cmd/ztest/ztest.c
+++ b/cddl/contrib/opensolaris/cmd/ztest/ztest.c
@@ -24,6 +24,7 @@
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
/*
diff --git a/cddl/contrib/opensolaris/common/util/strtolctype.h b/cddl/contrib/opensolaris/common/util/strtolctype.h
index a1d1836..91609ce 100644
--- a/cddl/contrib/opensolaris/common/util/strtolctype.h
+++ b/cddl/contrib/opensolaris/common/util/strtolctype.h
@@ -44,7 +44,7 @@ extern "C" {
* safe in probe context.
*/
-#if defined(sun) && (defined(_KERNEL) || defined(_BOOT))
+#if defined(illumos) && (defined(_KERNEL) || defined(_BOOT))
#define isalnum(ch) (isalpha(ch) || isdigit(ch))
#define isalpha(ch) (isupper(ch) || islower(ch))
diff --git a/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c b/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c
index 5822267..b9f512d 100644
--- a/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c
+++ b/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c
@@ -34,14 +34,14 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
-#if defined(sun)
+#ifdef illumos
#include <dlfcn.h>
#else
#include <zlib.h>
#endif
#include <gelf.h>
-#if defined(sun)
+#ifdef illumos
#ifdef _LP64
static const char *_libctf_zlib = "/usr/lib/64/libz.so";
#else
@@ -58,7 +58,7 @@ static struct {
static size_t _PAGESIZE;
static size_t _PAGEMASK;
-#if defined(sun)
+#ifdef illumos
#pragma init(_libctf_init)
#else
void _libctf_init(void) __attribute__ ((constructor));
@@ -66,7 +66,7 @@ void _libctf_init(void) __attribute__ ((constructor));
void
_libctf_init(void)
{
-#if defined(sun)
+#ifdef illumos
const char *p = getenv("LIBCTF_DECOMPRESSOR");
if (p != NULL)
@@ -87,7 +87,7 @@ _libctf_init(void)
void *
ctf_zopen(int *errp)
{
-#if defined(sun)
+#ifdef illumos
ctf_dprintf("decompressing CTF data using %s\n", _libctf_zlib);
if (zlib.z_dlp != NULL)
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c b/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
index b2854d2..1ee873b 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
@@ -56,13 +56,13 @@
*/
static const char *devnamep = "/dev/dtrace/helper";
-#if defined(sun)
+#ifdef illumos
static const char *olddevname = "/devices/pseudo/dtrace@0:helper";
#endif
static const char *modname; /* Name of this load object */
static int gen; /* DOF helper generation */
-#if defined(sun)
+#ifdef illumos
extern dof_hdr_t __SUNW_dof; /* DOF defined in the .SUNW_dof section */
#endif
static boolean_t dof_init_debug = B_FALSE; /* From DTRACE_DOF_INIT_DEBUG */
@@ -90,7 +90,7 @@ dprintf(int debug, const char *fmt, ...)
va_end(ap);
}
-#if !defined(sun)
+#ifndef illumos
static void
fixsymbol(Elf *e, Elf_Data *data, size_t idx, int nprobes, char *buf,
dof_sec_t *sec, int *fixedprobes, char *dofstrtab)
@@ -120,7 +120,7 @@ fixsymbol(Elf *e, Elf_Data *data, size_t idx, int nprobes, char *buf,
}
#endif
-#if defined(sun)
+#ifdef illumos
#pragma init(dtrace_dof_init)
#else
static void dtrace_dof_init(void) __attribute__ ((constructor));
@@ -129,7 +129,7 @@ static void dtrace_dof_init(void) __attribute__ ((constructor));
static void
dtrace_dof_init(void)
{
-#if defined(sun)
+#ifdef illumos
dof_hdr_t *dof = &__SUNW_dof;
#else
dof_hdr_t *dof = NULL;
@@ -141,7 +141,7 @@ dtrace_dof_init(void)
#endif
dof_helper_t dh;
Link_map *lmp;
-#if defined(sun)
+#ifdef illumos
Lmid_t lmid;
#else
u_long lmid = 0;
@@ -151,7 +151,7 @@ dtrace_dof_init(void)
#endif
int fd;
const char *p;
-#if !defined(sun)
+#ifndef illumos
Elf *e;
Elf_Scn *scn = NULL;
Elf_Data *symtabdata = NULL, *dynsymdata = NULL, *dofdata = NULL;
@@ -177,7 +177,7 @@ dtrace_dof_init(void)
return;
}
-#if defined(sun)
+#ifdef illumos
if (dlinfo(RTLD_SELF, RTLD_DI_LMID, &lmid) == -1) {
dprintf(1, "couldn't discover link map ID\n");
return;
@@ -189,7 +189,7 @@ dtrace_dof_init(void)
modname = lmp->l_name;
else
modname++;
-#if !defined(sun)
+#ifndef illumos
elf_version(EV_CURRENT);
if ((efd = open(lmp->l_name, O_RDONLY, 0)) < 0) {
dprintf(1, "couldn't open file for reading\n");
@@ -258,7 +258,7 @@ dtrace_dof_init(void)
if ((fd = open64(devnamep, O_RDWR)) < 0) {
dprintf(1, "failed to open helper device %s", devnamep);
-#if defined(sun)
+#ifdef illumos
/*
* If the device path wasn't explicitly set, try again with
* the old device path.
@@ -350,14 +350,14 @@ dtrace_dof_init(void)
dprintf(1, "DTrace ioctl failed for DOF at %p", dof);
else {
dprintf(1, "DTrace ioctl succeeded for DOF at %p\n", dof);
-#if !defined(sun)
+#ifndef illumos
gen = dh.gen;
#endif
}
(void) close(fd);
-#if !defined(sun)
+#ifndef illumos
/* End of while loop */
dof = dof_next;
}
@@ -367,7 +367,7 @@ dtrace_dof_init(void)
#endif
}
-#if defined(sun)
+#ifdef illumos
#pragma fini(dtrace_dof_fini)
#else
static void dtrace_dof_fini(void) __attribute__ ((destructor));
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c
index 6b571fa..5ea55a0 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c
@@ -35,7 +35,7 @@
#include <unistd.h>
#include <dt_impl.h>
#include <assert.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#else
#include <sys/sysctl.h>
@@ -453,7 +453,7 @@ dt_aggregate_snap_cpu(dtrace_hdl_t *dtp, processorid_t cpu)
buf->dtbd_cpu = cpu;
-#if defined(sun)
+#ifdef illumos
if (dt_ioctl(dtp, DTRACEIOC_AGGSNAP, buf) == -1) {
#else
if (dt_ioctl(dtp, DTRACEIOC_AGGSNAP, &buf) == -1) {
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c
index 35b8f02..84f8661 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c
@@ -1888,7 +1888,7 @@ dt_preproc(dtrace_hdl_t *dtp, FILE *ifp)
char **argv = malloc(sizeof (char *) * (argc + 5));
FILE *ofp = tmpfile();
-#if defined(sun)
+#ifdef illumos
char ipath[20], opath[20]; /* big enough for /dev/fd/ + INT_MAX + \0 */
#endif
char verdef[32]; /* big enough for -D__SUNW_D_VERSION=0x%08x + \0 */
@@ -1898,7 +1898,7 @@ dt_preproc(dtrace_hdl_t *dtp, FILE *ifp)
int wstat, estat;
pid_t pid;
-#if defined(sun)
+#ifdef illumos
off64_t off;
#else
off_t off = 0;
@@ -1929,7 +1929,7 @@ dt_preproc(dtrace_hdl_t *dtp, FILE *ifp)
(void) fseeko64(ifp, off, SEEK_SET);
}
-#if defined(sun)
+#ifdef illumos
(void) snprintf(ipath, sizeof (ipath), "/dev/fd/%d", fileno(ifp));
(void) snprintf(opath, sizeof (opath), "/dev/fd/%d", fileno(ofp));
#endif
@@ -1940,7 +1940,7 @@ dt_preproc(dtrace_hdl_t *dtp, FILE *ifp)
"-D__SUNW_D_VERSION=0x%08x", dtp->dt_vmax);
argv[argc++] = verdef;
-#if defined(sun)
+#ifdef illumos
switch (dtp->dt_stdcmode) {
case DT_STDC_XA:
case DT_STDC_XT:
@@ -1982,7 +1982,7 @@ dt_preproc(dtrace_hdl_t *dtp, FILE *ifp)
}
if (pid == 0) {
-#if !defined(sun)
+#ifndef illumos
if (isatty(fileno(ifp)) == 0)
lseek(fileno(ifp), off, SEEK_SET);
dup2(fileno(ifp), 0);
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c
index 2ed50c6..04c022b 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c
@@ -35,12 +35,12 @@
#include <limits.h>
#include <assert.h>
#include <ctype.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#endif
#include <dt_impl.h>
#include <dt_pq.h>
-#if !defined(sun)
+#ifndef illumos
#include <libproc_compat.h>
#endif
@@ -2961,7 +2961,7 @@ dt_get_buf(dtrace_hdl_t *dtp, int cpu, dtrace_bufdesc_t **bufp)
buf->dtbd_size = size;
buf->dtbd_cpu = cpu;
-#if defined(sun)
+#ifdef illumos
if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, buf) == -1) {
#else
if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, &buf) == -1) {
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c
index 5442683..4fc8876 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c
@@ -26,12 +26,12 @@
*/
#include <sys/types.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/sysmacros.h>
#endif
#include <strings.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#endif
#include <assert.h>
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_error.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_error.c
index 2327ff7..339e2de 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_error.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_error.c
@@ -145,7 +145,7 @@ dtrace_errno(dtrace_hdl_t *dtp)
return (dtp->dt_errno);
}
-#if defined(sun)
+#ifdef illumos
int
dt_set_errno(dtrace_hdl_t *dtp, int err)
{
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_handle.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_handle.c
index fe1ec7a..f26126b 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_handle.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_handle.c
@@ -31,7 +31,7 @@
#include <errno.h>
#include <unistd.h>
#include <assert.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#endif
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_ident.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_ident.c
index 5a2f0e4..b9164ac 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_ident.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_ident.c
@@ -28,18 +28,18 @@
#pragma ident "%Z%%M% %I% %E% SMI"
-#if defined(sun)
+#ifdef illumos
#include <sys/sysmacros.h>
#endif
#include <strings.h>
#include <stdlib.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#endif
#include <assert.h>
#include <errno.h>
#include <ctype.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/procfs_isa.h>
#endif
#include <limits.h>
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h
index b7abbc2..348231c 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h
@@ -34,7 +34,7 @@
#include <sys/param.h>
#include <sys/objfs.h>
-#if !defined(sun)
+#ifndef illumos
#include <sys/bitmap.h>
#include <sys/utsname.h>
#include <sys/ioccom.h>
@@ -45,7 +45,7 @@
#include <libctf.h>
#include <dtrace.h>
#include <gelf.h>
-#if defined(sun)
+#ifdef illumos
#include <synch.h>
#endif
@@ -142,7 +142,7 @@ typedef struct dt_module {
GElf_Addr dm_bss_va; /* virtual address of BSS */
GElf_Xword dm_bss_size; /* size in bytes of BSS */
dt_idhash_t *dm_extern; /* external symbol definitions */
-#if !defined(sun)
+#ifndef illumos
caddr_t dm_reloc_offset; /* Symbol relocation offset. */
uintptr_t *dm_sec_offsets;
#endif
@@ -296,7 +296,7 @@ struct dtrace_hdl {
int dt_version; /* library version requested by client */
int dt_ctferr; /* error resulting from last CTF failure */
int dt_errno; /* error resulting from last failed operation */
-#if !defined(sun)
+#ifndef illumos
const char *dt_errfile;
int dt_errline;
#endif
@@ -305,7 +305,7 @@ struct dtrace_hdl {
int dt_fterr; /* saved errno from failed open of dt_ftfd */
int dt_cdefs_fd; /* file descriptor for C CTF debugging cache */
int dt_ddefs_fd; /* file descriptor for D CTF debugging cache */
-#if defined(sun)
+#ifdef illumos
int dt_stdout_fd; /* file descriptor for saved stdout */
#else
FILE *dt_freopen_fp; /* file pointer for freopened stdout */
@@ -596,7 +596,7 @@ extern int dt_version_defined(dt_version_t);
extern char *dt_cpp_add_arg(dtrace_hdl_t *, const char *);
extern char *dt_cpp_pop_arg(dtrace_hdl_t *);
-#if defined(sun)
+#ifdef illumos
extern int dt_set_errno(dtrace_hdl_t *, int);
#else
int _dt_set_errno(dtrace_hdl_t *, int, const char *, int);
@@ -606,7 +606,7 @@ void dt_get_errloc(dtrace_hdl_t *, const char **, int *);
extern void dt_set_errmsg(dtrace_hdl_t *, const char *, const char *,
const char *, int, const char *, va_list);
-#if defined(sun)
+#ifdef illumos
extern int dt_ioctl(dtrace_hdl_t *, int, void *);
#else
extern int dt_ioctl(dtrace_hdl_t *, u_long, void *);
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l
index bd41171..192e1e2 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l
@@ -44,7 +44,7 @@
* We need to undefine lex's input and unput macros so that references to these
* call the functions provided at the end of this source file.
*/
-#if defined(sun)
+#ifdef illumos
#undef input
#undef unput
#else
@@ -79,7 +79,7 @@
#endif
static int id_or_type(const char *);
-#if defined(sun)
+#ifdef illumos
static int input(void);
static void unput(int);
#endif
@@ -740,7 +740,7 @@ yyinit(dt_pcb_t *pcb)
yypcb = pcb;
yylineno = 1;
yypragma = NULL;
-#if defined(sun)
+#ifdef illumos
yysptr = yysbuf;
#endif
YY_FLUSH_BUFFER;
@@ -839,7 +839,7 @@ id_or_type(const char *s)
return (ttok);
}
-#if defined(sun)
+#ifdef illumos
static int
input(void)
{
@@ -881,4 +881,4 @@ unput(int c)
*yysptr++ = c;
yytchar = c;
}
-#endif
+#endif /* illumos */
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
index dd8a2de..b73c67e 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
@@ -30,7 +30,7 @@
#include <elf.h>
#include <sys/types.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/sysmacros.h>
#else
#define P2ROUNDUP(x, align) (-(-(x) & -(align)))
@@ -38,7 +38,7 @@
#include <unistd.h>
#include <strings.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#endif
#include <limits.h>
@@ -47,7 +47,7 @@
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
-#if defined(sun)
+#ifdef illumos
#include <wait.h>
#else
#include <sys/wait.h>
@@ -1609,7 +1609,7 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
return (dt_link_error(dtp, elf, fd, bufs,
"failed to allocate space for probe"));
}
-#if !defined(sun)
+#ifndef illumos
/*
* Our linker doesn't understand the SUNW_IGNORE ndx and
* will try to use this relocation when we build the
@@ -1643,7 +1643,7 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
* already been processed by an earlier link
* invocation.
*/
-#if !defined(sun)
+#ifndef illumos
#define SHN_SUNW_IGNORE SHN_ABS
#endif
if (rsym.st_shndx != SHN_SUNW_IGNORE) {
@@ -1659,7 +1659,7 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
(void) elf_end(elf);
(void) close(fd);
-#if !defined(sun)
+#ifndef illumos
if (nsym > 0)
#endif
while ((pair = bufs) != NULL) {
@@ -1680,7 +1680,7 @@ int
dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
const char *file, int objc, char *const objv[])
{
-#if !defined(sun)
+#ifndef illumos
char tfile[PATH_MAX];
Elf *e;
Elf_Scn *scn;
@@ -1703,7 +1703,7 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
size_t len;
int eprobes = 0, ret = 0;
-#if !defined(sun)
+#ifndef illumos
if (access(file, R_OK) == 0) {
fprintf(stderr, "dtrace: target object (%s) already exists. "
"Please remove the target\ndtrace: object and rebuild all "
@@ -1781,7 +1781,7 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
if ((dof = dtrace_dof_create(dtp, pgp, dflags)) == NULL)
return (-1); /* errno is set for us */
-#if defined(sun)
+#ifdef illumos
/*
* Create a temporary file and then unlink it if we're going to
* combine it with drti.o later. We can still refer to it in child
@@ -1825,12 +1825,12 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
}
-#if defined(sun)
+#ifdef illumos
if (!dtp->dt_lazyload)
(void) unlink(file);
#endif
-#if defined(sun)
+#ifdef illumos
if (dtp->dt_oflags & DTRACE_O_LP64)
status = dump_elf64(dtp, dof, fd);
else
@@ -1846,7 +1846,7 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
}
if (!dtp->dt_lazyload) {
-#if defined(sun)
+#ifdef illumos
const char *fmt = "%s -o %s -r -Blocal -Breduce /dev/fd/%d %s";
if (dtp->dt_oflags & DTRACE_O_LP64) {
@@ -1912,7 +1912,7 @@ 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)
+#ifndef illumos
/*
* FreeBSD's ld(1) is not instructed to interpret and add
* correctly the SUNW_dof section present in tfile.
@@ -1999,7 +1999,7 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
done:
dtrace_dof_destroy(dtp, dof);
-#if !defined(sun)
+#ifndef illumos
unlink(tfile);
#endif
return (ret);
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c
index 6ab7cd9..20081ed 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c
@@ -156,7 +156,7 @@ dt_epid_add(dtrace_hdl_t *dtp, dtrace_epid_t id)
enabled->dtepd_epid = id;
enabled->dtepd_nrecs = 1;
-#if defined(sun)
+#ifdef illumos
if (dt_ioctl(dtp, DTRACEIOC_EPROBE, enabled) == -1) {
#else
if (dt_ioctl(dtp, DTRACEIOC_EPROBE, &enabled) == -1) {
@@ -180,7 +180,7 @@ dt_epid_add(dtrace_hdl_t *dtp, dtrace_epid_t id)
if ((enabled = nenabled) == NULL)
return (dt_set_errno(dtp, EDT_NOMEM));
-#if defined(sun)
+#ifdef illumos
rval = dt_ioctl(dtp, DTRACEIOC_EPROBE, enabled);
#else
rval = dt_ioctl(dtp, DTRACEIOC_EPROBE, &enabled);
@@ -356,7 +356,7 @@ dt_aggid_add(dtrace_hdl_t *dtp, dtrace_aggid_t id)
agg->dtagd_id = id;
agg->dtagd_nrecs = 1;
-#if defined(sun)
+#ifdef illumos
if (dt_ioctl(dtp, DTRACEIOC_AGGDESC, agg) == -1) {
#else
if (dt_ioctl(dtp, DTRACEIOC_AGGDESC, &agg) == -1) {
@@ -379,7 +379,7 @@ dt_aggid_add(dtrace_hdl_t *dtp, dtrace_aggid_t id)
if ((agg = nagg) == NULL)
return (dt_set_errno(dtp, EDT_NOMEM));
-#if defined(sun)
+#ifdef illumos
rval = dt_ioctl(dtp, DTRACEIOC_AGGDESC, agg);
#else
rval = dt_ioctl(dtp, DTRACEIOC_AGGDESC, &agg);
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c
index 9dd52b5..dcfff2f 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c
@@ -24,10 +24,11 @@
*/
/*
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2016, Pedro Giffuni. All rights reserved.
*/
#include <sys/types.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/modctl.h>
#include <sys/kobj.h>
#include <sys/kobj_impl.h>
@@ -41,7 +42,7 @@
#endif
#include <unistd.h>
-#if defined(sun)
+#ifdef illumos
#include <project.h>
#endif
#include <strings.h>
@@ -51,7 +52,7 @@
#include <assert.h>
#include <errno.h>
#include <dirent.h>
-#if !defined(sun)
+#ifndef illumos
#include <fcntl.h>
#include <libproc_compat.h>
#endif
@@ -572,7 +573,7 @@ dt_module_load_sect(dtrace_hdl_t *dtp, dt_module_t *dmp, ctf_sect_t *ctsp)
if (sp == NULL || (dp = elf_getdata(sp, NULL)) == NULL)
return (0);
-#if defined(sun)
+#ifdef illumos
ctsp->cts_data = dp->d_buf;
#else
if ((ctsp->cts_data = malloc(dp->d_size)) == NULL)
@@ -704,22 +705,20 @@ dt_module_load_proc(dtrace_hdl_t *dtp, dt_module_t *dmp)
return (dt_set_errno(dtp, EDT_CANTLOAD));
}
- dmp->dm_libctfp = malloc(sizeof (ctf_file_t *) * arg.dpa_count);
+ dmp->dm_libctfp = calloc(arg.dpa_count, sizeof (ctf_file_t *));
if (dmp->dm_libctfp == NULL) {
dt_proc_unlock(dtp, p);
dt_proc_release(dtp, p);
return (dt_set_errno(dtp, EDT_NOMEM));
}
- bzero(dmp->dm_libctfp, sizeof (ctf_file_t *) * arg.dpa_count);
- dmp->dm_libctfn = malloc(sizeof (char *) * arg.dpa_count);
+ dmp->dm_libctfn = calloc(arg.dpa_count, sizeof (char *));
if (dmp->dm_libctfn == NULL) {
free(dmp->dm_libctfp);
dt_proc_unlock(dtp, p);
dt_proc_release(dtp, p);
return (dt_set_errno(dtp, EDT_NOMEM));
}
- bzero(dmp->dm_libctfn, sizeof (char *) * arg.dpa_count);
dmp->dm_nctflibs = arg.dpa_count;
@@ -800,17 +799,14 @@ dt_module_load(dtrace_hdl_t *dtp, dt_module_t *dmp)
dmp->dm_nsymbuckets = _dtrace_strbuckets;
dmp->dm_symfree = 1; /* first free element is index 1 */
- dmp->dm_symbuckets = malloc(sizeof (uint_t) * dmp->dm_nsymbuckets);
- dmp->dm_symchains = malloc(sizeof (dt_sym_t) * dmp->dm_nsymelems + 1);
+ dmp->dm_symbuckets = calloc(dmp->dm_nsymbuckets, sizeof (uint_t));
+ dmp->dm_symchains = calloc(dmp->dm_nsymelems + 1, sizeof (dt_sym_t));
if (dmp->dm_symbuckets == NULL || dmp->dm_symchains == NULL) {
dt_module_unload(dtp, dmp);
return (dt_set_errno(dtp, EDT_NOMEM));
}
- bzero(dmp->dm_symbuckets, sizeof (uint_t) * dmp->dm_nsymbuckets);
- bzero(dmp->dm_symchains, sizeof (dt_sym_t) * dmp->dm_nsymelems + 1);
-
/*
* Iterate over the symbol table data buffer and insert each symbol
* name into the name hash if the name and type are valid. Then
@@ -921,7 +917,7 @@ dt_module_unload(dtrace_hdl_t *dtp, dt_module_t *dmp)
ctf_close(dmp->dm_ctfp);
dmp->dm_ctfp = NULL;
-#if !defined(sun)
+#ifndef illumos
if (dmp->dm_ctdata.cts_data != NULL) {
free(dmp->dm_ctdata.cts_data);
}
@@ -1115,7 +1111,7 @@ dt_module_getctflib(dtrace_hdl_t *dtp, dt_module_t *dmp, const char *name)
* including the path.
*/
static void
-#if defined(sun)
+#ifdef illumos
dt_module_update(dtrace_hdl_t *dtp, const char *name)
#else
dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat)
@@ -1132,7 +1128,7 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat)
Elf_Data *dp;
Elf_Scn *sp;
-#if defined(sun)
+#ifdef illumos
(void) snprintf(fname, sizeof (fname),
"%s/%s/object", OBJFS_ROOT, name);
#else
@@ -1242,7 +1238,7 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat)
}
dmp->dm_flags |= DT_DM_KERNEL;
-#if defined(sun)
+#ifdef illumos
dmp->dm_modid = (int)OBJFS_MODID(st.st_ino);
#else
/*
@@ -1265,7 +1261,7 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat)
}
}
#endif
-#endif
+#endif /* illumos */
if (dmp->dm_info.objfs_info_primary)
dmp->dm_flags |= DT_DM_PRIMARY;
@@ -1291,7 +1287,7 @@ dtrace_update(dtrace_hdl_t *dtp)
dmp != NULL; dmp = dt_list_next(dmp))
dt_module_unload(dtp, dmp);
-#if defined(sun)
+#ifdef illumos
/*
* Open /system/object and attempt to create a libdtrace module for
* each kernel module that is loaded on the current system.
@@ -1331,11 +1327,11 @@ dtrace_update(dtrace_hdl_t *dtp)
dt_idhash_lookup(dtp->dt_macros, "pid")->di_id = getpid();
dt_idhash_lookup(dtp->dt_macros, "pgid")->di_id = getpgid(0);
dt_idhash_lookup(dtp->dt_macros, "ppid")->di_id = getppid();
-#if defined(sun)
+#ifdef illumos
dt_idhash_lookup(dtp->dt_macros, "projid")->di_id = getprojid();
#endif
dt_idhash_lookup(dtp->dt_macros, "sid")->di_id = getsid(0);
-#if defined(sun)
+#ifdef illumos
dt_idhash_lookup(dtp->dt_macros, "taskid")->di_id = gettaskid();
#endif
dt_idhash_lookup(dtp->dt_macros, "uid")->di_id = getuid();
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
index f6c140b..f0e1294 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
@@ -26,7 +26,7 @@
*/
#include <sys/types.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/modctl.h>
#include <sys/systeminfo.h>
#endif
@@ -34,7 +34,7 @@
#include <libelf.h>
#include <strings.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#endif
#include <limits.h>
@@ -55,7 +55,7 @@
#include <dt_printf.h>
#include <dt_string.h>
#include <dt_provider.h>
-#if !defined(sun)
+#ifndef illumos
#include <sys/sysctl.h>
#include <string.h>
#endif
@@ -159,7 +159,7 @@ const dt_version_t _dtrace_versions[] = {
/*
* Global variables that are formatted on FreeBSD based on the kernel file name.
*/
-#if !defined(sun)
+#ifndef illumos
static char curthread_str[MAXPATHLEN];
static char intmtx_str[MAXPATHLEN];
static char threadmtx_str[MAXPATHLEN];
@@ -241,7 +241,7 @@ static const dt_ident_t _dtrace_globals[] = {
{ "curthread", DT_IDENT_SCALAR, 0, DIF_VAR_CURTHREAD,
{ DTRACE_STABILITY_STABLE, DTRACE_STABILITY_PRIVATE,
DTRACE_CLASS_COMMON }, DT_VERS_1_0,
-#if defined(sun)
+#ifdef illumos
&dt_idops_type, "genunix`kthread_t *" },
#else
&dt_idops_type, curthread_str },
@@ -292,13 +292,13 @@ static const dt_ident_t _dtrace_globals[] = {
{ "index", DT_IDENT_FUNC, 0, DIF_SUBR_INDEX, DT_ATTR_STABCMN, DT_VERS_1_1,
&dt_idops_func, "int(const char *, const char *, [int])" },
{ "inet_ntoa", DT_IDENT_FUNC, 0, DIF_SUBR_INET_NTOA, DT_ATTR_STABCMN,
-#if defined(sun)
+#ifdef illumos
DT_VERS_1_5, &dt_idops_func, "string(ipaddr_t *)" },
#else
DT_VERS_1_5, &dt_idops_func, "string(in_addr_t *)" },
#endif
{ "inet_ntoa6", DT_IDENT_FUNC, 0, DIF_SUBR_INET_NTOA6, DT_ATTR_STABCMN,
-#if defined(sun)
+#ifdef illumos
DT_VERS_1_5, &dt_idops_func, "string(in6_addr_t *)" },
#else
DT_VERS_1_5, &dt_idops_func, "string(struct in6_addr *)" },
@@ -323,7 +323,7 @@ static const dt_ident_t _dtrace_globals[] = {
&dt_idops_func, "void(@)" },
{ "memref", DT_IDENT_FUNC, 0, DIF_SUBR_MEMREF, DT_ATTR_STABCMN, DT_VERS_1_1,
&dt_idops_func, "uintptr_t *(void *, size_t)" },
-#if !defined(sun)
+#ifndef illumos
{ "memstr", DT_IDENT_FUNC, 0, DIF_SUBR_MEMSTR, DT_ATTR_STABCMN, DT_VERS_1_0,
&dt_idops_func, "string(void *, char, size_t)" },
#endif
@@ -337,7 +337,7 @@ static const dt_ident_t _dtrace_globals[] = {
{ "msgsize", DT_IDENT_FUNC, 0, DIF_SUBR_MSGSIZE,
DT_ATTR_STABCMN, DT_VERS_1_0,
&dt_idops_func, "size_t(mblk_t *)" },
-#if defined(sun)
+#ifdef illumos
{ "mutex_owned", DT_IDENT_FUNC, 0, DIF_SUBR_MUTEX_OWNED,
DT_ATTR_EVOLCMN, DT_VERS_1_0,
&dt_idops_func, "int(genunix`kmutex_t *)" },
@@ -408,7 +408,7 @@ static const dt_ident_t _dtrace_globals[] = {
&dt_idops_func, "int()" },
{ "rindex", DT_IDENT_FUNC, 0, DIF_SUBR_RINDEX, DT_ATTR_STABCMN, DT_VERS_1_1,
&dt_idops_func, "int(const char *, const char *, [int])" },
-#if defined(sun)
+#ifdef illumos
{ "rw_iswriter", DT_IDENT_FUNC, 0, DIF_SUBR_RW_ISWRITER,
DT_ATTR_EVOLCMN, DT_VERS_1_0,
&dt_idops_func, "int(genunix`krwlock_t *)" },
@@ -466,7 +466,7 @@ static const dt_ident_t _dtrace_globals[] = {
&dt_idops_func, "string(const char *, int, [int])" },
{ "sum", DT_IDENT_AGGFUNC, 0, DTRACEAGG_SUM, DT_ATTR_STABCMN, DT_VERS_1_0,
&dt_idops_func, "void(@)" },
-#if !defined(sun)
+#ifndef illumos
{ "sx_isexclusive", DT_IDENT_FUNC, 0, DIF_SUBR_SX_ISEXCLUSIVE,
DT_ATTR_EVOLCMN, DT_VERS_1_0,
&dt_idops_func, sxlock_str },
@@ -526,12 +526,12 @@ static const dt_ident_t _dtrace_globals[] = {
{ "walltimestamp", DT_IDENT_SCALAR, 0, DIF_VAR_WALLTIMESTAMP,
DT_ATTR_STABCMN, DT_VERS_1_0,
&dt_idops_type, "int64_t" },
-#if defined(sun)
+#ifdef illumos
{ "zonename", DT_IDENT_SCALAR, 0, DIF_VAR_ZONENAME,
DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" },
#endif
-#if !defined(sun)
+#ifndef illumos
{ "cpu", DT_IDENT_SCALAR, 0, DIF_VAR_CPU,
DT_ATTR_STABCMN, DT_VERS_1_6_3, &dt_idops_type, "int" },
#endif
@@ -775,7 +775,7 @@ const dtrace_pattr_t _dtrace_prvdesc = {
{ DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_COMMON },
};
-#if defined(sun)
+#ifdef illumos
const char *_dtrace_defcpp = "/usr/ccs/lib/cpp"; /* default cpp(1) to invoke */
const char *_dtrace_defld = "/usr/ccs/bin/ld"; /* default ld(1) to invoke */
#else
@@ -784,7 +784,7 @@ const char *_dtrace_defld = "ld"; /* default ld(1) to invoke */
#endif
const char *_dtrace_libdir = "/usr/lib/dtrace"; /* default library directory */
-#if defined(sun)
+#ifdef illumos
const char *_dtrace_provdir = "/dev/dtrace/provider"; /* provider directory */
#else
const char *_dtrace_provdir = "/dev/dtrace"; /* provider directory */
@@ -809,7 +809,7 @@ typedef struct dt_fdlist {
uint_t df_size; /* size of df_fds[] */
} dt_fdlist_t;
-#if defined(sun)
+#ifdef illumos
#pragma init(_dtrace_init)
#else
void _dtrace_init(void) __attribute__ ((constructor));
@@ -845,7 +845,7 @@ dt_provmod_open(dt_provmod_t **provmod, dt_fdlist_t *dfp)
dt_provmod_t *prov;
char path[PATH_MAX];
int fd;
-#if defined(sun)
+#ifdef illumos
struct dirent *dp, *ep;
DIR *dirp;
@@ -892,7 +892,7 @@ dt_provmod_open(dt_provmod_t **provmod, dt_fdlist_t *dfp)
}
(void) closedir(dirp);
-#else
+#else /* !illumos */
char *p;
char *p1;
char *p_providers = NULL;
@@ -977,7 +977,7 @@ dt_provmod_open(dt_provmod_t **provmod, dt_fdlist_t *dfp)
}
if (p_providers != NULL)
free(p_providers);
-#endif
+#endif /* illumos */
}
static void
@@ -994,7 +994,7 @@ dt_provmod_destroy(dt_provmod_t **provmod)
*provmod = NULL;
}
-#if defined(sun)
+#ifdef illumos
static const char *
dt_get_sysinfo(int cmd, char *buf, size_t len)
{
@@ -1107,7 +1107,7 @@ dt_vopen(int version, int flags, int *errp,
err = errno;
}
#endif
-#if defined(sun)
+#ifdef illumos
ftfd = open("/dev/dtrace/provider/fasttrap", O_RDWR);
#else
ftfd = open("/dev/dtrace/fasttrap", O_RDWR);
@@ -1149,7 +1149,7 @@ alloc:
bzero(dtp, sizeof (dtrace_hdl_t));
dtp->dt_oflags = flags;
-#if defined(sun)
+#ifdef illumos
dtp->dt_prcmode = DT_PROC_STOP_PREINIT;
#else
dtp->dt_prcmode = DT_PROC_STOP_POSTINIT;
@@ -1165,7 +1165,7 @@ alloc:
dtp->dt_fterr = fterr;
dtp->dt_cdefs_fd = -1;
dtp->dt_ddefs_fd = -1;
-#if defined(sun)
+#ifdef illumos
dtp->dt_stdout_fd = -1;
#else
dtp->dt_freopen_fp = NULL;
@@ -1197,7 +1197,7 @@ alloc:
dtp->dt_cpp_argv[0] = (char *)strbasename(dtp->dt_cpp_path);
-#if defined(sun)
+#ifdef illumos
(void) snprintf(isadef, sizeof (isadef), "-D__SUNW_D_%u",
(uint_t)(sizeof (void *) * NBBY));
@@ -1237,7 +1237,7 @@ alloc:
return (set_open_errno(dtp, errp, EDT_NOMEM));
#endif
-#if defined(sun)
+#ifdef illumos
#ifdef __x86
/*
* On x86 systems, __i386 is defined for <sys/isa_defs.h> for 32-bit
@@ -1277,7 +1277,7 @@ alloc:
* 'kern.bootfile' sysctl value tells us exactly which file is being
* used as the kernel.
*/
-#if !defined(sun)
+#ifndef illumos
{
char bootfile[MAXPATHLEN];
char *p;
@@ -1639,7 +1639,7 @@ dtrace_close(dtrace_hdl_t *dtp)
(void) close(dtp->dt_cdefs_fd);
if (dtp->dt_ddefs_fd != -1)
(void) close(dtp->dt_ddefs_fd);
-#if defined(sun)
+#ifdef illumos
if (dtp->dt_stdout_fd != -1)
(void) close(dtp->dt_stdout_fd);
#else
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c
index 832af88..e9164d0 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c
@@ -38,7 +38,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#endif
#include <errno.h>
@@ -871,7 +871,7 @@ dt_options_load(dtrace_hdl_t *dtp)
bzero(&hdr, sizeof (dof_hdr_t));
hdr.dofh_loadsz = sizeof (dof_hdr_t);
-#if defined(sun)
+#ifdef illumos
if (dt_ioctl(dtp, DTRACEIOC_DOFGET, &hdr) == -1)
#else
dof = &hdr;
@@ -889,7 +889,7 @@ dt_options_load(dtrace_hdl_t *dtp)
for (i = 0; i < DTRACEOPT_MAX; i++)
dtp->dt_options[i] = DTRACEOPT_UNSET;
-#if defined(sun)
+#ifdef illumos
if (dt_ioctl(dtp, DTRACEIOC_DOFGET, dof) == -1)
#else
if (dt_ioctl(dtp, DTRACEIOC_DOFGET, &dof) == -1)
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c
index 6ce3dad..ee31cef 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c
@@ -102,7 +102,7 @@
#include <setjmp.h>
#include <strings.h>
#include <assert.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#endif
#include <stdlib.h>
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c
index c865a2d..2472d8e 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c
@@ -33,7 +33,7 @@
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#endif
#include <libgen.h>
@@ -44,7 +44,7 @@
#include <dt_program.h>
#include <dt_pid.h>
#include <dt_string.h>
-#if !defined(sun)
+#ifndef illumos
#include <libproc_compat.h>
#endif
#include <dt_module.h>
@@ -74,7 +74,7 @@ typedef struct dt_pid_probe {
static void
dt_pid_objname(char *buf, size_t len, Lmid_t lmid, const char *obj)
{
-#if defined(sun)
+#ifdef illumos
if (lmid == LM_ID_BASE)
(void) strncpy(buf, obj, len);
else
@@ -126,7 +126,7 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func)
int isdash = strcmp("-", func) == 0;
pid_t pid;
-#if defined(sun)
+#ifdef illumos
pid = Pstatus(pp->dpp_pr)->pr_pid;
#else
pid = proc_getpid(pp->dpp_pr);
@@ -270,7 +270,7 @@ dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj)
if (obj == NULL)
return (0);
-#if defined(sun)
+#ifdef illumos
(void) Plmid(pp->dpp_pr, pmp->pr_vaddr, &pp->dpp_lmid);
#endif
@@ -279,7 +279,7 @@ dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj)
pp->dpp_obj = obj;
else
pp->dpp_obj++;
-#if defined(sun)
+#ifdef illumos
if (Pxlookup_by_name(pp->dpp_pr, pp->dpp_lmid, obj, ".stret1", &sym,
NULL) == 0)
pp->dpp_stret[0] = sym.st_value;
@@ -337,7 +337,7 @@ dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj)
GELF_ST_INFO(STB_LOCAL, STT_FUNC);
sym.st_other = 0;
sym.st_value = 0;
-#if defined(sun)
+#ifdef illumos
sym.st_size = Pstatus(pp->dpp_pr)->pr_dmodel ==
PR_MODEL_ILP32 ? -1U : -1ULL;
#else
@@ -404,7 +404,7 @@ dt_pid_mod_filt(void *arg, const prmap_t *pmp, const char *obj)
if (gmatch(obj, pp->dpp_mod))
return (dt_pid_per_mod(pp, pmp, obj));
-#if defined(sun)
+#ifdef illumos
(void) Plmid(pp->dpp_pr, pmp->pr_vaddr, &pp->dpp_lmid);
#else
pp->dpp_lmid = 0;
@@ -418,7 +418,7 @@ dt_pid_mod_filt(void *arg, const prmap_t *pmp, const char *obj)
if (gmatch(pp->dpp_obj, pp->dpp_mod))
return (dt_pid_per_mod(pp, pmp, obj));
-#if defined(sun)
+#ifdef illumos
(void) Plmid(pp->dpp_pr, pmp->pr_vaddr, &pp->dpp_lmid);
#endif
@@ -434,7 +434,7 @@ static const prmap_t *
dt_pid_fix_mod(dtrace_probedesc_t *pdp, struct ps_prochandle *P)
{
char m[MAXPATHLEN];
-#if defined(sun)
+#ifdef illumos
Lmid_t lmid = PR_LMID_EVERY;
#else
Lmid_t lmid = 0;
@@ -442,7 +442,7 @@ dt_pid_fix_mod(dtrace_probedesc_t *pdp, struct ps_prochandle *P)
const char *obj;
const prmap_t *pmp;
-#if defined(sun)
+#ifdef illumos
/*
* Pick apart the link map from the library name.
*/
@@ -470,7 +470,7 @@ dt_pid_fix_mod(dtrace_probedesc_t *pdp, struct ps_prochandle *P)
if ((pmp = Plmid_to_map(P, lmid, obj)) == NULL)
return (NULL);
-#if defined(sun)
+#ifdef illumos
(void) Pobjname(P, pmp->pr_vaddr, m, sizeof (m));
if ((obj = strrchr(m, '/')) == NULL)
obj = &m[0];
@@ -571,7 +571,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)
+#ifdef illumos
prsyminfo_t sip;
#endif
dof_helper_t dh;
@@ -609,13 +609,13 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname)
dh.dofhp_addr = (e_type == ET_EXEC) ? 0 : pmp->pr_vaddr;
dt_pid_objname(dh.dofhp_mod, sizeof (dh.dofhp_mod),
-#if defined(sun)
+#ifdef illumos
sip.prs_lmid, mname);
#else
0, mname);
#endif
-#if defined(sun)
+#ifdef illumos
if (fd == -1 &&
(fd = pr_open(P, "/dev/dtrace/helper", O_RDWR, 0)) < 0) {
dt_dprintf("pr_open of helper device failed: %s\n",
@@ -628,7 +628,7 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname)
#endif
}
-#if defined(sun)
+#ifdef illumos
if (fd != -1)
(void) pr_close(P, fd);
#endif
@@ -644,13 +644,13 @@ dt_pid_create_usdt_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp,
int ret = 0;
assert(DT_MUTEX_HELD(&dpr->dpr_lock));
-#if defined(sun)
+#ifdef illumos
(void) Pupdate_maps(P);
if (Pobject_iter(P, dt_pid_usdt_mapping, P) != 0) {
ret = -1;
(void) dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_USDT,
"failed to instantiate probes for pid %d: %s",
-#if defined(sun)
+#ifdef illumos
(int)Pstatus(P)->pr_pid, strerror(errno));
#else
(int)proc_getpid(P), strerror(errno));
@@ -852,7 +852,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)
+#ifdef illumos
prsyminfo_t si;
#else
void *si;
@@ -941,7 +941,7 @@ 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)
+#ifdef illumos
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);
@@ -977,7 +977,7 @@ 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)
+#ifdef illumos
} else {
if (ctf_func_args(fp, si.prs_id, argc, argv) == CTF_ERR)
goto out;
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c
index 760c2f6..50d0680 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c
@@ -28,7 +28,7 @@
#include <assert.h>
#include <strings.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#endif
#include <fcntl.h>
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c
index 720eba6..d408aed 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c
@@ -25,7 +25,7 @@
* Copyright (c) 2013 by Delphix. All rights reserved.
*/
-#if defined(sun)
+#ifdef illumos
#include <sys/sysmacros.h>
#else
#define ABS(a) ((a) < 0 ? -(a) : (a))
@@ -33,7 +33,7 @@
#include <string.h>
#include <strings.h>
#include <stdlib.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#endif
#include <assert.h>
@@ -467,7 +467,7 @@ pfprint_time(dtrace_hdl_t *dtp, FILE *fp, const char *format,
* Below, we turn this into the canonical adb/mdb /[yY] format,
* "1973 Dec 3 17:20:00".
*/
-#if defined(sun)
+#ifdef illumos
(void) ctime_r(&sec, src, sizeof (src));
#else
(void) ctime_r(&sec, src);
@@ -518,7 +518,7 @@ pfprint_port(dtrace_hdl_t *dtp, FILE *fp, const char *format,
char buf[256];
struct servent *sv, res;
-#if defined(sun)
+#ifdef illumos
if ((sv = getservbyport_r(port, NULL, &res, buf, sizeof (buf))) != NULL)
#else
if (getservbyport_r(port, NULL, &res, buf, sizeof (buf), &sv) > 0)
@@ -544,7 +544,7 @@ pfprint_inetaddr(dtrace_hdl_t *dtp, FILE *fp, const char *format,
s[size] = '\0';
if (strchr(s, ':') == NULL && inet_pton(AF_INET, s, inetaddr) != -1) {
-#if defined(sun)
+#ifdef illumos
if ((host = gethostbyaddr_r(inetaddr, NS_INADDRSZ,
AF_INET, &res, buf, sizeof (buf), &e)) != NULL)
#else
@@ -694,7 +694,7 @@ static const dt_pfconv_t _dtrace_conversions[] = {
{ "S", "s", pfproto_cstr, pfcheck_str, pfprint_estr },
{ "T", "s", "int64_t", pfcheck_time, pfprint_time822 },
{ "u", "u", pfproto_xint, pfcheck_xint, pfprint_uint },
-#if defined(sun)
+#ifdef illumos
{ "wc", "wc", "int", pfcheck_type, pfprint_sint }, /* a.k.a. wchar_t */
{ "ws", "ws", pfproto_wstr, pfcheck_wstr, pfprint_wstr },
#else
@@ -1669,7 +1669,7 @@ dtrace_freopen(dtrace_hdl_t *dtp, FILE *fp, void *fmtdata,
if (rval == -1 || fp == NULL)
return (rval);
-#if defined(sun)
+#ifdef illumos
if (pfd->pfd_preflen != 0 &&
strcmp(pfd->pfd_prefix, DT_FREOPEN_RESTORE) == 0) {
/*
@@ -1751,7 +1751,7 @@ dtrace_freopen(dtrace_hdl_t *dtp, FILE *fp, void *fmtdata,
}
(void) fclose(nfp);
-#else
+#else /* !illumos */
/*
* The 'standard output' (which is not necessarily stdout)
* treatment on FreeBSD is implemented differently than on
@@ -1826,7 +1826,7 @@ dtrace_freopen(dtrace_hdl_t *dtp, FILE *fp, void *fmtdata,
/* Remember that the output has been redirected to the new file. */
dtp->dt_freopen_fp = nfp;
-#endif
+#endif /* illumos */
return (rval);
}
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c
index d40a0ae..79c1871 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c
@@ -77,7 +77,7 @@
*/
#include <sys/wait.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/lwp.h>
#endif
#include <strings.h>
@@ -89,7 +89,7 @@
#include <dt_pid.h>
#include <dt_impl.h>
-#if !defined(sun)
+#ifndef illumos
#include <sys/syscall.h>
#include <libproc_compat.h>
#define SYS_forksys SYS_fork
@@ -143,7 +143,7 @@ dt_proc_bpdestroy(dt_proc_t *dpr, int delbkpts)
static void
dt_proc_bpmatch(dtrace_hdl_t *dtp, dt_proc_t *dpr)
{
-#if defined(sun)
+#ifdef illumos
const lwpstatus_t *psp = &Pstatus(dpr->dpr_proc)->pr_lwp;
#else
unsigned long pc;
@@ -152,14 +152,14 @@ dt_proc_bpmatch(dtrace_hdl_t *dtp, dt_proc_t *dpr)
assert(DT_MUTEX_HELD(&dpr->dpr_lock));
-#if !defined(sun)
+#ifndef illumos
proc_regget(dpr->dpr_proc, REG_PC, &pc);
proc_bkptregadj(&pc);
#endif
for (dbp = dt_list_next(&dpr->dpr_bps);
dbp != NULL; dbp = dt_list_next(dbp)) {
-#if defined(sun)
+#ifdef illumos
if (psp->pr_reg[R_PC] == dbp->dbp_addr)
break;
#else
@@ -170,7 +170,7 @@ dt_proc_bpmatch(dtrace_hdl_t *dtp, dt_proc_t *dpr)
if (dbp == NULL) {
dt_dprintf("pid %d: spurious breakpoint wakeup for %lx\n",
-#if defined(sun)
+#ifdef illumos
(int)dpr->dpr_pid, (ulong_t)psp->pr_reg[R_PC]);
#else
(int)dpr->dpr_pid, pc);
@@ -342,7 +342,7 @@ dt_proc_rdwatch(dt_proc_t *dpr, rd_event_e event, const char *evname)
}
(void) dt_proc_bpcreate(dpr, rdn.u.bptaddr,
-#if defined(sun)
+#ifdef illumos
(dt_bkpt_f *)dt_proc_rdevent, (void *)evname);
#else
/* XXX ugly */
@@ -357,7 +357,7 @@ dt_proc_rdwatch(dt_proc_t *dpr, rd_event_e event, const char *evname)
static void
dt_proc_attach(dt_proc_t *dpr, int exec)
{
-#if defined(sun)
+#ifdef illumos
const pstatus_t *psp = Pstatus(dpr->dpr_proc);
#endif
rd_err_e err;
@@ -366,23 +366,23 @@ dt_proc_attach(dt_proc_t *dpr, int exec)
assert(DT_MUTEX_HELD(&dpr->dpr_lock));
if (exec) {
-#if defined(sun)
+#ifdef illumos
if (psp->pr_lwp.pr_errno != 0)
return; /* exec failed: nothing needs to be done */
#endif
dt_proc_bpdestroy(dpr, B_FALSE);
-#if defined(sun)
+#ifdef illumos
Preset_maps(dpr->dpr_proc);
#endif
}
if ((dpr->dpr_rtld = Prd_agent(dpr->dpr_proc)) != NULL &&
(err = rd_event_enable(dpr->dpr_rtld, B_TRUE)) == RD_OK) {
-#if defined(sun)
+#ifdef illumos
dt_proc_rdwatch(dpr, RD_PREINIT, "RD_PREINIT");
#endif
dt_proc_rdwatch(dpr, RD_POSTINIT, "RD_POSTINIT");
-#if defined(sun)
+#ifdef illumos
dt_proc_rdwatch(dpr, RD_DLACTIVITY, "RD_DLACTIVITY");
#endif
} else {
@@ -507,7 +507,7 @@ dt_proc_control(void *arg)
struct ps_prochandle *P = dpr->dpr_proc;
int pid = dpr->dpr_pid;
-#if defined(sun)
+#ifdef illumos
int pfd = Pctlfd(P);
const long wstop = PCWSTOP;
@@ -529,7 +529,7 @@ dt_proc_control(void *arg)
*/
(void) pthread_mutex_lock(&dpr->dpr_lock);
-#if defined(sun)
+#ifdef illumos
(void) Punsetflags(P, PR_ASYNC); /* require synchronous mode */
(void) Psetflags(P, PR_BPTADJ); /* always adjust eip on x86 */
(void) Punsetflags(P, PR_FORK); /* do not inherit on fork */
@@ -562,7 +562,7 @@ dt_proc_control(void *arg)
* If PR_KLC is set, we created the process; otherwise we grabbed it.
* Check for an appropriate stop request and wait for dt_proc_continue.
*/
-#if defined(sun)
+#ifdef illumos
if (Pstatus(P)->pr_flags & PR_KLC)
#else
if (proc_getflags(P) & PR_KLC)
@@ -590,7 +590,7 @@ dt_proc_control(void *arg)
while (!dpr->dpr_quit) {
const lwpstatus_t *psp;
-#if defined(sun)
+#ifdef illumos
if (write(pfd, &wstop, sizeof (wstop)) == -1 && errno == EINTR)
continue; /* check dpr_quit and continue waiting */
#else
@@ -602,7 +602,7 @@ dt_proc_control(void *arg)
(void) pthread_mutex_lock(&dpr->dpr_lock);
-#if defined(sun)
+#ifdef illumos
pwait_locked:
if (Pstopstatus(P, PCNULL, 0) == -1 && errno == EINTR) {
(void) pthread_mutex_unlock(&dpr->dpr_lock);
@@ -612,7 +612,7 @@ pwait_locked:
switch (Pstate(P)) {
case PS_STOP:
-#if defined(sun)
+#ifdef illumos
psp = &Pstatus(P)->pr_lwp;
#else
psp = proc_getlwpstatus(P);
@@ -661,7 +661,7 @@ pwait_locked:
break;
case PS_LOST:
-#if defined(sun)
+#ifdef illumos
if (Preopen(P) == 0)
goto pwait_locked;
#endif
@@ -734,7 +734,7 @@ dt_proc_t *
dt_proc_lookup(dtrace_hdl_t *dtp, struct ps_prochandle *P, int remove)
{
dt_proc_hash_t *dph = dtp->dt_procs;
-#if defined(sun)
+#ifdef illumos
pid_t pid = Pstatus(P)->pr_pid;
#else
pid_t pid = proc_getpid(P);
@@ -772,14 +772,14 @@ dt_proc_destroy(dtrace_hdl_t *dtp, struct ps_prochandle *P)
* an external debugger and we were waiting in dt_proc_waitrun().
* Leave the process in this condition using PRELEASE_HANG.
*/
-#if defined(sun)
+#ifdef illumos
if (!(Pstatus(dpr->dpr_proc)->pr_flags & (PR_KLC | PR_RLC))) {
#else
if (!(proc_getflags(dpr->dpr_proc) & (PR_KLC | PR_RLC))) {
#endif
dt_dprintf("abandoning pid %d\n", (int)dpr->dpr_pid);
rflag = PRELEASE_HANG;
-#if defined(sun)
+#ifdef illumos
} else if (Pstatus(dpr->dpr_proc)->pr_flags & PR_KLC) {
#else
} else if (proc_getflags(dpr->dpr_proc) & PR_KLC) {
@@ -808,7 +808,7 @@ dt_proc_destroy(dtrace_hdl_t *dtp, struct ps_prochandle *P)
*/
(void) pthread_mutex_lock(&dpr->dpr_lock);
dpr->dpr_quit = B_TRUE;
-#if defined(sun)
+#ifdef illumos
(void) _lwp_kill(dpr->dpr_tid, SIGCANCEL);
#else
pthread_kill(dpr->dpr_tid, SIGTHR);
@@ -880,7 +880,7 @@ dt_proc_create_thread(dtrace_hdl_t *dtp, dt_proc_t *dpr, uint_t stop)
(void) sigfillset(&nset);
(void) sigdelset(&nset, SIGABRT); /* unblocked for assert() */
-#if defined(sun)
+#ifdef illumos
(void) sigdelset(&nset, SIGCANCEL); /* see dt_proc_destroy() */
#else
(void) sigdelset(&nset, SIGUSR1); /* see dt_proc_destroy() */
@@ -912,7 +912,7 @@ dt_proc_create_thread(dtrace_hdl_t *dtp, dt_proc_t *dpr, uint_t stop)
* small amount of useful information to help figure it out.
*/
if (dpr->dpr_done) {
-#if defined(sun)
+#ifdef illumos
const psinfo_t *prp = Ppsinfo(dpr->dpr_proc);
int stat = prp ? prp->pr_wstat : 0;
int pid = dpr->dpr_pid;
@@ -963,7 +963,7 @@ dt_proc_create(dtrace_hdl_t *dtp, const char *file, char *const *argv,
(void) pthread_mutex_init(&dpr->dpr_lock, NULL);
(void) pthread_cond_init(&dpr->dpr_cv, NULL);
-#if defined(sun)
+#ifdef illumos
if ((dpr->dpr_proc = Pcreate(file, argv, &err, NULL, 0)) == NULL) {
#else
if ((err = proc_create(file, argv, pcf, child_arg,
@@ -974,7 +974,7 @@ dt_proc_create(dtrace_hdl_t *dtp, const char *file, char *const *argv,
}
dpr->dpr_hdl = dtp;
-#if defined(sun)
+#ifdef illumos
dpr->dpr_pid = Pstatus(dpr->dpr_proc)->pr_pid;
#else
dpr->dpr_pid = proc_getpid(dpr->dpr_proc);
@@ -1039,7 +1039,7 @@ dt_proc_grab(dtrace_hdl_t *dtp, pid_t pid, int flags, int nomonitor)
(void) pthread_mutex_init(&dpr->dpr_lock, NULL);
(void) pthread_cond_init(&dpr->dpr_cv, NULL);
-#if defined(sun)
+#ifdef illumos
if ((dpr->dpr_proc = Pgrab(pid, flags, &err)) == NULL) {
#else
if ((err = proc_attach(pid, flags, &dpr->dpr_proc)) != 0) {
@@ -1174,7 +1174,7 @@ dtrace_proc_create(dtrace_hdl_t *dtp, const char *file, char *const *argv,
struct ps_prochandle *P = dt_proc_create(dtp, file, argv, pcf, child_arg);
if (P != NULL && idp != NULL && idp->di_id == 0) {
-#if defined(sun)
+#ifdef illumos
idp->di_id = Pstatus(P)->pr_pid; /* $target = created pid */
#else
idp->di_id = proc_getpid(P); /* $target = created pid */
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_program.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_program.c
index a325c42..232a372 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_program.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_program.c
@@ -30,7 +30,7 @@
#include <errno.h>
#include <assert.h>
#include <ctype.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#endif
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c
index 0f1bfe0..9d6c12b 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c
@@ -28,7 +28,7 @@
*/
#include <sys/types.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/sysmacros.h>
#endif
@@ -36,7 +36,7 @@
#include <limits.h>
#include <strings.h>
#include <stdlib.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#endif
#include <unistd.h>
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_regset.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_regset.c
index 0c747ed..a630d30 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_regset.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_regset.c
@@ -27,6 +27,7 @@
/*
* Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2016 Pedro Giffuni. All rights reserved.
*/
#include <sys/types.h>
@@ -47,15 +48,15 @@ dt_regset_create(ulong_t nregs)
if (drp == NULL)
return (NULL);
- drp->dr_bitmap = malloc(sizeof (ulong_t) * n);
- drp->dr_size = nregs;
+ drp->dr_bitmap = calloc(n, sizeof (ulong_t));
if (drp->dr_bitmap == NULL) {
dt_regset_destroy(drp);
return (NULL);
}
- bzero(drp->dr_bitmap, sizeof (ulong_t) * n);
+ drp->dr_size = nregs;
+
return (drp);
}
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_strtab.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_strtab.c
index cf6bc48..21669c8 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_strtab.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_strtab.c
@@ -24,6 +24,10 @@
* Use is subject to license terms.
*/
+/*
+ * Portions Copyright 2016 Pedro Giffuni. All rights reserved.
+ */
+
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/types.h>
@@ -70,12 +74,11 @@ dt_strtab_create(size_t bufsz)
return (NULL);
bzero(sp, sizeof (dt_strtab_t));
- sp->str_hash = malloc(nbuckets * sizeof (dt_strhash_t *));
+ sp->str_hash = calloc(nbuckets, sizeof (dt_strhash_t *));
if (sp->str_hash == NULL)
goto err;
- bzero(sp->str_hash, nbuckets * sizeof (dt_strhash_t *));
sp->str_hashsz = nbuckets;
sp->str_bufs = NULL;
sp->str_ptr = NULL;
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c
index 4429019..72fd08a 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c
@@ -25,7 +25,7 @@
* Use is subject to license terms.
*/
-#if defined(sun)
+#ifdef illumos
#include <sys/sysmacros.h>
#endif
#include <sys/isa_defs.h>
@@ -38,7 +38,7 @@
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#else
#include <sys/sysctl.h>
@@ -477,7 +477,7 @@ dt_dprintf(const char *format, ...)
}
int
-#if defined(sun)
+#ifdef illumos
dt_ioctl(dtrace_hdl_t *dtp, int val, void *arg)
#else
dt_ioctl(dtrace_hdl_t *dtp, u_long val, void *arg)
@@ -485,7 +485,7 @@ dt_ioctl(dtrace_hdl_t *dtp, u_long val, void *arg)
{
const dtrace_vector_t *v = dtp->dt_vector;
-#if !defined(sun)
+#ifndef illumos
/* Avoid sign extension. */
val &= 0xffffffff;
#endif
@@ -506,7 +506,7 @@ dt_status(dtrace_hdl_t *dtp, processorid_t cpu)
const dtrace_vector_t *v = dtp->dt_vector;
if (v == NULL) {
-#if defined(sun)
+#ifdef illumos
return (p_online(cpu, P_STATUS));
#else
int maxid = 0;
@@ -583,7 +583,7 @@ dt_printf(dtrace_hdl_t *dtp, FILE *fp, const char *format, ...)
va_list ap;
int n;
-#if !defined(sun)
+#ifndef illumos
/*
* On FreeBSD, check if output is currently being re-directed
* to another file. If so, output to that file instead of the
@@ -845,7 +845,7 @@ dt_popcb(const ulong_t *bp, ulong_t n)
return (popc + dt_popc(bp[maxw] & ((1UL << maxb) - 1)));
}
-#if defined(sun)
+#ifdef illumos
struct _rwlock;
struct _lwp_mutex;
@@ -867,7 +867,7 @@ dt_rw_write_held(pthread_rwlock_t *lock)
int
dt_mutex_held(pthread_mutex_t *lock)
{
-#if defined(sun)
+#ifdef illumos
extern int _mutex_held(struct _lwp_mutex *);
return (_mutex_held((struct _lwp_mutex *)lock));
#else
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_work.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_work.c
index d19fb88..07565e0 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_work.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_work.c
@@ -82,7 +82,7 @@ dtrace_sleep(dtrace_hdl_t *dtp)
return; /* sleep duration has already past */
}
-#if defined(sun)
+#ifdef illumos
tv.tv_sec = (earliest - now) / NANOSEC;
tv.tv_nsec = (earliest - now) % NANOSEC;
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h
index 6f88e6d..f0088a9 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h
@@ -37,7 +37,7 @@
#include <stdio.h>
#include <gelf.h>
#include <libproc.h>
-#if !defined(sun)
+#ifndef illumos
#include <rtld_db.h>
#endif
@@ -554,7 +554,7 @@ extern int dtrace_probe_info(dtrace_hdl_t *,
* entry point to obtain a library handle.
*/
struct dtrace_vector {
-#if defined(sun)
+#ifdef illumos
int (*dtv_ioctl)(void *, int, void *);
#else
int (*dtv_ioctl)(void *, u_long, void *);
@@ -605,7 +605,7 @@ extern int _dtrace_debug;
}
#endif
-#if !defined(sun)
+#ifndef illumos
#define _SC_CPUID_MAX _SC_NPROCESSORS_CONF
#define _SC_NPROCESSORS_MAX _SC_NPROCESSORS_CONF
#endif
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/i386/dt_isadep.c b/cddl/contrib/opensolaris/lib/libdtrace/i386/dt_isadep.c
index 9479e83..34d5587 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/i386/dt_isadep.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/i386/dt_isadep.c
@@ -39,7 +39,7 @@
#include <dis_tables.h>
-#if !defined(sun)
+#ifndef illumos
#define PR_MODEL_ILP32 1
#define PR_MODEL_LP64 2
#include <libproc_compat.h>
@@ -88,7 +88,7 @@ dt_pid_has_jump_table(struct ps_prochandle *P, dtrace_hdl_t *dtp,
{
ulong_t i;
int size;
-#if defined(sun)
+#ifdef illumos
pid_t pid = Pstatus(P)->pr_pid;
char dmodel = Pstatus(P)->pr_dmodel;
#else
@@ -144,7 +144,7 @@ dt_pid_create_return_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp,
uint8_t *text;
ulong_t i, end;
int size;
-#if defined(sun)
+#ifdef illumos
pid_t pid = Pstatus(P)->pr_pid;
char dmodel = Pstatus(P)->pr_dmodel;
#else
@@ -305,7 +305,7 @@ dt_pid_create_offset_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp,
uint8_t *text;
ulong_t i;
int size;
-#if defined(sun)
+#ifdef illumos
pid_t pid = Pstatus(P)->pr_pid;
char dmodel = Pstatus(P)->pr_dmodel;
#else
@@ -388,7 +388,7 @@ dt_pid_create_glob_offset_probes(struct ps_prochandle *P, dtrace_hdl_t *dtp,
uint8_t *text;
int size;
ulong_t i, end = symp->st_size;
-#if defined(sun)
+#ifdef illumos
pid_t pid = Pstatus(P)->pr_pid;
char dmodel = Pstatus(P)->pr_dmodel;
#else
diff --git a/cddl/contrib/opensolaris/lib/libgen/common/gmatch.c b/cddl/contrib/opensolaris/lib/libgen/common/gmatch.c
index fe4a382..6da5cf2 100644
--- a/cddl/contrib/opensolaris/lib/libgen/common/gmatch.c
+++ b/cddl/contrib/opensolaris/lib/libgen/common/gmatch.c
@@ -29,7 +29,7 @@
#pragma ident "%Z%%M% %I% %E% SMI"
-#if defined(sun)
+#ifdef illumos
#pragma weak gmatch = _gmatch
#include "gen_synonyms.h"
@@ -38,7 +38,7 @@
#include <libgen.h>
#include <stdlib.h>
#include <limits.h>
-#if defined(sun)
+#ifdef illumos
#include <widec.h>
#include "_range.h"
#else
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
index 246449c..1b4b46c 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
@@ -28,6 +28,7 @@
* Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#ifndef _LIBZFS_H
@@ -326,7 +327,7 @@ typedef enum {
ZPOOL_STATUS_VERSION_OLDER, /* older legacy on-disk version */
ZPOOL_STATUS_FEAT_DISABLED, /* supported features are disabled */
ZPOOL_STATUS_RESILVERING, /* device being resilvered */
- ZPOOL_STATUS_OFFLINE_DEV, /* device online */
+ ZPOOL_STATUS_OFFLINE_DEV, /* device offline */
ZPOOL_STATUS_REMOVED_DEV, /* removed device */
ZPOOL_STATUS_NON_NATIVE_ASHIFT, /* (e.g. 512e dev with ashift of 9) */
@@ -800,10 +801,10 @@ extern boolean_t libzfs_fru_compare(libzfs_handle_t *, const char *,
extern boolean_t libzfs_fru_notself(libzfs_handle_t *, const char *);
extern int zpool_fru_set(zpool_handle_t *, uint64_t, const char *);
-#ifndef sun
+#ifndef illumos
extern int zmount(const char *, const char *, int, char *, char *, int, char *,
int);
-#endif /* !sun */
+#endif
#ifdef __cplusplus
}
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.c
index 833e1b6..b9ecd9d 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.c
@@ -74,6 +74,9 @@ zcmd_ioctl(int fd, int request, zfs_cmd_t *zc)
if (zfs_ioctl_version >= ZFS_IOCVER_DEADMAN) {
switch (zfs_ioctl_version) {
+ case ZFS_IOCVER_RESUME:
+ cflag = ZFS_CMD_COMPAT_RESUME;
+ break;
case ZFS_IOCVER_EDBP:
cflag = ZFS_CMD_COMPAT_EDBP;
break;
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c
index d5ba20f..2f332a8 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c
@@ -26,6 +26,7 @@
/*
* Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2015 by Syneto S.R.L. All rights reserved.
*/
/*
@@ -246,8 +247,9 @@ zpool_get_features(zpool_handle_t *zhp)
config = zpool_get_config(zhp, NULL);
}
- verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_FEATURE_STATS,
- &features) == 0);
+ if (nvlist_lookup_nvlist(config, ZPOOL_CONFIG_FEATURE_STATS,
+ &features) != 0)
+ return (NULL);
return (features);
}
@@ -316,8 +318,7 @@ zpool_refresh_stats(zpool_handle_t *zhp, boolean_t *missing)
verify(nvlist_lookup_uint64(config,
ZPOOL_CONFIG_POOL_TXG, &newtxg) == 0);
- if (zhp->zpool_old_config != NULL)
- nvlist_free(zhp->zpool_old_config);
+ nvlist_free(zhp->zpool_old_config);
if (oldtxg != newtxg) {
nvlist_free(zhp->zpool_config);
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
index 44a9f00..dd09928 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
@@ -29,6 +29,7 @@
* Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <ctype.h>
@@ -1113,7 +1114,7 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
}
case ZFS_PROP_MLSLABEL:
{
-#ifdef sun
+#ifdef illumos
/*
* Verify the mlslabel string and convert to
* internal hex label string.
@@ -1162,11 +1163,11 @@ badlabel:
"invalid mlslabel '%s'"), strval);
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
m_label_free(new_sl); /* OK if null */
-#else /* !sun */
+#else /* !illumos */
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"mlslabel is not supported on FreeBSD"));
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
-#endif /* !sun */
+#endif /* illumos */
goto error;
}
@@ -2057,8 +2058,7 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
zcmd_free_nvlists(&zc);
return (-1);
}
- if (zplprops)
- nvlist_free(zplprops);
+ nvlist_free(zplprops);
zcmd_free_nvlists(&zc);
break;
@@ -2504,7 +2504,7 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
case ZFS_PROP_MLSLABEL:
{
-#ifdef sun
+#ifdef illumos
m_label_t *new_sl = NULL;
char *ascii = NULL; /* human readable label */
@@ -2538,9 +2538,9 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
(void) strlcpy(propbuf, ascii, proplen);
free(ascii);
-#else /* !sun */
+#else /* !illumos */
propbuf[0] = '\0';
-#endif /* !sun */
+#endif /* illumos */
}
break;
@@ -2652,7 +2652,7 @@ static int
idmap_id_to_numeric_domain_rid(uid_t id, boolean_t isuser,
char **domainp, idmap_rid_t *ridp)
{
-#ifdef sun
+#ifdef illumos
idmap_get_handle_t *get_hdl = NULL;
idmap_stat status;
int err = EINVAL;
@@ -2677,10 +2677,10 @@ out:
if (get_hdl)
idmap_get_destroy(get_hdl);
return (err);
-#else /* !sun */
+#else /* !illumos */
assert(!"invalid code path");
return (EINVAL); // silence compiler warning
-#endif /* !sun */
+#endif /* illumos */
}
/*
@@ -2715,7 +2715,7 @@ userquota_propname_decode(const char *propname, boolean_t zoned,
cp = strchr(propname, '@') + 1;
if (strchr(cp, '@')) {
-#ifdef sun
+#ifdef illumos
/*
* It's a SID name (eg "user@domain") that needs to be
* turned into S-1-domainID-RID.
@@ -2761,9 +2761,9 @@ userquota_propname_decode(const char *propname, boolean_t zoned,
cp = numericsid;
*ridp = rid;
/* will be further decoded below */
-#else /* !sun */
+#else /* !illumos */
return (ENOENT);
-#endif /* !sun */
+#endif /* illumos */
}
if (strncmp(cp, "S-1-", 4) == 0) {
@@ -4286,7 +4286,7 @@ zfs_prune_proplist(zfs_handle_t *zhp, uint8_t *props)
}
}
-#ifdef sun
+#ifdef illumos
static int
zfs_smb_acl_mgmt(libzfs_handle_t *hdl, char *dataset, char *path,
zfs_smb_acl_op_t cmd, char *resource1, char *resource2)
@@ -4333,8 +4333,7 @@ zfs_smb_acl_mgmt(libzfs_handle_t *hdl, char *dataset, char *path,
return (-1);
}
error = ioctl(hdl->libzfs_fd, ZFS_IOC_SMB_ACL, &zc);
- if (nvlist)
- nvlist_free(nvlist);
+ nvlist_free(nvlist);
return (error);
}
@@ -4368,7 +4367,7 @@ zfs_smb_acl_rename(libzfs_handle_t *hdl, char *dataset, char *path,
return (zfs_smb_acl_mgmt(hdl, dataset, path, ZFS_SMB_ACL_RENAME,
oldname, newname));
}
-#endif /* sun */
+#endif /* illumos */
int
zfs_userspace(zfs_handle_t *zhp, zfs_userquota_prop_t type,
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c
index 3b17579..28b1e2e 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2016 Joyent, Inc.
*/
/*
@@ -136,12 +137,13 @@ get_stats_for_obj(differ_info_t *di, const char *dsname, uint64_t obj,
static void
stream_bytes(FILE *fp, const char *string)
{
- while (*string) {
- if (*string > ' ' && *string != '\\' && *string < '\177')
- (void) fprintf(fp, "%c", *string++);
- else {
- (void) fprintf(fp, "\\%03hho",
- (unsigned char)*string++);
+ char c;
+
+ while ((c = *string++) != '\0') {
+ if (c > ' ' && c != '\\' && c < '\177') {
+ (void) fprintf(fp, "%c", c);
+ } else {
+ (void) fprintf(fp, "\\%03o", (uint8_t)c);
}
}
}
@@ -495,7 +497,7 @@ find_shares_object(differ_info_t *di)
(void) strlcat(fullpath, ZDIFF_SHARESDIR, MAXPATHLEN);
if (stat64(fullpath, &sb) != 0) {
-#ifdef sun
+#ifdef illumos
(void) snprintf(di->errbuf, sizeof (di->errbuf),
dgettext(TEXT_DOMAIN, "Cannot stat %s"), fullpath);
return (zfs_error(di->zhp->zfs_hdl, EZFS_DIFF, di->errbuf));
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
index 87b41cf..133cc6f 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
@@ -958,7 +958,7 @@ slice_cache_compare(const void *arg1, const void *arg2)
return (rv > 0 ? 1 : -1);
}
-#ifdef sun
+#ifdef illumos
static void
check_one_slice(avl_tree_t *r, char *diskname, uint_t partno,
diskaddr_t size, uint_t blksz)
@@ -981,12 +981,12 @@ check_one_slice(avl_tree_t *r, char *diskname, uint_t partno,
(node = avl_find(r, &tmpnode, NULL)))
node->rn_nozpool = B_TRUE;
}
-#endif /* sun */
+#endif /* illumos */
static void
nozpool_all_slices(avl_tree_t *r, const char *sname)
{
-#ifdef sun
+#ifdef illumos
char diskname[MAXNAMELEN];
char *ptr;
int i;
@@ -1002,10 +1002,10 @@ nozpool_all_slices(avl_tree_t *r, const char *sname)
ptr[0] = 'p';
for (i = 0; i <= FD_NUMPART; i++)
check_one_slice(r, diskname, i, 0, 1);
-#endif /* sun */
+#endif /* illumos */
}
-#ifdef sun
+#ifdef illumos
static void
check_slices(avl_tree_t *r, int fd, const char *sname)
{
@@ -1039,7 +1039,7 @@ check_slices(avl_tree_t *r, int fd, const char *sname)
efi_free(gpt);
}
}
-#endif /* sun */
+#endif /* illumos */
static void
zpool_open_func(void *arg)
@@ -1069,7 +1069,7 @@ zpool_open_func(void *arg)
return;
}
/* this file is too small to hold a zpool */
-#ifdef sun
+#ifdef illumos
if (S_ISREG(statbuf.st_mode) &&
statbuf.st_size < SPA_MINDEVSIZE) {
(void) close(fd);
@@ -1081,12 +1081,12 @@ zpool_open_func(void *arg)
*/
check_slices(rn->rn_avl, fd, rn->rn_name);
}
-#else /* !sun */
+#else /* !illumos */
if (statbuf.st_size < SPA_MINDEVSIZE) {
(void) close(fd);
return;
}
-#endif /* sun */
+#endif /* illumos */
if ((zpool_read_label(fd, &config)) != 0) {
(void) close(fd);
@@ -1331,8 +1331,7 @@ error:
venext = ve->ve_next;
for (ce = ve->ve_configs; ce != NULL; ce = cenext) {
cenext = ce->ce_next;
- if (ce->ce_config)
- nvlist_free(ce->ce_config);
+ nvlist_free(ce->ce_config);
free(ce);
}
free(ve);
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
index b94af5b..f03da99 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
@@ -139,7 +139,7 @@ is_shared(libzfs_handle_t *hdl, const char *mountpoint, zfs_share_proto_t proto)
*tab = '\0';
if (strcmp(buf, mountpoint) == 0) {
-#ifdef sun
+#ifdef illumos
/*
* the protocol field is the third field
* skip over second field
@@ -172,7 +172,7 @@ is_shared(libzfs_handle_t *hdl, const char *mountpoint, zfs_share_proto_t proto)
return (SHARED_NOT_SHARED);
}
-#ifdef sun
+#ifdef illumos
/*
* Returns true if the specified directory is empty. If we can't open the
* directory at all, return true so that the mount can fail with a more
@@ -297,7 +297,7 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags)
}
}
-#ifdef sun /* FreeBSD: overlay mounts are not checked. */
+#ifdef illumos /* FreeBSD: overlay mounts are not checked. */
/*
* Determine if the mountpoint is empty. If so, refuse to perform the
* mount. We don't perform this check if MS_OVERLAY is specified, which
@@ -507,7 +507,7 @@ zfs_is_shared_smb(zfs_handle_t *zhp, char **where)
* initialized in _zfs_init_libshare() are actually present.
*/
-#ifdef sun
+#ifdef illumos
static sa_handle_t (*_sa_init)(int);
static void (*_sa_fini)(sa_handle_t);
static sa_share_t (*_sa_find_share)(sa_handle_t, char *);
@@ -534,7 +534,7 @@ static void (*_sa_update_sharetab_ts)(sa_handle_t);
static void
_zfs_init_libshare(void)
{
-#ifdef sun
+#ifdef illumos
void *libshare;
char path[MAXPATHLEN];
char isa[MAXISALEN];
@@ -605,7 +605,7 @@ zfs_init_libshare(libzfs_handle_t *zhandle, int service)
{
int ret = SA_OK;
-#ifdef sun
+#ifdef illumos
if (_sa_init == NULL)
ret = SA_CONFIG_ERR;
@@ -646,7 +646,7 @@ void
zfs_uninit_libshare(libzfs_handle_t *zhandle)
{
if (zhandle != NULL && zhandle->libzfs_sharehdl != NULL) {
-#ifdef sun
+#ifdef illumos
if (_sa_fini != NULL)
_sa_fini(zhandle->libzfs_sharehdl);
#endif
@@ -663,7 +663,7 @@ zfs_uninit_libshare(libzfs_handle_t *zhandle)
int
zfs_parse_options(char *options, zfs_share_proto_t proto)
{
-#ifdef sun
+#ifdef illumos
if (_sa_parse_legacy_options != NULL) {
return (_sa_parse_legacy_options(NULL, options,
proto_table[proto].p_name));
@@ -674,7 +674,7 @@ zfs_parse_options(char *options, zfs_share_proto_t proto)
#endif
}
-#ifdef sun
+#ifdef illumos
/*
* zfs_sa_find_share(handle, path)
*
@@ -716,7 +716,7 @@ zfs_sa_disable_share(sa_share_t share, char *proto)
return (_sa_disable_share(share, proto));
return (SA_CONFIG_ERR);
}
-#endif /* sun */
+#endif /* illumos */
/*
* Share the given filesystem according to the options in the specified
@@ -767,7 +767,7 @@ zfs_share_proto(zfs_handle_t *zhp, zfs_share_proto_t *proto)
if (zfs_prop_get_int(zhp, ZFS_PROP_ZONED))
continue;
-#ifdef sun
+#ifdef illumos
share = zfs_sa_find_share(hdl->libzfs_sharehdl, mountpoint);
if (share == NULL) {
/*
@@ -856,7 +856,7 @@ static int
unshare_one(libzfs_handle_t *hdl, const char *name, const char *mountpoint,
zfs_share_proto_t proto)
{
-#ifdef sun
+#ifdef illumos
sa_share_t share;
int err;
char *mntpt;
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
index 5fd9612..4dc48fa 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
@@ -1054,12 +1054,9 @@ zpool_open(libzfs_handle_t *hdl, const char *pool)
void
zpool_close(zpool_handle_t *zhp)
{
- if (zhp->zpool_config)
- nvlist_free(zhp->zpool_config);
- if (zhp->zpool_old_config)
- nvlist_free(zhp->zpool_old_config);
- if (zhp->zpool_props)
- nvlist_free(zhp->zpool_props);
+ nvlist_free(zhp->zpool_config);
+ nvlist_free(zhp->zpool_old_config);
+ nvlist_free(zhp->zpool_props);
free(zhp);
}
@@ -1577,8 +1574,7 @@ zpool_import(libzfs_handle_t *hdl, nvlist_t *config, const char *newname,
ret = zpool_import_props(hdl, config, newname, props,
ZFS_IMPORT_NORMAL);
- if (props)
- nvlist_free(props);
+ nvlist_free(props);
return (ret);
}
@@ -2339,7 +2335,7 @@ zpool_get_physpath(zpool_handle_t *zhp, char *physpath, size_t phypath_size)
static int
zpool_relabel_disk(libzfs_handle_t *hdl, const char *name)
{
-#ifdef sun
+#ifdef illumos
char path[MAXPATHLEN];
char errbuf[1024];
int fd, error;
@@ -2369,7 +2365,7 @@ zpool_relabel_disk(libzfs_handle_t *hdl, const char *name)
"relabel '%s': unable to read disk capacity"), name);
return (zfs_error(hdl, EZFS_NOCAP, errbuf));
}
-#endif /* sun */
+#endif /* illumos */
return (0);
}
@@ -2901,8 +2897,7 @@ zpool_vdev_split(zpool_handle_t *zhp, char *newname, nvlist_t **newroot,
&children) != 0) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"Source pool is missing vdev tree"));
- if (zc_props)
- nvlist_free(zc_props);
+ nvlist_free(zc_props);
return (-1);
}
@@ -3050,10 +3045,8 @@ out:
free(varray);
}
zcmd_free_nvlists(&zc);
- if (zc_props)
- nvlist_free(zc_props);
- if (newconfig)
- nvlist_free(newconfig);
+ nvlist_free(zc_props);
+ nvlist_free(newconfig);
if (freelist) {
nvlist_free(*newroot);
*newroot = NULL;
@@ -3417,7 +3410,7 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
devid_str_free(newdevid);
}
-#ifdef sun
+#ifdef illumos
if (strncmp(path, "/dev/dsk/", 9) == 0)
path += 9;
@@ -3442,10 +3435,10 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
}
return (tmp);
}
-#else /* !sun */
+#else /* !illumos */
if (strncmp(path, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
path += sizeof(_PATH_DEV) - 1;
-#endif /* !sun */
+#endif /* illumos */
} else {
verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &path) == 0);
@@ -3835,7 +3828,7 @@ zpool_obj_to_path(zpool_handle_t *zhp, uint64_t dsobj, uint64_t obj,
free(mntpnt);
}
-#ifdef sun
+#ifdef illumos
/*
* Read the EFI label from the config, if a label does not exist then
* pass back the error to the caller. If the caller has passed a non-NULL
@@ -3900,7 +3893,7 @@ find_start_block(nvlist_t *config)
}
return (MAXOFFSET_T);
}
-#endif /* sun */
+#endif /* illumos */
/*
* Label an individual disk. The name provided is the short name,
@@ -3909,7 +3902,7 @@ find_start_block(nvlist_t *config)
int
zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, const char *name)
{
-#ifdef sun
+#ifdef illumos
char path[MAXPATHLEN];
struct dk_gpt *vtoc;
int fd;
@@ -4007,7 +4000,7 @@ zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, const char *name)
(void) close(fd);
efi_free(vtoc);
-#endif /* sun */
+#endif /* illumos */
return (0);
}
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
index e99231d..723cd42 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
@@ -26,6 +26,8 @@
* Copyright (c) 2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
* All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
+ * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <assert.h>
@@ -67,7 +69,7 @@ extern void zfs_setprop_error(libzfs_handle_t *, zfs_prop_t, int, char *);
static int zfs_receive_impl(libzfs_handle_t *, const char *, const char *,
recvflags_t *, int, const char *, nvlist_t *, avl_tree_t *, char **, int,
- uint64_t *);
+ uint64_t *, const char *);
static int guid_to_name(libzfs_handle_t *, const char *,
uint64_t, boolean_t, char *);
@@ -955,7 +957,7 @@ dump_ioctl(zfs_handle_t *zhp, const char *fromsnap, uint64_t fromsnap_obj,
case EIO:
case ENOLINK:
case ENOSPC:
-#ifdef sun
+#ifdef illumos
case ENOSTR:
#endif
case ENXIO:
@@ -2602,6 +2604,7 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
nvlist_t *stream_nv = NULL;
avl_tree_t *stream_avl = NULL;
char *fromsnap = NULL;
+ char *sendsnap = NULL;
char *cp;
char tofs[ZFS_MAXNAMELEN];
char sendfs[ZFS_MAXNAMELEN];
@@ -2750,8 +2753,16 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
*/
(void) strlcpy(sendfs, drr->drr_u.drr_begin.drr_toname,
ZFS_MAXNAMELEN);
- if ((cp = strchr(sendfs, '@')) != NULL)
+ if ((cp = strchr(sendfs, '@')) != NULL) {
*cp = '\0';
+ /*
+ * Find the "sendsnap", the final snapshot in a replication
+ * stream. zfs_receive_one() handles certain errors
+ * differently, depending on if the contained stream is the
+ * last one or not.
+ */
+ sendsnap = (cp + 1);
+ }
/* Finally, receive each contained stream */
do {
@@ -2764,7 +2775,7 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
*/
error = zfs_receive_impl(hdl, destname, NULL, flags, fd,
sendfs, stream_nv, stream_avl, top_zfs, cleanup_fd,
- action_handlep);
+ action_handlep, sendsnap);
if (error == ENODATA) {
error = 0;
break;
@@ -2783,8 +2794,7 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
out:
fsavl_destroy(stream_avl);
- if (stream_nv)
- nvlist_free(stream_nv);
+ nvlist_free(stream_nv);
if (softerr)
error = -2;
if (anyerr)
@@ -2930,7 +2940,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
const char *originsnap, recvflags_t *flags, dmu_replay_record_t *drr,
dmu_replay_record_t *drr_noswap, const char *sendfs, nvlist_t *stream_nv,
avl_tree_t *stream_avl, char **top_zfs, int cleanup_fd,
- uint64_t *action_handlep)
+ uint64_t *action_handlep, const char *finalsnap)
{
zfs_cmd_t zc = { 0 };
time_t begin_time;
@@ -2947,6 +2957,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
nvlist_t *snapprops_nvlist = NULL;
zprop_errflags_t prop_errflags;
boolean_t recursive;
+ char *snapname = NULL;
begin_time = time(NULL);
@@ -2957,7 +2968,6 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
ENOENT);
if (stream_avl != NULL) {
- char *snapname;
nvlist_t *fs = fsavl_find(stream_avl, drrb->drr_toguid,
&snapname);
nvlist_t *props;
@@ -3313,7 +3323,21 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
ZPROP_N_MORE_ERRORS) == 0) {
trunc_prop_errs(intval);
break;
- } else {
+ } else if (snapname == NULL || finalsnap == NULL ||
+ strcmp(finalsnap, snapname) == 0 ||
+ strcmp(nvpair_name(prop_err),
+ zfs_prop_to_name(ZFS_PROP_REFQUOTA)) != 0) {
+ /*
+ * Skip the special case of, for example,
+ * "refquota", errors on intermediate
+ * snapshots leading up to a final one.
+ * That's why we have all of the checks above.
+ *
+ * See zfs_ioctl.c's extract_delay_props() for
+ * a list of props which can fail on
+ * intermediate snapshots, but shouldn't
+ * affect the overall receive.
+ */
(void) snprintf(tbuf, sizeof (tbuf),
dgettext(TEXT_DOMAIN,
"cannot receive %s property on %s"),
@@ -3498,7 +3522,7 @@ static int
zfs_receive_impl(libzfs_handle_t *hdl, const char *tosnap,
const char *originsnap, recvflags_t *flags, int infd, const char *sendfs,
nvlist_t *stream_nv, avl_tree_t *stream_avl, char **top_zfs, int cleanup_fd,
- uint64_t *action_handlep)
+ uint64_t *action_handlep, const char *finalsnap)
{
int err;
dmu_replay_record_t drr, drr_noswap;
@@ -3594,10 +3618,11 @@ zfs_receive_impl(libzfs_handle_t *hdl, const char *tosnap,
if ((cp = strchr(nonpackage_sendfs, '@')) != NULL)
*cp = '\0';
sendfs = nonpackage_sendfs;
+ VERIFY(finalsnap == NULL);
}
return (zfs_receive_one(hdl, infd, tosnap, originsnap, flags,
&drr, &drr_noswap, sendfs, stream_nv, stream_avl, top_zfs,
- cleanup_fd, action_handlep));
+ cleanup_fd, action_handlep, finalsnap));
} else {
assert(DMU_GET_STREAM_HDRTYPE(drrb->drr_versioninfo) ==
DMU_COMPOUNDSTREAM);
@@ -3632,7 +3657,7 @@ zfs_receive(libzfs_handle_t *hdl, const char *tosnap, nvlist_t *props,
VERIFY(cleanup_fd >= 0);
err = zfs_receive_impl(hdl, tosnap, originsnap, flags, infd, NULL, NULL,
- stream_avl, &top_zfs, cleanup_fd, &action_handle);
+ stream_avl, &top_zfs, cleanup_fd, &action_handle, NULL);
VERIFY(0 == close(cleanup_fd));
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
index 6f70604..1316aec 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
@@ -686,7 +686,7 @@ libzfs_fini(libzfs_handle_t *hdl)
(void) fclose(hdl->libzfs_sharetab);
zfs_uninit_libshare(hdl);
zpool_free_handles(hdl);
-#ifdef sun
+#ifdef illumos
libzfs_fru_clear(hdl, B_TRUE);
#endif
namespace_clear(hdl);
@@ -738,7 +738,7 @@ zfs_path_to_zhandle(libzfs_handle_t *hdl, char *path, zfs_type_t argtype)
return (NULL);
}
-#ifdef sun
+#ifdef illumos
rewind(hdl->libzfs_mnttab);
while ((ret = getextmntent(hdl->libzfs_mnttab, &entry, 0)) == 0) {
if (makedevice(entry.mnt_major, entry.mnt_minor) ==
@@ -758,7 +758,7 @@ zfs_path_to_zhandle(libzfs_handle_t *hdl, char *path, zfs_type_t argtype)
strerror(errno));
}
}
-#endif /* sun */
+#endif /* illumos */
if (ret != 0) {
return (NULL);
}
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 69d332a..3accb2c 100644
--- a/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c
+++ b/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
/*
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 <garrett@damore.org>. All rights reserved.
+ * Copyright (c) 2014 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -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;
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c
index bc278b0..c071962 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.c
@@ -38,7 +38,7 @@
*/
#include <pthread.h>
-#if defined(sun)
+#ifdef illumos
#include <synch.h>
#endif
#include <stdio.h>
@@ -49,7 +49,7 @@ void
barrier_init(barrier_t *bar, int nthreads)
{
pthread_mutex_init(&bar->bar_lock, NULL);
-#if defined(sun)
+#ifdef illumos
sema_init(&bar->bar_sem, 0, USYNC_THREAD, NULL);
#else
sem_init(&bar->bar_sem, 0, 0);
@@ -66,7 +66,7 @@ barrier_wait(barrier_t *bar)
if (++bar->bar_numin < bar->bar_nthr) {
pthread_mutex_unlock(&bar->bar_lock);
-#if defined(sun)
+#ifdef illumos
sema_wait(&bar->bar_sem);
#else
sem_wait(&bar->bar_sem);
@@ -80,7 +80,7 @@ barrier_wait(barrier_t *bar)
/* reset for next use */
bar->bar_numin = 0;
for (i = 1; i < bar->bar_nthr; i++)
-#if defined(sun)
+#ifdef illumos
sema_post(&bar->bar_sem);
#else
sem_post(&bar->bar_sem);
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h
index c7e6212..babf2e6 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/barrier.h
@@ -33,7 +33,7 @@
* APIs for the barrier synchronization primitive.
*/
-#if defined(sun)
+#ifdef illumos
#include <synch.h>
#else
#include <semaphore.h>
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c
index efe6c27..d40be25 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfconvert.c
@@ -155,7 +155,7 @@ main(int argc, char **argv)
int keep_stabs = 0;
int c;
-#if defined(sun)
+#ifdef illumos
sighold(SIGINT);
sighold(SIGQUIT);
sighold(SIGTERM);
@@ -221,7 +221,7 @@ main(int argc, char **argv)
*/
set_terminate_cleanup(terminate_cleanup);
-#if defined(sun)
+#ifdef illumos
sigset(SIGINT, handle_sig);
sigset(SIGQUIT, handle_sig);
sigset(SIGTERM, handle_sig);
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c
index 3e030c7..a3d05ad 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c
@@ -176,20 +176,20 @@
#include <unistd.h>
#include <pthread.h>
#include <assert.h>
-#if defined(sun)
+#ifdef illumos
#include <synch.h>
#endif
#include <signal.h>
#include <libgen.h>
#include <string.h>
#include <errno.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#endif
#include <sys/param.h>
#include <sys/types.h>
#include <sys/mman.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/sysconf.h>
#endif
@@ -232,7 +232,7 @@ usage(void)
progname, progname);
}
-#if defined(sun)
+#ifdef illumos
static void
bigheap(void)
{
@@ -280,7 +280,7 @@ bigheap(void)
(void) memcntl(NULL, 0, MC_HAT_ADVISE, (caddr_t)&mha, 0, 0);
}
-#endif
+#endif /* illumos */
static void
finalize_phase_one(workqueue_t *wq)
@@ -707,7 +707,7 @@ start_threads(workqueue_t *wq)
(void *(*)(void *))worker_thread, wq);
}
-#if defined(sun)
+#ifdef illumos
sigset(SIGINT, handle_sig);
sigset(SIGQUIT, handle_sig);
sigset(SIGTERM, handle_sig);
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c b/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
index 63d4d1e..5725401 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c
@@ -1380,7 +1380,7 @@ die_base_type2enc(dwarf_t *dw, Dwarf_Off off, Dwarf_Signed enc, size_t sz)
mult = 2;
col = 1;
} else if (enc == DW_ATE_imaginary_float
-#if defined(sun)
+#ifdef illumos
|| enc == DW_ATE_SUN_imaginary_float
#endif
)
@@ -1431,7 +1431,7 @@ die_base_from_dwarf(dwarf_t *dw, Dwarf_Die base, Dwarf_Off off, size_t sz)
case DW_ATE_float:
case DW_ATE_complex_float:
case DW_ATE_imaginary_float:
-#if defined(sun)
+#ifdef illumos
case DW_ATE_SUN_imaginary_float:
case DW_ATE_SUN_interval_float:
#endif
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/output.c b/cddl/contrib/opensolaris/tools/ctf/cvt/output.c
index af79769..3131e7f 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/output.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/output.c
@@ -576,7 +576,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
shdr.sh_name);
}
-#if !defined(sun)
+#ifndef illumos
if (gelf_update_shdr(dscn, &shdr) == 0)
elfterminate(dstname, "Cannot update sect %s", sname);
#endif
@@ -585,7 +585,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
elfterminate(srcname, "Cannot get sect %s data", sname);
if ((ddata = elf_newdata(dscn)) == NULL)
elfterminate(dstname, "Can't make sect %s data", sname);
-#if defined(sun)
+#ifdef illumos
bcopy(sdata, ddata, sizeof (Elf_Data));
#else
/*
@@ -645,7 +645,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
}
}
-#if !defined(sun)
+#ifndef illumos
if (ddata->d_buf == NULL && sdata->d_buf != NULL) {
ddata->d_buf = xmalloc(shdr.sh_size);
bcopy(sdata->d_buf, ddata->d_buf, shdr.sh_size);
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c b/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c
index 1ccd6cd..d1a1ad0 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/tdata.c
@@ -173,7 +173,7 @@ tdesc_namecmp(void *arg1, void *arg2)
return (!streq(tdp1->t_name, tdp2->t_name));
}
-#if defined(sun)
+#ifdef illumos
/*ARGSUSED1*/
static int
tdesc_print(void *data, void *private __unused)
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/util.c b/cddl/contrib/opensolaris/tools/ctf/cvt/util.c
index 82dfe63..fb76cba 100644
--- a/cddl/contrib/opensolaris/tools/ctf/cvt/util.c
+++ b/cddl/contrib/opensolaris/tools/ctf/cvt/util.c
@@ -171,7 +171,7 @@ aborterr(const char *format, ...)
whine("ERROR", format, ap);
va_end(ap);
-#if defined(sun)
+#ifdef illumos
abort();
#else
exit(0);
diff --git a/lib/libc++/Makefile b/lib/libc++/Makefile
index c5ecedc..8c804a3 100644
--- a/lib/libc++/Makefile
+++ b/lib/libc++/Makefile
@@ -51,6 +51,7 @@ CXXRT_SRCS+= libelftc_dem_gnu3.c\
guard.cc
.for _S in ${CXXRT_SRCS}
+CLEANFILES+= cxxrt_${_S}
STATICOBJS+= cxxrt_${_S:R}.o
cxxrt_${_S}:
ln -sf ${LIBCXXRTDIR}/${_S} ${.TARGET}
diff --git a/sbin/geom/core/geom.c b/sbin/geom/core/geom.c
index 8c15c21..753c11f 100644
--- a/sbin/geom/core/geom.c
+++ b/sbin/geom/core/geom.c
@@ -635,8 +635,7 @@ get_class(int *argc, char ***argv)
} else if (!strcasecmp(class_name, "label")) {
version = &glabel_version;
class_commands = glabel_class_commands;
- } else
- errx(EXIT_FAILURE, "Invalid class name.");
+ }
#endif /* !STATIC_GEOM_CLASSES */
set_class_name();
diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5
index 832fa03..f354c7c 100644
--- a/share/man/man5/rc.conf.5
+++ b/share/man/man5/rc.conf.5
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 9, 2015
+.Dd February 28, 2016
.Dt RC.CONF 5
.Os
.Sh NAME
@@ -2120,25 +2120,25 @@ If set to
run the
.Xr unbound 8
daemon as a local caching resolver.
-.It Va kerberos5_server_enable
+.It Va kdc_enable
.Pq Vt bool
Set to
.Dq Li YES
to start a Kerberos 5 authentication server
at boot time.
-.It Va kerberos5_server
+.It Va kdc_program
.Pq Vt str
If
-.Va kerberos5_server_enable
+.Va kdc_enable
is set to
.Dq Li YES
this is the path to Kerberos 5 Authentication Server.
-.It Va kerberos5_server_flags
+.It Va kdc_flags
.Pq Vt str
Empty by default.
This variable contains additional flags to be passed to the Kerberos 5
authentication server.
-.It Va kadmind5_server_enable
+.It Va kadmind_enable
.Pq Vt bool
Set to
.Dq Li YES
@@ -2147,14 +2147,14 @@ to start
the Kerberos 5 Administration Daemon; set to
.Dq Li NO
on a slave server.
-.It Va kadmind5_server
+.It Va kadmind_program
.Pq Vt str
If
-.Va kadmind5_server_enable
+.Va kadmind_enable
is set to
.Dq Li YES
this is the path to Kerberos 5 Administration Daemon.
-.It Va kpasswdd_server_enable
+.It Va kpasswdd_enable
.Pq Vt bool
Set to
.Dq Li YES
@@ -2163,10 +2163,10 @@ to start
the Kerberos 5 Password-Changing Daemon; set to
.Dq Li NO
on a slave server.
-.It Va kpasswdd_server
+.It Va kpasswdd_program
.Pq Vt str
If
-.Va kpasswdd_server_enable
+.Va kpasswdd_enable
is set to
.Dq Li YES
this is the path to Kerberos 5 Password-Changing Daemon.
diff --git a/share/man/man9/sx.9 b/share/man/man9/sx.9
index b998749..ce73f71 100644
--- a/share/man/man9/sx.9
+++ b/share/man/man9/sx.9
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 16, 2011
+.Dd March 13, 2016
.Dt SX 9
.Os
.Sh NAME
@@ -124,12 +124,10 @@ specifies a set of optional flags to alter the behavior of
It contains one or more of the following flags:
.Bl -tag -width SX_NOADAPTIVE
.It Dv SX_NOADAPTIVE
-If the kernel is not compiled with
-.Cd "options NO_ADAPTIVE_SX" ,
-then lock operations for
-.Fa sx
-will spin instead of sleeping while an exclusive lock holder is executing on
-another CPU.
+Disable adaptive spinning, rather than sleeping, for lock operations
+while an exclusive lock holder is executing on another CPU.
+Adaptive spinning is the default unless the kernel is compiled with
+.Cd "options NO_ADAPTIVE_SX" .
.It Dv SX_DUPOK
Witness should not log messages about duplicate locks being acquired.
.It Dv SX_NOWITNESS
diff --git a/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c b/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c
index a2532f8..49becbc 100644
--- a/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c
+++ b/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c
@@ -196,6 +196,7 @@ mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype, char *fspath,
VI_UNLOCK(vp);
vrele(vp);
vfs_unbusy(mp);
+ vfs_freeopts(mp->mnt_optnew);
vfs_mount_destroy(mp);
*vpp = NULL;
return (error);
diff --git a/sys/cddl/compat/opensolaris/sys/callo.h b/sys/cddl/compat/opensolaris/sys/callo.h
new file mode 100644
index 0000000..df2ae69
--- /dev/null
+++ b/sys/cddl/compat/opensolaris/sys/callo.h
@@ -0,0 +1,37 @@
+/*-
+ * Copyright (c) 2016 Alexander Motin <mav@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _OPENSOLARIS_SYS_CALLO_H_
+#define _OPENSOLARIS_SYS_CALLO_H_
+
+#include_next <sys/callout.h>
+
+#define CALLOUT_REALTIME 0 /* realtime callout type */
+#define CALLOUT_NORMAL 1 /* normal callout type */
+
+#endif /* !_OPENSOLARIS_SYS_CALLO_H_ */
diff --git a/sys/cddl/compat/opensolaris/sys/systm.h b/sys/cddl/compat/opensolaris/sys/systm.h
index fe0e199..f6a0dce 100644
--- a/sys/cddl/compat/opensolaris/sys/systm.h
+++ b/sys/cddl/compat/opensolaris/sys/systm.h
@@ -42,6 +42,9 @@
#define delay(x) pause("soldelay", (x))
+#define timeout_generic(type, fn, arg, t, r, f) \
+ timeout(fn, arg, t / (NANOSEC/hz) + 1)
+
#endif /* _KERNEL */
#endif /* _OPENSOLARIS_SYS_SYSTM_H_ */
diff --git a/sys/cddl/compat/opensolaris/sys/time.h b/sys/cddl/compat/opensolaris/sys/time.h
index fe4857a..269424f 100644
--- a/sys/cddl/compat/opensolaris/sys/time.h
+++ b/sys/cddl/compat/opensolaris/sys/time.h
@@ -40,6 +40,9 @@
#define MSEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MILLISEC))
#define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC))
+#define NSEC2SEC(n) ((n) / (NANOSEC / SEC))
+#define SEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / SEC))
+
typedef longlong_t hrtime_t;
#if defined(__i386__) || defined(__powerpc__)
diff --git a/sys/cddl/contrib/opensolaris/common/nvpair/opensolaris_nvpair.c b/sys/cddl/contrib/opensolaris/common/nvpair/opensolaris_nvpair.c
index 7038f7f..4bba05a 100644
--- a/sys/cddl/contrib/opensolaris/common/nvpair/opensolaris_nvpair.c
+++ b/sys/cddl/contrib/opensolaris/common/nvpair/opensolaris_nvpair.c
@@ -544,8 +544,7 @@ nvpair_free(nvpair_t *nvp)
int i;
for (i = 0; i < NVP_NELEM(nvp); i++)
- if (nvlp[i] != NULL)
- nvlist_free(nvlp[i]);
+ nvlist_free(nvlp[i]);
break;
}
default:
diff --git a/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.c b/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.c
index 6eade2a..57e5f5e 100644
--- a/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.c
+++ b/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.c
@@ -24,6 +24,7 @@
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
* Copyright (c) 2014, Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#ifdef _KERNEL
diff --git a/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.h b/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.h
index 56f3da7..eea60f3 100644
--- a/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.h
+++ b/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.h
@@ -23,6 +23,7 @@
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#ifndef _ZFEATURE_COMMON_H
diff --git a/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c b/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c
index 39ad7ce..0d8971c 100644
--- a/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c
+++ b/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.c
@@ -54,8 +54,69 @@ zfs_cmd_compat_get(zfs_cmd_t *zc, caddr_t addr, const int cflag)
zfs_cmd_deadman_t *zcdm_c;
zfs_cmd_zcmd_t *zcmd_c;
zfs_cmd_edbp_t *edbp_c;
+ zfs_cmd_resume_t *resume_c;
switch (cflag) {
+ case ZFS_CMD_COMPAT_RESUME:
+ resume_c = (void *)addr;
+ /* zc */
+ strlcpy(zc->zc_name, resume_c->zc_name, MAXPATHLEN);
+ strlcpy(zc->zc_value, resume_c->zc_value, MAXPATHLEN * 2);
+ strlcpy(zc->zc_string, resume_c->zc_string, MAXPATHLEN);
+
+#define FIELD_COPY(field) zc->field = resume_c->field
+ FIELD_COPY(zc_nvlist_src);
+ FIELD_COPY(zc_nvlist_src_size);
+ FIELD_COPY(zc_nvlist_dst);
+ FIELD_COPY(zc_nvlist_dst_size);
+ FIELD_COPY(zc_nvlist_dst_filled);
+ FIELD_COPY(zc_pad2);
+ FIELD_COPY(zc_history);
+ FIELD_COPY(zc_guid);
+ FIELD_COPY(zc_nvlist_conf);
+ FIELD_COPY(zc_nvlist_conf_size);
+ FIELD_COPY(zc_cookie);
+ FIELD_COPY(zc_objset_type);
+ FIELD_COPY(zc_perm_action);
+ FIELD_COPY(zc_history_len);
+ FIELD_COPY(zc_history_offset);
+ FIELD_COPY(zc_obj);
+ FIELD_COPY(zc_iflags);
+ FIELD_COPY(zc_share);
+ FIELD_COPY(zc_jailid);
+ FIELD_COPY(zc_objset_stats);
+ FIELD_COPY(zc_begin_record);
+ FIELD_COPY(zc_inject_record.zi_objset);
+ FIELD_COPY(zc_inject_record.zi_object);
+ FIELD_COPY(zc_inject_record.zi_start);
+ FIELD_COPY(zc_inject_record.zi_end);
+ FIELD_COPY(zc_inject_record.zi_guid);
+ FIELD_COPY(zc_inject_record.zi_level);
+ FIELD_COPY(zc_inject_record.zi_error);
+ FIELD_COPY(zc_inject_record.zi_type);
+ FIELD_COPY(zc_inject_record.zi_freq);
+ FIELD_COPY(zc_inject_record.zi_failfast);
+ strlcpy(zc->zc_inject_record.zi_func,
+ resume_c->zc_inject_record.zi_func, MAXNAMELEN);
+ FIELD_COPY(zc_inject_record.zi_iotype);
+ FIELD_COPY(zc_inject_record.zi_duration);
+ FIELD_COPY(zc_inject_record.zi_timer);
+ zc->zc_inject_record.zi_nlanes = 1;
+ FIELD_COPY(zc_inject_record.zi_cmd);
+ FIELD_COPY(zc_inject_record.zi_pad);
+ FIELD_COPY(zc_defer_destroy);
+ FIELD_COPY(zc_flags);
+ FIELD_COPY(zc_action_handle);
+ FIELD_COPY(zc_cleanup_fd);
+ FIELD_COPY(zc_simple);
+ FIELD_COPY(zc_resumable);
+ FIELD_COPY(zc_sendobj);
+ FIELD_COPY(zc_fromobj);
+ FIELD_COPY(zc_createtxg);
+ FIELD_COPY(zc_stat);
+#undef FIELD_COPY
+ break;
+
case ZFS_CMD_COMPAT_EDBP:
edbp_c = (void *)addr;
/* zc */
@@ -63,40 +124,57 @@ zfs_cmd_compat_get(zfs_cmd_t *zc, caddr_t addr, const int cflag)
strlcpy(zc->zc_value, edbp_c->zc_value, MAXPATHLEN * 2);
strlcpy(zc->zc_string, edbp_c->zc_string, MAXPATHLEN);
-#define ZCMD_COPY(field) zc->field = edbp_c->field
- ZCMD_COPY(zc_nvlist_src);
- ZCMD_COPY(zc_nvlist_src_size);
- ZCMD_COPY(zc_nvlist_dst);
- ZCMD_COPY(zc_nvlist_dst_size);
- ZCMD_COPY(zc_nvlist_dst_filled);
- ZCMD_COPY(zc_pad2);
- ZCMD_COPY(zc_history);
- ZCMD_COPY(zc_guid);
- ZCMD_COPY(zc_nvlist_conf);
- ZCMD_COPY(zc_nvlist_conf_size);
- ZCMD_COPY(zc_cookie);
- ZCMD_COPY(zc_objset_type);
- ZCMD_COPY(zc_perm_action);
- ZCMD_COPY(zc_history_len);
- ZCMD_COPY(zc_history_offset);
- ZCMD_COPY(zc_obj);
- ZCMD_COPY(zc_iflags);
- ZCMD_COPY(zc_share);
- ZCMD_COPY(zc_jailid);
- ZCMD_COPY(zc_objset_stats);
+#define FIELD_COPY(field) zc->field = edbp_c->field
+ FIELD_COPY(zc_nvlist_src);
+ FIELD_COPY(zc_nvlist_src_size);
+ FIELD_COPY(zc_nvlist_dst);
+ FIELD_COPY(zc_nvlist_dst_size);
+ FIELD_COPY(zc_nvlist_dst_filled);
+ FIELD_COPY(zc_pad2);
+ FIELD_COPY(zc_history);
+ FIELD_COPY(zc_guid);
+ FIELD_COPY(zc_nvlist_conf);
+ FIELD_COPY(zc_nvlist_conf_size);
+ FIELD_COPY(zc_cookie);
+ FIELD_COPY(zc_objset_type);
+ FIELD_COPY(zc_perm_action);
+ FIELD_COPY(zc_history_len);
+ FIELD_COPY(zc_history_offset);
+ FIELD_COPY(zc_obj);
+ FIELD_COPY(zc_iflags);
+ FIELD_COPY(zc_share);
+ FIELD_COPY(zc_jailid);
+ FIELD_COPY(zc_objset_stats);
zc->zc_begin_record.drr_u.drr_begin = edbp_c->zc_begin_record;
- ZCMD_COPY(zc_inject_record);
- ZCMD_COPY(zc_defer_destroy);
- ZCMD_COPY(zc_flags);
- ZCMD_COPY(zc_action_handle);
- ZCMD_COPY(zc_cleanup_fd);
- ZCMD_COPY(zc_simple);
+ FIELD_COPY(zc_inject_record.zi_objset);
+ FIELD_COPY(zc_inject_record.zi_object);
+ FIELD_COPY(zc_inject_record.zi_start);
+ FIELD_COPY(zc_inject_record.zi_end);
+ FIELD_COPY(zc_inject_record.zi_guid);
+ FIELD_COPY(zc_inject_record.zi_level);
+ FIELD_COPY(zc_inject_record.zi_error);
+ FIELD_COPY(zc_inject_record.zi_type);
+ FIELD_COPY(zc_inject_record.zi_freq);
+ FIELD_COPY(zc_inject_record.zi_failfast);
+ strlcpy(zc->zc_inject_record.zi_func,
+ edbp_c->zc_inject_record.zi_func, MAXNAMELEN);
+ FIELD_COPY(zc_inject_record.zi_iotype);
+ FIELD_COPY(zc_inject_record.zi_duration);
+ FIELD_COPY(zc_inject_record.zi_timer);
+ zc->zc_inject_record.zi_nlanes = 1;
+ FIELD_COPY(zc_inject_record.zi_cmd);
+ FIELD_COPY(zc_inject_record.zi_pad);
+ FIELD_COPY(zc_defer_destroy);
+ FIELD_COPY(zc_flags);
+ FIELD_COPY(zc_action_handle);
+ FIELD_COPY(zc_cleanup_fd);
+ FIELD_COPY(zc_simple);
zc->zc_resumable = B_FALSE;
- ZCMD_COPY(zc_sendobj);
- ZCMD_COPY(zc_fromobj);
- ZCMD_COPY(zc_createtxg);
- ZCMD_COPY(zc_stat);
-#undef ZCMD_COPY
+ FIELD_COPY(zc_sendobj);
+ FIELD_COPY(zc_fromobj);
+ FIELD_COPY(zc_createtxg);
+ FIELD_COPY(zc_stat);
+#undef FIELD_COPY
break;
case ZFS_CMD_COMPAT_ZCMD:
@@ -106,43 +184,60 @@ zfs_cmd_compat_get(zfs_cmd_t *zc, caddr_t addr, const int cflag)
strlcpy(zc->zc_value, zcmd_c->zc_value, MAXPATHLEN * 2);
strlcpy(zc->zc_string, zcmd_c->zc_string, MAXPATHLEN);
-#define ZCMD_COPY(field) zc->field = zcmd_c->field
- ZCMD_COPY(zc_nvlist_src);
- ZCMD_COPY(zc_nvlist_src_size);
- ZCMD_COPY(zc_nvlist_dst);
- ZCMD_COPY(zc_nvlist_dst_size);
- ZCMD_COPY(zc_nvlist_dst_filled);
- ZCMD_COPY(zc_pad2);
- ZCMD_COPY(zc_history);
- ZCMD_COPY(zc_guid);
- ZCMD_COPY(zc_nvlist_conf);
- ZCMD_COPY(zc_nvlist_conf_size);
- ZCMD_COPY(zc_cookie);
- ZCMD_COPY(zc_objset_type);
- ZCMD_COPY(zc_perm_action);
- ZCMD_COPY(zc_history_len);
- ZCMD_COPY(zc_history_offset);
- ZCMD_COPY(zc_obj);
- ZCMD_COPY(zc_iflags);
- ZCMD_COPY(zc_share);
- ZCMD_COPY(zc_jailid);
- ZCMD_COPY(zc_objset_stats);
+#define FIELD_COPY(field) zc->field = zcmd_c->field
+ FIELD_COPY(zc_nvlist_src);
+ FIELD_COPY(zc_nvlist_src_size);
+ FIELD_COPY(zc_nvlist_dst);
+ FIELD_COPY(zc_nvlist_dst_size);
+ FIELD_COPY(zc_nvlist_dst_filled);
+ FIELD_COPY(zc_pad2);
+ FIELD_COPY(zc_history);
+ FIELD_COPY(zc_guid);
+ FIELD_COPY(zc_nvlist_conf);
+ FIELD_COPY(zc_nvlist_conf_size);
+ FIELD_COPY(zc_cookie);
+ FIELD_COPY(zc_objset_type);
+ FIELD_COPY(zc_perm_action);
+ FIELD_COPY(zc_history_len);
+ FIELD_COPY(zc_history_offset);
+ FIELD_COPY(zc_obj);
+ FIELD_COPY(zc_iflags);
+ FIELD_COPY(zc_share);
+ FIELD_COPY(zc_jailid);
+ FIELD_COPY(zc_objset_stats);
zc->zc_begin_record.drr_u.drr_begin = zcmd_c->zc_begin_record;
- ZCMD_COPY(zc_inject_record);
+ FIELD_COPY(zc_inject_record.zi_objset);
+ FIELD_COPY(zc_inject_record.zi_object);
+ FIELD_COPY(zc_inject_record.zi_start);
+ FIELD_COPY(zc_inject_record.zi_end);
+ FIELD_COPY(zc_inject_record.zi_guid);
+ FIELD_COPY(zc_inject_record.zi_level);
+ FIELD_COPY(zc_inject_record.zi_error);
+ FIELD_COPY(zc_inject_record.zi_type);
+ FIELD_COPY(zc_inject_record.zi_freq);
+ FIELD_COPY(zc_inject_record.zi_failfast);
+ strlcpy(zc->zc_inject_record.zi_func,
+ zcmd_c->zc_inject_record.zi_func, MAXNAMELEN);
+ FIELD_COPY(zc_inject_record.zi_iotype);
+ FIELD_COPY(zc_inject_record.zi_duration);
+ FIELD_COPY(zc_inject_record.zi_timer);
+ zc->zc_inject_record.zi_nlanes = 1;
+ FIELD_COPY(zc_inject_record.zi_cmd);
+ FIELD_COPY(zc_inject_record.zi_pad);
/* boolean_t -> uint32_t */
zc->zc_defer_destroy = (uint32_t)(zcmd_c->zc_defer_destroy);
zc->zc_flags = 0;
- ZCMD_COPY(zc_action_handle);
- ZCMD_COPY(zc_cleanup_fd);
- ZCMD_COPY(zc_simple);
+ FIELD_COPY(zc_action_handle);
+ FIELD_COPY(zc_cleanup_fd);
+ FIELD_COPY(zc_simple);
zc->zc_resumable = B_FALSE;
- ZCMD_COPY(zc_sendobj);
- ZCMD_COPY(zc_fromobj);
- ZCMD_COPY(zc_createtxg);
- ZCMD_COPY(zc_stat);
-#undef ZCMD_COPY
+ FIELD_COPY(zc_sendobj);
+ FIELD_COPY(zc_fromobj);
+ FIELD_COPY(zc_createtxg);
+ FIELD_COPY(zc_stat);
+#undef FIELD_COPY
break;
@@ -152,6 +247,8 @@ zfs_cmd_compat_get(zfs_cmd_t *zc, caddr_t addr, const int cflag)
strlcpy(zc->zc_name, zcdm_c->zc_name, MAXPATHLEN);
strlcpy(zc->zc_value, zcdm_c->zc_value, MAXPATHLEN * 2);
strlcpy(zc->zc_string, zcdm_c->zc_string, MAXPATHLEN);
+
+#define FIELD_COPY(field) zc->field = zcdm_c->field
zc->zc_guid = zcdm_c->zc_guid;
zc->zc_nvlist_conf = zcdm_c->zc_nvlist_conf;
zc->zc_nvlist_conf_size = zcdm_c->zc_nvlist_conf_size;
@@ -181,12 +278,28 @@ zfs_cmd_compat_get(zfs_cmd_t *zc, caddr_t addr, const int cflag)
zc->zc_fromobj = zcdm_c->zc_fromobj;
zc->zc_createtxg = zcdm_c->zc_createtxg;
zc->zc_stat = zcdm_c->zc_stat;
-
- /* zc_inject_record doesn't change in libzfs_core */
- zcdm_c->zc_inject_record = zc->zc_inject_record;
+ FIELD_COPY(zc_inject_record.zi_objset);
+ FIELD_COPY(zc_inject_record.zi_object);
+ FIELD_COPY(zc_inject_record.zi_start);
+ FIELD_COPY(zc_inject_record.zi_end);
+ FIELD_COPY(zc_inject_record.zi_guid);
+ FIELD_COPY(zc_inject_record.zi_level);
+ FIELD_COPY(zc_inject_record.zi_error);
+ FIELD_COPY(zc_inject_record.zi_type);
+ FIELD_COPY(zc_inject_record.zi_freq);
+ FIELD_COPY(zc_inject_record.zi_failfast);
+ strlcpy(zc->zc_inject_record.zi_func,
+ resume_c->zc_inject_record.zi_func, MAXNAMELEN);
+ FIELD_COPY(zc_inject_record.zi_iotype);
+ FIELD_COPY(zc_inject_record.zi_duration);
+ FIELD_COPY(zc_inject_record.zi_timer);
+ zc->zc_inject_record.zi_nlanes = 1;
+ FIELD_COPY(zc_inject_record.zi_cmd);
+ FIELD_COPY(zc_inject_record.zi_pad);
/* we always assume zc_nvlist_dst_filled is true */
zc->zc_nvlist_dst_filled = B_TRUE;
+#undef FIELD_COPY
break;
case ZFS_CMD_COMPAT_V28:
@@ -255,6 +368,7 @@ zfs_cmd_compat_get(zfs_cmd_t *zc, caddr_t addr, const int cflag)
zc28_c->zc_inject_record.zi_duration;
zc->zc_inject_record.zi_timer =
zc28_c->zc_inject_record.zi_timer;
+ zc->zc_inject_record.zi_nlanes = 1;
zc->zc_inject_record.zi_cmd = ZINJECT_UNINITIALIZED;
zc->zc_inject_record.zi_pad = 0;
break;
@@ -319,47 +433,121 @@ zfs_cmd_compat_put(zfs_cmd_t *zc, caddr_t addr, const int request,
zfs_cmd_deadman_t *zcdm_c;
zfs_cmd_zcmd_t *zcmd_c;
zfs_cmd_edbp_t *edbp_c;
+ zfs_cmd_resume_t *resume_c;
switch (cflag) {
+ case ZFS_CMD_COMPAT_RESUME:
+ resume_c = (void *)addr;
+ strlcpy(resume_c->zc_name, zc->zc_name, MAXPATHLEN);
+ strlcpy(resume_c->zc_value, zc->zc_value, MAXPATHLEN * 2);
+ strlcpy(resume_c->zc_string, zc->zc_string, MAXPATHLEN);
+
+#define FIELD_COPY(field) resume_c->field = zc->field
+ FIELD_COPY(zc_nvlist_src);
+ FIELD_COPY(zc_nvlist_src_size);
+ FIELD_COPY(zc_nvlist_dst);
+ FIELD_COPY(zc_nvlist_dst_size);
+ FIELD_COPY(zc_nvlist_dst_filled);
+ FIELD_COPY(zc_pad2);
+ FIELD_COPY(zc_history);
+ FIELD_COPY(zc_guid);
+ FIELD_COPY(zc_nvlist_conf);
+ FIELD_COPY(zc_nvlist_conf_size);
+ FIELD_COPY(zc_cookie);
+ FIELD_COPY(zc_objset_type);
+ FIELD_COPY(zc_perm_action);
+ FIELD_COPY(zc_history_len);
+ FIELD_COPY(zc_history_offset);
+ FIELD_COPY(zc_obj);
+ FIELD_COPY(zc_iflags);
+ FIELD_COPY(zc_share);
+ FIELD_COPY(zc_jailid);
+ FIELD_COPY(zc_objset_stats);
+ FIELD_COPY(zc_begin_record);
+ FIELD_COPY(zc_inject_record.zi_objset);
+ FIELD_COPY(zc_inject_record.zi_object);
+ FIELD_COPY(zc_inject_record.zi_start);
+ FIELD_COPY(zc_inject_record.zi_end);
+ FIELD_COPY(zc_inject_record.zi_guid);
+ FIELD_COPY(zc_inject_record.zi_level);
+ FIELD_COPY(zc_inject_record.zi_error);
+ FIELD_COPY(zc_inject_record.zi_type);
+ FIELD_COPY(zc_inject_record.zi_freq);
+ FIELD_COPY(zc_inject_record.zi_failfast);
+ strlcpy(resume_c->zc_inject_record.zi_func,
+ zc->zc_inject_record.zi_func, MAXNAMELEN);
+ FIELD_COPY(zc_inject_record.zi_iotype);
+ FIELD_COPY(zc_inject_record.zi_duration);
+ FIELD_COPY(zc_inject_record.zi_timer);
+ FIELD_COPY(zc_inject_record.zi_cmd);
+ FIELD_COPY(zc_inject_record.zi_pad);
+ FIELD_COPY(zc_defer_destroy);
+ FIELD_COPY(zc_flags);
+ FIELD_COPY(zc_action_handle);
+ FIELD_COPY(zc_cleanup_fd);
+ FIELD_COPY(zc_simple);
+ FIELD_COPY(zc_sendobj);
+ FIELD_COPY(zc_fromobj);
+ FIELD_COPY(zc_createtxg);
+ FIELD_COPY(zc_stat);
+#undef FIELD_COPY
+ break;
+
case ZFS_CMD_COMPAT_EDBP:
edbp_c = (void *)addr;
strlcpy(edbp_c->zc_name, zc->zc_name, MAXPATHLEN);
strlcpy(edbp_c->zc_value, zc->zc_value, MAXPATHLEN * 2);
strlcpy(edbp_c->zc_string, zc->zc_string, MAXPATHLEN);
-#define ZCMD_COPY(field) edbp_c->field = zc->field
- ZCMD_COPY(zc_nvlist_src);
- ZCMD_COPY(zc_nvlist_src_size);
- ZCMD_COPY(zc_nvlist_dst);
- ZCMD_COPY(zc_nvlist_dst_size);
- ZCMD_COPY(zc_nvlist_dst_filled);
- ZCMD_COPY(zc_pad2);
- ZCMD_COPY(zc_history);
- ZCMD_COPY(zc_guid);
- ZCMD_COPY(zc_nvlist_conf);
- ZCMD_COPY(zc_nvlist_conf_size);
- ZCMD_COPY(zc_cookie);
- ZCMD_COPY(zc_objset_type);
- ZCMD_COPY(zc_perm_action);
- ZCMD_COPY(zc_history_len);
- ZCMD_COPY(zc_history_offset);
- ZCMD_COPY(zc_obj);
- ZCMD_COPY(zc_iflags);
- ZCMD_COPY(zc_share);
- ZCMD_COPY(zc_jailid);
- ZCMD_COPY(zc_objset_stats);
+#define FIELD_COPY(field) edbp_c->field = zc->field
+ FIELD_COPY(zc_nvlist_src);
+ FIELD_COPY(zc_nvlist_src_size);
+ FIELD_COPY(zc_nvlist_dst);
+ FIELD_COPY(zc_nvlist_dst_size);
+ FIELD_COPY(zc_nvlist_dst_filled);
+ FIELD_COPY(zc_pad2);
+ FIELD_COPY(zc_history);
+ FIELD_COPY(zc_guid);
+ FIELD_COPY(zc_nvlist_conf);
+ FIELD_COPY(zc_nvlist_conf_size);
+ FIELD_COPY(zc_cookie);
+ FIELD_COPY(zc_objset_type);
+ FIELD_COPY(zc_perm_action);
+ FIELD_COPY(zc_history_len);
+ FIELD_COPY(zc_history_offset);
+ FIELD_COPY(zc_obj);
+ FIELD_COPY(zc_iflags);
+ FIELD_COPY(zc_share);
+ FIELD_COPY(zc_jailid);
+ FIELD_COPY(zc_objset_stats);
edbp_c->zc_begin_record = zc->zc_begin_record.drr_u.drr_begin;
- ZCMD_COPY(zc_inject_record);
- ZCMD_COPY(zc_defer_destroy);
- ZCMD_COPY(zc_flags);
- ZCMD_COPY(zc_action_handle);
- ZCMD_COPY(zc_cleanup_fd);
- ZCMD_COPY(zc_simple);
- ZCMD_COPY(zc_sendobj);
- ZCMD_COPY(zc_fromobj);
- ZCMD_COPY(zc_createtxg);
- ZCMD_COPY(zc_stat);
-#undef ZCMD_COPY
+ FIELD_COPY(zc_inject_record.zi_objset);
+ FIELD_COPY(zc_inject_record.zi_object);
+ FIELD_COPY(zc_inject_record.zi_start);
+ FIELD_COPY(zc_inject_record.zi_end);
+ FIELD_COPY(zc_inject_record.zi_guid);
+ FIELD_COPY(zc_inject_record.zi_level);
+ FIELD_COPY(zc_inject_record.zi_error);
+ FIELD_COPY(zc_inject_record.zi_type);
+ FIELD_COPY(zc_inject_record.zi_freq);
+ FIELD_COPY(zc_inject_record.zi_failfast);
+ strlcpy(resume_c->zc_inject_record.zi_func,
+ zc->zc_inject_record.zi_func, MAXNAMELEN);
+ FIELD_COPY(zc_inject_record.zi_iotype);
+ FIELD_COPY(zc_inject_record.zi_duration);
+ FIELD_COPY(zc_inject_record.zi_timer);
+ FIELD_COPY(zc_inject_record.zi_cmd);
+ FIELD_COPY(zc_inject_record.zi_pad);
+ FIELD_COPY(zc_defer_destroy);
+ FIELD_COPY(zc_flags);
+ FIELD_COPY(zc_action_handle);
+ FIELD_COPY(zc_cleanup_fd);
+ FIELD_COPY(zc_simple);
+ FIELD_COPY(zc_sendobj);
+ FIELD_COPY(zc_fromobj);
+ FIELD_COPY(zc_createtxg);
+ FIELD_COPY(zc_stat);
+#undef FIELD_COPY
break;
case ZFS_CMD_COMPAT_ZCMD:
@@ -369,42 +557,58 @@ zfs_cmd_compat_put(zfs_cmd_t *zc, caddr_t addr, const int request,
strlcpy(zcmd_c->zc_value, zc->zc_value, MAXPATHLEN * 2);
strlcpy(zcmd_c->zc_string, zc->zc_string, MAXPATHLEN);
-#define ZCMD_COPY(field) zcmd_c->field = zc->field
- ZCMD_COPY(zc_nvlist_src);
- ZCMD_COPY(zc_nvlist_src_size);
- ZCMD_COPY(zc_nvlist_dst);
- ZCMD_COPY(zc_nvlist_dst_size);
- ZCMD_COPY(zc_nvlist_dst_filled);
- ZCMD_COPY(zc_pad2);
- ZCMD_COPY(zc_history);
- ZCMD_COPY(zc_guid);
- ZCMD_COPY(zc_nvlist_conf);
- ZCMD_COPY(zc_nvlist_conf_size);
- ZCMD_COPY(zc_cookie);
- ZCMD_COPY(zc_objset_type);
- ZCMD_COPY(zc_perm_action);
- ZCMD_COPY(zc_history_len);
- ZCMD_COPY(zc_history_offset);
- ZCMD_COPY(zc_obj);
- ZCMD_COPY(zc_iflags);
- ZCMD_COPY(zc_share);
- ZCMD_COPY(zc_jailid);
- ZCMD_COPY(zc_objset_stats);
+#define FIELD_COPY(field) zcmd_c->field = zc->field
+ FIELD_COPY(zc_nvlist_src);
+ FIELD_COPY(zc_nvlist_src_size);
+ FIELD_COPY(zc_nvlist_dst);
+ FIELD_COPY(zc_nvlist_dst_size);
+ FIELD_COPY(zc_nvlist_dst_filled);
+ FIELD_COPY(zc_pad2);
+ FIELD_COPY(zc_history);
+ FIELD_COPY(zc_guid);
+ FIELD_COPY(zc_nvlist_conf);
+ FIELD_COPY(zc_nvlist_conf_size);
+ FIELD_COPY(zc_cookie);
+ FIELD_COPY(zc_objset_type);
+ FIELD_COPY(zc_perm_action);
+ FIELD_COPY(zc_history_len);
+ FIELD_COPY(zc_history_offset);
+ FIELD_COPY(zc_obj);
+ FIELD_COPY(zc_iflags);
+ FIELD_COPY(zc_share);
+ FIELD_COPY(zc_jailid);
+ FIELD_COPY(zc_objset_stats);
zcmd_c->zc_begin_record = zc->zc_begin_record.drr_u.drr_begin;
- ZCMD_COPY(zc_inject_record);
+ FIELD_COPY(zc_inject_record.zi_objset);
+ FIELD_COPY(zc_inject_record.zi_object);
+ FIELD_COPY(zc_inject_record.zi_start);
+ FIELD_COPY(zc_inject_record.zi_end);
+ FIELD_COPY(zc_inject_record.zi_guid);
+ FIELD_COPY(zc_inject_record.zi_level);
+ FIELD_COPY(zc_inject_record.zi_error);
+ FIELD_COPY(zc_inject_record.zi_type);
+ FIELD_COPY(zc_inject_record.zi_freq);
+ FIELD_COPY(zc_inject_record.zi_failfast);
+ strlcpy(resume_c->zc_inject_record.zi_func,
+ zc->zc_inject_record.zi_func, MAXNAMELEN);
+ FIELD_COPY(zc_inject_record.zi_iotype);
+ FIELD_COPY(zc_inject_record.zi_duration);
+ FIELD_COPY(zc_inject_record.zi_timer);
+ FIELD_COPY(zc_inject_record.zi_cmd);
+ FIELD_COPY(zc_inject_record.zi_pad);
/* boolean_t -> uint32_t */
zcmd_c->zc_defer_destroy = (uint32_t)(zc->zc_defer_destroy);
zcmd_c->zc_temphold = 0;
- ZCMD_COPY(zc_action_handle);
- ZCMD_COPY(zc_cleanup_fd);
- ZCMD_COPY(zc_simple);
- ZCMD_COPY(zc_sendobj);
- ZCMD_COPY(zc_fromobj);
- ZCMD_COPY(zc_createtxg);
- ZCMD_COPY(zc_stat);
-#undef ZCMD_COPY
+ FIELD_COPY(zc_action_handle);
+ FIELD_COPY(zc_cleanup_fd);
+ FIELD_COPY(zc_simple);
+ FIELD_COPY(zc_sendobj);
+ FIELD_COPY(zc_fromobj);
+ FIELD_COPY(zc_createtxg);
+ FIELD_COPY(zc_stat);
+#undef FIELD_COPY
break;
@@ -414,6 +618,8 @@ zfs_cmd_compat_put(zfs_cmd_t *zc, caddr_t addr, const int request,
strlcpy(zcdm_c->zc_name, zc->zc_name, MAXPATHLEN);
strlcpy(zcdm_c->zc_value, zc->zc_value, MAXPATHLEN * 2);
strlcpy(zcdm_c->zc_string, zc->zc_string, MAXPATHLEN);
+
+#define FIELD_COPY(field) zcdm_c->field = zc->field
zcdm_c->zc_guid = zc->zc_guid;
zcdm_c->zc_nvlist_conf = zc->zc_nvlist_conf;
zcdm_c->zc_nvlist_conf_size = zc->zc_nvlist_conf_size;
@@ -442,9 +648,24 @@ zfs_cmd_compat_put(zfs_cmd_t *zc, caddr_t addr, const int request,
zcdm_c->zc_fromobj = zc->zc_fromobj;
zcdm_c->zc_createtxg = zc->zc_createtxg;
zcdm_c->zc_stat = zc->zc_stat;
-
- /* zc_inject_record doesn't change in libzfs_core */
- zc->zc_inject_record = zcdm_c->zc_inject_record;
+ FIELD_COPY(zc_inject_record.zi_objset);
+ FIELD_COPY(zc_inject_record.zi_object);
+ FIELD_COPY(zc_inject_record.zi_start);
+ FIELD_COPY(zc_inject_record.zi_end);
+ FIELD_COPY(zc_inject_record.zi_guid);
+ FIELD_COPY(zc_inject_record.zi_level);
+ FIELD_COPY(zc_inject_record.zi_error);
+ FIELD_COPY(zc_inject_record.zi_type);
+ FIELD_COPY(zc_inject_record.zi_freq);
+ FIELD_COPY(zc_inject_record.zi_failfast);
+ strlcpy(resume_c->zc_inject_record.zi_func,
+ zc->zc_inject_record.zi_func, MAXNAMELEN);
+ FIELD_COPY(zc_inject_record.zi_iotype);
+ FIELD_COPY(zc_inject_record.zi_duration);
+ FIELD_COPY(zc_inject_record.zi_timer);
+ FIELD_COPY(zc_inject_record.zi_cmd);
+ FIELD_COPY(zc_inject_record.zi_pad);
+#undef FIELD_COPY
#ifndef _KERNEL
if (request == ZFS_IOC_RECV)
strlcpy(zcdm_c->zc_top_ds,
@@ -766,6 +987,12 @@ zcmd_ioctl_compat(int fd, int request, zfs_cmd_t *zc, const int cflag)
zp.zfs_cmd_size = sizeof(zfs_cmd_t);
zp.zfs_ioctl_version = ZFS_IOCVER_CURRENT;
return (ioctl(fd, ncmd, &zp));
+ case ZFS_CMD_COMPAT_RESUME:
+ ncmd = _IOWR('Z', request, struct zfs_iocparm);
+ zp.zfs_cmd = (uint64_t)zc;
+ zp.zfs_cmd_size = sizeof(zfs_cmd_resume_t);
+ zp.zfs_ioctl_version = ZFS_IOCVER_RESUME;
+ return (ioctl(fd, ncmd, &zp));
case ZFS_CMD_COMPAT_EDBP:
ncmd = _IOWR('Z', request, struct zfs_iocparm);
zp.zfs_cmd = (uint64_t)zc;
@@ -876,7 +1103,8 @@ zfs_ioctl_compat_innvl(zfs_cmd_t *zc, nvlist_t * innvl, const int vec,
int err;
if (cflag == ZFS_CMD_COMPAT_NONE || cflag == ZFS_CMD_COMPAT_LZC ||
- cflag == ZFS_CMD_COMPAT_ZCMD || cflag == ZFS_CMD_COMPAT_EDBP)
+ cflag == ZFS_CMD_COMPAT_ZCMD || cflag == ZFS_CMD_COMPAT_EDBP ||
+ cflag == ZFS_CMD_COMPAT_RESUME)
goto out;
switch (vec) {
@@ -1028,7 +1256,8 @@ zfs_ioctl_compat_outnvl(zfs_cmd_t *zc, nvlist_t * outnvl, const int vec,
nvlist_t *tmpnvl;
if (cflag == ZFS_CMD_COMPAT_NONE || cflag == ZFS_CMD_COMPAT_LZC ||
- cflag == ZFS_CMD_COMPAT_ZCMD || cflag == ZFS_CMD_COMPAT_EDBP)
+ cflag == ZFS_CMD_COMPAT_ZCMD || cflag == ZFS_CMD_COMPAT_EDBP ||
+ cflag == ZFS_CMD_COMPAT_RESUME)
return (outnvl);
switch (vec) {
diff --git a/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.h b/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.h
index 8361aa3..6f24380 100644
--- a/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.h
+++ b/sys/cddl/contrib/opensolaris/common/zfs/zfs_ioctl_compat.h
@@ -53,7 +53,8 @@ extern "C" {
#define ZFS_IOCVER_ZCMD 3
#define ZFS_IOCVER_EDBP 4
#define ZFS_IOCVER_RESUME 5
-#define ZFS_IOCVER_CURRENT ZFS_IOCVER_RESUME
+#define ZFS_IOCVER_INLANES 6
+#define ZFS_IOCVER_CURRENT ZFS_IOCVER_INLANES
/* compatibility conversion flag */
#define ZFS_CMD_COMPAT_NONE 0
@@ -63,6 +64,7 @@ extern "C" {
#define ZFS_CMD_COMPAT_LZC 4
#define ZFS_CMD_COMPAT_ZCMD 5
#define ZFS_CMD_COMPAT_EDBP 6
+#define ZFS_CMD_COMPAT_RESUME 7
#define ZFS_IOC_COMPAT_PASS 254
#define ZFS_IOC_COMPAT_FAIL 255
@@ -167,6 +169,25 @@ typedef struct zfs_cmd_v28 {
zfs_stat_t zc_stat;
} zfs_cmd_v28_t;
+typedef struct zinject_record_deadman {
+ uint64_t zi_objset;
+ uint64_t zi_object;
+ uint64_t zi_start;
+ uint64_t zi_end;
+ uint64_t zi_guid;
+ uint32_t zi_level;
+ uint32_t zi_error;
+ uint64_t zi_type;
+ uint32_t zi_freq;
+ uint32_t zi_failfast;
+ char zi_func[MAXNAMELEN];
+ uint32_t zi_iotype;
+ int32_t zi_duration;
+ uint64_t zi_timer;
+ uint32_t zi_cmd;
+ uint32_t zi_pad;
+} zinject_record_deadman_t;
+
typedef struct zfs_cmd_deadman {
char zc_name[MAXPATHLEN];
char zc_value[MAXPATHLEN * 2];
@@ -192,7 +213,7 @@ typedef struct zfs_cmd_deadman {
dmu_objset_stats_t zc_objset_stats;
struct drr_begin zc_begin_record;
/* zc_inject_record doesn't change in libzfs_core */
- zinject_record_t zc_inject_record;
+ zinject_record_deadman_t zc_inject_record;
boolean_t zc_defer_destroy;
boolean_t zc_temphold;
uint64_t zc_action_handle;
@@ -235,7 +256,7 @@ typedef struct zfs_cmd_zcmd {
uint64_t zc_jailid;
dmu_objset_stats_t zc_objset_stats;
struct drr_begin zc_begin_record;
- zinject_record_t zc_inject_record;
+ zinject_record_deadman_t zc_inject_record;
boolean_t zc_defer_destroy;
boolean_t zc_temphold;
uint64_t zc_action_handle;
@@ -278,7 +299,7 @@ typedef struct zfs_cmd_edbp {
uint64_t zc_jailid;
dmu_objset_stats_t zc_objset_stats;
struct drr_begin zc_begin_record;
- zinject_record_t zc_inject_record;
+ zinject_record_deadman_t zc_inject_record;
uint32_t zc_defer_destroy;
uint32_t zc_flags;
uint64_t zc_action_handle;
@@ -291,6 +312,49 @@ typedef struct zfs_cmd_edbp {
zfs_stat_t zc_stat;
} zfs_cmd_edbp_t;
+typedef struct zfs_cmd_resume {
+ char zc_name[MAXPATHLEN]; /* name of pool or dataset */
+ uint64_t zc_nvlist_src; /* really (char *) */
+ uint64_t zc_nvlist_src_size;
+ uint64_t zc_nvlist_dst; /* really (char *) */
+ uint64_t zc_nvlist_dst_size;
+ boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */
+ int zc_pad2;
+
+ /*
+ * The following members are for legacy ioctls which haven't been
+ * converted to the new method.
+ */
+ uint64_t zc_history; /* really (char *) */
+ char zc_value[MAXPATHLEN * 2];
+ char zc_string[MAXNAMELEN];
+ uint64_t zc_guid;
+ uint64_t zc_nvlist_conf; /* really (char *) */
+ uint64_t zc_nvlist_conf_size;
+ uint64_t zc_cookie;
+ uint64_t zc_objset_type;
+ uint64_t zc_perm_action;
+ uint64_t zc_history_len;
+ uint64_t zc_history_offset;
+ uint64_t zc_obj;
+ uint64_t zc_iflags; /* internal to zfs(7fs) */
+ zfs_share_t zc_share;
+ uint64_t zc_jailid;
+ dmu_objset_stats_t zc_objset_stats;
+ dmu_replay_record_t zc_begin_record;
+ zinject_record_deadman_t zc_inject_record;
+ uint32_t zc_defer_destroy;
+ uint32_t zc_flags;
+ uint64_t zc_action_handle;
+ int zc_cleanup_fd;
+ uint8_t zc_simple;
+ boolean_t zc_resumable;
+ uint64_t zc_sendobj;
+ uint64_t zc_fromobj;
+ uint64_t zc_createtxg;
+ zfs_stat_t zc_stat;
+} zfs_cmd_resume_t;
+
#ifdef _KERNEL
unsigned static long zfs_ioctl_v15_to_v28[] = {
0, /* 0 ZFS_IOC_POOL_CREATE */
diff --git a/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c b/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c
index 20b54d8..c310a67b 100644
--- a/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c
+++ b/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c
@@ -23,6 +23,7 @@
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
/* Portions Copyright 2010 Robert Milkowski */
diff --git a/sys/cddl/contrib/opensolaris/common/zfs/zpool_prop.c b/sys/cddl/contrib/opensolaris/common/zfs/zpool_prop.c
index 4d906b0..9c71744 100644
--- a/sys/cddl/contrib/opensolaris/common/zfs/zpool_prop.c
+++ b/sys/cddl/contrib/opensolaris/common/zfs/zpool_prop.c
@@ -22,6 +22,7 @@
* Copyright (c) 2007, 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) 2014 Integros [integros.com]
*/
#include <sys/zio.h>
diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
index 1955984..9266ffc 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
@@ -67,42 +67,42 @@
* on capital-f functions.
*/
#include <sys/errno.h>
-#if !defined(sun)
+#ifndef illumos
#include <sys/time.h>
#endif
#include <sys/stat.h>
#include <sys/modctl.h>
#include <sys/conf.h>
#include <sys/systm.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/ddi.h>
#include <sys/sunddi.h>
#endif
#include <sys/cpuvar.h>
#include <sys/kmem.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/strsubr.h>
#endif
#include <sys/sysmacros.h>
#include <sys/dtrace_impl.h>
#include <sys/atomic.h>
#include <sys/cmn_err.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/mutex_impl.h>
#include <sys/rwlock_impl.h>
#endif
#include <sys/ctf_api.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/panic.h>
#include <sys/priv_impl.h>
#endif
#include <sys/policy.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/cred_impl.h>
#include <sys/procfs_isa.h>
#endif
#include <sys/taskq.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/mkdev.h>
#include <sys/kdi.h>
#endif
@@ -112,7 +112,7 @@
#include "strtolctype.h"
/* FreeBSD includes: */
-#if !defined(sun)
+#ifndef illumos
#include <sys/callout.h>
#include <sys/ctype.h>
#include <sys/eventhandler.h>
@@ -184,7 +184,7 @@ hrtime_t dtrace_deadman_interval = NANOSEC;
hrtime_t dtrace_deadman_timeout = (hrtime_t)10 * NANOSEC;
hrtime_t dtrace_deadman_user = (hrtime_t)30 * NANOSEC;
hrtime_t dtrace_unregister_defunct_reap = (hrtime_t)60 * NANOSEC;
-#if !defined(sun)
+#ifndef illumos
int dtrace_memstr_max = 4096;
#endif
@@ -202,10 +202,10 @@ const char dtrace_zero[256] = { 0 }; /* zero-filled memory */
/*
* DTrace Internal Variables
*/
-#if defined(sun)
+#ifdef illumos
static dev_info_t *dtrace_devi; /* device info */
#endif
-#if defined(sun)
+#ifdef illumos
static vmem_t *dtrace_arena; /* probe ID arena */
static vmem_t *dtrace_minor; /* minor number arena */
#else
@@ -219,7 +219,7 @@ static dtrace_meta_t *dtrace_meta_pid; /* user-land meta provider */
static int dtrace_opens; /* number of opens */
static int dtrace_helpers; /* number of helpers */
static int dtrace_getf; /* number of unpriv getf()s */
-#if defined(sun)
+#ifdef illumos
static void *dtrace_softstate; /* softstate pointer */
#endif
static dtrace_hash_t *dtrace_bymod; /* probes hashed by module */
@@ -239,7 +239,7 @@ static dtrace_enabling_t *dtrace_retained; /* list of retained enablings */
static dtrace_genid_t dtrace_retained_gen; /* current retained enab gen */
static dtrace_dynvar_t dtrace_dynhash_sink; /* end of dynamic hash chains */
static int dtrace_dynvar_failclean; /* dynvars failed to clean */
-#if !defined(sun)
+#ifndef illumos
static struct mtx dtrace_unr_mtx;
MTX_SYSINIT(dtrace_unr_mtx, &dtrace_unr_mtx, "Unique resource identifier", MTX_DEF);
int dtrace_in_probe; /* non-zero if executing a probe */
@@ -284,7 +284,7 @@ static kmutex_t dtrace_lock; /* probe state lock */
static kmutex_t dtrace_provider_lock; /* provider state lock */
static kmutex_t dtrace_meta_lock; /* meta-provider state lock */
-#if !defined(sun)
+#ifndef illumos
/* XXX FreeBSD hacks. */
#define cr_suid cr_svuid
#define cr_sgid cr_svgid
@@ -309,7 +309,7 @@ SYSCTL_DECL(_debug_dtrace);
SYSCTL_DECL(_kern_dtrace);
#endif
-#if defined(sun)
+#ifdef illumos
#define curcpu CPU->cpu_id
#endif
@@ -424,7 +424,7 @@ static kmutex_t dtrace_errlock;
* no way for a global variable key signature to match a thread-local key
* signature.
*/
-#if defined(sun)
+#ifdef illumos
#define DTRACE_TLS_THRKEY(where) { \
uint_t intr = 0; \
uint_t actv = CPU->cpu_intr_actv >> (LOCK_LEVEL + 1); \
@@ -857,7 +857,7 @@ dtrace_canload(uint64_t addr, size_t sz, dtrace_mstate_t *mstate,
return (1);
}
-#if defined(sun)
+#ifdef illumos
if (p != NULL && p->p_pidp != NULL && DTRACE_INRANGE(addr, sz,
&(p->p_pidp->pid_id), sizeof (pid_t))) {
return (1);
@@ -891,7 +891,7 @@ dtrace_canload(uint64_t addr, size_t sz, dtrace_mstate_t *mstate,
return (1);
if ((vp = fp->f_vnode) != NULL) {
-#if defined(sun)
+#ifdef illumos
if (DTRACE_INRANGE(addr, sz, &vp->v_path, psz))
return (1);
if (vp->v_path != NULL && DTRACE_INRANGE(addr, sz,
@@ -903,7 +903,7 @@ dtrace_canload(uint64_t addr, size_t sz, dtrace_mstate_t *mstate,
if (DTRACE_INRANGE(addr, sz, &vp->v_op, psz))
return (1);
-#if defined(sun)
+#ifdef illumos
if ((op = vp->v_op) != NULL &&
DTRACE_INRANGE(addr, sz, &op->vnop_name, psz)) {
return (1);
@@ -1340,7 +1340,7 @@ dtrace_priv_proc_common_user(dtrace_state_t *state)
static int
dtrace_priv_proc_common_zone(dtrace_state_t *state)
{
-#if defined(sun)
+#ifdef illumos
cred_t *cr, *s_cr = state->dts_cred.dcr_cred;
/*
@@ -1465,7 +1465,7 @@ dtrace_priv_probe(dtrace_state_t *state, dtrace_mstate_t *mstate,
ASSERT(ecb->dte_cond);
-#if defined(sun)
+#ifdef illumos
if (pops->dtps_mode != NULL) {
mode = pops->dtps_mode(prov->dtpv_arg,
probe->dtpr_id, probe->dtpr_arg);
@@ -1524,13 +1524,13 @@ dtrace_priv_probe(dtrace_state_t *state, dtrace_mstate_t *mstate,
if (mode & DTRACE_MODE_NOPRIV_DROP)
return (0);
-#if defined(sun)
+#ifdef illumos
mstate->dtms_access &= ~DTRACE_ACCESS_PROC;
#endif
}
}
-#if defined(sun)
+#ifdef illumos
/*
* If our dte_cond is set to DTRACE_COND_ZONEOWNER and we are not
* in our zone, check to see if our mode policy is to restrict rather
@@ -3190,7 +3190,7 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v,
return (mstate->dtms_arg[ndx]);
-#if defined(sun)
+#ifdef illumos
case DIF_VAR_UREGS: {
klwp_t *lwp;
@@ -3246,7 +3246,7 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v,
}
return (mstate->dtms_walltimestamp);
-#if defined(sun)
+#ifdef illumos
case DIF_VAR_IPL:
if (!dtrace_priv_kernel(state))
return (0);
@@ -3383,7 +3383,7 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v,
if (!dtrace_priv_proc(state))
return (0);
-#if defined(sun)
+#ifdef illumos
/*
* Note that we are assuming that an unanchored probe is
* always due to a high-level interrupt. (And we're assuming
@@ -3409,7 +3409,7 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v,
if (!dtrace_priv_proc(state))
return (0);
-#if defined(sun)
+#ifdef illumos
/*
* See comment in DIF_VAR_PID.
*/
@@ -3431,7 +3431,7 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v,
#endif
case DIF_VAR_TID:
-#if defined(sun)
+#ifdef illumos
/*
* See comment in DIF_VAR_PID.
*/
@@ -3452,7 +3452,7 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v,
}
case DIF_VAR_EXECNAME:
-#if defined(sun)
+#ifdef illumos
if (!dtrace_priv_proc(state))
return (0);
@@ -3477,7 +3477,7 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v,
#endif
case DIF_VAR_ZONENAME:
-#if defined(sun)
+#ifdef illumos
if (!dtrace_priv_proc(state))
return (0);
@@ -3504,7 +3504,7 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v,
if (!dtrace_priv_proc(state))
return (0);
-#if defined(sun)
+#ifdef illumos
/*
* See comment in DIF_VAR_PID.
*/
@@ -3529,7 +3529,7 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v,
if (!dtrace_priv_proc(state))
return (0);
-#if defined(sun)
+#ifdef illumos
/*
* See comment in DIF_VAR_PID.
*/
@@ -3551,7 +3551,7 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v,
#endif
case DIF_VAR_ERRNO: {
-#if defined(sun)
+#ifdef illumos
klwp_t *lwp;
if (!dtrace_priv_proc(state))
return (0);
@@ -3576,7 +3576,7 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v,
return (curthread->td_errno);
#endif
}
-#if !defined(sun)
+#ifndef illumos
case DIF_VAR_CPU: {
return curcpu;
}
@@ -4060,7 +4060,7 @@ dtrace_dif_subr(uint_t subr, uint_t rd, uint64_t *regs,
volatile uintptr_t *illval = &cpu_core[curcpu].cpuc_dtrace_illval;
dtrace_vstate_t *vstate = &state->dts_vstate;
-#if defined(sun)
+#ifdef illumos
union {
mutex_impl_t mi;
uint64_t mx;
@@ -4083,7 +4083,7 @@ dtrace_dif_subr(uint_t subr, uint_t rd, uint64_t *regs,
regs[rd] = (dtrace_gethrtime() * 2416 + 374441) % 1771875;
break;
-#if defined(sun)
+#ifdef illumos
case DIF_SUBR_MUTEX_OWNED:
if (!dtrace_canload(tupregs[0].dttk_value, sizeof (kmutex_t),
mstate, vstate)) {
@@ -4171,7 +4171,7 @@ dtrace_dif_subr(uint_t subr, uint_t rd, uint64_t *regs,
regs[rd] = _RW_ISWRITER(&r.ri);
break;
-#else
+#else /* !illumos */
case DIF_SUBR_MUTEX_OWNED:
if (!dtrace_canload(tupregs[0].dttk_value,
sizeof (struct lock_object), mstate, vstate)) {
@@ -4250,7 +4250,7 @@ dtrace_dif_subr(uint_t subr, uint_t rd, uint64_t *regs,
regs[rd] = LOCK_CLASS(l.li)->lc_owner(l.li, &lowner) &&
lowner != NULL;
break;
-#endif /* ! defined(sun) */
+#endif /* illumos */
case DIF_SUBR_BCOPY: {
/*
@@ -4360,7 +4360,7 @@ dtrace_dif_subr(uint_t subr, uint_t rd, uint64_t *regs,
break;
}
-#if defined(sun)
+#ifdef illumos
case DIF_SUBR_MSGSIZE:
case DIF_SUBR_MSGDSIZE: {
uintptr_t baddr = tupregs[0].dttk_value, daddr;
@@ -4428,7 +4428,7 @@ dtrace_dif_subr(uint_t subr, uint_t rd, uint64_t *regs,
DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
for (p = curthread->t_procp; p != NULL; p = p->p_parent) {
-#if defined(sun)
+#ifdef illumos
if (p->p_pidp->pid_id == pid) {
#else
if (p->p_pid == pid) {
@@ -4946,7 +4946,7 @@ dtrace_dif_subr(uint_t subr, uint_t rd, uint64_t *regs,
break;
}
-#if defined(sun)
+#ifdef illumos
case DIF_SUBR_GETMAJOR:
#ifdef _LP64
regs[rd] = (tupregs[0].dttk_value >> NBITSMINOR64) & MAXMAJ64;
@@ -5462,7 +5462,7 @@ dtrace_dif_subr(uint_t subr, uint_t rd, uint64_t *regs,
uint64_t size = state->dts_options[DTRACEOPT_STRSIZE];
uintptr_t src = tupregs[0].dttk_value;
int i = 0, j = 0;
-#if defined(sun)
+#ifdef illumos
zone_t *z;
#endif
@@ -5564,7 +5564,7 @@ next:
dest[j] = '\0';
-#if defined(sun)
+#ifdef illumos
if (mstate->dtms_getf != NULL &&
!(mstate->dtms_access & DTRACE_ACCESS_KERNEL) &&
(z = state->dts_cred.dcr_cred->cr_zone) != kcred->cr_zone) {
@@ -5687,7 +5687,7 @@ next:
tryzero = -1;
numzero = 1;
for (i = 0; i < sizeof (struct in6_addr); i++) {
-#if defined(sun)
+#ifdef illumos
if (ip6._S6_un._S6_u8[i] == 0 &&
#else
if (ip6.__u6_addr.__u6_addr8[i] == 0 &&
@@ -5698,7 +5698,7 @@ next:
}
if (tryzero != -1 &&
-#if defined(sun)
+#ifdef illumos
(ip6._S6_un._S6_u8[i] != 0 ||
#else
(ip6.__u6_addr.__u6_addr8[i] != 0 ||
@@ -5714,7 +5714,7 @@ next:
numzero = i - i % 2 - tryzero;
tryzero = -1;
-#if defined(sun)
+#ifdef illumos
if (ip6._S6_un._S6_u8[i] == 0 &&
#else
if (ip6.__u6_addr.__u6_addr8[i] == 0 &&
@@ -5735,7 +5735,7 @@ next:
i >= DTRACE_V4MAPPED_OFFSET; i--) {
ASSERT(end >= base);
-#if defined(sun)
+#ifdef illumos
val = ip6._S6_un._S6_u8[i];
#else
val = ip6.__u6_addr.__u6_addr8[i];
@@ -5780,7 +5780,7 @@ next:
if (i < 14 && i != firstzero - 2)
*end-- = ':';
-#if defined(sun)
+#ifdef illumos
val = (ip6._S6_un._S6_u8[i] << 8) +
ip6._S6_un._S6_u8[i + 1];
#else
@@ -5826,7 +5826,7 @@ inetout: regs[rd] = (uintptr_t)end + 1;
break;
}
-#if !defined(sun)
+#ifndef illumos
case DIF_SUBR_MEMSTR: {
char *str = (char *)mstate->dtms_scratch_ptr;
uintptr_t mem = tupregs[0].dttk_value;
@@ -6726,7 +6726,7 @@ dtrace_action_breakpoint(dtrace_ecb_t *ecb)
c[i++] = ')';
c[i] = '\0';
-#if defined(sun)
+#ifdef illumos
debug_enter(c);
#else
kdb_enter(KDB_WHY_DTRACE, "breakpoint action");
@@ -6773,7 +6773,7 @@ dtrace_action_raise(uint64_t sig)
return;
}
-#if defined(sun)
+#ifdef illumos
/*
* raise() has a queue depth of 1 -- we ignore all subsequent
* invocations of the raise() action.
@@ -6797,7 +6797,7 @@ dtrace_action_stop(void)
if (dtrace_destructive_disallow)
return;
-#if defined(sun)
+#ifdef illumos
if (!curthread->t_dtrace_stop) {
curthread->t_dtrace_stop = 1;
curthread->t_sig_check = 1;
@@ -6816,7 +6816,7 @@ dtrace_action_chill(dtrace_mstate_t *mstate, hrtime_t val)
{
hrtime_t now;
volatile uint16_t *flags;
-#if defined(sun)
+#ifdef illumos
cpu_t *cpu = CPU;
#else
cpu_t *cpu = &solaris_cpu[curcpu];
@@ -7054,7 +7054,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
if (panicstr != NULL)
return;
-#if defined(sun)
+#ifdef illumos
/*
* Kick out immediately if this CPU is still being born (in which case
* curthread will be set to -1) or the current thread can't allow
@@ -7079,7 +7079,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
return;
}
-#if defined(sun)
+#ifdef illumos
if (panic_quiesce) {
#else
if (panicstr != NULL) {
@@ -7186,7 +7186,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
probe->dtpr_id, probe->dtpr_arg) == 0)
continue;
-#if defined(sun)
+#ifdef illumos
/*
* This is more subtle than it looks. We have to be
* absolutely certain that CRED() isn't going to
@@ -7611,7 +7611,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
case DTRACEACT_USYM:
case DTRACEACT_UMOD:
case DTRACEACT_UADDR: {
-#if defined(sun)
+#ifdef illumos
struct pid *pid = curthread->t_procp->p_pidp;
#endif
@@ -7619,7 +7619,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
continue;
DTRACE_STORE(uint64_t, tomax,
-#if defined(sun)
+#ifdef illumos
valoffs, (uint64_t)pid->pid_id);
#else
valoffs, (uint64_t) curproc->p_pid);
@@ -8044,7 +8044,7 @@ dtrace_cred2priv(cred_t *cr, uint32_t *privp, uid_t *uidp, zoneid_t *zoneidp)
{
uint32_t priv;
-#if defined(sun)
+#ifdef illumos
if (cr == NULL || PRIV_POLICY_ONLY(cr, PRIV_ALL, B_FALSE)) {
/*
* For DTRACE_PRIV_ALL, the uid and zoneid don't matter.
@@ -8638,7 +8638,7 @@ dtrace_unregister(dtrace_provider_id_t id)
* already held.
*/
ASSERT(old == dtrace_provider);
-#if defined(sun)
+#ifdef illumos
ASSERT(dtrace_devi != NULL);
#endif
ASSERT(MUTEX_HELD(&dtrace_provider_lock));
@@ -8653,7 +8653,7 @@ dtrace_unregister(dtrace_provider_id_t id)
}
} else {
mutex_enter(&dtrace_provider_lock);
-#if defined(sun)
+#ifdef illumos
mutex_enter(&mod_lock);
#endif
mutex_enter(&dtrace_lock);
@@ -8669,7 +8669,7 @@ dtrace_unregister(dtrace_provider_id_t id)
dtrace_anon.dta_state->dts_necbs > 0))) {
if (!self) {
mutex_exit(&dtrace_lock);
-#if defined(sun)
+#ifdef illumos
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_provider_lock);
@@ -8705,7 +8705,7 @@ dtrace_unregister(dtrace_provider_id_t id)
if (!self) {
mutex_exit(&dtrace_lock);
-#if defined(sun)
+#ifdef illumos
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_provider_lock);
@@ -8761,7 +8761,7 @@ dtrace_unregister(dtrace_provider_id_t id)
kmem_free(probe->dtpr_mod, strlen(probe->dtpr_mod) + 1);
kmem_free(probe->dtpr_func, strlen(probe->dtpr_func) + 1);
kmem_free(probe->dtpr_name, strlen(probe->dtpr_name) + 1);
-#if defined(sun)
+#ifdef illumos
vmem_free(dtrace_arena, (void *)(uintptr_t)(probe->dtpr_id), 1);
#else
free_unr(dtrace_arena, probe->dtpr_id);
@@ -8770,7 +8770,7 @@ dtrace_unregister(dtrace_provider_id_t id)
}
if ((prev = dtrace_provider) == old) {
-#if defined(sun)
+#ifdef illumos
ASSERT(self || dtrace_devi == NULL);
ASSERT(old->dtpv_next == NULL || dtrace_devi == NULL);
#endif
@@ -8789,7 +8789,7 @@ dtrace_unregister(dtrace_provider_id_t id)
if (!self) {
mutex_exit(&dtrace_lock);
-#if defined(sun)
+#ifdef illumos
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_provider_lock);
@@ -8882,7 +8882,7 @@ dtrace_condense(dtrace_provider_id_t id)
kmem_free(probe->dtpr_func, strlen(probe->dtpr_func) + 1);
kmem_free(probe->dtpr_name, strlen(probe->dtpr_name) + 1);
kmem_free(probe, sizeof (dtrace_probe_t));
-#if defined(sun)
+#ifdef illumos
vmem_free(dtrace_arena, (void *)((uintptr_t)i + 1), 1);
#else
free_unr(dtrace_arena, i + 1);
@@ -8922,7 +8922,7 @@ dtrace_probe_create(dtrace_provider_id_t prov, const char *mod,
mutex_enter(&dtrace_lock);
}
-#if defined(sun)
+#ifdef illumos
id = (dtrace_id_t)(uintptr_t)vmem_alloc(dtrace_arena, 1,
VM_BESTFIT | VM_SLEEP);
#else
@@ -9093,7 +9093,7 @@ dtrace_probe_description(const dtrace_probe_t *prp, dtrace_probedesc_t *pdp)
static void
dtrace_probe_provide(dtrace_probedesc_t *desc, dtrace_provider_t *prv)
{
-#if defined(sun)
+#ifdef illumos
modctl_t *ctl;
#endif
int all = 0;
@@ -9111,7 +9111,7 @@ dtrace_probe_provide(dtrace_probedesc_t *desc, dtrace_provider_t *prv)
*/
prv->dtpv_pops.dtps_provide(prv->dtpv_arg, desc);
-#if defined(sun)
+#ifdef illumos
/*
* Now call the per-module provide operation. We will grab
* mod_lock to prevent the list from being modified. Note
@@ -9134,7 +9134,7 @@ dtrace_probe_provide(dtrace_probedesc_t *desc, dtrace_provider_t *prv)
} while (all && (prv = prv->dtpv_next) != NULL);
}
-#if defined(sun)
+#ifdef illumos
/*
* Iterate over each probe, and call the Framework-to-Provider API function
* denoted by offs.
@@ -10092,7 +10092,7 @@ dtrace_difo_validate_helper(dtrace_difo_t *dp)
subr == DIF_SUBR_NTOHL ||
subr == DIF_SUBR_NTOHLL ||
subr == DIF_SUBR_MEMREF ||
-#if !defined(sun)
+#ifndef illumos
subr == DIF_SUBR_MEMSTR ||
#endif
subr == DIF_SUBR_TYPEREF)
@@ -10730,7 +10730,7 @@ dtrace_actdesc_create(dtrace_actkind_t kind, uint32_t ntuple,
{
dtrace_actdesc_t *act;
-#if defined(sun)
+#ifdef illumos
ASSERT(!DTRACEACT_ISPRINTFLIKE(kind) || (arg != NULL &&
arg >= KERNELBASE) || (arg == NULL && kind == DTRACEACT_PRINTA));
#endif
@@ -10769,7 +10769,7 @@ dtrace_actdesc_release(dtrace_actdesc_t *act, dtrace_vstate_t *vstate)
if (DTRACEACT_ISPRINTFLIKE(kind)) {
char *str = (char *)(uintptr_t)act->dtad_arg;
-#if defined(sun)
+#ifdef illumos
ASSERT((str != NULL && (uintptr_t)str >= KERNELBASE) ||
(str == NULL && act->dtad_kind == DTRACEACT_PRINTA));
#endif
@@ -11128,7 +11128,7 @@ success:
/*
* We need to allocate an id for this aggregation.
*/
-#if defined(sun)
+#ifdef illumos
aggid = (dtrace_aggid_t)(uintptr_t)vmem_alloc(state->dts_aggid_arena, 1,
VM_BESTFIT | VM_SLEEP);
#else
@@ -11182,7 +11182,7 @@ dtrace_ecb_aggregation_destroy(dtrace_ecb_t *ecb, dtrace_action_t *act)
dtrace_aggid_t aggid = agg->dtag_id;
ASSERT(DTRACEACT_ISAGG(act->dta_kind));
-#if defined(sun)
+#ifdef illumos
vmem_free(state->dts_aggid_arena, (void *)(uintptr_t)aggid, 1);
#else
free_unr(state->dts_aggid_arena, aggid);
@@ -11251,7 +11251,7 @@ dtrace_ecb_action_add(dtrace_ecb_t *ecb, dtrace_actdesc_t *desc)
format = 0;
} else {
ASSERT(arg != 0);
-#if defined(sun)
+#ifdef illumos
ASSERT(arg > KERNELBASE);
#endif
format = dtrace_format_add(state,
@@ -11803,13 +11803,13 @@ static int
dtrace_buffer_alloc(dtrace_buffer_t *bufs, size_t size, int flags,
processorid_t cpu, int *factor)
{
-#if defined(sun)
+#ifdef illumos
cpu_t *cp;
#endif
dtrace_buffer_t *buf;
int allocated = 0, desired = 0;
-#if defined(sun)
+#ifdef illumos
ASSERT(MUTEX_HELD(&cpu_lock));
ASSERT(MUTEX_HELD(&dtrace_lock));
@@ -12680,7 +12680,7 @@ dtrace_enabling_matchall(void)
* block pending our completion.
*/
for (enab = dtrace_retained; enab != NULL; enab = enab->dten_next) {
-#if defined(sun)
+#ifdef illumos
cred_t *cr = enab->dten_vstate->dtvs_state->dts_cred.dcr_cred;
if (INGLOBALZONE(curproc) ||
@@ -12985,7 +12985,7 @@ dtrace_dof_copyin(uintptr_t uarg, int *errp)
return (dof);
}
-#if !defined(sun)
+#ifndef illumos
static __inline uchar_t
dtrace_dof_char(char c) {
switch (c) {
@@ -13028,7 +13028,7 @@ dtrace_dof_property(const char *name)
unsigned int len, i;
dof_hdr_t *dof;
-#if defined(sun)
+#ifdef illumos
/*
* Unfortunately, array of values in .conf files are always (and
* only) interpreted to be integer arrays. We must read our DOF
@@ -13984,7 +13984,7 @@ dtrace_dstate_init(dtrace_dstate_t *dstate, size_t size)
maxper = (limit - (uintptr_t)start) / NCPU;
maxper = (maxper / dstate->dtds_chunksize) * dstate->dtds_chunksize;
-#if !defined(sun)
+#ifndef illumos
CPU_FOREACH(i) {
#else
for (i = 0; i < NCPU; i++) {
@@ -14064,7 +14064,7 @@ dtrace_vstate_fini(dtrace_vstate_t *vstate)
}
}
-#if defined(sun)
+#ifdef illumos
static void
dtrace_state_clean(dtrace_state_t *state)
{
@@ -14101,7 +14101,7 @@ dtrace_state_deadman(dtrace_state_t *state)
dtrace_membar_producer();
state->dts_alive = now;
}
-#else
+#else /* !illumos */
static void
dtrace_state_clean(void *arg)
{
@@ -14150,16 +14150,16 @@ dtrace_state_deadman(void *arg)
callout_reset(&state->dts_deadman, hz * dtrace_deadman_interval / NANOSEC,
dtrace_state_deadman, state);
}
-#endif
+#endif /* illumos */
static dtrace_state_t *
-#if defined(sun)
+#ifdef illumos
dtrace_state_create(dev_t *devp, cred_t *cr)
#else
dtrace_state_create(struct cdev *dev)
#endif
{
-#if defined(sun)
+#ifdef illumos
minor_t minor;
major_t major;
#else
@@ -14174,7 +14174,7 @@ dtrace_state_create(struct cdev *dev)
ASSERT(MUTEX_HELD(&dtrace_lock));
ASSERT(MUTEX_HELD(&cpu_lock));
-#if defined(sun)
+#ifdef illumos
minor = (minor_t)(uintptr_t)vmem_alloc(dtrace_minor, 1,
VM_BESTFIT | VM_SLEEP);
@@ -14197,7 +14197,7 @@ dtrace_state_create(struct cdev *dev)
state->dts_epid = DTRACE_EPIDNONE + 1;
(void) snprintf(c, sizeof (c), "dtrace_aggid_%d", m);
-#if defined(sun)
+#ifdef illumos
state->dts_aggid_arena = vmem_create(c, (void *)1, UINT32_MAX, 1,
NULL, NULL, NULL, 0, VM_SLEEP | VMC_IDENTIFIER);
@@ -14225,7 +14225,7 @@ dtrace_state_create(struct cdev *dev)
state->dts_buffer = kmem_zalloc(bufsize, KM_SLEEP);
state->dts_aggbuffer = kmem_zalloc(bufsize, KM_SLEEP);
-#if defined(sun)
+#ifdef illumos
state->dts_cleaner = CYCLIC_NONE;
state->dts_deadman = CYCLIC_NONE;
#else
@@ -14315,7 +14315,7 @@ dtrace_state_create(struct cdev *dev)
* we can do destructive things to processes which
* have altered credentials.
*/
-#if defined(sun)
+#ifdef illumos
if (priv_isequalset(priv_getset(cr, PRIV_EFFECTIVE),
cr->cr_zone->zone_privset)) {
state->dts_cred.dcr_action |=
@@ -14357,7 +14357,7 @@ dtrace_state_create(struct cdev *dev)
state->dts_cred.dcr_action |=
DTRACE_CRA_PROC_DESTRUCTIVE_ALLZONE;
-#if defined(sun)
+#ifdef illumos
/*
* If we have all privs in whatever zone this is,
* we can do destructive things to processes which
@@ -14516,7 +14516,7 @@ dtrace_state_go(dtrace_state_t *state, processorid_t *cpu)
dtrace_optval_t *opt = state->dts_options, sz, nspec;
dtrace_speculation_t *spec;
dtrace_buffer_t *buf;
-#if defined(sun)
+#ifdef illumos
cyc_handler_t hdlr;
cyc_time_t when;
#endif
@@ -14700,7 +14700,7 @@ dtrace_state_go(dtrace_state_t *state, processorid_t *cpu)
opt[DTRACEOPT_CLEANRATE] = dtrace_cleanrate_max;
state->dts_alive = state->dts_laststatus = dtrace_gethrtime();
-#if defined(sun)
+#ifdef illumos
hdlr.cyh_func = (cyc_func_t)dtrace_state_clean;
hdlr.cyh_arg = state;
hdlr.cyh_level = CY_LOW_LEVEL;
@@ -14727,7 +14727,7 @@ dtrace_state_go(dtrace_state_t *state, processorid_t *cpu)
state->dts_activity = DTRACE_ACTIVITY_WARMUP;
-#if defined(sun)
+#ifdef illumos
if (state->dts_getf != 0 &&
!(state->dts_cred.dcr_visible & DTRACE_CRV_KERNEL)) {
/*
@@ -14861,7 +14861,7 @@ dtrace_state_stop(dtrace_state_t *state, processorid_t *cpu)
state->dts_activity = DTRACE_ACTIVITY_STOPPED;
dtrace_sync();
-#if defined(sun)
+#ifdef illumos
if (state->dts_getf != 0 &&
!(state->dts_cred.dcr_visible & DTRACE_CRV_KERNEL)) {
/*
@@ -14944,7 +14944,7 @@ dtrace_state_destroy(dtrace_state_t *state)
{
dtrace_ecb_t *ecb;
dtrace_vstate_t *vstate = &state->dts_vstate;
-#if defined(sun)
+#ifdef illumos
minor_t minor = getminor(state->dts_dev);
#endif
int i, bufsize = NCPU * sizeof (dtrace_buffer_t);
@@ -15022,7 +15022,7 @@ dtrace_state_destroy(dtrace_state_t *state)
for (i = 0; i < nspec; i++)
dtrace_buffer_free(spec[i].dtsp_buffer);
-#if defined(sun)
+#ifdef illumos
if (state->dts_cleaner != CYCLIC_NONE)
cyclic_remove(state->dts_cleaner);
@@ -15062,14 +15062,14 @@ dtrace_state_destroy(dtrace_state_t *state)
dtrace_format_destroy(state);
if (state->dts_aggid_arena != NULL) {
-#if defined(sun)
+#ifdef illumos
vmem_destroy(state->dts_aggid_arena);
#else
delete_unrhdr(state->dts_aggid_arena);
#endif
state->dts_aggid_arena = NULL;
}
-#if defined(sun)
+#ifdef illumos
ddi_soft_state_free(dtrace_softstate, minor);
vmem_free(dtrace_minor, (void *)(uintptr_t)minor, 1);
#endif
@@ -15121,7 +15121,7 @@ dtrace_anon_property(void)
break;
}
-#if defined(sun)
+#ifdef illumos
/*
* We want to create anonymous state, so we need to transition
* the kernel debugger to indicate that DTrace is active. If
@@ -15140,7 +15140,7 @@ dtrace_anon_property(void)
* If we haven't allocated an anonymous state, we'll do so now.
*/
if ((state = dtrace_anon.dta_state) == NULL) {
-#if defined(sun)
+#ifdef illumos
state = dtrace_state_create(NULL, NULL);
#else
state = dtrace_state_create(NULL);
@@ -16031,7 +16031,7 @@ dtrace_helpers_create(proc_t *p)
return (help);
}
-#if defined(sun)
+#ifdef illumos
static
#endif
void
@@ -16039,7 +16039,7 @@ dtrace_helpers_destroy(proc_t *p)
{
dtrace_helpers_t *help;
dtrace_vstate_t *vstate;
-#if defined(sun)
+#ifdef illumos
proc_t *p = curproc;
#endif
int i;
@@ -16128,7 +16128,7 @@ dtrace_helpers_destroy(proc_t *p)
mutex_exit(&dtrace_lock);
}
-#if defined(sun)
+#ifdef illumos
static
#endif
void
@@ -16222,11 +16222,11 @@ dtrace_module_loaded(modctl_t *ctl)
dtrace_provider_t *prv;
mutex_enter(&dtrace_provider_lock);
-#if defined(sun)
+#ifdef illumos
mutex_enter(&mod_lock);
#endif
-#if defined(sun)
+#ifdef illumos
ASSERT(ctl->mod_busy);
#endif
@@ -16237,7 +16237,7 @@ dtrace_module_loaded(modctl_t *ctl)
for (prv = dtrace_provider; prv != NULL; prv = prv->dtpv_next)
prv->dtpv_pops.dtps_provide_module(prv->dtpv_arg, ctl);
-#if defined(sun)
+#ifdef illumos
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_provider_lock);
@@ -16276,7 +16276,7 @@ dtrace_module_loaded(modctl_t *ctl)
}
static void
-#if defined(sun)
+#ifdef illumos
dtrace_module_unloaded(modctl_t *ctl)
#else
dtrace_module_unloaded(modctl_t *ctl, int *error)
@@ -16284,12 +16284,12 @@ dtrace_module_unloaded(modctl_t *ctl, int *error)
{
dtrace_probe_t template, *probe, *first, *next;
dtrace_provider_t *prov;
-#if !defined(sun)
+#ifndef illumos
char modname[DTRACE_MODNAMELEN];
size_t len;
#endif
-#if defined(sun)
+#ifdef illumos
template.dtpr_mod = ctl->mod_modname;
#else
/* Handle the fact that ctl->filename may end in ".ko". */
@@ -16301,12 +16301,12 @@ dtrace_module_unloaded(modctl_t *ctl, int *error)
#endif
mutex_enter(&dtrace_provider_lock);
-#if defined(sun)
+#ifdef illumos
mutex_enter(&mod_lock);
#endif
mutex_enter(&dtrace_lock);
-#if !defined(sun)
+#ifndef illumos
if (ctl->nenabled > 0) {
/* Don't allow unloads if a probe is enabled. */
mutex_exit(&dtrace_provider_lock);
@@ -16324,7 +16324,7 @@ dtrace_module_unloaded(modctl_t *ctl, int *error)
* we don't have any work to do.
*/
mutex_exit(&dtrace_provider_lock);
-#if defined(sun)
+#ifdef illumos
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_lock);
@@ -16335,7 +16335,7 @@ dtrace_module_unloaded(modctl_t *ctl, int *error)
probe != NULL; probe = probe->dtpr_nextmod) {
if (probe->dtpr_ecb != NULL) {
mutex_exit(&dtrace_provider_lock);
-#if defined(sun)
+#ifdef illumos
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_lock);
@@ -16351,7 +16351,7 @@ dtrace_module_unloaded(modctl_t *ctl, int *error)
* probe, either.
*/
if (dtrace_err_verbose) {
-#if defined(sun)
+#ifdef illumos
cmn_err(CE_WARN, "unloaded module '%s' had "
"enabled probes", ctl->mod_modname);
#else
@@ -16400,7 +16400,7 @@ dtrace_module_unloaded(modctl_t *ctl, int *error)
kmem_free(probe->dtpr_mod, strlen(probe->dtpr_mod) + 1);
kmem_free(probe->dtpr_func, strlen(probe->dtpr_func) + 1);
kmem_free(probe->dtpr_name, strlen(probe->dtpr_name) + 1);
-#if defined(sun)
+#ifdef illumos
vmem_free(dtrace_arena, (void *)(uintptr_t)probe->dtpr_id, 1);
#else
free_unr(dtrace_arena, probe->dtpr_id);
@@ -16409,13 +16409,13 @@ dtrace_module_unloaded(modctl_t *ctl, int *error)
}
mutex_exit(&dtrace_lock);
-#if defined(sun)
+#ifdef illumos
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_provider_lock);
}
-#if !defined(sun)
+#ifndef illumos
static void
dtrace_kld_load(void *arg __unused, linker_file_t lf)
{
@@ -16434,7 +16434,7 @@ dtrace_kld_unload_try(void *arg __unused, linker_file_t lf, int *error)
}
#endif
-#if defined(sun)
+#ifdef illumos
static void
dtrace_suspend(void)
{
@@ -16507,7 +16507,7 @@ dtrace_cpu_setup(cpu_setup_t what, processorid_t cpu)
return (0);
}
-#if defined(sun)
+#ifdef illumos
static void
dtrace_cpu_setup_initial(processorid_t cpu)
{
@@ -16555,7 +16555,7 @@ dtrace_toxrange_add(uintptr_t base, uintptr_t limit)
static void
dtrace_getf_barrier()
{
-#if defined(sun)
+#ifdef illumos
/*
* When we have unprivileged (that is, non-DTRACE_CRV_KERNEL) enablings
* that contain calls to getf(), this routine will be called on every
@@ -16574,7 +16574,7 @@ dtrace_getf_barrier()
/*
* DTrace Driver Cookbook Functions
*/
-#if defined(sun)
+#ifdef illumos
/*ARGSUSED*/
static int
dtrace_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
@@ -16730,15 +16730,15 @@ dtrace_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
return (DDI_SUCCESS);
}
-#endif
+#endif /* illumos */
-#if !defined(sun)
+#ifndef illumos
static void dtrace_dtr(void *);
#endif
/*ARGSUSED*/
static int
-#if defined(sun)
+#ifdef illumos
dtrace_open(dev_t *devp, int flag, int otyp, cred_t *cred_p)
#else
dtrace_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
@@ -16749,7 +16749,7 @@ dtrace_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
uid_t uid;
zoneid_t zoneid;
-#if defined(sun)
+#ifdef illumos
if (getminor(*devp) == DTRACEMNRN_HELPER)
return (0);
@@ -16786,7 +16786,7 @@ dtrace_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
dtrace_opens++;
dtrace_membar_producer();
-#if defined(sun)
+#ifdef illumos
/*
* If the kernel debugger is active (that is, if the kernel debugger
* modified text in some way), we won't allow the open.
@@ -16819,7 +16819,7 @@ dtrace_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
mutex_exit(&cpu_lock);
if (state == NULL) {
-#if defined(sun)
+#ifdef illumos
if (--dtrace_opens == 0 && dtrace_anon.dta_enabling == NULL)
(void) kdi_dtrace_set(KDI_DTSET_DTRACE_DEACTIVATE);
#else
@@ -16835,7 +16835,7 @@ dtrace_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
}
/*ARGSUSED*/
-#if defined(sun)
+#ifdef illumos
static int
dtrace_close(dev_t dev, int flag, int otyp, cred_t *cred_p)
#else
@@ -16843,7 +16843,7 @@ static void
dtrace_dtr(void *data)
#endif
{
-#if defined(sun)
+#ifdef illumos
minor_t minor = getminor(dev);
dtrace_state_t *state;
#endif
@@ -16896,7 +16896,7 @@ dtrace_dtr(void *data)
#endif
ASSERT(dtrace_opens > 0);
-#if defined(sun)
+#ifdef illumos
/*
* Only relinquish control of the kernel debugger interface when there
* are no consumers and no anonymous enablings.
@@ -16915,12 +16915,12 @@ dtrace_dtr(void *data)
mutex_exit(&dtrace_lock);
mutex_exit(&cpu_lock);
-#if defined(sun)
+#ifdef illumos
return (0);
#endif
}
-#if defined(sun)
+#ifdef illumos
/*ARGSUSED*/
static int
dtrace_ioctl_helper(int cmd, intptr_t arg, int *rv)
@@ -17859,7 +17859,7 @@ dtrace_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
}
#endif
-#if defined(sun)
+#ifdef illumos
/*ARGSUSED*/
static int
dtrace_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
@@ -17882,7 +17882,7 @@ dtrace_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
}
#endif
-#if defined(sun)
+#ifdef illumos
static struct cb_ops dtrace_cb_ops = {
dtrace_open, /* open */
dtrace_close, /* close */
diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
index 19fb43c..84b72d2 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
@@ -38,13 +38,13 @@
#include <sys/modctl.h>
#include <sys/conf.h>
#include <sys/systm.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/ddi.h>
#endif
#include <sys/sunddi.h>
#include <sys/cpuvar.h>
#include <sys/kmem.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/strsubr.h>
#endif
#include <sys/fasttrap.h>
@@ -55,12 +55,12 @@
#include <sys/sysmacros.h>
#include <sys/proc.h>
#include <sys/policy.h>
-#if defined(sun)
+#ifdef illumos
#include <util/qsort.h>
#endif
#include <sys/mutex.h>
#include <sys/kernel.h>
-#if !defined(sun)
+#ifndef illumos
#include <sys/dtrace_bsd.h>
#include <sys/eventhandler.h>
#include <sys/sysctl.h>
@@ -215,7 +215,7 @@ static void fasttrap_provider_free(fasttrap_provider_t *);
static fasttrap_proc_t *fasttrap_proc_lookup(pid_t);
static void fasttrap_proc_release(fasttrap_proc_t *);
-#if !defined(sun)
+#ifndef illumos
static void fasttrap_thread_dtor(void *, struct thread *);
#endif
@@ -224,7 +224,7 @@ static void fasttrap_thread_dtor(void *, struct thread *);
#define FASTTRAP_PROCS_INDEX(pid) ((pid) & fasttrap_procs.fth_mask)
-#if !defined(sun)
+#ifndef illumos
static kmutex_t fasttrap_cpuc_pid_lock[MAXCPU];
static eventhandler_tag fasttrap_thread_dtor_tag;
#endif
@@ -288,7 +288,7 @@ fasttrap_hash_str(const char *p)
void
fasttrap_sigtrap(proc_t *p, kthread_t *t, uintptr_t pc)
{
-#if defined(sun)
+#ifdef illumos
sigqueue_t *sqp = kmem_zalloc(sizeof (sigqueue_t), KM_SLEEP);
sqp->sq_info.si_signo = SIGTRAP;
@@ -314,7 +314,7 @@ fasttrap_sigtrap(proc_t *p, kthread_t *t, uintptr_t pc)
#endif
}
-#if !defined(sun)
+#ifndef illumos
/*
* Obtain a chunk of scratch space in the address space of the target process.
*/
@@ -586,20 +586,20 @@ fasttrap_pid_cleanup(void)
static void
fasttrap_fork(proc_t *p, proc_t *cp)
{
-#if !defined(sun)
+#ifndef illumos
fasttrap_scrblock_t *scrblk;
fasttrap_proc_t *fprc = NULL;
#endif
pid_t ppid = p->p_pid;
int i;
-#if defined(sun)
+#ifdef illumos
ASSERT(curproc == p);
ASSERT(p->p_proc_flag & P_PR_LOCK);
#else
PROC_LOCK_ASSERT(p, MA_OWNED);
#endif
-#if defined(sun)
+#ifdef illumos
ASSERT(p->p_dtrace_count > 0);
#else
if (p->p_dtrace_helpers) {
@@ -638,7 +638,7 @@ fasttrap_fork(proc_t *p, proc_t *cp)
* We don't have to worry about the child process disappearing
* because we're in fork().
*/
-#if defined(sun)
+#ifdef illumos
mtx_lock_spin(&cp->p_slock);
sprlock_proc(cp);
mtx_unlock_spin(&cp->p_slock);
@@ -675,14 +675,14 @@ fasttrap_fork(proc_t *p, proc_t *cp)
* mid-fork.
*/
ASSERT(tp->ftt_proc->ftpc_acount != 0);
-#if !defined(sun)
+#ifndef illumos
fprc = tp->ftt_proc;
#endif
}
}
mutex_exit(&bucket->ftb_mtx);
-#if !defined(sun)
+#ifndef illumos
/*
* Unmap any scratch space inherited from the parent's address
* space.
@@ -699,7 +699,7 @@ fasttrap_fork(proc_t *p, proc_t *cp)
#endif
}
-#if defined(sun)
+#ifdef illumos
mutex_enter(&cp->p_lock);
sprunlock(cp);
#else
@@ -717,11 +717,11 @@ fasttrap_fork(proc_t *p, proc_t *cp)
static void
fasttrap_exec_exit(proc_t *p)
{
-#if !defined(sun)
+#ifndef illumos
struct thread *td;
#endif
-#if defined(sun)
+#ifdef illumos
ASSERT(p == curproc);
#else
PROC_LOCK_ASSERT(p, MA_OWNED);
@@ -741,7 +741,7 @@ fasttrap_exec_exit(proc_t *p)
* static probes are handled by the meta-provider remove entry point.
*/
fasttrap_provider_retire(p->p_pid, FASTTRAP_PID_NAME, 0);
-#if !defined(sun)
+#ifndef illumos
if (p->p_dtrace_helpers)
dtrace_helpers_destroy(p);
PROC_LOCK(p);
@@ -776,7 +776,7 @@ fasttrap_tracepoint_enable(proc_t *p, fasttrap_probe_t *probe, uint_t index)
ASSERT(probe->ftp_tps[index].fit_tp->ftt_pid == pid);
-#if defined(sun)
+#ifdef illumos
ASSERT(!(p->p_flag & SVFORK));
#endif
@@ -884,7 +884,7 @@ again:
* Increment the count of the number of tracepoints active in
* the victim process.
*/
-#if defined(sun)
+#ifdef illumos
ASSERT(p->p_proc_flag & P_PR_LOCK);
#endif
p->p_dtrace_count++;
@@ -1076,7 +1076,7 @@ fasttrap_tracepoint_disable(proc_t *p, fasttrap_probe_t *probe, uint_t index)
* Decrement the count of the number of tracepoints active
* in the victim process.
*/
-#if defined(sun)
+#ifdef illumos
ASSERT(p->p_proc_flag & P_PR_LOCK);
#endif
p->p_dtrace_count--;
@@ -1129,7 +1129,7 @@ fasttrap_enable_callbacks(void)
static void
fasttrap_disable_callbacks(void)
{
-#if defined(sun)
+#ifdef illumos
ASSERT(MUTEX_HELD(&cpu_lock));
#endif
@@ -1138,7 +1138,7 @@ fasttrap_disable_callbacks(void)
ASSERT(fasttrap_pid_count > 0);
fasttrap_pid_count--;
if (fasttrap_pid_count == 0) {
-#if defined(sun)
+#ifdef illumos
cpu_t *cur, *cpu = CPU;
for (cur = cpu->cpu_next_onln; cur != cpu;
@@ -1148,7 +1148,7 @@ fasttrap_disable_callbacks(void)
#endif
dtrace_pid_probe_ptr = NULL;
dtrace_return_probe_ptr = NULL;
-#if defined(sun)
+#ifdef illumos
for (cur = cpu->cpu_next_onln; cur != cpu;
cur = cur->cpu_next_onln) {
rw_exit(&cur->cpu_ft_lock);
@@ -1169,7 +1169,7 @@ fasttrap_pid_enable(void *arg, dtrace_id_t id, void *parg)
ASSERT(probe != NULL);
ASSERT(!probe->ftp_enabled);
ASSERT(id == probe->ftp_id);
-#if defined(sun)
+#ifdef illumos
ASSERT(MUTEX_HELD(&cpu_lock));
#endif
@@ -1196,7 +1196,7 @@ fasttrap_pid_enable(void *arg, dtrace_id_t id, void *parg)
* a fork in which the traced process is being born and we're copying
* USDT probes. Otherwise, the process is gone so bail.
*/
-#if defined(sun)
+#ifdef illumos
if ((p = sprlock(probe->ftp_pid)) == NULL) {
if ((curproc->p_flag & SFORKING) == 0)
return;
@@ -1264,7 +1264,7 @@ fasttrap_pid_enable(void *arg, dtrace_id_t id, void *parg)
i--;
}
-#if defined(sun)
+#ifdef illumos
mutex_enter(&p->p_lock);
sprunlock(p);
#else
@@ -1279,7 +1279,7 @@ fasttrap_pid_enable(void *arg, dtrace_id_t id, void *parg)
return;
}
}
-#if defined(sun)
+#ifdef illumos
mutex_enter(&p->p_lock);
sprunlock(p);
#else
@@ -1363,7 +1363,7 @@ fasttrap_pid_disable(void *arg, dtrace_id_t id, void *parg)
probe->ftp_enabled = 0;
-#if defined(sun)
+#ifdef illumos
ASSERT(MUTEX_HELD(&cpu_lock));
#endif
fasttrap_disable_callbacks();
@@ -1504,7 +1504,7 @@ fasttrap_proc_lookup(pid_t pid)
new_fprc->ftpc_pid = pid;
new_fprc->ftpc_rcount = 1;
new_fprc->ftpc_acount = 1;
-#if !defined(sun)
+#ifndef illumos
mutex_init(&new_fprc->ftpc_mtx, "fasttrap proc mtx", MUTEX_DEFAULT,
NULL);
#endif
@@ -1544,7 +1544,7 @@ fasttrap_proc_release(fasttrap_proc_t *proc)
fasttrap_bucket_t *bucket;
fasttrap_proc_t *fprc, **fprcp;
pid_t pid = proc->ftpc_pid;
-#if !defined(sun)
+#ifndef illumos
fasttrap_scrblock_t *scrblk, *scrblktmp;
fasttrap_scrspace_t *scrspc, *scrspctmp;
struct proc *p;
@@ -1561,7 +1561,7 @@ fasttrap_proc_release(fasttrap_proc_t *proc)
return;
}
-#if !defined(sun)
+#ifndef illumos
/*
* Free all structures used to manage per-thread scratch space.
*/
@@ -1683,7 +1683,7 @@ fasttrap_provider_lookup(pid_t pid, const char *name,
new_fp = kmem_zalloc(sizeof (fasttrap_provider_t), KM_SLEEP);
new_fp->ftp_pid = pid;
new_fp->ftp_proc = fasttrap_proc_lookup(pid);
-#if !defined(sun)
+#ifndef illumos
mutex_init(&new_fp->ftp_mtx, "provider mtx", MUTEX_DEFAULT, NULL);
mutex_init(&new_fp->ftp_cmtx, "lock on creating", MUTEX_DEFAULT, NULL);
#endif
@@ -1764,7 +1764,7 @@ fasttrap_provider_free(fasttrap_provider_t *provider)
fasttrap_proc_release(provider->ftp_proc);
-#if !defined(sun)
+#ifndef illumos
mutex_destroy(&provider->ftp_mtx);
mutex_destroy(&provider->ftp_cmtx);
#endif
@@ -1782,7 +1782,7 @@ fasttrap_provider_free(fasttrap_provider_t *provider)
}
p->p_dtrace_probes--;
-#if !defined(sun)
+#ifndef illumos
PROC_UNLOCK(p);
#endif
}
@@ -2323,7 +2323,7 @@ fasttrap_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int fflag,
proc_t *p;
pid_t pid = probe->ftps_pid;
-#if defined(sun)
+#ifdef illumos
mutex_enter(&pidlock);
#endif
/*
@@ -2334,12 +2334,12 @@ fasttrap_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int fflag,
if (p)
fill_kinfo_proc(p, &kp);
if (p == NULL || kp.ki_stat == SIDL) {
-#if defined(sun)
+#ifdef illumos
mutex_exit(&pidlock);
#endif
return (ESRCH);
}
-#if defined(sun)
+#ifdef illumos
mutex_enter(&p->p_lock);
mutex_exit(&pidlock);
#else
@@ -2349,7 +2349,7 @@ fasttrap_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int fflag,
#ifdef notyet
if ((ret = priv_proc_cred_perm(cr, p, NULL,
VREAD | VWRITE)) != 0) {
-#if defined(sun)
+#ifdef illumos
mutex_exit(&p->p_lock);
#else
PROC_UNLOCK(p);
@@ -2357,7 +2357,7 @@ fasttrap_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int fflag,
return (ret);
}
#endif /* notyet */
-#if defined(sun)
+#ifdef illumos
mutex_exit(&p->p_lock);
#else
PROC_UNLOCK(p);
@@ -2375,11 +2375,11 @@ err:
fasttrap_instr_query_t instr;
fasttrap_tracepoint_t *tp;
uint_t index;
-#if defined(sun)
+#ifdef illumos
int ret;
#endif
-#if defined(sun)
+#ifdef illumos
if (copyin((void *)arg, &instr, sizeof (instr)) != 0)
return (EFAULT);
#endif
@@ -2389,7 +2389,7 @@ err:
proc_t *p;
pid_t pid = instr.ftiq_pid;
-#if defined(sun)
+#ifdef illumos
mutex_enter(&pidlock);
#endif
/*
@@ -2400,12 +2400,12 @@ err:
if (p)
fill_kinfo_proc(p, &kp);
if (p == NULL || kp.ki_stat == SIDL) {
-#if defined(sun)
+#ifdef illumos
mutex_exit(&pidlock);
#endif
return (ESRCH);
}
-#if defined(sun)
+#ifdef illumos
mutex_enter(&p->p_lock);
mutex_exit(&pidlock);
#else
@@ -2415,7 +2415,7 @@ err:
#ifdef notyet
if ((ret = priv_proc_cred_perm(cr, p, NULL,
VREAD)) != 0) {
-#if defined(sun)
+#ifdef illumos
mutex_exit(&p->p_lock);
#else
PROC_UNLOCK(p);
@@ -2424,7 +2424,7 @@ err:
}
#endif /* notyet */
-#if defined(sun)
+#ifdef illumos
mutex_exit(&p->p_lock);
#else
PROC_UNLOCK(p);
@@ -2477,7 +2477,7 @@ fasttrap_load(void)
mutex_init(&fasttrap_count_mtx, "fasttrap count mtx", MUTEX_DEFAULT,
NULL);
-#if defined(sun)
+#ifdef illumos
fasttrap_max = ddi_getprop(DDI_DEV_T_ANY, devi, DDI_PROP_DONTPASS,
"fasttrap-max-probes", FASTTRAP_MAX_DEFAULT);
#endif
@@ -2486,7 +2486,7 @@ fasttrap_load(void)
/*
* Conjure up the tracepoints hashtable...
*/
-#if defined(sun)
+#ifdef illumos
nent = ddi_getprop(DDI_DEV_T_ANY, devi, DDI_PROP_DONTPASS,
"fasttrap-hash-size", FASTTRAP_TPOINTS_DEFAULT_SIZE);
#else
@@ -2506,7 +2506,7 @@ fasttrap_load(void)
fasttrap_tpoints.fth_mask = fasttrap_tpoints.fth_nent - 1;
fasttrap_tpoints.fth_table = kmem_zalloc(fasttrap_tpoints.fth_nent *
sizeof (fasttrap_bucket_t), KM_SLEEP);
-#if !defined(sun)
+#ifndef illumos
for (i = 0; i < fasttrap_tpoints.fth_nent; i++)
mutex_init(&fasttrap_tpoints.fth_table[i].ftb_mtx,
"tracepoints bucket mtx", MUTEX_DEFAULT, NULL);
@@ -2524,7 +2524,7 @@ fasttrap_load(void)
fasttrap_provs.fth_mask = fasttrap_provs.fth_nent - 1;
fasttrap_provs.fth_table = kmem_zalloc(fasttrap_provs.fth_nent *
sizeof (fasttrap_bucket_t), KM_SLEEP);
-#if !defined(sun)
+#ifndef illumos
for (i = 0; i < fasttrap_provs.fth_nent; i++)
mutex_init(&fasttrap_provs.fth_table[i].ftb_mtx,
"providers bucket mtx", MUTEX_DEFAULT, NULL);
@@ -2534,7 +2534,7 @@ fasttrap_load(void)
&fasttrap_cleanup_proc, 0, 0, "ftcleanup");
if (ret != 0) {
destroy_dev(fasttrap_cdev);
-#if !defined(sun)
+#ifndef illumos
for (i = 0; i < fasttrap_provs.fth_nent; i++)
mutex_destroy(&fasttrap_provs.fth_table[i].ftb_mtx);
for (i = 0; i < fasttrap_tpoints.fth_nent; i++)
@@ -2560,7 +2560,7 @@ fasttrap_load(void)
fasttrap_procs.fth_mask = fasttrap_procs.fth_nent - 1;
fasttrap_procs.fth_table = kmem_zalloc(fasttrap_procs.fth_nent *
sizeof (fasttrap_bucket_t), KM_SLEEP);
-#if !defined(sun)
+#ifndef illumos
for (i = 0; i < fasttrap_procs.fth_nent; i++)
mutex_init(&fasttrap_procs.fth_table[i].ftb_mtx,
"processes bucket mtx", MUTEX_DEFAULT, NULL);
@@ -2676,7 +2676,7 @@ fasttrap_unload(void)
mutex_exit(&fasttrap_count_mtx);
#endif
-#if !defined(sun)
+#ifndef illumos
EVENTHANDLER_DEREGISTER(thread_dtor, fasttrap_thread_dtor_tag);
for (i = 0; i < fasttrap_tpoints.fth_nent; i++)
@@ -2698,7 +2698,7 @@ fasttrap_unload(void)
fasttrap_procs.fth_nent * sizeof (fasttrap_bucket_t));
fasttrap_procs.fth_nent = 0;
-#if !defined(sun)
+#ifndef illumos
destroy_dev(fasttrap_cdev);
mutex_destroy(&fasttrap_count_mtx);
CPU_FOREACH(i) {
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c b/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c
index 4bcdfc6..2ff8df6 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c
@@ -107,7 +107,7 @@
* gfs_root_create_file()
*/
-#ifdef sun
+#ifdef illumos
/*
* gfs_make_opsvec: take an array of vnode type definitions and create
* their vnodeops_t structures
@@ -141,7 +141,7 @@ gfs_make_opsvec(gfs_opsvec_t *vec)
}
return (error);
}
-#endif /* sun */
+#endif /* illumos */
/*
* Low level directory routines
@@ -347,7 +347,7 @@ gfs_readdir_emit(gfs_readdir_state_t *st, uio_t *uiop, offset_t voff,
cookies));
}
-#ifdef sun
+#ifdef illumos
/*
* gfs_readdir_emitn: like gfs_readdir_emit(), but takes an integer
* instead of a string for the entry's name.
@@ -599,7 +599,7 @@ gfs_root_create(size_t size, vfs_t *vfsp, vnodeops_t *ops, ino64_t ino,
return (vp);
}
-#ifdef sun
+#ifdef illumos
/*
* gfs_root_create_file(): create a root vnode for a GFS file as a filesystem
*
@@ -619,7 +619,7 @@ gfs_root_create_file(size_t size, vfs_t *vfsp, vnodeops_t *ops, ino64_t ino)
return (vp);
}
-#endif /* sun */
+#endif /* illumos */
/*
* gfs_file_inactive()
@@ -1146,7 +1146,7 @@ gfs_vop_readdir(ap)
}
-#ifdef sun
+#ifdef illumos
/*
* gfs_vop_map: VOP_MAP() entry point
*
@@ -1218,7 +1218,7 @@ gfs_vop_map(vnode_t *vp, offset_t off, struct as *as, caddr_t *addrp,
return (rv);
}
-#endif /* sun */
+#endif /* illumos */
/*
* gfs_vop_reclaim: VOP_RECLAIM() entry point (solaris' VOP_INACTIVE())
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
index 29ef565..6d99a79 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
@@ -1610,7 +1610,7 @@ arc_cksum_compute(arc_buf_t *buf, boolean_t force)
mutex_exit(&buf->b_hdr->b_l1hdr.b_freeze_lock);
#ifdef illumos
arc_buf_watch(buf);
-#endif /* illumos */
+#endif
}
#ifdef illumos
@@ -1713,7 +1713,7 @@ arc_buf_thaw(arc_buf_t *buf)
#ifdef illumos
arc_buf_unwatch(buf);
-#endif /* illumos */
+#endif
}
void
@@ -2287,7 +2287,7 @@ arc_buf_destroy(arc_buf_t *buf, boolean_t remove)
arc_cksum_verify(buf);
#ifdef illumos
arc_buf_unwatch(buf);
-#endif /* illumos */
+#endif
if (type == ARC_BUFC_METADATA) {
arc_buf_data_free(buf, zio_buf_free);
@@ -3412,7 +3412,7 @@ arc_available_memory(void)
r = FMR_LOTSFREE;
}
-#ifdef sun
+#ifdef illumos
/*
* check that we're out of range of the pageout scanner. It starts to
* schedule paging if freemem is less than lotsfree and needfree.
@@ -3455,7 +3455,7 @@ arc_available_memory(void)
r = FMR_PAGES_PP_MAXIMUM;
}
-#endif /* sun */
+#endif /* illumos */
#if defined(__i386) || !defined(UMA_MD_SMALL_ALLOC)
/*
* If we're on an i386 platform, it's possible that we'll exhaust the
@@ -3578,7 +3578,7 @@ arc_kmem_reap_now(void)
kmem_cache_reap_now(hdr_l2only_cache);
kmem_cache_reap_now(range_seg_cache);
-#ifdef sun
+#ifdef illumos
if (zio_arena != NULL) {
/*
* Ask the vmem arena to reclaim unused memory from its
@@ -3609,7 +3609,7 @@ arc_kmem_reap_now(void)
static void
arc_reclaim_thread(void *dummy __unused)
{
- clock_t growtime = 0;
+ hrtime_t growtime = 0;
callb_cpr_t cpr;
CALLB_CPR_INIT(&cpr, &arc_reclaim_lock, callb_generic_cpr, FTAG);
@@ -3630,7 +3630,7 @@ arc_reclaim_thread(void *dummy __unused)
* Wait at least zfs_grow_retry (default 60) seconds
* before considering growing.
*/
- growtime = ddi_get_lbolt() + (arc_grow_retry * hz);
+ growtime = gethrtime() + SEC2NSEC(arc_grow_retry);
arc_kmem_reap_now();
@@ -3650,7 +3650,7 @@ arc_reclaim_thread(void *dummy __unused)
}
} else if (free_memory < arc_c >> arc_no_grow_shift) {
arc_no_grow = B_TRUE;
- } else if (ddi_get_lbolt() >= growtime) {
+ } else if (gethrtime() >= growtime) {
arc_no_grow = B_FALSE;
}
@@ -3684,8 +3684,8 @@ arc_reclaim_thread(void *dummy __unused)
* even if we aren't being signalled)
*/
CALLB_CPR_SAFE_BEGIN(&cpr);
- (void) cv_timedwait(&arc_reclaim_thread_cv,
- &arc_reclaim_lock, hz);
+ (void) cv_timedwait_hires(&arc_reclaim_thread_cv,
+ &arc_reclaim_lock, SEC2NSEC(1), MSEC2NSEC(1), 0);
CALLB_CPR_SAFE_END(&cpr, &arc_reclaim_lock);
}
}
@@ -4140,7 +4140,7 @@ arc_read_done(zio_t *zio)
arc_cksum_compute(buf, B_FALSE);
#ifdef illumos
arc_buf_watch(buf);
-#endif /* illumos */
+#endif
if (hash_lock && zio->io_error == 0 &&
hdr->b_l1hdr.b_state == arc_anon) {
@@ -4849,7 +4849,7 @@ arc_release(arc_buf_t *buf, void *tag)
arc_cksum_verify(buf);
#ifdef illumos
arc_buf_unwatch(buf);
-#endif /* illumos */
+#endif
mutex_exit(hash_lock);
@@ -5291,7 +5291,7 @@ arc_init(void)
/* Start out with 1/8 of all memory */
arc_c = kmem_size() / 8;
-#ifdef sun
+#ifdef illumos
#ifdef _KERNEL
/*
* On architectures where the physical memory can be larger
@@ -5300,7 +5300,7 @@ arc_init(void)
*/
arc_c = MIN(arc_c, vmem_size(heap_arena, VMEM_ALLOC | VMEM_FREE) / 8);
#endif
-#endif /* sun */
+#endif /* illumos */
/* set min cache to 1/32 of all memory, or 16MB, whichever is more */
arc_c_min = MAX(arc_c / 4, 16 << 20);
/* set max to 1/2 of all memory, or all but 1GB, whichever is more */
@@ -5570,10 +5570,12 @@ arc_fini(void)
multilist_destroy(&arc_mru_ghost->arcs_list[ARC_BUFC_METADATA]);
multilist_destroy(&arc_mfu->arcs_list[ARC_BUFC_METADATA]);
multilist_destroy(&arc_mfu_ghost->arcs_list[ARC_BUFC_METADATA]);
+ multilist_destroy(&arc_l2c_only->arcs_list[ARC_BUFC_METADATA]);
multilist_destroy(&arc_mru->arcs_list[ARC_BUFC_DATA]);
multilist_destroy(&arc_mru_ghost->arcs_list[ARC_BUFC_DATA]);
multilist_destroy(&arc_mfu->arcs_list[ARC_BUFC_DATA]);
multilist_destroy(&arc_mfu_ghost->arcs_list[ARC_BUFC_DATA]);
+ multilist_destroy(&arc_l2c_only->arcs_list[ARC_BUFC_DATA]);
buf_fini();
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bpobj.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bpobj.c
index 7d20096..c706a38 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bpobj.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bpobj.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/bpobj.h>
@@ -300,8 +301,10 @@ bpobj_iterate_impl(bpobj_t *bpo, bpobj_itor_t func, void *arg, dmu_tx_t *tx,
if (free) {
err = bpobj_space(&sublist,
&used_before, &comp_before, &uncomp_before);
- if (err)
+ if (err != 0) {
+ bpobj_close(&sublist);
break;
+ }
}
err = bpobj_iterate_impl(&sublist, func, arg, tx, free);
if (free) {
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bptree.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bptree.c
index b2b9887..a69fcc3 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bptree.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bptree.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/arc.h>
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
index f39a353..8b70cf5 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
@@ -25,6 +25,7 @@
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/zfs_context.h>
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c
index 93a0426..6aa6327 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c
@@ -1253,7 +1253,7 @@ dmu_write_uio(objset_t *os, uint64_t object, uio_t *uio, uint64_t size,
return (err);
}
-#ifdef sun
+#ifdef illumos
int
dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
page_t *pp, dmu_tx_t *tx)
@@ -1309,7 +1309,7 @@ dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
return (err);
}
-#else
+#else /* !illumos */
int
dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
@@ -1366,8 +1366,8 @@ dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
dmu_buf_rele_array(dbp, numbufs, FTAG);
return (err);
}
-#endif /* sun */
-#endif
+#endif /* illumos */
+#endif /* _KERNEL */
/*
* Allocate a loaned anonymous arc buffer.
@@ -1421,6 +1421,9 @@ dmu_assign_arcbuf(dmu_buf_t *handle, uint64_t offset, arc_buf_t *buf,
*/
if (offset == db->db.db_offset && blksz == db->db.db_size &&
DBUF_GET_BUFC_TYPE(db) == ARC_BUFC_DATA) {
+#ifdef _KERNEL
+ curthread->td_ru.ru_oublock++;
+#endif
dbuf_assign_arcbuf(db, buf, tx);
dbuf_rele(db, FTAG);
} else {
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c
index 79de1d1..367dbcb 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c
@@ -26,6 +26,7 @@
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2015, STRATO AG, Inc. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
/* Portions Copyright 2010 Robert Milkowski */
@@ -1789,6 +1790,7 @@ dmu_objset_find_dp(dsl_pool_t *dp, uint64_t ddobj,
* thread suffices. For now, stay single threaded.
*/
dmu_objset_find_dp_impl(dcp);
+ mutex_destroy(&err_lock);
return (error);
}
@@ -1800,6 +1802,8 @@ dmu_objset_find_dp(dsl_pool_t *dp, uint64_t ddobj,
INT_MAX, 0);
if (tq == NULL) {
kmem_free(dcp, sizeof (*dcp));
+ mutex_destroy(&err_lock);
+
return (SET_ERROR(ENOMEM));
}
dcp->dc_tq = tq;
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c
index ede1555..188810b 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c
@@ -25,6 +25,8 @@
* Copyright (c) 2014, Joyent, Inc. All rights reserved.
* Copyright (c) 2012, Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright 2014 HybridCluster. All rights reserved.
+ * Copyright 2016 RackTop Systems.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/dmu.h>
@@ -64,6 +66,12 @@
int zfs_send_corrupt_data = B_FALSE;
int zfs_send_queue_length = 16 * 1024 * 1024;
int zfs_recv_queue_length = 16 * 1024 * 1024;
+/* Set this tunable to FALSE to disable setting of DRR_FLAG_FREERECORDS */
+int zfs_send_set_freerecords_bit = B_TRUE;
+
+#ifdef _KERNEL
+TUNABLE_INT("vfs.zfs.send_set_freerecords_bit", &zfs_send_set_freerecords_bit);
+#endif
static char *dmu_recv_tag = "dmu_recv_tag";
const char *recv_clone_name = "%recv";
@@ -158,6 +166,14 @@ dump_record(dmu_sendarg_t *dsp, void *payload, int payload_len)
return (0);
}
+/*
+ * Fill in the drr_free struct, or perform aggregation if the previous record is
+ * also a free record, and the two are adjacent.
+ *
+ * Note that we send free records even for a full send, because we want to be
+ * able to receive a full send as a clone, which requires a list of all the free
+ * and freeobject records that were generated on the source.
+ */
static int
dump_free(dmu_sendarg_t *dsp, uint64_t object, uint64_t offset,
uint64_t length)
@@ -181,15 +197,6 @@ dump_free(dmu_sendarg_t *dsp, uint64_t object, uint64_t offset,
(object == dsp->dsa_last_data_object &&
offset > dsp->dsa_last_data_offset));
- /*
- * If we are doing a non-incremental send, then there can't
- * be any data in the dataset we're receiving into. Therefore
- * a free record would simply be a no-op. Save space by not
- * sending it to begin with.
- */
- if (!dsp->dsa_incremental)
- return (0);
-
if (length != -1ULL && offset + length < offset)
length = -1ULL;
@@ -368,10 +375,6 @@ dump_freeobjects(dmu_sendarg_t *dsp, uint64_t firstobj, uint64_t numobjs)
{
struct drr_freeobjects *drrfo = &(dsp->dsa_drr->drr_u.drr_freeobjects);
- /* See comment in dump_free(). */
- if (!dsp->dsa_incremental)
- return (0);
-
/*
* If there is a pending op, but it's not PENDING_FREEOBJECTS,
* push it out, since free block aggregation can only be done for
@@ -776,6 +779,8 @@ dmu_send_impl(void *tag, dsl_pool_t *dp, dsl_dataset_t *to_ds,
drr->drr_u.drr_begin.drr_toguid = dsl_dataset_phys(to_ds)->ds_guid;
if (dsl_dataset_phys(to_ds)->ds_flags & DS_FLAG_CI_DATASET)
drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_CI_DATA;
+ if (zfs_send_set_freerecords_bit)
+ drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_FREERECORDS;
if (ancestor_zb != NULL) {
drr->drr_u.drr_begin.drr_fromguid =
@@ -799,7 +804,6 @@ dmu_send_impl(void *tag, dsl_pool_t *dp, dsl_dataset_t *to_ds,
dsp->dsa_off = off;
dsp->dsa_toguid = dsl_dataset_phys(to_ds)->ds_guid;
dsp->dsa_pending_op = PENDING_NONE;
- dsp->dsa_incremental = (ancestor_zb != NULL);
dsp->dsa_featureflags = featureflags;
dsp->dsa_resume_object = resumeobj;
dsp->dsa_resume_offset = resumeoff;
@@ -1321,7 +1325,7 @@ dmu_recv_begin_check(void *arg, dmu_tx_t *tx)
/* target fs already exists; recv into temp clone */
/* Can't recv a clone into an existing fs */
- if (flags & DRR_FLAG_CLONE) {
+ if (flags & DRR_FLAG_CLONE || drba->drba_origin) {
dsl_dataset_rele(ds, FTAG);
return (SET_ERROR(EINVAL));
}
@@ -1340,6 +1344,15 @@ dmu_recv_begin_check(void *arg, dmu_tx_t *tx)
drba->drba_origin))
return (SET_ERROR(ENOENT));
+ /*
+ * If we're receiving a full send as a clone, and it doesn't
+ * contain all the necessary free records and freeobject
+ * records, reject it.
+ */
+ if (fromguid == 0 && drba->drba_origin &&
+ !(flags & DRR_FLAG_FREERECORDS))
+ return (SET_ERROR(EINVAL));
+
/* Open the parent of tofs */
ASSERT3U(strlen(tofs), <, MAXNAMELEN);
(void) strlcpy(buf, tofs, strrchr(tofs, '/') - tofs + 1);
@@ -1379,7 +1392,8 @@ dmu_recv_begin_check(void *arg, dmu_tx_t *tx)
dsl_dataset_rele(ds, FTAG);
return (SET_ERROR(EINVAL));
}
- if (dsl_dataset_phys(origin)->ds_guid != fromguid) {
+ if (dsl_dataset_phys(origin)->ds_guid != fromguid &&
+ fromguid != 0) {
dsl_dataset_rele(origin, FTAG);
dsl_dataset_rele(ds, FTAG);
return (SET_ERROR(ENODEV));
@@ -1709,6 +1723,20 @@ struct receive_writer_arg {
uint64_t bytes_read; /* bytes read when current record created */
};
+struct objlist {
+ list_t list; /* List of struct receive_objnode. */
+ /*
+ * Last object looked up. Used to assert that objects are being looked
+ * up in ascending order.
+ */
+ uint64_t last_lookup;
+};
+
+struct receive_objnode {
+ list_node_t node;
+ uint64_t object;
+};
+
struct receive_arg {
objset_t *os;
kthread_t *td;
@@ -1727,12 +1755,7 @@ struct receive_arg {
int err;
boolean_t byteswap;
/* Sorted list of objects not to issue prefetches for. */
- list_t ignore_obj_list;
-};
-
-struct receive_ign_obj_node {
- list_node_t node;
- uint64_t object;
+ struct objlist ignore_objlist;
};
typedef struct guid_map_entry {
@@ -2068,13 +2091,14 @@ receive_freeobjects(struct receive_writer_arg *rwa,
struct drr_freeobjects *drrfo)
{
uint64_t obj;
+ int next_err = 0;
if (drrfo->drr_firstobj + drrfo->drr_numobjs < drrfo->drr_firstobj)
return (SET_ERROR(EINVAL));
for (obj = drrfo->drr_firstobj;
- obj < drrfo->drr_firstobj + drrfo->drr_numobjs;
- (void) dmu_object_next(rwa->os, &obj, FALSE, 0)) {
+ obj < drrfo->drr_firstobj + drrfo->drr_numobjs && next_err == 0;
+ next_err = dmu_object_next(rwa->os, &obj, FALSE, 0)) {
int err;
if (dmu_object_info(rwa->os, obj, NULL) != 0)
@@ -2084,7 +2108,8 @@ receive_freeobjects(struct receive_writer_arg *rwa,
if (err != 0)
return (err);
}
-
+ if (next_err != ESRCH)
+ return (next_err);
return (0);
}
@@ -2414,6 +2439,66 @@ receive_read_payload_and_next_header(struct receive_arg *ra, int len, void *buf)
return (0);
}
+static void
+objlist_create(struct objlist *list)
+{
+ list_create(&list->list, sizeof (struct receive_objnode),
+ offsetof(struct receive_objnode, node));
+ list->last_lookup = 0;
+}
+
+static void
+objlist_destroy(struct objlist *list)
+{
+ for (struct receive_objnode *n = list_remove_head(&list->list);
+ n != NULL; n = list_remove_head(&list->list)) {
+ kmem_free(n, sizeof (*n));
+ }
+ list_destroy(&list->list);
+}
+
+/*
+ * This function looks through the objlist to see if the specified object number
+ * is contained in the objlist. In the process, it will remove all object
+ * numbers in the list that are smaller than the specified object number. Thus,
+ * any lookup of an object number smaller than a previously looked up object
+ * number will always return false; therefore, all lookups should be done in
+ * ascending order.
+ */
+static boolean_t
+objlist_exists(struct objlist *list, uint64_t object)
+{
+ struct receive_objnode *node = list_head(&list->list);
+ ASSERT3U(object, >=, list->last_lookup);
+ list->last_lookup = object;
+ while (node != NULL && node->object < object) {
+ VERIFY3P(node, ==, list_remove_head(&list->list));
+ kmem_free(node, sizeof (*node));
+ node = list_head(&list->list);
+ }
+ return (node != NULL && node->object == object);
+}
+
+/*
+ * The objlist is a list of object numbers stored in ascending order. However,
+ * the insertion of new object numbers does not seek out the correct location to
+ * store a new object number; instead, it appends it to the list for simplicity.
+ * Thus, any users must take care to only insert new object numbers in ascending
+ * order.
+ */
+static void
+objlist_insert(struct objlist *list, uint64_t object)
+{
+ struct receive_objnode *node = kmem_zalloc(sizeof (*node), KM_SLEEP);
+ node->object = object;
+#ifdef ZFS_DEBUG
+ struct receive_objnode *last_object = list_tail(&list->list);
+ uint64_t last_objnum = (last_object != NULL ? last_object->object : 0);
+ ASSERT3U(node->object, >, last_objnum);
+#endif
+ list_insert_tail(&list->list, node);
+}
+
/*
* Issue the prefetch reads for any necessary indirect blocks.
*
@@ -2436,13 +2521,7 @@ static void
receive_read_prefetch(struct receive_arg *ra,
uint64_t object, uint64_t offset, uint64_t length)
{
- struct receive_ign_obj_node *node = list_head(&ra->ignore_obj_list);
- while (node != NULL && node->object < object) {
- VERIFY3P(node, ==, list_remove_head(&ra->ignore_obj_list));
- kmem_free(node, sizeof (*node));
- node = list_head(&ra->ignore_obj_list);
- }
- if (node == NULL || node->object > object) {
+ if (!objlist_exists(&ra->ignore_objlist, object)) {
dmu_prefetch(ra->os, object, 1, offset, length,
ZIO_PRIORITY_SYNC_READ);
}
@@ -2475,18 +2554,7 @@ receive_read_record(struct receive_arg *ra)
*/
if (err == ENOENT ||
(err == 0 && doi.doi_data_block_size != drro->drr_blksz)) {
- struct receive_ign_obj_node *node =
- kmem_zalloc(sizeof (*node),
- KM_SLEEP);
- node->object = drro->drr_object;
-#ifdef ZFS_DEBUG
- struct receive_ign_obj_node *last_object =
- list_tail(&ra->ignore_obj_list);
- uint64_t last_objnum = (last_object != NULL ?
- last_object->object : 0);
- ASSERT3U(node->object, >, last_objnum);
-#endif
- list_insert_tail(&ra->ignore_obj_list, node);
+ objlist_insert(&ra->ignore_objlist, drro->drr_object);
err = 0;
}
return (err);
@@ -2704,7 +2772,6 @@ resume_check(struct receive_arg *ra, nvlist_t *begin_nvl)
return (0);
}
-
/*
* Read in the stream's records, one by one, and apply them to the pool. There
* are two threads involved; the thread that calls this function will spin up a
@@ -2739,8 +2806,7 @@ dmu_recv_stream(dmu_recv_cookie_t *drc, struct file *fp, offset_t *voffp,
sizeof (ra.bytes_read), 1, &ra.bytes_read);
}
- list_create(&ra.ignore_obj_list, sizeof (struct receive_ign_obj_node),
- offsetof(struct receive_ign_obj_node, node));
+ objlist_create(&ra.ignore_objlist);
/* these were verified in dmu_recv_begin */
ASSERT3U(DMU_GET_STREAM_HDRTYPE(drc->drc_drrb->drr_versioninfo), ==,
@@ -2894,12 +2960,7 @@ out:
}
*voffp = ra.voff;
- for (struct receive_ign_obj_node *n =
- list_remove_head(&ra.ignore_obj_list); n != NULL;
- n = list_remove_head(&ra.ignore_obj_list)) {
- kmem_free(n, sizeof (*n));
- }
- list_destroy(&ra.ignore_obj_list);
+ objlist_destroy(&ra.ignore_objlist);
return (err);
}
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c
index 65a017f..bea484f 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c
@@ -22,6 +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, 2015 by Delphix. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/dmu.h>
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c
index a295f90..39bef75 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c
@@ -22,6 +22,7 @@
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2015 by Delphix. All rights reserved.
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/zfs_context.h>
@@ -58,7 +59,7 @@ static dnode_phys_t dnode_phys_zero;
int zfs_default_bs = SPA_MINBLOCKSHIFT;
int zfs_default_ibs = DN_MAX_INDBLKSHIFT;
-#ifdef sun
+#ifdef illumos
static kmem_cbrc_t dnode_move(void *, void *, size_t, void *);
#endif
@@ -840,7 +841,7 @@ dnode_move_impl(dnode_t *odn, dnode_t *ndn)
odn->dn_moved = (uint8_t)-1;
}
-#ifdef sun
+#ifdef illumos
#ifdef _KERNEL
/*ARGSUSED*/
static kmem_cbrc_t
@@ -983,7 +984,7 @@ dnode_move(void *buf, void *newbuf, size_t size, void *arg)
return (KMEM_CBRC_YES);
}
#endif /* _KERNEL */
-#endif /* sun */
+#endif /* illumos */
void
dnode_special_close(dnode_handle_t *dnh)
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c
index 95e5392..00b9c7e 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c
@@ -25,6 +25,8 @@
* Copyright (c) 2014, Joyent, Inc. All rights reserved.
* Copyright (c) 2014 RackTop Systems.
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
+ * Copyright 2016, OmniTI Computer Consulting, Inc. All rights reserved.
*/
#include <sys/dmu_objset.h>
@@ -84,6 +86,8 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, max_recordsize, CTLFLAG_RWTUN,
extern inline dsl_dataset_phys_t *dsl_dataset_phys(dsl_dataset_t *ds);
+extern int spa_asize_inflation;
+
/*
* Figure out how much of this delta should be propogated to the dsl_dir
* layer. If there's a refreservation, that space has already been
@@ -2896,6 +2900,11 @@ int
dsl_dataset_clone_swap_check_impl(dsl_dataset_t *clone,
dsl_dataset_t *origin_head, boolean_t force, void *owner, dmu_tx_t *tx)
{
+ /*
+ * "slack" factor for received datasets with refquota set on them.
+ * See the bottom of this function for details on its use.
+ */
+ uint64_t refquota_slack = DMU_MAX_ACCESS * spa_asize_inflation;
int64_t unused_refres_delta;
/* they should both be heads */
@@ -2938,10 +2947,22 @@ dsl_dataset_clone_swap_check_impl(dsl_dataset_t *clone,
dsl_dir_space_available(origin_head->ds_dir, NULL, 0, TRUE))
return (SET_ERROR(ENOSPC));
- /* clone can't be over the head's refquota */
+ /*
+ * The clone can't be too much over the head's refquota.
+ *
+ * To ensure that the entire refquota can be used, we allow one
+ * transaction to exceed the the refquota. Therefore, this check
+ * needs to also allow for the space referenced to be more than the
+ * refquota. The maximum amount of space that one transaction can use
+ * on disk is DMU_MAX_ACCESS * spa_asize_inflation. Allowing this
+ * overage ensures that we are able to receive a filesystem that
+ * exceeds the refquota on the source system.
+ *
+ * So that overage is the refquota_slack we use below.
+ */
if (origin_head->ds_quota != 0 &&
dsl_dataset_phys(clone)->ds_referenced_bytes >
- origin_head->ds_quota)
+ origin_head->ds_quota + refquota_slack)
return (SET_ERROR(EDQUOT));
return (0);
@@ -2955,8 +2976,13 @@ dsl_dataset_clone_swap_sync_impl(dsl_dataset_t *clone,
int64_t unused_refres_delta;
ASSERT(clone->ds_reserved == 0);
+ /*
+ * NOTE: On DEBUG kernels there could be a race between this and
+ * the check function if spa_asize_inflation is adjusted...
+ */
ASSERT(origin_head->ds_quota == 0 ||
- dsl_dataset_phys(clone)->ds_unique_bytes <= origin_head->ds_quota);
+ dsl_dataset_phys(clone)->ds_unique_bytes <= origin_head->ds_quota +
+ DMU_MAX_ACCESS * spa_asize_inflation);
ASSERT3P(clone->ds_prev, ==, origin_head->ds_prev);
/*
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deadlist.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deadlist.c
index d26c6cd..7e3a122 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deadlist.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deadlist.c
@@ -22,6 +22,7 @@
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/dsl_dataset.h>
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_destroy.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_destroy.c
index 7de9845..b897176 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_destroy.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_destroy.c
@@ -23,6 +23,7 @@
* Copyright (c) 2012, 2015 by Delphix. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright (c) 2013 by Joyent, Inc. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/zfs_context.h>
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c
index 2bb74c8..d1b8002 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c
@@ -23,6 +23,7 @@
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/dsl_pool.h>
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c
index 3c6a29b..a157dfe 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
+ * Copyright 2016 Gary Mills
*/
#include <sys/dsl_scan.h>
@@ -855,7 +856,16 @@ dsl_scan_ds_destroyed(dsl_dataset_t *ds, dmu_tx_t *tx)
if (scn->scn_phys.scn_bookmark.zb_objset == ds->ds_object) {
if (ds->ds_is_snapshot) {
- /* Note, scn_cur_{min,max}_txg stays the same. */
+ /*
+ * Note:
+ * - scn_cur_{min,max}_txg stays the same.
+ * - Setting the flag is not really necessary if
+ * scn_cur_max_txg == scn_max_txg, because there
+ * is nothing after this snapshot that we care
+ * about. However, we set it anyway and then
+ * ignore it when we retraverse it in
+ * dsl_scan_visitds().
+ */
scn->scn_phys.scn_bookmark.zb_objset =
dsl_dataset_phys(ds)->ds_next_snap_obj;
zfs_dbgmsg("destroying ds %llu; currently traversing; "
@@ -895,9 +905,6 @@ dsl_scan_ds_destroyed(dsl_dataset_t *ds, dmu_tx_t *tx)
zfs_dbgmsg("destroying ds %llu; in queue; removing",
(u_longlong_t)ds->ds_object);
}
- } else {
- zfs_dbgmsg("destroying ds %llu; ignoring",
- (u_longlong_t)ds->ds_object);
}
/*
@@ -1050,6 +1057,46 @@ dsl_scan_visitds(dsl_scan_t *scn, uint64_t dsobj, dmu_tx_t *tx)
VERIFY3U(0, ==, dsl_dataset_hold_obj(dp, dsobj, FTAG, &ds));
+ if (scn->scn_phys.scn_cur_min_txg >=
+ scn->scn_phys.scn_max_txg) {
+ /*
+ * This can happen if this snapshot was created after the
+ * scan started, and we already completed a previous snapshot
+ * that was created after the scan started. This snapshot
+ * only references blocks with:
+ *
+ * birth < our ds_creation_txg
+ * cur_min_txg is no less than ds_creation_txg.
+ * We have already visited these blocks.
+ * or
+ * birth > scn_max_txg
+ * The scan requested not to visit these blocks.
+ *
+ * Subsequent snapshots (and clones) can reference our
+ * blocks, or blocks with even higher birth times.
+ * Therefore we do not need to visit them either,
+ * so we do not add them to the work queue.
+ *
+ * Note that checking for cur_min_txg >= cur_max_txg
+ * is not sufficient, because in that case we may need to
+ * visit subsequent snapshots. This happens when min_txg > 0,
+ * which raises cur_min_txg. In this case we will visit
+ * this dataset but skip all of its blocks, because the
+ * rootbp's birth time is < cur_min_txg. Then we will
+ * add the next snapshots/clones to the work queue.
+ */
+ char *dsname = kmem_alloc(MAXNAMELEN, KM_SLEEP);
+ dsl_dataset_name(ds, dsname);
+ zfs_dbgmsg("scanning dataset %llu (%s) is unnecessary because "
+ "cur_min_txg (%llu) >= max_txg (%llu)",
+ dsobj, dsname,
+ scn->scn_phys.scn_cur_min_txg,
+ scn->scn_phys.scn_max_txg);
+ kmem_free(dsname, MAXNAMELEN);
+
+ goto out;
+ }
+
if (dmu_objset_from_ds(ds, &os))
goto out;
@@ -1450,10 +1497,23 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx)
}
/*
+ * Only process scans in sync pass 1.
+ */
+ if (spa_sync_pass(dp->dp_spa) > 1)
+ return;
+
+ /*
+ * If the spa is shutting down, then stop scanning. This will
+ * ensure that the scan does not dirty any new data during the
+ * shutdown phase.
+ */
+ if (spa_shutting_down(spa))
+ return;
+
+ /*
* If the scan is inactive due to a stalled async destroy, try again.
*/
- if ((!scn->scn_async_stalled && !dsl_scan_active(scn)) ||
- spa_sync_pass(dp->dp_spa) > 1)
+ if (!scn->scn_async_stalled && !dsl_scan_active(scn))
return;
scn->scn_visited_this_txg = 0;
@@ -1541,7 +1601,8 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx)
}
if (err != 0)
return;
- if (!scn->scn_async_destroying && zfs_free_leak_on_eio &&
+ if (dp->dp_free_dir != NULL && !scn->scn_async_destroying &&
+ zfs_free_leak_on_eio &&
(dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes != 0 ||
dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes != 0 ||
dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes != 0)) {
@@ -1567,7 +1628,7 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx)
-dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes,
-dsl_dir_phys(dp->dp_free_dir)->dd_uncompressed_bytes, tx);
}
- if (!scn->scn_async_destroying) {
+ if (dp->dp_free_dir != NULL && !scn->scn_async_destroying) {
/* finished; verify that space accounting went to zero */
ASSERT0(dsl_dir_phys(dp->dp_free_dir)->dd_used_bytes);
ASSERT0(dsl_dir_phys(dp->dp_free_dir)->dd_compressed_bytes);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
index be0a688..0e75746 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
@@ -22,6 +22,7 @@
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/zfs_context.h>
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c
index 7e96e55..bae4a78 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c
@@ -30,6 +30,11 @@
#ifdef _KERNEL
int reference_tracking_enable = FALSE; /* runs out of memory too easily */
+SYSCTL_DECL(_vfs_zfs);
+TUNABLE_INT("vfs.zfs.reference_tracking_enable", &reference_tracking_enable);
+SYSCTL_INT(_vfs_zfs, OID_AUTO, reference_tracking_enable, CTLFLAG_RDTUN,
+ &reference_tracking_enable, 0,
+ "Track reference holders to refcount_t objects, used mostly by ZFS");
#else
int reference_tracking_enable = TRUE;
#endif
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c
index 90355a9..e11dd4d 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sa.c
@@ -24,6 +24,7 @@
* Portions Copyright 2011 iXsystems, Inc
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/zfs_context.h>
@@ -547,10 +548,9 @@ sa_find_sizes(sa_os_t *sa, sa_bulk_attr_t *attr_desc, int attr_count,
{
int var_size = 0;
int i;
- int j = -1;
int full_space;
int hdrsize;
- boolean_t done = B_FALSE;
+ int extra_hdrsize;
if (buftype == SA_BONUS && sa->sa_force_spill) {
*total = 0;
@@ -561,10 +561,9 @@ sa_find_sizes(sa_os_t *sa, sa_bulk_attr_t *attr_desc, int attr_count,
*index = -1;
*total = 0;
+ *will_spill = B_FALSE;
- if (buftype == SA_BONUS)
- *will_spill = B_FALSE;
-
+ extra_hdrsize = 0;
hdrsize = (SA_BONUSTYPE_FROM_DB(db) == DMU_OT_ZNODE) ? 0 :
sizeof (sa_hdr_phys_t);
@@ -576,8 +575,8 @@ sa_find_sizes(sa_os_t *sa, sa_bulk_attr_t *attr_desc, int attr_count,
*total = P2ROUNDUP(*total, 8);
*total += attr_desc[i].sa_length;
- if (done)
- goto next;
+ if (*will_spill)
+ continue;
is_var_sz = (SA_REGISTERED_LEN(sa, attr_desc[i].sa_attr) == 0);
if (is_var_sz) {
@@ -585,21 +584,28 @@ sa_find_sizes(sa_os_t *sa, sa_bulk_attr_t *attr_desc, int attr_count,
}
if (is_var_sz && var_size > 1) {
- if (P2ROUNDUP(hdrsize + sizeof (uint16_t), 8) +
+ /*
+ * Don't worry that the spill block might overflow.
+ * It will be resized if needed in sa_build_layouts().
+ */
+ if (buftype == SA_SPILL ||
+ P2ROUNDUP(hdrsize + sizeof (uint16_t), 8) +
*total < full_space) {
/*
* Account for header space used by array of
* optional sizes of variable-length attributes.
- * Record the index in case this increase needs
- * to be reversed due to spill-over.
+ * Record the extra header size in case this
+ * increase needs to be reversed due to
+ * spill-over.
*/
hdrsize += sizeof (uint16_t);
- j = i;
+ if (*index != -1)
+ extra_hdrsize += sizeof (uint16_t);
} else {
- done = B_TRUE;
- *index = i;
- if (buftype == SA_BONUS)
- *will_spill = B_TRUE;
+ ASSERT(buftype == SA_BONUS);
+ if (*index == -1)
+ *index = i;
+ *will_spill = B_TRUE;
continue;
}
}
@@ -614,22 +620,15 @@ sa_find_sizes(sa_os_t *sa, sa_bulk_attr_t *attr_desc, int attr_count,
(*total + P2ROUNDUP(hdrsize, 8)) >
(full_space - sizeof (blkptr_t))) {
*index = i;
- done = B_TRUE;
}
-next:
if ((*total + P2ROUNDUP(hdrsize, 8)) > full_space &&
buftype == SA_BONUS)
*will_spill = B_TRUE;
}
- /*
- * j holds the index of the last variable-sized attribute for
- * which hdrsize was increased. Reverse the increase if that
- * attribute will be relocated to the spill block.
- */
- if (*will_spill && j == *index)
- hdrsize -= sizeof (uint16_t);
+ if (*will_spill)
+ hdrsize -= extra_hdrsize;
hdrsize = P2ROUNDUP(hdrsize, 8);
return (hdrsize);
@@ -1654,7 +1653,7 @@ sa_modify_attrs(sa_handle_t *hdl, sa_attr_type_t newattr,
int spill_data_size = 0;
int spill_attr_count = 0;
int error;
- uint16_t length;
+ uint16_t length, reg_length;
int i, j, k, length_idx;
sa_hdr_phys_t *hdr;
sa_idx_tab_t *idx_tab;
@@ -1714,34 +1713,50 @@ sa_modify_attrs(sa_handle_t *hdl, sa_attr_type_t newattr,
hdr = SA_GET_HDR(hdl, SA_BONUS);
idx_tab = SA_IDX_TAB_GET(hdl, SA_BONUS);
for (; k != 2; k++) {
- /* iterate over each attribute in layout */
+ /*
+ * Iterate over each attribute in layout. Fetch the
+ * size of variable-length attributes needing rewrite
+ * from sa_lengths[].
+ */
for (i = 0, length_idx = 0; i != count; i++) {
sa_attr_type_t attr;
attr = idx_tab->sa_layout->lot_attrs[i];
- if (attr == newattr) {
- /* duplicate attributes are not allowed */
- ASSERT(action == SA_REPLACE ||
- action == SA_REMOVE);
- /* must be variable-sized to be replaced here */
- if (action == SA_REPLACE) {
- ASSERT(SA_REGISTERED_LEN(sa, attr) == 0);
- SA_ADD_BULK_ATTR(attr_desc, j, attr,
- locator, datastart, buflen);
- }
+ reg_length = SA_REGISTERED_LEN(sa, attr);
+ if (reg_length == 0) {
+ length = hdr->sa_lengths[length_idx];
+ length_idx++;
} else {
- length = SA_REGISTERED_LEN(sa, attr);
- if (length == 0) {
- length = hdr->sa_lengths[length_idx];
- }
+ length = reg_length;
+ }
+ if (attr == newattr) {
+ /*
+ * There is nothing to do for SA_REMOVE,
+ * so it is just skipped.
+ */
+ if (action == SA_REMOVE)
+ continue;
+
+ /*
+ * Duplicate attributes are not allowed, so the
+ * action can not be SA_ADD here.
+ */
+ ASSERT3S(action, ==, SA_REPLACE);
+ /*
+ * Only a variable-sized attribute can be
+ * replaced here, and its size must be changing.
+ */
+ ASSERT3U(reg_length, ==, 0);
+ ASSERT3U(length, !=, buflen);
+ SA_ADD_BULK_ATTR(attr_desc, j, attr,
+ locator, datastart, buflen);
+ } else {
SA_ADD_BULK_ATTR(attr_desc, j, attr,
NULL, (void *)
(TOC_OFF(idx_tab->sa_idx_tab[attr]) +
(uintptr_t)old_data[k]), length);
}
- if (SA_REGISTERED_LEN(sa, attr) == 0)
- length_idx++;
}
if (k == 0 && hdl->sa_spill) {
hdr = SA_GET_HDR(hdl, SA_SPILL);
@@ -1752,10 +1767,8 @@ sa_modify_attrs(sa_handle_t *hdl, sa_attr_type_t newattr,
}
}
if (action == SA_ADD) {
- length = SA_REGISTERED_LEN(sa, newattr);
- if (length == 0) {
- length = buflen;
- }
+ reg_length = SA_REGISTERED_LEN(sa, newattr);
+ IMPLY(reg_length != 0, reg_length == buflen);
SA_ADD_BULK_ATTR(attr_desc, j, newattr, locator,
datastart, buflen);
}
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
index 69b84b7..563967d 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
@@ -21,11 +21,12 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
* Copyright (c) 2015, Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2013 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
* Copyright 2013 Saso Kiselkov. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
/*
@@ -85,17 +86,21 @@
/* Check hostid on import? */
static int check_hostid = 1;
-SYSCTL_DECL(_vfs_zfs);
-TUNABLE_INT("vfs.zfs.check_hostid", &check_hostid);
-SYSCTL_INT(_vfs_zfs, OID_AUTO, check_hostid, CTLFLAG_RW, &check_hostid, 0,
- "Check hostid on import?");
-
/*
* The interval, in seconds, at which failed configuration cache file writes
* should be retried.
*/
static int zfs_ccw_retry_interval = 300;
+SYSCTL_DECL(_vfs_zfs);
+TUNABLE_INT("vfs.zfs.check_hostid", &check_hostid);
+SYSCTL_INT(_vfs_zfs, OID_AUTO, check_hostid, CTLFLAG_RWTUN, &check_hostid, 0,
+ "Check hostid on import?");
+TUNABLE_INT("vfs.zfs.ccw_retry_interval", &zfs_ccw_retry_interval);
+SYSCTL_INT(_vfs_zfs, OID_AUTO, ccw_retry_interval, CTLFLAG_RW,
+ &zfs_ccw_retry_interval, 0,
+ "Configuration cache file write, retry after failure, interval (seconds)");
+
typedef enum zti_modes {
ZTI_MODE_FIXED, /* value is # of threads (min 1) */
ZTI_MODE_BATCH, /* cpu-intensive; value is ignored */
@@ -140,7 +145,7 @@ static const char *const zio_taskq_types[ZIO_TASKQ_TYPES] = {
const zio_taskq_info_t zio_taskqs[ZIO_TYPES][ZIO_TASKQ_TYPES] = {
/* ISSUE ISSUE_HIGH INTR INTR_HIGH */
{ ZTI_ONE, ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* NULL */
- { ZTI_N(8), ZTI_NULL, ZTI_BATCH, ZTI_NULL }, /* READ */
+ { ZTI_N(8), ZTI_NULL, ZTI_P(12, 8), ZTI_NULL }, /* READ */
{ ZTI_BATCH, ZTI_N(5), ZTI_N(8), ZTI_N(5) }, /* WRITE */
{ ZTI_P(12, 8), ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* FREE */
{ ZTI_ONE, ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* CLAIM */
@@ -3807,7 +3812,7 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
}
#ifdef _KERNEL
-#if defined(sun)
+#ifdef illumos
/*
* Get the root pool information from the root disk, then import the root pool
* during the system boot up time.
@@ -4008,7 +4013,7 @@ out:
return (error);
}
-#else
+#else /* !illumos */
extern int vdev_geom_read_pool_label(const char *name, nvlist_t ***configs,
uint64_t *count);
@@ -4204,8 +4209,8 @@ spa_import_rootpool(const char *name)
return (0);
}
-#endif /* sun */
-#endif
+#endif /* illumos */
+#endif /* _KERNEL */
/*
* Import a non-root pool into the system.
@@ -5381,13 +5386,13 @@ spa_vdev_split_mirror(spa_t *spa, char *newname, nvlist_t *config,
spa_activate(newspa, spa_mode_global);
spa_async_suspend(newspa);
-#ifndef sun
+#ifndef illumos
/* mark that we are creating new spa by splitting */
newspa->spa_splitting_newspa = B_TRUE;
#endif
/* create the new pool from the disks of the original pool */
error = spa_load(newspa, SPA_LOAD_IMPORT, SPA_IMPORT_ASSEMBLE, B_TRUE);
-#ifndef sun
+#ifndef illumos
newspa->spa_splitting_newspa = B_FALSE;
#endif
if (error)
@@ -6343,8 +6348,7 @@ spa_sync_config_object(spa_t *spa, dmu_tx_t *tx)
spa_config_exit(spa, SCL_STATE, FTAG);
- if (spa->spa_config_syncing)
- nvlist_free(spa->spa_config_syncing);
+ nvlist_free(spa->spa_config_syncing);
spa->spa_config_syncing = config;
spa_sync_nvlist(spa, spa->spa_config_object, config, tx);
@@ -6644,12 +6648,12 @@ spa_sync(spa_t *spa, uint64_t txg)
#ifdef illumos
VERIFY(cyclic_reprogram(spa->spa_deadman_cycid,
spa->spa_sync_starttime + spa->spa_deadman_synctime));
-#else /* FreeBSD */
+#else /* !illumos */
#ifdef _KERNEL
callout_reset(&spa->spa_deadman_cycid,
hz * spa->spa_deadman_synctime / NANOSEC, spa_deadman, spa);
#endif
-#endif
+#endif /* illumos */
/*
* If we are upgrading to SPA_VERSION_RAIDZ_DEFLATE this txg,
@@ -6768,16 +6772,10 @@ spa_sync(spa_t *spa, uint64_t txg)
if (svdcount == SPA_DVAS_PER_BP)
break;
}
- error = vdev_config_sync(svd, svdcount, txg, B_FALSE);
- if (error != 0)
- error = vdev_config_sync(svd, svdcount, txg,
- B_TRUE);
+ error = vdev_config_sync(svd, svdcount, txg);
} else {
error = vdev_config_sync(rvd->vdev_child,
- rvd->vdev_children, txg, B_FALSE);
- if (error != 0)
- error = vdev_config_sync(rvd->vdev_child,
- rvd->vdev_children, txg, B_TRUE);
+ rvd->vdev_children, txg);
}
if (error == 0)
@@ -6794,11 +6792,11 @@ spa_sync(spa_t *spa, uint64_t txg)
#ifdef illumos
VERIFY(cyclic_reprogram(spa->spa_deadman_cycid, CY_INFINITY));
-#else /* FreeBSD */
+#else /* !illumos */
#ifdef _KERNEL
callout_drain(&spa->spa_deadman_cycid);
#endif
-#endif
+#endif /* illumos */
/*
* Clear the dirty config list.
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c
index be1e528..a5c17a5 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c
@@ -367,8 +367,7 @@ void
spa_config_set(spa_t *spa, nvlist_t *config)
{
mutex_enter(&spa->spa_props_lock);
- if (spa->spa_config != NULL)
- nvlist_free(spa->spa_config);
+ nvlist_free(spa->spa_config);
spa->spa_config = config;
mutex_exit(&spa->spa_props_lock);
}
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c
index ecd5435..8965686 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/spa.h>
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
index e18ffd2..49299b6 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
@@ -21,10 +21,11 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
- * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
* Copyright 2013 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
* Copyright 2013 Saso Kiselkov. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/zfs_context.h>
@@ -263,6 +264,33 @@ TUNABLE_INT("vfs.zfs.recover", &zfs_recover);
SYSCTL_INT(_vfs_zfs, OID_AUTO, recover, CTLFLAG_RWTUN, &zfs_recover, 0,
"Try to recover from otherwise-fatal errors.");
+static int
+sysctl_vfs_zfs_debug_flags(SYSCTL_HANDLER_ARGS)
+{
+ int err, val;
+
+ val = zfs_flags;
+ err = sysctl_handle_int(oidp, &val, 0, req);
+ if (err != 0 || req->newptr == NULL)
+ return (err);
+
+ /*
+ * ZFS_DEBUG_MODIFY must be enabled prior to boot so all
+ * arc buffers in the system have the necessary additional
+ * checksum data. However, it is safe to disable at any
+ * time.
+ */
+ if (!(zfs_flags & ZFS_DEBUG_MODIFY))
+ val &= ~ZFS_DEBUG_MODIFY;
+ zfs_flags = val;
+
+ return (0);
+}
+TUNABLE_INT("vfs.zfs.debug_flags", &zfs_flags);
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, debug_flags,
+ CTLTYPE_UINT | CTLFLAG_MPSAFE | CTLFLAG_RW, 0, sizeof(int),
+ sysctl_vfs_zfs_debug_flags, "IU", "Debug flags for ZFS testing.");
+
/*
* If destroy encounters an EIO while reading metadata (e.g. indirect
* blocks), space referenced by the missing metadata can not be freed.
@@ -432,14 +460,16 @@ spa_config_tryenter(spa_t *spa, int locks, void *tag, krw_t rw)
if (rw == RW_READER) {
if (scl->scl_writer || scl->scl_write_wanted) {
mutex_exit(&scl->scl_lock);
- spa_config_exit(spa, locks ^ (1 << i), tag);
+ spa_config_exit(spa, locks & ((1 << i) - 1),
+ tag);
return (0);
}
} else {
ASSERT(scl->scl_writer != curthread);
if (!refcount_is_zero(&scl->scl_count)) {
mutex_exit(&scl->scl_lock);
- spa_config_exit(spa, locks ^ (1 << i), tag);
+ spa_config_exit(spa, locks & ((1 << i) - 1),
+ tag);
return (0);
}
scl->scl_writer = curthread;
@@ -581,6 +611,12 @@ spa_deadman(void *arg)
++spa->spa_deadman_calls);
if (zfs_deadman_enabled)
vdev_deadman(spa->spa_root_vdev);
+#ifdef __FreeBSD__
+#ifdef _KERNEL
+ callout_schedule(&spa->spa_deadman_cycid,
+ hz * zfs_deadman_checktime_ms / MILLISEC);
+#endif
+#endif
}
/*
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h
index 6ba19c9..cb3b739 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h
@@ -28,6 +28,7 @@
* Copyright 2014 HybridCluster. All rights reserved.
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
* Copyright 2013 Saso Kiselkov. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
/* Portions Copyright 2010 Robert Milkowski */
@@ -724,7 +725,7 @@ int dmu_write_uio(objset_t *os, uint64_t object, struct uio *uio, uint64_t size,
int dmu_write_uio_dbuf(dmu_buf_t *zdb, struct uio *uio, uint64_t size,
dmu_tx_t *tx);
#ifdef _KERNEL
-#ifdef sun
+#ifdef illumos
int dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset,
uint64_t size, struct page *pp, dmu_tx_t *tx);
#else
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_impl.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_impl.h
index e8d6294..8cb6341 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_impl.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_impl.h
@@ -25,7 +25,7 @@
/*
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
* Copyright (c) 2012, Martin Matuska <mm@FreeBSD.org>. All rights reserved.
- * Copyright (c) 2013, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2013, 2015 by Delphix. All rights reserved.
*/
#ifndef _SYS_DMU_IMPL_H
@@ -296,7 +296,6 @@ typedef struct dmu_sendarg {
uint64_t dsa_toguid;
int dsa_err;
dmu_pendop_t dsa_pending_op;
- boolean_t dsa_incremental;
uint64_t dsa_featureflags;
uint64_t dsa_last_data_object;
uint64_t dsa_last_data_offset;
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_objset.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_objset.h
index 8a263a3..f05b2cf 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_objset.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_objset.h
@@ -23,6 +23,7 @@
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
/* Portions Copyright 2010 Robert Milkowski */
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_send.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_send.h
index 2865e82..19464a5 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_send.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_send.h
@@ -24,6 +24,7 @@
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#ifndef _DMU_SEND_H
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h
index d7df05b..766ae3c 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h
@@ -24,6 +24,7 @@
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#ifndef _SYS_DSL_DATASET_H
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h
index be00621..105f889 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h
@@ -24,6 +24,7 @@
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
* Copyright 2013 Saso Kiselkov. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#ifndef _SYS_SPA_H
@@ -625,7 +626,7 @@ extern int spa_get_stats(const char *pool, nvlist_t **config, char *altroot,
size_t buflen);
extern int spa_create(const char *pool, nvlist_t *config, nvlist_t *props,
nvlist_t *zplprops);
-#if defined(sun)
+#ifdef illumos
extern int spa_import_rootpool(char *devpath, char *devid);
#else
extern int spa_import_rootpool(const char *name);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h
index 0f9a18b..a93ba83 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h
@@ -256,7 +256,7 @@ struct spa {
uint64_t spa_feat_refcount_cache[SPA_FEATURES];
#ifdef illumos
cyclic_id_t spa_deadman_cycid; /* cyclic id */
-#else /* FreeBSD */
+#else /* !illumos */
#ifdef _KERNEL
struct callout spa_deadman_cycid; /* callout id */
#endif
@@ -286,7 +286,7 @@ struct spa {
*/
spa_config_lock_t spa_config_lock[SCL_LOCKS]; /* config changes */
refcount_t spa_refcount; /* number of opens */
-#ifndef sun
+#ifndef illumos
boolean_t spa_splitting_newspa; /* creating new spa in split */
#endif
};
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h
index ff46ba6..6312f03 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h
@@ -127,8 +127,7 @@ extern void vdev_queue_register_lastoffset(vdev_t *vd, zio_t *zio);
extern void vdev_config_dirty(vdev_t *vd);
extern void vdev_config_clean(vdev_t *vd);
-extern int vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg,
- boolean_t);
+extern int vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg);
extern void vdev_state_dirty(vdev_t *vd);
extern void vdev_state_clean(vdev_t *vd);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h
index a31d04c..77e291b 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h
@@ -60,7 +60,7 @@ typedef int vdev_open_func_t(vdev_t *vd, uint64_t *size, uint64_t *max_size,
uint64_t *logical_ashift, uint64_t *physical_ashift);
typedef void vdev_close_func_t(vdev_t *vd);
typedef uint64_t vdev_asize_func_t(vdev_t *vd, uint64_t psize);
-typedef int vdev_io_start_func_t(zio_t *zio);
+typedef void vdev_io_start_func_t(zio_t *zio);
typedef void vdev_io_done_func_t(zio_t *zio);
typedef void vdev_state_change_func_t(vdev_t *vd, int, int);
typedef void vdev_hold_func_t(vdev_t *vd);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h
index 09b052e..6af259f 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#ifndef _SYS_ZAP_IMPL_H
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h
index 5102040..17503d8 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h
@@ -94,10 +94,8 @@ extern "C" {
#include <sys/sunddi.h>
#ifdef illumos
#include <sys/cyclic.h>
-#include <sys/callo.h>
-#else /* FreeBSD */
-#include <sys/callout.h>
#endif
+#include <sys/callo.h>
#include <sys/disp.h>
#include <machine/stdarg.h>
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h
index 20bf545..f42df17 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h
@@ -20,7 +20,9 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2015 by Delphix. All rights reserved.
+ * Copyright 2016 RackTop Systems.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#ifndef _SYS_ZFS_IOCTL_H
@@ -124,8 +126,22 @@ typedef enum dmu_send_resume_token_version {
#define DMU_BACKUP_MAGIC 0x2F5bacbacULL
+/*
+ * Send stream flags. Bits 24-31 are reserved for vendor-specific
+ * implementations and should not be used.
+ */
#define DRR_FLAG_CLONE (1<<0)
#define DRR_FLAG_CI_DATA (1<<1)
+/*
+ * This send stream, if it is a full send, includes the FREE and FREEOBJECT
+ * records that are created by the sending process. This means that the send
+ * stream can be received as a clone, even though it is not an incremental.
+ * This is not implemented as a feature flag, because the receiving side does
+ * not need to have implemented it to receive this stream; it is fully backwards
+ * compatible. We need a flag, though, because full send streams without it
+ * cannot necessarily be received as a clone correctly.
+ */
+#define DRR_FLAG_FREERECORDS (1<<2)
/*
* flags in the drr_checksumflags field in the DRR_WRITE and
@@ -298,6 +314,7 @@ typedef struct zinject_record {
uint32_t zi_iotype;
int32_t zi_duration;
uint64_t zi_timer;
+ uint64_t zi_nlanes;
uint32_t zi_cmd;
uint32_t zi_pad;
} zinject_record_t;
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
index c8e3105..3e72ec4 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#ifndef _SYS_FS_ZFS_ZNODE_H
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h
index d3fe6e9..1642da0 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
/* Portions Copyright 2010 Robert Milkowski */
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil_impl.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil_impl.h
index b5c666c..ac908bd 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil_impl.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil_impl.h
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
/* Portions Copyright 2010 Robert Milkowski */
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h
index 16d9ad2..56c821a 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h
@@ -150,9 +150,6 @@ enum zio_compress {
#define ZIO_FAILURE_MODE_CONTINUE 1
#define ZIO_FAILURE_MODE_PANIC 2
-#define ZIO_PIPELINE_CONTINUE 0x100
-#define ZIO_PIPELINE_STOP 0x101
-
enum zio_flag {
/*
* Flags inherited by gang, ddt, and vdev children,
@@ -458,6 +455,7 @@ struct zio {
uint64_t io_offset;
hrtime_t io_timestamp;
+ hrtime_t io_target_timestamp;
avl_node_t io_queue_node;
avl_node_t io_offset_node;
@@ -551,6 +549,8 @@ extern int zio_wait(zio_t *zio);
extern void zio_nowait(zio_t *zio);
extern void zio_execute(zio_t *zio);
extern void zio_interrupt(zio_t *zio);
+extern void zio_delay_init(zio_t *zio);
+extern void zio_delay_interrupt(zio_t *zio);
extern zio_t *zio_walk_parents(zio_t *cio);
extern zio_t *zio_walk_children(zio_t *pio);
@@ -612,7 +612,7 @@ extern int zio_handle_fault_injection(zio_t *zio, int error);
extern int zio_handle_device_injection(vdev_t *vd, zio_t *zio, int error);
extern int zio_handle_label_injection(zio_t *zio, int error);
extern void zio_handle_ignored_writes(zio_t *zio);
-extern uint64_t zio_handle_io_delay(zio_t *zio);
+extern hrtime_t zio_handle_io_delay(zio_t *zio);
/*
* Checksum ereport functions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h
index 75c6b37..7556eda 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h
@@ -45,7 +45,7 @@ extern int zvol_remove_minor(const char *);
extern void zvol_remove_minors(const char *);
extern int zvol_set_volsize(const char *, uint64_t);
-#ifdef sun
+#ifdef illumos
extern int zvol_open(dev_t *devp, int flag, int otyp, cred_t *cr);
extern int zvol_dump(dev_t dev, caddr_t addr, daddr_t offset, int nblocks);
extern int zvol_close(dev_t dev, int flag, int otyp, cred_t *cr);
@@ -54,14 +54,14 @@ extern int zvol_read(dev_t dev, uio_t *uiop, cred_t *cr);
extern int zvol_write(dev_t dev, uio_t *uiop, cred_t *cr);
extern int zvol_aread(dev_t dev, struct aio_req *aio, cred_t *cr);
extern int zvol_awrite(dev_t dev, struct aio_req *aio, cred_t *cr);
-#endif /* sun */
+#endif /* illumos */
extern int zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr,
int *rvalp);
extern int zvol_busy(void);
extern void zvol_init(void);
extern void zvol_fini(void);
-#ifdef sun
+#ifdef illumos
extern int zvol_get_volume_params(minor_t minor, uint64_t *blksize,
uint64_t *max_xfer_len, void **minor_hdl, void **objset_hdl, void **zil_hdl,
void **rl_hdl, void **bonus_hdl);
@@ -69,7 +69,7 @@ extern uint64_t zvol_get_volume_size(void *minor_hdl);
extern int zvol_get_volume_wce(void *minor_hdl);
extern void zvol_log_write_minor(void *minor_hdl, dmu_tx_t *tx, offset_t off,
ssize_t resid, boolean_t sync);
-#endif /* sun */
+#endif /* illumos */
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
extern int zvol_create_minors(const char *name);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
index a846487..28ff6c9 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
@@ -24,6 +24,7 @@
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
* Copyright 2013 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/zfs_context.h>
@@ -3401,7 +3402,7 @@ vdev_set_state(vdev_t *vd, boolean_t isopen, vdev_state_t state, vdev_aux_t aux)
boolean_t
vdev_is_bootable(vdev_t *vd)
{
-#ifdef sun
+#ifdef illumos
if (!vd->vdev_ops->vdev_op_leaf) {
char *vdev_type = vd->vdev_ops->vdev_op_type;
@@ -3418,7 +3419,7 @@ vdev_is_bootable(vdev_t *vd)
if (!vdev_is_bootable(vd->vdev_child[c]))
return (B_FALSE);
}
-#endif /* sun */
+#endif /* illumos */
return (B_TRUE);
}
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c
index eaa9dfc..681a670 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2015 by Delphix. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2013 Joyent, Inc. All rights reserved.
*/
@@ -691,7 +691,7 @@ vdev_disk_io_intr(buf_t *bp)
kmem_free(vb, sizeof (vdev_buf_t));
- zio_interrupt(zio);
+ zio_delay_interrupt(zio);
}
static void
@@ -715,7 +715,7 @@ vdev_disk_ioctl_done(void *zio_arg, int error)
zio_interrupt(zio);
}
-static int
+static void
vdev_disk_io_start(zio_t *zio)
{
vdev_t *vd = zio->io_vd;
@@ -732,7 +732,7 @@ vdev_disk_io_start(zio_t *zio)
if (dvd == NULL || (dvd->vd_ldi_offline && dvd->vd_lh == NULL)) {
zio->io_error = SET_ERROR(ENXIO);
zio_interrupt(zio);
- return (ZIO_PIPELINE_STOP);
+ return;
}
if (zio->io_type == ZIO_TYPE_IOCTL) {
@@ -740,7 +740,7 @@ vdev_disk_io_start(zio_t *zio)
if (!vdev_readable(vd)) {
zio->io_error = SET_ERROR(ENXIO);
zio_interrupt(zio);
- return (ZIO_PIPELINE_STOP);
+ return;
}
switch (zio->io_cmd) {
@@ -771,7 +771,7 @@ vdev_disk_io_start(zio_t *zio)
* and will call vdev_disk_ioctl_done()
* upon completion.
*/
- return (ZIO_PIPELINE_STOP);
+ return;
}
if (error == ENOTSUP || error == ENOTTY) {
@@ -792,11 +792,12 @@ vdev_disk_io_start(zio_t *zio)
zio->io_error = SET_ERROR(ENOTSUP);
}
- zio_interrupt(zio);
- return (ZIO_PIPELINE_STOP);
+ zio_execute(zio);
+ return;
}
ASSERT(zio->io_type == ZIO_TYPE_READ || zio->io_type == ZIO_TYPE_WRITE);
+ zio->io_target_timestamp = zio_handle_io_delay(zio);
vb = kmem_alloc(sizeof (vdev_buf_t), KM_SLEEP);
@@ -816,8 +817,6 @@ vdev_disk_io_start(zio_t *zio)
/* ldi_strategy() will return non-zero only on programming errors */
VERIFY(ldi_strategy(dvd->vd_lh, bp) == 0);
-
- return (ZIO_PIPELINE_STOP);
}
static void
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c
index ad21d6e..8228af1 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -156,7 +156,7 @@ vdev_file_close(vdev_t *vd)
vd->vdev_tsd = NULL;
}
-static int
+static void
vdev_file_io_start(zio_t *zio)
{
vdev_t *vd = zio->io_vd;
@@ -167,7 +167,7 @@ vdev_file_io_start(zio_t *zio)
if (!vdev_readable(vd)) {
zio->io_error = SET_ERROR(ENXIO);
zio_interrupt(zio);
- return (ZIO_PIPELINE_STOP);
+ return;
}
vf = vd->vdev_tsd;
@@ -183,11 +183,12 @@ vdev_file_io_start(zio_t *zio)
zio->io_error = SET_ERROR(ENOTSUP);
}
- zio_interrupt(zio);
- return (ZIO_PIPELINE_STOP);
+ zio_execute(zio);
+ return;
}
ASSERT(zio->io_type == ZIO_TYPE_READ || zio->io_type == ZIO_TYPE_WRITE);
+ zio->io_target_timestamp = zio_handle_io_delay(zio);
zio->io_error = vn_rdwr(zio->io_type == ZIO_TYPE_READ ?
UIO_READ : UIO_WRITE, vp, zio->io_data, zio->io_size,
@@ -196,9 +197,12 @@ vdev_file_io_start(zio_t *zio)
if (resid != 0 && zio->io_error == 0)
zio->io_error = ENOSPC;
- zio_interrupt(zio);
+ zio_delay_interrupt(zio);
- return (ZIO_PIPELINE_STOP);
+#ifdef illumos
+ VERIFY3U(taskq_dispatch(system_taskq, vdev_file_io_strategy, bp,
+ TQ_SLEEP), !=, 0);
+#endif
}
/* ARGSUSED */
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
index 763ea1a..d64001e 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
@@ -80,6 +80,9 @@ static void
vdev_geom_attrchanged(struct g_consumer *cp, const char *attr)
{
vdev_t *vd;
+ spa_t *spa;
+ char *physpath;
+ int error, physpath_len;
vd = cp->private;
if (vd == NULL)
@@ -89,6 +92,47 @@ vdev_geom_attrchanged(struct g_consumer *cp, const char *attr)
vdev_geom_set_rotation_rate(vd, cp);
return;
}
+
+ if (strcmp(attr, "GEOM::physpath") != 0)
+ return;
+
+ if (g_access(cp, 1, 0, 0) != 0)
+ return;
+
+ /*
+ * Record/Update physical path information for this device.
+ */
+ spa = vd->vdev_spa;
+ physpath_len = MAXPATHLEN;
+ physpath = g_malloc(physpath_len, M_WAITOK|M_ZERO);
+ error = g_io_getattr("GEOM::physpath", cp, &physpath_len, physpath);
+ g_access(cp, -1, 0, 0);
+ if (error == 0) {
+ char *old_physpath;
+
+ old_physpath = vd->vdev_physpath;
+ vd->vdev_physpath = spa_strdup(physpath);
+ spa_async_request(spa, SPA_ASYNC_CONFIG_UPDATE);
+
+ if (old_physpath != NULL) {
+ int held_lock;
+
+ held_lock = spa_config_held(spa, SCL_STATE, RW_WRITER);
+ if (held_lock == 0) {
+ g_topology_unlock();
+ spa_config_enter(spa, SCL_STATE, FTAG,
+ RW_WRITER);
+ }
+
+ spa_strfree(old_physpath);
+
+ if (held_lock == 0) {
+ spa_config_exit(spa, SCL_STATE, FTAG);
+ g_topology_lock();
+ }
+ }
+ }
+ g_free(physpath);
}
static void
@@ -99,8 +143,10 @@ vdev_geom_orphan(struct g_consumer *cp)
g_topology_assert();
vd = cp->private;
- if (vd == NULL)
+ if (vd == NULL) {
+ /* Vdev close in progress. Ignore the event. */
return;
+ }
/*
* Orphan callbacks occur from the GEOM event thread.
@@ -121,7 +167,7 @@ vdev_geom_orphan(struct g_consumer *cp)
}
static struct g_consumer *
-vdev_geom_attach(struct g_provider *pp)
+vdev_geom_attach(struct g_provider *pp, vdev_t *vd)
{
struct g_geom *gp;
struct g_consumer *cp;
@@ -140,6 +186,7 @@ vdev_geom_attach(struct g_provider *pp)
if (gp == NULL) {
gp = g_new_geomf(&zfs_vdev_class, "zfs::vdev");
gp->orphan = vdev_geom_orphan;
+ gp->attrchanged = vdev_geom_attrchanged;
cp = g_new_consumer(gp);
if (g_attach(cp, pp) != 0) {
g_wither_geom(gp, ENXIO);
@@ -176,28 +223,56 @@ vdev_geom_attach(struct g_provider *pp)
ZFS_LOG(1, "Used existing consumer for %s.", pp->name);
}
}
+
+ /*
+ * BUG: cp may already belong to a vdev. This could happen if:
+ * 1) That vdev is a shared spare, or
+ * 2) We are trying to reopen a missing vdev and we are scanning by
+ * guid. In that case, we'll ultimately fail to open this consumer,
+ * but not until after setting the private field.
+ * The solution is to:
+ * 1) Don't set the private field until after the open succeeds, and
+ * 2) Set it to a linked list of vdevs, not just a single vdev
+ */
+ cp->private = vd;
+ vd->vdev_tsd = cp;
+
+ /* Fetch initial physical path information for this device. */
+ vdev_geom_attrchanged(cp, "GEOM::physpath");
+
cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
return (cp);
}
static void
-vdev_geom_detach(void *arg, int flag __unused)
+vdev_geom_close_locked(vdev_t *vd)
{
struct g_geom *gp;
struct g_consumer *cp;
g_topology_assert();
- cp = arg;
- gp = cp->geom;
+
+ cp = vd->vdev_tsd;
+ if (cp == NULL)
+ return;
ZFS_LOG(1, "Closing access to %s.", cp->provider->name);
+ KASSERT(vd->vdev_tsd == cp, ("%s: vdev_tsd is not cp", __func__));
+ vd->vdev_tsd = NULL;
+ vd->vdev_delayed_close = B_FALSE;
+ cp->private = NULL;
+
+ gp = cp->geom;
g_access(cp, -1, 0, -1);
/* Destroy consumer on last close. */
if (cp->acr == 0 && cp->ace == 0) {
- ZFS_LOG(1, "Destroyed consumer to %s.", cp->provider->name);
if (cp->acw > 0)
g_access(cp, 0, -cp->acw, 0);
- g_detach(cp);
+ if (cp->provider != NULL) {
+ ZFS_LOG(1, "Destroyed consumer to %s.",
+ cp->provider->name);
+ g_detach(cp);
+ }
g_destroy_consumer(cp);
}
/* Destroy geom if there are no consumers left. */
@@ -491,7 +566,7 @@ vdev_geom_read_guids(struct g_consumer *cp, uint64_t *pguid, uint64_t *vguid)
}
static struct g_consumer *
-vdev_geom_attach_by_guids(uint64_t pool_guid, uint64_t vdev_guid)
+vdev_geom_attach_by_guids(vdev_t *vd)
{
struct g_class *mp;
struct g_geom *gp, *zgp;
@@ -528,10 +603,10 @@ vdev_geom_attach_by_guids(uint64_t pool_guid, uint64_t vdev_guid)
* label.)
*/
if ((pguid != 0 &&
- pguid != pool_guid) ||
- vguid != vdev_guid)
+ pguid != spa_guid(vd->vdev_spa)) ||
+ vguid != vd->vdev_guid)
continue;
- cp = vdev_geom_attach(pp);
+ cp = vdev_geom_attach(pp, vd);
if (cp == NULL) {
printf("ZFS WARNING: Unable to "
"attach to %s.\n", pp->name);
@@ -561,7 +636,7 @@ vdev_geom_open_by_guids(vdev_t *vd)
g_topology_assert();
ZFS_LOG(1, "Searching by guid [%ju].", (uintmax_t)vd->vdev_guid);
- cp = vdev_geom_attach_by_guids(spa_guid(vd->vdev_spa), vd->vdev_guid);
+ cp = vdev_geom_attach_by_guids(vd);
if (cp != NULL) {
len = strlen(cp->provider->name) + strlen("/dev/") + 1;
buf = kmem_alloc(len, KM_SLEEP);
@@ -595,7 +670,7 @@ vdev_geom_open_by_path(vdev_t *vd, int check_guid)
pp = g_provider_by_name(vd->vdev_path + sizeof("/dev/") - 1);
if (pp != NULL) {
ZFS_LOG(1, "Found provider by name %s.", vd->vdev_path);
- cp = vdev_geom_attach(pp);
+ cp = vdev_geom_attach(pp, vd);
if (cp != NULL && check_guid && ISP2(pp->sectorsize) &&
pp->sectorsize <= VDEV_PAD_SIZE) {
g_topology_unlock();
@@ -603,7 +678,7 @@ vdev_geom_open_by_path(vdev_t *vd, int check_guid)
g_topology_lock();
if (pguid != spa_guid(vd->vdev_spa) ||
vguid != vd->vdev_guid) {
- vdev_geom_detach(cp, 0);
+ vdev_geom_close_locked(vd);
cp = NULL;
ZFS_LOG(1, "guid mismatch for provider %s: "
"%ju:%ju != %ju:%ju.", vd->vdev_path,
@@ -685,7 +760,8 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
!ISP2(cp->provider->sectorsize)) {
ZFS_LOG(1, "Provider %s has unsupported sectorsize.",
vd->vdev_path);
- vdev_geom_detach(cp, 0);
+
+ vdev_geom_close_locked(vd);
error = EINVAL;
cp = NULL;
} else if (cp->acw == 0 && (spa_mode(vd->vdev_spa) & FWRITE) != 0) {
@@ -702,19 +778,17 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
if (error != 0) {
printf("ZFS WARNING: Unable to open %s for writing (error=%d).\n",
vd->vdev_path, error);
- vdev_geom_detach(cp, 0);
+ vdev_geom_close_locked(vd);
cp = NULL;
}
}
+
g_topology_unlock();
PICKUP_GIANT();
if (cp == NULL) {
vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
return (error);
}
-
- cp->private = vd;
- vd->vdev_tsd = cp;
pp = cp->provider;
/*
@@ -728,7 +802,8 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
*/
*logical_ashift = highbit(MAX(pp->sectorsize, SPA_MINBLOCKSIZE)) - 1;
*physical_ashift = 0;
- if (pp->stripesize)
+ if (pp->stripesize > (1 << *logical_ashift) && ISP2(pp->stripesize) &&
+ pp->stripesize <= (1 << SPA_MAXASHIFT) && pp->stripeoffset == 0)
*physical_ashift = highbit(pp->stripesize) - 1;
/*
@@ -737,12 +812,6 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
*/
vd->vdev_nowritecache = B_FALSE;
- if (vd->vdev_physpath != NULL)
- spa_strfree(vd->vdev_physpath);
- bufsize = sizeof("/dev/") + strlen(pp->name);
- vd->vdev_physpath = kmem_alloc(bufsize, KM_SLEEP);
- snprintf(vd->vdev_physpath, bufsize, "/dev/%s", pp->name);
-
/*
* Determine the device's rotation rate.
*/
@@ -754,15 +823,12 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
static void
vdev_geom_close(vdev_t *vd)
{
- struct g_consumer *cp;
- cp = vd->vdev_tsd;
- if (cp == NULL)
- return;
- vd->vdev_tsd = NULL;
- vd->vdev_delayed_close = B_FALSE;
- cp->private = NULL; /* XXX locking */
- g_post_event(vdev_geom_detach, cp, M_WAITOK, NULL);
+ DROP_GIANT();
+ g_topology_lock();
+ vdev_geom_close_locked(vd);
+ g_topology_unlock();
+ PICKUP_GIANT();
}
static void
@@ -811,10 +877,10 @@ vdev_geom_io_intr(struct bio *bp)
break;
}
g_destroy_bio(bp);
- zio_interrupt(zio);
+ zio_delay_interrupt(zio);
}
-static int
+static void
vdev_geom_io_start(zio_t *zio)
{
vdev_t *vd;
@@ -829,6 +895,8 @@ vdev_geom_io_start(zio_t *zio)
/* XXPOLICY */
if (!vdev_readable(vd)) {
zio->io_error = SET_ERROR(ENXIO);
+ zio_interrupt(zio);
+ return;
} else {
switch (zio->io_cmd) {
case DKIOCFLUSHWRITECACHE:
@@ -844,16 +912,16 @@ vdev_geom_io_start(zio_t *zio)
}
}
- zio_interrupt(zio);
- return (ZIO_PIPELINE_STOP);
+ zio_execute(zio);
+ return;
case ZIO_TYPE_FREE:
if (vd->vdev_notrim) {
zio->io_error = SET_ERROR(ENOTSUP);
} else if (!vdev_geom_bio_delete_disable) {
goto sendreq;
}
- zio_interrupt(zio);
- return (ZIO_PIPELINE_STOP);
+ zio_execute(zio);
+ return;
}
sendreq:
ASSERT(zio->io_type == ZIO_TYPE_READ ||
@@ -865,13 +933,14 @@ sendreq:
if (cp == NULL) {
zio->io_error = SET_ERROR(ENXIO);
zio_interrupt(zio);
- return (ZIO_PIPELINE_STOP);
+ return;
}
bp = g_alloc_bio();
bp->bio_caller1 = zio;
switch (zio->io_type) {
case ZIO_TYPE_READ:
case ZIO_TYPE_WRITE:
+ zio->io_target_timestamp = zio_handle_io_delay(zio);
bp->bio_cmd = zio->io_type == ZIO_TYPE_READ ? BIO_READ : BIO_WRITE;
bp->bio_data = zio->io_data;
bp->bio_offset = zio->io_offset;
@@ -894,8 +963,6 @@ sendreq:
bp->bio_done = vdev_geom_io_intr;
g_io_request(bp, cp);
-
- return (ZIO_PIPELINE_STOP);
}
static void
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c
index 9befa75..77191e7 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c
@@ -602,7 +602,8 @@ vdev_inuse(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason,
* read-only. Instead we look to see if the pools is marked
* read-only in the namespace and set the state to active.
*/
- if ((spa = spa_by_guid(pool_guid, device_guid)) != NULL &&
+ if (state != POOL_STATE_SPARE && state != POOL_STATE_L2CACHE &&
+ (spa = spa_by_guid(pool_guid, device_guid)) != NULL &&
spa_mode(spa) == FREAD)
state = POOL_STATE_ACTIVE;
@@ -1193,15 +1194,16 @@ vdev_label_sync_list(spa_t *spa, int l, uint64_t txg, int flags)
* at any time, you can just call it again, and it will resume its work.
*/
int
-vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
+vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg)
{
spa_t *spa = svd[0]->vdev_spa;
uberblock_t *ub = &spa->spa_uberblock;
vdev_t *vd;
zio_t *zio;
- int error;
+ int error = 0;
int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL;
+retry:
/*
* Normally, we don't want to try too hard to write every label and
* uberblock. If there is a flaky disk, we don't want the rest of the
@@ -1209,8 +1211,11 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
* single label out, we should retry with ZIO_FLAG_TRYHARD before
* bailing out and declaring the pool faulted.
*/
- if (tryhard)
+ if (error != 0) {
+ if ((flags & ZIO_FLAG_TRYHARD) != 0)
+ return (error);
flags |= ZIO_FLAG_TRYHARD;
+ }
ASSERT(ub->ub_txg <= txg);
@@ -1254,7 +1259,7 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
* are committed to stable storage before the uberblock update.
*/
if ((error = vdev_label_sync_list(spa, 0, txg, flags)) != 0)
- return (error);
+ goto retry;
/*
* Sync the uberblocks to all vdevs in svd[].
@@ -1272,7 +1277,7 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
* to the new uberblocks.
*/
if ((error = vdev_uberblock_sync_list(svd, svdcount, ub, flags)) != 0)
- return (error);
+ goto retry;
/*
* Sync out odd labels for every dirty vdev. If the system dies
@@ -1285,7 +1290,7 @@ vdev_config_sync(vdev_t **svd, int svdcount, uint64_t txg, boolean_t tryhard)
* stable storage before the next transaction group begins.
*/
if ((error = vdev_label_sync_list(spa, 1, txg, flags)) != 0)
- return (error);
+ goto retry;;
trim_thread_wakeup(spa);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c
index 9d22d1e..65acd47 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c
@@ -24,7 +24,7 @@
*/
/*
- * Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -431,7 +431,7 @@ vdev_mirror_child_select(zio_t *zio)
return (-1);
}
-static int
+static void
vdev_mirror_io_start(zio_t *zio)
{
mirror_map_t *mm;
@@ -457,8 +457,8 @@ vdev_mirror_io_start(zio_t *zio)
zio->io_type, zio->io_priority, 0,
vdev_mirror_scrub_done, mc));
}
- zio_interrupt(zio);
- return (ZIO_PIPELINE_STOP);
+ zio_execute(zio);
+ return;
}
/*
* For normal reads just pick one child.
@@ -485,8 +485,7 @@ vdev_mirror_io_start(zio_t *zio)
c++;
}
- zio_interrupt(zio);
- return (ZIO_PIPELINE_STOP);
+ zio_execute(zio);
}
static int
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_missing.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_missing.c
index fec0037..24a44a6 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_missing.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_missing.c
@@ -24,7 +24,7 @@
*/
/*
- * Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
*/
/*
@@ -67,12 +67,11 @@ vdev_missing_close(vdev_t *vd)
}
/* ARGSUSED */
-static int
+static void
vdev_missing_io_start(zio_t *zio)
{
zio->io_error = SET_ERROR(ENOTSUP);
- zio_interrupt(zio);
- return (ZIO_PIPELINE_STOP);
+ zio_execute(zio);
}
/* ARGSUSED */
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c
index 9f83abb..a1d1d79 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c
@@ -25,6 +25,7 @@
/*
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/zfs_context.h>
@@ -883,9 +884,6 @@ vdev_queue_io_done(zio_t *zio)
vdev_queue_t *vq = &zio->io_vd->vdev_queue;
zio_t *nio;
- if (zio_injection_enabled)
- delay(SEC_TO_TICK(zio_handle_io_delay(zio)));
-
mutex_enter(&vq->vq_lock);
vdev_queue_pending_remove(vq, zio);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c
index 33bedc1..a755f3a 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c
@@ -21,8 +21,9 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/zfs_context.h>
@@ -1726,7 +1727,7 @@ vdev_raidz_child_done(zio_t *zio)
* vdevs have had errors, then create zio read operations to the parity
* columns' VDevs as well.
*/
-static int
+static void
vdev_raidz_io_start(zio_t *zio)
{
vdev_t *vd = zio->io_vd;
@@ -1756,8 +1757,8 @@ vdev_raidz_io_start(zio_t *zio)
vdev_raidz_child_done, rc));
}
- zio_interrupt(zio);
- return (ZIO_PIPELINE_STOP);
+ zio_execute(zio);
+ return;
}
if (zio->io_type == ZIO_TYPE_WRITE) {
@@ -1789,8 +1790,8 @@ vdev_raidz_io_start(zio_t *zio)
ZIO_FLAG_NODATA | ZIO_FLAG_OPTIONAL, NULL, NULL));
}
- zio_interrupt(zio);
- return (ZIO_PIPELINE_STOP);
+ zio_execute(zio);
+ return;
}
ASSERT(zio->io_type == ZIO_TYPE_READ);
@@ -1830,8 +1831,7 @@ vdev_raidz_io_start(zio_t *zio)
}
}
- zio_interrupt(zio);
- return (ZIO_PIPELINE_STOP);
+ zio_execute(zio);
}
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c
index 8ca68b8..ea3d869 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c
@@ -22,6 +22,7 @@
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/zio.h>
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
index 6545dc2..fd1d59b 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
@@ -1994,8 +1994,8 @@ top:
zfs_sa_upgrade_txholds(tx, zp);
error = dmu_tx_assign(tx, TXG_NOWAIT);
if (error) {
- mutex_exit(&zp->z_acl_lock);
mutex_exit(&zp->z_lock);
+ mutex_exit(&zp->z_acl_lock);
if (error == ERESTART) {
dmu_tx_wait(tx);
@@ -2020,7 +2020,6 @@ top:
if (fuidp)
zfs_fuid_info_free(fuidp);
dmu_tx_commit(tx);
-done:
mutex_exit(&zp->z_lock);
mutex_exit(&zp->z_acl_lock);
@@ -2053,7 +2052,7 @@ zfs_zaccess_dataset_check(znode_t *zp, uint32_t v4_mode)
return (SET_ERROR(EPERM));
}
-#ifdef sun
+#ifdef illumos
if ((v4_mode & (ACE_DELETE | ACE_DELETE_CHILD)) &&
(zp->z_pflags & ZFS_NOUNLINK)) {
return (SET_ERROR(EPERM));
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
index 22bbfb2..693ba41 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
@@ -113,7 +113,7 @@ snapentry_compare(const void *a, const void *b)
return (0);
}
-#ifdef sun
+#ifdef illumos
vnodeops_t *zfsctl_ops_root;
vnodeops_t *zfsctl_ops_snapdir;
vnodeops_t *zfsctl_ops_snapshot;
@@ -124,20 +124,20 @@ static const fs_operation_def_t zfsctl_tops_root[];
static const fs_operation_def_t zfsctl_tops_snapdir[];
static const fs_operation_def_t zfsctl_tops_snapshot[];
static const fs_operation_def_t zfsctl_tops_shares[];
-#else /* !sun */
+#else
static struct vop_vector zfsctl_ops_root;
static struct vop_vector zfsctl_ops_snapdir;
static struct vop_vector zfsctl_ops_snapshot;
static struct vop_vector zfsctl_ops_shares;
static struct vop_vector zfsctl_ops_shares_dir;
-#endif /* !sun */
+#endif
static vnode_t *zfsctl_mknode_snapdir(vnode_t *);
static vnode_t *zfsctl_mknode_shares(vnode_t *);
static vnode_t *zfsctl_snapshot_mknode(vnode_t *, uint64_t objset);
static int zfsctl_unmount_snap(zfs_snapentry_t *, int, cred_t *);
-#ifdef sun
+#ifdef illumos
static gfs_opsvec_t zfsctl_opsvec[] = {
{ ".zfs", zfsctl_tops_root, &zfsctl_ops_root },
{ ".zfs/snapshot", zfsctl_tops_snapdir, &zfsctl_ops_snapdir },
@@ -146,7 +146,7 @@ static gfs_opsvec_t zfsctl_opsvec[] = {
{ ".zfs/shares/vnode", zfsctl_tops_shares, &zfsctl_ops_shares },
{ NULL }
};
-#endif /* sun */
+#endif
/*
* Root directory elements. We only have two entries
@@ -171,7 +171,7 @@ static gfs_dirent_t zfsctl_root_entries[] = {
void
zfsctl_init(void)
{
-#ifdef sun
+#ifdef illumos
VERIFY(gfs_make_opsvec(zfsctl_opsvec) == 0);
#endif
}
@@ -179,7 +179,7 @@ zfsctl_init(void)
void
zfsctl_fini(void)
{
-#ifdef sun
+#ifdef illumos
/*
* Remove vfsctl vnode ops
*/
@@ -199,7 +199,7 @@ zfsctl_fini(void)
zfsctl_ops_snapshot = NULL;
zfsctl_ops_shares = NULL;
zfsctl_ops_shares_dir = NULL;
-#endif /* sun */
+#endif /* illumos */
}
boolean_t
@@ -550,7 +550,7 @@ zfsctl_root_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, pathname_t *pnp,
return (err);
}
-#ifdef sun
+#ifdef illumos
static int
zfsctl_pathconf(vnode_t *vp, int cmd, ulong_t *valp, cred_t *cr,
caller_context_t *ct)
@@ -566,9 +566,9 @@ zfsctl_pathconf(vnode_t *vp, int cmd, ulong_t *valp, cred_t *cr,
return (fs_pathconf(vp, cmd, valp, cr, ct));
}
-#endif /* sun */
+#endif /* illumos */
-#ifdef sun
+#ifdef illumos
static const fs_operation_def_t zfsctl_tops_root[] = {
{ VOPNAME_OPEN, { .vop_open = zfsctl_common_open } },
{ VOPNAME_CLOSE, { .vop_close = zfsctl_common_close } },
@@ -583,7 +583,7 @@ static const fs_operation_def_t zfsctl_tops_root[] = {
{ VOPNAME_FID, { .vop_fid = zfsctl_common_fid } },
{ NULL }
};
-#endif /* sun */
+#endif /* illumos */
/*
* Special case the handling of "..".
@@ -677,7 +677,7 @@ zfsctl_unmount_snap(zfs_snapentry_t *sep, int fflags, cred_t *cr)
if ((error = vn_vfswlock(svp)) != 0)
return (error);
-#ifdef sun
+#ifdef illumos
VN_HOLD(svp);
error = dounmount(vn_mountedvfs(svp), fflags, cr);
if (error) {
@@ -697,13 +697,13 @@ zfsctl_unmount_snap(zfs_snapentry_t *sep, int fflags, cred_t *cr)
kmem_free(sep, sizeof (zfs_snapentry_t));
return (0);
-#else /* !sun */
+#else
vfs_ref(vn_mountedvfs(svp));
return (dounmount(vn_mountedvfs(svp), fflags, curthread));
-#endif /* !sun */
+#endif
}
-#ifdef sun
+#ifdef illumos
static void
zfsctl_rename_snap(zfsctl_snapdir_t *sdp, zfs_snapentry_t *sep, const char *nm)
{
@@ -756,9 +756,9 @@ zfsctl_rename_snap(zfsctl_snapdir_t *sdp, zfs_snapentry_t *sep, const char *nm)
vfs_unlock(vfsp);
}
-#endif /* sun */
+#endif /* illumos */
-#ifdef sun
+#ifdef illumos
/*ARGSUSED*/
static int
zfsctl_snapdir_rename(vnode_t *sdvp, char *snm, vnode_t *tdvp, char *tnm,
@@ -823,9 +823,9 @@ zfsctl_snapdir_rename(vnode_t *sdvp, char *snm, vnode_t *tdvp, char *tnm,
return (err);
}
-#endif /* sun */
+#endif /* illumos */
-#ifdef sun
+#ifdef illumos
/* ARGSUSED */
static int
zfsctl_snapdir_remove(vnode_t *dvp, char *name, vnode_t *cwd, cred_t *cr,
@@ -881,7 +881,7 @@ zfsctl_snapdir_remove(vnode_t *dvp, char *name, vnode_t *cwd, cred_t *cr,
return (err);
}
-#endif /* sun */
+#endif /* illumos */
/*
* This creates a snapshot under '.zfs/snapshot'.
@@ -1069,7 +1069,7 @@ zfsctl_snapdir_lookup(ap)
}
ZFS_EXIT(zfsvfs);
return (err);
-#endif /* !illumos */
+#endif /* illumos */
}
sep = kmem_alloc(sizeof (zfs_snapentry_t), KM_SLEEP);
@@ -1377,7 +1377,7 @@ zfsctl_snapdir_inactive(ap)
return (0);
}
-#ifdef sun
+#ifdef illumos
static const fs_operation_def_t zfsctl_tops_snapdir[] = {
{ VOPNAME_OPEN, { .vop_open = zfsctl_common_open } },
{ VOPNAME_CLOSE, { .vop_close = zfsctl_common_close } },
@@ -1408,7 +1408,7 @@ static const fs_operation_def_t zfsctl_tops_shares[] = {
{ VOPNAME_FID, { .vop_fid = zfsctl_shares_fid } },
{ NULL }
};
-#else /* !sun */
+#else /* !illumos */
static struct vop_vector zfsctl_ops_snapdir = {
.vop_default = &default_vnodeops,
.vop_open = zfsctl_common_open,
@@ -1437,7 +1437,7 @@ static struct vop_vector zfsctl_ops_shares = {
.vop_reclaim = gfs_vop_reclaim,
.vop_fid = zfsctl_shares_fid,
};
-#endif /* !sun */
+#endif /* illumos */
/*
* pvp is the GFS vnode '.zfs/snapshot'.
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c
index e2a3bff..cf42ff6 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c
@@ -222,7 +222,7 @@ zfs_dirent_lock(zfs_dirlock_t **dlpp, znode_t *dzp, char *name, znode_t **zpp,
mutex_enter(&dzp->z_lock);
for (;;) {
- if (dzp->z_unlinked) {
+ if (dzp->z_unlinked && !(flag & ZXATTR)) {
mutex_exit(&dzp->z_lock);
if (!(flag & ZHAVELOCK))
rw_exit(&dzp->z_name_lock);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fuid.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fuid.c
index 197e122..e74799a 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fuid.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fuid.c
@@ -406,7 +406,7 @@ zfs_fuid_map_id(zfsvfs_t *zfsvfs, uint64_t fuid,
domain = zfs_fuid_find_by_idx(zfsvfs, index);
ASSERT(domain != NULL);
-#ifdef sun
+#ifdef illumos
if (type == ZFS_OWNER || type == ZFS_ACE_USER) {
(void) kidmap_getuidbysid(crgetzone(cr), domain,
FUID_RID(fuid), &id);
@@ -414,9 +414,9 @@ zfs_fuid_map_id(zfsvfs_t *zfsvfs, uint64_t fuid,
(void) kidmap_getgidbysid(crgetzone(cr), domain,
FUID_RID(fuid), &id);
}
-#else /* !sun */
+#else
id = UID_NOBODY;
-#endif /* !sun */
+#endif
return (id);
}
@@ -703,13 +703,13 @@ zfs_fuid_info_free(zfs_fuid_info_t *fuidp)
boolean_t
zfs_groupmember(zfsvfs_t *zfsvfs, uint64_t id, cred_t *cr)
{
-#ifdef sun
+#ifdef illumos
ksid_t *ksid = crgetsid(cr, KSID_GROUP);
ksidlist_t *ksidlist = crgetsidlist(cr);
-#endif /* !sun */
+#endif
uid_t gid;
-#ifdef sun
+#ifdef illumos
if (ksid && ksidlist) {
int i;
ksid_t *ksid_groups;
@@ -741,7 +741,7 @@ zfs_groupmember(zfsvfs_t *zfsvfs, uint64_t id, cred_t *cr)
}
}
}
-#endif /* !sun */
+#endif /* illumos */
/*
* Not found in ksidlist, check posix groups
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
index 6d9877b..8483fd7 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
@@ -25,11 +25,13 @@
* All rights reserved.
* Copyright 2013 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright 2014 Xin Li <delphij@FreeBSD.org>. All rights reserved.
+ * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2014, Joyent, Inc. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
/*
@@ -132,6 +134,9 @@
* distinguish between the operation failing, and
* deserialization failing.
*/
+#ifdef __FreeBSD__
+#include "opt_kstack_pages.h"
+#endif
#include <sys/types.h>
#include <sys/param.h>
@@ -1335,7 +1340,7 @@ get_nvlist(uint64_t nvl, uint64_t size, int iflag, nvlist_t **nvp)
if ((error = ddi_copyin((void *)(uintptr_t)nvl, packed, size,
iflag)) != 0) {
kmem_free(packed, size);
- return (error);
+ return (SET_ERROR(EFAULT));
}
if ((error = nvlist_unpack(packed, size, &list, 0)) != 0) {
@@ -1596,8 +1601,7 @@ zfs_ioc_pool_import(zfs_cmd_t *zc)
nvlist_free(config);
- if (props)
- nvlist_free(props);
+ nvlist_free(props);
return (error);
}
@@ -3745,10 +3749,12 @@ static int
zfs_ioc_rename(zfs_cmd_t *zc)
{
boolean_t recursive = zc->zc_cookie & 1;
+ char *at;
+ boolean_t allow_mounted = B_TRUE;
+
#ifdef __FreeBSD__
- boolean_t allow_mounted = zc->zc_cookie & 2;
+ allow_mounted = (zc->zc_cookie & 2) != 0;
#endif
- char *at;
zc->zc_value[sizeof (zc->zc_value) - 1] = '\0';
if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 ||
@@ -3763,11 +3769,7 @@ zfs_ioc_rename(zfs_cmd_t *zc)
if (strncmp(zc->zc_name, zc->zc_value, at - zc->zc_name + 1))
return (SET_ERROR(EXDEV));
*at = '\0';
-#ifdef illumos
- if (zc->zc_objset_type == DMU_OST_ZFS) {
-#else
if (zc->zc_objset_type == DMU_OST_ZFS && allow_mounted) {
-#endif
error = dmu_objset_find(zc->zc_name,
recursive_unmount, at + 1,
recursive ? DS_FIND_CHILDREN : 0);
@@ -3969,7 +3971,7 @@ zfs_check_settable(const char *dsname, nvpair_t *pair, cred_t *cr)
return (SET_ERROR(EINVAL));
/* check prop value is enabled in features */
- feature = zio_checksum_to_feature(intval);
+ feature = zio_checksum_to_feature(intval & ZIO_CHECKSUM_MASK);
if (feature == SPA_FEATURE_NONE)
break;
@@ -4175,6 +4177,56 @@ next:
}
}
+/*
+ * Extract properties that cannot be set PRIOR to the receipt of a dataset.
+ * For example, refquota cannot be set until after the receipt of a dataset,
+ * because in replication streams, an older/earlier snapshot may exceed the
+ * refquota. We want to receive the older/earlier snapshot, but setting
+ * refquota pre-receipt will set the dsl's ACTUAL quota, which will prevent
+ * the older/earlier snapshot from being received (with EDQUOT).
+ *
+ * The ZFS test "zfs_receive_011_pos" demonstrates such a scenario.
+ *
+ * libzfs will need to be judicious handling errors encountered by props
+ * extracted by this function.
+ */
+static nvlist_t *
+extract_delay_props(nvlist_t *props)
+{
+ nvlist_t *delayprops;
+ nvpair_t *nvp, *tmp;
+ static const zfs_prop_t delayable[] = { ZFS_PROP_REFQUOTA, 0 };
+ int i;
+
+ VERIFY(nvlist_alloc(&delayprops, NV_UNIQUE_NAME, KM_SLEEP) == 0);
+
+ for (nvp = nvlist_next_nvpair(props, NULL); nvp != NULL;
+ nvp = nvlist_next_nvpair(props, nvp)) {
+ /*
+ * strcmp() is safe because zfs_prop_to_name() always returns
+ * a bounded string.
+ */
+ for (i = 0; delayable[i] != 0; i++) {
+ if (strcmp(zfs_prop_to_name(delayable[i]),
+ nvpair_name(nvp)) == 0) {
+ break;
+ }
+ }
+ if (delayable[i] != 0) {
+ tmp = nvlist_prev_nvpair(props, nvp);
+ VERIFY(nvlist_add_nvpair(delayprops, nvp) == 0);
+ VERIFY(nvlist_remove_nvpair(props, nvp) == 0);
+ nvp = tmp;
+ }
+ }
+
+ if (nvlist_empty(delayprops)) {
+ nvlist_free(delayprops);
+ delayprops = NULL;
+ }
+ return (delayprops);
+}
+
#ifdef DEBUG
static boolean_t zfs_ioc_recv_inject_err;
#endif
@@ -4211,6 +4263,7 @@ zfs_ioc_recv(zfs_cmd_t *zc)
offset_t off;
nvlist_t *props = NULL; /* sent properties */
nvlist_t *origprops = NULL; /* existing properties */
+ nvlist_t *delayprops = NULL; /* sent properties applied post-receive */
char *origin = NULL;
char *tosnap;
char tofs[ZFS_MAXNAMELEN];
@@ -4296,21 +4349,12 @@ zfs_ioc_recv(zfs_cmd_t *zc)
props_error = dsl_prop_set_hasrecvd(tofs);
if (props_error == 0) {
+ delayprops = extract_delay_props(props);
(void) zfs_set_prop_nvlist(tofs, ZPROP_SRC_RECEIVED,
props, errors);
}
}
- if (zc->zc_nvlist_dst_size != 0 &&
- (nvlist_smush(errors, zc->zc_nvlist_dst_size) != 0 ||
- put_nvlist(zc, errors) != 0)) {
- /*
- * Caller made zc->zc_nvlist_dst less than the minimum expected
- * size or supplied an invalid address.
- */
- props_error = SET_ERROR(EINVAL);
- }
-
off = fp->f_offset;
error = dmu_recv_stream(&drc, fp, &off, zc->zc_cleanup_fd,
&zc->zc_action_handle);
@@ -4335,6 +4379,40 @@ zfs_ioc_recv(zfs_cmd_t *zc)
} else {
error = dmu_recv_end(&drc, NULL);
}
+
+ /* Set delayed properties now, after we're done receiving. */
+ if (delayprops != NULL && error == 0) {
+ (void) zfs_set_prop_nvlist(tofs, ZPROP_SRC_RECEIVED,
+ delayprops, errors);
+ }
+ }
+
+ if (delayprops != NULL) {
+ /*
+ * Merge delayed props back in with initial props, in case
+ * we're DEBUG and zfs_ioc_recv_inject_err is set (which means
+ * we have to make sure clear_received_props() includes
+ * the delayed properties).
+ *
+ * Since zfs_ioc_recv_inject_err is only in DEBUG kernels,
+ * using ASSERT() will be just like a VERIFY.
+ */
+ ASSERT(nvlist_merge(props, delayprops, 0) == 0);
+ nvlist_free(delayprops);
+ }
+
+ /*
+ * Now that all props, initial and delayed, are set, report the prop
+ * errors to the caller.
+ */
+ if (zc->zc_nvlist_dst_size != 0 &&
+ (nvlist_smush(errors, zc->zc_nvlist_dst_size) != 0 ||
+ put_nvlist(zc, errors) != 0)) {
+ /*
+ * Caller made zc->zc_nvlist_dst less than the minimum expected
+ * size or supplied an invalid address.
+ */
+ props_error = SET_ERROR(EINVAL);
}
zc->zc_cookie = off - fp->f_offset;
@@ -4860,7 +4938,7 @@ zfs_ioc_userspace_upgrade(zfs_cmd_t *zc)
return (error);
}
-#ifdef sun
+#ifdef illumos
/*
* We don't want to have a hard dependency
* against some special symbols in sharefs
@@ -4878,10 +4956,10 @@ int zfs_smbshare_inited;
ddi_modhandle_t nfs_mod;
ddi_modhandle_t sharefs_mod;
ddi_modhandle_t smbsrv_mod;
-#endif /* sun */
+#endif /* illumos */
kmutex_t zfs_share_lock;
-#ifdef sun
+#ifdef illumos
static int
zfs_init_sharefs()
{
@@ -4901,12 +4979,12 @@ zfs_init_sharefs()
}
return (0);
}
-#endif /* sun */
+#endif /* illumos */
static int
zfs_ioc_share(zfs_cmd_t *zc)
{
-#ifdef sun
+#ifdef illumos
int error;
int opcode;
@@ -4997,9 +5075,9 @@ zfs_ioc_share(zfs_cmd_t *zc)
return (error);
-#else /* !sun */
+#else /* !illumos */
return (ENOSYS);
-#endif /* !sun */
+#endif /* illumos */
}
ace_t full_access[] = {
@@ -5107,7 +5185,7 @@ zfs_ioc_diff(zfs_cmd_t *zc)
return (error);
}
-#ifdef sun
+#ifdef illumos
/*
* Remove all ACL files in shares dir
*/
@@ -5129,12 +5207,12 @@ zfs_smb_acl_purge(znode_t *dzp)
zap_cursor_fini(&zc);
return (error);
}
-#endif /* sun */
+#endif /* illumos */
static int
zfs_ioc_smb_acl(zfs_cmd_t *zc)
{
-#ifdef sun
+#ifdef illumos
vnode_t *vp;
znode_t *dzp;
vnode_t *resourcevp = NULL;
@@ -5258,9 +5336,9 @@ zfs_ioc_smb_acl(zfs_cmd_t *zc)
ZFS_EXIT(zfsvfs);
return (error);
-#else /* !sun */
+#else /* !illumos */
return (EOPNOTSUPP);
-#endif /* !sun */
+#endif /* illumos */
}
/*
@@ -6013,7 +6091,7 @@ zfsdev_open(struct cdev *devp, int flag, int mode, struct thread *td)
{
int error = 0;
-#ifdef sun
+#ifdef illumos
if (getminor(*devp) != 0)
return (zvol_open(devp, flag, otyp, cr));
#endif
@@ -6142,6 +6220,14 @@ zfsdev_ioctl(struct cdev *dev, u_long zcmd, caddr_t arg, int flag,
goto out;
}
break;
+ case ZFS_IOCVER_RESUME:
+ if (zc_iocparm->zfs_cmd_size != sizeof(zfs_cmd_resume_t)) {
+ error = SET_ERROR(EFAULT);
+ goto out;
+ }
+ compat = B_TRUE;
+ cflag = ZFS_CMD_COMPAT_RESUME;
+ break;
case ZFS_IOCVER_EDBP:
if (zc_iocparm->zfs_cmd_size != sizeof(zfs_cmd_edbp_t)) {
error = SET_ERROR(EFAULT);
@@ -6358,7 +6444,7 @@ out:
return (error);
}
-#ifdef sun
+#ifdef illumos
static int
zfs_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
{
@@ -6409,7 +6495,7 @@ zfs_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
return (DDI_FAILURE);
}
-#endif /* sun */
+#endif /* illumos */
/*
* OK, so this is a little weird.
@@ -6420,7 +6506,7 @@ zfs_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
* /dev/zfs has basically nothing to do except serve up ioctls,
* so most of the standard driver entry points are in zvol.c.
*/
-#ifdef sun
+#ifdef illumos
static struct cb_ops zfs_cb_ops = {
zfsdev_open, /* open */
zfsdev_close, /* close */
@@ -6469,7 +6555,7 @@ static struct modlinkage modlinkage = {
(void *)&zfs_modldrv,
NULL
};
-#endif /* sun */
+#endif /* illumos */
static struct cdevsw zfs_cdevsw = {
.d_version = D_VERSION,
@@ -6502,7 +6588,7 @@ zfsdev_fini(void)
static struct root_hold_token *zfs_root_token;
struct proc *zfsproc;
-#ifdef sun
+#ifdef illumos
int
_init(void)
{
@@ -6565,7 +6651,7 @@ _info(struct modinfo *modinfop)
{
return (mod_info(&modlinkage, modinfop));
}
-#endif /* sun */
+#endif /* illumos */
static int zfs__init(void);
static int zfs__fini(void);
@@ -6573,18 +6659,22 @@ static void zfs_shutdown(void *, int);
static eventhandler_tag zfs_shutdown_event_tag;
+#ifdef __FreeBSD__
#define ZFS_MIN_KSTACK_PAGES 4
+#endif
int
zfs__init(void)
{
+#ifdef __FreeBSD__
#if KSTACK_PAGES < ZFS_MIN_KSTACK_PAGES
printf("ZFS NOTICE: KSTACK_PAGES is %d which could result in stack "
"overflow panic!\nPlease consider adding "
"'options KSTACK_PAGES=%d' to your kernel config\n", KSTACK_PAGES,
ZFS_MIN_KSTACK_PAGES);
#endif
+#endif
zfs_root_token = root_mount_hold("ZFS");
mutex_init(&zfs_share_lock, NULL, MUTEX_DEFAULT, NULL);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c
index 30b3b52..6933ccd 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015 by Delphix. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/types.h>
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_replay.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_replay.c
index ae24ef0..6a76513 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_replay.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_replay.c
@@ -820,7 +820,7 @@ top:
static int
zfs_replay_truncate(zfsvfs_t *zfsvfs, lr_truncate_t *lr, boolean_t byteswap)
{
-#ifdef sun
+#ifdef illumos
znode_t *zp;
flock64_t fl;
int error;
@@ -843,10 +843,10 @@ zfs_replay_truncate(zfsvfs_t *zfsvfs, lr_truncate_t *lr, boolean_t byteswap)
VN_RELE(ZTOV(zp));
return (error);
-#else /* !sun */
+#else
ZFS_LOG(0, "Unexpected code path, report to pjd@FreeBSD.org");
return (EOPNOTSUPP);
-#endif /* !sun */
+#endif
}
static int
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
index 8e66044..fa6eac7 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
@@ -23,6 +23,7 @@
* Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>.
* All rights reserved.
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
/* Portions Copyright 2010 Robert Milkowski */
@@ -133,6 +134,13 @@ zfs_sync(vfs_t *vfsp, int waitfor)
if (panicstr)
return (0);
+ /*
+ * Ignore the system syncher. ZFS already commits async data
+ * at zfs_txg_timeout intervals.
+ */
+ if (waitfor == MNT_LAZY)
+ return (0);
+
if (vfsp != NULL) {
/*
* Sync a specific filesystem.
@@ -848,6 +856,17 @@ zfsvfs_create(const char *osname, zfsvfs_t **zfvp)
int i, error;
uint64_t sa_obj;
+ /*
+ * XXX: Fix struct statfs so this isn't necessary!
+ *
+ * The 'osname' is used as the filesystem's special node, which means
+ * it must fit in statfs.f_mntfromname, or else it can't be
+ * enumerated, so libzfs_mnttab_find() returns NULL, which causes
+ * 'zfs unmount' to think it's not mounted when it is.
+ */
+ if (strlen(osname) >= MNAMELEN)
+ return (SET_ERROR(ENAMETOOLONG));
+
zfsvfs = kmem_zalloc(sizeof (zfsvfs_t), KM_SLEEP);
/*
@@ -1566,13 +1585,13 @@ zfs_mount(vfs_t *vfsp)
* can be interrogated.
*/
if ((uap->flags & MS_DATA) && uap->datalen > 0)
-#else
+#else /* !illumos */
if (!prison_allow(td->td_ucred, PR_ALLOW_MOUNT_ZFS))
return (SET_ERROR(EPERM));
if (vfs_getopt(vfsp->mnt_optnew, "from", (void **)&osname, NULL))
return (SET_ERROR(EINVAL));
-#endif /* ! illumos */
+#endif /* illumos */
/*
* If full-owner-access is enabled and delegated administration is
@@ -1675,14 +1694,14 @@ zfs_mount(vfs_t *vfsp)
error = zfs_domount(vfsp, osname);
PICKUP_GIANT();
-#ifdef sun
+#ifdef illumos
/*
* Add an extra VFS_HOLD on our parent vfs so that it can't
* disappear due to a forced unmount.
*/
if (error == 0 && ((zfsvfs_t *)vfsp->vfs_data)->z_issnap)
VFS_HOLD(mvp->v_vfsp);
-#endif /* sun */
+#endif
out:
return (error);
@@ -1937,7 +1956,7 @@ zfs_umount(vfs_t *vfsp, int fflag)
return (ret);
}
-#ifdef sun
+#ifdef illumos
if (!(fflag & MS_FORCE)) {
/*
* Check the number of active vnodes in the file system.
@@ -2264,7 +2283,7 @@ zfs_freevfs(vfs_t *vfsp)
{
zfsvfs_t *zfsvfs = vfsp->vfs_data;
-#ifdef sun
+#ifdef illumos
/*
* If this is a snapshot, we have an extra VFS_HOLD on our parent
* from zfs_mount(). Release it here. If we came through
@@ -2273,7 +2292,7 @@ zfs_freevfs(vfs_t *vfsp)
*/
if (zfsvfs->z_issnap && (vfsp != rootvfs))
VFS_RELE(zfsvfs->z_parent->z_vfs);
-#endif /* sun */
+#endif
zfsvfs_free(zfsvfs);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
index 5c26efe..04e1342 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
@@ -21,7 +21,8 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2015 by Delphix. All rights reserved.
- * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
/* Portions Copyright 2007 Jeremy Teo */
@@ -334,7 +335,7 @@ zfs_ioctl(vnode_t *vp, u_long com, intptr_t data, int flag, cred_t *cred,
ZFS_EXIT(zfsvfs);
if (error)
return (error);
-#ifdef sun
+#ifdef illumos
if (ddi_copyout(&off, (void *)data, sizeof (off), flag))
return (SET_ERROR(EFAULT));
#else
@@ -763,7 +764,7 @@ zfs_read(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
ASSERT(uio->uio_loffset < zp->z_size);
n = MIN(uio->uio_resid, zp->z_size - uio->uio_loffset);
-#ifdef sun
+#ifdef illumos
if ((uio->uio_extflg == UIO_XUIO) &&
(((xuio_t *)uio)->xu_type == UIOTYPE_ZEROCOPY)) {
int nblk;
@@ -792,7 +793,7 @@ zfs_read(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
}
}
}
-#endif /* sun */
+#endif /* illumos */
while (n > 0) {
nbytes = MIN(n, zfs_read_chunk_size -
@@ -894,6 +895,16 @@ zfs_write(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
&zp->z_pflags, 8);
/*
+ * In a case vp->v_vfsp != zp->z_zfsvfs->z_vfs (e.g. snapshots) our
+ * callers might not be able to detect properly that we are read-only,
+ * so check it explicitly here.
+ */
+ if (zfsvfs->z_vfs->vfs_flag & VFS_RDONLY) {
+ ZFS_EXIT(zfsvfs);
+ return (SET_ERROR(EROFS));
+ }
+
+ /*
* If immutable or not appending then return EPERM
*/
if ((zp->z_pflags & (ZFS_IMMUTABLE | ZFS_READONLY)) ||
@@ -924,7 +935,7 @@ zfs_write(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
return (error);
}
-#ifdef sun
+#ifdef illumos
/*
* Pre-fault the pages to ensure slow (eg NFS) pages
* don't hold up txg.
@@ -935,7 +946,7 @@ zfs_write(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
xuio = (xuio_t *)uio;
else
uio_prefaultpages(MIN(n, max_blksz), uio);
-#endif /* sun */
+#endif
/*
* If in append mode, set the io offset pointer to eof.
@@ -1187,10 +1198,10 @@ zfs_write(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
ASSERT(tx_bytes == nbytes);
n -= nbytes;
-#ifdef sun
+#ifdef illumos
if (!xuio && n > 0)
uio_prefaultpages(MIN(n, max_blksz), uio);
-#endif /* sun */
+#endif
}
zfs_range_unlock(rl);
@@ -1999,12 +2010,9 @@ top:
dmu_tx_hold_zap(tx, zfsvfs->z_unlinkedobj, FALSE, NULL);
/*
- * Mark this transaction as typically resulting in a net free of
- * space, unless object removal will be delayed indefinitely
- * (due to active holds on the vnode due to the file being open).
+ * Mark this transaction as typically resulting in a net free of space
*/
- if (may_delete_now)
- dmu_tx_mark_netfree(tx);
+ dmu_tx_mark_netfree(tx);
error = dmu_tx_assign(tx, waited ? TXG_WAITED : TXG_NOWAIT);
if (error) {
@@ -2863,7 +2871,7 @@ zfs_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
mutex_enter(&zp->z_lock);
vap->va_type = IFTOVT(zp->z_mode);
vap->va_mode = zp->z_mode & ~S_IFMT;
-#ifdef sun
+#ifdef illumos
vap->va_fsid = zp->z_zfsvfs->z_vfs->vfs_dev;
#else
vap->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0];
@@ -2875,7 +2883,7 @@ zfs_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
links = zp->z_links;
vap->va_nlink = MIN(links, LINK_MAX); /* nlink_t limit! */
vap->va_size = zp->z_size;
-#ifdef sun
+#ifdef illumos
vap->va_rdev = vp->v_rdev;
#else
if (vp->v_type == VBLK || vp->v_type == VCHR)
@@ -4392,6 +4400,11 @@ zfs_link(vnode_t *tdvp, vnode_t *svp, char *name, cred_t *cr,
szp = VTOZ(svp);
ZFS_VERIFY_ZP(szp);
+ if (szp->z_pflags & (ZFS_APPENDONLY | ZFS_IMMUTABLE | ZFS_READONLY)) {
+ ZFS_EXIT(zfsvfs);
+ return (SET_ERROR(EPERM));
+ }
+
/*
* We check z_zfsvfs rather than v_vfsp here, because snapshots and the
* ctldir appear to have the same v_vfsp.
@@ -4497,7 +4510,7 @@ top:
return (error);
}
-#ifdef sun
+#ifdef illumos
/*
* zfs_null_putapage() is used when the file system has been force
* unmounted. It just drops the pages.
@@ -4725,7 +4738,7 @@ out:
ZFS_EXIT(zfsvfs);
return (error);
}
-#endif /* sun */
+#endif /* illumos */
/*ARGSUSED*/
void
@@ -4778,7 +4791,7 @@ zfs_inactive(vnode_t *vp, cred_t *cr, caller_context_t *ct)
rw_exit(&zfsvfs->z_teardown_inactive_lock);
}
-#ifdef sun
+#ifdef illumos
/*
* Bounds-check the seek operation.
*
@@ -5176,6 +5189,16 @@ zfs_space(vnode_t *vp, int cmd, flock64_t *bfp, int flag,
return (SET_ERROR(EINVAL));
}
+ /*
+ * In a case vp->v_vfsp != zp->z_zfsvfs->z_vfs (e.g. snapshots) our
+ * callers might not be able to detect properly that we are read-only,
+ * so check it explicitly here.
+ */
+ if (zfsvfs->z_vfs->vfs_flag & VFS_RDONLY) {
+ ZFS_EXIT(zfsvfs);
+ return (SET_ERROR(EROFS));
+ }
+
if (error = convoff(vp, bfp, 0, offset)) {
ZFS_EXIT(zfsvfs);
return (error);
@@ -5194,7 +5217,7 @@ zfs_space(vnode_t *vp, int cmd, flock64_t *bfp, int flag,
ZFS_EXIT(zfsvfs);
return (error);
}
-#endif /* sun */
+#endif /* illumos */
CTASSERT(sizeof(struct zfid_short) <= sizeof(struct fid));
CTASSERT(sizeof(struct zfid_long) <= sizeof(struct fid));
@@ -5282,7 +5305,7 @@ zfs_pathconf(vnode_t *vp, int cmd, ulong_t *valp, cred_t *cr,
case _PC_FILESIZEBITS:
*valp = 64;
return (0);
-#ifdef sun
+#ifdef illumos
case _PC_XATTR_EXISTS:
zp = VTOZ(vp);
zfsvfs = zp->z_zfsvfs;
@@ -5320,16 +5343,16 @@ zfs_pathconf(vnode_t *vp, int cmd, ulong_t *valp, cred_t *cr,
case _PC_ACL_ENABLED:
*valp = _ACL_ACE_ENABLED;
return (0);
-#endif /* sun */
+#endif /* illumos */
case _PC_MIN_HOLE_SIZE:
*valp = (int)SPA_MINBLOCKSIZE;
return (0);
-#ifdef sun
+#ifdef illumos
case _PC_TIMESTAMP_RESOLUTION:
/* nanosecond timestamp resolution */
*valp = 1L;
return (0);
-#endif /* sun */
+#endif
case _PC_ACL_EXTENDED:
*valp = 0;
return (0);
@@ -5388,7 +5411,7 @@ zfs_setsecattr(vnode_t *vp, vsecattr_t *vsecp, int flag, cred_t *cr,
return (error);
}
-#ifdef sun
+#ifdef illumos
/*
* The smallest read we may consider to loan out an arcbuf.
* This must be a power of 2.
@@ -5719,7 +5742,7 @@ const fs_operation_def_t zfs_evnodeops_template[] = {
VOPNAME_PATHCONF, { .vop_pathconf = zfs_pathconf },
NULL, NULL
};
-#endif /* sun */
+#endif /* illumos */
static int
ioflags(int ioflags)
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
index 749ad53..04f0b6c 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
/* Portions Copyright 2007 Jeremy Teo */
@@ -172,7 +173,7 @@ static struct {
} znode_move_stats;
#endif /* ZNODE_STATS */
-#ifdef sun
+#ifdef illumos
static void
zfs_znode_move_impl(znode_t *ozp, znode_t *nzp)
{
@@ -343,7 +344,7 @@ zfs_znode_move(void *buf, void *newbuf, size_t size, void *arg)
return (KMEM_CBRC_YES);
}
-#endif /* sun */
+#endif /* illumos */
void
zfs_znode_init(void)
@@ -362,12 +363,12 @@ zfs_znode_init(void)
void
zfs_znode_fini(void)
{
-#ifdef sun
+#ifdef illumos
/*
* Cleanup vfs & vnode ops
*/
zfs_remove_op_tables();
-#endif /* sun */
+#endif
/*
* Cleanup zcache
@@ -378,7 +379,7 @@ zfs_znode_fini(void)
rw_destroy(&zfsvfs_lock);
}
-#ifdef sun
+#ifdef illumos
struct vnodeops *zfs_dvnodeops;
struct vnodeops *zfs_fvnodeops;
struct vnodeops *zfs_symvnodeops;
@@ -470,7 +471,7 @@ zfs_create_op_tables()
return (error);
}
-#endif /* sun */
+#endif /* illumos */
int
zfs_create_share_dir(zfsvfs_t *zfsvfs, dmu_tx_t *tx)
@@ -689,7 +690,7 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz,
case VDIR:
zp->z_zn_prefetch = B_TRUE; /* z_prefetch default is enabled */
break;
-#ifdef sun
+#ifdef illumos
case VBLK:
case VCHR:
{
@@ -700,12 +701,12 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz,
vp->v_rdev = zfs_cmpldev(rdev);
}
break;
-#endif /* sun */
+#endif
case VFIFO:
-#ifdef sun
+#ifdef illumos
case VSOCK:
case VDOOR:
-#endif /* sun */
+#endif
vp->v_op = &zfs_fifoops;
break;
case VREG:
@@ -714,14 +715,14 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz,
vp->v_op = &zfs_shareops;
}
break;
-#ifdef sun
+#ifdef illumos
case VLNK:
vn_setops(vp, zfs_symvnodeops);
break;
default:
vn_setops(vp, zfs_evnodeops);
break;
-#endif /* sun */
+#endif
}
mutex_enter(&zfsvfs->z_znodes_lock);
@@ -794,7 +795,7 @@ zfs_mknode(znode_t *dzp, vattr_t *vap, dmu_tx_t *tx, cred_t *cr,
gen = vap->va_nblocks; /* ditto */
} else {
obj = 0;
- gethrestime(&now);
+ vfs_timestamp(&now);
gen = dmu_tx_get_txg(tx);
}
@@ -1175,13 +1176,13 @@ again:
*zpp = zp;
err = 0;
}
- sa_buf_rele(db, NULL);
/* Don't let the vnode disappear after ZFS_OBJ_HOLD_EXIT. */
if (err == 0)
VN_HOLD(vp);
mutex_exit(&zp->z_lock);
+ sa_buf_rele(db, NULL);
ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
if (err == 0) {
@@ -1436,7 +1437,7 @@ zfs_tstamp_update_setup(znode_t *zp, uint_t flag, uint64_t mtime[2],
{
timestruc_t now;
- gethrestime(&now);
+ vfs_timestamp(&now);
if (have_tx) { /* will sa_bulk_update happen really soon? */
zp->z_atime_dirty = 0;
@@ -1500,7 +1501,7 @@ zfs_grow_blocksize(znode_t *zp, uint64_t size, dmu_tx_t *tx)
dmu_object_size_from_db(sa_get_db(zp->z_sa_hdl), &zp->z_blksz, &dummy);
}
-#ifdef sun
+#ifdef illumos
/*
* This is a dummy interface used when pvn_vplist_dirty() should *not*
* be calling back into the fs for a putpage(). E.g.: when truncating
@@ -1514,7 +1515,7 @@ zfs_no_putpage(vnode_t *vp, page_t *pp, u_offset_t *offp, size_t *lenp,
ASSERT(0);
return (0);
}
-#endif /* sun */
+#endif
/*
* Increase the file length
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c
index 32a9ee7..0c407d7 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
/* Portions Copyright 2010 Robert Milkowski */
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
index cce7fd1..f135af70 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
@@ -22,6 +22,7 @@
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/sysmacros.h>
@@ -93,6 +94,9 @@ kmem_cache_t *zio_data_buf_cache[SPA_MAXBLOCKSIZE >> SPA_MINBLOCKSHIFT];
extern vmem_t *zio_alloc_arena;
#endif
+#define ZIO_PIPELINE_CONTINUE 0x100
+#define ZIO_PIPELINE_STOP 0x101
+
#define BP_SPANB(indblkshift, level) \
(((uint64_t)1) << ((level) * ((indblkshift) - SPA_BLKPTRSHIFT)))
#define COMPARE_META_LEVEL 0x80000000ul
@@ -1219,6 +1223,8 @@ zio_write_bp_init(zio_t *zio)
zio->io_pipeline |= ZIO_STAGE_DDT_WRITE;
return (ZIO_PIPELINE_CONTINUE);
}
+ zio->io_bp_override = NULL;
+ BP_ZERO(bp);
}
if (!BP_IS_HOLE(bp) && bp->blk_birth == zio->io_txg) {
@@ -1442,6 +1448,58 @@ zio_interrupt(zio_t *zio)
zio_taskq_dispatch(zio, ZIO_TASKQ_INTERRUPT, B_FALSE);
}
+void
+zio_delay_interrupt(zio_t *zio)
+{
+ /*
+ * The timeout_generic() function isn't defined in userspace, so
+ * rather than trying to implement the function, the zio delay
+ * functionality has been disabled for userspace builds.
+ */
+
+#ifdef _KERNEL
+ /*
+ * If io_target_timestamp is zero, then no delay has been registered
+ * for this IO, thus jump to the end of this function and "skip" the
+ * delay; issuing it directly to the zio layer.
+ */
+ if (zio->io_target_timestamp != 0) {
+ hrtime_t now = gethrtime();
+
+ if (now >= zio->io_target_timestamp) {
+ /*
+ * This IO has already taken longer than the target
+ * delay to complete, so we don't want to delay it
+ * any longer; we "miss" the delay and issue it
+ * directly to the zio layer. This is likely due to
+ * the target latency being set to a value less than
+ * the underlying hardware can satisfy (e.g. delay
+ * set to 1ms, but the disks take 10ms to complete an
+ * IO request).
+ */
+
+ DTRACE_PROBE2(zio__delay__miss, zio_t *, zio,
+ hrtime_t, now);
+
+ zio_interrupt(zio);
+ } else {
+ hrtime_t diff = zio->io_target_timestamp - now;
+
+ DTRACE_PROBE3(zio__delay__hit, zio_t *, zio,
+ hrtime_t, now, hrtime_t, diff);
+
+ (void) timeout_generic(CALLOUT_NORMAL,
+ (void (*)(void *))zio_interrupt, zio, diff, 1, 0);
+ }
+
+ return;
+ }
+#endif
+
+ DTRACE_PROBE1(zio__delay__skip, zio_t *, zio);
+ zio_interrupt(zio);
+}
+
/*
* Execute the I/O pipeline until one of the following occurs:
*
@@ -2662,6 +2720,18 @@ zio_free_zil(spa_t *spa, uint64_t txg, blkptr_t *bp)
* Read, write and delete to physical devices
* ==========================================================================
*/
+
+
+/*
+ * Issue an I/O to the underlying vdev. Typically the issue pipeline
+ * stops after this stage and will resume upon I/O completion.
+ * However, there are instances where the vdev layer may need to
+ * continue the pipeline when an I/O was not issued. Since the I/O
+ * that was sent to the vdev layer might be different than the one
+ * currently active in the pipeline (see vdev_queue_io()), we explicitly
+ * force the underlying vdev layers to call either zio_execute() or
+ * zio_interrupt() to ensure that the pipeline continues with the correct I/O.
+ */
static int
zio_vdev_io_start(zio_t *zio)
{
@@ -2680,7 +2750,8 @@ zio_vdev_io_start(zio_t *zio)
/*
* The mirror_ops handle multiple DVAs in a single BP.
*/
- return (vdev_mirror_ops.vdev_op_io_start(zio));
+ vdev_mirror_ops.vdev_op_io_start(zio);
+ return (ZIO_PIPELINE_STOP);
}
if (vd->vdev_ops->vdev_op_leaf && zio->io_type == ZIO_TYPE_FREE &&
@@ -2694,7 +2765,7 @@ zio_vdev_io_start(zio_t *zio)
* can quickly react to certain workloads. In particular, we care
* about non-scrubbing, top-level reads and writes with the following
* characteristics:
- * - synchronous writes of user data to non-slog devices
+ * - synchronous writes of user data to non-slog devices
* - any reads of user data
* When these conditions are met, adjust the timestamp of spa_last_io
* which allows the scan thread to adjust its workload accordingly.
@@ -2711,8 +2782,7 @@ zio_vdev_io_start(zio_t *zio)
align = 1ULL << vd->vdev_top->vdev_ashift;
- if ((!(zio->io_flags & ZIO_FLAG_PHYSICAL) ||
- (vd->vdev_top->vdev_physical_ashift > SPA_MINBLOCKSHIFT)) &&
+ if (!(zio->io_flags & ZIO_FLAG_PHYSICAL) &&
P2PHASE(zio->io_size, align) != 0) {
/* Transform logical writes to be a full physical block size. */
uint64_t asize = P2ROUNDUP(zio->io_size, align);
@@ -2798,10 +2868,8 @@ zio_vdev_io_start(zio_t *zio)
return (ZIO_PIPELINE_STOP);
}
- ret = vd->vdev_ops->vdev_op_io_start(zio);
- ASSERT(ret == ZIO_PIPELINE_STOP);
-
- return (ret);
+ vd->vdev_ops->vdev_op_io_start(zio);
+ return (ZIO_PIPELINE_STOP);
}
static int
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_checksum.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_checksum.c
index 6ba64e0..dac118a 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_checksum.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_checksum.c
@@ -138,10 +138,16 @@ zio_checksum_info_t zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS] = {
#endif
};
+/*
+ * The flag corresponding to the "verify" in dedup=[checksum,]verify
+ * must be cleared first, so callers should use ZIO_CHECKSUM_MASK.
+ */
spa_feature_t
zio_checksum_to_feature(enum zio_checksum cksum)
{
#ifdef illumos
+ VERIFY((cksum & ~ZIO_CHECKSUM_MASK) == 0);
+
switch (cksum) {
case ZIO_CHECKSUM_SHA512:
return (SPA_FEATURE_SHA512);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_inject.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_inject.c
index 0a7f4e4..26f59af 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_inject.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_inject.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2015 by Delphix. All rights reserved.
*/
/*
@@ -49,15 +49,53 @@
uint32_t zio_injection_enabled;
+/*
+ * Data describing each zinject handler registered on the system, and
+ * contains the list node linking the handler in the global zinject
+ * handler list.
+ */
typedef struct inject_handler {
int zi_id;
spa_t *zi_spa;
zinject_record_t zi_record;
+ uint64_t *zi_lanes;
+ int zi_next_lane;
list_node_t zi_link;
} inject_handler_t;
+/*
+ * List of all zinject handlers registered on the system, protected by
+ * the inject_lock defined below.
+ */
static list_t inject_handlers;
+
+/*
+ * This protects insertion into, and traversal of, the inject handler
+ * list defined above; as well as the inject_delay_count. Any time a
+ * handler is inserted or removed from the list, this lock should be
+ * taken as a RW_WRITER; and any time traversal is done over the list
+ * (without modification to it) this lock should be taken as a RW_READER.
+ */
static krwlock_t inject_lock;
+
+/*
+ * This holds the number of zinject delay handlers that have been
+ * registered on the system. It is protected by the inject_lock defined
+ * above. Thus modifications to this count must be a RW_WRITER of the
+ * inject_lock, and reads of this count must be (at least) a RW_READER
+ * of the lock.
+ */
+static int inject_delay_count = 0;
+
+/*
+ * This lock is used only in zio_handle_io_delay(), refer to the comment
+ * in that function for more details.
+ */
+static kmutex_t inject_delay_mtx;
+
+/*
+ * Used to assign unique identifying numbers to each new zinject handler.
+ */
static int inject_next_id = 1;
/*
@@ -360,32 +398,164 @@ spa_handle_ignored_writes(spa_t *spa)
rw_exit(&inject_lock);
}
-uint64_t
+hrtime_t
zio_handle_io_delay(zio_t *zio)
{
vdev_t *vd = zio->io_vd;
- inject_handler_t *handler;
- uint64_t seconds = 0;
-
- if (zio_injection_enabled == 0)
- return (0);
+ inject_handler_t *min_handler = NULL;
+ hrtime_t min_target = 0;
rw_enter(&inject_lock, RW_READER);
- for (handler = list_head(&inject_handlers); handler != NULL;
- handler = list_next(&inject_handlers, handler)) {
+ /*
+ * inject_delay_count is a subset of zio_injection_enabled that
+ * is only incremented for delay handlers. These checks are
+ * mainly added to remind the reader why we're not explicitly
+ * checking zio_injection_enabled like the other functions.
+ */
+ IMPLY(inject_delay_count > 0, zio_injection_enabled > 0);
+ IMPLY(zio_injection_enabled == 0, inject_delay_count == 0);
+
+ /*
+ * If there aren't any inject delay handlers registered, then we
+ * can short circuit and simply return 0 here. A value of zero
+ * informs zio_delay_interrupt() that this request should not be
+ * delayed. This short circuit keeps us from acquiring the
+ * inject_delay_mutex unnecessarily.
+ */
+ if (inject_delay_count == 0) {
+ rw_exit(&inject_lock);
+ return (0);
+ }
+
+ /*
+ * Each inject handler has a number of "lanes" associated with
+ * it. Each lane is able to handle requests independently of one
+ * another, and at a latency defined by the inject handler
+ * record's zi_timer field. Thus if a handler in configured with
+ * a single lane with a 10ms latency, it will delay requests
+ * such that only a single request is completed every 10ms. So,
+ * if more than one request is attempted per each 10ms interval,
+ * the average latency of the requests will be greater than
+ * 10ms; but if only a single request is submitted each 10ms
+ * interval the average latency will be 10ms.
+ *
+ * We need to acquire this mutex to prevent multiple concurrent
+ * threads being assigned to the same lane of a given inject
+ * handler. The mutex allows us to perform the following two
+ * operations atomically:
+ *
+ * 1. determine the minimum handler and minimum target
+ * value of all the possible handlers
+ * 2. update that minimum handler's lane array
+ *
+ * Without atomicity, two (or more) threads could pick the same
+ * lane in step (1), and then conflict with each other in step
+ * (2). This could allow a single lane handler to process
+ * multiple requests simultaneously, which shouldn't be possible.
+ */
+ mutex_enter(&inject_delay_mtx);
+ for (inject_handler_t *handler = list_head(&inject_handlers);
+ handler != NULL; handler = list_next(&inject_handlers, handler)) {
if (handler->zi_record.zi_cmd != ZINJECT_DELAY_IO)
continue;
- if (vd->vdev_guid == handler->zi_record.zi_guid) {
- seconds = handler->zi_record.zi_timer;
- break;
+ if (vd->vdev_guid != handler->zi_record.zi_guid)
+ continue;
+
+ /*
+ * Defensive; should never happen as the array allocation
+ * occurs prior to inserting this handler on the list.
+ */
+ ASSERT3P(handler->zi_lanes, !=, NULL);
+
+ /*
+ * This should never happen, the zinject command should
+ * prevent a user from setting an IO delay with zero lanes.
+ */
+ ASSERT3U(handler->zi_record.zi_nlanes, !=, 0);
+
+ ASSERT3U(handler->zi_record.zi_nlanes, >,
+ handler->zi_next_lane);
+
+ /*
+ * We want to issue this IO to the lane that will become
+ * idle the soonest, so we compare the soonest this
+ * specific handler can complete the IO with all other
+ * handlers, to find the lowest value of all possible
+ * lanes. We then use this lane to submit the request.
+ *
+ * Since each handler has a constant value for its
+ * delay, we can just use the "next" lane for that
+ * handler; as it will always be the lane with the
+ * lowest value for that particular handler (i.e. the
+ * lane that will become idle the soonest). This saves a
+ * scan of each handler's lanes array.
+ *
+ * There's two cases to consider when determining when
+ * this specific IO request should complete. If this
+ * lane is idle, we want to "submit" the request now so
+ * it will complete after zi_timer milliseconds. Thus,
+ * we set the target to now + zi_timer.
+ *
+ * If the lane is busy, we want this request to complete
+ * zi_timer milliseconds after the lane becomes idle.
+ * Since the 'zi_lanes' array holds the time at which
+ * each lane will become idle, we use that value to
+ * determine when this request should complete.
+ */
+ hrtime_t idle = handler->zi_record.zi_timer + gethrtime();
+ hrtime_t busy = handler->zi_record.zi_timer +
+ handler->zi_lanes[handler->zi_next_lane];
+ hrtime_t target = MAX(idle, busy);
+
+ if (min_handler == NULL) {
+ min_handler = handler;
+ min_target = target;
+ continue;
}
+ ASSERT3P(min_handler, !=, NULL);
+ ASSERT3U(min_target, !=, 0);
+
+ /*
+ * We don't yet increment the "next lane" variable since
+ * we still might find a lower value lane in another
+ * handler during any remaining iterations. Once we're
+ * sure we've selected the absolute minimum, we'll claim
+ * the lane and increment the handler's "next lane"
+ * field below.
+ */
+
+ if (target < min_target) {
+ min_handler = handler;
+ min_target = target;
+ }
}
+
+ /*
+ * 'min_handler' will be NULL if no IO delays are registered for
+ * this vdev, otherwise it will point to the handler containing
+ * the lane that will become idle the soonest.
+ */
+ if (min_handler != NULL) {
+ ASSERT3U(min_target, !=, 0);
+ min_handler->zi_lanes[min_handler->zi_next_lane] = min_target;
+
+ /*
+ * If we've used all possible lanes for this handler,
+ * loop back and start using the first lane again;
+ * otherwise, just increment the lane index.
+ */
+ min_handler->zi_next_lane = (min_handler->zi_next_lane + 1) %
+ min_handler->zi_record.zi_nlanes;
+ }
+
+ mutex_exit(&inject_delay_mtx);
rw_exit(&inject_lock);
- return (seconds);
+
+ return (min_target);
}
/*
@@ -409,6 +579,24 @@ zio_inject_fault(char *name, int flags, int *id, zinject_record_t *record)
if ((error = spa_reset(name)) != 0)
return (error);
+ if (record->zi_cmd == ZINJECT_DELAY_IO) {
+ /*
+ * A value of zero for the number of lanes or for the
+ * delay time doesn't make sense.
+ */
+ if (record->zi_timer == 0 || record->zi_nlanes == 0)
+ return (SET_ERROR(EINVAL));
+
+ /*
+ * The number of lanes is directly mapped to the size of
+ * an array used by the handler. Thus, to ensure the
+ * user doesn't trigger an allocation that's "too large"
+ * we cap the number of lanes here.
+ */
+ if (record->zi_nlanes >= UINT16_MAX)
+ return (SET_ERROR(EINVAL));
+ }
+
if (!(flags & ZINJECT_NULL)) {
/*
* spa_inject_ref() will add an injection reference, which will
@@ -420,11 +608,34 @@ zio_inject_fault(char *name, int flags, int *id, zinject_record_t *record)
handler = kmem_alloc(sizeof (inject_handler_t), KM_SLEEP);
+ handler->zi_spa = spa;
+ handler->zi_record = *record;
+
+ if (handler->zi_record.zi_cmd == ZINJECT_DELAY_IO) {
+ handler->zi_lanes = kmem_zalloc(
+ sizeof (*handler->zi_lanes) *
+ handler->zi_record.zi_nlanes, KM_SLEEP);
+ handler->zi_next_lane = 0;
+ } else {
+ handler->zi_lanes = NULL;
+ handler->zi_next_lane = 0;
+ }
+
rw_enter(&inject_lock, RW_WRITER);
+ /*
+ * We can't move this increment into the conditional
+ * above because we need to hold the RW_WRITER lock of
+ * inject_lock, and we don't want to hold that while
+ * allocating the handler's zi_lanes array.
+ */
+ if (handler->zi_record.zi_cmd == ZINJECT_DELAY_IO) {
+ ASSERT3S(inject_delay_count, >=, 0);
+ inject_delay_count++;
+ ASSERT3S(inject_delay_count, >, 0);
+ }
+
*id = handler->zi_id = inject_next_id++;
- handler->zi_spa = spa;
- handler->zi_record = *record;
list_insert_tail(&inject_handlers, handler);
atomic_inc_32(&zio_injection_enabled);
@@ -502,9 +713,23 @@ zio_clear_fault(int id)
return (SET_ERROR(ENOENT));
}
+ if (handler->zi_record.zi_cmd == ZINJECT_DELAY_IO) {
+ ASSERT3S(inject_delay_count, >, 0);
+ inject_delay_count--;
+ ASSERT3S(inject_delay_count, >=, 0);
+ }
+
list_remove(&inject_handlers, handler);
rw_exit(&inject_lock);
+ if (handler->zi_record.zi_cmd == ZINJECT_DELAY_IO) {
+ ASSERT3P(handler->zi_lanes, !=, NULL);
+ kmem_free(handler->zi_lanes, sizeof (*handler->zi_lanes) *
+ handler->zi_record.zi_nlanes);
+ } else {
+ ASSERT3P(handler->zi_lanes, ==, NULL);
+ }
+
spa_inject_delref(handler->zi_spa);
kmem_free(handler, sizeof (inject_handler_t));
atomic_dec_32(&zio_injection_enabled);
@@ -516,6 +741,7 @@ void
zio_inject_init(void)
{
rw_init(&inject_lock, NULL, RW_DEFAULT, NULL);
+ mutex_init(&inject_delay_mtx, NULL, MUTEX_DEFAULT, NULL);
list_create(&inject_handlers, sizeof (inject_handler_t),
offsetof(inject_handler_t, zi_link));
}
@@ -524,5 +750,6 @@ void
zio_inject_fini(void)
{
list_destroy(&inject_handlers);
+ mutex_destroy(&inject_delay_mtx);
rw_destroy(&inject_lock);
}
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
index ce8eed3..d4d10e3 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
@@ -29,6 +29,7 @@
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
/* Portions Copyright 2011 Martin Matuska <mm@FreeBSD.org> */
diff --git a/sys/cddl/contrib/opensolaris/uts/common/os/callb.c b/sys/cddl/contrib/opensolaris/uts/common/os/callb.c
index da397a5..da47908 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/os/callb.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/os/callb.c
@@ -368,7 +368,7 @@ callb_unlock_table(void)
mutex_exit(&ct->ct_lock);
}
-#ifdef sun
+#ifdef illumos
/*
* Return a boolean value indicating whether a particular kernel thread is
* stopped in accordance with the cpr callback protocol. If returning
@@ -432,7 +432,7 @@ callb_is_stopped(kthread_id_t tp, caddr_t *thread_name)
mutex_exit(&ct->ct_lock);
return (ret_val);
}
-#endif /* sun */
+#endif /* illumos */
SYSINIT(sol_callb, SI_SUB_DRIVERS, SI_ORDER_FIRST, callb_init, NULL);
SYSUNINIT(sol_callb, SI_SUB_DRIVERS, SI_ORDER_FIRST, callb_fini, NULL);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/os/fm.c b/sys/cddl/contrib/opensolaris/uts/common/os/fm.c
index 66a860d..57b2335 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/os/fm.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/os/fm.c
@@ -79,7 +79,7 @@ static const char *fm_url = "http://www.sun.com/msg";
static const char *fm_msgid = "SUNOS-8000-0G";
static char *volatile fm_panicstr = NULL;
-#ifdef sun
+#ifdef illumos
errorq_t *ereport_errorq;
#endif
void *ereport_dumpbuf;
@@ -112,7 +112,7 @@ static struct erpt_kstat erpt_kstat_data = {
{ "payload-set-failed", KSTAT_DATA_UINT64 }
};
-#ifdef sun
+#ifdef illumos
/*ARGSUSED*/
static void
fm_drain(void *private, void *data, errorq_elem_t *eep)
@@ -131,7 +131,7 @@ fm_init(void)
{
kstat_t *ksp;
-#ifdef sun
+#ifdef illumos
(void) sysevent_evc_bind(FM_ERROR_CHAN,
&ereport_chan, EVCH_CREAT | EVCH_HOLD_PEND);
@@ -145,7 +145,7 @@ fm_init(void)
if (ereport_size == 0)
ereport_size = ERPT_DATA_SZ;
-#ifdef sun
+#ifdef illumos
ereport_errorq = errorq_nvcreate("fm_ereport_queue",
(errorq_func_t)fm_drain, NULL, ereport_qlen, ereport_size,
FM_ERR_PIL, ERRORQ_VITAL);
@@ -170,7 +170,7 @@ fm_init(void)
}
}
-#ifdef sun
+#ifdef illumos
/*
* Formatting utility function for fm_nvprintr. We attempt to wrap chunks of
* output so they aren't split across console lines, and return the end column.
@@ -528,7 +528,7 @@ fm_ereport_post(nvlist_t *ereport, int evc_flag)
return;
}
-#ifdef sun
+#ifdef illumos
if (sysevent_evc_bind(FM_ERROR_CHAN, &error_chan,
EVCH_CREAT|EVCH_HOLD_PEND) != 0) {
atomic_inc_64(&erpt_kstat_data.erpt_dropped.value.ui64);
@@ -1262,7 +1262,7 @@ fm_ena_time_get(uint64_t ena)
return (time);
}
-#ifdef sun
+#ifdef illumos
/*
* Convert a getpcstack() trace to symbolic name+offset, and add the resulting
* string array to a Fault Management ereport as FM_EREPORT_PAYLOAD_NAME_STACK.
@@ -1290,7 +1290,7 @@ fm_payload_stack_add(nvlist_t *payload, const pc_t *stack, int depth)
}
#endif
-#ifdef sun
+#ifdef illumos
void
print_msg_hwerr(ctid_t ct_id, proc_t *p)
{
diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/ctf.h b/sys/cddl/contrib/opensolaris/uts/common/sys/ctf.h
index 2d1987b..5288141 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/sys/ctf.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/sys/ctf.h
@@ -27,7 +27,7 @@
#ifndef _CTF_H
#define _CTF_H
-#if defined(sun)
+#ifdef illumos
#pragma ident "%Z%%M% %I% %E% SMI"
#endif
diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/ctf_api.h b/sys/cddl/contrib/opensolaris/uts/common/sys/ctf_api.h
index 8e3f4ca..6b7ab01 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/sys/ctf_api.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/sys/ctf_api.h
@@ -69,7 +69,7 @@ typedef struct ctf_sect {
const char *cts_name; /* section name (if any) */
ulong_t cts_type; /* section type (ELF SHT_... value) */
ulong_t cts_flags; /* section flags (ELF SHF_... value) */
-#if defined(sun)
+#ifdef illumos
const void *cts_data; /* pointer to section data */
#else
void *cts_data; /* pointer to section data */
diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h
index ca73689..d449294 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h
@@ -54,7 +54,7 @@ extern "C" {
#include <sys/types.h>
#include <sys/modctl.h>
#include <sys/processor.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/systm.h>
#else
#include <sys/cpuvar.h>
@@ -65,7 +65,7 @@ extern "C" {
typedef int model_t;
#endif
#include <sys/ctf_api.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/cyclic.h>
#include <sys/int_limits.h>
#else
@@ -257,7 +257,7 @@ typedef enum dtrace_probespec {
#define DIF_VAR_ERRNO 0x0120 /* thread errno */
#define DIF_VAR_EXECARGS 0x0121 /* process arguments */
-#if !defined(sun)
+#ifndef illumos
#define DIF_VAR_CPU 0x0200
#endif
@@ -1277,7 +1277,7 @@ typedef struct dtrace_providerdesc {
* pseudodevice driver. These ioctls comprise the user-kernel interface to
* DTrace.
*/
-#if defined(sun)
+#ifdef illumos
#define DTRACEIOC (('d' << 24) | ('t' << 16) | ('r' << 8))
#define DTRACEIOC_PROVIDER (DTRACEIOC | 1) /* provider query */
#define DTRACEIOC_PROBES (DTRACEIOC | 2) /* probe query */
@@ -1408,7 +1408,7 @@ typedef struct {
* helpers and should no longer be used. No other ioctls are valid on the
* helper minor node.
*/
-#if defined(sun)
+#ifdef illumos
#define DTRACEHIOC (('d' << 24) | ('t' << 16) | ('h' << 8))
#define DTRACEHIOC_ADD (DTRACEHIOC | 1) /* add helper */
#define DTRACEHIOC_REMOVE (DTRACEHIOC | 2) /* remove helper */
@@ -1423,7 +1423,7 @@ typedef struct dof_helper {
char dofhp_mod[DTRACE_MODNAMELEN]; /* executable or library name */
uint64_t dofhp_addr; /* base address of object */
uint64_t dofhp_dof; /* address of helper DOF */
-#if !defined(sun)
+#ifndef illumos
int gen;
#endif
} dof_helper_t;
@@ -2325,7 +2325,7 @@ typedef enum dtrace_vtime_state {
DTRACE_VTIME_ACTIVE_TNF /* DTrace virtual time _and_ TNF */
} dtrace_vtime_state_t;
-#if defined(sun)
+#ifdef illumos
extern dtrace_vtime_state_t dtrace_vtime_active;
#endif
extern void dtrace_vtime_switch(kthread_t *next);
@@ -2337,7 +2337,7 @@ extern void dtrace_vtime_disable(void);
struct regs;
struct reg;
-#if defined(sun)
+#ifdef illumos
extern int (*dtrace_pid_probe_ptr)(struct reg *);
extern int (*dtrace_return_probe_ptr)(struct reg *);
extern void (*dtrace_fasttrap_fork_ptr)(proc_t *, proc_t *);
@@ -2356,7 +2356,7 @@ extern void dtrace_membar_producer(void);
extern void dtrace_membar_consumer(void);
extern void (*dtrace_cpu_init)(processorid_t);
-#if defined(sun)
+#ifdef illumos
extern void (*dtrace_modload)(modctl_t *);
extern void (*dtrace_modunload)(modctl_t *);
#endif
@@ -2370,7 +2370,7 @@ extern void (*dtrace_debugger_init)(void);
extern void (*dtrace_debugger_fini)(void);
extern dtrace_cacheid_t dtrace_predcache_id;
-#if defined(sun)
+#ifdef illumos
extern hrtime_t dtrace_gethrtime(void);
#else
void dtrace_debug_printf(const char *, ...) __printflike(1, 2);
@@ -2399,7 +2399,7 @@ extern int dtrace_blksuword32(uintptr_t, uint32_t *, int);
extern void dtrace_getfsr(uint64_t *);
#endif
-#if !defined(sun)
+#ifndef illumos
extern void dtrace_helpers_duplicate(proc_t *, proc_t *);
extern void dtrace_helpers_destroy(proc_t *);
#endif
diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h
index f9e9689..a65d1ae 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h
@@ -50,7 +50,7 @@ extern "C" {
*/
#include <sys/dtrace.h>
-#if !defined(sun)
+#ifndef illumos
#ifdef __sparcv9
typedef uint32_t pc_t;
#else
@@ -1122,7 +1122,7 @@ typedef struct dtrace_cred {
* dtrace_state structure.
*/
struct dtrace_state {
-#if defined(sun)
+#ifdef illumos
dev_t dts_dev; /* device */
#else
struct cdev *dts_dev; /* device */
@@ -1140,7 +1140,7 @@ struct dtrace_state {
int dts_nspeculations; /* number of speculations */
int dts_naggregations; /* number of aggregations */
dtrace_aggregation_t **dts_aggregations; /* aggregation array */
-#if defined(sun)
+#ifdef illumos
vmem_t *dts_aggid_arena; /* arena for aggregation IDs */
#else
struct unrhdr *dts_aggid_arena; /* arena for aggregation IDs */
@@ -1152,7 +1152,7 @@ struct dtrace_state {
uint32_t dts_dblerrors; /* errors in ERROR probes */
uint32_t dts_reserve; /* space reserved for END */
hrtime_t dts_laststatus; /* time of last status */
-#if defined(sun)
+#ifdef illumos
cyclic_id_t dts_cleaner; /* cleaning cyclic */
cyclic_id_t dts_deadman; /* deadman cyclic */
#else
@@ -1270,7 +1270,7 @@ typedef struct dtrace_toxrange {
uintptr_t dtt_limit; /* limit of toxic range */
} dtrace_toxrange_t;
-#if defined(sun)
+#ifdef illumos
extern uint64_t dtrace_getarg(int, int);
#else
extern uint64_t __noinline dtrace_getarg(int, int);
@@ -1300,7 +1300,7 @@ extern void dtrace_probe_error(dtrace_state_t *, dtrace_epid_t, int, int,
int, uintptr_t);
extern int dtrace_assfail(const char *, const char *, int);
extern int dtrace_attached(void);
-#if defined(sun)
+#ifdef illumos
extern hrtime_t dtrace_gethrestime(void);
#endif
diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap.h b/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap.h
index 431307f..ec3582f 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap.h
@@ -37,7 +37,7 @@
extern "C" {
#endif
-#if defined(sun)
+#ifdef illumos
#define FASTTRAPIOC (('m' << 24) | ('r' << 16) | ('f' << 8))
#define FASTTRAPIOC_MAKEPROBE (FASTTRAPIOC | 1)
#define FASTTRAPIOC_GETINSTR (FASTTRAPIOC | 2)
diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap_impl.h b/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap_impl.h
index 6f591fa..cae9193 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap_impl.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap_impl.h
@@ -79,7 +79,7 @@ extern "C" {
* until it exits.
*/
-#if !defined(sun)
+#ifndef illumos
typedef struct fasttrap_scrblock {
vm_offset_t ftsb_addr; /* address of a scratch block */
LIST_ENTRY(fasttrap_scrblock) ftsb_next;/* next block in list */
@@ -99,7 +99,7 @@ typedef struct fasttrap_proc {
uint64_t ftpc_rcount; /* count of extant providers */
kmutex_t ftpc_mtx; /* lock on all but acount */
struct fasttrap_proc *ftpc_next; /* next proc in hash chain */
-#if !defined(sun)
+#ifndef illumos
LIST_HEAD(, fasttrap_scrblock) ftpc_scrblks; /* mapped scratch blocks */
LIST_HEAD(, fasttrap_scrspace) ftpc_fscr; /* free scratch space */
LIST_HEAD(, fasttrap_scrspace) ftpc_ascr; /* used scratch space */
@@ -198,7 +198,7 @@ typedef struct fasttrap_hash {
#endif
extern void fasttrap_sigtrap(proc_t *, kthread_t *, uintptr_t);
-#if !defined(sun)
+#ifndef illumos
extern fasttrap_scrspace_t *fasttrap_scraddr(struct thread *,
fasttrap_proc_t *);
#endif
diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h b/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h
index 809ce9b..3818616 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h
@@ -25,6 +25,7 @@
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
* Copyright (c) 2012, Martin Matuska <mm@FreeBSD.org>. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
/* Portions Copyright 2010 Robert Milkowski */
diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/isa_defs.h b/sys/cddl/contrib/opensolaris/uts/common/sys/isa_defs.h
index f515614..29d616b 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/sys/isa_defs.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/sys/isa_defs.h
@@ -235,7 +235,7 @@ extern "C" {
/*
* Define the appropriate "processor characteristics"
*/
-#if defined(sun)
+#ifdef illumos
#define _LITTLE_ENDIAN
#endif
#define _STACK_GROWS_DOWNWARD
@@ -302,7 +302,7 @@ extern "C" {
/*
* Define the appropriate "processor characteristics"
*/
-#if defined(sun)
+#ifdef illumos
#define _LITTLE_ENDIAN
#endif
#define _STACK_GROWS_DOWNWARD
@@ -504,7 +504,7 @@ extern "C" {
* Define the appropriate "processor characteristics" shared between
* all Solaris on SPARC systems.
*/
-#if defined(sun)
+#ifdef illumos
#define _BIG_ENDIAN
#endif
#define _STACK_GROWS_DOWNWARD
diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/procset.h b/sys/cddl/contrib/opensolaris/uts/common/sys/procset.h
index 8c5739b..a7d58e5 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/sys/procset.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/sys/procset.h
@@ -143,7 +143,7 @@ typedef struct procset {
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
-#if defined(sun)
+#ifdef illumos
#ifdef _KERNEL
struct proc;
diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent.h b/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent.h
index 3558c2a..777d748 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent.h
@@ -214,7 +214,7 @@ typedef struct sysevent_value {
#define EVCH_SET_CHAN_LEN 3 /* Set event queue length */
#define EVCH_CMD_LAST EVCH_SET_CHAN_LEN /* Last command */
-#ifdef sun
+#ifdef illumos
/*
* Shared user/kernel event channel interface definitions
*/
@@ -228,11 +228,11 @@ extern int sysevent_evc_publish(evchan_t *, const char *, const char *,
extern int sysevent_evc_control(evchan_t *, int, ...);
extern int sysevent_evc_setpropnvl(evchan_t *, nvlist_t *);
extern int sysevent_evc_getpropnvl(evchan_t *, nvlist_t **);
-#endif /* sun */
+#endif /* illumos */
#ifndef _KERNEL
-#ifdef sun
+#ifdef illumos
/*
* Userland-only event channel interfaces
*/
@@ -254,7 +254,7 @@ extern void sysevent_subattr_thrsetup(sysevent_subattr_t *,
extern int sysevent_evc_xsubscribe(evchan_t *, const char *, const char *,
int (*)(sysevent_t *, void *), void *, uint32_t, sysevent_subattr_t *);
-#endif /* sun */
+#endif /* illumos */
#else
@@ -270,7 +270,7 @@ extern int sysevent_add_attr(sysevent_attr_list_t **, char *,
extern void sysevent_free_attr(sysevent_attr_list_t *);
extern int sysevent_attach_attributes(sysevent_t *, sysevent_attr_list_t *);
extern void sysevent_detach_attributes(sysevent_t *);
-#ifdef sun
+#ifdef illumos
extern char *sysevent_get_class_name(sysevent_t *);
extern char *sysevent_get_subclass_name(sysevent_t *);
extern uint64_t sysevent_get_seq(sysevent_t *);
@@ -278,7 +278,7 @@ extern void sysevent_get_time(sysevent_t *, hrtime_t *);
extern size_t sysevent_get_size(sysevent_t *);
extern char *sysevent_get_pub(sysevent_t *);
extern int sysevent_get_attr_list(sysevent_t *, nvlist_t **);
-#endif /* sun */
+#endif /* illumos */
#endif /* _KERNEL */
diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h b/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h
index 0d5a35a..aa84f36 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h
@@ -115,7 +115,7 @@ extern unsigned char bcd_to_byte[256];
#define L_MAXMIN L_MAXMIN32
#endif
-#ifdef sun
+#ifdef illumos
#ifdef _KERNEL
/* major part of a device internal to the kernel */
@@ -175,7 +175,7 @@ extern unsigned char bcd_to_byte[256];
#define getemajor(x) (major_t)((((dev_t)(x) >> L_BITSMINOR) > L_MAXMAJ) ? \
NODEV : (((dev_t)(x) >> L_BITSMINOR) & L_MAXMAJ))
#define geteminor(x) (minor_t)((x) & L_MAXMIN)
-#endif /* sun */
+#endif /* illumos */
/*
* These are versions of the kernel routines for compressing and
diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/u8_textprep.h b/sys/cddl/contrib/opensolaris/uts/common/sys/u8_textprep.h
index 77c9c0b..1496fa3 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/sys/u8_textprep.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/sys/u8_textprep.h
@@ -36,7 +36,7 @@
extern "C" {
#endif
-#ifdef sun
+#ifdef illumos
/*
* Unicode encoding conversion functions and their macros.
*/
@@ -58,7 +58,7 @@ extern int uconv_u32tou16(const uint32_t *, size_t *, uint16_t *, size_t *,
extern int uconv_u32tou8(const uint32_t *, size_t *, uchar_t *, size_t *, int);
extern int uconv_u8tou16(const uchar_t *, size_t *, uint16_t *, size_t *, int);
extern int uconv_u8tou32(const uchar_t *, size_t *, uint32_t *, size_t *, int);
-#endif /* sun */
+#endif /* illumos */
/*
* UTF-8 text preparation functions and their macros.
diff --git a/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c b/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c
index 8df1090..5d60a07 100644
--- a/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c
+++ b/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c
@@ -28,7 +28,7 @@
* Use is subject to license terms.
*/
-#if defined(sun)
+#ifdef illumos
#pragma ident "%Z%%M% %I% %E% SMI"
#endif
@@ -37,7 +37,7 @@
#include <sys/dtrace.h>
#include <sys/dtrace_impl.h>
#include <sys/cmn_err.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/regset.h>
#include <sys/privregs.h>
#include <sys/segments.h>
@@ -53,7 +53,7 @@
#include <machine/pcb.h>
#endif
#include <sys/sysmacros.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/trap.h>
#include <sys/archsystm.h>
#else
@@ -97,7 +97,7 @@ uwrite(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr)
return (proc_ops(UIO_WRITE, p, kaddr, uaddr, len));
}
-#endif /* sun */
+#endif /* illumos */
#ifdef __i386__
#define r_rax r_eax
#define r_rbx r_ebx
@@ -747,11 +747,11 @@ fasttrap_return_common(struct reg *rp, uintptr_t pc, pid_t pid,
fasttrap_tracepoint_t *tp;
fasttrap_bucket_t *bucket;
fasttrap_id_t *id;
-#if defined(sun)
+#ifdef illumos
kmutex_t *pid_mtx;
#endif
-#if defined(sun)
+#ifdef illumos
pid_mtx = &cpu_core[CPU->cpu_id].cpuc_pid_lock;
mutex_enter(pid_mtx);
#endif
@@ -769,7 +769,7 @@ fasttrap_return_common(struct reg *rp, uintptr_t pc, pid_t pid,
* is not essential to the correct execution of the process.
*/
if (tp == NULL) {
-#if defined(sun)
+#ifdef illumos
mutex_exit(pid_mtx);
#endif
return;
@@ -792,7 +792,7 @@ fasttrap_return_common(struct reg *rp, uintptr_t pc, pid_t pid,
rp->r_rax, rp->r_rbx, 0, 0);
}
-#if defined(sun)
+#ifdef illumos
mutex_exit(pid_mtx);
#endif
}
@@ -800,7 +800,7 @@ fasttrap_return_common(struct reg *rp, uintptr_t pc, pid_t pid,
static void
fasttrap_sigsegv(proc_t *p, kthread_t *t, uintptr_t addr)
{
-#if defined(sun)
+#ifdef illumos
sigqueue_t *sqp = kmem_zalloc(sizeof (sigqueue_t), KM_SLEEP);
sqp->sq_info.si_signo = SIGSEGV;
@@ -1001,13 +1001,13 @@ int
fasttrap_pid_probe(struct reg *rp)
{
proc_t *p = curproc;
-#if !defined(sun)
+#ifndef illumos
proc_t *pp;
#endif
uintptr_t pc = rp->r_rip - 1;
uintptr_t new_pc = 0;
fasttrap_bucket_t *bucket;
-#if defined(sun)
+#ifdef illumos
kmutex_t *pid_mtx;
#endif
fasttrap_tracepoint_t *tp, tp_local;
@@ -1044,7 +1044,7 @@ fasttrap_pid_probe(struct reg *rp)
* parent. We know that there's only one thread of control in such a
* process: this one.
*/
-#if defined(sun)
+#ifdef illumos
while (p->p_flag & SVFORK) {
p = p->p_parent;
}
@@ -1082,7 +1082,7 @@ fasttrap_pid_probe(struct reg *rp)
* fasttrap_ioctl), or somehow we have mislaid this tracepoint.
*/
if (tp == NULL) {
-#if defined(sun)
+#ifdef illumos
mutex_exit(pid_mtx);
#else
_PRELE(p);
@@ -1209,7 +1209,7 @@ fasttrap_pid_probe(struct reg *rp)
* tracepoint again later if we need to light up any return probes.
*/
tp_local = *tp;
-#if defined(sun)
+#ifdef illumos
mutex_exit(pid_mtx);
#else
PROC_UNLOCK(p);
@@ -1537,7 +1537,7 @@ fasttrap_pid_probe(struct reg *rp)
uint8_t scratch[2 * FASTTRAP_MAX_INSTR_SIZE + 7];
#endif
uint_t i = 0;
-#if defined(sun)
+#ifdef illumos
klwp_t *lwp = ttolwp(curthread);
/*
@@ -1558,7 +1558,7 @@ fasttrap_pid_probe(struct reg *rp)
addr = USD_GETBASE(&lwp->lwp_pcb.pcb_gsdesc);
addr += sizeof (void *);
#endif
-#else
+#else /* !illumos */
fasttrap_scrspace_t *scrspace;
scrspace = fasttrap_scraddr(curthread, tp->ftt_proc);
if (scrspace == NULL) {
@@ -1574,7 +1574,7 @@ fasttrap_pid_probe(struct reg *rp)
break;
}
addr = scrspace->ftss_addr;
-#endif /* sun */
+#endif /* illumos */
/*
* Generic Instruction Tracing
@@ -1760,7 +1760,7 @@ fasttrap_pid_probe(struct reg *rp)
ASSERT(i <= sizeof (scratch));
-#if defined(sun)
+#ifdef illumos
if (fasttrap_copyout(scratch, (char *)addr, i)) {
#else
if (uwrite(p, scratch, i, addr)) {
@@ -1822,7 +1822,7 @@ done:
rp->r_rip = new_pc;
-#if !defined(sun)
+#ifndef illumos
PROC_LOCK(p);
proc_write_regs(curthread, rp);
_PRELE(p);
@@ -1844,7 +1844,7 @@ fasttrap_return_probe(struct reg *rp)
curthread->t_dtrace_scrpc = 0;
curthread->t_dtrace_astpc = 0;
-#if defined(sun)
+#ifdef illumos
/*
* Treat a child created by a call to vfork(2) as if it were its
* parent. We know that there's only one thread of control in such a
@@ -1917,7 +1917,7 @@ fasttrap_getreg(struct reg *rp, uint_t reg)
case REG_ERR: return (rp->r_err);
case REG_RIP: return (rp->r_rip);
case REG_CS: return (rp->r_cs);
-#if defined(sun)
+#ifdef illumos
case REG_RFL: return (rp->r_rfl);
#endif
case REG_RSP: return (rp->r_rsp);
diff --git a/sys/cddl/dev/dtrace/amd64/instr_size.c b/sys/cddl/dev/dtrace/amd64/instr_size.c
index 1acf2c5..b3afcb7 100644
--- a/sys/cddl/dev/dtrace/amd64/instr_size.c
+++ b/sys/cddl/dev/dtrace/amd64/instr_size.c
@@ -30,14 +30,14 @@
/* All Rights Reserved */
-#if defined(sun)
+#ifdef illumos
#pragma ident "@(#)instr_size.c 1.14 05/07/08 SMI"
#endif
#include <sys/types.h>
#include <sys/param.h>
#include <sys/proc.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/cmn_err.h>
#include <sys/archsystm.h>
#include <sys/copyops.h>
@@ -104,7 +104,7 @@ dtrace_dis_isize(uchar_t *instr, dis_isize_t which, model_t model, int *rmindex)
dis86_t x;
uint_t mode = SIZE64;
-#if defined(sun)
+#ifdef illumos
mode = (model == DATAMODEL_LP64) ? SIZE64 : SIZE32;
#endif
diff --git a/sys/cddl/dev/dtrace/dtrace_ioctl.c b/sys/cddl/dev/dtrace/dtrace_ioctl.c
index e261091..ef9bed5 100644
--- a/sys/cddl/dev/dtrace/dtrace_ioctl.c
+++ b/sys/cddl/dev/dtrace/dtrace_ioctl.c
@@ -578,14 +578,14 @@ dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
return (EINVAL);
mutex_enter(&dtrace_provider_lock);
-#if defined(sun)
+#ifdef illumos
mutex_enter(&mod_lock);
#endif
mutex_enter(&dtrace_lock);
if (desc->dtargd_id > dtrace_nprobes) {
mutex_exit(&dtrace_lock);
-#if defined(sun)
+#ifdef illumos
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_provider_lock);
@@ -594,7 +594,7 @@ dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
if ((probe = dtrace_probes[desc->dtargd_id - 1]) == NULL) {
mutex_exit(&dtrace_lock);
-#if defined(sun)
+#ifdef illumos
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_provider_lock);
@@ -620,7 +620,7 @@ dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
probe->dtpr_id, probe->dtpr_arg, desc);
}
-#if defined(sun)
+#ifdef illumos
mutex_exit(&mod_lock);
#endif
mutex_exit(&dtrace_provider_lock);
@@ -779,7 +779,7 @@ dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
dstate = &state->dts_vstate.dtvs_dynvars;
for (i = 0; i < NCPU; i++) {
-#if !defined(sun)
+#ifndef illumos
if (pcpu_find(i) == NULL)
continue;
#endif
diff --git a/sys/cddl/dev/dtrace/i386/instr_size.c b/sys/cddl/dev/dtrace/i386/instr_size.c
index 7f667f7..11fbf9b 100644
--- a/sys/cddl/dev/dtrace/i386/instr_size.c
+++ b/sys/cddl/dev/dtrace/i386/instr_size.c
@@ -30,14 +30,14 @@
/* All Rights Reserved */
-#if defined(sun)
+#ifdef illumos
#pragma ident "@(#)instr_size.c 1.14 05/07/08 SMI"
#endif
#include <sys/types.h>
#include <sys/param.h>
#include <sys/proc.h>
-#if defined(sun)
+#ifdef illumos
#include <sys/cmn_err.h>
#include <sys/archsystm.h>
#include <sys/copyops.h>
@@ -104,7 +104,7 @@ dtrace_dis_isize(uchar_t *instr, dis_isize_t which, model_t model, int *rmindex)
dis86_t x;
uint_t mode = SIZE32;
-#if defined(sun)
+#ifdef illumos
mode = (model == DATAMODEL_LP64) ? SIZE64 : SIZE32;
#endif
diff --git a/sys/cddl/dev/dtrace/x86/regset.h b/sys/cddl/dev/dtrace/x86/regset.h
index b1c5116..ad12e26 100644
--- a/sys/cddl/dev/dtrace/x86/regset.h
+++ b/sys/cddl/dev/dtrace/x86/regset.h
@@ -61,7 +61,7 @@ extern "C" {
#define REG_GSBASE 27
#define REG_FSBASE 26
-#if defined(sun)
+#ifdef illumos
#define REG_DS 25
#define REG_ES 24
@@ -89,7 +89,7 @@ extern "C" {
#define REG_R13 2
#define REG_R14 1
#define REG_R15 0
-#else
+#else /* !illumos */
#define REG_SS 25
#define REG_RSP 24
#define REG_RFL 23
@@ -116,13 +116,13 @@ extern "C" {
#define REG_R13 2
#define REG_R14 1
#define REG_R15 0
-#endif
+#endif /* illumos */
/*
* The names and offsets defined here are specified by i386 ABI suppl.
*/
-#if defined(sun)
+#ifdef illumos
#define SS 18 /* only stored on a privilege transition */
#define UESP 17 /* only stored on a privilege transition */
#define EFL 16
@@ -142,7 +142,7 @@ extern "C" {
#define ES 2
#define FS 1
#define GS 0
-#else
+#else /* !illumos */
#define GS 18
#define SS 17 /* only stored on a privilege transition */
#define UESP 16 /* only stored on a privilege transition */
@@ -162,7 +162,7 @@ extern "C" {
#define DS 2
#define ES 1
#define FS 0
-#endif
+#endif /* illumos */
#define REG_PC EIP
#define REG_FP EBP
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index de4a380..3dfb53f 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -3250,6 +3250,12 @@ cxgbe_uninit_synchronized(struct port_info *pi)
ASSERT_SYNCHRONIZED_OP(sc);
+ if (!(pi->flags & PORT_INIT_DONE)) {
+ KASSERT(!(ifp->if_drv_flags & IFF_DRV_RUNNING),
+ ("uninited port is running"));
+ return (0);
+ }
+
/*
* Disable the VI so that all its data in either direction is discarded
* by the MPS. Leave everything else (the queues, interrupts, and 1Hz
diff --git a/sys/dev/drm2/drm_drv.c b/sys/dev/drm2/drm_drv.c
index f4431a7..3b46253 100644
--- a/sys/dev/drm2/drm_drv.c
+++ b/sys/dev/drm2/drm_drv.c
@@ -386,17 +386,21 @@ int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
switch (cmd) {
case FIONBIO:
case FIOASYNC:
+ atomic_dec(&dev->ioctl_count);
return 0;
case FIOSETOWN:
+ atomic_dec(&dev->ioctl_count);
return fsetown(*(int *)data, &file_priv->minor->buf_sigio);
case FIOGETOWN:
+ atomic_dec(&dev->ioctl_count);
*(int *) data = fgetown(&file_priv->minor->buf_sigio);
return 0;
}
if (IOCGROUP(cmd) != DRM_IOCTL_BASE) {
+ atomic_dec(&dev->ioctl_count);
DRM_DEBUG("Bad ioctl group 0x%x\n", (int)IOCGROUP(cmd));
return EINVAL;
}
diff --git a/sys/dev/mrsas/mrsas.c b/sys/dev/mrsas/mrsas.c
index 3e6dbe8..6fa4639 100644
--- a/sys/dev/mrsas/mrsas.c
+++ b/sys/dev/mrsas/mrsas.c
@@ -1272,14 +1272,12 @@ mrsas_get_softc_instance(struct cdev *dev, u_long cmd, caddr_t arg)
* Application
*/
sc = mrsas_mgmt_info.sc_ptr[user_ioc->host_no];
- if ((user_ioc->host_no >= mrsas_mgmt_info.max_index) || (sc == NULL)) {
- if (sc == NULL)
- mrsas_dprint(sc, MRSAS_FAULT,
- "There is no Controller number %d .\n", user_ioc->host_no);
- else
- mrsas_dprint(sc, MRSAS_FAULT,
- "Invalid Controller number %d .\n", user_ioc->host_no);
- }
+ if (sc == NULL)
+ printf("There is no Controller number %d\n",
+ user_ioc->host_no);
+ else if (user_ioc->host_no >= mrsas_mgmt_info.max_index)
+ mrsas_dprint(sc, MRSAS_FAULT,
+ "Invalid Controller number %d\n", user_ioc->host_no);
}
return sc;
@@ -4018,8 +4016,8 @@ mrsas_aen_handler(struct mrsas_softc *sc)
u_int32_t seq_num;
int error;
- if (!sc) {
- device_printf(sc->mrsas_dev, "invalid instance!\n");
+ if (sc == NULL) {
+ printf("invalid instance!\n");
return;
}
if (sc->evt_detail_mem) {
diff --git a/sys/dev/nvd/nvd.c b/sys/dev/nvd/nvd.c
index e062f57..989ed92 100644
--- a/sys/dev/nvd/nvd.c
+++ b/sys/dev/nvd/nvd.c
@@ -311,7 +311,7 @@ nvd_new_disk(struct nvme_namespace *ns, void *ctrlr_arg)
disk->d_delmaxsize = (off_t)nvme_ns_get_size(ns);
if (disk->d_delmaxsize > nvd_delete_max)
disk->d_delmaxsize = nvd_delete_max;
- disk->d_stripesize = nvme_ns_get_optimal_sector_size(ns);
+ disk->d_stripesize = nvme_ns_get_stripesize(ns);
if (TAILQ_EMPTY(&disk_head))
disk->d_unit = 0;
diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h
index 227a89e..7e41e77 100644
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -870,7 +870,6 @@ const char * nvme_ns_get_serial_number(struct nvme_namespace *ns);
const char * nvme_ns_get_model_number(struct nvme_namespace *ns);
const struct nvme_namespace_data *
nvme_ns_get_data(struct nvme_namespace *ns);
-uint32_t nvme_ns_get_optimal_sector_size(struct nvme_namespace *ns);
uint32_t nvme_ns_get_stripesize(struct nvme_namespace *ns);
int nvme_ns_bio_process(struct nvme_namespace *ns, struct bio *bp,
diff --git a/sys/dev/nvme/nvme_ns.c b/sys/dev/nvme/nvme_ns.c
index 4580e66..754d074 100644
--- a/sys/dev/nvme/nvme_ns.c
+++ b/sys/dev/nvme/nvme_ns.c
@@ -45,8 +45,6 @@ __FBSDID("$FreeBSD$");
#include "nvme_private.h"
-extern int nvme_max_optimal_sectorsize;
-
static void nvme_bio_child_inbed(struct bio *parent, int bio_error);
static void nvme_bio_child_done(void *arg,
const struct nvme_completion *cpl);
@@ -219,22 +217,6 @@ nvme_ns_get_stripesize(struct nvme_namespace *ns)
return (ns->stripesize);
}
-uint32_t
-nvme_ns_get_optimal_sector_size(struct nvme_namespace *ns)
-{
- uint32_t stripesize;
-
- stripesize = nvme_ns_get_stripesize(ns);
-
- if (stripesize == 0)
- return nvme_ns_get_sector_size(ns);
-
- if (nvme_max_optimal_sectorsize == 0)
- return (stripesize);
-
- return (MIN(stripesize, nvme_max_optimal_sectorsize));
-}
-
static void
nvme_ns_bio_done(void *arg, const struct nvme_completion *status)
{
diff --git a/sys/dev/nvme/nvme_sysctl.c b/sys/dev/nvme/nvme_sysctl.c
index 08cd15e..44b0ab7 100644
--- a/sys/dev/nvme/nvme_sysctl.c
+++ b/sys/dev/nvme/nvme_sysctl.c
@@ -33,22 +33,6 @@ __FBSDID("$FreeBSD$");
#include "nvme_private.h"
-SYSCTL_NODE(_kern, OID_AUTO, nvme, CTLFLAG_RD, 0, "NVM Express");
-/*
- * Intel NVMe controllers have a slow path for I/Os that span a 128KB
- * stripe boundary but ZFS limits ashift, which is derived from
- * d_stripesize, to 13 (8KB) so we limit the stripesize reported to
- * geom(8) to 4KB by default.
- *
- * This may result in a small number of additional I/Os to require
- * splitting in nvme(4), however the NVMe I/O path is very efficient
- * so these additional I/Os will cause very minimal (if any) difference
- * in performance or CPU utilisation.
- */
-int nvme_max_optimal_sectorsize = 1<<12;
-SYSCTL_INT(_kern_nvme, OID_AUTO, max_optimal_sectorsize, CTLFLAG_RWTUN,
- &nvme_max_optimal_sectorsize, 0, "The maximum optimal sectorsize reported");
-
/*
* CTLTYPE_S64 and sysctl_handle_64 were added in r217616. Define these
* explicitly here for older kernels that don't include the r217616
diff --git a/sys/dev/qlxgb/qla_hw.c b/sys/dev/qlxgb/qla_hw.c
index e9c635d..d71bb29 100644
--- a/sys/dev/qlxgb/qla_hw.c
+++ b/sys/dev/qlxgb/qla_hw.c
@@ -797,7 +797,8 @@ qla_tx_tso(qla_host_t *ha, struct mbuf *mp, q80_tx_cmd_t *tx_cmd, uint8_t *hdr)
}
if ((*tcp_opt != 0x01) || (*(tcp_opt + 1) != 0x01) ||
- (*(tcp_opt + 2) != 0x08) || (*(tcp_opt + 2) != 10)) {
+ (*(tcp_opt + 2) != 0x08) ||
+ (*(tcp_opt + 3) != 10)) {
return -1;
}
}
diff --git a/sys/fs/ext2fs/ext2_vnops.c b/sys/fs/ext2fs/ext2_vnops.c
index eea65d2..29229ef 100644
--- a/sys/fs/ext2fs/ext2_vnops.c
+++ b/sys/fs/ext2fs/ext2_vnops.c
@@ -464,16 +464,14 @@ ext2_setattr(struct vop_setattr_args *ap)
((vap->va_vaflags & VA_UTIMES_NULL) == 0 ||
(error = VOP_ACCESS(vp, VWRITE, cred, td))))
return (error);
- if (vap->va_atime.tv_sec != VNOVAL)
- ip->i_flag |= IN_ACCESS;
- if (vap->va_mtime.tv_sec != VNOVAL)
- ip->i_flag |= IN_CHANGE | IN_UPDATE;
- ext2_itimes(vp);
+ ip->i_flag |= IN_CHANGE | IN_MODIFIED;
if (vap->va_atime.tv_sec != VNOVAL) {
+ ip->i_flag &= ~IN_ACCESS;
ip->i_atime = vap->va_atime.tv_sec;
ip->i_atimensec = vap->va_atime.tv_nsec;
}
if (vap->va_mtime.tv_sec != VNOVAL) {
+ ip->i_flag &= ~IN_UPDATE;
ip->i_mtime = vap->va_mtime.tv_sec;
ip->i_mtimensec = vap->va_mtime.tv_nsec;
}
diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c
index 0aa1326..a578049 100644
--- a/sys/kern/link_elf_obj.c
+++ b/sys/kern/link_elf_obj.c
@@ -140,7 +140,7 @@ static int link_elf_each_function_name(linker_file_t,
static int link_elf_each_function_nameval(linker_file_t,
linker_function_nameval_callback_t,
void *);
-static void link_elf_reloc_local(linker_file_t);
+static int link_elf_reloc_local(linker_file_t);
static long link_elf_symtab_get(linker_file_t, const Elf_Sym **);
static long link_elf_strtab_get(linker_file_t, caddr_t *);
@@ -401,15 +401,26 @@ link_elf_link_preload(linker_class_t cls, const char *filename,
break;
}
}
- if (pb != ef->nprogtab)
- panic("lost progbits");
- if (rl != ef->nreltab)
- panic("lost reltab");
- if (ra != ef->nrelatab)
- panic("lost relatab");
+ if (pb != ef->nprogtab) {
+ printf("%s: lost progbits\n", filename);
+ error = ENOEXEC;
+ goto out;
+ }
+ if (rl != ef->nreltab) {
+ printf("%s: lost reltab\n", filename);
+ error = ENOEXEC;
+ goto out;
+ }
+ if (ra != ef->nrelatab) {
+ printf("%s: lost relatab\n", filename);
+ error = ENOEXEC;
+ goto out;
+ }
/* Local intra-module relocations */
- link_elf_reloc_local(lf);
+ error = link_elf_reloc_local(lf);
+ if (error != 0)
+ goto out;
*result = lf;
return (0);
@@ -612,8 +623,11 @@ link_elf_load_file(linker_class_t cls, const char *filename,
ef->relatab = malloc(ef->nrelatab * sizeof(*ef->relatab),
M_LINKER, M_WAITOK | M_ZERO);
- if (symtabindex == -1)
- panic("lost symbol table index");
+ if (symtabindex == -1) {
+ link_elf_error(filename, "lost symbol table index");
+ error = ENOEXEC;
+ goto out;
+ }
/* Allocate space for and load the symbol table */
ef->ddbsymcnt = shdr[symtabindex].sh_size / sizeof(Elf_Sym);
ef->ddbsymtab = malloc(shdr[symtabindex].sh_size, M_LINKER, M_WAITOK);
@@ -628,8 +642,11 @@ link_elf_load_file(linker_class_t cls, const char *filename,
goto out;
}
- if (symstrindex == -1)
- panic("lost symbol string index");
+ if (symstrindex == -1) {
+ link_elf_error(filename, "lost symbol string index");
+ error = ENOEXEC;
+ goto out;
+ }
/* Allocate space for and load the symbol strings */
ef->ddbstrcnt = shdr[symstrindex].sh_size;
ef->ddbstrtab = malloc(shdr[symstrindex].sh_size, M_LINKER, M_WAITOK);
@@ -858,19 +875,35 @@ link_elf_load_file(linker_class_t cls, const char *filename,
break;
}
}
- if (pb != ef->nprogtab)
- panic("lost progbits");
- if (rl != ef->nreltab)
- panic("lost reltab");
- if (ra != ef->nrelatab)
- panic("lost relatab");
- if (mapbase != (vm_offset_t)ef->address + mapsize)
- panic("mapbase 0x%lx != address %p + mapsize 0x%lx (0x%lx)\n",
+ if (pb != ef->nprogtab) {
+ link_elf_error(filename, "lost progbits");
+ error = ENOEXEC;
+ goto out;
+ }
+ if (rl != ef->nreltab) {
+ link_elf_error(filename, "lost reltab");
+ error = ENOEXEC;
+ goto out;
+ }
+ if (ra != ef->nrelatab) {
+ link_elf_error(filename, "lost relatab");
+ error = ENOEXEC;
+ goto out;
+ }
+ if (mapbase != (vm_offset_t)ef->address + mapsize) {
+ printf(
+ "%s: mapbase 0x%lx != address %p + mapsize 0x%lx (0x%lx)\n",
+ filename != NULL ? filename : "<none>",
(u_long)mapbase, ef->address, (u_long)mapsize,
(u_long)(vm_offset_t)ef->address + mapsize);
+ error = ENOMEM;
+ goto out;
+ }
/* Local intra-module relocations */
- link_elf_reloc_local(lf);
+ error = link_elf_reloc_local(lf);
+ if (error != 0)
+ goto out;
/* Pull in dependencies */
VOP_UNLOCK(nd.ni_vp, 0);
@@ -1005,12 +1038,16 @@ relocate_file(elf_file_t ef)
/* Perform relocations without addend if there are any: */
for (i = 0; i < ef->nreltab; i++) {
rel = ef->reltab[i].rel;
- if (rel == NULL)
- panic("lost a reltab!");
+ if (rel == NULL) {
+ link_elf_error(ef->lf.filename, "lost a reltab!");
+ return (ENOEXEC);
+ }
rellim = rel + ef->reltab[i].nrel;
base = findbase(ef, ef->reltab[i].sec);
- if (base == 0)
- panic("lost base for reltab");
+ if (base == 0) {
+ link_elf_error(ef->lf.filename, "lost base for reltab");
+ return (ENOEXEC);
+ }
for ( ; rel < rellim; rel++) {
symidx = ELF_R_SYM(rel->r_info);
if (symidx >= ef->ddbsymcnt)
@@ -1024,7 +1061,7 @@ relocate_file(elf_file_t ef)
symname = symbol_name(ef, rel->r_info);
printf("link_elf_obj: symbol %s undefined\n",
symname);
- return ENOENT;
+ return (ENOENT);
}
}
}
@@ -1032,12 +1069,17 @@ relocate_file(elf_file_t ef)
/* Perform relocations with addend if there are any: */
for (i = 0; i < ef->nrelatab; i++) {
rela = ef->relatab[i].rela;
- if (rela == NULL)
- panic("lost a relatab!");
+ if (rela == NULL) {
+ link_elf_error(ef->lf.filename, "lost a relatab!");
+ return (ENOEXEC);
+ }
relalim = rela + ef->relatab[i].nrela;
base = findbase(ef, ef->relatab[i].sec);
- if (base == 0)
- panic("lost base for relatab");
+ if (base == 0) {
+ link_elf_error(ef->lf.filename,
+ "lost base for relatab");
+ return (ENOEXEC);
+ }
for ( ; rela < relalim; rela++) {
symidx = ELF_R_SYM(rela->r_info);
if (symidx >= ef->ddbsymcnt)
@@ -1051,7 +1093,7 @@ relocate_file(elf_file_t ef)
symname = symbol_name(ef, rela->r_info);
printf("link_elf_obj: symbol %s undefined\n",
symname);
- return ENOENT;
+ return (ENOENT);
}
}
}
@@ -1063,7 +1105,7 @@ relocate_file(elf_file_t ef)
*/
elf_obj_cleanup_globals_cache(ef);
- return 0;
+ return (0);
}
static int
@@ -1346,7 +1388,7 @@ link_elf_fix_link_set(elf_file_t ef)
}
}
-static void
+static int
link_elf_reloc_local(linker_file_t lf)
{
elf_file_t ef = (elf_file_t)lf;
@@ -1364,12 +1406,16 @@ link_elf_reloc_local(linker_file_t lf)
/* Perform relocations without addend if there are any: */
for (i = 0; i < ef->nreltab; i++) {
rel = ef->reltab[i].rel;
- if (rel == NULL)
- panic("lost a reltab!");
+ if (rel == NULL) {
+ link_elf_error(ef->lf.filename, "lost a reltab");
+ return (ENOEXEC);
+ }
rellim = rel + ef->reltab[i].nrel;
base = findbase(ef, ef->reltab[i].sec);
- if (base == 0)
- panic("lost base for reltab");
+ if (base == 0) {
+ link_elf_error(ef->lf.filename, "lost base for reltab");
+ return (ENOEXEC);
+ }
for ( ; rel < rellim; rel++) {
symidx = ELF_R_SYM(rel->r_info);
if (symidx >= ef->ddbsymcnt)
@@ -1386,12 +1432,16 @@ link_elf_reloc_local(linker_file_t lf)
/* Perform relocations with addend if there are any: */
for (i = 0; i < ef->nrelatab; i++) {
rela = ef->relatab[i].rela;
- if (rela == NULL)
- panic("lost a relatab!");
+ if (rela == NULL) {
+ link_elf_error(ef->lf.filename, "lost a relatab!");
+ return (ENOEXEC);
+ }
relalim = rela + ef->relatab[i].nrela;
base = findbase(ef, ef->relatab[i].sec);
- if (base == 0)
- panic("lost base for relatab");
+ if (base == 0) {
+ link_elf_error(ef->lf.filename, "lost base for reltab");
+ return (ENOEXEC);
+ }
for ( ; rela < relalim; rela++) {
symidx = ELF_R_SYM(rela->r_info);
if (symidx >= ef->ddbsymcnt)
@@ -1404,6 +1454,7 @@ link_elf_reloc_local(linker_file_t lf)
elf_obj_lookup);
}
}
+ return (0);
}
static long
diff --git a/sys/kern/subr_sglist.c b/sys/kern/subr_sglist.c
index c66973a..df88a26 100644
--- a/sys/kern/subr_sglist.c
+++ b/sys/kern/subr_sglist.c
@@ -216,6 +216,9 @@ void
sglist_free(struct sglist *sg)
{
+ if (sg == NULL)
+ return;
+
if (refcount_release(&sg->sg_refs))
free(sg, M_SGLIST);
}
diff --git a/sys/kern/subr_taskqueue.c b/sys/kern/subr_taskqueue.c
index f104bb5..bfc941e 100644
--- a/sys/kern/subr_taskqueue.c
+++ b/sys/kern/subr_taskqueue.c
@@ -46,6 +46,9 @@ __FBSDID("$FreeBSD$");
static MALLOC_DEFINE(M_TASKQUEUE, "taskqueue", "Task Queues");
static void *taskqueue_giant_ih;
static void *taskqueue_ih;
+static void taskqueue_fast_enqueue(void *);
+static void taskqueue_swi_enqueue(void *);
+static void taskqueue_swi_giant_enqueue(void *);
struct taskqueue_busy {
struct task *tb_running;
@@ -69,7 +72,7 @@ struct taskqueue {
#define TQ_FLAGS_ACTIVE (1 << 0)
#define TQ_FLAGS_BLOCKED (1 << 1)
-#define TQ_FLAGS_PENDING (1 << 2)
+#define TQ_FLAGS_UNLOCKED_ENQUEUE (1 << 2)
#define DT_CALLOUT_ARMED (1 << 0)
@@ -97,7 +100,8 @@ _timeout_task_init(struct taskqueue *queue, struct timeout_task *timeout_task,
{
TASK_INIT(&timeout_task->t, priority, func, context);
- callout_init_mtx(&timeout_task->c, &queue->tq_mutex, 0);
+ callout_init_mtx(&timeout_task->c, &queue->tq_mutex,
+ CALLOUT_RETURNUNLOCKED);
timeout_task->q = queue;
timeout_task->f = 0;
}
@@ -128,6 +132,11 @@ _taskqueue_create(const char *name __unused, int mflags,
queue->tq_context = context;
queue->tq_spin = (mtxflags & MTX_SPIN) != 0;
queue->tq_flags |= TQ_FLAGS_ACTIVE;
+ if (enqueue == taskqueue_fast_enqueue ||
+ enqueue == taskqueue_swi_enqueue ||
+ enqueue == taskqueue_swi_giant_enqueue ||
+ enqueue == taskqueue_thread_enqueue)
+ queue->tq_flags |= TQ_FLAGS_UNLOCKED_ENQUEUE;
mtx_init(&queue->tq_mutex, mtxname, NULL, mtxflags);
return queue;
@@ -197,6 +206,7 @@ taskqueue_enqueue_locked(struct taskqueue *queue, struct task *task)
if (task->ta_pending) {
if (task->ta_pending < USHRT_MAX)
task->ta_pending++;
+ TQ_UNLOCK(queue);
return (0);
}
@@ -220,11 +230,14 @@ taskqueue_enqueue_locked(struct taskqueue *queue, struct task *task)
}
task->ta_pending = 1;
+ if ((queue->tq_flags & TQ_FLAGS_UNLOCKED_ENQUEUE) != 0)
+ TQ_UNLOCK(queue);
if ((queue->tq_flags & TQ_FLAGS_BLOCKED) == 0)
queue->tq_enqueue(queue->tq_context);
- else
- queue->tq_flags |= TQ_FLAGS_PENDING;
+ if ((queue->tq_flags & TQ_FLAGS_UNLOCKED_ENQUEUE) == 0)
+ TQ_UNLOCK(queue);
+ /* Return with lock released. */
return (0);
}
int
@@ -234,7 +247,7 @@ taskqueue_enqueue(struct taskqueue *queue, struct task *task)
TQ_LOCK(queue);
res = taskqueue_enqueue_locked(queue, task);
- TQ_UNLOCK(queue);
+ /* The lock is released inside. */
return (res);
}
@@ -251,6 +264,7 @@ taskqueue_timeout_func(void *arg)
timeout_task->f &= ~DT_CALLOUT_ARMED;
queue->tq_callouts--;
taskqueue_enqueue_locked(timeout_task->q, &timeout_task->t);
+ /* The lock is released inside. */
}
int
@@ -267,6 +281,7 @@ taskqueue_enqueue_timeout(struct taskqueue *queue,
res = timeout_task->t.ta_pending;
if (ticks == 0) {
taskqueue_enqueue_locked(queue, &timeout_task->t);
+ /* The lock is released inside. */
} else {
if ((timeout_task->f & DT_CALLOUT_ARMED) != 0) {
res++;
@@ -280,8 +295,8 @@ taskqueue_enqueue_timeout(struct taskqueue *queue,
callout_reset(&timeout_task->c, ticks,
taskqueue_timeout_func, timeout_task);
}
+ TQ_UNLOCK(queue);
}
- TQ_UNLOCK(queue);
return (res);
}
@@ -309,10 +324,8 @@ taskqueue_unblock(struct taskqueue *queue)
TQ_LOCK(queue);
queue->tq_flags &= ~TQ_FLAGS_BLOCKED;
- if (queue->tq_flags & TQ_FLAGS_PENDING) {
- queue->tq_flags &= ~TQ_FLAGS_PENDING;
+ if (!STAILQ_EMPTY(&queue->tq_queue))
queue->tq_enqueue(queue->tq_context);
- }
TQ_UNLOCK(queue);
}
@@ -596,7 +609,6 @@ taskqueue_thread_enqueue(void *context)
tqp = context;
tq = *tqp;
- TQ_ASSERT_LOCKED(tq);
wakeup_one(tq);
}
OpenPOWER on IntegriCloud