diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2018-01-31 12:33:41 +0000 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2018-01-31 12:33:41 +0000 |
commit | 4f85f546262f3d67c5d1d64ab4c0843d36bd91ee (patch) | |
tree | e3e4d176a1f5c2fc7b162bb701753bf7b737aca0 | |
parent | 9f6b3ea11dce076cf9dd9f88c85a752702938873 (diff) | |
parent | f06dce2c1f0f3af78581e7574f65bfba843ddb6e (diff) | |
download | illumos-joyent-4f85f546262f3d67c5d1d64ab4c0843d36bd91ee.tar.gz |
[illumos-gate merge]
commit f06dce2c1f0f3af78581e7574f65bfba843ddb6e
8809 libzpool should leverage work done in libfakekernel
commit 0fb055e81fd0cda5221da8ddd98b2f8d1fc6bdbe
8969 Cannot boot from RAIDZ with parity > 1
Conflicts:
usr/src/lib/libzpool/common/sys/zfs_context.h
usr/src/lib/libzpool/common/taskq.c (deleted)
54 files changed, 780 insertions, 1516 deletions
diff --git a/exception_lists/packaging b/exception_lists/packaging index ab197d396c..5e6e873d8c 100644 --- a/exception_lists/packaging +++ b/exception_lists/packaging @@ -26,6 +26,7 @@ # Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> # Copyright 2016 Nexenta Systems, Inc. # Copyright 2017 Toomas Soome <tsoome@me.com> +# Copyright 2017 RackTop Systems. # # @@ -721,19 +722,19 @@ usr/include/sys/srn.h usr/include/smb usr/include/smbsrv # -# Private/Internal libraries for smbsrv in user space +# Private/Internal files for libfakekernel. Do not ship. # +lib/amd64/libfakekernel.so i386 +lib/amd64/llib-lfakekernel.ln i386 +lib/sparcv9/libfakekernel.so sparc +lib/sparcv9/llib-lfakekernel.ln sparc +lib/libfakekernel.so +lib/llib-lfakekernel +lib/llib-lfakekernel.ln usr/include/libfakekernel usr/lib/libfakekernel.so -usr/lib/libfakekernel.so.1 -usr/lib/llib-lfakekernel -usr/lib/llib-lfakekernel.ln -usr/lib/amd64/llib-lfakekernel.ln i386 -usr/lib/sparcv9/llib-lfakekernel.ln sparc usr/lib/amd64/libfakekernel.so i386 -usr/lib/amd64/libfakekernel.so.1 i386 usr/lib/sparcv9/libfakekernel.so sparc -usr/lib/sparcv9/libfakekernel.so.1 sparc # # Private/Internal libraries of smbsrv. Do not ship. # @@ -1209,6 +1209,7 @@ f lib/amd64/libefi.so.1 0755 root bin s lib/amd64/libefi.so=libefi.so.1 f lib/amd64/libelf.so.1 0755 root bin s lib/amd64/libelf.so=libelf.so.1 +f lib/amd64/libfakekernel.so.1 0755 root bin f lib/amd64/libfdisk.so.1 0755 root bin s lib/amd64/libfdisk.so=libfdisk.so.1 f lib/amd64/libgen.so.1 0755 root bin @@ -1397,6 +1398,7 @@ f lib/libelf.so.1 0755 root bin s lib/libelf.so=libelf.so.1 f lib/libelfsign.so.1 0755 root bin s lib/libelfsign.so=libelfsign.so.1 +f lib/libfakekernel.so.1 0755 root bin f lib/libfdisk.so.1 0755 root bin s lib/libfdisk.so=libfdisk.so.1 f lib/libgen.so.1 0755 root bin @@ -4817,6 +4819,7 @@ s usr/lib/amd64/libelf.so.1=../../../lib/amd64/libelf.so.1 s usr/lib/amd64/libelf.so=../../../lib/amd64/libelf.so.1 f usr/lib/amd64/libexacct.so.1 0755 root bin s usr/lib/amd64/libexacct.so=libexacct.so.1 +s usr/lib/amd64/libfakekernel.so.1=../../../lib/amd64/libfakekernel.so.1 f usr/lib/amd64/libfcoe.so.1 0755 root bin s usr/lib/amd64/libfcoe.so=libfcoe.so.1 s usr/lib/amd64/libfdisk.so.1=../../../lib/amd64/libfdisk.so.1 @@ -6219,6 +6222,7 @@ s usr/lib/libelfsign.so.1=../../lib/libelfsign.so.1 s usr/lib/libelfsign.so=../../lib/libelfsign.so.1 f usr/lib/libexacct.so.1 0755 root bin s usr/lib/libexacct.so=libexacct.so.1 +s usr/lib/libfakekernel.so.1=../../../lib/libfakekernel.so.1 f usr/lib/libfcoe.so.1 0755 root bin s usr/lib/libfcoe.so=libfcoe.so.1 s usr/lib/libfdisk.so.1=../../lib/libfdisk.so.1 diff --git a/usr/src/Targetdirs b/usr/src/Targetdirs index 777f67952e..9538a98ad9 100644 --- a/usr/src/Targetdirs +++ b/usr/src/Targetdirs @@ -24,10 +24,10 @@ # Copyright (c) 2012 by Delphix. All rights reserved. # Copyright (c) 2012, Igor Kozhukhov <ikozhukhov@gmail.com> # Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved. -# Copyright (c) 2013 RackTop Systems. # Copyright 2014 Garrett D'Amore <garrett@damore.org> # Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> # Copyright 2016 Nexenta Systems, Inc. +# Copyright 2017 RackTop Systems. # # @@ -859,6 +859,8 @@ $(ROOT)/usr/lib/libefi.so.1:= REALPATH=../../lib/libefi.so.1 $(ROOT)/usr/lib/libefi.so:= REALPATH=../../lib/libefi.so.1 $(ROOT)/usr/lib/libelf.so.1:= REALPATH=../../lib/libelf.so.1 $(ROOT)/usr/lib/libelf.so:= REALPATH=../../lib/libelf.so.1 +$(ROOT)/usr/lib/libfakekernel.so.1:= REALPATH=../../lib/libfakekernel.so.1 +$(ROOT)/usr/lib/libfakekernel.so:= REALPATH=../../lib/libfakekernel.so.1 $(ROOT)/usr/lib/libfdisk.so.1:= REALPATH=../../lib/libfdisk.so.1 $(ROOT)/usr/lib/libfdisk.so:= REALPATH=../../lib/libfdisk.so.1 $(ROOT)/usr/lib/libgen.so.1:= REALPATH=../../lib/libgen.so.1 @@ -1316,6 +1318,10 @@ $(ROOT)/usr/lib/$(MACH64)/libzfs_core.so:= \ REALPATH=../../../lib/$(MACH64)/libzfs_core.so.1 $(ROOT)/usr/lib/$(MACH64)/libzfs_core.so.1:= \ REALPATH=../../../lib/$(MACH64)/libzfs_core.so.1 +$(ROOT)/usr/lib/$(MACH64)/libfakekernel.so:= \ + REALPATH=../../../lib/$(MACH64)/libfakekernel.so.1 +$(ROOT)/usr/lib/$(MACH64)/libfakekernel.so.1:= \ + REALPATH=../../../lib/$(MACH64)/libfakekernel.so.1 $(ROOT)/usr/lib/$(MACH64)/libfdisk.so.1:= \ REALPATH=../../../lib/$(MACH64)/libfdisk.so.1 $(ROOT)/usr/lib/$(MACH64)/libfdisk.so:= \ @@ -1492,6 +1498,8 @@ SYM.USRLIB= \ /usr/lib/libefi.so.1 \ /usr/lib/libelf.so \ /usr/lib/libelf.so.1 \ + /usr/lib/libfakekernel.so \ + /usr/lib/libfakekernel.so.1 \ /usr/lib/libgen.so \ /usr/lib/libgen.so.1 \ /usr/lib/libinetutil.so \ @@ -1741,6 +1749,8 @@ SYM.USRLIB64= \ /usr/lib/$(MACH64)/libefi.so.1 \ /usr/lib/$(MACH64)/libelf.so \ /usr/lib/$(MACH64)/libelf.so.1 \ + /usr/lib/$(MACH64)/libfakekernel.so \ + /usr/lib/$(MACH64)/libfakekernel.so.1 \ /usr/lib/$(MACH64)/libgen.so \ /usr/lib/$(MACH64)/libgen.so.1 \ /usr/lib/$(MACH64)/libinetutil.so \ diff --git a/usr/src/cmd/mdb/intel/amd64/libzpool/Makefile b/usr/src/cmd/mdb/intel/amd64/libzpool/Makefile index 8947c877c5..f4d128dff7 100644 --- a/usr/src/cmd/mdb/intel/amd64/libzpool/Makefile +++ b/usr/src/cmd/mdb/intel/amd64/libzpool/Makefile @@ -23,6 +23,8 @@ # Copyright 2005 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # +# Copyright 2017 RackTop Systems. +# MODULE = libzpool.so MDBTGT = proc @@ -38,6 +40,7 @@ include ../../../common/modules/zfs/Makefile.zfs MODSRCS_DIR = ../../../common/modules/zfs GENUNIX_DIR = ../../../common/modules/genunix +CPPFLAGS.first = -I$(SRC)/lib/libfakekernel/common -D_FAKE_KERNEL CPPFLAGS += -I../../../../../lib/libzpool/common \ -I../../../../../uts/common/fs/zfs diff --git a/usr/src/cmd/mdb/intel/ia32/libzpool/Makefile b/usr/src/cmd/mdb/intel/ia32/libzpool/Makefile index 68416f725b..658c466248 100644 --- a/usr/src/cmd/mdb/intel/ia32/libzpool/Makefile +++ b/usr/src/cmd/mdb/intel/ia32/libzpool/Makefile @@ -24,6 +24,7 @@ # Use is subject to license terms. # # Copyright (c) 2016 by Delphix. All rights reserved. +# Copyright 2017 RackTop Systems. # MODULE = libzpool.so @@ -39,6 +40,7 @@ include ../../../common/modules/zfs/Makefile.zfs MODSRCS_DIR = ../../../common/modules/zfs GENUNIX_DIR = ../../../common/modules/genunix +CPPFLAGS.first = -I$(SRC)/lib/libfakekernel/common -D_FAKE_KERNEL CPPFLAGS += -I../../../../../lib/libzpool/common \ -I../../../../../uts/common/fs/zfs \ -I../../../../../uts/common/fs/zfs/lua diff --git a/usr/src/cmd/zdb/Makefile.com b/usr/src/cmd/zdb/Makefile.com index 8459f52032..78d1bb1738 100644 --- a/usr/src/cmd/zdb/Makefile.com +++ b/usr/src/cmd/zdb/Makefile.com @@ -24,6 +24,7 @@ # Use is subject to license terms. # Copyright (c) 2012 by Delphix. All rights reserved. # Copyright 2017 Joyent, Inc. +# Copyright 2017 RackTop Systems. # PROG:sh= cd ..; basename `pwd` @@ -37,13 +38,14 @@ INCS += -I../../../lib/libzpool/common INCS += -I../../../uts/common/fs/zfs INCS += -I../../../common/zfs -LDLIBS += -lzpool -lumem -lnvpair -lzfs -lavl -lcmdutils +LDLIBS += -lzpool -lumem -lnvpair -lzfs -lavl -lcmdutils -lfakekernel C99MODE= -xc99=%all C99LMODE= -Xc99=%all CFLAGS += $(CCVERBOSE) CFLAGS64 += $(CCVERBOSE) +CPPFLAGS.first = -I$(SRC)/lib/libfakekernel/common -D_FAKE_KERNEL CPPFLAGS += -D_LARGEFILE64_SOURCE=1 -D_REENTRANT $(INCS) -DDEBUG # re-enable warnings that we can tolerate, which are disabled by default diff --git a/usr/src/cmd/zdb/zdb.c b/usr/src/cmd/zdb/zdb.c index a6c2a9c821..657b783fdc 100644 --- a/usr/src/cmd/zdb/zdb.c +++ b/usr/src/cmd/zdb/zdb.c @@ -24,6 +24,7 @@ * Copyright (c) 2011, 2017 by Delphix. All rights reserved. * Copyright (c) 2014 Integros [integros.com] * Copyright 2017 Nexenta Systems, Inc. + * Copyright 2017 RackTop Systems. */ #include <stdio.h> @@ -87,11 +88,13 @@ extern int reference_tracking_enable; extern boolean_t zfs_recover; extern uint64_t zfs_arc_max, zfs_arc_meta_limit; extern int zfs_vdev_async_read_max_active; +extern int aok; #else int reference_tracking_enable; boolean_t zfs_recover; uint64_t zfs_arc_max, zfs_arc_meta_limit; int zfs_vdev_async_read_max_active; +int aok; #endif static const char cmdname[] = "zdb"; diff --git a/usr/src/cmd/zhack/Makefile.com b/usr/src/cmd/zhack/Makefile.com index f077ed252a..3e7890d5d7 100644 --- a/usr/src/cmd/zhack/Makefile.com +++ b/usr/src/cmd/zhack/Makefile.com @@ -26,6 +26,7 @@ # # Copyright (c) 2012, 2016 by Delphix. All rights reserved. +# Copyright 2017 RackTop Systems. # PROG= zhack @@ -47,6 +48,7 @@ C99LMODE= -Xc99=%all CFLAGS += $(CCVERBOSE) CFLAGS64 += $(CCVERBOSE) +CPPFLAGS.first = -I$(SRC)/lib/libfakekernel/common -D_FAKE_KERNEL CPPFLAGS += -D_LARGEFILE64_SOURCE=1 -D_REENTRANT -DDEBUG $(INCS) LINTFLAGS += -erroff=E_STATIC_UNUSED diff --git a/usr/src/cmd/zinject/Makefile.com b/usr/src/cmd/zinject/Makefile.com index 82b4e6c2c1..5bfe8bad79 100644 --- a/usr/src/cmd/zinject/Makefile.com +++ b/usr/src/cmd/zinject/Makefile.com @@ -23,6 +23,7 @@ # Use is subject to license terms. # # Copyright (c) 2016 by Delphix. All rights reserved. +# Copyright 2017 RackTop Systems. # PROG:sh= cd ..; basename `pwd` @@ -40,6 +41,7 @@ LDLIBS += -lzpool -lzfs -lnvpair C99MODE= -xc99=%all C99LMODE= -Xc99=%all +CPPFLAGS.first = -I$(SRC)/lib/libfakekernel/common -D_FAKE_KERNEL CPPFLAGS += -D_LARGEFILE64_SOURCE=1 -D_REENTRANT $(INCS) CERRWARN += -_gcc=-Wno-uninitialized diff --git a/usr/src/cmd/ztest/Makefile.com b/usr/src/cmd/ztest/Makefile.com index 6491ee2047..172ff02b5a 100644 --- a/usr/src/cmd/ztest/Makefile.com +++ b/usr/src/cmd/ztest/Makefile.com @@ -21,6 +21,7 @@ # # Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2012, 2016 by Delphix. All rights reserved. +# Copyright 2017 RackTop Systems. # PROG= ztest @@ -35,12 +36,13 @@ INCS += -I../../../uts/common/fs/zfs INCS += -I../../../uts/common/fs/zfs/lua INCS += -I../../../common/zfs -LDLIBS += -lumem -lzpool -lcmdutils -lm -lnvpair +LDLIBS += -lumem -lzpool -lcmdutils -lm -lnvpair -lfakekernel C99MODE= -xc99=%all C99LMODE= -Xc99=%all CFLAGS += -g $(CCVERBOSE) CFLAGS64 += -g $(CCVERBOSE) +CPPFLAGS.first = -I$(SRC)/lib/libfakekernel/common -D_FAKE_KERNEL CPPFLAGS += -D_LARGEFILE64_SOURCE=1 -D_REENTRANT $(INCS) -DDEBUG # lint complains about unused _umem_* functions diff --git a/usr/src/cmd/ztest/ztest.c b/usr/src/cmd/ztest/ztest.c index 1fde9cbe6d..1b7441eb51 100644 --- a/usr/src/cmd/ztest/ztest.c +++ b/usr/src/cmd/ztest/ztest.c @@ -25,6 +25,7 @@ * Copyright (c) 2013 Steven Hartland. All rights reserved. * Copyright (c) 2014 Integros [integros.com] * Copyright 2017 Joyent, Inc. + * Copyright 2017 RackTop Systems. */ /* @@ -245,8 +246,8 @@ typedef enum { typedef struct rll { void *rll_writer; int rll_readers; - mutex_t rll_lock; - cond_t rll_cv; + kmutex_t rll_lock; + kcondvar_t rll_cv; } rll_t; typedef struct rl { @@ -280,11 +281,11 @@ typedef struct ztest_od { typedef struct ztest_ds { ztest_shared_ds_t *zd_shared; objset_t *zd_os; - rwlock_t zd_zilog_lock; + krwlock_t zd_zilog_lock; zilog_t *zd_zilog; ztest_od_t *zd_od; /* debugging aid */ char zd_name[ZFS_MAX_DATASET_NAME_LEN]; - mutex_t zd_dirobj_lock; + kmutex_t zd_dirobj_lock; rll_t zd_object_lock[ZTEST_OBJECT_LOCKS]; rll_t zd_range_lock[ZTEST_RANGE_LOCKS]; } ztest_ds_t; @@ -395,7 +396,7 @@ ztest_info_t ztest_info[] = { * The callbacks are ordered by txg number. */ typedef struct ztest_cb_list { - mutex_t zcl_callbacks_lock; + kmutex_t zcl_callbacks_lock; list_t zcl_callbacks; } ztest_cb_list_t; @@ -430,7 +431,7 @@ ztest_shared_t *ztest_shared; static spa_t *ztest_spa = NULL; static ztest_ds_t *ztest_ds; -static mutex_t ztest_vdev_lock; +static kmutex_t ztest_vdev_lock; /* * The ztest_name_lock protects the pool and dataset namespace used by @@ -438,7 +439,7 @@ static mutex_t ztest_vdev_lock; * this lock as writer. Grabbing the lock as reader will ensure that the * namespace does not change while the lock is held. */ -static rwlock_t ztest_name_lock; +static krwlock_t ztest_name_lock; static boolean_t ztest_dump_core = B_TRUE; static boolean_t ztest_exiting; @@ -1094,8 +1095,8 @@ ztest_rll_init(rll_t *rll) { rll->rll_writer = NULL; rll->rll_readers = 0; - VERIFY(_mutex_init(&rll->rll_lock, USYNC_THREAD, NULL) == 0); - VERIFY(cond_init(&rll->rll_cv, USYNC_THREAD, NULL) == 0); + mutex_init(&rll->rll_lock, NULL, USYNC_THREAD, NULL); + cv_init(&rll->rll_cv, NULL, USYNC_THREAD, NULL); } static void @@ -1103,32 +1104,32 @@ ztest_rll_destroy(rll_t *rll) { ASSERT(rll->rll_writer == NULL); ASSERT(rll->rll_readers == 0); - VERIFY(_mutex_destroy(&rll->rll_lock) == 0); - VERIFY(cond_destroy(&rll->rll_cv) == 0); + mutex_destroy(&rll->rll_lock); + cv_destroy(&rll->rll_cv); } static void ztest_rll_lock(rll_t *rll, rl_type_t type) { - VERIFY(mutex_lock(&rll->rll_lock) == 0); + mutex_enter(&rll->rll_lock); if (type == RL_READER) { while (rll->rll_writer != NULL) - (void) cond_wait(&rll->rll_cv, &rll->rll_lock); + cv_wait(&rll->rll_cv, &rll->rll_lock); rll->rll_readers++; } else { while (rll->rll_writer != NULL || rll->rll_readers) - (void) cond_wait(&rll->rll_cv, &rll->rll_lock); + cv_wait(&rll->rll_cv, &rll->rll_lock); rll->rll_writer = curthread; } - VERIFY(mutex_unlock(&rll->rll_lock) == 0); + mutex_exit(&rll->rll_lock); } static void ztest_rll_unlock(rll_t *rll) { - VERIFY(mutex_lock(&rll->rll_lock) == 0); + mutex_enter(&rll->rll_lock); if (rll->rll_writer) { ASSERT(rll->rll_readers == 0); @@ -1140,9 +1141,9 @@ ztest_rll_unlock(rll_t *rll) } if (rll->rll_writer == NULL && rll->rll_readers == 0) - VERIFY(cond_broadcast(&rll->rll_cv) == 0); + cv_broadcast(&rll->rll_cv); - VERIFY(mutex_unlock(&rll->rll_lock) == 0); + mutex_exit(&rll->rll_lock); } static void @@ -1201,8 +1202,8 @@ ztest_zd_init(ztest_ds_t *zd, ztest_shared_ds_t *szd, objset_t *os) if (zd->zd_shared != NULL) zd->zd_shared->zd_seq = 0; - VERIFY(rwlock_init(&zd->zd_zilog_lock, USYNC_THREAD, NULL) == 0); - VERIFY(_mutex_init(&zd->zd_dirobj_lock, USYNC_THREAD, NULL) == 0); + rw_init(&zd->zd_zilog_lock, NULL, USYNC_THREAD, NULL); + mutex_init(&zd->zd_dirobj_lock, NULL, USYNC_THREAD, NULL); for (int l = 0; l < ZTEST_OBJECT_LOCKS; l++) ztest_rll_init(&zd->zd_object_lock[l]); @@ -1214,7 +1215,7 @@ ztest_zd_init(ztest_ds_t *zd, ztest_shared_ds_t *szd, objset_t *os) static void ztest_zd_fini(ztest_ds_t *zd) { - VERIFY(_mutex_destroy(&zd->zd_dirobj_lock) == 0); + mutex_destroy(&zd->zd_dirobj_lock); for (int l = 0; l < ZTEST_OBJECT_LOCKS; l++) ztest_rll_destroy(&zd->zd_object_lock[l]); @@ -1969,7 +1970,7 @@ ztest_lookup(ztest_ds_t *zd, ztest_od_t *od, int count) int missing = 0; int error; - ASSERT(_mutex_held(&zd->zd_dirobj_lock)); + ASSERT(MUTEX_HELD(&zd->zd_dirobj_lock)); for (int i = 0; i < count; i++, od++) { od->od_object = 0; @@ -2009,7 +2010,7 @@ ztest_create(ztest_ds_t *zd, ztest_od_t *od, int count) { int missing = 0; - ASSERT(_mutex_held(&zd->zd_dirobj_lock)); + ASSERT(MUTEX_HELD(&zd->zd_dirobj_lock)); for (int i = 0; i < count; i++, od++) { if (missing) { @@ -2054,7 +2055,7 @@ ztest_remove(ztest_ds_t *zd, ztest_od_t *od, int count) int missing = 0; int error; - ASSERT(_mutex_held(&zd->zd_dirobj_lock)); + ASSERT(MUTEX_HELD(&zd->zd_dirobj_lock)); od += count - 1; @@ -2200,7 +2201,7 @@ ztest_io(ztest_ds_t *zd, uint64_t object, uint64_t offset) if (ztest_random(2) == 0) io_type = ZTEST_IO_WRITE_TAG; - (void) rw_rdlock(&zd->zd_zilog_lock); + rw_enter(&zd->zd_zilog_lock, RW_READER); switch (io_type) { @@ -2237,7 +2238,7 @@ ztest_io(ztest_ds_t *zd, uint64_t object, uint64_t offset) break; case ZTEST_IO_REWRITE: - (void) rw_rdlock(&ztest_name_lock); + rw_enter(&ztest_name_lock, RW_READER); err = ztest_dsl_prop_set_uint64(zd->zd_name, ZFS_PROP_CHECKSUM, spa_dedup_checksum(ztest_spa), B_FALSE); @@ -2247,7 +2248,7 @@ ztest_io(ztest_ds_t *zd, uint64_t object, uint64_t offset) ztest_random_dsl_prop(ZFS_PROP_COMPRESSION), B_FALSE); VERIFY(err == 0 || err == ENOSPC); - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); VERIFY0(dmu_read(zd->zd_os, object, offset, blocksize, data, DMU_READ_NO_PREFETCH)); @@ -2256,7 +2257,7 @@ ztest_io(ztest_ds_t *zd, uint64_t object, uint64_t offset) break; } - (void) rw_unlock(&zd->zd_zilog_lock); + rw_exit(&zd->zd_zilog_lock); umem_free(data, blocksize); } @@ -2295,13 +2296,13 @@ ztest_object_init(ztest_ds_t *zd, ztest_od_t *od, size_t size, boolean_t remove) int count = size / sizeof (*od); int rv = 0; - VERIFY(mutex_lock(&zd->zd_dirobj_lock) == 0); + mutex_enter(&zd->zd_dirobj_lock); if ((ztest_lookup(zd, od, count) != 0 || remove) && (ztest_remove(zd, od, count) != 0 || ztest_create(zd, od, count) != 0)) rv = -1; zd->zd_od = od; - VERIFY(mutex_unlock(&zd->zd_dirobj_lock) == 0); + mutex_exit(&zd->zd_dirobj_lock); return (rv); } @@ -2312,7 +2313,7 @@ ztest_zil_commit(ztest_ds_t *zd, uint64_t id) { zilog_t *zilog = zd->zd_zilog; - (void) rw_rdlock(&zd->zd_zilog_lock); + rw_enter(&zd->zd_zilog_lock, RW_READER); zil_commit(zilog, ztest_random(ZTEST_OBJECTS)); @@ -2327,7 +2328,7 @@ ztest_zil_commit(ztest_ds_t *zd, uint64_t id) zd->zd_shared->zd_seq = zilog->zl_commit_lr_seq; mutex_exit(&zilog->zl_lock); - (void) rw_unlock(&zd->zd_zilog_lock); + rw_exit(&zd->zd_zilog_lock); } /* @@ -2346,8 +2347,8 @@ ztest_zil_remount(ztest_ds_t *zd, uint64_t id) * updating the zil (i.e. adding in-memory log records) and the * zd_zilog_lock to block any I/O. */ - VERIFY0(mutex_lock(&zd->zd_dirobj_lock)); - (void) rw_wrlock(&zd->zd_zilog_lock); + mutex_enter(&zd->zd_dirobj_lock); + rw_enter(&zd->zd_zilog_lock, RW_WRITER); /* zfsvfs_teardown() */ zil_close(zd->zd_zilog); @@ -2356,8 +2357,8 @@ ztest_zil_remount(ztest_ds_t *zd, uint64_t id) VERIFY(zil_open(os, ztest_get_data) == zd->zd_zilog); zil_replay(os, zd, ztest_replay_vector); - (void) rw_unlock(&zd->zd_zilog_lock); - VERIFY(mutex_unlock(&zd->zd_dirobj_lock) == 0); + rw_exit(&zd->zd_zilog_lock); + mutex_exit(&zd->zd_dirobj_lock); } /* @@ -2392,7 +2393,7 @@ ztest_spa_create_destroy(ztest_ds_t *zd, uint64_t id) * Attempt to create an existing pool. It shouldn't matter * what's in the nvroot; we should fail with EEXIST. */ - (void) rw_rdlock(&ztest_name_lock); + rw_enter(&ztest_name_lock, RW_READER); nvroot = make_vdev_root("/dev/bogus", NULL, NULL, 0, 0, 0, 0, 0, 1); VERIFY3U(EEXIST, ==, spa_create(zo->zo_pool, nvroot, NULL, NULL)); nvlist_free(nvroot); @@ -2400,7 +2401,7 @@ ztest_spa_create_destroy(ztest_ds_t *zd, uint64_t id) VERIFY3U(EBUSY, ==, spa_destroy(zo->zo_pool)); spa_close(spa, FTAG); - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); } /* ARGSUSED */ @@ -2413,7 +2414,7 @@ ztest_spa_upgrade(ztest_ds_t *zd, uint64_t id) nvlist_t *nvroot, *props; char *name; - VERIFY0(mutex_lock(&ztest_vdev_lock)); + mutex_enter(&ztest_vdev_lock); name = kmem_asprintf("%s_upgrade", ztest_opts.zo_pool); /* @@ -2472,7 +2473,7 @@ ztest_spa_upgrade(ztest_ds_t *zd, uint64_t id) spa_close(spa, FTAG); strfree(name); - VERIFY0(mutex_unlock(&ztest_vdev_lock)); + mutex_exit(&ztest_vdev_lock); } static vdev_t * @@ -2525,7 +2526,7 @@ ztest_vdev_add_remove(ztest_ds_t *zd, uint64_t id) nvlist_t *nvroot; int error; - VERIFY(mutex_lock(&ztest_vdev_lock) == 0); + mutex_enter(&ztest_vdev_lock); leaves = MAX(zs->zs_mirrors + zs->zs_splits, 1) * ztest_opts.zo_raidz; spa_config_enter(spa, SCL_VDEV, FTAG, RW_READER); @@ -2551,9 +2552,9 @@ ztest_vdev_add_remove(ztest_ds_t *zd, uint64_t id) * dmu_objset_destroy() to fail with EBUSY thus * leaving the dataset in an inconsistent state. */ - VERIFY(rw_wrlock(&ztest_name_lock) == 0); + rw_enter(&ztest_name_lock, RW_WRITER); error = spa_vdev_remove(spa, guid, B_FALSE); - VERIFY(rw_unlock(&ztest_name_lock) == 0); + rw_exit(&ztest_name_lock); if (error && error != EEXIST) fatal(0, "spa_vdev_remove() = %d", error); @@ -2577,7 +2578,7 @@ ztest_vdev_add_remove(ztest_ds_t *zd, uint64_t id) fatal(0, "spa_vdev_add() = %d", error); } - VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); + mutex_exit(&ztest_vdev_lock); } /* @@ -2603,7 +2604,7 @@ ztest_vdev_aux_add_remove(ztest_ds_t *zd, uint64_t id) aux = ZPOOL_CONFIG_L2CACHE; } - VERIFY(mutex_lock(&ztest_vdev_lock) == 0); + mutex_enter(&ztest_vdev_lock); spa_config_enter(spa, SCL_VDEV, FTAG, RW_READER); @@ -2660,7 +2661,7 @@ ztest_vdev_aux_add_remove(ztest_ds_t *zd, uint64_t id) fatal(0, "spa_vdev_remove(%llu) = %d", guid, error); } - VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); + mutex_exit(&ztest_vdev_lock); } /* @@ -2677,11 +2678,11 @@ ztest_split_pool(ztest_ds_t *zd, uint64_t id) uint_t c, children, schildren = 0, lastlogid = 0; int error = 0; - VERIFY(mutex_lock(&ztest_vdev_lock) == 0); + mutex_enter(&ztest_vdev_lock); /* ensure we have a useable config; mirrors of raidz aren't supported */ if (zs->zs_mirrors < 3 || ztest_opts.zo_raidz > 1) { - VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); + mutex_exit(&ztest_vdev_lock); return; } @@ -2740,9 +2741,9 @@ ztest_split_pool(ztest_ds_t *zd, uint64_t id) spa_config_exit(spa, SCL_VDEV, FTAG); - (void) rw_wrlock(&ztest_name_lock); + rw_enter(&ztest_name_lock, RW_WRITER); error = spa_vdev_split_mirror(spa, "splitp", config, NULL, B_FALSE); - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); nvlist_free(config); @@ -2755,7 +2756,7 @@ ztest_split_pool(ztest_ds_t *zd, uint64_t id) ++zs->zs_splits; --zs->zs_mirrors; } - VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); + mutex_exit(&ztest_vdev_lock); } @@ -2784,7 +2785,7 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id) int oldvd_is_log; int error, expected_error; - VERIFY(mutex_lock(&ztest_vdev_lock) == 0); + mutex_enter(&ztest_vdev_lock); leaves = MAX(zs->zs_mirrors, 1) * ztest_opts.zo_raidz; spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER); @@ -2797,7 +2798,7 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id) */ if (spa->spa_vdev_removal != NULL) { spa_config_exit(spa, SCL_ALL, FTAG); - VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); + mutex_exit(&ztest_vdev_lock); return; } @@ -2857,7 +2858,7 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id) if (error != 0 && error != ENODEV && error != EBUSY && error != ENOTSUP) fatal(0, "detach (%s) returned %d", oldpath, error); - VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); + mutex_exit(&ztest_vdev_lock); return; } @@ -2955,7 +2956,7 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id) newsize, replacing, error, expected_error); } - VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); + mutex_exit(&ztest_vdev_lock); } /* ARGSUSED */ @@ -2966,7 +2967,7 @@ ztest_device_removal(ztest_ds_t *zd, uint64_t id) vdev_t *vd; uint64_t guid; - VERIFY(mutex_lock(&ztest_vdev_lock) == 0); + mutex_enter(&ztest_vdev_lock); spa_config_enter(spa, SCL_VDEV, FTAG, RW_READER); vd = vdev_lookup_top(spa, ztest_random_vdev_top(spa, B_FALSE)); @@ -2975,7 +2976,7 @@ ztest_device_removal(ztest_ds_t *zd, uint64_t id) (void) spa_vdev_remove(spa, guid, B_FALSE); - VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); + mutex_exit(&ztest_vdev_lock); } /* @@ -3103,7 +3104,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id) uint64_t top; uint64_t old_class_space, new_class_space, old_ms_count, new_ms_count; - VERIFY(mutex_lock(&ztest_vdev_lock) == 0); + mutex_enter(&ztest_vdev_lock); spa_config_enter(spa, SCL_STATE, spa, RW_READER); /* @@ -3114,7 +3115,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id) */ if (spa->spa_vdev_removal != NULL) { spa_config_exit(spa, SCL_STATE, FTAG); - VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); + mutex_exit(&ztest_vdev_lock); return; } @@ -3143,7 +3144,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id) if (tvd->vdev_state != VDEV_STATE_HEALTHY || psize == 0 || psize >= 4 * ztest_opts.zo_vdev_size) { spa_config_exit(spa, SCL_STATE, spa); - VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); + mutex_exit(&ztest_vdev_lock); return; } ASSERT(psize > 0); @@ -3168,7 +3169,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id) "the vdev configuration changed.\n"); } spa_config_exit(spa, SCL_STATE, spa); - VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); + mutex_exit(&ztest_vdev_lock); return; } @@ -3202,7 +3203,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id) "intervening vdev offline or remove.\n"); } spa_config_exit(spa, SCL_STATE, spa); - VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); + mutex_exit(&ztest_vdev_lock); return; } @@ -3232,7 +3233,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id) } spa_config_exit(spa, SCL_STATE, spa); - VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); + mutex_exit(&ztest_vdev_lock); } /* @@ -3346,7 +3347,7 @@ ztest_dmu_objset_create_destroy(ztest_ds_t *zd, uint64_t id) char name[ZFS_MAX_DATASET_NAME_LEN]; zilog_t *zilog; - (void) rw_rdlock(&ztest_name_lock); + rw_enter(&ztest_name_lock, RW_READER); (void) snprintf(name, sizeof (name), "%s/temp_%llu", ztest_opts.zo_pool, (u_longlong_t)id); @@ -3385,7 +3386,7 @@ ztest_dmu_objset_create_destroy(ztest_ds_t *zd, uint64_t id) if (error) { if (error == ENOSPC) { ztest_record_enospc(FTAG); - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); return; } fatal(0, "dmu_objset_create(%s) = %d", name, error); @@ -3433,7 +3434,7 @@ ztest_dmu_objset_create_destroy(ztest_ds_t *zd, uint64_t id) dmu_objset_disown(os, FTAG); ztest_zd_fini(&zdtmp); - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); } /* @@ -3442,10 +3443,10 @@ ztest_dmu_objset_create_destroy(ztest_ds_t *zd, uint64_t id) void ztest_dmu_snapshot_create_destroy(ztest_ds_t *zd, uint64_t id) { - (void) rw_rdlock(&ztest_name_lock); + rw_enter(&ztest_name_lock, RW_READER); (void) ztest_snapshot_destroy(zd->zd_name, id); (void) ztest_snapshot_create(zd->zd_name, id); - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); } /* @@ -3504,7 +3505,7 @@ ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id) char *osname = zd->zd_name; int error; - (void) rw_rdlock(&ztest_name_lock); + rw_enter(&ztest_name_lock, RW_READER); ztest_dsl_dataset_cleanup(osname, id); @@ -3581,7 +3582,7 @@ ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id) out: ztest_dsl_dataset_cleanup(osname, id); - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); } /* @@ -4515,9 +4516,9 @@ ztest_commit_callback(void *arg, int error) ASSERT3U(data->zcd_txg, !=, 0); /* Remove our callback from the list */ - (void) mutex_lock(&zcl.zcl_callbacks_lock); + mutex_enter(&zcl.zcl_callbacks_lock); list_remove(&zcl.zcl_callbacks, data); - (void) mutex_unlock(&zcl.zcl_callbacks_lock); + mutex_exit(&zcl.zcl_callbacks_lock); out: umem_free(data, sizeof (ztest_cb_data_t)); @@ -4619,7 +4620,7 @@ ztest_dmu_commit_callbacks(ztest_ds_t *zd, uint64_t id) dmu_write(os, od[0].od_object, 0, sizeof (uint64_t), &txg, tx); - (void) mutex_lock(&zcl.zcl_callbacks_lock); + mutex_enter(&zcl.zcl_callbacks_lock); /* * Since commit callbacks don't have any ordering requirement and since @@ -4666,7 +4667,7 @@ ztest_dmu_commit_callbacks(ztest_ds_t *zd, uint64_t id) tmp_cb = cb_data[i]; } - (void) mutex_unlock(&zcl.zcl_callbacks_lock); + mutex_exit(&zcl.zcl_callbacks_lock); dmu_tx_commit(tx); } @@ -4682,27 +4683,27 @@ ztest_dsl_prop_get_set(ztest_ds_t *zd, uint64_t id) ZFS_PROP_DEDUP }; - (void) rw_rdlock(&ztest_name_lock); + rw_enter(&ztest_name_lock, RW_READER); for (int p = 0; p < sizeof (proplist) / sizeof (proplist[0]); p++) (void) ztest_dsl_prop_set_uint64(zd->zd_name, proplist[p], ztest_random_dsl_prop(proplist[p]), (int)ztest_random(2)); - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); } /* ARGSUSED */ void ztest_remap_blocks(ztest_ds_t *zd, uint64_t id) { - (void) rw_rdlock(&ztest_name_lock); + rw_enter(&ztest_name_lock, RW_READER); int error = dmu_objset_remap_indirects(zd->zd_name); if (error == ENOSPC) error = 0; ASSERT0(error); - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); } /* ARGSUSED */ @@ -4711,7 +4712,7 @@ ztest_spa_prop_get_set(ztest_ds_t *zd, uint64_t id) { nvlist_t *props = NULL; - (void) rw_rdlock(&ztest_name_lock); + rw_enter(&ztest_name_lock, RW_READER); (void) ztest_spa_prop_set_uint64(ZPOOL_PROP_DEDUPDITTO, ZIO_DEDUPDITTO_MIN + ztest_random(ZIO_DEDUPDITTO_MIN)); @@ -4723,7 +4724,7 @@ ztest_spa_prop_get_set(ztest_ds_t *zd, uint64_t id) nvlist_free(props); - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); } static int @@ -4758,7 +4759,7 @@ ztest_dmu_snapshot_hold(ztest_ds_t *zd, uint64_t id) char osname[ZFS_MAX_DATASET_NAME_LEN]; nvlist_t *holds; - (void) rw_rdlock(&ztest_name_lock); + rw_enter(&ztest_name_lock, RW_READER); dmu_objset_name(os, osname); @@ -4863,7 +4864,7 @@ ztest_dmu_snapshot_hold(ztest_ds_t *zd, uint64_t id) VERIFY3U(dmu_objset_hold(fullname, FTAG, &origin), ==, ENOENT); out: - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); } /* @@ -4891,11 +4892,11 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id) uint64_t guid0 = 0; boolean_t islog = B_FALSE; - VERIFY(mutex_lock(&ztest_vdev_lock) == 0); + mutex_enter(&ztest_vdev_lock); maxfaults = MAXFAULTS(); leaves = MAX(zs->zs_mirrors, 1) * ztest_opts.zo_raidz; mirror_save = zs->zs_mirrors; - VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); + mutex_exit(&ztest_vdev_lock); ASSERT(leaves >= 1); @@ -4905,7 +4906,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id) * they are in progress (i.e. spa_change_guid). Those * operations will have grabbed the name lock as writer. */ - (void) rw_rdlock(&ztest_name_lock); + rw_enter(&ztest_name_lock, RW_READER); /* * We need SCL_STATE here because we're going to look at vd0->vdev_tsd. @@ -4977,7 +4978,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id) if (sav->sav_count == 0) { spa_config_exit(spa, SCL_STATE, FTAG); - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); return; } vd0 = sav->sav_vdevs[ztest_random(sav->sav_count)]; @@ -4991,7 +4992,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id) } spa_config_exit(spa, SCL_STATE, FTAG); - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); /* * If we can tolerate two or more faults, or we're dealing @@ -5011,12 +5012,12 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id) * leaving the dataset in an inconsistent state. */ if (islog) - (void) rw_wrlock(&ztest_name_lock); + rw_enter(&ztest_name_lock, RW_WRITER); VERIFY(vdev_offline(spa, guid0, flags) != EBUSY); if (islog) - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); } else { /* * Ideally we would like to be able to randomly @@ -5027,9 +5028,9 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id) * prevent a race between injection testing and * aux_vdev removal. */ - VERIFY(mutex_lock(&ztest_vdev_lock) == 0); + mutex_enter(&ztest_vdev_lock); (void) vdev_online(spa, guid0, 0, NULL); - VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); + mutex_exit(&ztest_vdev_lock); } } @@ -5101,9 +5102,9 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id) offset + sizeof (bad) > psize - VDEV_LABEL_END_SIZE) continue; - VERIFY(mutex_lock(&ztest_vdev_lock) == 0); + mutex_enter(&ztest_vdev_lock); if (mirror_save != zs->zs_mirrors) { - VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); + mutex_exit(&ztest_vdev_lock); (void) close(fd); return; } @@ -5112,7 +5113,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id) fatal(1, "can't inject bad word at 0x%llx in %s", offset, pathrand); - VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); + mutex_exit(&ztest_vdev_lock); if (ztest_opts.zo_verbose >= 7) (void) printf("injected bad word into %s," @@ -5152,13 +5153,13 @@ ztest_ddt_repair(ztest_ds_t *zd, uint64_t id) * Take the name lock as writer to prevent anyone else from changing * the pool and dataset properies we need to maintain during this test. */ - (void) rw_wrlock(&ztest_name_lock); + rw_enter(&ztest_name_lock, RW_WRITER); if (ztest_dsl_prop_set_uint64(zd->zd_name, ZFS_PROP_DEDUP, checksum, B_FALSE) != 0 || ztest_dsl_prop_set_uint64(zd->zd_name, ZFS_PROP_COPIES, 1, B_FALSE) != 0) { - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); return; } @@ -5177,7 +5178,7 @@ ztest_ddt_repair(ztest_ds_t *zd, uint64_t id) dmu_tx_hold_write(tx, object, 0, copies * blocksize); txg = ztest_tx_assign(tx, TXG_WAIT, FTAG); if (txg == 0) { - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); return; } @@ -5225,7 +5226,7 @@ ztest_ddt_repair(ztest_ds_t *zd, uint64_t id) abd_free(abd); - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); } /* @@ -5256,9 +5257,9 @@ ztest_reguid(ztest_ds_t *zd, uint64_t id) orig = spa_guid(spa); load = spa_load_guid(spa); - (void) rw_wrlock(&ztest_name_lock); + rw_enter(&ztest_name_lock, RW_WRITER); error = spa_change_guid(spa); - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); if (error != 0) return; @@ -5282,7 +5283,7 @@ ztest_spa_rename(ztest_ds_t *zd, uint64_t id) char *oldname, *newname; spa_t *spa; - (void) rw_wrlock(&ztest_name_lock); + rw_enter(&ztest_name_lock, RW_WRITER); oldname = ztest_opts.zo_pool; newname = umem_alloc(strlen(oldname) + 5, UMEM_NOFAIL); @@ -5322,7 +5323,7 @@ ztest_spa_rename(ztest_ds_t *zd, uint64_t id) umem_free(newname, strlen(newname) + 1); - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); } /* @@ -5677,18 +5678,18 @@ ztest_dataset_open(int d) ztest_dataset_name(name, ztest_opts.zo_pool, d); - (void) rw_rdlock(&ztest_name_lock); + rw_enter(&ztest_name_lock, RW_READER); error = ztest_dataset_create(name); if (error == ENOSPC) { - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); ztest_record_enospc(FTAG); return (error); } ASSERT(error == 0 || error == EEXIST); VERIFY0(dmu_objset_own(name, DMU_OST_OTHER, B_FALSE, zd, &os)); - (void) rw_unlock(&ztest_name_lock); + rw_exit(&ztest_name_lock); ztest_zd_init(zd, ZTEST_GET_SHARED_DS(d), os); @@ -5750,8 +5751,8 @@ ztest_run(ztest_shared_t *zs) /* * Initialize parent/child shared state. */ - VERIFY(_mutex_init(&ztest_vdev_lock, USYNC_THREAD, NULL) == 0); - VERIFY(rwlock_init(&ztest_name_lock, USYNC_THREAD, NULL) == 0); + mutex_init(&ztest_vdev_lock, NULL, USYNC_THREAD, NULL); + rw_init(&ztest_name_lock, NULL, USYNC_THREAD, NULL); zs->zs_thread_start = gethrtime(); zs->zs_thread_stop = @@ -5763,7 +5764,7 @@ ztest_run(ztest_shared_t *zs) ztest_random(ztest_opts.zo_passtime * NANOSEC); } - (void) _mutex_init(&zcl.zcl_callbacks_lock, USYNC_THREAD, NULL); + mutex_init(&zcl.zcl_callbacks_lock, NULL, USYNC_THREAD, NULL); list_create(&zcl.zcl_callbacks, sizeof (ztest_cb_data_t), offsetof(ztest_cb_data_t, zcd_node)); @@ -5910,10 +5911,10 @@ ztest_run(ztest_shared_t *zs) list_destroy(&zcl.zcl_callbacks); - (void) _mutex_destroy(&zcl.zcl_callbacks_lock); + mutex_destroy(&zcl.zcl_callbacks_lock); - (void) rwlock_destroy(&ztest_name_lock); - (void) _mutex_destroy(&ztest_vdev_lock); + rw_destroy(&ztest_name_lock); + mutex_destroy(&ztest_vdev_lock); } static void @@ -6057,8 +6058,8 @@ ztest_init(ztest_shared_t *zs) spa_t *spa; nvlist_t *nvroot, *props; - VERIFY(_mutex_init(&ztest_vdev_lock, USYNC_THREAD, NULL) == 0); - VERIFY(rwlock_init(&ztest_name_lock, USYNC_THREAD, NULL) == 0); + mutex_init(&ztest_vdev_lock, NULL, USYNC_THREAD, NULL); + rw_init(&ztest_name_lock, NULL, USYNC_THREAD, NULL); kernel_init(FREAD | FWRITE); @@ -6096,8 +6097,8 @@ ztest_init(ztest_shared_t *zs) ztest_run_zdb(ztest_opts.zo_pool); - (void) rwlock_destroy(&ztest_name_lock); - (void) _mutex_destroy(&ztest_vdev_lock); + rw_destroy(&ztest_name_lock); + mutex_destroy(&ztest_vdev_lock); } static void diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile index 7f82981d8c..935ed2edc5 100644 --- a/usr/src/lib/Makefile +++ b/usr/src/lib/Makefile @@ -29,6 +29,7 @@ # Copyright 2016 Toomas Soome <tsoome@me.com> # Copyright 2017 Nexenta Systems, Inc. # Copyright (c) 2016, Chris Fraire <cfraire@me.com>. +# Copyright 2017 RackTop Systems. # include ../Makefile.master @@ -698,7 +699,7 @@ libzfs_jni: libdiskmgt libzfs libzonecfg: libuuid libsysevent libsec libbrand libpool libscf libproc \ libuutil libbsm libsecdb libzonestat: libcmdutils libumem -libzpool: libavl libumem libcmdutils libsysevent +libzpool: libavl libumem libcmdutils libsysevent libfakekernel madv: libgen mpapi: libpthread libdevinfo libsysevent mpss: libgen diff --git a/usr/src/lib/libfakekernel/Makefile.com b/usr/src/lib/libfakekernel/Makefile.com index a6a35c96e0..dd448d45db 100644 --- a/usr/src/lib/libfakekernel/Makefile.com +++ b/usr/src/lib/libfakekernel/Makefile.com @@ -11,19 +11,22 @@ # # Copyright 2013 Nexenta Systems, Inc. All rights reserved. +# Copyright 2017 RackTop Systems. # LIBRARY = libfakekernel.a VERS = .1 COBJS = \ - cred.o \ clock.o \ cond.o \ copy.o \ + cred.o \ + cyclic.o \ kiconv.o \ kmem.o \ kmisc.o \ + ksid.o \ ksocket.o \ kstat.o \ mutex.o \ @@ -31,6 +34,7 @@ COBJS = \ random.o \ rwlock.o \ sema.o \ + strext.o \ taskq.o \ thread.o \ uio.o @@ -39,6 +43,9 @@ OBJECTS= $(COBJS) include ../../Makefile.lib +# libfakekernel must be installed in the root filesystem for libzpool +include ../../Makefile.rootfs + SRCDIR= ../common LIBS = $(DYNLIB) $(LINTLIB) diff --git a/usr/src/lib/libfakekernel/common/clock.c b/usr/src/lib/libfakekernel/common/clock.c index 114190413c..2bee02af2e 100644 --- a/usr/src/lib/libfakekernel/common/clock.c +++ b/usr/src/lib/libfakekernel/common/clock.c @@ -56,13 +56,6 @@ ddi_get_lbolt64(void) return (hrt / nsec_per_tick); } -void -clock2ts(clock_t clk, timespec_t *ts) -{ - ts->tv_sec = clk / hz; - ts->tv_nsec = (clk % hz) * (NANOSEC / hz); -} - hrtime_t gethrtime_unscaled(void) { diff --git a/usr/src/lib/libfakekernel/common/cond.c b/usr/src/lib/libfakekernel/common/cond.c index 0ed2ea7b73..08d0265dd2 100644 --- a/usr/src/lib/libfakekernel/common/cond.c +++ b/usr/src/lib/libfakekernel/common/cond.c @@ -11,6 +11,7 @@ /* * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 RackTop Systems. */ /* @@ -23,6 +24,7 @@ #include <sys/errno.h> #include <sys/debug.h> #include <sys/thread.h> +#include <sys/systm.h> /* avoiding synch.h */ int _lwp_cond_wait(lwp_cond_t *, lwp_mutex_t *); @@ -33,10 +35,9 @@ int _lwp_cond_broadcast(lwp_cond_t *); extern clock_t ddi_get_lbolt(void); -extern void clock2ts(clock_t, timespec_t *); static int cv__wait(kcondvar_t *, kmutex_t *, int); -static clock_t cv__twait(kcondvar_t *, kmutex_t *, clock_t, int); +static clock_t cv__twait(kcondvar_t *, kmutex_t *, clock_t, int, int); static const lwp_cond_t default_cv = {{{0, 0, 0, 0}, USYNC_THREAD, _COND_MAGIC}, 0}; @@ -106,7 +107,7 @@ cv_timedwait(kcondvar_t *cv, kmutex_t *mp, clock_t abstime) clock_t delta; delta = abstime - ddi_get_lbolt(); - return (cv__twait(cv, mp, delta, 0)); + return (cv__twait(cv, mp, delta, 0, 0)); } clock_t @@ -115,7 +116,20 @@ cv_timedwait_sig(kcondvar_t *cv, kmutex_t *mp, clock_t abstime) clock_t delta; delta = abstime - ddi_get_lbolt(); - return (cv__twait(cv, mp, delta, 1)); + return (cv__twait(cv, mp, delta, 1, 0)); +} + +/*ARGSUSED*/ +clock_t +cv_timedwait_hires(kcondvar_t *cv, kmutex_t *mp, hrtime_t tim, hrtime_t res, + int flag) +{ + clock_t delta; + + delta = tim; + if (flag & CALLOUT_FLAG_ABSOLUTE) + delta -= gethrtime(); + return (cv__twait(cv, mp, delta, 0, 1)); } clock_t @@ -123,7 +137,7 @@ cv_reltimedwait(kcondvar_t *cv, kmutex_t *mp, clock_t delta, time_res_t res) { _NOTE(ARGUNUSED(res)) - return (cv__twait(cv, mp, delta, 0)); + return (cv__twait(cv, mp, delta, 0, 0)); } clock_t @@ -132,7 +146,7 @@ cv_reltimedwait_sig(kcondvar_t *cv, kmutex_t *mp, clock_t delta, { _NOTE(ARGUNUSED(res)) - return (cv__twait(cv, mp, delta, 1)); + return (cv__twait(cv, mp, delta, 1, 0)); } /* @@ -143,7 +157,7 @@ cv_reltimedwait_sig(kcondvar_t *cv, kmutex_t *mp, clock_t delta, * which (NB!) decrements that delta in-place! */ static clock_t -cv__twait(kcondvar_t *cv, kmutex_t *mp, clock_t delta, int sigok) +cv__twait(kcondvar_t *cv, kmutex_t *mp, clock_t delta, int sigok, int hires) { timestruc_t ts; int err; @@ -151,7 +165,13 @@ cv__twait(kcondvar_t *cv, kmutex_t *mp, clock_t delta, int sigok) if (delta <= 0) return (-1); - clock2ts(delta, &ts); + if (hires) { + ts.tv_sec = delta / NANOSEC; + ts.tv_nsec = delta % NANOSEC; + } else { + ts.tv_sec = delta / hz; + ts.tv_nsec = (delta % hz) * (NANOSEC / hz); + } top: if (ts.tv_sec == 0 && ts.tv_nsec == 0) diff --git a/usr/src/lib/libfakekernel/common/cred.c b/usr/src/lib/libfakekernel/common/cred.c index 01baeb9f66..1563f02ac9 100644 --- a/usr/src/lib/libfakekernel/common/cred.c +++ b/usr/src/lib/libfakekernel/common/cred.c @@ -11,6 +11,7 @@ /* * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 RackTop Systems. */ @@ -52,6 +53,34 @@ crgetuid(const cred_t *cr) return (0); } +/*ARGSUSED*/ +uid_t +crgetruid(const cred_t *cr) +{ + return (0); +} + +/*ARGSUSED*/ +uid_t +crgetgid(const cred_t *cr) +{ + return (0); +} + +/*ARGSUSED*/ +int +crgetngroups(const cred_t *cr) +{ + return (0); +} + +/*ARGSUSED*/ +const gid_t * +crgetgroups(const cred_t *cr) +{ + return (NULL); +} + cred_t * zone_kcred(void) { diff --git a/usr/src/lib/libfakekernel/common/cyclic.c b/usr/src/lib/libfakekernel/common/cyclic.c new file mode 100644 index 0000000000..8fb5be2d85 --- /dev/null +++ b/usr/src/lib/libfakekernel/common/cyclic.c @@ -0,0 +1,36 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2017 RackTop Systems. + */ + +#include <sys/cyclic.h> + +/* ARGSUSED */ +cyclic_id_t +cyclic_add(cyc_handler_t *hdlr, cyc_time_t *when) +{ + return (1); +} + +/* ARGSUSED */ +void +cyclic_remove(cyclic_id_t id) +{ +} + +/* ARGSUSED */ +int +cyclic_reprogram(cyclic_id_t id, hrtime_t expiration) +{ + return (1); +} diff --git a/usr/src/lib/libfakekernel/common/kmisc.c b/usr/src/lib/libfakekernel/common/kmisc.c index 686812e9b0..2849552a66 100644 --- a/usr/src/lib/libfakekernel/common/kmisc.c +++ b/usr/src/lib/libfakekernel/common/kmisc.c @@ -11,6 +11,7 @@ /* * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 RackTop Systems. */ #include <sys/types.h> @@ -24,6 +25,7 @@ #include <time.h> #include <stdlib.h> #include <unistd.h> +#include <errno.h> #include <fakekernel.h> @@ -55,10 +57,55 @@ ddi_get_pid(void) return ((pid_t)getpid()); } +/* + * Find highest one bit set. + * Returns bit number + 1 of highest bit that is set, otherwise returns 0. + */ +int +highbit64(uint64_t i) +{ + int h = 1; + + if (i == 0) + return (0); + if (i & 0xffffffff00000000ULL) { + h += 32; i >>= 32; + } + if (i & 0xffff0000) { + h += 16; i >>= 16; + } + if (i & 0xff00) { + h += 8; i >>= 8; + } + if (i & 0xf0) { + h += 4; i >>= 4; + } + if (i & 0xc) { + h += 2; i >>= 2; + } + if (i & 0x2) { + h += 1; + } + return (h); +} + int ddi_strtoul(const char *str, char **endp, int base, unsigned long *res) { *res = strtoul(str, endp, base); + if (*res == 0) + return (errno); + return (0); +} + +int +ddi_strtoull(const char *str, char **nptr, int base, u_longlong_t *res) +{ + char *end; + + *res = strtoull(str, &end, base); + if (*res == 0) + return (errno); return (0); } @@ -69,6 +116,12 @@ delay(clock_t ticks) (void) poll(0, 0, msec); } +int +issig(int why) +{ + return (0); +} + /* * This library does not really need an "init" function, but * providing one the main program can call is an easy way to diff --git a/usr/src/lib/libfakekernel/common/ksid.c b/usr/src/lib/libfakekernel/common/ksid.c new file mode 100644 index 0000000000..a6a40aa7dc --- /dev/null +++ b/usr/src/lib/libfakekernel/common/ksid.c @@ -0,0 +1,68 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015 by Delphix. All rights reserved. + * Copyright (c) 2013, Joyent, Inc. All rights reserved. + * Copyright 2017 RackTop Systems. + */ + +#include <sys/sid.h> + +#include <umem.h> +#include <strings.h> + +static char * +ksid_strdup(const char *s) +{ + size_t len; + char *new; + + len = strlen(s); + new = umem_alloc(len + 1, KM_SLEEP); + bcopy(s, new, len); + new[len] = '\0'; + + return (new); +} + +static void +ksid_strfree(char *s) +{ + umem_free(s, strlen(s) + 1); +} + +ksiddomain_t * +ksid_lookupdomain(const char *dom) +{ + ksiddomain_t *kd; + + kd = umem_zalloc(sizeof (ksiddomain_t), UMEM_NOFAIL); + kd->kd_name = ksid_strdup(dom); + return (kd); +} + +void +ksiddomain_rele(ksiddomain_t *ksid) +{ + ksid_strfree(ksid->kd_name); + umem_free(ksid, sizeof (ksiddomain_t)); +} diff --git a/usr/src/lib/libfakekernel/common/kstat.c b/usr/src/lib/libfakekernel/common/kstat.c index ed877fd694..849f0ddf0e 100644 --- a/usr/src/lib/libfakekernel/common/kstat.c +++ b/usr/src/lib/libfakekernel/common/kstat.c @@ -11,6 +11,7 @@ /* * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 RackTop Systems. */ #include <sys/types.h> @@ -36,6 +37,11 @@ kstat_create(const char *ks_module, int ks_instance, const char *ks_name, /*ARGSUSED*/ void +kstat_named_init(kstat_named_t *knp, const char *name, uchar_t type) +{} + +/*ARGSUSED*/ +void kstat_install(kstat_t *ksp) {} @@ -43,3 +49,33 @@ kstat_install(kstat_t *ksp) void kstat_delete(kstat_t *ksp) {} + +/*ARGSUSED*/ +void +kstat_waitq_enter(kstat_io_t *kiop) +{} + +/*ARGSUSED*/ +void +kstat_waitq_exit(kstat_io_t *kiop) +{} + +/*ARGSUSED*/ +void +kstat_runq_enter(kstat_io_t *kiop) +{} + +/*ARGSUSED*/ +void +kstat_runq_exit(kstat_io_t *kiop) +{} + +/*ARGSUSED*/ +void +kstat_waitq_to_runq(kstat_io_t *kiop) +{} + +/*ARGSUSED*/ +void +kstat_runq_back_to_waitq(kstat_io_t *kiop) +{} diff --git a/usr/src/lib/libfakekernel/common/mapfile-vers b/usr/src/lib/libfakekernel/common/mapfile-vers index cae4b7b30b..2aed6dfef2 100644 --- a/usr/src/lib/libfakekernel/common/mapfile-vers +++ b/usr/src/lib/libfakekernel/common/mapfile-vers @@ -12,6 +12,7 @@ # # Copyright 2015 Nexenta Systems, Inc. All rights reserved. # Copyright (c) 2017, Joyent, Inc. +# Copyright 2017 RackTop Systems. # # @@ -44,8 +45,16 @@ SYMBOL_VERSION SUNWprivate_1.1 { copyinstr; copystr; + cyclic_add; + cyclic_remove; + cyclic_reprogram; + crfree; crgetuid; + crgetruid; + crgetgid; + crgetngroups; + crgetgroups; crhold; cv_broadcast; @@ -56,6 +65,7 @@ SYMBOL_VERSION SUNWprivate_1.1 { cv_signal; cv_timedwait; cv_timedwait_sig; + cv_timedwait_hires; cv_wait; cv_wait_sig; @@ -63,9 +73,12 @@ SYMBOL_VERSION SUNWprivate_1.1 { ddi_get_lbolt; ddi_get_pid; ddi_strtoul; + ddi_strtoull; delay; + fm_panic; + fakekernel_cprintf { FLAGS = NODIRECT }; fakekernel_init; fakekernel_putlog { FLAGS = NODIRECT }; @@ -76,12 +89,17 @@ SYMBOL_VERSION SUNWprivate_1.1 { hz; + highbit64; + + issig; + kcred; kiconv; kiconv_close; kiconv_open; kmem_alloc; + kmem_asprintf; kmem_cache_alloc; kmem_cache_create; kmem_cache_destroy; @@ -95,10 +113,15 @@ SYMBOL_VERSION SUNWprivate_1.1 { kmutex_destroy; kmutex_init; + kmutex_enter; + kmutex_exit; ksema_destroy; ksema_init; + ksid_lookupdomain; + ksiddomain_rele; + ksocket_accept; ksocket_bind; ksocket_bind_helper { FLAGS = NODIRECT }; @@ -122,13 +145,18 @@ SYMBOL_VERSION SUNWprivate_1.1 { kstat_create; kstat_create_zone; + kstat_named_init; kstat_delete; kstat_install; + kstat_waitq_enter; + kstat_waitq_exit; + kstat_runq_enter; + kstat_runq_exit; + kstat_waitq_to_runq; + kstat_runq_back_to_waitq; msec_per_tick; - mutex_enter; - mutex_exit; mutex_owned; mutex_owner; mutex_tryenter; @@ -167,10 +195,12 @@ SYMBOL_VERSION SUNWprivate_1.1 { strfree; + system_taskq; system_taskq_fini; system_taskq_init; taskq_create; taskq_create_proc; + taskq_create_sysdc; taskq_destroy; taskq_dispatch; taskq_dispatch_ent; @@ -178,7 +208,14 @@ SYMBOL_VERSION SUNWprivate_1.1 { taskq_empty; taskq_wait; + thread_create; thread_join; + thread_exit; + + tsd_get; + tsd_set; + tsd_create; + tsd_destroy; tick_per_msec; tsignal; diff --git a/usr/src/lib/libfakekernel/common/mutex.c b/usr/src/lib/libfakekernel/common/mutex.c index 03bfa7d2a4..1200d589dc 100644 --- a/usr/src/lib/libfakekernel/common/mutex.c +++ b/usr/src/lib/libfakekernel/common/mutex.c @@ -11,6 +11,7 @@ /* * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 RackTop Systems. */ /* @@ -29,7 +30,6 @@ int _lwp_mutex_unlock(lwp_mutex_t *); int _lwp_mutex_trylock(lwp_mutex_t *); extern clock_t ddi_get_lbolt(void); -extern void clock2ts(clock_t, timespec_t *); static const lwp_mutex_t default_mutex = {{0, 0, 0, {USYNC_THREAD}, _MUTEX_MAGIC}, @@ -51,7 +51,7 @@ kmutex_destroy(kmutex_t *mp) } void -mutex_enter(kmutex_t *mp) +kmutex_enter(kmutex_t *mp) { VERIFY(0 == _lwp_mutex_lock(&mp->m_lock)); mp->m_owner = _curthread(); @@ -71,7 +71,7 @@ mutex_tryenter(kmutex_t *mp) } void -mutex_exit(kmutex_t *mp) +kmutex_exit(kmutex_t *mp) { ASSERT(mp->m_owner == _curthread()); mp->m_owner = _KTHREAD_INVALID; diff --git a/usr/src/lib/libfakekernel/common/printf.c b/usr/src/lib/libfakekernel/common/printf.c index 1bcef683d1..1cfded9239 100644 --- a/usr/src/lib/libfakekernel/common/printf.c +++ b/usr/src/lib/libfakekernel/common/printf.c @@ -22,6 +22,7 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012 by Delphix. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 RackTop Systems. */ #include <sys/param.h> @@ -71,7 +72,7 @@ fakekernel_putlog(char *msg, size_t len, int flags) */ void fakekernel_cprintf(const char *fmt, va_list adx, int flags, - const char *prefix, const char *suffix) + const char *prefix, const char *suffix) { size_t bufsize = LOG_MSGSIZE; char buf[LOG_MSGSIZE]; @@ -130,6 +131,16 @@ panic(const char *fmt, ...) } void +fm_panic(const char *fmt, ...) +{ + va_list adx; + + va_start(adx, fmt); + vpanic(fmt, adx); + va_end(adx); +} + +void vcmn_err(int ce, const char *fmt, va_list adx) { diff --git a/usr/src/lib/libfakekernel/common/strext.c b/usr/src/lib/libfakekernel/common/strext.c new file mode 100644 index 0000000000..7e0ef6f502 --- /dev/null +++ b/usr/src/lib/libfakekernel/common/strext.c @@ -0,0 +1,42 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2017 RackTop Systems. + */ + +#include <sys/kmem.h> +#include <sys/varargs.h> +#include <sys/cmn_err.h> + +/* + * Do not change the length of the returned string; it must be freed + * with strfree(). + */ +char * +kmem_asprintf(const char *fmt, ...) +{ + int size; + va_list adx; + char *buf; + + va_start(adx, fmt); + size = vsnprintf(NULL, 0, fmt, adx) + 1; + va_end(adx); + + buf = kmem_alloc(size, KM_SLEEP); + + va_start(adx, fmt); + size = vsnprintf(buf, size, fmt, adx); + va_end(adx); + + return (buf); +} diff --git a/usr/src/lib/libfakekernel/common/sys/cmn_err.h b/usr/src/lib/libfakekernel/common/sys/cmn_err.h new file mode 100644 index 0000000000..c77b22b868 --- /dev/null +++ b/usr/src/lib/libfakekernel/common/sys/cmn_err.h @@ -0,0 +1,80 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2016 Joyent, Inc. + * Copyright 2017 RackTop Systems. + */ + +#ifndef _SYS_CMN_ERR_H +#define _SYS_CMN_ERR_H + +#include <stdio.h> + +#if !defined(_ASM) && (defined(_KERNEL) || defined(_FAKE_KERNEL)) +#include <sys/va_list.h> +#endif + +#include <sys/dditypes.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* Common error handling severity levels */ + +#define CE_CONT 0 /* continuation */ +#define CE_NOTE 1 /* notice */ +#define CE_WARN 2 /* warning */ +#define CE_PANIC 3 /* panic */ +#define CE_IGNORE 4 /* print nothing */ + +#if !defined(_ASM) && (defined(_KERNEL) || defined(_FAKE_KERNEL)) + +/*PRINTFLIKE2*/ +extern void cmn_err(int, const char *, ...) + __KPRINTFLIKE(2); + +extern void vcmn_err(int, const char *, __va_list) + __KVPRINTFLIKE(2); + +/*PRINTFLIKE1*/ +extern void panic(const char *, ...) + __KPRINTFLIKE(1) __NORETURN; + +extern void vpanic(const char *, __va_list) + __KVPRINTFLIKE(1) __NORETURN; + +#endif /* !_ASM && (_KERNEL || _FAKE_KERNEL) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_CMN_ERR_H */ diff --git a/usr/src/lib/libfakekernel/common/sys/condvar.h b/usr/src/lib/libfakekernel/common/sys/condvar.h index 043cc98bae..1fa88222a5 100644 --- a/usr/src/lib/libfakekernel/common/sys/condvar.h +++ b/usr/src/lib/libfakekernel/common/sys/condvar.h @@ -26,6 +26,7 @@ /* * Copyright (c) 2012 by Delphix. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 RackTop Systems. */ /* @@ -78,6 +79,8 @@ extern time_res_t time_res[]; #define TIME_RES_VALID(tr) (tr >= TR_NANOSEC && tr < TR_COUNT) +#define CALLOUT_FLAG_ABSOLUTE 0x2 + /* * condition variable function prototypes */ @@ -87,6 +90,8 @@ extern void cv_destroy(kcondvar_t *); extern void cv_wait(kcondvar_t *, kmutex_t *); extern void cv_wait_stop(kcondvar_t *, kmutex_t *, int); extern clock_t cv_timedwait(kcondvar_t *, kmutex_t *, clock_t); +extern clock_t cv_timedwait_hires(kcondvar_t *, kmutex_t *, hrtime_t, hrtime_t, + int); extern clock_t cv_reltimedwait(kcondvar_t *, kmutex_t *, clock_t, time_res_t); extern int cv_wait_sig(kcondvar_t *, kmutex_t *); extern clock_t cv_timedwait_sig(kcondvar_t *, kmutex_t *, clock_t); diff --git a/usr/src/lib/libfakekernel/common/sys/cred.h b/usr/src/lib/libfakekernel/common/sys/cred.h index ecfe70baab..d544e04275 100644 --- a/usr/src/lib/libfakekernel/common/sys/cred.h +++ b/usr/src/lib/libfakekernel/common/sys/cred.h @@ -20,6 +20,7 @@ */ /* * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 RackTop Systems. * * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. @@ -76,6 +77,9 @@ extern gid_t crgetsgid(const cred_t *); extern zoneid_t crgetzoneid(const cred_t *); extern projid_t crgetprojid(const cred_t *); +extern const gid_t *crgetgroups(const cred_t *); +extern int crgetngroups(const cred_t *); + #endif /* _KERNEL */ #ifdef __cplusplus diff --git a/usr/src/lib/libfakekernel/common/sys/mutex.h b/usr/src/lib/libfakekernel/common/sys/mutex.h index ea1e49aea3..0301cc24f5 100644 --- a/usr/src/lib/libfakekernel/common/sys/mutex.h +++ b/usr/src/lib/libfakekernel/common/sys/mutex.h @@ -21,6 +21,7 @@ /* * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 RackTop Systems. */ #ifndef _SYS_MUTEX_H @@ -73,6 +74,8 @@ typedef struct pad_mutex { } pad_mutex_t; #endif /* _KERNEL */ +extern char *volatile panicstr; /* panic string pointer */ + #define MUTEX_HELD(x) (mutex_owned(x)) #define MUTEX_NOT_HELD(x) (!mutex_owned(x) || panicstr) @@ -83,12 +86,20 @@ typedef struct pad_mutex { #define mutex_init kmutex_init #define mutex_destroy kmutex_destroy +/* + * We want to avoid binding against the versions of these + * functions in libc which causes bad things to happen. + */ +#define mutex_enter kmutex_enter +#define mutex_exit kmutex_exit + extern void kmutex_init(kmutex_t *, char *, kmutex_type_t, void *); extern void kmutex_destroy(kmutex_t *); -extern void mutex_enter(kmutex_t *); +extern void kmutex_enter(kmutex_t *); +extern void kmutex_exit(kmutex_t *); + extern int mutex_tryenter(kmutex_t *); -extern void mutex_exit(kmutex_t *); extern int mutex_owned(const kmutex_t *); extern void *mutex_owner(const kmutex_t *); diff --git a/usr/src/lib/libfakekernel/common/sys/proc.h b/usr/src/lib/libfakekernel/common/sys/proc.h index 1ded4eb5a7..f896674f15 100644 --- a/usr/src/lib/libfakekernel/common/sys/proc.h +++ b/usr/src/lib/libfakekernel/common/sys/proc.h @@ -22,6 +22,7 @@ /* * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 RackTop Systems. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -110,6 +111,18 @@ extern proc_t p0; /* process 0 */ extern struct plock p0lock; /* p0's plock */ extern struct pid pid0; /* p0's pid */ +extern int issig(int); +#define ISSIG(thr, why) issig(why) + +/* Reasons for calling issig() */ + +#define FORREAL 0 /* Usual side-effects */ +#define JUSTLOOKING 1 /* Don't stop the process */ + +extern void tsd_create(uint_t *, void (*)(void *)); +extern void tsd_destroy(uint_t *); +extern void *tsd_get(uint_t); +extern int tsd_set(uint_t, void *); /* * This is normally in sunddi.h but diff --git a/usr/src/lib/libfakekernel/common/taskq.c b/usr/src/lib/libfakekernel/common/taskq.c index ffaa73fccc..be734f9096 100644 --- a/usr/src/lib/libfakekernel/common/taskq.c +++ b/usr/src/lib/libfakekernel/common/taskq.c @@ -26,6 +26,7 @@ * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2017, Joyent, Inc. + * Copyright 2017 RackTop Systems. */ #include <sys/taskq_impl.h> @@ -39,6 +40,9 @@ #include <sys/sysmacros.h> #include <sys/unistd.h> +/* avoid <sys/disp.h> */ +#define maxclsyspri 99 + /* avoid <unistd.h> */ extern long sysconf(int); @@ -278,8 +282,17 @@ taskq_create(const char *name, int nthr, pri_t pri, int minalloc, /*ARGSUSED*/ taskq_t * +taskq_create_sysdc(const char *name, int nthr, int minalloc, + int maxalloc, proc_t *proc, uint_t dc, uint_t flags) +{ + return (taskq_create_proc(name, nthr, maxclsyspri, + minalloc, maxalloc, proc, flags)); +} + +/*ARGSUSED*/ +taskq_t * taskq_create_proc(const char *name, int nthreads, pri_t pri, - int minalloc, int maxalloc, proc_t *proc, uint_t flags) + int minalloc, int maxalloc, proc_t *proc, uint_t flags) { taskq_t *tq = kmem_zalloc(sizeof (taskq_t), KM_SLEEP); int t; diff --git a/usr/src/lib/libfakekernel/common/thread.c b/usr/src/lib/libfakekernel/common/thread.c index ba16f3b8d5..7cfac712a8 100644 --- a/usr/src/lib/libfakekernel/common/thread.c +++ b/usr/src/lib/libfakekernel/common/thread.c @@ -11,11 +11,13 @@ /* * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 RackTop Systems. */ #include <sys/cmn_err.h> #include <sys/thread.h> #include <sys/zone.h> +#include <sys/proc.h> #define _SYNCH_H /* keep out <synch.h> */ #include <thread.h> @@ -123,3 +125,28 @@ zthread_exit(void) thread_exit(); /* NOTREACHED */ } + +void +tsd_create(uint_t *keyp, void (*destructor)(void *)) +{ + VERIFY0(thr_keycreate(keyp, destructor)); +} + +/*ARGSUSED*/ +void +tsd_destroy(uint_t *keyp) +{} + +void * +tsd_get(uint_t key) +{ + void *value; + + return (thr_getspecific(key, &value) ? NULL : value); +} + +int +tsd_set(uint_t key, void *value) +{ + return (thr_setspecific(key, value)); +} diff --git a/usr/src/lib/libzpool/Makefile.com b/usr/src/lib/libzpool/Makefile.com index 13aa1858c6..e4511dc50a 100644 --- a/usr/src/lib/libzpool/Makefile.com +++ b/usr/src/lib/libzpool/Makefile.com @@ -29,7 +29,7 @@ VERS= .1 # include the list of ZFS sources include ../../../uts/common/Makefile.files -KERNEL_OBJS = kernel.o taskq.o util.o +KERNEL_OBJS = kernel.o util.o DTRACE_OBJS = zfs.o OBJECTS=$(LUA_OBJS) $(ZFS_COMMON_OBJS) $(ZFS_SHARED_OBJS) $(KERNEL_OBJS) @@ -67,8 +67,13 @@ C99LMODE= -Xc99=%all CFLAGS += -g $(CCVERBOSE) $(CNOGLOBAL) CFLAGS64 += -g $(CCVERBOSE) $(CNOGLOBAL) -LDLIBS += -lcmdutils -lumem -lavl -lnvpair -lz -lc -lsysevent -lmd -CPPFLAGS += $(INCS) -DDEBUG +LDLIBS += -lcmdutils -lumem -lavl -lnvpair -lz -lc -lsysevent -lmd \ + -lfakekernel +CPPFLAGS.first = -I$(SRC)/lib/libfakekernel/common +CPPFLAGS += $(INCS) -DDEBUG -D_FAKE_KERNEL + +LINTFLAGS += -erroff=E_STATIC_UNUSED $(INCS) +LINTFLAGS64 += -erroff=E_STATIC_UNUSED $(INCS) CERRWARN += -_gcc=-Wno-parentheses CERRWARN += -_gcc=-Wno-switch diff --git a/usr/src/lib/libzpool/common/kernel.c b/usr/src/lib/libzpool/common/kernel.c index 590398d118..1d94907b1a 100644 --- a/usr/src/lib/libzpool/common/kernel.c +++ b/usr/src/lib/libzpool/common/kernel.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) 2013, Joyent, Inc. All rights reserved. + * Copyright 2017 RackTop Systems. */ #include <assert.h> @@ -41,12 +42,14 @@ #include <sys/utsname.h> #include <sys/systeminfo.h> +extern void system_taskq_init(void); +extern void system_taskq_fini(void); + /* * Emulation of kernel services in userland. */ -int aok; -uint64_t physmem; +pgcnt_t physmem; vnode_t *rootdir = (vnode_t *)0xabcd1234; char hw_serial[HW_HOSTID_LEN]; kmutex_t cpu_lock; @@ -59,337 +62,6 @@ struct utsname utsname = { "userland", "libzpool", "1", "1", "na" }; -/* this only exists to have its address taken */ -struct proc p0; - -/* - * ========================================================================= - * threads - * ========================================================================= - */ -/*ARGSUSED*/ -kthread_t * -zk_thread_create(void (*func)(), void *arg, uint64_t len) -{ - thread_t tid; - - ASSERT0(len); - VERIFY(thr_create(0, 0, (void *(*)(void *))func, arg, THR_DETACHED, - &tid) == 0); - - return ((void *)(uintptr_t)tid); -} - -/* - * ========================================================================= - * kstats - * ========================================================================= - */ -/*ARGSUSED*/ -kstat_t * -kstat_create(const char *module, int instance, const char *name, - const char *class, uchar_t type, ulong_t ndata, uchar_t ks_flag) -{ - return (NULL); -} - -/*ARGSUSED*/ -void -kstat_named_init(kstat_named_t *knp, const char *name, uchar_t type) -{} - -/*ARGSUSED*/ -void -kstat_install(kstat_t *ksp) -{} - -/*ARGSUSED*/ -void -kstat_delete(kstat_t *ksp) -{} - -/*ARGSUSED*/ -void -kstat_waitq_enter(kstat_io_t *kiop) -{} - -/*ARGSUSED*/ -void -kstat_waitq_exit(kstat_io_t *kiop) -{} - -/*ARGSUSED*/ -void -kstat_runq_enter(kstat_io_t *kiop) -{} - -/*ARGSUSED*/ -void -kstat_runq_exit(kstat_io_t *kiop) -{} - -/*ARGSUSED*/ -void -kstat_waitq_to_runq(kstat_io_t *kiop) -{} - -/*ARGSUSED*/ -void -kstat_runq_back_to_waitq(kstat_io_t *kiop) -{} - -/* - * ========================================================================= - * mutexes - * ========================================================================= - */ -void -zmutex_init(kmutex_t *mp) -{ - mp->m_owner = NULL; - mp->initialized = B_TRUE; - (void) _mutex_init(&mp->m_lock, USYNC_THREAD, NULL); -} - -void -zmutex_destroy(kmutex_t *mp) -{ - ASSERT(mp->initialized == B_TRUE); - ASSERT(mp->m_owner == NULL); - (void) _mutex_destroy(&(mp)->m_lock); - mp->m_owner = (void *)-1UL; - mp->initialized = B_FALSE; -} - -void -zmutex_enter(kmutex_t *mp) -{ - ASSERT(mp->initialized == B_TRUE); - ASSERT(mp->m_owner != (void *)-1UL); - ASSERT(mp->m_owner != curthread); - VERIFY(mutex_lock(&mp->m_lock) == 0); - ASSERT(mp->m_owner == NULL); - mp->m_owner = curthread; -} - -int -mutex_tryenter(kmutex_t *mp) -{ - ASSERT(mp->initialized == B_TRUE); - ASSERT(mp->m_owner != (void *)-1UL); - if (0 == mutex_trylock(&mp->m_lock)) { - ASSERT(mp->m_owner == NULL); - mp->m_owner = curthread; - return (1); - } else { - return (0); - } -} - -void -zmutex_exit(kmutex_t *mp) -{ - ASSERT(mp->initialized == B_TRUE); - ASSERT(mutex_owner(mp) == curthread); - mp->m_owner = NULL; - VERIFY(mutex_unlock(&mp->m_lock) == 0); -} - -void * -mutex_owner(kmutex_t *mp) -{ - ASSERT(mp->initialized == B_TRUE); - return (mp->m_owner); -} - -/* - * ========================================================================= - * rwlocks - * ========================================================================= - */ -/*ARGSUSED*/ -void -rw_init(krwlock_t *rwlp, char *name, int type, void *arg) -{ - rwlock_init(&rwlp->rw_lock, USYNC_THREAD, NULL); - rwlp->rw_owner = NULL; - rwlp->initialized = B_TRUE; -} - -void -rw_destroy(krwlock_t *rwlp) -{ - rwlock_destroy(&rwlp->rw_lock); - rwlp->rw_owner = (void *)-1UL; - rwlp->initialized = B_FALSE; -} - -void -rw_enter(krwlock_t *rwlp, krw_t rw) -{ - ASSERT(!RW_LOCK_HELD(rwlp)); - ASSERT(rwlp->initialized == B_TRUE); - ASSERT(rwlp->rw_owner != (void *)-1UL); - ASSERT(rwlp->rw_owner != curthread); - - if (rw == RW_WRITER) - VERIFY(rw_wrlock(&rwlp->rw_lock) == 0); - else - VERIFY(rw_rdlock(&rwlp->rw_lock) == 0); - - rwlp->rw_owner = curthread; -} - -void -rw_exit(krwlock_t *rwlp) -{ - ASSERT(rwlp->initialized == B_TRUE); - ASSERT(rwlp->rw_owner != (void *)-1UL); - - rwlp->rw_owner = NULL; - VERIFY(rw_unlock(&rwlp->rw_lock) == 0); -} - -int -rw_tryenter(krwlock_t *rwlp, krw_t rw) -{ - int rv; - - ASSERT(rwlp->initialized == B_TRUE); - ASSERT(rwlp->rw_owner != (void *)-1UL); - - if (rw == RW_WRITER) - rv = rw_trywrlock(&rwlp->rw_lock); - else - rv = rw_tryrdlock(&rwlp->rw_lock); - - if (rv == 0) { - rwlp->rw_owner = curthread; - return (1); - } - - return (0); -} - -/*ARGSUSED*/ -int -rw_tryupgrade(krwlock_t *rwlp) -{ - ASSERT(rwlp->initialized == B_TRUE); - ASSERT(rwlp->rw_owner != (void *)-1UL); - - return (0); -} - -/* - * ========================================================================= - * condition variables - * ========================================================================= - */ -/*ARGSUSED*/ -void -cv_init(kcondvar_t *cv, char *name, int type, void *arg) -{ - VERIFY(cond_init(cv, type, NULL) == 0); -} - -void -cv_destroy(kcondvar_t *cv) -{ - VERIFY(cond_destroy(cv) == 0); -} - -void -cv_wait(kcondvar_t *cv, kmutex_t *mp) -{ - ASSERT(mutex_owner(mp) == curthread); - mp->m_owner = NULL; - int ret = cond_wait(cv, &mp->m_lock); - VERIFY(ret == 0 || ret == EINTR); - mp->m_owner = curthread; -} - -clock_t -cv_timedwait(kcondvar_t *cv, kmutex_t *mp, clock_t abstime) -{ - int error; - timestruc_t ts; - clock_t delta; - -top: - delta = abstime - ddi_get_lbolt(); - if (delta <= 0) - return (-1); - - ts.tv_sec = delta / hz; - ts.tv_nsec = (delta % hz) * (NANOSEC / hz); - - ASSERT(mutex_owner(mp) == curthread); - mp->m_owner = NULL; - error = cond_reltimedwait(cv, &mp->m_lock, &ts); - mp->m_owner = curthread; - - if (error == ETIME) - return (-1); - - if (error == EINTR) - goto top; - - ASSERT(error == 0); - - return (1); -} - -/*ARGSUSED*/ -clock_t -cv_timedwait_hires(kcondvar_t *cv, kmutex_t *mp, hrtime_t tim, hrtime_t res, - int flag) -{ - int error; - timestruc_t ts; - hrtime_t delta; - - ASSERT(flag == 0 || flag == CALLOUT_FLAG_ABSOLUTE); - -top: - delta = tim; - if (flag & CALLOUT_FLAG_ABSOLUTE) - delta -= gethrtime(); - - if (delta <= 0) - return (-1); - - ts.tv_sec = delta / NANOSEC; - ts.tv_nsec = delta % NANOSEC; - - ASSERT(mutex_owner(mp) == curthread); - mp->m_owner = NULL; - error = cond_reltimedwait(cv, &mp->m_lock, &ts); - mp->m_owner = curthread; - - if (error == ETIME) - return (-1); - - if (error == EINTR) - goto top; - - ASSERT(error == 0); - - return (1); -} - -void -cv_signal(kcondvar_t *cv) -{ - VERIFY(cond_signal(cv) == 0); -} - -void -cv_broadcast(kcondvar_t *cv) -{ - VERIFY(cond_broadcast(cv) == 0); -} - /* * ========================================================================= * vnode operations @@ -691,56 +363,6 @@ __dprintf(const char *file, const char *func, int line, const char *fmt, ...) /* * ========================================================================= - * cmn_err() and panic() - * ========================================================================= - */ -static char ce_prefix[CE_IGNORE][10] = { "", "NOTICE: ", "WARNING: ", "" }; -static char ce_suffix[CE_IGNORE][2] = { "", "\n", "\n", "" }; - -void -vpanic(const char *fmt, va_list adx) -{ - char buf[512]; - (void) vsnprintf(buf, 512, fmt, adx); - assfail(buf, NULL, 0); - abort(); /* necessary to make vpanic meet noreturn requirements */ -} - -void -panic(const char *fmt, ...) -{ - va_list adx; - - va_start(adx, fmt); - vpanic(fmt, adx); - va_end(adx); -} - -void -vcmn_err(int ce, const char *fmt, va_list adx) -{ - if (ce == CE_PANIC) - vpanic(fmt, adx); - if (ce != CE_NOTE) { /* suppress noise in userland stress testing */ - (void) fprintf(stderr, "%s", ce_prefix[ce]); - (void) vfprintf(stderr, fmt, adx); - (void) fprintf(stderr, "%s", ce_suffix[ce]); - } -} - -/*PRINTFLIKE2*/ -void -cmn_err(int ce, const char *fmt, ...) -{ - va_list adx; - - va_start(adx, fmt); - vcmn_err(ce, fmt, adx); - va_end(adx); -} - -/* - * ========================================================================= * kobj interfaces * ========================================================================= */ @@ -794,124 +416,6 @@ kobj_get_filesize(struct _buf *file, uint64_t *size) /* * ========================================================================= - * misc routines - * ========================================================================= - */ - -void -delay(clock_t ticks) -{ - poll(0, 0, ticks * (1000 / hz)); -} - -/* - * Find highest one bit set. - * Returns bit number + 1 of highest bit that is set, otherwise returns 0. - */ -int -highbit64(uint64_t i) -{ - int h = 1; - - if (i == 0) - return (0); - if (i & 0xffffffff00000000ULL) { - h += 32; i >>= 32; - } - if (i & 0xffff0000) { - h += 16; i >>= 16; - } - if (i & 0xff00) { - h += 8; i >>= 8; - } - if (i & 0xf0) { - h += 4; i >>= 4; - } - if (i & 0xc) { - h += 2; i >>= 2; - } - if (i & 0x2) { - h += 1; - } - return (h); -} - -static int random_fd = -1, urandom_fd = -1; - -static int -random_get_bytes_common(uint8_t *ptr, size_t len, int fd) -{ - size_t resid = len; - ssize_t bytes; - - ASSERT(fd != -1); - - while (resid != 0) { - bytes = read(fd, ptr, resid); - ASSERT3S(bytes, >=, 0); - ptr += bytes; - resid -= bytes; - } - - return (0); -} - -int -random_get_bytes(uint8_t *ptr, size_t len) -{ - return (random_get_bytes_common(ptr, len, random_fd)); -} - -int -random_get_pseudo_bytes(uint8_t *ptr, size_t len) -{ - return (random_get_bytes_common(ptr, len, urandom_fd)); -} - -int -ddi_strtoul(const char *hw_serial, char **nptr, int base, unsigned long *result) -{ - char *end; - - *result = strtoul(hw_serial, &end, base); - if (*result == 0) - return (errno); - return (0); -} - -int -ddi_strtoull(const char *str, char **nptr, int base, u_longlong_t *result) -{ - char *end; - - *result = strtoull(str, &end, base); - if (*result == 0) - return (errno); - return (0); -} - -/* ARGSUSED */ -cyclic_id_t -cyclic_add(cyc_handler_t *hdlr, cyc_time_t *when) -{ - return (1); -} - -/* ARGSUSED */ -void -cyclic_remove(cyclic_id_t id) -{ -} - -/* ARGSUSED */ -int -cyclic_reprogram(cyclic_id_t id, hrtime_t expiration) -{ - return (1); -} - -/* - * ========================================================================= * kernel emulation setup & teardown * ========================================================================= */ @@ -940,9 +444,6 @@ kernel_init(int mode) (void) snprintf(hw_serial, sizeof (hw_serial), "%ld", (mode & FWRITE) ? gethostid() : 0); - VERIFY((random_fd = open("/dev/random", O_RDONLY)) != -1); - VERIFY((urandom_fd = open("/dev/urandom", O_RDONLY)) != -1); - system_taskq_init(); mutex_init(&cpu_lock, NULL, MUTEX_DEFAULT, NULL); @@ -958,12 +459,6 @@ kernel_fini(void) spa_fini(); system_taskq_fini(); - - close(random_fd); - close(urandom_fd); - - random_fd = -1; - urandom_fd = -1; } int @@ -991,36 +486,6 @@ z_compress_level(void *dst, size_t *dstlen, const void *src, size_t srclen, return (ret); } -uid_t -crgetuid(cred_t *cr) -{ - return (0); -} - -uid_t -crgetruid(cred_t *cr) -{ - return (0); -} - -gid_t -crgetgid(cred_t *cr) -{ - return (0); -} - -int -crgetngroups(cred_t *cr) -{ - return (0); -} - -gid_t * -crgetgroups(cred_t *cr) -{ - return (NULL); -} - int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr) { @@ -1039,47 +504,6 @@ zfs_secpolicy_destroy_perms(const char *name, cred_t *cr) return (0); } -ksiddomain_t * -ksid_lookupdomain(const char *dom) -{ - ksiddomain_t *kd; - - kd = umem_zalloc(sizeof (ksiddomain_t), UMEM_NOFAIL); - kd->kd_name = spa_strdup(dom); - return (kd); -} - -void -ksiddomain_rele(ksiddomain_t *ksid) -{ - spa_strfree(ksid->kd_name); - umem_free(ksid, sizeof (ksiddomain_t)); -} - -/* - * Do not change the length of the returned string; it must be freed - * with strfree(). - */ -char * -kmem_asprintf(const char *fmt, ...) -{ - int size; - va_list adx; - char *buf; - - va_start(adx, fmt); - size = vsnprintf(NULL, 0, fmt, adx) + 1; - va_end(adx); - - buf = kmem_alloc(size, KM_SLEEP); - - va_start(adx, fmt); - size = vsnprintf(buf, size, fmt, adx); - va_end(adx); - - return (buf); -} - /* ARGSUSED */ int zfs_onexit_fd_hold(int fd, minor_t *minorp) diff --git a/usr/src/lib/libzpool/common/sys/zfs_context.h b/usr/src/lib/libzpool/common/sys/zfs_context.h index 45eeeaeb24..4993d77967 100644 --- a/usr/src/lib/libzpool/common/sys/zfs_context.h +++ b/usr/src/lib/libzpool/common/sys/zfs_context.h @@ -23,6 +23,7 @@ * Copyright 2011 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2017, Joyent, Inc. * Copyright (c) 2012, 2016 by Delphix. All rights reserved. + * Copyright 2017 RackTop Systems. */ #ifndef _SYS_ZFS_CONTEXT_H @@ -32,14 +33,10 @@ extern "C" { #endif -#define _SYS_MUTEX_H -#define _SYS_RWLOCK_H -#define _SYS_CONDVAR_H -#define _SYS_SYSTM_H -#define _SYS_T_LOCK_H +#define _SYNCH_H + #define _SYS_VNODE_H #define _SYS_VFS_H -#define _SYS_SUNDDI_H #define _SYS_CALLB_H #include <stdio.h> @@ -51,7 +48,6 @@ extern "C" { #include <errno.h> #include <string.h> #include <strings.h> -#include <synch.h> #include <thread.h> #include <assert.h> #include <alloca.h> @@ -80,25 +76,28 @@ extern "C" { #include <sys/u8_textprep.h> #include <sys/sysevent/eventdefs.h> #include <sys/sysevent/dev.h> -#include <sys/sunddi.h> #include <sys/debug.h> +#include <sys/taskq.h> +#include <sys/taskq_impl.h> +#include <sys/mutex.h> +#include <sys/proc.h> +#include <sys/condvar.h> +#include <sys/cmn_err.h> +#include <sys/kmem.h> +#include <sys/systm.h> +#include <sys/random.h> +#include <sys/buf.h> +#include <sys/sid.h> +#include <sys/acl.h> +#include <sys/bitmap.h> +#include <sys/systeminfo.h> +#include <sys/cpuvar.h> +#include <sys/pset.h> +#include <sys/kobj.h> +#include <sys/fm/util.h> #include "zfs.h" /* - * Debugging - */ - -/* - * Note that we are not using the debugging levels. - */ - -#define CE_CONT 0 /* continuation */ -#define CE_NOTE 1 /* notice */ -#define CE_WARN 2 /* warning */ -#define CE_PANIC 3 /* panic */ -#define CE_IGNORE 4 /* print nothing */ - -/* * ZFS debugging */ @@ -106,15 +105,6 @@ extern "C" { extern void dprintf_setup(int *argc, char **argv); #endif /* ZFS_DEBUG */ -extern void cmn_err(int, const char *, ...); -extern void vcmn_err(int, const char *, __va_list); -extern void panic(const char *, ...) __NORETURN; -extern void vpanic(const char *, __va_list) __NORETURN; - -#define fm_panic panic - -extern int aok; - /* * DTrace SDT probes have different signatures in userland than they do in * the kernel. If they're being used in kernel code, re-define them out of @@ -174,236 +164,15 @@ extern int aok; /* * Threads */ -#define curthread ((void *)(uintptr_t)thr_self()) - #define kpreempt(x) yield() - -typedef struct kthread kthread_t; - -#define thread_create(stk, stksize, func, arg, len, pp, state, pri) \ - zk_thread_create(func, arg, len) -#define thread_exit() thr_exit(NULL) -#define thread_join(t) panic("libzpool cannot join threads") - #define newproc(f, a, cid, pri, ctp, pid) (ENOSYS) -/* in libzpool, p0 exists only to have its address taken */ -struct proc { - uintptr_t this_is_never_used_dont_dereference_it; -}; - -extern struct proc p0; -#define curproc (&p0) - -#define PS_NONE -1 - -extern kthread_t *zk_thread_create(void (*func)(void*), void *arg, - uint64_t len); - -#define issig(why) (FALSE) -#define ISSIG(thr, why) (FALSE) - -/* - * Mutexes - */ -typedef struct kmutex { - void *m_owner; - boolean_t initialized; - mutex_t m_lock; -} kmutex_t; - -#define MUTEX_DEFAULT USYNC_THREAD -#undef MUTEX_HELD -#undef MUTEX_NOT_HELD -#define MUTEX_HELD(m) _mutex_held(&(m)->m_lock) -#define MUTEX_NOT_HELD(m) (!MUTEX_HELD(m)) - -/* - * Argh -- we have to get cheesy here because the kernel and userland - * have different signatures for the same routine. - */ -extern int _mutex_init(mutex_t *mp, int type, void *arg); -extern int _mutex_destroy(mutex_t *mp); - -#define mutex_init(mp, b, c, d) zmutex_init((kmutex_t *)(mp)) -#define mutex_destroy(mp) zmutex_destroy((kmutex_t *)(mp)) -#define mutex_enter(mp) zmutex_enter(mp) -#define mutex_exit(mp) zmutex_exit(mp) - -extern void zmutex_init(kmutex_t *mp); -extern void zmutex_destroy(kmutex_t *mp); -extern void zmutex_enter(kmutex_t *mp); -extern void zmutex_exit(kmutex_t *mp); -extern int mutex_tryenter(kmutex_t *mp); -extern void *mutex_owner(kmutex_t *mp); - -/* - * RW locks - */ -typedef struct krwlock { - void *rw_owner; - boolean_t initialized; - rwlock_t rw_lock; -} krwlock_t; - -typedef int krw_t; - -#define RW_READER 0 -#define RW_WRITER 1 -#define RW_DEFAULT USYNC_THREAD - -#undef RW_READ_HELD -#define RW_READ_HELD(x) _rw_read_held(&(x)->rw_lock) - -#undef RW_WRITE_HELD -#define RW_WRITE_HELD(x) _rw_write_held(&(x)->rw_lock) - -#undef RW_LOCK_HELD -#define RW_LOCK_HELD(x) (RW_READ_HELD(x) || RW_WRITE_HELD(x)) - -extern void rw_init(krwlock_t *rwlp, char *name, int type, void *arg); -extern void rw_destroy(krwlock_t *rwlp); -extern void rw_enter(krwlock_t *rwlp, krw_t rw); -extern int rw_tryenter(krwlock_t *rwlp, krw_t rw); -extern int rw_tryupgrade(krwlock_t *rwlp); -extern void rw_exit(krwlock_t *rwlp); -#define rw_downgrade(rwlp) do { } while (0) - -extern uid_t crgetuid(cred_t *cr); -extern uid_t crgetruid(cred_t *cr); -extern gid_t crgetgid(cred_t *cr); -extern int crgetngroups(cred_t *cr); -extern gid_t *crgetgroups(cred_t *cr); - -/* - * Condition variables - */ -typedef cond_t kcondvar_t; - -#define CV_DEFAULT USYNC_THREAD -#define CALLOUT_FLAG_ABSOLUTE 0x2 - -extern void cv_init(kcondvar_t *cv, char *name, int type, void *arg); -extern void cv_destroy(kcondvar_t *cv); -extern void cv_wait(kcondvar_t *cv, kmutex_t *mp); -extern clock_t cv_timedwait(kcondvar_t *cv, kmutex_t *mp, clock_t abstime); -extern clock_t cv_timedwait_hires(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim, - hrtime_t res, int flag); -extern void cv_signal(kcondvar_t *cv); -extern void cv_broadcast(kcondvar_t *cv); - -/* - * Thread-specific data - */ -#define tsd_get(k) pthread_getspecific(k) -#define tsd_set(k, v) pthread_setspecific(k, v) -#define tsd_create(kp, d) pthread_key_create(kp, d) -#define tsd_destroy(kp) /* nothing */ - /* - * kstat creation, installation and deletion - */ -extern kstat_t *kstat_create(const char *, int, - const char *, const char *, uchar_t, ulong_t, uchar_t); -extern void kstat_named_init(kstat_named_t *, const char *, uchar_t); -extern void kstat_install(kstat_t *); -extern void kstat_delete(kstat_t *); -extern void kstat_waitq_enter(kstat_io_t *); -extern void kstat_waitq_exit(kstat_io_t *); -extern void kstat_runq_enter(kstat_io_t *); -extern void kstat_runq_exit(kstat_io_t *); -extern void kstat_waitq_to_runq(kstat_io_t *); -extern void kstat_runq_back_to_waitq(kstat_io_t *); - -/* - * Kernel memory - */ -#define KM_SLEEP UMEM_NOFAIL -#define KM_PUSHPAGE KM_SLEEP -#define KM_NOSLEEP UMEM_DEFAULT -#define KM_NORMALPRI 0 /* not needed with UMEM_DEFAULT */ -#define KMC_NODEBUG UMC_NODEBUG -#define KMC_NOTOUCH 0 /* not needed for userland caches */ -#define kmem_alloc(_s, _f) umem_alloc(_s, _f) -#define kmem_zalloc(_s, _f) umem_zalloc(_s, _f) -#define kmem_free(_b, _s) umem_free(_b, _s) -#define kmem_cache_create(_a, _b, _c, _d, _e, _f, _g, _h, _i) \ - umem_cache_create(_a, _b, _c, _d, _e, _f, _g, _h, _i) -#define kmem_cache_destroy(_c) umem_cache_destroy(_c) -#define kmem_cache_alloc(_c, _f) umem_cache_alloc(_c, _f) -#define kmem_cache_free(_c, _b) umem_cache_free(_c, _b) -#define kmem_debugging() 0 -#define kmem_cache_reap_active() (B_FALSE) -#define kmem_cache_reap_soon(_c) /* nothing */ -#define kmem_cache_set_move(_c, _cb) /* nothing */ -#define vmem_qcache_reap(_v) /* nothing */ -#define POINTER_INVALIDATE(_pp) /* nothing */ -#define POINTER_IS_VALID(_p) 0 - -extern vmem_t *zio_arena; - -typedef umem_cache_t kmem_cache_t; - -typedef enum kmem_cbrc { - KMEM_CBRC_YES, - KMEM_CBRC_NO, - KMEM_CBRC_LATER, - KMEM_CBRC_DONT_NEED, - KMEM_CBRC_DONT_KNOW -} kmem_cbrc_t; - -/* - * Task queues + * vnodes */ -typedef struct taskq taskq_t; -typedef uintptr_t taskqid_t; -typedef void (task_func_t)(void *); - -typedef struct taskq_ent { - struct taskq_ent *tqent_next; - struct taskq_ent *tqent_prev; - task_func_t *tqent_func; - void *tqent_arg; - uintptr_t tqent_flags; -} taskq_ent_t; - -#define TQENT_FLAG_PREALLOC 0x1 /* taskq_dispatch_ent used */ - -#define TASKQ_PREPOPULATE 0x0001 -#define TASKQ_CPR_SAFE 0x0002 /* Use CPR safe protocol */ -#define TASKQ_DYNAMIC 0x0004 /* Use dynamic thread scheduling */ -#define TASKQ_THREADS_CPU_PCT 0x0008 /* Scale # threads by # cpus */ -#define TASKQ_DC_BATCH 0x0010 /* Mark threads as batch */ - -#define TQ_SLEEP KM_SLEEP /* Can block for memory */ -#define TQ_NOSLEEP KM_NOSLEEP /* cannot block for memory; may fail */ -#define TQ_NOQUEUE 0x02 /* Do not enqueue if can't dispatch */ -#define TQ_FRONT 0x08 /* Queue in front */ - - -extern taskq_t *system_taskq; - -extern taskq_t *taskq_create(const char *, int, pri_t, int, int, uint_t); -#define taskq_create_proc(a, b, c, d, e, p, f) \ - (taskq_create(a, b, c, d, e, f)) -#define taskq_create_sysdc(a, b, d, e, p, dc, f) \ - (taskq_create(a, b, maxclsyspri, d, e, f)) -extern taskqid_t taskq_dispatch(taskq_t *, task_func_t, void *, uint_t); -extern void taskq_dispatch_ent(taskq_t *, task_func_t, void *, uint_t, - taskq_ent_t *); -extern void taskq_destroy(taskq_t *); -extern boolean_t taskq_empty(taskq_t *); -extern void taskq_wait(taskq_t *); -extern int taskq_member(taskq_t *, void *); -extern void system_taskq_init(void); -extern void system_taskq_fini(void); - #define XVA_MAPSIZE 3 #define XVA_MAGIC 0x78766174 -/* - * vnodes - */ typedef struct vnode { uint64_t v_size; int v_fd; @@ -503,26 +272,13 @@ extern void vn_close(vnode_t *vp); extern vnode_t *rootdir; #include <sys/file.h> /* for FREAD, FWRITE, etc */ +#include <sys/sunddi.h> /* for ddi_strtoul, ddi_strtoull, etc */ +#include <sys/cyclic.h> /* for cyclic_add, cyclic remove, etc */ +#include <vm/seg_kmem.h> /* for zio_arena */ /* * Random stuff */ -#define ddi_get_lbolt() (gethrtime() >> 23) -#define ddi_get_lbolt64() (gethrtime() >> 23) -#define hz 119 /* frequency when using gethrtime() >> 23 for lbolt */ - -extern void delay(clock_t ticks); - -#define SEC_TO_TICK(sec) ((sec) * hz) -#define NSEC_TO_TICK(usec) ((usec) / (NANOSEC / hz)) - -#define gethrestime_sec() time(NULL) -#define gethrestime(t) \ - do {\ - (t)->tv_sec = gethrestime_sec();\ - (t)->tv_nsec = 0;\ - } while (0); - #define max_ncpus 64 #define boot_ncpus (sysconf(_SC_NPROCESSORS_ONLN)) @@ -531,22 +287,10 @@ extern void delay(clock_t ticks); #define CPU_SEQID (thr_self() & (max_ncpus - 1)) -#define kcred NULL -#define CRED() NULL - -#define ptob(x) ((x) * PAGESIZE) - -extern uint64_t physmem; - -extern int highbit64(uint64_t i); -extern int random_get_bytes(uint8_t *ptr, size_t len); -extern int random_get_pseudo_bytes(uint8_t *ptr, size_t len); - extern void kernel_init(int); extern void kernel_fini(void); struct spa; -extern void nicenum(uint64_t num, char *buf, size_t); extern void show_pool_stats(struct spa *); extern int set_global_var(char *arg); @@ -574,127 +318,14 @@ typedef struct callb_cpr { #define zone_dataset_visible(x, y) (1) #define INGLOBALZONE(z) (1) -extern char *kmem_asprintf(const char *fmt, ...); -#define strfree(str) kmem_free((str), strlen(str) + 1) - -/* - * Hostname information - */ -extern char hw_serial[]; /* for userland-emulated hostid access */ -extern int ddi_strtoul(const char *str, char **nptr, int base, - unsigned long *result); - -extern int ddi_strtoull(const char *str, char **nptr, int base, - u_longlong_t *result); - -/* ZFS Boot Related stuff. */ - -struct _buf { - intptr_t _fd; -}; - -struct bootstat { - uint64_t st_size; -}; - -typedef struct ace_object { - uid_t a_who; - uint32_t a_access_mask; - uint16_t a_flags; - uint16_t a_type; - uint8_t a_obj_type[16]; - uint8_t a_inherit_obj_type[16]; -} ace_object_t; - - -#define ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x05 -#define ACE_ACCESS_DENIED_OBJECT_ACE_TYPE 0x06 -#define ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE 0x07 -#define ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE 0x08 - -extern struct _buf *kobj_open_file(char *name); -extern int kobj_read_file(struct _buf *file, char *buf, unsigned size, - unsigned off); -extern void kobj_close_file(struct _buf *file); -extern int kobj_get_filesize(struct _buf *file, uint64_t *size); extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr); extern int zfs_secpolicy_rename_perms(const char *from, const char *to, cred_t *cr); extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr); -extern zoneid_t getzoneid(void); - -/* SID stuff */ -typedef struct ksiddomain { - uint_t kd_ref; - uint_t kd_len; - char *kd_name; -} ksiddomain_t; -ksiddomain_t *ksid_lookupdomain(const char *); -void ksiddomain_rele(ksiddomain_t *); - -#define DDI_SLEEP KM_SLEEP #define ddi_log_sysevent(_a, _b, _c, _d, _e, _f, _g) \ sysevent_post_event(_c, _d, _b, "libzpool", _e, _f) -/* - * Cyclic information - */ -extern kmutex_t cpu_lock; - -typedef uintptr_t cyclic_id_t; -typedef uint16_t cyc_level_t; -typedef void (*cyc_func_t)(void *); - -#define CY_LOW_LEVEL 0 -#define CY_INFINITY INT64_MAX -#define CYCLIC_NONE ((cyclic_id_t)0) - -typedef struct cyc_time { - hrtime_t cyt_when; - hrtime_t cyt_interval; -} cyc_time_t; - -typedef struct cyc_handler { - cyc_func_t cyh_func; - void *cyh_arg; - cyc_level_t cyh_level; -} cyc_handler_t; - -extern cyclic_id_t cyclic_add(cyc_handler_t *, cyc_time_t *); -extern void cyclic_remove(cyclic_id_t); -extern int cyclic_reprogram(cyclic_id_t, hrtime_t); - -/* - * Buf structure - */ -#define B_BUSY 0x0001 -#define B_DONE 0x0002 -#define B_ERROR 0x0004 -#define B_READ 0x0040 /* read when I/O occurs */ -#define B_WRITE 0x0100 /* non-read pseudo-flag */ - -typedef struct buf { - int b_flags; - size_t b_bcount; - union { - caddr_t b_addr; - } b_un; - - lldaddr_t _b_blkno; -#define b_lblkno _b_blkno._f - size_t b_resid; - size_t b_bufsize; - int (*b_iodone)(struct buf *); - int b_error; - void *b_private; -} buf_t; - -extern void bioinit(buf_t *); -extern void biodone(buf_t *); -extern void bioerror(buf_t *, int); -extern int geterror(buf_t *); - #ifdef __cplusplus } #endif diff --git a/usr/src/lib/libzpool/common/taskq.c b/usr/src/lib/libzpool/common/taskq.c deleted file mode 100644 index 11a646d62f..0000000000 --- a/usr/src/lib/libzpool/common/taskq.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -/* - * 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. - * Copyright (c) 2017, Joyent, Inc. - */ - -#include <sys/zfs_context.h> - -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; - kcondvar_t tq_wait_cv; - thread_t *tq_threadlist; - int tq_flags; - int tq_active; - int tq_nthreads; - int tq_nalloc; - int tq_minalloc; - int tq_maxalloc; - kcondvar_t tq_maxalloc_cv; - int tq_maxalloc_wait; - taskq_ent_t *tq_freelist; - taskq_ent_t tq_task; -}; - -static taskq_ent_t * -task_alloc(taskq_t *tq, int tqflags) -{ - taskq_ent_t *t; - int rv; - -again: if ((t = tq->tq_freelist) != NULL && tq->tq_nalloc >= tq->tq_minalloc) { - tq->tq_freelist = t->tqent_next; - } else { - if (tq->tq_nalloc >= tq->tq_maxalloc) { - if (!(tqflags & KM_SLEEP)) - return (NULL); - - /* - * We don't want to exceed tq_maxalloc, but we can't - * wait for other tasks to complete (and thus free up - * task structures) without risking deadlock with - * the caller. So, we just delay for one second - * to throttle the allocation rate. If we have tasks - * complete before one second timeout expires then - * taskq_ent_free will signal us and we will - * immediately retry the allocation. - */ - tq->tq_maxalloc_wait++; - rv = cv_timedwait(&tq->tq_maxalloc_cv, - &tq->tq_lock, ddi_get_lbolt() + hz); - tq->tq_maxalloc_wait--; - if (rv > 0) - goto again; /* signaled */ - } - mutex_exit(&tq->tq_lock); - - t = kmem_alloc(sizeof (taskq_ent_t), tqflags); - - mutex_enter(&tq->tq_lock); - if (t != NULL) - tq->tq_nalloc++; - } - return (t); -} - -static void -task_free(taskq_t *tq, taskq_ent_t *t) -{ - if (tq->tq_nalloc <= tq->tq_minalloc) { - t->tqent_next = tq->tq_freelist; - tq->tq_freelist = t; - } else { - tq->tq_nalloc--; - mutex_exit(&tq->tq_lock); - kmem_free(t, sizeof (taskq_ent_t)); - mutex_enter(&tq->tq_lock); - } - - if (tq->tq_maxalloc_wait) - cv_signal(&tq->tq_maxalloc_cv); -} - -taskqid_t -taskq_dispatch(taskq_t *tq, task_func_t func, void *arg, uint_t tqflags) -{ - taskq_ent_t *t; - - if (taskq_now) { - func(arg); - return (1); - } - - mutex_enter(&tq->tq_lock); - ASSERT(tq->tq_flags & TASKQ_ACTIVE); - if ((t = task_alloc(tq, tqflags)) == NULL) { - mutex_exit(&tq->tq_lock); - return (0); - } - if (tqflags & TQ_FRONT) { - t->tqent_next = tq->tq_task.tqent_next; - t->tqent_prev = &tq->tq_task; - } else { - t->tqent_next = &tq->tq_task; - t->tqent_prev = tq->tq_task.tqent_prev; - } - t->tqent_next->tqent_prev = t; - t->tqent_prev->tqent_next = t; - t->tqent_func = func; - t->tqent_arg = arg; - t->tqent_flags = 0; - cv_signal(&tq->tq_dispatch_cv); - mutex_exit(&tq->tq_lock); - return (1); -} - -void -taskq_dispatch_ent(taskq_t *tq, task_func_t func, void *arg, uint_t flags, - taskq_ent_t *t) -{ - ASSERT(func != NULL); - ASSERT(!(tq->tq_flags & TASKQ_DYNAMIC)); - - /* - * Mark it as a prealloc'd task. This is important - * to ensure that we don't free it later. - */ - t->tqent_flags |= TQENT_FLAG_PREALLOC; - /* - * Enqueue the task to the underlying queue. - */ - mutex_enter(&tq->tq_lock); - - if (flags & TQ_FRONT) { - t->tqent_next = tq->tq_task.tqent_next; - t->tqent_prev = &tq->tq_task; - } else { - t->tqent_next = &tq->tq_task; - t->tqent_prev = tq->tq_task.tqent_prev; - } - t->tqent_next->tqent_prev = t; - t->tqent_prev->tqent_next = t; - t->tqent_func = func; - t->tqent_arg = arg; - cv_signal(&tq->tq_dispatch_cv); - mutex_exit(&tq->tq_lock); -} - -boolean_t -taskq_empty(taskq_t *tq) -{ - boolean_t rv; - - mutex_enter(&tq->tq_lock); - rv = (tq->tq_task.tqent_next == &tq->tq_task) && (tq->tq_active == 0); - mutex_exit(&tq->tq_lock); - - return (rv); -} - -void -taskq_wait(taskq_t *tq) -{ - mutex_enter(&tq->tq_lock); - while (tq->tq_task.tqent_next != &tq->tq_task || tq->tq_active != 0) - cv_wait(&tq->tq_wait_cv, &tq->tq_lock); - mutex_exit(&tq->tq_lock); -} - -static void * -taskq_thread(void *arg) -{ - taskq_t *tq = arg; - taskq_ent_t *t; - boolean_t prealloc; - - mutex_enter(&tq->tq_lock); - while (tq->tq_flags & TASKQ_ACTIVE) { - if ((t = tq->tq_task.tqent_next) == &tq->tq_task) { - if (--tq->tq_active == 0) - cv_broadcast(&tq->tq_wait_cv); - cv_wait(&tq->tq_dispatch_cv, &tq->tq_lock); - tq->tq_active++; - continue; - } - t->tqent_prev->tqent_next = t->tqent_next; - t->tqent_next->tqent_prev = t->tqent_prev; - t->tqent_next = NULL; - t->tqent_prev = NULL; - prealloc = t->tqent_flags & TQENT_FLAG_PREALLOC; - mutex_exit(&tq->tq_lock); - - rw_enter(&tq->tq_threadlock, RW_READER); - t->tqent_func(t->tqent_arg); - rw_exit(&tq->tq_threadlock); - - mutex_enter(&tq->tq_lock); - if (!prealloc) - task_free(tq, t); - } - tq->tq_nthreads--; - cv_broadcast(&tq->tq_wait_cv); - mutex_exit(&tq->tq_lock); - return (NULL); -} - -/*ARGSUSED*/ -taskq_t * -taskq_create(const char *name, int nthreads, pri_t pri, - int minalloc, int maxalloc, uint_t flags) -{ - taskq_t *tq = kmem_zalloc(sizeof (taskq_t), KM_SLEEP); - int t; - - if (flags & TASKQ_THREADS_CPU_PCT) { - int pct; - ASSERT3S(nthreads, >=, 0); - ASSERT3S(nthreads, <=, 100); - pct = MIN(nthreads, 100); - pct = MAX(pct, 0); - - nthreads = (sysconf(_SC_NPROCESSORS_ONLN) * pct) / 100; - nthreads = MAX(nthreads, 1); /* need at least 1 thread */ - } else { - ASSERT3S(nthreads, >=, 1); - } - - rw_init(&tq->tq_threadlock, NULL, RW_DEFAULT, NULL); - mutex_init(&tq->tq_lock, NULL, MUTEX_DEFAULT, NULL); - 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; - tq->tq_minalloc = minalloc; - tq->tq_maxalloc = maxalloc; - tq->tq_task.tqent_next = &tq->tq_task; - tq->tq_task.tqent_prev = &tq->tq_task; - tq->tq_threadlist = kmem_alloc(nthreads * sizeof (thread_t), KM_SLEEP); - - if (flags & TASKQ_PREPOPULATE) { - mutex_enter(&tq->tq_lock); - while (minalloc-- > 0) - task_free(tq, task_alloc(tq, KM_SLEEP)); - mutex_exit(&tq->tq_lock); - } - - for (t = 0; t < nthreads; t++) - (void) thr_create(0, 0, taskq_thread, - tq, THR_BOUND, &tq->tq_threadlist[t]); - - return (tq); -} - -void -taskq_destroy(taskq_t *tq) -{ - int t; - int nthreads = tq->tq_nthreads; - - taskq_wait(tq); - - mutex_enter(&tq->tq_lock); - - tq->tq_flags &= ~TASKQ_ACTIVE; - cv_broadcast(&tq->tq_dispatch_cv); - - while (tq->tq_nthreads != 0) - cv_wait(&tq->tq_wait_cv, &tq->tq_lock); - - tq->tq_minalloc = 0; - while (tq->tq_nalloc != 0) { - ASSERT(tq->tq_freelist != NULL); - task_free(tq, task_alloc(tq, KM_SLEEP)); - } - - mutex_exit(&tq->tq_lock); - - for (t = 0; t < nthreads; t++) - (void) thr_join(tq->tq_threadlist[t], NULL, NULL); - - kmem_free(tq->tq_threadlist, nthreads * sizeof (thread_t)); - - rw_destroy(&tq->tq_threadlock); - mutex_destroy(&tq->tq_lock); - cv_destroy(&tq->tq_dispatch_cv); - cv_destroy(&tq->tq_wait_cv); - cv_destroy(&tq->tq_maxalloc_cv); - - kmem_free(tq, sizeof (taskq_t)); -} - -int -taskq_member(taskq_t *tq, void *t) -{ - int i; - - if (taskq_now) - return (1); - - for (i = 0; i < tq->tq_nthreads; i++) - if (tq->tq_threadlist[i] == (thread_t)(uintptr_t)t) - return (1); - - return (0); -} - -void -system_taskq_init(void) -{ - system_taskq = taskq_create("system_taskq", 64, minclsyspri, 4, 512, - TASKQ_DYNAMIC | TASKQ_PREPOPULATE); -} - -void -system_taskq_fini(void) -{ - taskq_destroy(system_taskq); - system_taskq = NULL; /* defensive */ -} diff --git a/usr/src/lib/libzpool/common/util.c b/usr/src/lib/libzpool/common/util.c index 363940677c..c9da9adca7 100644 --- a/usr/src/lib/libzpool/common/util.c +++ b/usr/src/lib/libzpool/common/util.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016 by Delphix. All rights reserved. + * Copyright 2017 RackTop Systems. */ #include <assert.h> @@ -34,6 +35,8 @@ #include <sys/refcount.h> #include <dlfcn.h> +extern void nicenum(uint64_t num, char *buf, size_t); + /* * Routines needed by more than one client of libzpool. */ diff --git a/usr/src/pkg/manifests/system-library.mf b/usr/src/pkg/manifests/system-library.mf index 523abb44d7..c8cdd6f53f 100644 --- a/usr/src/pkg/manifests/system-library.mf +++ b/usr/src/pkg/manifests/system-library.mf @@ -24,6 +24,7 @@ # Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved. # Copyright (c) 2013 Gary Mills # Copyright 2017 Nexenta Systems, Inc. +# Copyright 2017 RackTop Systems. # <include system-library.man3.inc> @@ -202,6 +203,7 @@ file path=lib/$(ARCH64)/libdlpi.so.1 file path=lib/$(ARCH64)/libdoor.so.1 file path=lib/$(ARCH64)/libefi.so.1 file path=lib/$(ARCH64)/libelf.so.1 +file path=lib/$(ARCH64)/libfakekernel.so.1 $(i386_ONLY)file path=lib/$(ARCH64)/libfdisk.so.1 file path=lib/$(ARCH64)/libgen.so.1 file path=lib/$(ARCH64)/libinetutil.so.1 @@ -280,6 +282,7 @@ file path=lib/libdoor.so.1 file path=lib/libefi.so.1 file path=lib/libelf.so.1 file path=lib/libelfsign.so.1 +file path=lib/libfakekernel.so.1 $(i386_ONLY)file path=lib/libfdisk.so.1 file path=lib/libgen.so.1 file path=lib/libinetutil.so.1 @@ -855,6 +858,8 @@ link path=usr/lib/$(ARCH64)/libelf.so \ link path=usr/lib/$(ARCH64)/libelf.so.1 \ target=../../../lib/$(ARCH64)/libelf.so.1 link path=usr/lib/$(ARCH64)/libexacct.so target=libexacct.so.1 +link path=usr/lib/$(ARCH64)/libfakekernel.so.1 \ + target=../../../lib/$(ARCH64)/libfakekernel.so.1 $(i386_ONLY)link path=usr/lib/$(ARCH64)/libfdisk.so \ target=../../../lib/$(ARCH64)/libfdisk.so.1 $(i386_ONLY)link path=usr/lib/$(ARCH64)/libfdisk.so.1 \ @@ -1108,6 +1113,7 @@ link path=usr/lib/libefi.so.1 target=../../lib/libefi.so.1 link path=usr/lib/libelf.so target=../../lib/libelf.so.1 link path=usr/lib/libelf.so.1 target=../../lib/libelf.so.1 link path=usr/lib/libexacct.so target=./libexacct.so.1 +link path=usr/lib/libfakekernel.so.1 target=../../lib/libfakekernel.so.1 $(i386_ONLY)link path=usr/lib/libfdisk.so target=../../lib/libfdisk.so.1 $(i386_ONLY)link path=usr/lib/libfdisk.so.1 target=../../lib/libfdisk.so.1 link path=usr/lib/libform.so target=./libform.so.1 diff --git a/usr/src/uts/common/fs/zfs/dnode.c b/usr/src/uts/common/fs/zfs/dnode.c index 7bdddfe16c..7018e0f81e 100644 --- a/usr/src/uts/common/fs/zfs/dnode.c +++ b/usr/src/uts/common/fs/zfs/dnode.c @@ -23,6 +23,7 @@ * Copyright (c) 2012, 2017 by Delphix. All rights reserved. * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. * Copyright (c) 2014 Integros [integros.com] + * Copyright 2017 RackTop Systems. */ #include <sys/zfs_context.h> @@ -59,7 +60,9 @@ static dnode_phys_t dnode_phys_zero; int zfs_default_bs = SPA_MINBLOCKSHIFT; int zfs_default_ibs = DN_MAX_INDBLKSHIFT; +#ifdef _KERNEL static kmem_cbrc_t dnode_move(void *, void *, size_t, void *); +#endif /* _KERNEL */ static int dbuf_compare(const void *x1, const void *x2) @@ -213,7 +216,9 @@ dnode_init(void) dnode_cache = kmem_cache_create("dnode_t", sizeof (dnode_t), 0, dnode_cons, dnode_dest, NULL, NULL, NULL, 0); +#ifdef _KERNEL kmem_cache_set_move(dnode_cache, dnode_move); +#endif /* _KERNEL */ } void @@ -405,7 +410,9 @@ dnode_create(objset_t *os, dnode_phys_t *dnp, dmu_buf_impl_t *db, dnode_t *dn; dn = kmem_cache_alloc(dnode_cache, KM_SLEEP); +#ifdef _KERNEL ASSERT(!POINTER_IS_VALID(dn->dn_objset)); +#endif /* _KERNEL */ dn->dn_moved = 0; /* @@ -697,6 +704,7 @@ static struct { } dnode_move_stats; #endif /* DNODE_STATS */ +#ifdef _KERNEL static void dnode_move_impl(dnode_t *odn, dnode_t *ndn) { @@ -833,7 +841,6 @@ dnode_move_impl(dnode_t *odn, dnode_t *ndn) odn->dn_moved = (uint8_t)-1; } -#ifdef _KERNEL /*ARGSUSED*/ static kmem_cbrc_t dnode_move(void *buf, void *newbuf, size_t size, void *arg) diff --git a/usr/src/uts/common/fs/zfs/spa.c b/usr/src/uts/common/fs/zfs/spa.c index cc66deed8e..f273a7c299 100644 --- a/usr/src/uts/common/fs/zfs/spa.c +++ b/usr/src/uts/common/fs/zfs/spa.c @@ -29,6 +29,7 @@ * Copyright 2016 Toomas Soome <tsoome@me.com> * Copyright 2017 Joyent, Inc. * Copyright (c) 2017 Datto Inc. + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. */ /* @@ -4051,6 +4052,9 @@ spa_import_rootpool(char *devpath, char *devid) spa = spa_add(pname, config, NULL); spa->spa_is_root = B_TRUE; spa->spa_import_flags = ZFS_IMPORT_VERBATIM; + if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, + &spa->spa_ubsync.ub_version) != 0) + spa->spa_ubsync.ub_version = SPA_VERSION_INITIAL; /* * Build up a vdev tree based on the boot device's label config. diff --git a/usr/src/uts/common/sys/acl.h b/usr/src/uts/common/sys/acl.h index e546d8a11a..eec11886c4 100644 --- a/usr/src/uts/common/sys/acl.h +++ b/usr/src/uts/common/sys/acl.h @@ -25,6 +25,7 @@ * Use is subject to license terms. * * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + * Copyright 2017 RackTop Systems. */ #ifndef _SYS_ACL_H @@ -158,7 +159,7 @@ typedef struct acl_info acl_t; #define ACE_ALL_TYPES 0x001F -#ifdef _KERNEL +#if defined(_KERNEL) || defined(_FAKE_KERNEL) typedef struct ace_object { uid_t a_who; /* uid or gid */ diff --git a/usr/src/uts/common/sys/bitmap.h b/usr/src/uts/common/sys/bitmap.h index c56b118b98..02d54d2bb5 100644 --- a/usr/src/uts/common/sys/bitmap.h +++ b/usr/src/uts/common/sys/bitmap.h @@ -26,6 +26,7 @@ /* * Copyright (c) 2014 by Delphix. All rights reserved. + * Copyright 2017 RackTop Systems. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -134,7 +135,7 @@ extern "C" { #define BIT_ONLYONESET(u) \ ((((u) == 0) ? 0 : ((u) & ((u) - 1)) == 0)) -#if defined(_KERNEL) && !defined(_ASM) +#if (defined(_KERNEL) || defined(_FAKE_KERNEL)) && !defined(_ASM) #include <sys/atomic.h> /* @@ -188,7 +189,7 @@ extern int odd_parity(ulong_t); */ #define BITX(u, h, l) (((u) >> (l)) & ((1LU << ((h) - (l) + 1LU)) - 1LU)) -#endif /* _KERNEL && !_ASM */ +#endif /* (_KERNEL || _FAKE_KERNEL) && !_ASM */ #ifdef __cplusplus } diff --git a/usr/src/uts/common/sys/bitset.h b/usr/src/uts/common/sys/bitset.h index 99a5f3e236..c1e369bfaf 100644 --- a/usr/src/uts/common/sys/bitset.h +++ b/usr/src/uts/common/sys/bitset.h @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2017 RackTop Systems. */ #ifndef _BITSET_H @@ -29,7 +30,7 @@ extern "C" { #endif -#if (defined(_KERNEL) || defined(_KMEMUSER)) +#if defined(_KERNEL) || defined(_FAKE_KERNEL) || defined(_KMEMUSER) #include <sys/bitmap.h> #include <sys/types.h> @@ -87,7 +88,7 @@ void bitset_zero(bitset_t *); void bitset_copy(bitset_t *, bitset_t *); int bitset_match(bitset_t *, bitset_t *); -#endif /* !_KERNEL && !_KMEMUSER */ +#endif /* _KERNEL || _FAKE_KERNEL || _KMEMUSER */ #ifdef __cplusplus } diff --git a/usr/src/uts/common/sys/buf.h b/usr/src/uts/common/sys/buf.h index bb3a4af182..b6b5c20e44 100644 --- a/usr/src/uts/common/sys/buf.h +++ b/usr/src/uts/common/sys/buf.h @@ -22,6 +22,8 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * Copyright 2012 Joyent, Inc. All rights reserved. + * + * Copyright 2017 RackTop Systems. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -300,7 +302,7 @@ struct dwbuf { (bp)->av_forw = (bp)->av_back = NULL; \ } -#if defined(_KERNEL) +#if defined(_KERNEL) || defined(_FAKE_KERNEL) /* * Macros to avoid the extra function call needed for binary compat. * @@ -405,7 +407,7 @@ void bioreset(struct buf *bp); struct buf *bioclone(struct buf *, off_t, size_t, dev_t, daddr_t, int (*)(struct buf *), struct buf *, int); size_t biosize(void); -#endif /* defined(_KERNEL) */ +#endif /* defined(_KERNEL) || defined(_FAKE_KERNEL) */ #ifdef __cplusplus } diff --git a/usr/src/uts/common/sys/cpupart.h b/usr/src/uts/common/sys/cpupart.h index b44dda5e84..a91c989bbf 100644 --- a/usr/src/uts/common/sys/cpupart.h +++ b/usr/src/uts/common/sys/cpupart.h @@ -20,6 +20,7 @@ */ /* * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2017 RackTop Systems. */ #ifndef _SYS_CPUPART_H @@ -40,7 +41,7 @@ extern "C" { #endif -#ifdef _KERNEL +#if defined(_KERNEL) || defined(_FAKE_KERNEL) typedef int cpupartid_t; @@ -148,7 +149,7 @@ extern uint_t cpupart_list(psetid_t *, uint_t, int); extern int cpupart_setattr(psetid_t, uint_t); extern int cpupart_getattr(psetid_t, uint_t *); -#endif /* _KERNEL */ +#endif /* _KERNEL || _FAKE_KERNEL */ #ifdef __cplusplus } diff --git a/usr/src/uts/common/sys/cpuvar.h b/usr/src/uts/common/sys/cpuvar.h index 0b5d9d9d7b..3ee4e70eec 100644 --- a/usr/src/uts/common/sys/cpuvar.h +++ b/usr/src/uts/common/sys/cpuvar.h @@ -24,6 +24,7 @@ * Copyright (c) 2012 by Delphix. All rights reserved. * Copyright 2014 Igor Kozhukhov <ikozhukhov@gmail.com>. * Copyright 2017 Joyent, Inc. + * Copyright 2017 RackTop Systems. */ #ifndef _SYS_CPUVAR_H @@ -33,6 +34,7 @@ #include <sys/sysinfo.h> /* has cpu_stat_t definition */ #include <sys/disp.h> #include <sys/processor.h> +#include <sys/kcpc.h> /* has kcpc_ctx_t definition */ #include <sys/loadavg.h> #if (defined(_KERNEL) || defined(_KMEMUSER)) && defined(_MACHDEP) @@ -582,9 +584,9 @@ extern struct cpu *curcpup(void); #endif /* defined(_KERNEL) || defined(_KMEMUSER) */ /* - * CPU support routines. + * CPU support routines (not for genassym.c) */ -#if defined(_KERNEL) && defined(__STDC__) /* not for genassym.c */ +#if (defined(_KERNEL) || defined(_FAKE_KERNEL)) && defined(__STDC__) struct zone; @@ -791,7 +793,7 @@ extern void populate_idstr(struct cpu *); extern void cpu_vm_data_init(struct cpu *); extern void cpu_vm_data_destroy(struct cpu *); -#endif /* _KERNEL */ +#endif /* _KERNEL || _FAKE_KERNEL */ #ifdef __cplusplus } diff --git a/usr/src/uts/common/sys/cyclic.h b/usr/src/uts/common/sys/cyclic.h index 1a93cc3f0e..5f28543f9f 100644 --- a/usr/src/uts/common/sys/cyclic.h +++ b/usr/src/uts/common/sys/cyclic.h @@ -21,6 +21,8 @@ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * + * Copyright 2017 RackTop Systems. */ #ifndef _SYS_CYCLIC_H @@ -72,7 +74,7 @@ typedef struct cyc_omni_handler { #define CY_INFINITY INT64_MAX -#ifdef _KERNEL +#if defined(_KERNEL) || defined(_FAKE_KERNEL) extern cyclic_id_t cyclic_add(cyc_handler_t *, cyc_time_t *); extern cyclic_id_t cyclic_add_omni(cyc_omni_handler_t *); @@ -92,7 +94,7 @@ extern void cyclic_resume(); extern void cyclic_fire(cpu_t *cpu); extern void cyclic_softint(cpu_t *cpu, cyc_level_t level); -#endif /* _KERNEL */ +#endif /* _KERNEL || _FAKE_KERNEL */ #endif /* !_ASM */ diff --git a/usr/src/uts/common/sys/fm/util.h b/usr/src/uts/common/sys/fm/util.h index 37334101b3..a9d4d06b02 100644 --- a/usr/src/uts/common/sys/fm/util.h +++ b/usr/src/uts/common/sys/fm/util.h @@ -21,6 +21,7 @@ /* * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2017 RackTop Systems. */ #ifndef _SYS_FM_UTIL_H @@ -70,7 +71,7 @@ typedef struct erpt_dump { } ed_tod_base; } erpt_dump_t; -#ifdef _KERNEL +#if defined(_KERNEL) || defined(_FAKE_KERNEL) #include <sys/systm.h> #define FM_STK_DEPTH 20 /* maximum stack depth */ @@ -94,7 +95,7 @@ extern void fm_ereport_post(nvlist_t *, int); extern void fm_payload_stack_add(nvlist_t *, const pc_t *, int); extern int is_fm_panic(); -#endif /* _KERNEL */ +#endif /* _KERNEL || _FAKE_KERNEL */ #ifdef __cplusplus } diff --git a/usr/src/uts/common/sys/kobj.h b/usr/src/uts/common/sys/kobj.h index a3c31cec85..d52a54f6b7 100644 --- a/usr/src/uts/common/sys/kobj.h +++ b/usr/src/uts/common/sys/kobj.h @@ -21,6 +21,8 @@ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * + * Copyright 2017 RackTop Systems. */ /* * Copyright (c) 2017 Joyent, Inc. @@ -29,8 +31,6 @@ #ifndef _SYS_KOBJ_H #define _SYS_KOBJ_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/modctl.h> #include <sys/elf.h> #include <sys/machelf.h> @@ -169,7 +169,7 @@ typedef struct { #define F_BLKS(file, size) ((size / (file)->_bsize) * (file)->_bsize) -#if defined(_KERNEL) +#if defined(_KERNEL) || defined(_FAKE_KERNEL) extern int kobj_load_module(struct modctl *, int); extern void kobj_unload_module(struct modctl *); @@ -214,7 +214,7 @@ extern void kobj_stat_get(kobj_stat_t *); extern void kobj_textwin_alloc(struct module *); extern void kobj_textwin_free(struct module *); -#endif /* defined(_KERNEL) */ +#endif /* defined(_KERNEL) || defined(_FAKE_KERNEL) */ #ifdef __cplusplus } diff --git a/usr/src/uts/common/sys/lgrp.h b/usr/src/uts/common/sys/lgrp.h index 0d1b24770d..447c9e03fc 100644 --- a/usr/src/uts/common/sys/lgrp.h +++ b/usr/src/uts/common/sys/lgrp.h @@ -22,6 +22,8 @@ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * + * Copyright 2017 RackTop Systems. */ #ifndef _LGRP_H @@ -39,11 +41,11 @@ extern "C" { #define LGRP_NONE (-1) /* non-existent lgroup ID */ -#if (!defined(_KERNEL) && !defined(_KMEMUSER)) +#if !defined(_KERNEL) && !defined(_FAKE_KERNEL) && !defined(_KMEMUSER) typedef struct lgrp_mem_policy_info { int opaque[2]; } lgrp_mem_policy_info_t; -#endif /* !_KERNEL && !_KMEMUSER */ +#endif /* !_KERNEL && !_FAKE_KERNEL && !_KMEMUSER */ -#if (defined(_KERNEL) || defined(_KMEMUSER)) +#if defined(_KERNEL) || defined(_FAKE_KERNEL) || defined(_KMEMUSER) #include <sys/cpuvar.h> #include <sys/bitmap.h> #include <sys/vnode.h> @@ -631,7 +633,7 @@ extern uint32_t lgrp_loadavg_max_effect; extern uint32_t lgrp_load_thresh; extern lgrp_mem_policy_t lgrp_mem_policy_root; -#endif /* _KERNEL && _KMEMUSER */ +#endif /* _KERNEL || _FAKE_KERNEL || _KMEMUSER */ #ifdef __cplusplus } diff --git a/usr/src/uts/common/sys/lgrp_user.h b/usr/src/uts/common/sys/lgrp_user.h index cf9a04ab21..13d54c7ce3 100644 --- a/usr/src/uts/common/sys/lgrp_user.h +++ b/usr/src/uts/common/sys/lgrp_user.h @@ -21,6 +21,7 @@ */ /* * Copyright 2014 Garrett D'Amore <garrett@damore.org> + * Copyright 2017 RackTop Systems. * * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. @@ -242,7 +243,7 @@ typedef struct lgrp_snapshot_header32 { #endif /* _SYSCALL32 */ -#if (!defined(_KERNEL) && !defined(_KMEMUSER)) +#if !defined(_KERNEL) && !defined(_FAKE_KERNEL) && !defined(_KMEMUSER) lgrp_affinity_t lgrp_affinity_get(idtype_t idtype, id_t id, lgrp_id_t lgrp); @@ -285,7 +286,7 @@ int lgrp_version(int version); lgrp_view_t lgrp_view(lgrp_cookie_t cookie); -#endif /* !_KERNEL && !_KMEMUSER */ +#endif /* !_KERNEL && !_FAKE_KERNEL && !_KMEMUSER */ #ifdef __cplusplus } diff --git a/usr/src/uts/common/sys/systeminfo.h b/usr/src/uts/common/sys/systeminfo.h index b148a3ed82..a664a19b9e 100644 --- a/usr/src/uts/common/sys/systeminfo.h +++ b/usr/src/uts/common/sys/systeminfo.h @@ -20,6 +20,7 @@ */ /* * Copyright 2014 Garrett D'Amore <garrett@damore.org> + * Copyright 2017 RackTop Systems. * * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. @@ -36,14 +37,14 @@ extern "C" { #endif -#ifdef _KERNEL +#if defined(_KERNEL) || defined(_FAKE_KERNEL) extern char architecture[]; extern char architecture_32[]; extern char hw_serial[]; /* machine's 32-bit hostid; a decimal string */ extern char hw_provider[]; extern char srpc_domain[]; extern char platform[]; -#endif /* _KERNEL */ +#endif /* _KERNEL || _FAKE_KERNEL */ /* * Commands to sysinfo(2) diff --git a/usr/src/uts/common/sys/taskq_impl.h b/usr/src/uts/common/sys/taskq_impl.h index dcb7290155..59aae4db8f 100644 --- a/usr/src/uts/common/sys/taskq_impl.h +++ b/usr/src/uts/common/sys/taskq_impl.h @@ -25,6 +25,7 @@ /* * Copyright 2011 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2017 by Delphix. All rights reserved. + * Copyright 2017 RackTop Systems. */ #ifndef _SYS_TASKQ_IMPL_H @@ -35,6 +36,7 @@ #include <sys/vmem.h> #include <sys/list.h> #include <sys/kstat.h> +#include <sys/rwlock.h> #ifdef __cplusplus extern "C" { diff --git a/usr/src/uts/common/sys/vnode.h b/usr/src/uts/common/sys/vnode.h index 82511132ff..8dfd36353b 100644 --- a/usr/src/uts/common/sys/vnode.h +++ b/usr/src/uts/common/sys/vnode.h @@ -23,6 +23,7 @@ * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, Joyent, Inc. * Copyright (c) 2011, 2017 by Delphix. All rights reserved. + * Copyright 2017 RackTop Systems. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -340,6 +341,7 @@ typedef struct vnode { #define IS_SWAPVP(vp) (((vp)->v_flag & (VISSWAP | VSWAPLIKE)) != 0) +#ifdef _KERNEL typedef struct vn_vfslocks_entry { rwstlock_t ve_lock; void *ve_vpvfs; @@ -348,6 +350,7 @@ typedef struct vn_vfslocks_entry { char pad[64 - sizeof (rwstlock_t) - 2 * sizeof (void *) - \ sizeof (uint32_t)]; } vn_vfslocks_entry_t; +#endif /* * The following two flags are used to lock the v_vfsmountedhere field diff --git a/usr/src/uts/common/vm/seg_kmem.h b/usr/src/uts/common/vm/seg_kmem.h index 3ad4202e91..1db85826b1 100644 --- a/usr/src/uts/common/vm/seg_kmem.h +++ b/usr/src/uts/common/vm/seg_kmem.h @@ -22,6 +22,7 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * Copyright 2016 Joyent, Inc. + * Copyright 2017 RackTop Systems. */ #ifndef _VM_SEG_KMEM_H @@ -43,7 +44,7 @@ extern "C" { * VM - Kernel Segment Driver */ -#if defined(_KERNEL) +#if defined(_KERNEL) || defined(_FAKE_KERNEL) extern char *kernelheap; /* start of primary kernel heap */ extern char *ekernelheap; /* end of primary kernel heap */ @@ -139,7 +140,7 @@ extern size_t segkmem_kmemlp_max; extern struct seg_ops segkmem_ops; -#endif /* _KERNEL */ +#endif /* _KERNEL || _FAKE_KERNEL */ #ifdef __cplusplus } |